akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define F first
#define S second
#define ll long long
const int MOD = 1e9 + 7;
const float epsilon = 0.0005f;
const float PI = 3.1415926535897932384626433f;
 
vector<pair<int,int>> dire{{0,1},{0,-1},{1,0},{-1,0}};
 
// std::cout << std::fixed;
// std::cout << std::setprecision(9);

ll powe(ll a,ll b){
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%MOD;
        a = a * a%MOD;
        b >>= 1;
    }
    return res;
}

void solve(){
    ll n;
    cin >> n;
    ll ans = 0;
    if(n == 1){
        cout << 0 << "\n";
        return;
    }
    if(n == 2){
        cout << 2 << "\n";
        return;
    }
    ans = ans % MOD + powe(10, n) % MOD;
    ans = ans % MOD;
    ans = ans % MOD + powe(8, n) % MOD;
    ans = ans % MOD;
    ans = ans % MOD - powe(9, n) % MOD;
    ans = ans % MOD;
    ans = ans % MOD - powe(9, n) % MOD;
    ans = ans % MOD;
    ans = (ans + MOD) % MOD;
    cout << ans << "\n";
}
    
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    // int t;cin>>t;
    // for(int i = 0;i<t;++i){
    //     solve();
    // }
    solve();
    return(0);
}

