akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli unsigned long long int   //used int to avoid mle
#define ulli unsigned long long int 
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define spl set<pll>
#define msl multiset <lli>
#define msp multiset <pll>
#define pll pair<lli, lli>
#define mll map<lli, lli>              //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x)
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
lli mod=1000000007;
//string s=bitset<32>(n).to_string();
lli power(lli x, lli y,lli p) 
{ 
    lli res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}
long long int sumXOR(lli arr[], lli n) 
{ 
    long long int sum = 0; 
    for (lli i = 0; i < 64; i++)  
    { 
        //  Count of zeros and ones 
        lli zc = 0, oc = 0;  
          
        // Individual sum at each bit position 
        long long int idsum = 0;  
        for (lli j = 0; j < n; j++) 
        { 
            if (arr[j] % 2 == 0) 
                zc++; 
            else
                oc++; 
            arr[j] /= 2; 
        } 
          
        // calculating individual bit sum  
        idsum = ((oc%mod) * (zc%mod)%mod) * (power(2,i,mod));  
  
        // final sum     
        sum += idsum;
        sum%=mod;  
    } 
    return sum; 
} 
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
    lli n;
    cin>>n;
    lli a[n];
    for(lli i=0;i<n;i++)cin>>a[i];
    cout<<sumXOR(a,n)%mod;   
    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int k=in.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
			a[i]=in.nextInt();
		int dp[]=new int[n];
		dp[0]=0;
		for(int i=1;i<n;i++)
		{
			dp[i]=dp[i-1]+Math.abs(a[i]-a[i-1]);
			for(int j=2;j<=k;j++)
			{
				if(i-j<0)
					break;
				dp[i]=Math.min(dp[i], dp[i-j]+Math.abs(a[i]-a[i-j]));
			}
		}
		System.out.println(dp[n-1]);
	}
}


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

using namespace std;

#ifdef LOCAL
#define DBG_MACRO_NO_WARNING
#include <dbg.h>
#else
#define dbg(...) 0
#endif

using ll = long long;
using ull = unsigned long long;

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

#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  long double l;
  cin >> l;
  auto ans = pow(l, 3) / 27;

  cout << setprecision(20) << ans << "\n";

  return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;


int main() {
    ll n;
    cin >> n;
    vll nums(n);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    ll ans = __gcd(nums[0], nums[1]);
    for (int i = 2; i < n; ++i) {
        ans = __gcd(ans, nums[i]);
    }
    cout << ans << endl;
    return 0;
}


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

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

	int A, B, ans;
	cin >> A >> B;
	ans = A - B * 2;
	if (ans < 0) ans = 0;
	cout << ans << endl;
	return 0;
}


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


class UnionFind {
private:
    VI par;
    VI sizes;

public:
    UnionFind(int n) : par(n), sizes(n, 1) {
        REP(i, n) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        else return par[x] = this->root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        
        if(x == y) return;
        if (sizes[x] < sizes[y]) swap(x, y);
        
        par[y] = x;
        sizes[x] += sizes[y];
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

    int size(int x) {
        return sizes[root(x)];
    }
};

ll comb2(ll n) {
    return n * (n - 1) / 2;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    VI a(m), b(m);
    REP(i, m) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }

    UnionFind uf(n);
    VL graph_cnt(n, 1);
    VL ans(m);
    ans[m - 1] = comb2(n);
    FORR(i, m - 1, 1) {
        if(!uf.same(a[i], b[i])) {
            ans[i - 1] = ans[i] - graph_cnt[uf.root(a[i])] * graph_cnt[uf.root(b[i])];
            ll cnt = graph_cnt[uf.root(a[i])] + graph_cnt[uf.root(b[i])];
            uf.unite(a[i], b[i]);
            graph_cnt[uf.root(a[i])] = cnt;
            graph_cnt[uf.root(b[i])] = cnt;
        } else {
            ans[i - 1] = ans[i];
        }
    }

    REP(i, m) cout << ans[i] << ln;
    return 0;
}


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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

typedef long long ll;
typedef pair<int, int> PII;

const double EPS = 1e-10;

typedef struct edge_def {
  int from;
  int to;
  int cost;

  edge_def() {;}
  edge_def(int _from, int _to, int _cost) {
    from = _from;
    to   = _to;
    cost = _cost;
  }
} edge;

const int INF = 1000 * 1000 * 1000;
const int N = 100;
int n;
int ed[N];  //ed[i]:??????i???????°???¨?????¨?????¨?????????????????????????????????i??¨??¨?????¨??????????????????????????????
            //????°???¨?????¨????§?????????????????????????????????£????????????
int u[N];  //??¢???????°???¨?????¨???????????????????????????
vector<edge> es[N];

