akhauriyash/Code-Regression huggingface dataset:
#define A return 0;
#define AA int
#define AAA ;
#define AAAA if
#define AAAAA (
#define AAAAAA )
#define AAAAAAA cin
#define AAAAAAAA >>
#define AAAAAAAAA cout
#define AAAAAAAAAA <<
#define AAAAAAAAAAA endl
#define AAAAAAAAAAAA ,
#define AAAAAAAAAAAAA *
#define AAAAAAAAAAAAAA =
#define AAAAAAAAAAAAAAA else
#define AAAAAAAAAAAAAAAA <

#include<iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
	AA a AAAAAAAAAAAA aa AAAAAAAAAAAA aaa AAA
	AAAAAAA AAAAAAAA a AAAAAAAA aa AAAAAAAA aaa AAA
	AA aaaa AAAAAAAAAAAAAA a AAAAAAAAAAAAA aa AAA
	AAAA AAAAA aaaa AAAAAAAAAAAAAAAA aaa AAAAAA
	AAAAAAAAA AAAAAAAAAA aaaa AAAAAAAAAA AAAAAAAAAAA AAA
	AAAAAAAAAAAAAAA AAAAAAAAA AAAAAAAAAA aaa AAAAAAAAAA AAAAAAAAAAA AAA
	A
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll a, b, c, x;
    cin >> a >> b >> c >> x;
    x /= 50;

    ll ans = 0;
    rep(i, a+1) {
        rep(j, b+1) {
            rep(k, c+1) {
                if(10*i + 2*j + k == x) {
                    ans++;
                }
            }
        }
    }

    out(ans);
    re0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
//http://www.ipsj.or.jp/07editj/promenade/4304.pdf
//http://algorithms.blog55.fc2.com/blog-entry-131.html
public class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		int[][] plate=new int[h][w];
		int[][] dp=new int[h][w];
		for(int i=0; i<h; i++) {
			for(int j=0; j<w; j++) {
				plate[i][j]=0;
				dp[i][j]=0;
			}
		}
		String s="";
		for(int i=0; i<h; i++) {
			s=sc.nextLine();
			for(int j=0; j<w; j++) {
				if(s.charAt(j*2)=='0') {
					plate[i][j]=0;
				}
				else {
					plate[i][j]=1;
				}
			}
		}
		for(int i=0; i<h; i++) {		//dpループ
			for(int j=0; j<w; j++) {
				if(i>=1 && j>=1) {		//3方向見えるときは、正方形のサイズの制限はない
					if(plate[i][j-1]==1 || plate[i-1][j]==1 || plate[i-1][j-1]==1) {
						//上、左、左上のどれかに壁があるならできる正方形は高々1
						if(plate[i][j]==1) {
							dp[i][j]=0;	//いま見ているところが壁なら正方形はそこにはできない
						}
						else {
							dp[i][j]=1;	//まわりのどれかが壁の時できる正方形は高々1
						}
					}
					else if(plate[i][j]==0){
						dp[i][j]=Math.min(Math.min(dp[i-1][j], dp[i-1][j-1]), Math.min(dp[i-1][j], dp[i][j-1]))+1;
					}
					else if(plate[i][j]==1) {
						dp[i][j]=0;
					}
				}
				else {//もしもいま見ている座標の上、左上、左のいづれかが見ることできないなら　できる正方形のサイズは高々1
					if(plate[i][j]==1) {
						dp[i][j]=0;
					}
					else if(plate[i][j]==0){
						dp[i][j]=1;
					}
				}
			}
		}
		int max=0;
		for(int i=0; i<h; i++) {
			for(int j=0; j<w; j++) {
				max=Math.max(dp[i][j], max);
			}
		}
		pl(max*max);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 58884
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll N; cin >> N;
  string ans;
  N--;
  while (1){
    ans += 'a' + N % 26;
    N /= 26;
    N--;
    if (N < 0)
      break;
  }
  ll ssz = ans.size();
  rep(i, ssz)
    cout << ans[ssz - i - 1];
  cout << endl;
}


Measured memory_bytes: 3664
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i < (int)(n); i++)
int main() {
   int a;
   cin>>a;
    if(a<1200){
        cout<<"ABC"<<endl;
    }
    else if(a>=1200&&a<2800){
            cout<<"ARC"<<endl;
        }
        else
        {
            cout<<"AGC"<<endl;
        }
        
}



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

int main() {
  
  long A,B;
  cin >> A >> B;
  
  int i;
  
  for ( i = 1; i <= B; i++){
    if ( (A * i) % B == 0){
      break;
    }    
  }
  
  cout << A*i << endl;      
  
}

Measured memory_bytes: 256
//#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() {
	vector<int> v(3);
	cin>>v.at(0)>>v.at(1)>>v.at(2);
	sort(v.begin(),v.end());
	cout<<v.at(0)+v.at(1)<<endl;
	return 0;
}


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

#define FOR(a, b) for (int i = a; i < b; ++i)
#define FOR_EACH(container) for (const auto& p: container)
#define SORT(container) sort(container.begin(), container.end())
#define DSORT(container) sort(container.begin(), container.end(), greater<>())