Measured memory_bytes: 3616
import java.util.*;
public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int hug = 0;
        if(str.length()%2 == 0){
            for(int i =0; i<str.length()/2;i++){
                if(str.charAt(i)!=str.charAt(str.length()-1-i)){
                    hug ++;
                }
            }
        }else{
            for(int i =0; i<(str.length()-1)/2;i++){
                if(str.charAt(i)!=str.charAt(str.length()-1-i)){
                    hug ++;
                }
            }
        }
        System.out.println(hug);
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int mx=1e6+777;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll A,B; cin>>A>>B;
	ll G=__gcd(A,B);
	vector<int> flag(mx,true);
	flag[0]=flag[1]=false;
	for (int i=2; i*i<mx; i++)
		if(flag[i])
			for (int j=i; j*i<mx; j++)
				flag[i*j]=false;
	int ret=1;
	for (int i=0; i<mx; i++) {
		if(!flag[i])
			continue;
		int d=i;
		bool ok=false;
		while(G%d==0)
			G/=d, ok=true;
		if(ok) ret++;
	}
	if(G>1) ret++;
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 4224
#include <stdio.h>
int main(void){
  int x,y,sum=0;
  scanf("%d %d", &x, &y);
  for(int i=0;i<x;i++){
    for(int s=0;s<=100;s++){
      for(int t=0;t<=100;t++){
        sum=2*s+4*t;
        if(s+t==x&&sum==y){
          puts("Yes");
          return 0;
        }
      }
    }
  }
  puts("No");
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007

ll A, B, Q;
vector<ll> s,t;
int main() {
	cin >> A >> B >> Q;
	REP(i, A) {
		ll a;
		cin >> a;
		s.push_back(a);
	}
	REP(i, B) {
		ll a;
		cin >> a;
		t.push_back(a);
	}
	REP(i, Q) {
		ll x,lt = INF64 / 100,rt = INF64 / 100,ls = INF64 / 100,rs = INF64 / 100, ans = INF64;
		cin >> x;
		auto i1 = lower_bound(ALL(s), x);
		auto i2 = lower_bound(ALL(t), x);
		if (i1 - s.begin() > 0) ls = abs(s[i1 - s.begin() - 1] - x);
		if (i2 - t.begin() > 0) lt = abs(t[i2 - t.begin() - 1] - x);
		if (s.end() - i1 > 0) rs = abs(s[i1 - s.begin()] - x);
		if (t.end() - i2 > 0) rt = abs(t[i2 - t.begin()] - x);
		ans = min(ans, max(lt, ls));
		ans = min(ans, max(rt, rs));
		ans = min(ans, lt + rs * 2);
		ans = min(ans, lt * 2 + rs);
		ans = min(ans, rt + ls * 2);
		ans = min(ans, rt * 2 + ls);
		cout << ans << endl;
	}
}




Measured memory_bytes: 3060
n = int(input())
rooms = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
for rec in range(n):
    b, f, r, v = map(int, input().split())
    rooms[b-1][f-1][r-1] += v
    
for i, b in enumerate(rooms):
    for f in b:
        print("",*f)
    if i != 3:
        print("####################")

Measured memory_bytes: 7664
#include <stdio.h>

int a, b;

int main() {
	scanf("%d %d", &a, &b);
	if (a < b) {
		printf("a < b\n");
	} else if (a > b) {
		printf("a > b\n");
	} else {
		printf("a == b\n");
	}
	return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;

int main()
{
    ios::sync_with_stdio(false);
    int n , x , t; cin >> n >> x >> t;
    cout << (n / x + (n % x != 0)) * t << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

#define ll long long
#define sq(a) (a)*(a)
#define caset int t; cin >> t; while(t--)
#define get1(a) ll int a; cin>>a;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define line '\n'

#define vi(v)	vector < int > v;
#define	all(v)	v.begin(), v.end()


//#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)   #ifndef ONLINE_JUDGE   freopen("input.txt","r",stdin);		freopen("output.txt","w",stdout); 	#endif




int main() {

	int k,a,b,c=0,i=1;
	cin>>k>>a>>b;
    while(true)
    {
        if(k*i>=a&&k*i<=b)
         {
             c=1;break;
         }
        else if(k*i>b)
            break;
        else
            i++;
    }
    if(c==1)
        cout<<"OK";
    else
        cout<<"NG";
    return 0;

}



Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
long long gcd(long long a, long long b) { return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b) { return a/gcd(a,b)*b;}

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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


  int v[n][3];
  rep (i, n) {
    cin >> v[i][0] >> v[i][1] >> v[i][2];
  }

  int dp[n + 5][3];
  rep (i, n + 5) {
    rep (j, 3) {
      dp[i][j] = 0;
    }
  }

  rep (i, n) {
    rep (j, 3) {
      rep (target, 3) {
        int ni = i + 1;
        int nj = target;
        if (j == nj) continue;
        dp[ni][nj] = max(dp[ni][nj], dp[i][j] + v[i][j]);
      }
    }
  }

  // cout << "============" << endl;
  // rep (i, n + 1) {
  //   rep (j, 3) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }

  cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;

  return 0;
}

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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
const int N = 3001;

signed main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  bool data1[3001] = {0}, data2[3001] = {0};
  
  Rep(i, F+1) Rep(j, F+1) {
    int tmp = A*i + B*j;
    if ( tmp*100 <= F ) data1[tmp] = true;
  }

  Rep(i, F+1) Rep(j, F+1) {
    int tmp = C*i + D*j;
    if ( tmp <= F ) data2[tmp] = true;
  }

  double mx = -1.0;
  int sum = 0, ans = 0;
  Rep(i, F+1) {
    if ( !data1[i] ) continue;
    Rep(j, F+1) {
      if ( !data2[j] ) continue;
      if ( i*100 + j <= F && mx < (double)j * 100.0 / (double)(i*100 + j) && (double)E >= (double)j / (double)i ) {
	mx =  (double)j * 100.0 / (double)(i*100 + j);
	sum = i*100 + j;
	ans = j;
      }
    }
  }

  cout << sum << " " << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for( int i=a; i<b; i++ )
#define REP(i,n) rep(i,0,n)
using lli = long long int;
using ulli = unsigned long long int;
typedef pair<lli,lli> P;
struct edge{ int u, v, cost; };
struct DirectedGraph
{
  int vertex_num;
  int edge_num;
  vector<edge> edge_list;
  vector< vector<int> > adj_list;
};

void displayVector(vector<lli> v)
{
	lli n = v.size();
	REP(i,n){
		cout << v[i] << " " ;
	}
	cout << endl;
}

vector<lli> argsort(vector<lli> v)
{
	lli n = v.size();
	vector<lli> indices(n);
	REP(i,n){ indices[i] = i; }

	sort(indices.begin(), indices.end(), [&v](lli i1, lli i2) {
        return v[i1] > v[i2];
  });

	return indices;
}


int main(){
	int N; cin >> N;
	lli Y; cin >> Y;
	int jud = 0;
	REP(x, Y/10000 + 1){
		REP(y, Y/5000 + 1){
			int z = N - x - y;
			if(z<0){break;}
			if( lli(10000*x + 5000*y + 1000*z) == Y){
				cout << x << " " << y << " " << z << endl;
				jud = 1;
				break;
			}
		}
		if(jud==1) break;
	}

	if(jud==0){ cout << "-1 -1 -1" << endl; }
  return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();

        var r = 0;
        var b = 0;
        for (int i = 0; i < n; i++)
        {
            if (s[i] == 'R')
            {
                r++;
            }
            else
            {
                b++;
            }
        }

        if (b < r)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>

using namespace std;

int main() {

	int n;
	cin >> n;
	long a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}

	for (int i = n - 1; i >= 0; i--) {
		if (i == n - 1) {
			cout << a[i];
		} else {
			cout << " " << a[i];
		}
	}
	cout << endl;
	
	return 0;

}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

long long gcd(long long a, long long b) { return b ? gcd(b, a%b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

long long ngcd(vector<long long> a) {
  long long res = a[0];
  for(int i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}

const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n,X; cin>>n>>X;
  vll a(n);
  rep(i,n){
    int x; cin>>x;
    a[i]=abs(X-x);
  }
  cout<<ngcd(a)<<endl;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

typedef long long ll;

string str;
int pos;
int loc;
ll now;

int number() {
	int res = 0;
	while ( pos < str.size() && isdigit(str[pos]) ) {
		res = res * 10 + (int)(str[pos] - '0');
		++pos;
	}
	return res;
}
string alp() {
	string res = "";
	while ( pos < str.size() && 'A' <= str[pos] && str[pos] <= 'Z' ) {
		res += str[pos];
		++pos;
	}
	return res;
}
string expr2() {
	string res = "";
	while (pos < str.size() && str[pos] != ')') {
		int n = 1;
		if (isdigit(str[pos])) {
			n = number();
		}

		string a;
		if (str[pos] == '(') {
			++pos;
			a = expr2();
			++pos;
		}
		else {
			a = alp();
		}

		for (int i = 0; i < n; ++i) {
			res += a;
		}
	}
	return res;
}
ll expr() {
	ll res = 0;
	while (pos < str.size() && str[pos] != ')') {
		int n = 1;
		if (isdigit(str[pos])) {
			n = number();
		}

		int op = pos;

		ll l;
		if (str[pos] == '(') {
			++pos;
			l = expr();
			++pos;
			now -= l;
		}
		else {
			l = alp().size();
		}

		if (now <= loc && loc < now+l*n) {
			pos = op;
			string s;
			if (str[pos] == '(') {
				++pos;
				s = expr2();
				++pos;
			}
			else {
				s = alp();
			}
			throw s[(loc-now)%l];
		}

		now += l * n;
		res += l * n;
		if (now > loc+1) now = loc+1;
		if (res > loc+1) res = loc+1;
	}

	return res;
}


char parse() {
	pos = 0;

	try {
		now = 0;
		pos = 0;
		expr();
	}
	catch (char c) {
		return c;
	}
	return '0';
}

int main() {
	while (cin >> str >> loc, str != "0" || loc != 0) {
		cout << parse() << endl;
	}
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
int mod = 1e9 + 7;
int main()
{
	SPEED
	ll n, k;
	cin >> n >> k;
	int arr[n];
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	ll count = 0;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j < n; ++j)
		{
			if (arr[i]>arr[j])
			{
				ll mul = k*(k+1)/2;
				count += mul;
				count = count%mod;
			}
			else if (arr[j]>arr[i])
			{
				ll mul = k*(k-1)/2;
				count += mul;
				count = count%mod;
			}
		}
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    path = [-1] * N * 2
    idx = 0
    visited = [False] * N
    cur = 0
    loop = -1
    while K:
        K -= 1
        if loop == -1 and visited[cur]:
            loop = idx - path.index(cur)
            K %= loop
        path[idx] = cur
        visited[cur] = True
        cur = A[cur] - 1
        idx += 1
    print(cur + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 95816
#include <bits/stdc++.h>
//#include <boost/functional/hash.hpp>
//example: unordered_set< pair<int,int>,boost::hash< std::pair<int, int> > > used;
//priority_queue< pair<int,pair<int,int> >, vector<pair<int,pair<int,int>>>, greater<pair<int,pair<int,int> > > > pqueue;    //cost, vertex(行き先)
using namespace std;

#define MODULE 1000000007
#define MP make_pair
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<class T, class U>
inline void chmin(T &t, U f) { if (t > f)t = f; }

template<class T, class U>
inline void chmax(T &t, U f) { if (t < f)t = f; }

template<typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val) { //usage: int dp[10][10]; Fill(dp,INF);
    std::fill((T *) array, (T *) (array + N), val);
}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9 LLの時はLLONG_MAX
/*const int MAXN = 100001;

struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<edge> graph[MAXN];*/
int dx[2] = {0, 1};
int dy[2] = {1, 0};
//-----Template---------

int h, w;
string tmp;
char grid[10][10];
char grid2[10][10];

bool isMovable(int x, int y) {
    /*for (int i = 0; i < h; ++i) {
        int lim = i < x ? w : y;
        for (int j = 0; j < lim; ++j) {
            if (grid[i][j] == '#')
                return false;
        }
    }
    return true;*/
}

bool isValid(int x, int y) {
    return 0 <= x && x < h && 0 <= y && y < w;
}
bool passedAllGrid(){
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if(grid2[i][j]=='#')
                return false;
        }
    }
    return true;
}

bool bfs(int sx, int sy, int gx, int gy) {
    std::queue<P> qu;
    qu.push(P(sx, sy));
    while (!qu.empty()) {
        P now = qu.front();
        qu.pop();
        grid2[now.first][now.second]='.';
        if (now.first == gx && now.second == gy)
            return true;

        for (int i = 0; i < 2; i++) {
            int x = now.first + dx[i];
            int y = now.second + dy[i];
            if (0 <= x && x < h && 0 <= y && y < w && grid[x][y] == '#') {
                qu.push(P(x, y));
            }
        }

        if ((isValid(now.first + 1, now.second) && (grid[now.first + 1][now.second] == '#'))
            == (isValid(now.first, now.second + 1) && (grid[now.first][now.second + 1] == '#')))
            return false;//両方イケたら終わり
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false); //cout<< fixed << setprecision(10);
    cin >> h >> w;
    for (int i = 0; i < h; ++i) {
        cin >> tmp;
        for (int j = 0; j < w; ++j) {
            grid[i][j] = tmp[j];
        }
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            grid2[i][j] = grid[i][j];
        }
    }
    cout << (bfs(0, 0, h - 1, w - 1)&&passedAllGrid() ? "Possible" : "Impossible") << endl;

}

Measured memory_bytes: 256
using System.Collections.Generic;
using System;

public class hello
{
    public static Dictionary<string, string> dic1, dic2;
    public static void Main()
    {
        var a = new string[] { " ", "\'", ",", "-", ".", "?", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
        var b = new string[] { "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" };
        var c = new string[] { "00000", "00001", "00010", "00011", "00100", "00101", "00110", "00111", "01000", "01001", "01010", "01011", "01100", "01101", "01110", "01111", "10000", "10001", "10010", "10011", "10100", "10101", "10110", "10111", "11000", "11001", "11010", "11011", "11100", "11101", "11110", "11111" };
        var d = new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " ", ".", ",", "-", "\'", "?" };
        dic1 = new Dictionary<string, string>();
        dic2 = new Dictionary<string, string>();
        for (int i = 0; i < 32; i++)
        {
            dic1[a[i]] = b[i];
            dic2[c[i]] = d[i];
        }
        string line;
        for (; (line = Console.ReadLine()) != null;)
        {
            getAns(line);
        }
    }
    static void getAns(string s)
    {
        var imax = s.Length;
        var ts = "";
        for (int i = 0; i < imax; i++)
        {
            var w = s.Substring(i, 1);
            ts += dic1[w];
        }
        var pts = ts.Length % 5;
        if (ts.Length % 5 != 0) ts += "0000";
        imax = ts.Length / 5;
        var res = "";
        for (int i = 0; i < imax; i++)
        {
            var w = ts.Substring(i * 5, 5);
            res += dic2[w];
        }
        Console.WriteLine(res);
    }
}



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

int main(void){
	int n;
	double x, sum = 0;
	char u[5];

	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%lf %s", &x, u);
		if(!strcmp("JPY", u))
			sum += x;
		else
			sum += x * 380000;
	}
	printf("%lf\n", sum);
	return 0;
}


Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))

    dic={}
    for i in range(k):
        d=int(readline())
        arr=list(readline().rstrip().split())
        for a in arr:
            dic[a]=1
    ans=n-len(dic.keys())
    print(ans)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16260