int prim(int s) {
  int i, j, res = 0;
  priority_queue<PII, vector<PII>, greater<PII > > q;
  memset(u, 0, sizeof(u));
  for (i=0; i<n; i++) ed[i] = INF;
  ed[s] = 0;
  q.push(PII(0, s));

  while (q.size()) {
    PII p = q.top(); q.pop();

    u[p.second] = 1;
    res += p.first;

    int m = INF;
    edge me;
    for (i=0; i<n; i++)
      for (j=0; j<(int)es[i].size(); j++) {
        edge e = es[i][j];
        if (u[e.from] && !u[e.to] && e.cost < m) {
          me = e;
          m = me.cost;
        }
      }
    if (m != INF) {
      q.push(PII(me.cost, me.to)); 
      ed[me.to] = me.cost;
    }
  }

  return res;
}


int main() {
  int i, j;
  scanf("%d ", &n);
  int c;
  for (i=0; i<n; i++)
    for (j=0; j<n; j++) {
      scanf("%d ", &c);
      if (c!=-1) es[i].psb(edge(i,j,c));
    }
  printf("%d\n", prim(0));
  return 0;
}

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

using namespace std;


int main() {
    int n = 0, ans = 0;
    cin >> n;

    if (n == 111)ans = 999;
    if (n == 119)ans = 991;
    if (n == 191)ans = 919;
    if (n == 199)ans = 911;
    if (n == 911)ans = 199;
    if (n == 919)ans = 191;
    if (n == 991)ans = 119;
    if (n == 999)ans = 111;
    cout << ans << endl;
}

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

int main (){
    int a,b,c,d1,d2,d3;
    cin >> a >> b >> c;
    if(a>b){
        d1=a-b;
    }else{
        d1=b-a;
    }
    if(b>c){
        d2=b-c;
    }else{
        d2=c-b;
    }
    if(a>c){
        d3=a-c;
    }else{
        d3=c-a;
    }

    if(d1<d2){
        swap(d1,d2);
    }
    if(d2<d3){
        swap(d2,d3);
    }
    if(d1<d2){
        swap(d1,d2);
    }

    cout << d2+d3 << endl;




}

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

using namespace std;

int main(){
    int N;
    cin>>N;
    vector<int> v;
    for(int i=1;i<=N;i++){
        int x;
        cin>>x;
        if(x==i){
            int leng=1;
            while(1){
                i++;
                if(i>N) break;
                int y;
                cin>>y;
                if(y==i){
                    leng++;
                }else{
                    break;
                }
            }
            v.push_back(leng);
        }
    }
    int ans=0;
    for(int i=0;i<v.size();i++){
        ans += (v[i]+1)/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int,input().split(" ")))
for i in range(N):
	A[i] -= (i+1)
