akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {

    	Scanner sc=new Scanner(System.in);

    	int N=sc.nextInt();
    	int W=sc.nextInt();

    	int[] w=new int[N];
    	int[] v=new int[N];

    	int[] dp=new int[W+1];

    	for(int i=0;i<N;i++) {
    		v[i]=sc.nextInt();
    		w[i]=sc.nextInt();
    	}

    	//dp[i+1][j] i番目までのアイテムで容量jのリュックに詰めれる価値の最大値

    	//dp[0][j]=0;

    	for(int i=0;i<=W;i++) {
    		dp[i]=0;
    	}


    	for(int i=0;i<N;i++) {

    		for(int j=W;j>=0;j--) {

    			if(j-w[i]>=0) {
    				dp[j]=Math.max(dp[j],dp[j-w[i]]+v[i]);
    			}

    		}

    	}

//    	for(int i=0;i<N;i++) {
//    		for(int j=0;j<=W;j++) {
//    			if(j-w[i]<0) {
//    				dp[i+1][j]=dp[i][j];
//    			}else {
//    				dp[i+1][j]=Math.max(dp[i][j],dp[i][j-w[i]]+v[i]);
//    			}
//    		}
//    	}

    	System.out.println(dp[W]);

    }
}



Measured memory_bytes: 26880
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

void print() { cout << endl; }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << ((sizeof...(tail)!=0)?" ":""); print(forward<Tail>(tail)...); }
template <class T> void print(vector<T> &vec) { for (auto& a : vec) { cout << a << ((&a!=&vec.back())?" ":""); } cout << endl; }
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec); } }

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

    ll n, k; cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        int x; cin >> x;
        x--; a[i] = x;
    }
    map<int, int> mp;
    vector<int> t;
    int pos = 0;
    bool found = false;
    rep(i, min(n, k)) {
        if (mp.count(pos)) {
            found = true; 
            break;
        } else {
            mp[pos] = i;
            t.push_back(pos);
            int next = a[pos];
            pos = next;
            if (i==k-1) {
                cout << pos+1 << endl;
                return 0;
            }
        }
    }
    if (found) {
        int start = mp[pos];
        int loop = t.size()-start;
        int cnt = (k-start)%loop;
        // print(start, k-start, loop, cnt);
        // print(t);
        cout << t[start+cnt]+1 << endl;
    } else {
        int cnt = k%n;
        cout << t[cnt]+1 << endl;
    }
}

Measured memory_bytes: 12128
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
void solve(){
    ll s,i;
	cin>>s;
	vector<ll> dp(s+1,0);
	dp[0]=1;
	for(int i=3;i<=s;++i){
		for(int j=i-3;j>=0;--j)
			(dp[i]+=dp[j])%=mod;
	}
	cout<<dp[s];
}
int main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3608
def main():

    N, K = map(int, input().split())
    p = []
    for _ in range(N):
        x, y = map(int, input().split())
        p.append([x, y])
    p.sort(key = lambda x: x[0])

    min_area = float('inf')
    for i in range(N-1):
        for j in range(i+1, N):
            if j-i+1 >= K:
                x1 = p[i][0]
                x2 = p[j][0]
                ys = []
                for k in range(i, j+1):
                    ys.append(p[k][1])
                ys.sort()
                for k in range(len(ys)):
                    for l in range(k+K-1, len(ys)):
                        y1 = ys[k]
                        y2 = ys[l]
                        area = (x2-x1)*(y2-y1)
                        if area > 0:
                            min_area = min(min_area, area)
    return min_area

if __name__ == '__main__':
    print(main())

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

int n,m;

bool betweenR(int x)
{
	return (1<=x && x<=n); 
}

bool betweenC(int x)
{
	return (1<=x && x<=m);
}

int main()
{
	cin>>n>>m;
	char tab[55][55];
	int ans[55][55];
	memset(ans,0,sizeof(ans));
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=m;j++)
	  {
	  	cin>>tab[i][j];
	  	if (tab[i][j]=='#') ans[i][j]=-1;
	  } 
	int delta[3]={-1,0,1};
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=m;j++)
	 {
	 	if (tab[i][j]!='#') continue;
		for (int k=0;k<3;k++)
		 for (int l=0;l<3;l++)
		 {
		 	if (delta[l]==0 && delta[k]==0) continue;
		 	int x=i+delta[k];
		 	int y=j+delta[l];
		 	if (tab[x][y]=='#') continue;
		 	if (!betweenR(x)) continue;
		 	if (!betweenC(y)) continue;
		 	ans[x][y]++;
		 }
	 }
	for (int i=1;i<=n;i++)
	 for (int j=1;j<=m;j++)
	 {
	 	if (j==m)
	 	{
	 		if (ans[i][j]==-1)
	 		 cout<<"#\n";
	 		else
	 		 cout<<ans[i][j]<<"\n";
		}
		else
		 {
		 	if (ans[i][j]==-1)
		 	 cout<<"#";
		 	else
		 	 cout<<ans[i][j];
		 }
	 }
}

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

#define FOR(i, a, b) for(int i = a; i < b; ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

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

const int MAXN = 1e5 + 5;

ll sweep[MAXN], flat[MAXN];

ll m;
ll global;