N,K=[int(i) for i in input().split()]
data=list()
for i in range(0,N):
    data.append([int(i) for i in input().split()])
newdata=sorted(data,key=lambda d:d[0])
count=0
for d in newdata:
    count+=d[1]
    if count>=K:
        print(d[0])
        break

Measured memory_bytes: 23640
/*      ex3_2
        Tarara  */
#include <stdio.h>

int main(void)
{
    int pencils; //鉛筆の本数
    scanf("%d", &pencils);

    int digit = pencils % 10; //鉛筆の本数の一の位の数
    if (digit == 3)
        printf("bon\n");
    else if (digit == 0 || digit == 1 || digit == 6 || digit == 8)
        printf("pon\n");
    else // 0, 1, 6, 8の時
        printf("hon\n");
    return 0;
}

Measured memory_bytes: 1604
#include<iostream>
#include<vector>
#define lli long long int
#define N 4
#define pb push_back
using namespace std;


int main()
{
    lli n;
    cin>>n;
    vector<vector<lli>>arr(n+1,vector<lli>(3));
    for(lli i=1;i<=n;i++)
        for(lli k=0;k<3;k++) cin>>arr[i][k];
    
    vector<vector<lli>>dp(n+1,vector<lli>(3));
    
    dp[n][0] = max(arr[n][1],arr[n][2]);
    dp[n][1] = max(arr[n][2],arr[n][0]);
    dp[n][2] = max(arr[n][0],arr[n][1]);
    
    for(lli i=n-1;i>=1;i--)
    {
        dp[i][0] = max(arr[i][1]+dp[i+1][1],arr[i][2]+dp[i+1][2]);
        dp[i][1] = max(arr[i][0]+dp[i+1][0],arr[i][2]+dp[i+1][2]);
        dp[i][2] = max(arr[i][1]+dp[i+1][1],arr[i][0]+dp[i+1][0]);
    }
    
    cout<<max(dp[1][0],max(dp[1][1],dp[1][2]))<<endl;
    
    
    
}