using namespace std;
using pii = pair<int, int>;

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

    int N;

    cin >> N;

    vector<int> v; v.reserve(50);
    int vi;
    FOR(0, N)
    {
        cin >> vi;
        v.emplace_back(vi);
    }

    int ci;
    FOR(0, N)
    {
        cin >> ci;
        v[i] -= ci;
    }

    DSORT(v);

    int bestSum = 0;
    FOR_EACH(v)
    {
        if (p <= 0)
        {
            break;
        }

        bestSum += p;
        //cout << p << " ";
    }
    //cout << endl;

    cout << bestSum << endl;
}



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

static const int MAX = 100000;
static const int INFTY = 1 << 29;
vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];//入度

void bfs(int s)
{
	queue<int> q;
	q.push(s);
	V[s] = true;
	while (!q.empty()){
		int u = q.front();
		q.pop();
		out.push_back(u);
		for (int i = 0; i < G[u].size(); ++i)
		{
			int v = G[u][i];
			--indeg[v];
			if (indeg[v] == 0 && !V[v]){
				V[v] = true;
				q.push(v);
			}
		}
	}
}

void tsort(){
	for (int i = 0; i < N; ++i)indeg[i] = 0;
	for (int u = 0; u < N; ++u){
		for (int i = 0; i < G[u].size(); ++i){
			int v = G[u][i];
			indeg[v]++;
		}
	}
	for (int u = 0; u < N; ++u)if (indeg[u] == 0 && !V[u])bfs(u);
	for (auto it(out.begin()); it != out.end(); ++it)cout << *it << endl;
}

int main()
{
	int s, t, M;
	cin >> N >> M;
	for (int i = 0; i < N; ++i)V[i] = false;
	for (int i = 0; i < M; ++i)
	{
		cin >> s >> t;
		G[s].push_back(t);
	}
	tsort();
	return 0;
}


Measured memory_bytes: 6264
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
 
int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
 
    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;
 
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3636
n, k = map(int, input().split())
arr = [0] + list(map(int, input().split()))

pos = 1

if k <= n:
    for _ in range(k):
        pos = arr[pos]
    print(pos)
    exit()

res = []
visited = dict()
for i in range(n + 1):
    if pos in visited:
        start = visited[pos]
        length = i - visited[pos]
        print(res[start + (k - start) % length])
        exit()
    res.append(pos)
    visited[pos] = i
    pos = arr[pos]

Measured memory_bytes: 32364
#include<bits/stdc++.h>
#define ll  long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 1000000000000000
#define mod 1000000007
#define ld long double
#define pll pair<ll,ll>
using namespace std;

int main()
{ 
	

fast;

string s,t;
cin>>s>>t;


ll n=s.size();
ll ans=0;

for(ll i=0;i<n;i++)
	if(s[i]!=t[i])ans++;

cout<<ans<<'\n';

}


Measured memory_bytes: 3888
#include <stdio.h>
#include <inttypes.h>

#define GENKAI 200000

int N;
uint64_t A[GENKAI];

uint64_t gusu_sum[GENKAI]; /* 0, w1, w1+w3, ... */
uint64_t kisu_sum[GENKAI]; /* 0, w2, w2*w4, ... */

int main(void) {
	int i;
	uint64_t sum = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNu64, &A[i]) != 1) return 1;
		sum += A[i];
	}
	gusu_sum[0] = kisu_sum[0] = 0;
	for (i = 0; i < N; i += 2) {
		gusu_sum[i / 2 + 1] = gusu_sum[i / 2] + A[i];
		kisu_sum[i / 2 + 1] = kisu_sum[i / 2] + A[i + 1];
	}
	for (i = 0; i < N; i++) {
		uint64_t hikuryou;
		if (i % 2 == 0) {
			hikuryou = gusu_sum[i / 2] + (kisu_sum[N / 2 + 1] - kisu_sum[i / 2]);
		} else {
			hikuryou = kisu_sum[i / 2] + (gusu_sum[N / 2 + 1] - gusu_sum[(i + 1) / 2]);
		}
		if (i > 0) putchar(' ');
		printf("%" PRIu64, sum - hikuryou * 2);
	}
	putchar('\n');
	return 0;
}

/*
山に降った雨の量 2*m1, 2*m2, ... , 2*mN
ダムに溜まった水の量 w1, w2, ..., wN

w1 = m1 + m2
w2 = m2 + m3
...
wN = mN + m1


m1 + m2      = w1
     m2 + m3 = w2
m1 +      m3 = w3

2m1 + 2m2 + 2m3 = w1+w2+w3
m1 + m2 + m3 = (w1+w2+w3)/2

Nは奇数 → 必ず2個ずつ消して1個残る


*/


Measured memory_bytes: 4096
N = int(input())
P = list(map(int, input().split()))

ans = 0
for i in range(1, N - 1):
	cnt = 0
	if P[i - 1] < P[i]: cnt += 1
	if P[i] > P[i + 1]: cnt += 1
	if cnt == 1: ans += 1

print(ans)


Measured memory_bytes: 2940
#include <cassert>
#include <climits>
#include <cstdio>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;