void add(ll x, ll y) {
  if(x < y && y - x > 1) {
    sweep[x + 2] += +1;
    sweep[y + 1] += -1;
    flat[y + 1] += abs(1 - (y - x));

    global += y - x;
  }
  else if(x > y) {
    sweep[2] += 1;
    sweep[y + 1] -= 1;
    flat[y + 1] += abs(1 - (m - x + y));

    sweep[x + 2] += 1;

    global += y;
  }
  else if(x < y) {
    global += 1;
  }
}

int a[MAXN];

int main() {

  int n; cin >> n >> m;
  REP(i, n) {
    cin >> a[i];
  }

  REP(i, n - 1) {
    add(a[i], a[i + 1]);
  }

  ll sol = 0, tmp = 0, current = 0;

  FOR(i, 1, m + 1) {
    tmp += sweep[i];
    current += flat[i] - tmp;
    sol = min(sol, current);
  }
  cout << sol + global;
}


Measured memory_bytes: 2176
/*input
1 3 3
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	long long a,b,mx,mn,k,n;
	cin>>n>>a>>b;
	if(n==2 || a==b) return cout<<1,0;
	else if(n==1||a>b) return cout<<0,0;
	k=n-2;
	mn=k*a,mx=k*b;
	cout<<mx-mn+1;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int MAX_N = 200000;

using ll = long long;

int N;
int A[MAX_N];
ll ans = 0;
ll cnt[22][MAX_N+1];

/*void bin( int x )
{
  std::vector<int> vs;
  int y = x;

  rep( i, 10 )
    vs.push_back( x&1 ), x>>=1;

  for( auto v : vs )
    printf( "%d", v );

  printf( " (%d)\n", y );

  return;
}*/

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", A+i );

  //rep( i, N )
    //bin(A[i]);

  rep( i, N )
  {
    int s = A[i];
    int p = 0;
    while( s > 0 )
    {
      cnt[p][i+1] = cnt[p][i]+(s&1);
      
      s >>= 1;

      ++p;
    }

    repi( j, p, 22 )
      cnt[j][i+1] += cnt[j][i];
  }

  /*rep( i, N+1 )
  {
    rep( j, 22 )
      printf( "%lld ", cnt[j][i] );

    if( i-1 >= 0 )
      printf( "(%d)\n", A[i-1] );
  }*/

  rep( i, N )
  {
    ll mi = N+1;

    //printf( "[%d]\n", A[i]);
    rep( j, 22 )
    {
      ll p = std::upper_bound( cnt[j]+i+1, cnt[j]+N+1, cnt[j][i]+1 )-cnt[j]-i-1;
      //printf( "ub: %d ", cnt[j][i]+1 );
      mi = std::min( mi, p );
    }
    //puts("");

    //printf( "%d, mi: %lld\n", A[i], mi );

    ans += mi;
  }

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

Measured memory_bytes: 35328
#include <bits/stdc++.h>
 
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define ii pair<int,int>
#define qu queue <int>
#define qmax priority_queue <int>
#define qmin priority_queue <int, vector<int>,greater<int>>

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int a, b;
    cin>>a>>b;

    cout<<((a<=8 && b<=8) ? "Yay!" : ":(")<<endl;

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;
 