Measured memory_bytes: 14008
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int A[3];
  rep(i,3) cin >> A[i];
  sort(A,A+3);
  reverse(A,A+3);
  cout << abs(A[1]-A[0])+abs(A[2]-A[1]) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int m, d, r;
	
	while(1) {
	    //成績を入力する
	    scanf("%d%d%d", &m, &d, &r);
	    
	    //全て-1だったら処理を終了する
	    if((m == -1) && (d == -1) && (r == -1)) {
	        break;
	    }
	    
	    //中間試験、期末試験のどちらかを欠席した場合
	    if((m == -1) || (d == -1)) {
	        printf("F\n");
	    }
	    //中間試験と期末試験の合計が80以上の場合
	    else if((m + d) >= 80) {
	        printf("A\n");
	    }
	    //合計が65以上80未満の場合
	    else if((m + d) >= 65) {
	        printf("B\n");
	    }
	    //合計が50以上65未満の場合
	    else if((m + d) >= 50) {
	        printf("C\n");
	    }
	    //合計が30以上50未満の場合
	    else if((m + d) >= 30) {
	        //再試験の点数が50以上の場合
	        if(r >= 50) {
	            printf("C\n");
	        }
	        else {
	            printf("D\n");
	        }
	    }
	    //合計が30未満の場合
	    else {
	        printf("F\n");
	    }
	}
	return 0;
}