template <typename UnaryPredicate>
ll binsearch(ll l, ll r, UnaryPredicate p) { // [l, r), p is monotone
    assert (l < r);
    -- l;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        (p(m) ? r : l) = m;
    }
    return r; // = min { x in [l, r) | p(x) }, or r
}

constexpr ll inf = LLONG_MAX / 3;
int main() {
    // input
    int n, k; scanf("%d%d", &n, &k);
    vector<ll> w(n);
    vector<int> d(n);
    repeat (i, n) {
        scanf("%lld%d", &w[i], &d[i]);
    }
    // solve
    ll result = binsearch(0, inf, [&](ll x) {
        ll cnt = 0;
        repeat (i, n) {
            if (w[i] <= x) {
                cnt += 1 + (x - w[i]) / d[i];
            }
        }
        return cnt >= k;
    });
    // output
    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;		
class Main{		
	public static void main(String[ ] args)throws java.lang.Exception {	
		
		//????????¬?????°?????????????????????????????????
		Scanner reader = new Scanner(System.in);
		
		//???????????????????????\?????????????¬??????°???????????°???????´?
		
		int iLength = reader.nextInt();
		
		//???????????????????????\?????????????¬??????°???????????°???????´?
		
		int iSide = reader.nextInt();
		
		reader.close();
		
		//??¢???????¨????
		int iMenseki = iLength * iSide;
		
		//??¨?????????????¨????
		int iMawari = (iLength + iSide) * 2;
		
		//?????????1?????§??????
		System.out.println(iMenseki + " " + iMawari);
	}	
}		

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

static const int MAX=1000;
static const int VMAX=10000;

int n, A[MAX],s;
int B[MAX],T[VMAX+1];

int solve() {
  int ans=0;
  bool V[MAX];
  for (int i=0; i<n; i++) {
    B[i]=A[i];
    V[i]=false;
  }
  sort(B,B+n);
  for (int i=0; i<n; i++) {
    T[B[i]]=i;
  }
  for (int i=0; i<n; i++) {
    if (V[i]) {
      continue;
    }
    int cur=i;
    int S=0;
    int m=VMAX;
    int an=0;
    while (true) {
      V[cur]=true;
      an++;
      int v=A[cur];
      m=min(m,v);
      S+=v;
      cur=T[v];
      if (V[cur]) {
        break;
      }
    }
    ans+=min(S+(an-2)*m,m+S+(an+1)*s);
  }
  return ans;
}
int main() {
  cin>>n;
  s=VMAX;
  for (int i=0; i<n; i++) {
    cin>>A[i];
    s=min(s,A[i]);
  }
  int ans=solve();
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3164
import java.util.Arrays;
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);
    final int n = scanner.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) a[i] = scanner.nextInt();
    Arrays.sort(a);
    int r = upperBound(a, a[n - 1] / 2);
    if (r + 1 < n - 1 && a[n - 1] - a[r + 1] > a[r]) r = a[r + 1];
    else r = a[r];
    System.out.printf("%d %d\n", a[n - 1], r);
  }

  public static int upperBound(int[] a, int k) {
    int left = -1;
    int right = a.length;
    while (right - left > 1) {
      int mid = (left + right) / 2;
      if (a[mid] <= k) {
        left = mid;
      } else {
        right = mid;
      }
    }
    return left;
  }
}


Measured memory_bytes: 50448
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n+1);
    map<ll, ll> mp;
    rep(i, n){
        cin >> a[i];
        b[a[i]]++;
        mp[a[i]]++;
    }

    ll res = 0;
    rep(i, n+1){
        res += (b[i] * (b[i]-1)) / 2;
    }
    
    rep(i, n){
        ll tmp1 = (b[a[i]] * (b[a[i]]-1)) / 2;
        ll tmp2 = ((b[a[i]]-1) * (b[a[i]]-2)) / 2;
        if(b[a[i]]-1 < 0){
            tmp2 = 0;
        }
        cout << res - tmp1 + tmp2 << endl;
    }

    return 0;
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int n;
    cin >> n;

    vector<int> a(n);
    for (auto& x : a) cin >> x;
    a.push_back(0);

    sort(a.begin(), a.end());

    vector<int> ac(n + 1);
    ac[0] = 0;
    for (int i = 1; i < ac.size(); i++) {
        ac[i] = a[i] + ac[i - 1];
    }

    int ans = 1;
    for (int i = n; i > 0; i--) {
        if (a[i] > ac[i - 1] * 2) break;
        ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <algorithm>
#include <map>
#include <numeric>
#include <iomanip>
#include <set>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

/* class */
class DisjointSet {
public:
    vector<int> d;

    DisjointSet() {}
    DisjointSet(int size) : d(size, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool same(int x, int y) { return find(x) == find(y); }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];  // unite x <- y
        d[y] = x;  //y.parent = x
        return true;
    }
    int size(int x) { return -d[find(x)]; }
};

/* global variables */

/* function */

