akhauriyash/Code-Regression huggingface dataset:
package main

import(
    "fmt"
    "sort"
    "strings"
)

func digitsum(a int) int{
    ret := 0
    for a>0{
        ret+=a%10
        a/=10
    }
    return ret
}

func main() {
    var n,a,b int
    fmt.Scan(&n,&a,&b)
    ans := 0
    for i:=1;i<=n;i++{
        k := digitsum(i)
        if k>=a && k<=b{
            ans+=i
        }
    }
    fmt.Println(ans)
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


Measured memory_bytes: 640
N,M=map(int,input().split())
f=[set() for i in range(N)]
v=[False]*N
g=[]

for i in range(0,M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    f[a].add(b)
    f[b].add(a)

for i in range(0,N):
    if v[i]:
        continue
    s=set()
    q=[i]
    while len(q)>0:
        p=q.pop()
        v[p]=True
        s.add(p)
        for x in f[p]:
            if v[x]:
                continue
            q.append(x)
    g.append(s)

z=0
for x in g:
    z=max(z,len(x))

print(z)

Measured memory_bytes: 160784
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N,A,B;
  cin>>N>>A>>B;
  int ans=0;
for (int i = 1; i <= N; i++) {
 int x=i;
 int sum=0;
  for (int j = 0; j < 5; j++) {
 sum += x%10;
    x /=10;
}
if(A<=sum&&sum<=B){
  ans+=i;
}
}
cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i < n; i++)
#define INF 1001001001
#define LINF (1LL << 62)
using namespace std;
using ll = long long;
using P = pair<int,int>;

void solv() {
    set<int> count;
    rep(i,3){
        int buf;
        cin >> buf;
        count.insert(buf);
    }
    cout << count.size() << endl;
}

int main() {
    solv();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
long long MOD = 1000000007;


template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }


int main(){
    int D, T, S;
    cin >> D >> T >> S;

    if(D<= T*S)cout << "Yes" << endl;
    else cout << "No" << endl; 
}



Measured memory_bytes: 3600
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>

using namespace std;

typedef pair<int,int> pii;

const int N=100010;

struct node{
	node *ls,*rs;
	int val;
}b[N],*rt[N];

int n,m,fa[N],a[N];

int getfa(int x){
	return x==fa[x]?x:fa[x]=getfa(fa[x]);
}

inline int ran(){
	static int x=31253125; x+=(x<<4)+5; return x&65536;
}

node *Merge(node *x,node *y){
	if(!x || !y) return !x?y:x;
	if(x->val>y->val) swap(x,y);
	ran()?x->ls=Merge(x->ls,y):x->rs=Merge(x->rs,y);
	return x;
}

priority_queue<pii> Q;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) 
		scanf("%d",&a[i]),rt[i]=b+i,rt[i]->val=a[i],fa[i]=i;
	for(int i=1;i<=m;i++){
		int x,y; scanf("%d%d",&x,&y); x++; y++;
		x=getfa(x); y=getfa(y);
		if(x==y) continue;
		rt[x]=Merge(rt[x],rt[y]);
		fa[y]=x;
	}
	int cnt=0; long long ans=0;
	node *c; c=0;
	for(int i=1;i<=n;i++)
		if(getfa(i)==i){
			cnt++; ans+=rt[i]->val;
			rt[i]=Merge(rt[i]->ls,rt[i]->rs);
			c=Merge(c,rt[i]);
		}
	if(cnt==1) return puts("0"),0;
	int cur=0;
	while(c && cur<cnt-2){
		ans+=c->val; c=Merge(c->ls,c->rs); cur++;
	}
	if(cur==cnt-2) printf("%lld\n",ans);
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  vll arr(n), cum(n);
  mllll m;
  fi(0, n) {
    cin >> arr[i];
    cum[i] = arr[i];
    if(i > 0) {
      cum[i] += cum[i - 1];
    }
    m[cum[i]]++;
  }
  for(auto x: m) {
    ll cnt = x.second;
    if(x.first == 0)
      cnt++;
    ans += cnt * (cnt - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;

int main() {
  
  int64_t X; cin >> X;
  
  int64_t ans = 1;
  
  while (true) {
    
    int64_t sum = ans * (ans + 1) / 2;
    
    if (X <= sum) { cout << ans << endl; return 0; }
    
    ans++;
    
  }
  
}

Measured memory_bytes: 3596
//#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))


int main() {
	int n;
	cin>>n;
	vector<int> v(n+1);
	v.at(0)=0;
	rep(i,n){
		int w;
		cin>>w;
		v.at(i+1)=v.at(i)+w;
	}
	int m=100;

	rep(j,n){
		m = min(m,abs(v.at(n)-v.at(j+1)*2));

	}
	cout<<m<<endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include <math.h>
#include <climits>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
using namespace std;

/* sample input

*/

long long n, m;
long long answer;
long long mod = 1000000007;
int main()
{
	cin >> n >> m;

	if (abs(n - m) > 1){
		cout << 0;
		return 0;
	}

	answer = 1;
	if (abs(n - m) == 1){
		//cout << "odd" << endl;
		//(n!m!%(10^9+7)
		for (int i = 1; i <= n; i++){
			answer = answer*i;
			answer = answer %mod;
		}
		for (int i = 1; i <= m; i++){
			answer = answer*i;
			answer = answer %mod;
		}
	}
	else{
		//cout << "even" << endl;
		//(2*n!m!)%(10^9+7)
		for (int i = 1; i <= n; i++){
			answer = answer*i;
			answer = answer %mod;
		}
		answer = (2 * answer*answer) % mod;
	}

	cout << answer;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,n,s;
  while(cin>>a>>b>>n){
    a%=b;
    s=0;
    for(int i=0;i<n;i++){
      a*=10;
      s+=a/b;
      a%=b;
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>

int main(){
    int A, B;
    std::cin >> A >> B;
    int coin = 0;
    if(A > B){
        coin += A;
        A--;
    }else{
        coin += B;
        B--;
    }
    if(A > B){
        coin += A;
    }else{
        coin += B;
        B--;
    }
    std::cout << coin << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    ll n, x, m;
    cin >> n >> x >> m;
    pair<int, ll> dp[m + 1][41];
    fill(dp[0], dp[m + 1], pair<ll, ll>(0, 0));
    for (int i = 0; i <= m; i++) {
        dp[i][0].first = ((ll)i * i) % m;
        dp[i][0].second = ((ll)i * i) % m;
    }
    for (int i = 0; i < 40; i++) {
        for (int j = 0; j <= m; j++) {
            dp[j][i + 1].first = dp[dp[j][i].first][i].first;
            dp[j][i + 1].second =
                dp[j][i].second + dp[dp[j][i].first][i].second;
        }
    }
    int cur = x;
    ll ans = x;
    for (int i = 40; i >= 0; i--) {
        if (n >= (1LL << i)) {
            ans += dp[cur][i].second;
            cur = dp[cur][i].first;
            n -= (1LL << i);
        }
    }
    cout << ans - cur << endl;
    return 0;
}

Measured memory_bytes: 67672
#include<bits/stdc++.h>
using namespace std;

inline void InitRand(){
    srand((unsigned int)time(NULL));
}

int main(){
    int n;
    cin >> n;
    vector<int> t(n), x(n), y(n);
    for(int i = 0; i < n; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    for(int i = 0; i < n; i++){
        if(t[i] < x[i] + y[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i = 0; i < n-1; i++){
        if(x[i] == x[i+1] && y[i] == y[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }

    for(int i = 0; i < n-1; i++){
        InitRand();
        if(abs(t[i]-t[i-1]) < abs((x[i] + y[i])-(x[i+1] + y[i+1])) && rand() % 2 + 1 == 1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); (i)++)
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

struct Edge {
   int to, cost;
};
const ll INF = 1e18;
int N, M;
vec<vec<Edge>> G;

void dfs(int pos, vec<ll> &dist) {
   for (Edge e : G[pos]) {
      if (dist[e.to] == INF) {
         dist[e.to] = dist[pos] + e.cost;
         dfs(e.to, dist);
      }
   }
}

int main() {
   cin >> N >> M;
   G = vec<vec<Edge>>(N);
   rep (i, 0, M) {
      int l, r, d;
      cin >> l >> r >> d;
      l--, r--;
      G[l].push_back(Edge{r, d});
      G[r].push_back(Edge{l, -d});
   }

   vec<ll> dist(N, INF);
   rep (i, 0, N) {
      if (dist[i] == INF) {
         dist[i] = 0;
         dfs(i, dist);
      }
   }

   rep (i, 0, N) {
      for (Edge e : G[i]) {
         if (dist[e.to] - dist[i] != e.cost) {
            puts("No");
            return 0;
         }
      }
   }
   puts("Yes");

   return 0;
}

Measured memory_bytes: 12416
using System;
using static System.Console;

class plmko{
  static void Main(){
    int a = int.Parse(ReadLine());
    int b = 111;
    int i =0;
    while(b*i<=a){
      i++;
      if(b*i>=a){
        WriteLine(b*i);
        break;
      }
    }
  }
}

Measured memory_bytes: 13140
/*
  AUTHOR:SOURABH
  CREATED:19:09:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 998244353
#define MAXN 10000001
#define M 32

using namespace std;
using namespace __gnu_pbds;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    //freopen("input.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,n,x,m,q,rem,l,r,i,st,curr,sum,ans;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n>>x>>m;
        vll a(m);
        ans=0;
        curr=x;
        l=min(m+5,n+1);
        fs(i,1,min(m+5,n+1))
        {
            if(a[curr])
            {l=a[curr],r=i;break;}
            else
            a[curr]=i;
            curr=(curr*curr)%m;
        }

        curr=x;
        fs(i,1,l)
        {
            ans+=curr;
            curr=(curr*curr)%m;
        }

        if(l<=n){
        q=(r-l);
        sum=0;
        st=curr;
        fs(i,l,r)
        {
            sum+=curr;
            curr=(curr*curr)%m;
        }
        ans=ans+((n-l+1)/q)*sum;
        rem=(n-l+1)%q;
        curr=st;
        fs(i,l,l+rem)
        {
            ans+=curr;
            curr=(curr*curr)%m;
        }
        }
        cout<<ans;
    }
}










Measured memory_bytes: 3984
#include<stdio.h>
int main(void)
{
  int i,j;
  int ymd[100][3], n, y3=590, date;

  scanf("%d", &n);
  for(i=0; i<n; i++) {
    for(j=0; j<3; j++) {
      scanf("%d", &ymd[i][j]);
    }
  }

  for(i=0;i<n;i++) {
    date = 0;
    date += ((ymd[i][0]-1)/3)*y3;
    switch(ymd[i][0]%3){
    case 2:
      date += 195;
      for(j=0;j<ymd[i][1]-1;j++) {
	j%2 ? (date += 19):(date += 20);
      }
      date += ymd[i][2];
      break;
      
    case 1:
      for(j=0;j<ymd[i][1]-1;j++) {
	j%2 ? (date += 19):(date += 20);
      }
      date += ymd[i][2];
      break;
      
    case 0:
      date += 390;
      for(j=0;j<ymd[i][1]-1;j++) {
	date += 20;
      }
      date += ymd[i][2];
      break;
    }
    printf("%d\n", 196471 - date);
  }

  for(i=0;i<100000;i++)

  return 0;
}
      

      

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[1]-a[0]==a[2]-a[1]) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
li = list(map(lambda x:int(x)*2,input().split()))
num = 0
for i,b in enumerate(li[1:]):
  if i%2==0:
    num += b
  else:
    num -= b
x = (li[0]-num)//2
print(x,end=" ")
for i in range(n-1):
  x = li[i]-x
  print(x,end=" ")

Measured memory_bytes: 14164
#include <bits/stdc++.h>

using namespace std;
int main(){
    int H,W;
    cin >> H >> W;
    char a[100][100];
    for(int i = 0; i < H; i++){
        for(int j = 0;j < W; j++){
            cin >> a[i][j];
        }    
    }
    vector<int> b;
    int k = 0;
    for(int i = 0; i < W; i++){
        while(a[k][i] == '.'){
            k++;
        }
        if(k < H){
            b.push_back(i);
        }
        k = 0;
    }
    for(int i = 0; i < H; i++){
        while(a[i][k] == '.'){
            k++;
        }
        if(k < W){
            for(int j = 0; j < b.size(); j++){
                cout << a[i][b[j]];
            } 
            cout << endl;
        }
        k = 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char enl = '\n';
#define rep(i, from, to) for (int i = from; i < (to); ++i)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<pair<int, int>> vii;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin.exceptions(cin.failbit);

    int n;
    cin >> n;
    vi a(n);
    bool allsame = true;
    set<int> distinct;
    rep(i,0,n) {
        cin >> a[i];
        distinct.insert(a[i]);
    }
    int xa = a[0];
    int ya = a[0];
    rep(i,1,n) {
        if (a[i] != a[i-1]) allsame = false;
        xa = min(a[i], xa);
        ya = max(a[i], ya);
    }
    if (distinct.size() > 2) {
        cout << "No" << endl;
        return 0;
    }

    if (allsame) {
        int aa = a[0];
        if (aa+1 == n) {
            cout << "Yes" << endl;
            return 0;
        }
        if (aa <= n / 2) {
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;
        return 0;
    }
    if (xa + 1 != ya) {
        cout << "No" << endl;
        return 0;
    }

    int x = 0;
    int y = 0;
    rep(i,0,n) {
        if (a[i] == xa) x++;
        if (a[i] == ya) y++;
    }

    if (x + (y/2) >= xa+1) {
        if (x + 1 <= xa+1) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;





    return 0;
}


Measured memory_bytes: 5376
/*
 * atcoder/abc089/b.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
void solve();
int main() { solve(); return 0; }

#define ld long double
void solve() {
  string s;
  cin >> s;
  s = "ABC" + s;	
  cout << s << endl;
}


Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
#include<assert.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")
#define charsize 100005 //10^5+5

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a= c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){n+= n<0?((-n)/MOD1+1)*MOD1:0; return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

int main(void){
    // char ;
    ll n,m,x,ans=0;
    scanf("%lld%lld%lld",&n,&m,&x);
    ll a[m];
    rep(i,0,m){
        scanf("%lld",&a[i]);
    }
    rep(i,0,m){
        if(a[i]<x){
            ans++;
        }
    }
    ans = min2(ans,m-ans);

    
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#define int long long
#define r(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin,v.end()
using namespace std;
typedef pair<int,int>P;
int main(){
  int a;
  cin>>a;
  int ans=0;
  for(int i=1;i<=100;i++){
    for(int j=2;j<100;j++){
      int b=i*i;
      int k=j-2;
      while(b<=a&&k){
        ans=max(b,ans);
        b*=i;
        k--;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
struct UnionFind{
  int n;
  vector<int>p;
  UnionFind(int s):n(s),p(s,0){iota(p.begin(),p.end(),0);}
  int find(int x){return (x==p[x]?x:p[x]=find(p[x]));}
  void unite(int x,int y){
    x=find(x);y=find(y);
    p[y]=x;
  }
};
main(){
  map<P,int>m;
  int n,m1,m2,a,b,l[200009],r[200009];
  cin>>n>>m1>>m2;
  UnionFind u1(n),u2(n);
  r(i,m1){
    cin>>a>>b;
    u1.unite(a-1,b-1);
  }
  r(i,m2){
    cin>>a>>b;
    u2.unite(a-1,b-1);
  }
  r(i,n)l[i]=u1.find(i),r[i]=u2.find(i);
  r(i,n)m[P(l[i],r[i])]++;
  r(i,n)cout<<m[P(l[i],r[i])]<<endl;
}

Measured memory_bytes: 15872
N, L = map(int,input().split())

taste_abs = [abs(L+i-1) for i in range(1,N+1)]
taste = [L+i-1 for i in range(1,N+1)]
pie_all = sum(taste)

dec = min(taste_abs)
idx = taste_abs.index(dec)

print(pie_all-taste[idx])

Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>

typedef long long ll;

#define rep(i,n) for(int i = 0; i < n; i++)
#define debug(x) cerr << #x << ": " << x << "\n";

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int N;
  string S;
  cin >> N >> S;

  int r=0,g=0,b=0;
  rep(i,N){
    if(S[i] == 'R') r++;
    if(S[i] == 'G') g++;
    if(S[i] == 'B') b++;
  }

  ll ans = r*g*b;
  for(int i = 0; i <= N-3; i++){
    for(int j = i+1; j <= N-2; j++){
      int k = 2*j-i;
      if(k<0 || N<=k) continue;
      if(S[i]!=S[j] && S[i]!=S[k] && S[j]!=S[k]) ans--;      
    }  
  }
  cout << ans << endl;
}


Measured memory_bytes: 3236
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		while (true) {

			int x = sc.nextInt();
			int y = sc.nextInt();
			int s = sc.nextInt();

			int max = 0;

			if (x == 0 && y == 0 && s == 0) {
				break;
			}

			for (int i = 1; i < s; i++) {
				for (int j = 1; j < s; j++) {

					int a = i * (100 + x) / 100;
					int b = j * (100 + x) / 100;

					if (a + b == s) {
						int c = i * (100 + y) / 100;
						int d = j * (100 + y) / 100;

						int sum = c + d;

						if (sum > max) {
							max = sum;
						}
					}
				}
			}

			System.out.println(max);
		}
	}
}

Measured memory_bytes: 20932
from itertools import product

H, W, K = map(int, input().split(' '))
s = [input() for i in range(H)]
ans = 0
for i in product([0, 1], repeat=H + W):
    h = list(i[:H])
    w = list(i[H:])
    tmp = 0
    for j in range(H):
        for k in range(W):
            if h[j] == w[k] == 0 and s[j][k] == "#":
                tmp += 1
    if tmp == K:
        ans += 1
print(ans)


Measured memory_bytes: 9108
import java.util.Scanner;

public class Main {

    public Main() {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.next();
        String T = scanner.next();

        int R = 0;
        for (int i = 0; i < S.length(); i++) {
            if (S.charAt(i) != T.charAt(i))
                R++;
        }

        System.out.println(R);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 41308
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int result = 0;
        int a[] = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        for (int i = 0; i < N; i++) {
            if ((i + 1) % 2 != 0 && a[i] % 2 != 0) {
                result++;
            }
        }

        PrintWriter out = new PrintWriter(System.out);
        out.println(result);
        out.flush();
        sc.close();
    }
}

Measured memory_bytes: 35664
#include <stdio.h>
#include <string.h>

int main(){
	char str1[100], str2[100], str3[200];
	int i, one=0, two=0;
	
	scanf("%s", &str1);
	scanf(" %s", &str2);
	
	for(i=0; i<(strlen(str1)+strlen(str2)); i++){
		if(i%2==0){
			str3[i] = str1[one];
		//	strcpy(str3[i], str1[one]);
			one++;
		}
		else if(i%2==1){
			str3[i] = str2[two];
		//	strcpy(str3[i], str2[two]);
			two++;
		}	
	}
	str3[i] = '\0';

	printf("%s\n", str3);

	//getchar();
	//getchar();
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,M; cin>>N>>M;
  vi X(N),Y(N),x(M),y(M);
  rep(i,0,N) cin>>X[i]>>Y[i];
  rep(i,0,M) cin>>x[i]>>y[i];
  rep(i,0,N){
    int ans,memo=MOD;
    rep(j,0,M){
      int K=abs(X[i]-x[j])+abs(Y[i]-y[j]);
      if(K<memo){
        ans=j+1;
        memo=K;
      }
    }
    cout<<ans<<endl;
  }
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    int main()
    {
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d))
    printf("Yes");
    else
    printf("No");
    }

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	for(int w, h; cin >> w >> h, w;) {
		vector<vector<int> > horizontal(h, vector<int>(w - 1));
		vector<vector<int> > vertical(h - 1, vector<int>(w));
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w - 1; ++j)
				cin >> horizontal[i][j];

			if(i + 1 < h)
				for(int j = 0; j < w; ++j)
					cin >> vertical[i][j];
		}

		vector<vector<int> > label(h, vector<int>(w, 0));
		label[0][0] = 1;
		queue<pair<int, int> > que;
		que.push(make_pair(0, 0));

		while(!que.empty()) {
			const int x = que.front().first, y = que.front().second;
			que.pop();

			if(x > 0 && !label[y][x - 1] && !horizontal[y][x - 1]) {
				label[y][x - 1] = label[y][x] + 1;
				que.push(make_pair(x - 1, y));
			}
			if(y > 0 && !label[y - 1][x] && !vertical[y - 1][x]) {
				label[y - 1][x] = label[y][x] + 1;
				que.push(make_pair(x, y - 1));
			}
			if(x < w - 1 && !label[y][x + 1] && !horizontal[y][x]) {
				label[y][x + 1] = label[y][x] + 1;
				que.push(make_pair(x + 1, y));
			}
			if(y < h - 1 && !label[y + 1][x] && !vertical[y][x]) {
				label[y + 1][x] = label[y][x] + 1;
				que.push(make_pair(x, y + 1));
			}
		}

		cout << label[h - 1][w - 1] << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1244
import java.util.Scanner;

/**
 * Created by zzt on 17-1-22.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];

        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
            B[i] = scanner.nextInt();
        }

        long ret = 0;
        for (int i = N - 1; i >= 0; i--) {
            long mod = (A[i] + ret) % B[i];
            if (mod != 0)
                ret += (B[i] - mod);
        }

        System.out.println(ret);
    }
}

Measured memory_bytes: 48748
n,m = map(int,input().split())
s=[False]*n
t=[False]*n
for i in range(m):
  a,b=map(int,input().split())
  if a==1:
    s[b-1]=True
  if b==n:
    t[a-1]=True
for i in range(n):
  if s[i]==True and t[i]==True:
    print('POSSIBLE')
    exit()
print('IMPOSSIBLE')

Measured memory_bytes: 11944
#include <bits/stdc++.h>
using namespace std;

int main(){
    long int  A , B;
    cin >> A >> B;
    unsigned long  x = A * B;
    if(A < B){
        int tmp = A;
        A = B;
        B = tmp;
    }
    long  r = A % B;
    while(r != 0) {
        A = B;
        B = r;
        r = A % B;
    }
    cout << x/B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int a, b;

int main() {
    cin >> a >> b;

    int sml = min(a, b);
    int lrg = max(a, b);

    for (int i = 0; i < lrg; i++) {
        cout << sml;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
using namespace std;

int main() {
	int k,n;cin>>k>>n;
	vector<int> a(n);
	int maxd=0;
	long long sum=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(i){
			maxd=max(maxd,a[i]-a[i-1]);
		}
	}
	maxd=max(maxd,a[0]+k-a[n-1]);
	cout<<k-maxd<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    //bool hasnext = true;
    bool isfirst = true;

    while(cin >> s){
        if(s[s.size() - 1] == ',' || s[s.size() - 1] == '.'){
            s = s.substr(0, s.size() - 1);
        }
        if(3 <= s.size() && s.size() <= 6){
             if(isfirst == false)
                cout << " ";
            cout << s;
            isfirst = false;
        }
    }
    cout << endl;

    
    // while(hasnext){
    //     cin >> s;
    //     if(s[s.size() - 1] == ',')
    //         s = s.substr(0, s.size() - 1);
    //     if(s[s.size() - 1] == '.'){
    //         s = s.substr(0, s.size() - 1);
    //         hasnext = false;
    //     }
    //     if(3 <= s.size() && s.size() <= 6){
    //         if(isfirst == false)
    //             cout << " ";
    //         cout << s;
    //         isfirst = false;
    //     }
    // } 
    // cout << endl;  
}



Measured memory_bytes: 3076
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<long long> nums(n);
  for(int i=0;i<n;i++)
    cin>>nums[i];
  long long p=1;
  long long v=1e18;
  sort(nums.begin(),nums.end());
  for(int i=0;i<n;i++)
  {
    if(nums[i]==0)
    {
      cout<<0;
      return 0;
    }
    if(p<=(v/nums[i]))
       p*=nums[i];
    else
       {
         cout<<-1;
         return 0;
       }
  }
       cout<<p;
}

Measured memory_bytes: 4048
#include<iostream>
using namespace std;

int main(){
    int i, j, n, m, A[100][100] = {}, b[100] = {}, c;
    cin >> n >> m;
    for (i = 0; i < n; i++) {
        for (j = 0; j < m; j++) {
            cin >> A[i][j];
        }   
    }
    for (j = 0; j < m; j++) {
        cin >> b[j];
    } 
    for (i = 0; i < n; i++) {
        c = 0;
        for (j = 0; j < m; j++){
            c += A[i][j] * b[j];
        }
        cout << c << endl;
    }
    return 0;
}


Measured memory_bytes: 3144
# https://atcoder.jp/contests/abc129/tasks/abc129_e
# 問題文
# 正整数 L が二進数表記で与えられます。 
# 以下の条件を満たす非負整数 a,b の組 (a,b) がいくつ存在するか求めてください
# a+b≤L
# a+b=a XOR b
# ただし、この値は非常に大きくなることがあるので、
# 109+7 で割った余りを出力してください。
# XOR とは制約Lは二進数表記で与えられ、
# 先頭文字は必ず 1 である
# 1≤L<2**100001

# 1111111111111111111
# 162261460

MOD = (10**9) + 7

L = gets.chomp
dp = Array.new(2) {[]}
dp[0][0] = 1
dp[1][0] = 0

counter = 0
L.bytes do |b|
  if b == 49
    dp[0][counter+1] = (dp[0][counter] * 2)%MOD
    dp[1][counter+1] = (dp[0][counter] + (dp[1][counter] * 3)%MOD)%MOD
  else
    dp[0][counter+1] = dp[0][counter]
    dp[1][counter+1] = (dp[1][counter] * 3)%MOD
  end
  counter += 1
end

puts (dp[0].last + dp[1].last)%MOD

Measured memory_bytes: 3836
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int W = scn.nextInt();
		int[] DP = new int[W+1];
		for(int i = 0;i < N;i++) {
			int val = scn.nextInt(), w = scn.nextInt();
			for(int j = W;j >0;j--) {
				if(j >= w) {
					DP[j] = Math.max(DP[j], DP[j-w] + val);
				}
			}
		}

		System.out.println(DP[W]);
		scn.close();
	}
}


Measured memory_bytes: 27108
#include <stdio.h>

int main() {
	int n, j, ans;
	int a[16666670*2] = {};
	long int k;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%ld", &k);
		int s = k / 30, t = k % 30;
		if ((a[s] & (0b1 << t)) == 0)
		{
			a[s] = a[s] | (0b1 << t);
			ans++;
		}
		else
		{
			a[s] = a[s] & ~(0b1 << t);
			ans--;
		}
	}

	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 130432
let n, k = Scanf.scanf "%d %d\n" (fun a b -> a, b)
let ds = Array.init k (fun _ -> Scanf.scanf "%c " (fun x -> x))

let rec solve p =
  if (Array.fold_left (fun pre c ->
      pre || String.contains (string_of_int p) c) false ds)
  then solve (p + 1)
  else p

let () = solve n |> Printf.printf "%d\n"

Measured memory_bytes: 2560
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if A[i] + A[i+1] > x:
        diff = A[i] + A[i+1] - x
        ans += diff
        if A[i+1] >= diff:
            A[i+1] -= diff
        else:
            diff -= A[i+1]
            A[i+1] = 0
            A[i] -= diff
print(ans)

Measured memory_bytes: 14068
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H, W, M;
	cin >> H >> W >> M;

	vector<int> CR(H), CC(W);
	vector<pii> B(M);

	int y, x;
	rep(i, 0, M)
	{
		cin >> y >> x;
		x--,y--;
		B[i] = mp(x, y);
		CR[y]++;
		CC[x]++;
	}

	set<int> RS, CS;

	int ans = 0;
	int ma = 0;
	rep(i, 0, H)chmax(ma, CR[i]);	
	rep(i, 0, H)if (CR[i] == ma)RS.insert(i);
	ans += ma;

	ma = 0;
	rep(i, 0, W)chmax(ma, CC[i]);
	rep(i, 0, W)if (CC[i] == ma)CS.insert(i);
	ans += ma;

	int cnt = 0;
	rep(i, 0, M)
	{
		if (RS.find(B[i].second) != RS.end() && CS.find(B[i].first) != CS.end())
		{
			cnt++;
		}
	}

	if (cnt == SZ(RS)*SZ(CS))
	{
		ans--;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 40656
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>K>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  vector<int> B(N-1);
  for(int i=0;i<N-1;i++){
    B.at(i)=A.at(i+1)-A.at(i);
  }
  B.push_back(K-A.at(N-1)+A.at(0));
  sort(B.begin(),B.end());
  cout<<K-B.at(N-1)<<endl;
}


Measured memory_bytes: 5608
/*************************************************************************
    > File Name: A.cpp
    > Author: Roundgod
    > Mail: wcysai@foxmail.com 
    > Created Time: 2018-05-23 14:11:50
 ************************************************************************/

#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll a,b,c,k;
int main()
{
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
    ll res=a-b;
    printf("%lld\n",res*((k&1)?-1:1));
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <limits>

using namespace std;

int main(){
  int N;
  scanf("%d", &N);

  int X[N];
  for(int i=0; i<N; i++){
    scanf("%d", &X[i]);
  }

  int minX = INT32_MAX;
  for(int i=1; i<=100; i++){
    int XX = 0;
    XX = 0;
    for(int j=0; j<N; j++){
      XX += (X[j]-i) * (X[j]-i);
    }
    if(XX < minX) minX = XX;
  }
  
  cout << minX << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 10000000000
#define MOD 1000000007

int main()
{
	ll ans = INF;
	ll H, W;
	
	cin >> H >> W;

	
	// 縦3、上1下2、横3、左1右2の4パターンを考えればよい
	// 4パターンの中でのSmax - Sminの最小値が答え
	ll s1, s2, s3;
	// 縦3
	// 一番上の長方形の縦の長さをh1(1 ≦ h1 ≦ H - 2)として全探索
	// 下は最低2は残しておかないと3つに分けられない
	for (int h1 = 1; h1 <= H - 2; h1++) {
		// 一番上の長方形の面積
		s1 = h1 * W;
		// 下2つの長方形はできるだけ均等に分ける
		// つまり縦の長さは片方が(H - h1) / 2(小数点以下切り捨て)で、もう片方が(H - h1) - ((H - h1) / 2)
		// 横の長さはWで固定
		// h2 ≦ h3なので、s2 ≦ s3となるはず
		ll h2, h3;
		h2 = (H - h1) / 2;
		h3 = (H - h1) - h2;
		s2 = h2 * W;
		s3 = h3 * W;
		ll smax, smin;
		if (s1 >= s3) { // s1がsmaxの場合
			smax = s1;
			smin = s2;
		} else { // s3がsmaxの場合
			smax = s3;
			smin = min(s1, s2);
		}
		if (ans > smax - smin) { // 今までで最小なら更新
			ans = smax - smin;
		}
	}
	// 上1下2
	// 一番上の長方形の縦の長さをh1(1 ≦ h1 ≦ H - 1)として全探索
	for (int h1 = 1; h1 <= H - 1; h1++) {
		// 一番上の長方形の面積
		s1 = h1 * W;
		// 下2つの長方形はできるだけ均等に分ける
		// つまり横の長さは片方がW / 2(小数点以下切り捨て)で、もう片方がW - (W / 2)
		// 縦の長さは(H - h1)で固定
		// w2 ≦ w3なので、s2 ≦ s3となるはず
		ll w2, w3;
		w2 = W / 2;
		w3 = W - w2;
		s2 = (H - h1) * w2;
		s3 = (H - h1) * w3;
		ll smax, smin;
		if (s1 >= s3) { // s1がsmaxの場合
			smax = s1;
			smin = s2;
		} else { // s3がsmaxの場合
			smax = s3;
			smin = min(s1, s2);
		}
		if (ans > smax - smin) { // 今までで最小なら更新
			ans = smax - smin;
		}
	}
	// 横3
	// 一番左の長方形の横の長さをw1(1 ≦ w1 ≦ W - 2)として全探索
	// 右は最低2は残しておかないと3つに分けられない
	for (int w1 = 1; w1 <= W - 2; w1++) {
		// 一番左の長方形の面積
		s1 = H * w1;
		// 右2つの長方形はできるだけ均等に分ける
		// つまり横の長さは片方が(W - w1) / 2(小数点以下切り捨て)で、もう片方が(W - w1) - ((W - w1) / 2)
		// 縦の長さはHで固定
		// w2 ≦ w3なので、s2 ≦ s3となるはず
		ll w2, w3;
		w2 = (W - w1) / 2;
		w3 = (W - w1) - w2;
		s2 = H * w2;
		s3 = H * w3;
		ll smax, smin;
		if (s1 >= s3) { // s1がsmaxの場合
			smax = s1;
			smin = s2;
		} else { // s3がsmaxの場合
			smax = s3;
			smin = min(s1, s2);
		}
		if (ans > smax - smin) { // 今までで最小なら更新
			ans = smax - smin;
		}
	}
	// 左1右2
	// 一番左の長方形の横の長さをw1(1 ≦ w1 ≦ W - 1)として全探索
	for (int w1 = 1; w1 <= W - 1; w1++) {
		// 一番左の長方形の面積
		s1 = H * w1;
		// 右2つの長方形はできるだけ均等に分ける
		// つまり縦の長さは片方がH / 2(小数点以下切り捨て)で、もう片方がH - (H / 2)
		// 横の長さはW - w1で固定
		// h2 ≦ h3なので、s2 ≦ s3となるはず
		ll h2, h3;
		h2 = H / 2;
		h3 = H - h2;
		s2 = h2 * (W - w1);
		s3 = h3 * (W - w1);
		ll smax, smin;
		if (s1 >= s3) { // s1がsmaxの場合
			smax = s1;
			smin = s2;
		} else { // s3がsmaxの場合
			smax = s3;
			smin = min(s1, s2);
		}
		if (ans > smax - smin) { // 今までで最小なら更新
			ans = smax - smin;
		}
	}
	cout << ans << endl;

	return (0);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
long long GetCount(long long* p,long long n){
	long long sum=0,num=p[n/2];
	for(long long i=0;i<n;i++)
		sum+=abs(p[i]-num);
	return sum;
}
int main(){
	long long n;
	cin>>n;
	long long num[n];
	for(long long i=0;i<n;i++)
		cin>>num[i];
	for(long long i=0;i<n;i++)
		num[i]=num[i]-(i+1);
	sort(num,num+n);
	cout<<GetCount(num,n);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<P> a(n);
	rep(i, n) {
		cin >> a[i].first;
		a[i].second = i + 1;
	}
	sort(a.begin(), a.end());
	rep(i, n) {
		cout << a[i].second << ' ';
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;

#define   ll     long long int

const int N = 100005;
ll ara[N], ara2[N], ara3[N];
ll n;

int sign(int x)
{
    if (x == 0) return -2;
    return (x / abs(x));
}

ll func(ll s, ll ara[])
{
    ll i, j, k, sum = 0;
    ll ss;
    ll fl = -sign(s);
    for (i = 2; i <= n; i++) {
        ss = s + ara[i];
        if (ss == 0 || sign(ss) != fl) {
            j = fl - s;
            sum += abs(j - ara[i]);
            ara[i] = j;
        }
        s = s + ara[i];
        fl = -fl;
    }
    return sum;
}

int main( )
{
    ll i, j;
    ll s = 0;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> ara[i];
        ara2[i] = ara[i];
        ara3[i] = ara[i];
    }
    if (ara[1] == 0) {
        cout << (1 + min(func(-1, ara), func(1, ara2))) << '\n';
    }
    else {
//        cout << abs(-1 - ara[1]) + func(-1, ara) << '\n';
//        cout << abs(+1 - ara2[1]) + func(+1, ara2) << '\n';
//        cout << func(ara3[1], ara3) << '\n';
        cout << min( abs(-1 - ara[1]) + func(-1, ara), min( abs(+1 - ara2[1]) + func(+1, ara2), func(ara3[1], ara3) ) ) << '\n';
    }
    return 0;
}


/**

        cout << abs(-1 - ara[1]) + func(-1) << '\n';
        cout << abs(+1 - ara[1]) + func(+1) << '\n';
        cout << func(ara[1]) << '\n';
        cout << min(abs(-1 - ara[1]) + func(-1), min( abs(1 - ara[1]) + func(1),    func(ara[1]))) << '\n';


**/


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,n,k,cnt;
  while(cin>>n){
    if(n==0) break;
    int chk=0,cnt=0;
    for(i=0;i<n;++i){
      cin>>k;
      if(k!=0&&k!=1) chk=1;
      if(k!=0) cnt++;
    }
    if(n==1) cout<<2<<endl;
    else if(chk==0) cout<<"NA\n";
    else cout<<cnt+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;

int N, M;
std::vector<int> WA(105000,0);
std::vector<bool> AC(105000,false);

void solve() {
    cin >> N >> M;
    int WAnum = 0;
    int ACnum = 0;

    while(M--) {
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC") {
            AC[p] = true;
            ACnum++;
            // ACになるまでのWAなのでACに
            // ならなかった場合合計されない
            WAnum += WA[p];
        } else if(S == "WA") {
            WA[p]++;
        }
    }
    cout << ACnum << " " << WAnum << endl;
    return;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
	int a, b, c;		//Value a, b, c.
	int count;			//answer.

	scanf("%d %d %d", &a, &b, &c);

	count = 0;
	while(a <= b)
	{
		if(c % a == 0)
			count++;
		a++;
	}
	printf("%d\n", count);

	return (0);
}



Measured memory_bytes: 2088
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N, D = [int(x) for x in input().strip().split()]
    D2 = D ** 2
    ans = 0
    for n in range(N):
        x, y = [int(x) for x in input().strip().split()]
        if x ** 2 + y ** 2 <= D2:
            ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

bool check(int x) {
	return 0 <= x and x <= 9;
}

int main(int argc, char const *argv[])
{
	int n; cin >> n;
	string s; cin >> s;
	if (n % 2 == 1) {
		printf("No\n");
		return 0;
	}

	string s1 = s.substr(0, n / 2);
	string s2 = s.substr(n / 2, n / 2);
	if (s1 == s2)
		printf("Yes\n");
	else 
		printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
    int A1, A2, A3;
    cin >> A1 >> A2 >> A3;
    int sum;
    sum = A1 + A2 + A3;
    if (sum >= 22) {
        cout << "bust";
    }
    else {
        cout << "win";
    }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int m,k,i,f,count=0;
    string a;
    cin>>a;
    k=a. size();
    m=k/2;
    for(i=0,f=k-1;i<m;i++,f--)
    {
        if(a[i]!=a[f])
        {
            count++;
        }
    }
    cout<<count<<endl;



}


Measured memory_bytes: 256
N = int(input())

S = [0] * N
cnt = [0] * 4
i = 0

while i < N:
    S[i] = input()
    if S[i] == 'AC':
        cnt[0] += 1
    elif S[i] == 'WA':
        cnt[1] += 1
    elif S[i] == 'TLE':
        cnt[2] += 1
    elif S[i] == 'RE':
        cnt[3] += 1
    i += 1

print('AC x {}'.format(cnt[0]))
print('WA x {}'.format(cnt[1]))
print('TLE x {}'.format(cnt[2]))
print('RE x {}'.format(cnt[3]))

Measured memory_bytes: 16100