int main(){
    ll a,b; cin >> a >> b;
    ll sum = 0;
    vl v(1000);
    REP(i,1,1000){
        sum += i;
        v[i] = sum;
    }
    cout << v[b-a-1] - a << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
using namespace std;
const int INF=1e9+5;
int main(){
    //read;
    //write;
    int n;
    cin >> n;
    vector<int> h(n+2),cost(n+2,INF);
    for(int i=0;i<n;++i){
        cin >> h[i];
    }
    cost[0]=0;
    for(int i=0;i<n;++i){
        for(int j : {i+1,i+2}){
            cost[j]=min(cost[j],cost[i]+abs(h[i]-h[j]));
        }
    }
    cout << cost[n-1];
    return 0;
}


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

int main(void){
    int k, n;
    cin>>k>>n;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    vector<ll>diff(n+1);
    rep(i, n-1){
        diff[i]=v[i+1]-v[i];
    }
    diff[n]=v[0]+k-v[n-1];
    sort(diff.begin(), diff.end(), greater<int>());
    ll ans = accumulate(diff.begin(), diff.end(), 0LL)-diff[0];
    cout<<ans<<endl;
   return 0; 
}

Measured memory_bytes: 3328
#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline
from math import gcd

def main():
    K=int(input())
    ret = 0
    for a in range(K):
        for b in range(K):
            for c in range(K):
                ret += gcd(gcd(a+1,b+1),c+1)
    print(ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9148
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N, R; cin >> N >> R;
    if(N >= 10) cout << R << endl;
    else cout << R + 100 * (10-N) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define inf    0x3f3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
typedef vector<int>      vi;
typedef vector<bool>     vb;
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

int main(){

 int n;  cin>>n;
 vector<int>v(n);

 ll sum =0;

 for(int i=0;i<n;i++)
  {
    cin>>v[i];
     sum += v[i];
  sum %= MOD;
  }

  ll ans=0;

  for(int i=0;i<n;i++){
      sum -=v[i];

      if(sum < 0) sum += MOD;

      ans += v[i] * sum;
      ans = ans%MOD;
  }

 cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 3964
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int[][] M = new int[H][];
		for(int i=0;i<H;i++) M[i] = new int[W];
		int r = 0, c = 0;
		for(int i=0;i<N;i++){
			for(int j=0;j<A[i];j++){
				M[r][c] = i+1;
				c++;
				if(c == W){ c = 0; r++; }
			}
		}
		
		for(int i=0;i<H;i++){
			if(i % 2 == 1){
				Array.Reverse(M[i]);
			}
		}
		
		for(int i=0;i<H;i++){
			Console.WriteLine(String.Join(" ",M[i]));
		}
		
	}
	int H, W;
	int N;
	int[] A;
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1];
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする
template<class T> void chmin(T &a, T b){ if(a>b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

/*
 * 解法１・・・()カッコ列の整合性判定問題の亜種として、スタックで処理
 *
 *　スタック st を用意する
    文字を順番に見て

    + '(' ならば st に push する
    + ')' のとき
      + st が空、または st.top が ')' なら push する
      + st.top が ')' なら pop してペアにする

    こうして作れるペアの個数が最大


    解法２・・・もっとシンプルに考えることができる。今回の問題では、まずはそもそも

        どんなに頑張っても min(0 の個数、1 の個数) 回より多く操作を行うことはできない
        ということがすぐにわかる。なぜなら、1 回の操作で必ず 0 と 1 を 1 個ずつ消すからだ。そしてなんと、
        逆に必ず min(0 の個数、1 の個数) 回の操作を達成できることが示せてしまう。
        こういう風に「自明な上界として考えた値が実は最適解」というのはよくある。

        さて、このような操作を扱う問題では

        「操作を行った結果出来上がるものがどんなものか、わかりやすく言い換える」

        を考察するのが良さそう。
        今回は
        「限界まで操作を行ったならば、最終結果に 0 と 1 が両方登場することはない」
        という事が言える
 * */


int main() {

    string s;
    cin >> s;

    int res = 0;
    stack<char> st;
    rep(i, s.size()){
        if(st.empty() || st.top() == s[i]){
            st.push(s[i]);
        }
        else{
            res += 2; // ペアを足す
            st.pop();
        }
    }
    cout << res << endl;

    /*  解法２ */
    /*
    string s;
    cin >> s;
    int zero =0, one =0;
    rep(i,s.size()){
        if(s[i]=='0') zero++;
        else one++;
    }
    cout << min(zero, one) * 2 << endl;
    */
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rsort(x) sort(x.rbegin(), x.rend())
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define fio(x) ios::sync_with_stdio(x), cin.tie(x), cout.tie(x);
#define znit(x) memset(x, 0, sizeof(x))
#define mnit(x) memset(x, -1, sizeof(x))
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<db, db> pdd;
const int dr[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dc[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int inf = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db EPS = 1e-7;

const ll mod = 1e9 + 7;
const ll mod2 = 1e9 + 9;
ll mypow(ll x, ll y, ll p){ll ret = 1;while(y){if(y & 1) ret = (ret * x) % p;x = (x * x) % p; y /= 2;}return ret;}
ll inv(ll x, ll p){return mypow(x, p - 2, p);}
ll gcd(ll x, ll y){return y ? gcd(y, x % y) : x;}

const int MAX = 2e5 + 3;

ll X, Y;
int main(){
	cin >> X >> Y;
	ll g = __gcd(X, Y);
	X /= g, Y /= g;
	if(X % Y == 0)	puts("-1");
	else{		
		printf("%lld\n", X * g);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
struct UnionFind{
  vector<int> par;
  vector<int>rank;
  UnionFind(int n):par(n),rank(n){
    for(int i=0;i<n;i++){
      par[i]=i;
      rank[i]=0;
    }
  }
  
  int root(int x){
    return par[x]==x?x:par[x]=root(par[x]);
  }

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

  void Union(int x,int y){
    x=root(x);
    y=root(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(){
  int n,m;
  cin>>n>>m;
  vector<int>Data(n);
  for(int i=0;i<n;i++){
    cin>>Data[i];
    Data[i]--;
  }
  UnionFind uf(n);
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    x--;y--;
    uf.Union(x,y);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(uf.same(Data[i],i))ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4576
<?php
$n = trim(fgets(STDIN));
$vArray = explode(" ", trim(fgets(STDIN)));

foreach($vArray as $i => $v){
    $dArray = divisor($v);
    foreach($dArray as $d){
        @$map[$d]++;
    }
}
$max = 1;
foreach($map as $value => $count){
    if($count >= $n - 1){
        $max = max($max, $value);
    }
}
echo $max;

function divisor($n){
    if(!isset($GLOBALS["cache"][$n])){
        $sqrtn = sqrt($n);
        for($i = 1; $i <= $sqrtn; $i++){
            if($n % $i == 0){
                $f[] = $i;
                $f[] = $n / $i;
            }
        }
        sort($f);
        $GLOBALS["cache"][$n] = array_unique($f);
    }
    return $GLOBALS["cache"][$n];
}

Measured memory_bytes: 14840
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char> cvec;
typedef vector<double> dvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
#define fs first
#define sc second
int main()	{
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c<22)
    cout<<"win"<<endl;
  else
    cout<<"bust"<<endl;
}

Measured memory_bytes: 256
s = gets.chomp.reverse.split("").map(&:to_i)
ans = 0
mod = 2019
mod_array = Array.new(s.size,0)
hash = Hash.new(0)
mod_temp = Array.new(s.size,0)
mod_temp[0] = 1
(1..s.size).each do |i|
	mod_temp[i] = mod_temp[i-1] * 10 % mod
end

s.each_with_index do |c,i|
	t = mod_temp[i] * c
	if i == 0
		mod_array[i] = c % mod
	else
		mod_array[i] = (mod_array[i-1] + t) % mod
	end
	hash[mod_array[i]] += 1
end

hash.each do |k,v|
	if k == 0
		ans += v
	end
	ans += v * (v-1) / 2 if v > 1
end

puts ans

Measured memory_bytes: 29792
#include <stdio.h>

int main(){
    
    int N,H,MAX=0,count=0;
    
    scanf("%d",&N);
    int i;
    
    for(i = 1;i <= N;i++){
        scanf("%d",&H);
        if(MAX <= H){
            count++;
            MAX = H;
  //         printf("i=%d\n",i);
        }
    }
    
    printf("%d\n",count);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	while(true){
		ll n;	cin>>n;
		if(n==0) 	return 0;
		ll ans=8*n;// 底面積
		ll ans2=n/2;
		ll w=1;
		for(;w*w<n/2;w++){
			ans2+=(n+2*w-1)/(2*w);
		}
		ans2=2*ans2-w*w;
		if(n&1)	ans2++;
		ll s=ans+ans2*8;
		cout<<s<<endl;
	}
}

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

int main(){
  int N;
  string S;
  cin >> N >> S;
  int Q;
  cin >> Q;
  vector<set<int>> I(26);
  for(int i = 0; i < N; ++i){
    I[S[i]-'a'].insert(i);
  }
  for(int i = 0; i < 26; ++i)
    I[i].insert(1e9);
  while(Q--){
    int t;
    cin >> t;
    if(t == 1){
      int i;
      char c;
      cin >> i >> c;
      --i;
      I[S[i]-'a'].erase(i);
      I[c-'a'].insert(i);
      S[i] = c;
    }else{
      int l, r;
      cin >> l >> r;
      --l;
      int ans = 0;
      for(int i = 0; i < 26; ++i){
        int lb = *I[i].lower_bound(l);
        if(lb < r) ++ans;
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 24196
n, m = map(int, input().split())
c = list(map(int, input().split()))

INF = 10**12

T = [i for i in range(n+1)]

for i in range(m):
    for j in range(1, n+1):
        if j - c[i] >= 0:
            T[j] = min(T[j], T[j - c[i]] + 1)

print(T[n])

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

using namespace std;

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

const int MM = 1e9 + 7;
const double eps = 1e-8;
const int MAXN = 2e6 + 10;

int n, m;

vector<int> E[MAXN];
int l[MAXN], r[MAXN], op[MAXN];
int f[MAXN];

const int inf = 1e8;

void read(){
	scanf("%d", &n);
	for(int i = 1; i < n; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		E[x].push_back(y);
		E[y].push_back(x);
	}
	scanf("%d", &m);
	for(int i = 1; i<= n; i++)
		f[i] = -1;
	for(int i = 1; i <= m; i++){
		int x, y;
		scanf("%d%d", &x, &y);
		f[x] = y;
	}
}

int dfs(int x, int fa){
	int _l = -inf, _r = inf, _op = 0;
	int y;
	for(int i = 0; i < E[x].size(); i++){
		if ((y = E[x][i]) == fa) continue;
		if (!dfs(y, x)) return 0;
		if (op[y] == 0){
			;
		}
		else{
			if (_op == 0) _op = 3 - op[y];
			else if (_op + op[y] != 3) return 0;
			_l = max(_l, l[y] - 1);
			_r = min(_r, r[y] + 1);
		}
	}
	if (f[x] != -1){
		if (_l <= f[x] && _r >= f[x] && (f[x] % 2 == _op % 2 || _op == 0)){
			l[x] = f[x], r[x] = f[x], op[x] = 2 - (f[x] % 2);
		}
		else return 0;
	}
	else{
		l[x] = _l, r[x] = _r, op[x] = _op;
	}
	if (l[x] <= r[x])
		return 1;
	else
		return 0;
}

int DFS(int x, int fa){
	int y;
	while(l[x] % 2 != op[x] % 2)
		l[x]++;
	if (l[x] > r[x]) return 0;
	f[x] = l[x];
	r[x] = l[x];
//	cout<<x<<' '<<fa<<' '<<f[x]<<endl;
	for(int i = 0; i < E[x].size(); i++){
		if ((y = E[x][i]) == fa) continue;
		if (f[y] == -1){
			l[y] = max(l[y], f[x] - 1);
			r[y] = min(r[y], f[x] + 1);
			op[y] = 3 - op[x];
		}
		if (!DFS(y, x)) return 0;
	}
	return 1;
}

int solve(){
	if (!dfs(1, 0)) return 0;
	else{
	//	for(int i = 1; i <= n; i++)
	//		cout<<l[i]<<' '<<r[i]<<' '<<f[i]<<' '<<op[i]<<endl;
		if (!DFS(1, 0)) return 0;
		else
			return 1;
	}
}

void printans(int flag){
	if (flag == 0) puts("No");
	else{
		puts("Yes");
		for(int i = 1; i <= n; i++)
			printf("%d\n", f[i]);
	}
}
	

int main(){
	int T = 1;
//	cin>>T;
	while(T--){
		read();
		printans(solve());
	}
	return 0;
} 


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

ll op[3];
char num[4];
ll ans;
ll op_ans[3];

void calc(){
    char tmp[1];
    tmp[0] = char(num[0]);
    ans = atoi(tmp);
    rep(i, 3){
        if(op[i] == 0){
            tmp[0] = char(num[i+1]);
            ans += atoi(tmp);
        }else{
            tmp[0] = char(num[i+1]);
            ans -= atoi(tmp);
        }
    }
    if(ans == 7){
        op_ans[0] = op[0];
        op_ans[1] = op[1];
        op_ans[2] = op[2];
    }
}

void dfs(ll dp){
    if(dp == 3){
        calc();
        return;
    }
    op[dp] = 0;
    dfs(dp + 1);

    op[dp] = 1;
    dfs(dp + 1);
}

int main(void){
    cin >> num;

    dfs(0);

    rep(i, 3){
        cout << num[i];
        if(op_ans[i] == 0)
            cout << "+";
        else
            cout << "-";
    }

    cout << num[3] << "=7" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,T,A;
  cin>>N>>T>>A;
  vector<int> H(N);
  vector<double> X(N);
  double max_X=-100000;
  int ans;
  for(int i=0;i<N;i++){
    cin>>H.at(i);
    X.at(i)=T-H.at(i)*0.006;
    if (abs(X.at(i)-A)<abs(max_X-A)){
      max_X=X.at(i);
      ans=i+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;
typedef int64_t ll;


int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> L(2 * N);
    for (int i = 0; i < 2 * N; i++){
        cin >> L.at(i);
    }
    sort(ALL(L));
    for (int i = 0; i < 2 * N; i += 2){
        ans += L.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll
#define F first
#define S second

const int N = 1e5 + 10;
vector<int> g[N];
int p[N], dp[N], ans, k;

void dfs(int v) {
	dp[v] = 1;
	for (auto u : g[v]) {
		dfs(u);
		dp[v] = max(dp[v], dp[u] + 1);
	}
	if (dp[v] == k - 1 && p[v] != 1) {
		dp[v] = 0;
		ans++;
	}
}

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
	int n;
	cin >> n >> k;
	k++;
	int x;
	cin >> x;
	if (x != 1) {
		ans++;
	}
	p[1] = 1;
	for (int i = 2; i <= n; i++) {
		int x;
		cin >> x;
		g[x].pb(i);
		p[i] = x;
	}
	dfs(1);
	cout << ans << '\n';
}

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

using namespace std;

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

  int sum = 0;
  vector<int> a(n);

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

  int ret = 0;
  double min = 10000;

  for(int i = 0;i < n;i++){
    double dif = abs((double)a[i] - (double)sum/n) ;
    if(dif < min){
      min = dif;
      ret = i;
    }
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i):
	a(x,3,x)
	for t in r(i,i+30):b(p:=t+30);a(q:=p+1,3,q);[*map(b,r(q,v:=i+60))];a(v,x,t,1);b(p);a(q,t,q)
p(3934)
a(0,1,3)
a(2,3,3,1)
d(0,9)
d(1,50)
for t in r(60):a(2,2,2);[t-31<s<30!=(a(8+t-s,50+s,5),a(3,5,6,1),a(2,6,2))for s in r(t)]

Measured memory_bytes: 9340
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    int a, l, keta;
    int[] nums;
    HashMap<Integer, Integer> as;

    void run(){
	while(sc.hasNext()){
	    a = sc.nextInt();
	    l = sc.nextInt();
	    if(a==0 && l==0) break;


	    as = new HashMap<Integer, Integer>();
	    as.put(a, 0);
	    int count = 1;
	    int tmp = a;

	    while(true){

		nums = new int[l];
		keta = 10;
		for(int i=0; i<l; i++){
		    nums[i] = tmp%keta;
		    tmp /= 10;
		    //System.out.print(nums[i]+" ");
		}
		//System.out.println();

		Arrays.sort(nums);
		int x = 0, y = 0;
		keta = 1;
		for(int i=0; i<nums.length; i++){
		    x += nums[i]*keta;
		    y += nums[l-1-i]*keta;
		    keta *= 10;
		    //System.out.println(x+" "+y);
		}	

		int an = Math.abs(x-y);
		//System.out.println(an);	
		if(as.containsKey(an)){
		    System.out.println(as.get(an)+" "+an+" "+(count-as.get(an)));
		    break;
		}
		
		as.put(an, count);
		tmp = an;
		count++;
	    }
	}
    }
}

Measured memory_bytes: 20424
import java.util.*;

class Main {
    //Floyd Warshall's Algorithm
    private static final long MAX = (long) (2e10 + 1);
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        int V = scanner.nextInt();
        int E = scanner.nextInt();

        long[][] dist = new long[V][V];

        for(int i = 0; i < V; ++i){
            Arrays.fill(dist[i], MAX);
            dist[i][i] = 0;
        }

        for(int i = 0; i < E; ++i){
            int u = scanner.nextInt();
            int v = scanner.nextInt();
            int weight = scanner.nextInt();

            dist[u][v] = weight;
        }

        for(int k = 0; k < V; ++k){
            for(int i = 0; i < V; ++i){
                for(int j = 0; j < V; ++j){
                    if(dist[i][k] != MAX && dist[k][j] != MAX && dist[i][k] + dist[k][j] < dist[i][j]){
                        dist[i][j] = dist[i][k] + dist[k][j];
                    }
                }

                if(dist[i][i] < 0){
                    System.out.println("NEGATIVE CYCLE");
                    return;
                }
            }
        }

        for(int i = 0; i < V; ++i){
            for(int j = 0; j < V; ++j){
                System.out.print(dist[i][j] == MAX ? "INF" : dist[i][j]);
                if(j != V - 1){
                    System.out.print(" ");
                }
            }
            System.out.println("");
        }
    }
}

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

using namespace std;

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

const int N = 2e5+100, M = 1e6+100, K = 29;

int nxt[M][K], cnts[M], sz;

void add(string s){
	int it=0;
	for(auto C : s){
		int c = C - 'a';
		if(nxt[it][c] == -1)
			nxt[it][c] = sz ++;
		it = nxt[it][c];
	}
	cnts[it] ++;
}

string s[N];

signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	memset(nxt, -1, sizeof nxt);
	sz=1;
	int n;cin >> n;
	for(int i=0 ; i<n ; i++){
		cin >> s[i];
		reverse(s[i].begin(), s[i].end());
		add(s[i]);
	}
	ll ans=0;
	for(int i=0 ; i<n ; i++){
		int cnt[K] = {};
		for(auto c : s[i])
			cnt[c - 'a'] ++;
		int it=0;
		for(auto C : s[i]){
			for(int j=0 ; j<K ; j++){
				if(cnt[j] && nxt[it][j] != -1)
					ans += cnts[ nxt[it][j] ];
			}
			int c = C - 'a';
			cnt[c] --;
			it = nxt[it][c];
		}
	}
	ans -= n;
	cout << ans << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define nl "\n" 

void solve();

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int k,a,b;
    cin >> k >> a >> b;
    for(int i=a;i<=b;++i){
		if(i%k==0){
			printf("OK");
			return 0;
		}
	}
	printf("NG");
	return 0;
}


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

int main() {
	double a, b;
	cin >> a >> b;
	int d = a / b;
	int r = (int)a % (int)b;
	double f = a / b;
	printf("%d %d %lf", d, r, f);
	return 0;
}

Measured memory_bytes: 3284
import sys
N = int(input())

T = [0]
X = [0]
Y = [0]

for i in range(N):
    t, x, y = map(int, input().split())
    T.append(t)
    X.append(x)
    Y.append(y)

for i in range(N):
    diff_T = T[i+1] - T[i]
    diff_X = abs(X[i+1] - X[i])
    diff_Y = abs(Y[i+1] - Y[i])
    if diff_T < diff_X + diff_Y:
        print('No')
        sys.exit()
    if (diff_X + diff_Y - diff_T) % 2:
        print('No')
        sys.exit()
        
print('Yes')   


Measured memory_bytes: 11816
n, k = map(int, input().split())
trees = [int(input()) for _ in range(n)]
trees.sort()
diff_trees_height = []

for i in range(n - (k - 1)):
    diff = abs(trees[i] - trees[i + k - 1])
    diff_trees_height.append(diff)
print(min(diff_trees_height))


Measured memory_bytes: 17144
str=list(input())
flag=True
if str[0]!='A':
    flag=False
str[0]='a'
cnt=0
for i in range(2,len(str)-1):
    if str[i]=='C':
        cnt+=1
        if cnt==1:
            str[i]='c'
if cnt!=1:
    flag=False

tmp="".join(str)
if not tmp.islower():
    flag=False

if flag==True:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3064
A, B = map(int, input().split())


def f(first, last):
    diff = last - first
    m = diff % 4
    res = 0
    # print(first, last, last - m, last + 1)
    if first % 2 == 0:
        for i in reversed(range(last - m, last + 1)):
            res ^= i
        return res
    else:
        for i in reversed(range(last - m + 1, last + 1)):
            res ^= i
        res ^= first
        return res


print(f(A, B))



Measured memory_bytes: 9196
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	int N;
	cin >> N;
	int M = sqrt(N) - 1;
	for (; (M + 1) * (M + 1) <= N; M++);
	cout << M * M << endl;

	return 0;
}

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

public class Main {

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

	    int n=gi();
	    long[] s=new long[n];

	    long ans=0;
	    for (int i=0; i<n;i++) {
	    	s[i]=gl();
	    	ans+=s[i];
	    }
	    
	    if(ans%10!=0) {
	        System.out.println(ans);
	        return;
	    }
	    Arrays.parallelSort(s);
	    for (int i=0; i<n;i++) {
	    	if (s[i]%10!=0) {
	    		ans-=s[i];
	    		break;
	    	}
	    }
	    //System.out.println(ans);
	    if(ans%10==0) {
	        System.out.println(0);
	    } else {
	    	System.out.println(ans);
	    }
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

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

long long mod =  1000000007;

int main()
{
    int n,k;
    cin>>n>>k;
    map<int,int>mp;
    for(int i=0;i<k;i++)
    {
        int a;
        cin>>a;
        mp[a]++;
    }
    long long arr[n+5];
    memset(arr,0,sizeof arr);
    arr[0]=1;
    for(int i=1;i<=n;i++)
    {
        if(i-1>=0&&mp[i-1]==0)arr[i]+=arr[i-1];
        arr[i]=arr[i]%mod;
        if(i-2>=0&&mp[i-2]==0)arr[i]+=arr[i-2];
         arr[i]=arr[i]%mod;
    }
    cout<<arr[n]<<endl;
}


Measured memory_bytes: 5760
#include <stdio.h>

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


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

auto chmax = [](auto&& l, auto r) { return l < r ? l = r, 1 : 0; };

template <class It> auto rle(It first, It last) {
  vector<pair<decltype(*first), int>> res;
  for (; first != last; ++first) {
    if (res.empty() or res.back().first != *first) {
      res.emplace_back(*first, 1);
    } else {
      ++res.back().second;
    }
  }
  return res;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vector<string> s(8);
  for (auto&& e : s) {
    cin >> e;
  }
  auto in = [](int i, int j) {
    return 0 <= i and i < 8 and 0 <= j and j < 8;
  };
  auto fn = [&](int i, int j, char c, bool ch = false) {
    int res = 0;
    for (int di = -1; di <= 1; ++di) {
      for (int dj = -1; dj <= 1; ++dj) {
        if (di or dj) {
          string t;
          for (int ni = i + di, nj = j + dj; in(ni, nj); ni += di, nj += dj) {
            t += s[ni][nj];
          }
          auto v = rle(begin(t), end(t));
          if (v.size() >= 2 and v[0].first == (c ^ 'o' ^ 'x') and v[1].first == c) {
            res += v[0].second;
            if (ch) {
              s[i][j] = c;
              for (int ni = i + di, nj = j + dj; in(ni, nj) and s[ni][nj] != c; ni += di, nj += dj) {
                s[ni][nj] = c;
              }
            }
          }
        }
      }
    }
    return res;
  };
  while (true) {
    bool fo = false;
    {
      int mx = 0, mi = -1, mj = -1;
      for (int i = 0; i < 8; ++i) {
        for (int j = 0; j < 8; ++j) {
          if (s[i][j] == '.' and chmax(mx, fn(i, j, 'o'))) {
            mi = i, mj = j;
          }
        }
      }
      if (mx) {
        fn(mi, mj, 'o', true);
        fo = true;
      }
    }
    bool fx = false;
    {
      int mx = 0, mi = -1, mj = -1;
      for (int i = 8; i--; ) {
        for (int j = 8; j--; ) {
          if (s[i][j] == '.' and chmax(mx, fn(i, j, 'x'))) {
            mi = i, mj = j;
          }
        }
      }
      if (mx) {
        fn(mi, mj, 'x', true);
        fx = true;
      }
    }
    if (not fo and not fx) {
      break;
    }
  }
  for (auto e : s) {
    cout << e << '\n';
  }
}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

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

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

  int n;
  int t;
  cin >> n >> t;
  vector<int> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  int max_value = 0;
  int max_gap = 0;
  for (int i = n - 1; i >= 0; i--) {
    UpdateMax(max_value, xs[i]);
    UpdateMax(max_gap, max_value - xs[i]);
  }

  int count = 0;

  max_value = 0;
  for (int i = n - 1; i >= 0; i--) {
    UpdateMax(max_value, xs[i]);
    if (max_gap == max_value - xs[i]) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
#include<string>
#include<strstream>
#include<sstream>
#include<algorithm>
#include<math.h>
bool issqr(int n)
{
	double d = sqrt(n);
	double x = floor(d);
	if (d - x == 0)
		return true;
	else
		return false;
}
int main()
{
	int n; cin >> n;
	
	for (int i = n; i >= 0; --i)
	{
		if (issqr(i) == true)
		{
			cout << i;
			break;
		}
	}
}


Measured memory_bytes: 3636
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n;
        string s;
        cin >> n >> s;
        if(n >= 3200){
            cout << s;
        }
        else{
            cout << "red";
        }
    }
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n,i,sum=0;
    cin>>n;
    string s;
    cin>>s;
    for (i=0;i<n-2;i++){
        if (s.substr(i,3)=="ABC")sum++;
    }
    cout<<sum<<'\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long n,a[100001];
long long ans=1,sum;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)  cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=n;i>=1;i--)
	{
		if(a[i]==a[i+1])
		{
			ans*=a[i];
			i--;
			sum++;
		}
		if(sum==2)  break;
	}
	if(sum!=2)  cout<<"0";
	else        cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>

int main() {
 /* 自然数 */
  int num;
  std::cin >> num;
  int n = num;
  /* 各桁の数字 */
  int dig;
 
  /* 和 */
  int sum = 0;
 
  /* 自然数の各桁の数字の和を計算 */
  while(num){
    dig = num % 10;
    sum = sum + dig;
    num = num / 10;
  }
  //std::cout << sum;
  if (n%sum == 0) {
	  std::cout << "Yes" << std::endl;
  }
  else{
	  std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
from math import sqrt
x,y=map(int,input().split())
a=list(map(int,input().split()))
a.append(y)

p=set()

a.sort()
k=a[0]
for i in a[1:]:
    l=i-k
    s=set()
    for j in range(1,int(sqrt(l))+1):
        if l%j==0:
            
            s.add(l//j)
            s.add(j)
                
    if k==a[0]:
        k=i
        p=s
        
    else:
        k=i
        p=p.intersection(s)
    #print(s)    
print(max(p))        

Measured memory_bytes: 62576
#include<iostream>
#include<set>
#include<vector>
using namespace std ;
using ll = long long ;

int main(){
	ll n,m ;
	cin >> n >> m ;
	ll mod = 1000000007 ;
	set<ll> s ;
	for(int i=0;i<m;i++){
		ll a ; cin >> a ;
		s.insert(a) ;
	}
	vector<ll> dp(n+1,0) ;
	dp.at(0) = dp.at(1) = 1 ;
	if(s.count(1)) dp.at(1) = 0 ;
	for(int i=2;i<n+1;i++){
		if(s.count(i)) continue ;
		dp.at(i) = (dp.at(i-1)+dp.at(i-2))%mod ;
	}
	cout << dp.at(n) << endl ;
}


Measured memory_bytes: 5760
import java.util.*;
import java.util.stream.IntStream;

class Dice {
	int[] surfaces = new int[6];

	Dice(int[] diceNumArr) {surfaces = diceNumArr;}

	public int getTopNumber() {return surfaces[0];}

	public void move(String str) {
		char[] directions = str.toCharArray();
		for (char d : directions) {
			if (d == 'E') {roll(true, false, false);}
			else if (d == 'W') {IntStream.range(0, 3).forEach(e -> roll(true, false, false));}
			else if (d == 'S') {IntStream.range(0, 3).forEach(e -> roll(false, true, false));}
			else if (d == 'N') {roll(false, true, false);}
		}
	}

	private void roll(boolean x, boolean y, boolean z) {
		if (x && !y && !z) {roll(0, 3, 5, 2);}
		else if (!x && y && !z) {roll(0, 1, 5, 4);}
		else if (!x && !y && z) {roll(1, 2, 4, 3);}
	}

	private void roll(int w, int x, int y, int z) {
			int tmp = surfaces[w];
			surfaces[w] = surfaces[x];
			surfaces[x] = surfaces[y];
			surfaces[y] = surfaces[z];
			surfaces[z] = tmp;
	}
}

public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int[] diceNumArr = { sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt(), sc.nextInt() };
			Dice dice = new Dice(diceNumArr);
			dice.move(sc.next());
			System.out.println(dice.getTopNumber());
		}
	}
}


Measured memory_bytes: 32108
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		long k = sc.nextLong();
		//long l = sc.nextLong();
		long count=0;

		/*for(int i=1;i<10000;i++) {
			if(n<500*(i+1)) {
				count=i;
				break;
			}
		}*/
		if(n+m>=k) {
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		//System.out.println((int)Math.ceil((n+m)/2.0));
		//System.out.println(s.substring(0,1)+t.substring(1,2)+g.substring(2,3));
	}
}




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

int main() {
    int64_t N;
    cin >> N;
    map<string, int64_t> num;
    for (int64_t i = 0; i < N; i++) {
        string S;
        cin >> S;
        num[S]++;
    }

    for (const string& s : { "AC", "WA", "TLE", "RE" }) {
        cout << s << " x " << num[s] << endl;
    }
}

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

//solution:
#define int int64_t
#define matrix vector<vector<int>>
constexpr int mod = 1000'000'007;

auto identity(int n) {
    matrix id = matrix(n, vector<int>(n));
    for(int i = 0; i < n; ++i) id[i][i] ^= 1;
    return move(id);
}

auto multiply(matrix& A, matrix& B, int n) {
    matrix C = matrix(n, vector<int>(n));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < n; ++j) {
            for(int k = 0; k < n; ++k) {
                (C[i][j] += A[i][k] * B[k][j]) %= mod;
            }
        }
    }
    return move(C);
}
  
auto power(matrix& base, int k, int n) {
    matrix result = identity(n);
    while(k) {
        if(k & 1) result = multiply(result, base, n);
        base = multiply(base, base, n);
        k >>= 1;
    }
    return move(result);
}

signed main() {
    int n, k; cin >> n >> k;
    matrix a(n, vector<int>(n));
    for(auto& i: a) for(int& j: i) cin >> j;
    a = power(a, k, n);
    int count = 0;
    for(auto& i: a) for(int& j: i) (count += j) %= mod;
    cout << count << endl;
    return 0;
} //farewell, until we meet again..

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

int n;
vector<string> ans;
string lis[] = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n"};

void solve(string s, int num, int ma){
    if(num-1 == n){
        ans.push_back(s);
        return;
    }
    char c = s[s.size()-1];
    for(int i = 0; i <= ma+1; i++){
        string p = lis[i];
        solve(s+p, num+1, max(ma, i));
    }
    return;
}

int main(){
    cin >> n;
    string s = "a";
    if(n == 1){
        cout << s << endl;
    }else{
        solve(s, 2, 0);
    }
    sort(ans.begin(), ans.end());
    string pre = "";
    for(int i = 0; i < ans.size(); i++){
        if(ans[i] == pre){
            continue;
        }else{
            cout << ans[i] << endl;
            pre = ans[i];
        }
    }
}

Measured memory_bytes: 9588
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n; cin >> n;
    vector<int> cnt;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int num = 0;
    rep(i,n-1){
        if (h[i] >= h[i+1]) num++;
        else {
            cnt.push_back(num);
            num = 0;
        }
    }
    cnt.push_back(num);
    sort(cnt.rbegin(),cnt.rend());
    cout << cnt[0] << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

char b;

int main(){
    cin >> b;
    char ans;
    if(b == 'A') ans = 'T';
    if(b == 'C') ans = 'G';
    if(b == 'G') ans = 'C';
    if(b == 'T') ans = 'A';
    cout << ans << endl;
}

Measured memory_bytes: 256