/* main */
int main() {
    int N, M, K, a, b;
    cin >> N >> M >> K;
    DisjointSet ds(N+1);
    vector< vector<int> > to(N+1, vector<int>());
    vector<int> deg(N+1, 0);
    for (int i = 0; i < M; i++) {
        cin >> a >> b;
        deg[a]++;
        deg[b]++;
        ds.unite(a, b);
    }
    for (int i = 0; i < K; i++) {
        cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    for (int i = 1; i <= N; i++) {
        int ans = ds.size(i) - deg[i] - 1;
        for (int t : to[i]) {
            if (ds.same(i, t)) ans--;
        }
        cout << ans << ' ';
    }
    cout << '\n';

}

Measured memory_bytes: 6784
#include<iostream>
using namespace std;
int main(){
  int n,pointA,pointB;
  int a[10000],b[10000];
  pointA = 0; pointB = 0;
  for(n = 1;n != 0;){  
 cin >> n;
 if(n != 0){
    pointA = 0; pointB = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0;i< n;i++){
    
    if(a[i] < b[i]){
      pointB = pointB + a[i] +b[i];
    } else if(a[i] > b[i]){
      pointA = pointA + a[i] +b[i];
    } else if(a[i] == b[i]){
      pointA = pointA + a[i];
      pointB = pointB + b[i];
    }
  }
 
  cout << pointA << " "<< pointB << endl;
 }
  }
  
  
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    if((A+B)%2 == 0)
    {
        cout << (A+B)/2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include <vector>
#include <set>
#include<queue>
#include<map>
using namespace std;
int main()
{
	long long int a, b, c;
	cin >> a >> b >> c;
	if ((a == b && a != c) || (a == c && a != b) || (c == b && c != a))
	{
		cout << "Yes";
	}
	else
		cout << "No";

}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int A,B ;
    scanf("%d %d",&A,&B) ;

    if((A==1 && B==2)||(A==2 && B==1))
    {
           printf("3\n");
    }
    else if((A==2 && B==3)||(A==3 && B==2))
    {
           printf("1\n");
    }
    else
    
           printf("2\n");
        
    return 0;
}
            

Measured memory_bytes: 1636
l = input()
x = list(map(int, l.split()))
for i in range(len(x)):
    for j in range(len(x) - i - 1):
        if x[j] > x[j+1]:
            work = x[j+1]
            x[j+1] = x[j]
            x[j] = work
print(f"{x[0]} {x[1]} {x[2]}")


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N,D;
    cin >> N >> D;
    vector<vector<int>> X(N,vector<int>(D));
    rep(i,N){
        rep(j,D){
            cin >> X[i][j];
        }
    }
    int ans = 0;
    rep(y,N){
        repX(z,N,y+1){
            int sum = 0;
            rep(i,D){
                sum += pow(abs(X[y][i]-X[z][i]),2);
            }
            if (floor((float)pow(sum, 0.5)) == (float)pow(sum, 0.5)){
                ans ++;
            }
        }
    }
    cout << ans << endl;

    return 0;
}

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

l = list(map(int,input().split()))
l = [0]+l+[0]
dis = 0
for i in range(len(l)-1):
    dis += abs(l[i]-l[i+1])

for i in range(1,len(l)-1):
    print(dis-abs(l[i]-l[i-1])-abs(l[i]-l[i+1])+abs(l[i-1]-l[i+1]))


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i,n)
    cin >> a[i];
  double sum=0;
  rep(i,n)
    sum = sum + a[i];
  double border = sum/(4*m);
  int count = 0;
  rep(i,n){
    if(a[i] >= border)
      count++;
  }
  if(count >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream> 
#include <vector>
#include <cstring>
#include <algorithm>


int main() {
	using namespace std;
	//memset(dp, -1e, sizeof(dp));
	
	int n, m;
	cin >> n >> m;
	vector<vector<int>> dp(n + 1, vector<int> (10,-1e9));
	vector<int> mapped = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
	vector<int> v(m);
	for (int i = 0; i < m; ++i) {
		cin >> v[i];
	}
	for (int i = 0; i < 10; ++i) dp[0][i] = 0;
	
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j <= n; ++j) {
			int x = mapped[v[i]];
			if (j >= x) {
				if (1 + dp[j - x][0] >= dp[j][0]) {
					if (1 + dp[j - x][0] > dp[j][0]) {
						dp[j] = dp[j - x];
						dp[j][0]++;
						dp[j][v[i]]++;
					}else {
						vector<int> d1 = dp[j - x];
						d1[0]++;
						d1[v[i]]++;
						vector<int> d2 = dp[j];
						reverse(d1.begin(), d1.end()); 
						reverse(d2.begin(), d2.end()); 
						if (d1 > d2) {
							reverse(d1.begin(), d1.end());
							dp[j] = d1;
						} 
					}
				}
			}
		} 
	}
	
	for (int i = 9; i > 0; --i) {
		for (int j = 0; j < dp[n][i]; ++j) {
			cout << i;
		}
	}
}