Measured memory_bytes: 2056
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//グローバル変数


//ライブラリ挿入


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N) cin>>A[i];
    int i_top,i_second;
    int m=0,m_2=0;;
    REP(i,N){
        if(m_2<=A[i]&&m>=A[i]){
            i_second=i;
            m_2=A[i];
        }
        if(m<=A[i]){
            i_top=i;
            m=A[i];
        }

    }

    REP(i,N){
        if(A[i]==m) cout << m_2 << endl;
        else cout << m << endl;
    }


    
}

Measured memory_bytes: 2432
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int n;
   string s;
   cin >> n >> s;
   int cnttmp =0;
   for(int i = 1;i<n-1;i++){
   int cnt = 0;
   int num_f[26] = {0};
   int num_r[26] = {0};
      for(int j=0;j<n;j++){
         if(j<i){
            num_f[s[j]-97]++;
         }else{
            num_r[s[j]-97]++;
         }
      }
      rep(k,26){
         if((num_f[k])&&(num_r[k])) cnt++; 
      }
      if(cnt>cnttmp) cnttmp = cnt;
   }
   cout << cnttmp << endl;



   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#ifdef LOCAL
#define lout cout
#else
stringstream devnull;
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
#define rep1(n) rep(_, n)
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep3(i, f, n) for (int i = f; i < n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> pi;
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");

int main()
{
  AMULET
  int n, q;
  cin >> n >> q;
  string s;
  cin >> s;
  vector<int> l(q), r(q);
  vcin(l, r);

  vector<ll> c(n + 1, 0);
  rep(i, n)
  {
    string sub = "";
    c[i + 1] = c[i] + (s.substr(i, 2) == "AC");
  }

  rep(i, q)
  {
    cout << c[r[i] - 1] - c[l[i] - 1] << endl;
  }

  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}


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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int num;
    if(h > w) {
        num = h;
        if (n % num == 0){
            cout << n / num << endl;
        }else{
            cout << n / num + 1 << endl;
        }
    }else{
        num = w;
        if (n % num == 0){
            cout << n / num << endl;
        }else{
            cout << n / num + 1 << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;

int main(){
  string s;
  cin >> s;
  string t;
  rep(i,s.size()){
    if(i % 2 == 0){
      t += s.at(i);
    }
  }
  cout << t << endl;
      
        
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>


int main() {
	int n;

	std::cin >> n;

	int sum = 0;

	std::vector<int> v(n);

	for (size_t i = 0; i < n; i++)
	{
		std::cin >> v[i];
		sum += v[i];
	}

	int a = 0;
	int min = 1000000000;
	for (size_t i = 1; i < n; i++)
	{
		a += v[i - 1];
		int b = sum - a;
		min = std::min(min, abs(a - b));
	}

	std::cout << min << std::endl;

	return 0;
}

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

int main(){
    int N, M; cin >> N >> M;
    Graph G(N);
    vector<int> v;
    for(int i=0; i<N; i++){
        v.push_back(i);
    }
    for(int i=0; i<M; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    int cnt = 0;
    do{
        for(int i=0; i<N; i++){
            if(i==N-1) cnt++; 
            else if(count(G[v[i]].begin(), G[v[i]].end(), v[i+1])==0){
                break;
            }
        }
    } while (next_permutation(v.begin()+1, v.end()));

    cout << cnt << endl;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    ll s = 0;
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
        s ^= A[i];
    };
    for (ll i = 0; i < N; i++) {
        ll ans = s ^ A[i];
        cout << ans << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}


Measured memory_bytes: 4768
# 0-indexedで、getは半開区間であることに注意
class SegmentTree

  @@inf = (1 << 60) - 1

  # O(n)
  def initialize(n, form)
    case form
    when "and"
      @identity_element = (1 << 60) - 1
      @func = Proc.new{|x, y| x & y }
    when "gcd"
      @identity_element = 0
      @func = Proc.new{|x, y| x.gcd y }
    when "lcm"
      @identity_element = 1
      @func = Proc.new{|x, y| x.lcm y }
    when "max"
      @identity_element = -@@inf
      @func = Proc.new{|x, y| x > y ? x : y }
    when "min"
      @identity_element =  @@inf
      @func = Proc.new{|x, y| x < y ? x : y }
    when "or"
      @identity_element = 0
      @func = Proc.new{|x, y| x | y}
    when "prod"
      @identity_element = 1
      @func = Proc.new{|x, y| x * y}
    when "sum"
      @identity_element = 1
      @func = Proc.new{|x, y| x + y}
    end

    # @identity_element = identity_element
    @n = 1
    @n *= 2 while @n < n
    # @n: leaf node size(2^k)
    # @n*2-1: tree node size
    @n_1 = @n - 1
    @nodes = Array.new(@n*2-1){ @identity_element }
  end

  def update(i, val)
    # @n-1: inner node size
    i += @n_1
    @nodes[i] = val
    while i > 0
      i = ( i - 1 ) / 2
      @nodes[i] = @func.call(@nodes[2*i+1], @nodes[2*i+2])
    end
    true
  end

  def swap(i, j)
    # @n-1: inner node size
    n_i = @nodes[i + @n_1].dup
    n_j = @nodes[j + @n_1].dup
    update(i, n_j)
    update(j, n_i)
  end

  def get(l, r)
    l += @n_1
    r += @n_1
    lres, rres = @identity_element, @identity_element
    while l < r
      if l[0] == 0
        lres = @func.call(lres, @nodes[l])
        l += 1
      end
      if r[0] == 0
        r -= 1
        rres = @func.call(rres, @nodes[r])
      end
      l /= 2
      r /= 2
    end
    return @func.call(lres, rres)
  end

  def all_update
    @n_1.downto(1){ |i| @nodes[i-1] = @func.call(@nodes[2*i-1], @nodes[2*i]) }
  end

  def [](k)
    @nodes[@n_1 + k]
  end

  def []=(i, val)
    @nodes[@n_1 + i] = val
  end

  def inf=(x)
    @@inf = x
  end

  def inf()
    @@inf
  end

  def inspect

    t = 0
    res = "SegmentTree\n  "
    @nodes.each_with_index do |e,i|

      res << e.to_s << " "
      if t == i && i < @n_1
        res << "\n  "
        t = t * 2 + 2
      end
    end
    res
  end
end

class Array
  def to_st(form)
    st = SegmentTree.new(size, form)
    each_with_index{ |t, i| st[i] = t }
    st.all_update
    st
  end
end

n = gets.to_s.to_i
s = gets.to_s.chomp
q = gets.to_s.to_i

# p "a".ord #=> 97
st = s.bytes.map{|c| 1 << (c-97) }.to_st("or")

ans = []
q.times do
 
  t, x, y = gets.to_s.split
 
  if t == "1"
    i, c = x.to_i-1, y[0].ord
    st.update(i, 1 << (c-97))
  else
    l, r = x.to_i-1, y.to_i-1
    ans << st.get(l, r+1).to_s(2).count('1')
  end
end

puts ans

Measured memory_bytes: 18988
#include <iostream>
#include <set>
using namespace std;
int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int g=max(a,b), l=min(a,b);
    set<int> st1, st2;
    for (int i=1; i*i<=g; i++) {
        if (g%i == 0) {
            st1.insert(i);
            st1.insert(g/i);
        }
        if (l%i == 0) {
            st2.insert(i);
            st2.insert(l/i);
        }
    }
    set<int>::reverse_iterator itr=st2.rbegin();
    int cnt = 0;
    while (itr != st2.rend()) {
        if (st1.find(*itr) != st1.end()) {
            cnt++;
            if (cnt == k) {
                cout << *itr << endl;
                return 0;
            }
        }
        itr++;
    }

}

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

int main(void){
  int n, m;
  vector<int> a(50), b(50);

  cin >> n >> m;
  for(int i = 0; i < m; i ++)
    cin >> a.at(i) >> b.at(i);

  map<int, int> c;

  for(int i = 0; i < m; i ++){
    c[a.at(i)] ++;
    c[b.at(i)] ++;
  }

  for(int i = 0; i < n; i ++){
    cout << c[i+1] << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        boolean is=false;
        int cnt=0;
        for(int i=1;i<a.length;i++){
            if(a[i]==a[i-1])cnt++;
            else cnt=0;
            if(cnt>=2)is=true;
        }
        System.out.println(is?"Yes":"No");
    }
}


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

#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

const int INF = INT_MAX;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

using PII = pair<int, int>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;



int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::string s;
    cin >> s;
    int y = atoi(s.substr(0,4).c_str());
    int mo = atoi(s.substr(5,2).c_str());
    int mm = atoi(s.substr(8,2).c_str());

    if(2019 < y) cout << "TBD" << "\n";
    else if(2019 == y && 5 <= mo) cout << "TBD" << "\n";
    else cout << "Heisei" << "\n";
}

Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
    input!{
        N: usize,
        K: i32,
        Q: i32,
        A: [usize; Q]
    }
    let mut P = vec![0; N];
    for a in A.iter() {
        P[a - 1] += 1;
    }
    for p in P.iter() {
        println!("{}", if *p <= Q - K {
            "No"
        } else {
            "Yes"
        });
    }
}


Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vs= vector<string>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

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

  cout << (a-1)*(b-1);
  
  return 0;
}


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

int main() {
  int X, Y;
  cin >> X >> Y;
  rep(i,X+1){
    if (i  * 2 +  (X - i) * 4 == Y){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3632
a,b,x,y=map(int,input().split());r,c=y-b,x-a;R,L,U,D='RLUD';print(R*c+U*r+L*c+D*-~r+R*-~c+U*-~r+L+U+L*-~c+D*-~r+R)

Measured memory_bytes: 3060
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))

dp = [10**10 for _ in range(n)]
dp[0] = 0
for i in range(1,n):
	for j in range(1,k+1):
		if i-j < 0:
			break
		dp[i] = min(dp[i],dp[i-j]+abs(lst1[i-j]-lst1[i]))

print(dp[-1])


Measured memory_bytes: 52464
import java.util.*;

public class Main {
    public static void main(String[] args)  {
        Scanner sc = new Scanner(System.in);
        int D = sc.nextInt();
        int N = sc.nextInt();
        
        int count = 1;
        int ans = 0;
        for(int i=0; i<D; i++){
            count *= 100;
        }
        if(N<100){
            ans = count*N;
        }else{
            ans = count * 101;
        }
        
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 35816
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, s, n) for (int var = (s); var < (n); ++var)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()

int main() {
  //
  int n, l;
  cin >> n >> l;
  int orig = n * (2 * l + n - 1) / 2;
  int diff = INT_MAX;
  int idx = -1;
  rep(i, n) {
    if (diff > abs(l + i)) {
      idx = i;
      diff = abs(l + i);
    }
  }
  cout << orig - (l + idx) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    if (a<2) cout<<1<<endl;
    else if(a<4)  cout<<2<<endl;
    else if(a<8)  cout<<4<<endl;
    else if(a<16) cout<<8<<endl;
    else if(a<32) cout<<16<<endl;
    else if(a<64) cout<<32<<endl;
    else cout<<64<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  int four = 0, eve = 0;
  rep(i, 0, n) {
    int a;
    cin >> a;
    if (a % 4 == 0)
      four++;
    else if (a % 2 == 0)
      eve++;
  }

  n -= eve;

  if ((eve == 0 && four >= n / 2) || (eve >= 1 && four >= (n + 1) / 2))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

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

    int sum = N*L + N*(N + 1)/2 - N;
    int smallest = 0;

    if(L > 0)
    {
        smallest = L;
    }
    else
    {
        if(N - 1 >= abs(L))
            smallest = 0;
        else
            smallest = L + (N - 1);
    }

    sum -= smallest;

    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
const int MAX_N=100005;
int n;
int a[MAX_N];
int main()
{
	cin>>n;
	For(i,1,n)
	{
		cin>>a[i];
	}
	int ans=0;
	bool flag=false;
	For(i,1,n)
	{
		if(a[i]==i)
			ans+=(flag=!flag);
		else 
			flag=false;
	}
	cout<<ans<<endl;
	return 0;
}




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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef std::vector<long> LI;
typedef std::queue<long> QI;
#define rep(i,n) for(long i = 0; i < (long)n; ++i)
const double pi = M_PI;
const long mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   long gcd(long x, long y) {
      if( y == 0 ) return x;
      return gcd(y, x%y);
   }
   void solve() {
      long n, k; scan(n, k);
      LI xs(n); for(long &x : xs) scan(x);
      long z = xs[0];
      for(long x : xs) z = gcd(z, x);
      long max = xs[0];
      for(long x : xs) max = std::max(max, x);
      puts( ( k%z==0 and k <= max ) ? "POSSIBLE" : "IMPOSSIBLE" );
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 1024
#include <iostream>
 
int main()
{
  long n, d, count;
  std::cin >> n >> d;
  count = 0;
  for (;0<n;--n)
  {
    long x, y;
    std::cin >> x >> y;
    if (d * d >= x * x + y * y)
    {
      count++;
    }
  }
  std::cout << count;
  return 0;
}

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

ll n, money;

int main() {
  cin >> n;
  vector<ll> a(n);
  rep (i, n) {
    cin >> a[i];
  }
  money = 1000;
  rep (i, n-1) {
    if (a[i] < a[i+1]) {
      money = (money / a[i]) * a[i+1] + money % a[i];
    }
  }
  cout << money << endl;
  return 0;
}


Measured memory_bytes: 3640
X = int(input())
prime_under_X = []
for i in range(2, int(X ** 0.5) + 1):
    flg = True
    for j in range(len(prime_under_X)):
        if i % prime_under_X[j] == 0:
            flg = False
            break
    if flg:
        prime_under_X.append(i)

while True:
    flg = True
    for j in range(len(prime_under_X)):
        if X % prime_under_X[j] == 0:
            flg = False
            break
    if flg:
        print(X)
        break
    X = X + 1


Measured memory_bytes: 9360
#include <stdio.h>
#include <math.h>
#define DOT(v1, v2) (v1.x * v2.x + v1.y * v2.y)
#define CROSS(v1, v2) (v1.x * v2.y - v1.y * v2.x)
#define NORM(v) (v.x * v.x + v.y * v.y)
#define ABS(v) (sqrt(NORM(v)))

typedef struct { double x, y; } point_t;
typedef point_t vector_t;
typedef struct { point_t p0, p1; } segment_t;
typedef segment_t line_t;

static vector_t minus(vector_t v1, vector_t v2) {
  vector_t ret = { v1.x - v2.x, v1.y - v2.y };
  return ret;
}

// @see http://www5d.biglobe.ne.jp/~tomoya03/shtml/algorithm/Intersection.htm
// (y - q) = slope * (x - p)
static int intersect(segment_t s1, segment_t s2) {
  double t1, t2, t3, t4;

  //    *******                                               *******
  t1 = (s1.p0.y - s2.p0.y) * (s2.p0.x - s2.p1.x) + (s2.p0.x - s1.p0.x) * (s2.p0.y - s2.p1.y);
  t2 = (s1.p1.y - s2.p0.y) * (s2.p0.x - s2.p1.x) + (s2.p0.x - s1.p1.x) * (s2.p0.y - s2.p1.y);
  t3 = (s2.p0.y - s1.p0.y) * (s1.p0.x - s1.p1.x) + (s1.p0.x - s2.p0.x) * (s1.p0.y - s1.p1.y);
  t4 = (s2.p1.y - s1.p0.y) * (s1.p0.x - s1.p1.x) + (s1.p0.x - s2.p1.x) * (s1.p0.y - s1.p1.y);
  return (t1 * t2 < 0.0) && (t3 * t4 < 0.0);
}

static double distance(segment_t s1, segment_t s2) {
  int i;
  double min, d;
  segment_t s;
  point_t p;

  if (intersect(s1, s2)) return 0.0;
  struct { segment_t s; point_t p; } list[4] = {{s1, s2.p0}, {s1, s2.p1}, {s2, s1.p0}, {s2, s1.p1}};
  for (i = 0, min = -1.0; i < 4; ++i) {
    s = list[i].s;
    p = list[i].p;
    if (DOT(minus(s.p0, s.p1), minus(p, s.p1)) < 0.0) {
      d = ABS(minus(p, s.p1));
    } else if (DOT(minus(s.p1, s.p0), minus(p, s.p0)) < 0.0) {
      d = ABS(minus(p, s.p0));
    } else {
      d = CROSS(minus(s.p0, s.p1), minus(p, s.p1)) / ABS(minus(s.p0, s.p1));
      if (d < 0.0) d = -d;
    }
    if (min < 0.0 || d < min) min = d;
  }
  return min;
}

int main(int argc, char **argv) {
  int q, i;
  segment_t s1, s2;

  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
        &s1.p0.x, &s1.p0.y, &s1.p1.x, &s1.p1.y,
        &s2.p0.x, &s2.p0.y, &s2.p1.x, &s2.p1.y);
    printf("%.10lf\n", distance(s1, s2));
  }
}


Measured memory_bytes: 2112
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int num;
    cin>>num;
    
    vector<int64_t> lucas(num+2);
    lucas.at(0)=2;
    lucas.at(1)=1;
    
    for(int i=0;i<num;i++){
        lucas.at(i+2)=lucas.at(i+1)+lucas.at(i);
    }
    cout<<lucas.at(num)<<endl;
}


Measured memory_bytes: 256