A.sort()
if N % 2 == 1:
	b = A[(N//2)]
	ans = list(map(lambda x:abs(x-b),A))
	print(sum(ans))
else:
	b1 = (A[N//2-1] + A[(N//2)])//2
	ans1 = list(map(lambda x:abs(x-b1),A))
	b2 = b1 + 1
	ans2 = list(map(lambda x:abs(x-b2),A))
	print(min(sum(ans1),sum(ans2)))

Measured memory_bytes: 26864
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string color = "rgb";

    for(;;){
        string s;
        cin >> s;
        if(s == "0")
            return 0;
        int n = s.size();

        set<string> worm;
        queue<pair<string, int> > q;
        worm.insert(s);
        q.push(make_pair(s, 0));
        int ok = false;
        while(!q.empty()){
            s = q.front().first;
            int k = q.front().second;
            q.pop();

            ok = true;
            for(int i=1; i<n; ++i){
                if(s[i] != s[i-1]){
                    ok = false;
                    break;
                }
            }
            if(ok){
                cout << k << endl;
                break;
            }

            for(int i=1; i<n; ++i){
                if(s[i] == s[i-1])
                    continue;
                for(int j=0; j<3; ++j){
                    if(s[i] != color[j] && s[i-1] != color[j]){
                        string s1 = s;
                        s1[i] = s1[i-1] = color[j];
                        if(worm.find(s1) == worm.end()){
                            worm.insert(s1);
                            q.push(make_pair(s1, k+1));
                        }
                    }
                }
            }
        }

        if(!ok)
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 1772
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int64_t max(int64_t a, int64_t b)
{
    return a > b ? a : b;
}

int main (void)
{
    intmax_t A, B;
    intmax_t add, sub, mul, ans = 0;

    scanf("%jd%jd", &A, &B);

    add = A + B;
    sub = A - B;
    mul = A * B;

    ans = max(add, max(sub, mul));

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	#define int long long
	int n, m, k, x, t, maxx=0;
	cin >> n >> m >> k;
	int a[n+1], b[m+1];
	a[0]=0, b[0]=0;
	for (int i=1; i<=n; i++){
		cin >> x;
		a[i]=a[i-1]+x;
	}
	for (int i=1; i<=m; i++){
		cin >> x;
		b[i]=b[i-1]+x;
	}
	int L=0, R=n+m, lastf, lastr;
	while (L<=R){
		lastf=L, lastr=R;
		bool f=false;
		int Mid=(L+R)/2;
		for (int i=0; i<=min(n, Mid); i++)
			if (Mid-i<=m){
				t=a[i]+b[Mid-i];
				if (t<=k){
					maxx=max(maxx, Mid);
					f=true;
					break;
				}
			}
		if (f) L=Mid;
		else R=Mid;
		if (lastf==L&&lastr==R){
			f=false;
			for (int i=0; i<=min(n, R); i++)
				if (R-i<=m){
					t=a[i]+b[R-i];
					if (t<=k){
						cout << max(maxx,R) << endl;
						return 0;
					}
				}
			L=R+1;
		}
	}
	cout << maxx << endl;
	return 0;
}


Measured memory_bytes: 6648
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	vector<int> a(3);
	for (int i = 0; i < 3; i++)
		cin >> a[i];
	vector<int> p(3);
	for (int i = 0; i < 3; i++)
		p[i] = i;
	int result = 1000000000;
	do
	{
		int res = 0;
		for (int i = 1; i < 3; i++)
			res += abs(a[p[i - 1]] - a[p[i]]);
		result = min(result, res);
	}	
	while (next_permutation(p.begin(), p.end()));
	cout << result << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int n;
int I[555];
int S,A,C;
const int mod = 256;
int r[555];

int R(int i)
{
  if(i==0)return r[i]=S;
  return r[i]=(A*R(i-1)+C)%mod;
}

int main(void)
{
  typedef long double ldouble;
  for(;;) {
    scanf("%d",&n); if(!n) break;
    for(int i = 0; i < n; i++) {
      scanf("%d", I+i);
    }
    ldouble res = 1<<21;
    int s,a,c;
    int o[256];
    for(int i = 0; i < 16; i++) {
      for(int j = 0; j < 16; j++) {
        for(int k = 0; k < 16; k++) {
          S = i; A = j; C = k;
          for(int ii = 0; ii < 256; ii++) {
            o[ii] = 0;
          }
          R(n);
          for(int ii = 0; ii < n; ii++) {
            o[(I[ii]+r[ii+1])%mod]++;
          }
          ldouble h = 0;
          for(int ii = 0; ii < 256; ii++) {
            if(o[ii]) {
              h += ((ldouble(o[ii])/n)*log(ldouble(o[ii])/n));
            }
          }
          h = -h;
          //if(S==8&&A==7&&C==14)printf("v:%.10Lf\n",h);
          if( res > h+1e-8 ) {
            //printf("%.10Lf %.10Lf %d %d %d\n",res,h,S,A,C);
            res = h;
            s = S;
            a = A;
            c = C;
          }
        }
      }
    }
    printf("%d %d %d\n",s,a,c);
  }
  return 0;
}

Measured memory_bytes: 1048
def main():
    N,K=map(int,input().split())
    A=[int(x) for x in input().split()]
    
    dictionary={}
    for num in A:
        if num in dictionary:
            dictionary[num]+=1
        else:
            dictionary[num]=1
    
    ans=0  
    i=0
    
    if len(dictionary)<=K:
        ans=0
    else:
        for value in sorted(dictionary.values()):
            if (i==len(dictionary)-K):
                break
            else:
                ans+=value
                i+=1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 33152
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
input:
3 4 6
0 0
0 2
0 3
1 1
2 1
2 3

output:
3
"""

import sys


def dfs(current, matching, visited):
    for target in range(y_num):
        if not visited[target] and target in adj_table[current]:
            visited[target] = True
            ''' Matching[target] = -1: target not assigned to any of x.
            And dfs(matching[target], matching, visited) = True
            indicates that source in x has been already assigned
            to another target in y. '''
            if matching[target] == -1 or dfs(matching[target], matching, visited):
                matching[target] = current
                return True
    return False


def mbm():
    res = 0
    matching = [-1] * y_num
    for source in range(x_num):
        visited = [False] * y_num
        if dfs(source, matching, visited):
            res += 1
    return res


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    x_num, y_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    adj_table = tuple(set() for _ in range(x_num))
    for edge in edges:
        vx, vy = map(int, edge)
        adj_table[vx].add(vy)
    print(mbm())

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  ll ai, ao, at, aj, al, as, az; cin >> ai >> ao >> at >> aj >> al >> as >> az;

  ll cnt1 = 0, cnt2 = 0;
  cnt1 = ao + ai - ai % 2 + aj - aj % 2 + al - al % 2;
  ai--; aj--; al--;
  if(ai >=0 && aj >= 0 && al >= 0) cnt2 = ao + ai - ai % 2 + aj - aj % 2 + al - al % 2 + 3;

  cout << max(cnt1, cnt2) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const int INF=100100100;
const double PI=3.141592653589;


int main(){
  int n,k; cin>>n>>k;
  bool ans=0;
  if((n-1)*(n-2)/2<k)
  ans=1;

  vector<P> p;
  if(ans)
  cout<<-1<<endl;
  else{
    for(int i=1;i<n;i++){
      p.push_back({1,i+1});
    }
    // k=(n-1)*(n-2)/2-x
    vector<P> ad;
    for(int i=2;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        ad.push_back({i,j});
      }
    }
    rep(i,(n-1)*(n-2)/2-k){
      p.push_back(ad[i]);
    }
    cout<<p.size()<<endl;
    rep(i,p.size()){
      cout<<p[i].first<<" "<<p[i].second<<endl;
    }

  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a[1000];
    int n;
    
    cin>>n;
    int i;
    for(i=0;i<=n;i=i+1)
    {cin>>a[i];}
    
    int j;
    for(j=n-1;j >-1;j=j-1)
    {cout<<a[j];
    
    if(j>0){cout<<" ";}
    if(j==0){cout<<endl;}
}
}


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

using namespace std;
using ll = long long;

struct Node {
	vector<int> child;
	int r;
	
	Node() {r = 0;}
};

void Weight(vector<Node> &nodes, int n, int t) {
	nodes[n].r += t;
	for(int j=0; j<nodes[n].child.size(); j++) {
		Weight(nodes, nodes[n].child[j], nodes[n].r);
	}
}

int main() {
	
	int N, Q, tmp1, tmp2;
	vector<int> a, b;
	
	cin >> N >> Q;
	vector<Node> nodes(N);
	
	for(int i=0; i<N-1; i++) {
		cin >> tmp1 >> tmp2;
		nodes[tmp1-1].child.push_back(tmp2-1);
	}
	
	for(int i=0; i<Q; i++) {
		cin >> tmp1 >> tmp2;
		nodes[tmp1-1].r += tmp2;
	}
	
	Weight(nodes, 0, 0);
	for(int i=0; i<N; i++) {
		printf("%d ", nodes[i].r);
	}
	
	return 0;
}


Measured memory_bytes: 21120
fn main() {
    let (n, m) = read_tuple();
    let mut g: Vec<Vec<usize>> = Vec::new();
    for _ in 0..n+1 {
       g.push(Vec::new());
    }
    for _ in 0..m {
        let (x, y) = read_tuple();
        g[x].push(y);
    }

    let mut res: i32 = 0;
    let mut dp = vec![-1; n+1];
    for i in 1..n+1 {
        chmax(&mut res, dfs(&g, i, &mut dp));
    }

    println!("{}", res);
}

fn dfs(g: &Vec<Vec<usize>>, i: usize, dp: &mut Vec<i32>) -> i32 {
    if dp[i] != -1 {
        return dp[i]
    }

    let mut res = 0;
    for n in g[i].clone() {
        chmax(&mut res, dfs(g, n, dp) + 1);
    }

    dp[i] = res;
    res
}

fn chmax(a: &mut i32, b: i32) {
    if *a < b {
        *a = b;
    }
}

fn read_tuple() -> (usize, usize) {
    let v = read_vec::<usize>();
    (v[0], v[1])
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 17272
#include <bits/stdc++.h>
using namespace std;
#define REP(i, M) for (int i = 0; i < M; i++)
int main() {
  string s;
  cin >> s;
  int n = s.size();
  bool res = true;
  for (int i = 0; i < n - 1; i += 2) {
    if (s.at(i) != 'R' && s.at(i) != 'U' && s.at(i) != 'D') {
      res = false;
    }
    if (s.at(i + 1) != 'L' && s.at(i + 1) != 'U' && s.at(i + 1) != 'D') {
      res = false;
    }
  }
  if (n % 2 != 0) {
    if (s.at(n - 1) != 'R' && s.at(n - 1) != 'U' && s.at(n - 1) != 'D') {
      res = false;
    }
  }
  if (res) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

ll N, K;
map<ll, ll> Pattern;    // key: 探索パターン, val: その時の最大値

int main()
{
    cin >> N >> K;

    // K から見るべきパターンを列挙
    Pattern[K] = 0;     // K 自身
    for(int i = 31; i >= 0; --i) {
        if(((K >> i) & 1) == 1) {
            ll key = K & (~(1 << i));
            key |= ((1 << i) - 1);
            Pattern[key] = 0;
        }
    }

    ll ans = 0;
    REP(i, N) {
        ll a, b;
        scanf("%lld %lld", &a, &b);
        for(auto pat : Pattern) {
            if((pat.first | a) == pat.first) {
                pat.second += b;
                Pattern[pat.first] = pat.second;
                ans = max(ans, pat.second);
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <bits/stdc++.h> // only for GCC

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

//container util
//------------------------------------------
#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

//repetition
//------------------------------------------
#define loop(i,a,b) for(ull i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)
#define iter(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define riter(i,c) for(auto i=(c).rbegin(); i!=(c).rend(); ++i)

//constant
//--------------------------------------------
const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

// output vector
// ------------------------------------------
namespace std {
    template<typename T>ostream&operator<<(ostream&os, vector<T>const&v){
        iter(it,v) os<<*it<<(it+1==v.end()?"":",");
        return os;
    }
    template<typename T, typename U>ostream&operator<<(ostream&os,const pair<T,U>&p){
        return os << "[" << p.dirst << "," << p.second << "]";
    }
}

//clear memory
// ------------------------------------------
#define clr(a,i) memset((a), (i) ,sizeof(a))

int main(){
   int ans;
   string s;
   while(getline(cin,s)){
      ans=0;
      rep(i,s.size()-1){
         if(s[i]=='M') ans+=1000;
         else if(s[i]=='D'){
            if(s[i+1]=='M') ans-=500;
            else ans+=500;
         } else if(s[i]=='C'){
            if(s[i+1]!='D'&&s[i+1]!='M') ans+=100;
            else ans-=100;
         }else if(s[i]=='L'){
            if(s[i+1]!='C'&&s[i+1]!='D'&&s[i+1]!='M') ans+=50;
            else ans-=50;
         }else if(s[i]=='X'){
            if(s[i+1]=='X'||s[i+1]=='V'||s[i+1]=='I') ans+=10;
            else ans-=10;
         }else if(s[i]=='V'){
            if(s[i+1]=='I') ans+=5;
            else ans-=5;
         }else if(s[i]=='I'){
            if(s[i+1]=='I') ans+=1;
            else ans-=1;
         }
      }
      if(s[s.size()-1]=='M') ans+=1000;
      if(s[s.size()-1]=='D') ans+=500;
      if(s[s.size()-1]=='C') ans+=100;
      if(s[s.size()-1]=='L') ans+=50;
      if(s[s.size()-1]=='X') ans+=10;
      if(s[s.size()-1]=='V') ans+=5;
      if(s[s.size()-1]=='I') ans+=1;
      cout << ans << endl;
   }
}

Measured memory_bytes: 1180
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


M_1, D_1 = zz()
M_2, D_2 = zz()
if (M_1 == M_2):
    print(0)
else:
    print(1)


Measured memory_bytes: 42080
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = Integer.parseInt(scanner.nextLine());
        int b = Integer.parseInt(scanner.nextLine());
        int c = Integer.parseInt(scanner.nextLine());
        int x = Integer.parseInt(scanner.nextLine());

        int result = 0;
        for (int i500 = 0; i500 <= a; i500++) {
            for (int i100 = 0; i100 <= b; i100++) {
                int rest = (x - 500 * i500 - 100 * i100);
                if (rest >= 0 && rest == Math.min(rest / 50, c) * 50) {
                    result++;
                }
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<complex>
#include<algorithm>
#define EPS 1e-6
using namespace std;

typedef complex<double> P;

int n,m;
P p[100][4];

double cross(P a,P b){return imag(conj(a)*b);}
double dot(P a,P b){return real(conj(a)*b);}
/*
bool is_cp(P a1,P a2,P b1,P b2){
  if(cross(a2-a1,b1-a1) * cross(a2-a1,b2-a1) < EPS)
    if(cross(b2-b1,a1-b1) * cross(b2-b1,a2-b1) < EPS)return true;
  return false;
}

bool interp(int q,P x){
  P tmp = P(10000,x.imag());
  bool res = false;
  for(int i=0;i<4;i++)if(is_cp(p[q][i],p[q][(i+1)%4],x,tmp))res=!res;
  return res;
}
*/

int ccw(P a,P b,P c){
  b -= a;c -= a;
  if (cross(b,c)>EPS) return 1;
  if (cross(b,c)<-EPS) return -1;
  if (dot(b, c)<-EPS) return 2;
  if (abs(b)<abs(c)) return -2;
  return 0;
}
bool is_cp(P a1, P a2, P b1, P b2){
    return ( ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0 &&
     ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0 );
}
bool interp(int q, P x){
  for(int i=0;i<4;i++){
    if ( ccw(p[q][i], p[q][(i+1)%4], x ) == 1 ) return false;
  }
  return true;
}
bool inter(int q1,int q2){
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
      if(is_cp(p[q1][i],p[q1][(i+1)%4],p[q2][j],p[q2][(j+1)%4]))return true;
  for(int i=0;i<4;i++)if(interp(q1,p[q2][i]))return true;
  for(int i=0;i<4;i++)if(interp(q2,p[q1][i]))return true;
  return false;
}

int par[100];
int rank[100];

void init(int n){
  for(int i=0;i<n;i++){
    par[i] = i;
    rank[i] = 0;
  }
}

int find(int x){
  if(par[x] == x)return x;
  return par[x] = find(par[x]);
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x==y)return;

  if(rank[x] < rank[y])par[x] = y;
  else{
    par[y] = x;
    if(rank[x] == rank[y])rank[x]++;
  }
}

int main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> m;
      for(int j=0;j<m;j++)
	for(int k=0;k<4;k++)cin >> p[j][k].real() >> p[j][k].imag();

      init(m);

      for(int j=0;j<m;j++)
	for(int k=0;k<j;k++)
	  for(int l=0;l<4;l++)
	    if(inter(j,k))unite(j,k);

      int ans = 0;
      for(int j=0;j<m;j++){
	find(j);
	if(par[j]==j)ans++;
      }
      cout << ans << endl;
    }
  }
}

Measured memory_bytes: 984
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
??????????????????
??????????????????????????????????????¨?????????????????????Bubble??????
?°´??¢???????????£???????????????????????????????´????????????????????????????
??????????????????????¬???????????????¢?????´???????????§??°????????????????????????????????????

1 bubbleSort(A, N) // N ??????????´?????????? 0-????????????????????? A
2   flag = 1 // ????????£??\????´?????????¨??????
3   while flag
4     flag = 0
5     for j ??? N-1 ?????? 1 ?????§
6       if A[j] < A[j-1]
7         A[j] ??¨ A[j-1] ?????????
8         flag = 1

"""
import math

def bSort(A, N):
    cnt = 0
    f = True
    s = N-1
    e = 0
    while f == True:
        f = False
#        print("start={0} end={1}\n".format(s, e))
        for j in range(s, e, -1):
            x = A[j]
            y = A[j-1]
#            print("A[{0}]={1} A[{2}]={3}".format(j, x, j-1, y))
#            print(A)
            if x < y:
#                print("swap {0} {1}".format(x, y))
                A[j] = y
                A[j-1] = x
                f = True
                cnt += 1
        e += 1
        if e > s:
            break
    return cnt

# ?????????
N = int(input().strip())
A = list(map(int,input().strip().split()))
cnt = bSort(A,N)
print(" ".join(map(str,A)))
print(cnt)

Measured memory_bytes: 7848
#include <iostream>

using namespace std;
typedef long long ll;


int main() {
    ll s = 0;
    int N;
    cin >> N;
    for (int i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) s+= i;
    }

    cout << s << endl;
}


Measured memory_bytes: 3164
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <cstring>
using namespace std;
const char *t1=" ',-.?ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const char *v1[]={"101","000000","000011","10010001","010001","000001","100101","10011010","0101","0001","110","01001","10011011","010000","0111","10011000","0110","00100","10011001","10011110","00101","111","10011111","1000","00110","00111","10011100","10011101","000010","10010010","10010011","10010000"};
const char *t2="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
int main(){
  string s,t,z;
  int i,j,x;
  map<string,char>m;
  for(i=0;i<32;i++)m[string(v1[i])]=t1[i];
  for(;z=t="",getline(cin,s);cout<<t<<endl){
    for(i=0;i<s.size();i++)
      if((j=strchr(t2,s[i])-t2)+t2)z+=bitset<5>(j).to_string();
    for(x=i=0;;i+=j){
      for(j=1;i+j<=z.size();j++){
        if(m[z.substr(i,j)]){x=0;t+=m[z.substr(i,j)];break;}
      }
      if(i+j>z.size())break;
    }
  }
}

Measured memory_bytes: 0
import math
t=int(input())
for i in range(t):
 a,b,c,d=map(int,input().split())
 if b>a:print("No")
 elif b>d:print("No")
 elif c>=b:print("Yes")
 else:g=math.gcd(b,d);print("Yes"if c>=a%g+b-g else"No")

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, n) for(int i = n-1; i >= 0; i--)
#define rep4(i, x, n) for(int i = x; i > n; i--)
#define elif else if
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const ll INF = 1e15;

ll gcd(ll x, ll y){
    ll a = max(x, y);
    ll b = min(x, y);
    while(b > 0){
        ll s = a%b;
        ll t = b;
        a = t;
        b = s;
    }
    return a;
}

int main(){
    int T;
    cin >> T;
    ll A, B, C, D;
    string S[T];
    string yes = "Yes";
    string no = "No";
    rep(i, T){
        cin >> A >> B >> C >> D;
        if(A < B) S[i] = no;
        elif(B > D) S[i] = no;
        elif(C >= B-1) S[i] = yes;
        elif(A % B > C) S[i] = no;
        else{
            ll a = A % B;
            ll g = gcd(B, D);
            ll m = a + ((C-a)/g + 1)*g;
            if(0 <= m-B) S[i] = yes;
            else S[i] = no;
        }
    }
    rep(i, T) cout << S[i] << endl;
}

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

int n,k,a[505000],bel[505000],L[1010],R[1010],mn[1010],an[1010],pos[1010],sz=500,tot,ans[505000],inf=1e8;

void RE(int w){
	int now=inf,res=inf,p;
	for (int i=L[w];i<=R[w];++i){
		if (now-a[i]>=k&&res>a[i]) res=a[i],p=i;
		now=min(now,a[i]);
	}
	mn[w]=now, an[w]=res, pos[w]=p;
}

int doit(){
	int now=inf,res=inf,p;
	for (int i=1;i<=tot;++i){
		if (now-an[i]>=k&&res>an[i]) res=an[i],p=i;
		now=min(now,mn[i]);
	}
	return pos[p];
}

int main(){
	cin>>n>>k; for (int i=1,x;i<=n;++i) scanf("%d",&x), a[x]=i, tot=bel[i]=(i-1)/sz+1;
	for (int i=1;i<=tot;++i) L[i]=i*sz-sz+1, R[i]=min(n,i*sz), RE(i);
	for (int i=1,p;i<=n;++i) ans[a[p=doit()]]=i, a[p]=inf, RE(bel[p]);
	for (int i=1;i<=n;++i) printf("%d\n",ans[i]);
}

Measured memory_bytes: 9472
n = int(input())
A = list(map(int, input().split()))
l = [0]*50
for s in A:
    b = list(bin(s))
    b = b[::-1]
    for ii, ss in enumerate(b):
        if ss == "b":
            break
        if ss == "1":
            l[ii] = (l[ii]+1) % 2
e = 1
num = 0
for i in range(50):
    num += l[i]*e
    e = e*2
for s in A:
    print(s ^ num)


Measured memory_bytes: 31696
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

//右下左上
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    string s, t;
    cin >> s >> t;
    print(s == t.substr(0, s.size()));
}


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

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

  int d, n;
  cin >> d >> n;
  int res = pow(100, d) * n;
  if (n == 100) res += pow(100, d);
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func group(i int) int {
	switch i {
	case 1, 3, 5, 7, 8, 10, 12:
		return 1
	case 4, 6, 9, 11:
		return 2
	case 2:
		return 3
	}
	return 0
}

func (con *contest) main() error {
	var x, y int
	con.Scan(&x, &y)
	if group(x) == group(y) {
		con.Println("Yes")
	} else {
		con.Println("No")
	}
	return nil
}


Measured memory_bytes: 640
import Data.Char
key = ["the", "this", "that"]

f n a =
  if a == '.' || a == ' '
  then a
  else 
    let i = (ord a) - (ord 'a')
        o = (n + i) `mod` 26
    in
      chr (o + ord 'a')

try w =
  filter(\(n,w) -> w=="the" || w=="this" || w=="that") $ map (\n -> (n,map (f n) w)) [0..25]

ans s =
  let c = filter (\x->length(x)==3 || length(x)==4 ) s
      r = map try c
      (n,_) = head $ concat r
  in
    map (map (f n)) s


spt :: String -> [String]
spt [] = []
spt s@(sh:ss)
  | sh == ' ' || sh == '.' = let ss = takeWhile (== sh) s
                                 rr = dropWhile (== sh) s
                             in
                               ss:(spt rr)
spt s@(sh:ss) =
  let ss = takeWhile (\c -> c /= ' ' && c /= '.') s
      rr = dropWhile (\c -> c /= ' ' && c /= '.') s
  in
    ss:(spt rr)

main = do
  c <- getContents
  let i = map spt $ lines c
      o = map ans i
  mapM_ putStrLn $ map concat o

Measured memory_bytes: 3888
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

int main()
{
        //input->compute->output//
        int N, M, X;
        cin >> N >> M >> X;

        int ans = 0;
        for (int i = 0; i < N; i++)
        {
                int cnt = 0;
                int a;
                cin >> a;
                for (int j = 1; j <= M; j += a)
                {
                        cnt++;
                }
                ans += cnt;
        }
        cout << ans + X << endl;

        return 0;
}


Measured memory_bytes: 256
#include <iostream>                                             
using namespace std;                                            
                                                                
int main() {                                                    
  int a, b;                                                     
  cin >> a >> b;                                                
  int S = a*b;                                                  
  int R = 2*(a+b);                                              
  cout << S << " " << R << endl;                                
  return 0;                                                     
}                                                               
                   

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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    bool f = false;
    int c = 0;
    while (n--) {
        int a, b; cin >> a >> b;
        if (a == b) {
            c++;
            f |= (c >= 3);
        }
        else {
            c = 0;
        }
    }
    cout << (f ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3632
import sys
from itertools import accumulate
def input(): return sys.stdin.readline().strip()


def get_sieve_of_eratosthenes(n):
    """
    エラトステネスの篩。√N以下の数に対して2から順にその数の倍数を消していく。
    計算量は「調和級数」になるのがミソ。具体的には
        N/2 + N/3 + N/5 + ... + N/(√N) = N * (1/2 + 1/3 + 1/5 + ... + 1/√N)
                                       = N * loglog(√N) (素数の逆数和の発散スピードがこれ)
                                       = N(loglogN - log2)
    """
    if not isinstance(n, int):
        raise TypeError('n is int type.')
    if n < 2:
        return []
    prime = [1] * (n + 1)
    prime[0] = prime[1] = 0
    for i in range(2, int(n**0.5) + 1):
        if not prime[i]: continue
        for j in range(i * 2, n + 1, i):
            prime[j] = 0
    return prime


def main():
    primes = get_sieve_of_eratosthenes(100000)
    like = [0] * 10**5
    for i in range(3, 10**5):
        if primes[i] and primes[(i + 1) // 2]:
            like[i] = 1
    like = list(accumulate(like))

    q = int(input())
    for _ in range(q):
        l, r = map(int, input().split())
        if l < 3: l = 3
        if r < 3:
            print(0)
            continue
        print(like[r] - like[l - 1])



if __name__ == "__main__":
    main()


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

int main() {
	int n, a, b, c;
	cin >> n >> c;
	c /= 1000;
	b = min(c / 5, (c - n) / 4);
	c -= 5 * b;
	a = min(b / 2, b + c - n);
	b -= 2 * a;
	if (a < 0 || b < 0 || c < 0 || a + b + c != n) {
		a = b = c = -1;
	}
	cout << a << " " << b << " " << c << endl;
	return 0;
}


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

bool eratoes[201];
void init(){
	for(int i=1; i<=200; i++){
		eratoes[i] = true;
	}
	for(int i=2; i<=15; i++){
		if(eratoes[i]){
			for(int j=i*i; j<=200; j+=i) eratoes[j]=false;
		}
	}
}
int solve(int small,int a,int b){
	if(a%small==0 && b%small==0) return small;
	if(eratoes[small]) return 1;
	//가장 작은게 소수가 아니다. 
	for(int i=small-1; i>=1; i--){
		if(small%i==0 && a%i==0 && b%i==0) return i;
	}
}
int main(){
	int k;
	cin>>k;
	init();
	long long ret=0;
	for(int a=1; a<=k; a++){
		for(int b=1; b<=k; b++){
			for(int c=1; c<=k; c++){
				if(a==1 || b==1 || c==1) ret+=1;
				else{
					if(a<=b && a<=c) ret+=solve(a,b,c);
					else if(b<=a && b<=c) ret+=solve(b,a,c);
					else ret+=solve(c,a,b);
				}
			}
		}
	}
	cout<<ret;
}

Measured memory_bytes: 3132
using System;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var W = int.Parse(input[0]);
            var H = int.Parse(input[1]);
            var x = int.Parse(input[2]);
            var y = int.Parse(input[3]);
            var r = int.Parse(input[4]);

            var left = r;
            var top = H - r;
            var right = W - r;
            var down = r;

            if ((left <= x) && (x <= right) && (down <= y) && (y <= top))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 19612
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for(ll i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(ll i=int(m)-1; i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;

int n;

int dfs(ll x, int S) {
  if (x > n) return 0;
  int res = 0;
  if (S == 7) ++res; 
  res += dfs(10*x + 3, S | 1);
  res += dfs(10*x + 5, S | 2);
  res += dfs(10*x + 7, S | 4);
  return res;
}

int main() {
  cin >> n;
  cout << dfs(0, 0) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> T _max(T a,T b){return a>b ? a : b;}
template <class T> T _min(T a,T b){return a<b ? a : b;}
template <class T> bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=2005;
int n,a[N];
bitset<N*N> S;
void init()
{
	read(n);
	for (int i=1;i<=n;++i)
	{
		read(a[i]);
	}
}

void solve()
{
	S[0]=1;
	int sum=0;
	for (int i=1;i<=n;++i)
	{
		S|=(S<<a[i]); 
		sum+=a[i];
	}
	for (int i=(sum+1)/2;;++i)
	{
		if (S[i])
		{
			printf("%d\n",i);
			return;
		}
	}
} 
       
#undef int
int main()
{
	init();
	solve();
    return 0;
}

Measured memory_bytes: 5276
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict, deque
    # import math
    # import random
    input = stdin.readline


    x = int(input())

    squared = [0]*401
    for i in range(-200, 201):
        squared[i+200] = i**5

    ans_dict = dict()
    
    for i in range(401):
        for j in range(i, 401):
            temp = squared[j]-squared[i]
            ans_dict[temp] = (j-200, i-200)
    a, b = ans_dict[x]
    print(a, b)







Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n=s.size();
  string target="keyence";
  if(s==target){
    cout << "YES" << endl;
    return 0;
  }
  for(int i=0;i<n;i++){
    for(int j=i;j<n;j++){
      string S="";
      for(int k=0;k<n;k++){
        if(i<=k && k<=j)continue;
        S.push_back(s[k]);
      }
      if(target==S){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    cin.tie(0);ios::sync_with_stdio(false);
    int n;cin>>n;
    if(n<1200)cout<<"ABC"<<endl;
    else if(n<2800)cout<<"ARC"<<endl;
    else cout<<"AGC"<<endl;
    
    return 0;
}


Measured memory_bytes: 256