Measured memory_bytes: 4016
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <bits/stdc++.h>
#define LL long long
using namespace std;
int main()
{
    int A,B;
    scanf("%d %d",&A,&B);
    if((A*B)%2==0){
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
A = [0 for i in range(N)]

for i in range(N - 1):
    if i == 0:
        A[i] = B[i]
    if B[i] >= A[i]:
        A[i] = A[i]
    else:
        A[i] = B[i]
    A[i + 1] = B[i]

print(sum(A))


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

int main() {
  int H,W,X;
  cin >> H >> W >> X;
  
  if (H <= X && X <= H+W) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int
using namespace std;
int32_t main()
{
  int n,m;
  cin>>n>>m;
  map<int,int> mp;
  map<int,int> mi;
  int ac=0,wa=0;
  for(int i=0;i<m;i++)
  {
      int a;
      string s;
      cin>>a;
      cin>>s;
      //cout<<s<<endl;
      if(mp[a]==1)
      continue;
      else
      {
          if(s=="WA")
          {
              mi[a]++;
          }
          
          else
          {
              ac++;
              mp[a]=1;
              wa+=mi[a];
          }
      }
  }
  cout<<ac<<" "<<wa<<endl;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define M 1000005
#define P 1000000007
#define LL long long
using namespace std;
int A[M],B[M],n;
char str[M]; 
int main(){  
	int n,x;cin>>n;
	for(int i=0;i<n;i++)scanf("%d",&A[i]);
	sort(A,A+n);
	double res=A[0];
	for(int i=1;i<n;i++){
		res=(A[i]+res)/2;
	}
	printf("%.10f\n",res);
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define N 100010
#define ll long long 
#define db double
#define Add(u, v) ({f[++l] = (Edge) { u, v, head[u]}; head[u] = l;})
using namespace std;
struct Edge { int from, to, next; } f[N*2];
int head[N], l = 0, u, v, n, d[N], fa[N], val[N];
void Dfs(int u, int pa)
{
   d[u] = d[pa] + 1;
   fa[u] = pa; val[u] = 1; 
   for (int i = head[u]; i; i = f[i].next)
      if (f[i].to != pa)  { Dfs(f[i].to, u); val[u] += val[f[i].to]; } 
}
int main()
{
   cin >> n;
   for (int i = 1; i < n; i++) {
      scanf("%d%d", &u, &v);
      Add(u, v);
      Add(v, u);
   }
   Dfs(1, 0);
   int u = n; 
   for (int i = 1; i <= (d[n] / 2 - 1); i++)
      u = fa[u];
   // cout << u << "=" << val[1] << endl; 
   int tA = val[u], tB = n - tA;
   puts((tA < tB) ? "Fennec" : "Snuke"); 
   return 0; 
}


Measured memory_bytes: 8832
#pragma warning(disable:4996)

#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <cmath>
#include <map>
#include <array>
#include <set>
#include <queue>
#include <complex>
#include <iterator>
#include <random>
#include <time.h>
#include <tuple>
#include <functional>
#include <list>
#include <limits.h>
#define mp make_pair
#define ni(x) scanf("%d", &(x))
#define nii(x,y) scanf("%d%d",&(x),&(y))
#define mul(x,y) ((ll)(x)*(y)%mod)
#define mtp make_tuple
#define F(i,n) for(int i = 0; i < (n); i++)
#define FF(i,n) for(int i = 1; i <= (n); i++)
#define FE(i,n) for(int i = 0; i <= (n); i++)

#ifndef __GNUG__
int __builtin_popcount(int n) {
	int x = 0;
	while (n)n -= n&(-n), x++;
	return x;
}
#endif

using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int mod = 1000003;
const int inf = 2012345678;
const ll infl = 9012345678901234567;
const double pi = 3.1415926535897932384626433832795;
//----------------------------------------------------------------------------//

const int N = 2000, M = 32;

char b[N];
uint64_t db[N][M], eb[N][M], a[N][M], foo[M];

inline void Set(uint64_t A[], int i) {
	A[i >> 6] |= 1LL << (i & 63);
}
int Get(uint64_t A[], int i) {
	return A[i >> 6] & 1LL << (i & 63);
}

int main() {
#ifndef __GNUG__
	freopen("input.txt", "r", stdin);
#endif
	int n; ni(n);
	for (int i = 1; i < n; i++) {
		scanf("%s", b);
		F(j, i) {
			if (b[j] == '1')Set(a[i], j);
			else Set(a[j], i);
		}
	}
	for (int i = n; i--;) for (int j = i; j < n; j++) {
		if (i == j) {
			Set(db[i], i);
			Set(eb[i], i);
			continue;
		}
		bool good = false;
		F(k, M) {
			if (a[i][k] & db[j][k] & eb[i + 1][k]) {
				good = true; break;
			}
		}
		if (good)Set(db[j], i);
		good = false;
		F(k, M) {
			if (a[j][k] & db[j - 1][k] & eb[i][k]) {
				good = true; break;
			}
		}
		if (good)Set(eb[i], j);
	}
	int ans = 0;
  	F(i, M) {
     	ans += __builtin_popcountll(eb[0][i] & db[n-1][i]); 
    }
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n;
    scanf("%d", &n);
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        int x;
        scanf("%d", &x);
        if (cnt[x]) {
            puts("NO");
            return 0;
        }
        cnt[x]++;
    }
    puts("YES");
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long
//#define scanf scanf_s

char city[1005][1005];
int way[1005][1005];
int di[4] = { -1, 0, 0, 1 }; int dj[4] = { 0, -1, 1, 0 };

int main()
{
	int h, w, n;
	cin >> h >> w >> n;
	REP(i, h)REP(j, w) cin >> city[i][j];
	typedef queue<pair<int, int>> que;
	que start;
	REP(i, h)REP(j, w)
	{
		if (city[i][j] == 'S') start.push(make_pair(i, j));
	}
	FOR(k, 1, n+1)
	{
		REP(i, h)REP(j, w)
		{
			if (city[i][j] - '0' == k)
			{
				start.push(make_pair(i, j));
			}
		}
	}
	int cnt = 0;

	REP(i,n)
	{
		REP(i, 1005)REP(j, 1005) way[i][j] = INF;
		que q; 
		way[start.front().first][start.front().second] = 0;
		q.push(start.front());
		start.pop();
		while (1)
		{
			int tmpi = q.front().first; int tmpj = q.front().second;
			q.pop();
			if (tmpi == start.front().first&&tmpj == start.front().second)
			{
				cnt += way[tmpi][tmpj];
				break;
			}
			else
			{
				REP(i, 4)
				{
					if (tmpi + di[i] >= 0 && tmpi + di[i] < h &&tmpj + dj[i] >= 0 && tmpj + dj[i] < w && city[tmpi + di[i]][tmpj + dj[i]] != 'X' && way[tmpi + di[i]][tmpj + dj[i]] == INF)
					{
						way[tmpi + di[i]][tmpj + dj[i]] = way[tmpi][tmpj] + 1;
						q.push(make_pair(tmpi + di[i], tmpj + dj[i]));
					}
				}
			}
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 6140
N, L = gets.strip.split.map(&:to_i)

sum=0
(0..N-1).each do |i|
	sum+=L+i
end

num=-1
ans=99999999
(0..N-1).each do |i|
    t=sum-(L+i)
    dif=(sum-t).abs
    if dif<ans
        ans=dif
        num=i
    end
end



puts sum-(L+num)


Measured memory_bytes: 1788
#include<stdio.h>
int main(){
  int n,l,sum=0;
  scanf("%d%d",&n,&l);
  if(l+n-1<0){
    for(int i=1;i<n;i++) sum+=l+i-1;
  }else if(l>0){
    for(int i=2;i<=n;i++) sum+=l+i-1;
  }else{
    for(int i=1;i<=n;i++) sum+=l+i-1;
  }
  printf("%d",sum);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
#include <stdlib.h>


int main(void){
  //int a,b;
  char a[10],b[4];
  char c[10];
  int n;
  scanf("%s %s", a,b);
  //scanf("%s", c);
  strcat(a,b);
  n=atoi(a);
  //char c[8]=a+b;
  for(int i=1;i<=1000;i++){
    if(i*i==n){
      printf("Yes");
      return 0;
    }
    
  }

  printf("No");
  return 0;
}



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

int main() {
    ios :: sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
    int a,b,t;
    cin>>a>>b>>t;
    cout<<((int)(t+0.5)/a)*b<<endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[4];
  cin >> a;
  if(strlen(a)==3)cout << a[2] << a[1] << a[0];
  else cout << a;
  /*
  int n;
  cin >> n;
  int a[n],r[n],b[n],p=0,q=0;
  char s[n];
  for(int i=0;i<n;i++){
    r[i]=99999999;
    b[i]=99999999;
  }
  for(int i=0;i<n;i++){
    cin >> a[i] >> s[i];
    if(s[i]=='R'){
      r[p]=a[i];
      p++;
    }
    else{
      b[q]=a[i];
      q++;
    }
  }
  sort(r,r+n);
  sort(b,b+n);
  for(int i=0;i<n;i++){
    if(r[i]==99999999)break;
    cout << r[i] << endl;
  }
  for(int i=0;i<n;i++){
    if(b[i]==99999999)break;
    cout << b[i] << endl;
  }
  */
}


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

using namespace std;

int range[5]={5,7,5,7,7};

bool search(int n,vector<int> &list,int p,int s){
  int c=0,i=p;
  if(s==5) return true;
  do{
    c+=list[i];
    i++;
  }while(c<range[s] && i<n);
  //  cout << c << endl;                                                                        
  // cout << "a " << s << endl;                                                                 
    if(c==range[s]) return search(n,list,i,s+1);
    else return false;
}

int main(){
  while(true){
    int n;
    cin >> n;
    if(n==0)break;
    string temp;
    vector<int> list(n,0);
    for(int i=0;i<n;i++){
      cin >>temp;
      list[i]=temp.length();
      //  cout << list[i] << endl;                                                              
    }
    bool flag;
    for(int i=0;i<n;i++){
      flag=search(n,list,i,0);
      if(flag){
        cout << i+1 << endl;
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3080
s = input()
mae = []
num = len(s)-1
for i in range(2**num):
    ato = []
    for j in range(num):
        if ((i >> j) & 1):
            ato.append("+")
        else:
            ato.append("")
    mae.append(ato)

li = list(s)
ans = []
for i in mae:
    word = ""
    for letter,en in zip(li,i):
        word += letter+en
    word += li[num]
    ans.append(eval(word))
print(sum(ans))

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<list>
#include <array>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807
#define INF I64_MAX
#define MOD 1000000007
#define MEM_SIZE = 1e5+5;

template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}



//BELOW
struct mint {
  int x; // typedef long long int;
  mint(int x=0):x((x%MOD+MOD)%MOD){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(int t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime MOD
  mint inv() const {
    return pow(MOD-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
 
 
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

//-----CODE------//


void solve(void)
{
  int N;
  cin>>N;
  vector<int> vec(50,0);
  vec[0] = 1;
  vec[1] = 1;
  for (int i = 0; i < 48; i++)
  {
    vec[i+2] = vec[i+1] + vec[i];
  }
  cout<<vec[N]<<endl;
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}


Measured memory_bytes: 3224
#include <iostream>
using namespace std;
int main(void){
  	
  	int n;
  	cin>>n;
  	int a[n]={};
  	for(int i=0;i<n;i++){
      	cin>>a[i];
    }
  	
  	long long int answer = 0;
  	
  	for(int i=1;i<n;i++){
      	if(a[i-1]>a[i]){
          	answer+=a[i-1]-a[i];
          	a[i]=a[i-1];
        }
    }
  	
  	cout<<answer<<endl;
  	
  	return 0;
}

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

using namespace std;

int main()
{
    string s;
    cin>>s;
    string s1 = "ABC";
    string s2 = "ARC";
    if(s == s1)
    {
        cout<<s2;
    }
    else if(s == s2)
    {
        cout<<s1;
    }
    
    return 0;
    
}

Measured memory_bytes: 3652
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, c, k = map(int, read().split())

while a >= b and k >= 1:
    b *= 2
    k -= 1
c *= pow(2, k)

print('Yes' if a < b < c else 'No')

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

int main(){
    int n, t, x;
    cin >> n >> t >> x;

    int tako = 0;
    int ans = 0;
    while(true) {
        tako += t;
        ans += x;
        if(tako >= n) break;
    }

    cout << ans << endl;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0) : x((x%mod+mod)%mod) {}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    if ((x+y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    } 
    ll m = (2*x-y)/3;
    ll n = (2*y-x)/3;
    if (m >= 0 && n >= 0) {
        if (m < n) swap(m, n);
        ans = 1;
        ll x = 0;
        combination comb(m+n);
        mint res = comb(m+n, n);
        ans = res.x;
    }
    std::cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
vector<int>bb;
vector<int>cc;
int main()
{
    int x,i,num,sum=0,cnt;
    int avg;
    cin>>num;
    for(i=0; i<num; i++)
    {
        cin>>x;
        v.push_back(x);
        sum+=x;
    }
//    avg=v(num/2-1);
    cnt=0;
    int big=0;
    int small=0;
    sort(v.begin(),v.end());
    avg=v[(num/2-1)];
    for(i=0; i<num; i++)
    {
        if(v[i]<=avg)
        {
           cc.push_back(v[i]);
          // small++;
        }
        else
        {
            bb.push_back(v[i]);
            //big++;
        }
    }
        //cout<<v[i]<<" ";
        if(cc.size()!=bb.size())
        {
            cout<<"0"<<endl;
        }
        else
            {
                cout<<bb[0]-cc[cc.size()-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 1272
#include <bits/stdc++.h> 
using namespace std;  
typedef vector<vector< int> >vvi;
typedef vector<int> vi; 
#define PB push_back  
#define int long long
const int nax =1e6 +5;
const int inf =1e9 +5;
const double PHI = 1.6180339;
int f[6]= {0,1,1,2,3,5};


signed main () {
	
    ios::sync_with_stdio(false); 
    cin.tie(0);  
    int n;
    cin>>n;
    while(n--) {
    	cout<<"ACL";
	}
	
    
}

Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long dp[2][2019]={};
std::string S;
cin>>S;
long long ans=0;
for(long long i=0;i<S.length();++i){
    int num=S[i]-'0';
    for(long long j=0;j<2019;++j){
        dp[1][(j*10+num)%2019]+=dp[0][j];
    }
    dp[1][num]+=1;
        for(long long j=0;j<2019;++j){
        dp[0][j]=dp[1][j];
        dp[1][j]=0;
    }
ans+=dp[0][0];
}
cout<<ans<<"\n";
return 0;
}


Measured memory_bytes: 3740
#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() {
    int N, M; cin >> N >> M;
    int x = M/N;
    for (int i = x; i > 0; i--){
        if(M%i == 0){
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;


#define INF 1e18
#define int long long

signed main() {
    int a, b, x;
    cin >> a >> b >> x;

    if(x >= a * a * b / 2) {
        double c = b - (2.0 * x - b * pow(a, 2.0)) / pow(a, 2.0);
        double ans = atan2(c, a) * 180.0 / M_PI;

        cout << setprecision(10) << ans << endl;
        return 0;
    }

    double c = 2.0 * x / (b * a);
    double ans = 90 - atan2(c, b) * 180.0 / M_PI;

    cout << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
def resolve():
    import sys
    input = sys.stdin.readline
    from collections import deque, defaultdict
    N, M = map(int, input().split())
    ab = [tuple(map(int, input().split())) for _ in range(N + M - 1)]
    in_cnt = defaultdict(int)
    outs = defaultdict(list)
    for a, b in ab:
        in_cnt[b - 1] += 1
        outs[a - 1].append(b - 1)
    res = []
    queue = deque([i for i in range(N) if in_cnt[i] == 0])
    while len(queue) != 0:
        v = queue.popleft()
        res.append(v)
        for v2 in outs[v]:
            in_cnt[v2] -= 1
            if in_cnt[v2] == 0:
                queue.append(v2)
    dp = [(0, -1)] * N
    for i in res:
        for j in outs[i]:
            if dp[i][0] + 1 > dp[j][0]:
                dp[j] = (dp[i][0] + 1, i)
    for _, i in dp:
        print(i + 1)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61588
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        long a=sc.nextLong();
        long b=sc.nextLong();
        long c=sc.nextInt();
        long d=sc.nextInt();
        long x=b-a+1 - ((b/c) - (a/c) + (b/d) - (a/d) - ((b/(lcm(c,d))) - (a/(lcm(c,d)))));
//        System.out.println(x);
        if (a%c==0)x--;
        if (a%d==0)x--;
        if (a%(lcm(c,d))==0)x++;
        System.out.println(x);

    }
    static long gcd(long a,long b){
        if(a==0)return b;
        else return gcd(b%a,a);
    }
    static long lcm(long a,long b){
        return (a*b)/gcd(a,b);
    }

}



Measured memory_bytes: 23124
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
ll n,used[51];
vector <int> day[31];

int solve(){
  for(int i=1;i<=30;i++){
    ll a=0;
    for(int j=0;j<day[i].size();j++) a=(a|used[day[i][j]]);
    for(int j=0;j<day[i].size();j++) used[day[i][j]]=a;
    if(a==((ll)1<<n)-1)return i;
  }
  return -1;
}

int main(){
  while(1){
    cin >> n;
    if(!n)break;
    for(int i=0;i<=30;i++)day[i].clear();
    for(int i=0;i<n;i++){
      used[i]=((ll)1<<i);
      int a,b;
      cin>>a;
      while(a--)cin>>b,day[b].push_back(i);
    }
    cout << solve()<<endl;
  }
  return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;

int main() {
  int N, M;
  cin >> N >> M;

  vector<int> A(N); cin >> A;
  vector<pair<int, int>> BC(M); cin >> BC;

  sort(A.begin(), A.end());
  sort(BC.begin(), BC.end(), [](auto const& x, auto const& y){
    return x.second == y.second ? x.first > y.first
                                : x.second > y.second;
  });

  int edited = 0;
  ll ans = 0;
  rep(i, M) {
    int b = BC[i].first, c = BC[i].second;
    int last = std::lower_bound(A.begin() + edited, A.end(), c) - A.begin();
    int distance = min(b, last - edited);
    ans += (ll)distance * c;
    edited += distance;
    if (edited >= N) { break; }
  }
  REP(i, edited, N) ans += A[i];
  cout << ans << endl;
}


Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N){
        cin >> A[i];
    }

    int right = 0;
    int sum1 = 0;
    ll sum2 = 0;
    ll ans = 0;
    rep(i,N){
        while(right < N && (sum1^A[right]) == sum2+A[right]){
            sum1 ^= A[right];
            sum2 += A[right];
            ans += right-i+1;
            //cout << right << " " << ans << " " << sum1 << " " << sum2 << endl;
            right++;
        }
        sum1 ^= A[i];
        sum2 -= A[i];
        if(right == i) right++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 1024
let () =
    let arr = Array.make 100001 false in
    arr.(0) <- true;
    for i = 0 to 100000 do
        if arr.(i) then (
            for j = 100 to 105 do
                if i + j <= 100000 then arr.(i + j) <- true
            done
        )
    done;
    let main () =
        let n = int_of_string (read_line ()) in
        Printf.printf "%d\n" (if arr.(n)then 1 else 0)
    in
    main ()

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && a == c && b == c) cout << "No";
    else if (a != b && a != c && b != c) cout << "No";
    else cout << "Yes";
    return 0;
}

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

typedef long long ll;
using namespace std;

ll H, N;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> H >> N;
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        ll l;
        cin >> l;
        sum += l;
    }
    if (H > sum) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

int main() {
    string s; cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) cout << "Yes" << endl;
    else if (s[1] == s[2] && s[2] == s[3]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3592
import java.util.*;class Main{public static void main(String[]z){int x,y,n=10,i,j,m,r=0,u=0,k;int[][]a=new int[n][n];for(Scanner s=new Scanner(System.in);s.hasNext();){String[]p=s.nextLine().split(",");x=new Integer(p[0]);y=new Integer(p[1]);m=new Integer(p[2]);for(i=u=0;i<n;i++)for(j=0;j<n;u+=a[i][j]<1?1:0,j++){k=Math.abs(i-x)+Math.abs(j-y);r=Math.max(r,a[i][j]+=(m<2&&k<2)||(m>2&&k<3)||(m==2&&x-2<i&&i<x+2&&y-2<j&&j<y+2)?1:0);}}System.out.println(u+"\n"+r);}}

Measured memory_bytes: 12000