akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, l; cin >> n >> l;
  vector<string> s(n);
  for(int i = 0; i < n; i++) cin >> s[i];
  sort(s.begin(), s.end());
  for(int i = 0; i < n; i++) cout << s[i];
  cout << endl;
  return 0;
}


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



namespace CSharpSample01
{

    
      
    class Program
    {
        const long MOD = 1000000007;
        static long[] exp3;
        
        static void Main(string[] args)
        {
            //入力1(S)
            string S = Console.ReadLine();
            int N = S.Length;

            exp3 = new long[N + 1];
            exp3[0] = 1;
            for(int i = 1; i <= N; i++)
            {
                exp3[i] = exp3[i - 1] * 3 % MOD;
            }

            int la = 0;
            int lp = 0;

            int rc = 0;
            int rp = 0;

            long ans = 0;

            for(int i = 0; i < S.Length; i++)
            {
                if (S[i] == 'C') rc++;
                else if (S[i] == '?') rp++;
            }

            for(int i = 0; i < S.Length; i++)
            {
                if (S[i] == 'C') rc--;
                else if (S[i] == '?') rp--;

                if(S[i] == 'B' || S[i] == '?')
                {
                    //Console.WriteLine($"i:{i} lp:{lp}");
                    long left = (long)la * exp3[lp] % MOD;
                    if (lp >= 1) left = (left + (long)lp * exp3[lp - 1] % MOD) % MOD;
                    long right = (long)rc * exp3[rp] % MOD;
                    if (rp >= 1) right = (right + (long)rp * exp3[rp - 1] % MOD) % MOD;
                    ans = (ans + left * right % MOD) % MOD;
                }

                if (S[i] == 'A') la++;
                else if (S[i] == '?') lp++;
            }

            Console.WriteLine(ans);

        }
    }

}

Measured memory_bytes: 13140
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
d = sum(B) - sum(A)
for i in range(N):
  if A[i] % 2 != B[i] % 2:
    B[i] += 1
    d -= 1
print('Yes' if sum([max(A[i] - B[i], 0) for i in range(N)]) <= d else 'No')

Measured memory_bytes: 4600
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
#from fractions import gcd
#from itertools import combinations # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x,y = readInts()
for i in range(0,y//2 + 1):
    for j in range(0,y//4 + 1):
        if i + j == x and i * 2 + j * 4 == y:
            print('Yes')
            exit()
print('No')


Measured memory_bytes: 9468
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	if sum(a)%(n*(n+1)>>1)!=0
		println("NO")
	else
		k = div(sum(a),n*(n+1)>>1)
		f = 0
		for i in 1:n-1
			if k-a[i+1]+a[i]<0||(k-a[i+1]+a[i])%n!=0
				f = 1
			end
		end
		println(f==1?"NO":"YES")
	end
end

main()

Measured memory_bytes: 173540
N,W = map(int, input().split())
w,v = [0]*N, [0]*N
for i in range(N):
    w[i],v[i] = map(int, input().split())
    
# dp table
dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        if j-w[i]<0:
            dp[i+1][j] = dp[i][j]
        else:
            dp[i+1][j] = max(dp[i][j],
                             dp[i][j-w[i]] + v[i])
print(dp[N][W])

Measured memory_bytes: 120300
#include <bits/stdc++.h>
using namespace std;
int N, K;
vector<int> adj[2005];
int q, num_touched;
void dfs(int n, int k, int p)
{
	num_touched++;
	if(k>0)
	{
		for(auto a: adj[n])
		{
			if(a!= p) dfs(a, k-1, n);
		}
	}
	else
	{
		q+= adj[n].size()-1;
	}
}
int main()
{
	//freopen("infile.txt", "r", stdin);
	scanf("%d %d", &N, &K);
	int ans = N;
	for(int n=1; n<N; n++)
	{
		int A, B;
		scanf("%d %d", &A, &B);
		adj[A].push_back(B);
		adj[B].push_back(A);
	}
	if(K==1)
	{
		printf("%d\n", N-2);
		return 0;
	}
	for(int n=1; n<=N; n++)
	{
		int T=1, Q=0;
		for(auto a: adj[n])
		{
			q =0;
			num_touched=0;
			dfs(a, (K/2)-1, n);
			T+=num_touched;
			Q = max(Q, q);
		}
		if(K%2==1)
		{
			T+= Q;
		}
		ans = min(ans, N-T);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
inline int getint() {
    register char ch;
    while(!isdigit(ch=getchar()));
    register int x=ch^'0';
    while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
    return x;
}
int main() {
    std::multiset<std::string> set;
    for(register int i=getint();i;i--) set.insert("a");
    for(register int i=getint();i;i--) set.insert("b");
    for(register int i=getint();i;i--) set.insert("c");
    while(set.size()>1){
        std::string s=*set.begin(),t=*set.rbegin();
        set.erase(set.lower_bound(s));
        set.erase(set.lower_bound(t));
        set.insert(s+t);
    }
    std::cout<<*set.begin();
} 

Measured memory_bytes: 256
fn solve(n: usize, a: usize, b: usize) -> usize {
    use std::cmp::min;

    min(n * a, b)
}

#[test]
fn solve_test() {
    assert_eq!(solve(4, 2, 9), 8);
    assert_eq!(solve(4, 2, 7), 7);
    assert_eq!(solve(4, 2, 8), 8);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (n, a, b) = parse_line!(usize, usize, usize);

    println!("{}", solve(n, a, b));
}


Measured memory_bytes: 4352
function Main(input) {
  var output = "";
  for(var i = 0; i < input.length; i++){
    if(i % 2 == 0){
       output += input.slice(i , i + 1);
       }
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 10296
N, K = [int(x) for x in input().split()]
AB = [None]*N
for i in range(N):
    a, b = [int(x) for x in input().split()]
    AB[i] = (a, b) 
AB.sort()

cnt = K
for a, b in AB:
    cnt-=b
    if cnt <= 0:
        print(a)
        break




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

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int a, b, x;
  cin >> a >> b >> x;
  if(a <= x && a+b >= x) cout << "YES" << endl;
  else cout << "NO" << endl;

}






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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	ll W, H, x, y;
	cin >> W >> H >> x >> y;

	double area = W * H * 0.5;

	int ans = 0;
	if ((2 * x == W) && (2 * y == H)){
		ans = 1;
	}

	cout << area << " " << ans << endl;

	return 0;
}


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

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    string s;
    cin>>s;

    int n = s.length();
    string t;

    for (int i=0; i<n; i++){
        if (i<n-1 and s[i]=='B' and s[i+1]=='C'){
            t.push_back('D');
            i++;
        }
        else{
            t.push_back(s[i]);
        }
    }

//    cout<<t<<endl;

    int cnt = 0;
    int ans = 0;
    for (int i=0; i<(int)t.size(); i++){
        if (t[i]=='A'){
            cnt++;
        }
        else if (t[i]=='D'){
            ans += cnt;
        }
        else{
            cnt = 0;
        }
    }

    cout<<ans<<endl;

    return 0;
}





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

typedef long long ll;

ll gcd(ll numA, ll numB){
    ll maxAB = max(numA, numB);
    ll minAB = min(numA, numB);
    while(maxAB % minAB != 0){
        ll tmp = minAB;
        minAB = maxAB % minAB;
        maxAB = tmp;
    }
    return minAB;
} 

int main()
{
    int N;
    cin >> N;
    vector<ll> nums(N);
    int minusCount = 0;
    for(int i = 0; i < N; i++)
    {
       ll num;
       cin >> num;
       nums.at(i) = num;
    }
    vector<ll> gcds(N + 1);
    vector<ll> revGcds(N + 1);
    gcds.at(0) = nums.at(0);
    for(int i = 1; i < N; i++)
    {
        gcds.at(i) = gcd(nums.at(i), gcds.at(i - 1));
    }
    revGcds.at(N - 1) = nums.at(N - 1);
    for(int i = N - 2; i >= 0; i--)
    {
        revGcds.at(i) = gcd(nums.at(i), revGcds.at(i + 1));
    }
    ll answer = 0;
    for(int i = 0; i < N; i++){
        if (i == 0){
            answer = max(answer, revGcds.at(1));
        } else if(i == N - 1){
            answer = max(answer, gcds.at(N - 2));
        } else {
            answer = max(answer, gcd(gcds.at(i - 1), revGcds.at(i + 1)));
        }
    }

    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 2560
#region Using directives
using System;
using static System.Console;
using static System.Convert;
using System.Collections.Generic;
#endregion

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = ReadLine().Split();
            int A = ToInt32(input[0]);
            int B = ToInt32(input[1]);
            int C = ToInt32(input[2]);
            int D = ToInt32(input[3]);
            int E = ToInt32(input[4]);
            int F = ToInt32(input[5]);
            HashSet<int> st = new HashSet<int>();
            int x = 1;
            A *= 100; B *= 100;
            while (A*x <= F)
            {
                for (int i = 0; i <= x; i++)
                {
                    int sum = i * A + (x-i)*B;
                    if (sum <= F)
                        st.Add(sum);
                    sum = i * B + (x-i)*A;
                    if (sum <= F)
                        st.Add(sum);
                }
                x++;
            }
            int[] sug = new int[st.Count];
            int[] water = new int[st.Count];
            st.CopyTo(water);
            for (int i = 0; i < st.Count; i++)
            {
                int pos = Math.Min(water[i] + (water[i]/100) * E, F);
                pos -= water[i];
                sug[i] = pos;
            }
            int[] answ = new int[sug.Length];
            for (int k = 0; k < sug.Length; k++)
            {
                bool f = false;
                for (int j = sug[k]; j >= C; j--)
                {
                    for (int i = 0; i <= sug[k]; i++)
                        if ((i % C == 0 && (j - i) % D == 0) || (i % D == 0 && (j - i) % C == 0))
                        {
                            f = true;
                            break;
                        }
                    if (f)
                    {
                        answ[k] = j;
                        break;
                    }
                }
                if (!f)
                    answ[k] = 0;
            }
            double[] t = new double[answ.Length];
            for (int i = 0; i < answ.Length; i++)
                t[i] = (double)answ[i] / ((double)water[i] + (double)answ[i]);
            double ma = 0; int  ima = 0;
            for(int i = 0; i < t.Length; i++)
                if(t[i] > ma)
                {
                    ma = t[i];
                    ima = i;
                }
            WriteLine($"{water[ima] + answ[ima]} {answ[ima]}");
            ReadKey();
        }
    }
}



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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int count = 0;
  for (int i = 0; i <= n - 3; i++) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
      count++;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
using namespace std;
int n,q,t,k,d,ans;
map <char,char> mp,mp2;
const int maxn=1e5+7;
int num[maxn];
bool vis[1000];
int main(){
    string a;
    string b;
    memset(num,-1,sizeof(num));
    cin>>a>>b;
    int len=a.size();
    for(int i=0;i<len;i++)
    {
        if(num[a[i]]==-1)
        {
            num[a[i]]=b[i];
        }
        else
        {
            if(num[a[i]]!=b[i])
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    memset(num,-1,sizeof(num));
    for(int i=0;i<len;i++)
    {
        if(num[b[i]]==-1)
        {
            num[b[i]]=a[i];
        }
        else
        {
            if(num[b[i]]!=a[i])
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
	}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef map<int,int> mii;
typedef vector<int>vi;
#define pb push_back
#define sc(n) scanf("%d",&n)
#define lsc(n) scanf("%lld",&n)
#define all(x) x.begin(),x.end()
#define rep(i,n) for(i=0LL;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define rev1(i,n) for(i=n;i>0;i--)
#define in insert
#define IT ::iterator
#define pr(n) printf("%d\n",n)
#define lpr(n) printf("%lld\n",n);

int main()
{
	int n,ii,ans=0,num=1;
	cin >>n;
	for(ii=2;ii<=n;ii++)
	{
		int aa=0,i=ii;
		while(i%2==0)
		{
			aa++;
			//cout << aa << endl;
			i/=2;
		}
		if(ans<aa)
		{
			ans=aa;
			num=ii;
		}
	}
	
	cout << num;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
using namespace std;
/*
 * Complete the twoStacks function below.
 */
void fun() {
    ll i,z=0,c,d,y=0,x,l=0,j,m,n,num,p,q,k,r;
    cin>>n>>m>>x;
    vector<ll>a(n),b(m);
    for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<m;i++)
    cin>>b[i];
 /*  reverse(a.begin(),a.end());
   reverse(b.begin(),b.end());
 //  int i,l=0,z=0;
   stack<ll>s,s1;
   for(i=0;i<a.size();i++)
   {
       s.push(a[i]);
   }
   for(i=0;i<b.size();i++)
   {
       s1.push(b[i]);
   }
    
    while(1)
    {
        if(s1.empty() && s.empty())
        break;
        else if(s.top()>=s1.top() && !s1.empty() && !s.empty())
        {
            if(l+s1.top()<=x)
            {
                z++;
                l+=s1.top();
                s1.pop();
            }
            else
            break;
        }
        else if(s1.top()>s.top() && !s.empty() && !s1.empty())
        {
            if(l+s.top()<=x)
            {
                z++;
                l+=s.top();
                s.pop();
            }
            else
            break;
        }
        else if(s1.empty() && !s.empty())
        {
            if(l+s.top()<=x)
            {
                z++;
                l+=s.top();
                s.pop();
            }
            else if(s.empty())
            break;
            else
            break;
        }
        else if(s.empty() && !s1.empty())
        {
            if(l+s1.top()<=x)
            {
                z++;
                l+=s1.top();
                s1.pop();
            }
            else if(s1.empty())
            break;
            else
            break;
        }
        
    }
    cout<<z;*/
    i=0; ll s=0; 
    while(i<a.size() && s+a[i]<=x)
    {
        s+=a[i];
        i++;
    }
    j=0;
    ll count ;
    count=i;
    while(j<b.size() && i>=0)
    {
        s+=b[j];
        j++;
        while(s>x && i>0)
        {
            i--;
            s-=a[i];
        }
       if(s<=x && i+j>count)
        count=i+j;
    }
    cout<<count;
}

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


Measured memory_bytes: 6344
#include <stdio.h>

unsigned long long factorial(unsigned long long x) {
    int i;
    unsigned long long product = 1;
    if (x == 0) return 1;
    else if (x == 1) return 1;
    for (i = 2; i < x; i++) {
        product *= i;
    }
    return product;
}

int main() {
    unsigned long long N, M;
    scanf("%lld %lld", &N, &M);
    printf("%lld", N * (N - 1) / 2 + M * (M - 1) / 2);
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string> 
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <cmath>



typedef long long ll;


using namespace std;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

ll maxn=2*100000;
string l;
//vector<ll> b;
vector<ll> w;

//二重ループだと間に合わない
//結局終わりの形は決まっているのでそれと比較
int main(){
    cin>>l;
    ll ans=0;
    for (int i=0;i<l.size();i++){
        if (l[i]=='W') {
            w.push_back(i);
        }
    }
    for (int i=0;i<w.size();i++){
            ans+=w.at(i)-i;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2552
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
template <class T> void corner(bool flg, T hoge) {
    if (flg) {
        cout << hoge << endl;
        exit(0);
    }
}
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main() {
    cin >> n >> k;
    inputv(A, n);
    sort(all(A));
    b = n - min(n, k);
    rep(i, b) {
        ans += A[i];
    }
    cout << ans<<endl;
}

Measured memory_bytes: 2420
N,K,Q= [int(s) for s in input().split()]
A = [int(input()) for _ in range(Q)]

temp=[0]*N

for i in A:
  temp[i-1]=temp[i-1]+1

ans = list(map(lambda x: K-(Q-x), temp))

for t in ans:
  if t>0:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 12588
N = int(input())
L = list(map(int,input().split()))
ans = 0
flag = 0
while flag == 0 :
    counter = 0
    for i in range(N) :
        if (i+1) == L[i] :
            ans += 1
            if i == 0 :
                L[i],L[i+1] = L[i+1],L[i]
            elif i == N-1 :
                L[i-1],L[i] = L[i],L[i-1]
            else :
                if L[i-1] == i :
                    L[i-1],L[i] = L[i],L[i-1]
                else :
                    L[i],L[i+1] = L[i+1],L[i]
        else :
            counter += 1
    if counter == N :
        flag = 1
print(ans)


Measured memory_bytes: 14008
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
typedef pair<pii, ll>pi3;
ll mod = 1000000007;
ll gcd(ll a, ll b)
{
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
int a[202020];
int main()
{
	int num;
	scanf("%d", &num);
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		a[z / 400]++;
	}
	int r = 0, s = 0;
	for (int i = 0; i <= 7; i++)r += (a[i] > 0);
	for (int i = 8; i < 100; i++)s += a[i];
	if (r == 0)r++, s--;
	printf("%d %d\n", r, r + s);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a, b, c;
	int x = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++)
		if (c%i == 0){
			x++;
		}
	cout << x << endl;

	return 0;
}



Measured memory_bytes: 3108
fun main(args: Array<String>) {
    abc152d()
}

fun abc152d() {
    val n = readLine()!!.toInt()

    val dic = Array(10) { IntArray(10) { 0 } }

    for (i in 1..n) {
        val first = i.toString().first().toString().toInt()
        val last = i.toString().last().toString().toInt()
        dic[last][first]++
    }

    var answer = 0L

    for (a in 1..n) {
        val first = a.toString().first().toString().toInt()
        val last = a.toString().last().toString().toInt()
        answer += dic[first][last]
    }

    println(answer)
}


Measured memory_bytes: 54756
import sys
    
def shortest_path(GRAPH, distance):
    
    nodes = set()
    p1 = 0
    distance[p1] = 0

    while True:
        dp1 = distance[p1]
        gp1 = GRAPH[p1]
        status[p1]=1
        for p2 in gp1.keys():
            tmp = gp1[p2] + dp1
            if status[p2]==0 and tmp < distance[p2]:
                distance[p2] = tmp
                nodes.add(p2)

        p1 = -1
        mini = 1000000
            
        for p2 in nodes:
            if distance[p2]<mini:
                p1 = p2
                mini = distance[p2]
        if mini == 1000000:
            break
        nodes.remove(p1)
    return

def resultout(distance):
    for i in xrange(len(distance)):
        print "%d %d" %(i, distance[i])
    return

n = int(raw_input())
x = [{} for i in xrange(n)]
status = [0 for i in xrange(n)]
distance = [1000000 for i in xrange(n)]

for i in xrange(n):
    seq = map(int, raw_input().split())
    tmp={}
    for j in xrange(2, len(seq), 2):
        j2, weight = seq[j:j+2]
        tmp[j2] = weight
    x[seq[0]] = tmp
    status[i] = 0

shortest_path(x, distance)
resultout(distance)

Measured memory_bytes: 4684
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Deque;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		String str[] = br.readLine().split(" ");
		int a[] = new int[n + 1];

		for (int i = 0; i < n; i++) {
			a[i + 1] = Integer.parseInt(str[i]);
		}

		int dp[] = new int[n + 10];

		ArrayList<Integer> list = new ArrayList<>();
		for (int i = n; i >= 1; i--) {
			int sum = 0;
			for (int j = i; j <= n; j += i) {
				sum += dp[j];
			}
			if ((sum + a[i]) % 2 == 1) {
				dp[i]++;
				list.add(i);
			}
		}

		Collections.sort(list);

		System.out.println(list.size());
		if (list.size() != 0) {
			System.out.print(list.get(0));
			for (int i = 1; i < list.size(); i++) {
				System.out.print(" " + list.get(i));
			}
			System.out.println();
		}
	}

	public static final ArrayList<Integer> divisor(final int n) {
		final ArrayList<Integer> list = new ArrayList<>();

		for (int i = 1; i * i <= n; i++) { // √n
			if (n % i == 0) {
				list.add(i); // a x b
				if (i != n / i) {
					list.add(n / i); // b x a (逆向き)
				}
			}
		}
		return list;
	}
}

Measured memory_bytes: 63572
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int k,l,r;
    cin>>k>>l>>r;
    for(int i=k; i<=r; i+=k){
        if(l<=i){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3588
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){ 
    int w,a,b,ans;
    cin>>w>>a>>b;
    if (b>=a and b<=a+w) ans=0;
    if (b>a+w) ans = b-(a+w);
    else ans = max(0LL,(a-w)-b);
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define MAX(a, b) ((a) < (b) ? (b) : (a))

const long long INF = 1LL << 60;
typedef long long ll;
const long long MOD = 1000000000 + 7;

int main()
{
    ll n, m;
    cin >> n >> m;
    if (n == 1 && m == 1)
    {
        cout << 1 << endl;
        return 0;
    }
    if (n == 1 || m == 1)
    {
        cout << max(n - 2, m - 2) << endl;
        return 0;
    }
    cout << (n - 2) * (m - 2) << endl;
    return 0;
}

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

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

int main() {
  string s, t;
  cin >> s >> t;
  map<char, int> smp, tmp;
  rep(i, s.size()){
    smp[s[i]]++;
    tmp[t[i]]++;
  }
  rep(i, s.size()){
    if(smp[s[i]] != tmp[t[i]]){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 776
n = int(input())
cou = 0
lis = []
li = []
for i in range(n):
  a,b = map(int,input().split())
  lis.append(a)
  li.append(b)
for i in range(1,n+1):
  if (cou + lis[-i]) % li[-i] != 0:
    cou += (li[-i] -(cou + lis[-i]) % li[-i])
print(cou)

Measured memory_bytes: 11052
import java.util.*;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner as = new Scanner(System.in);
		int n,x,i,j,k,t;
		int s = 0;
		String str;
		
		while(true){
			
			n = as.nextInt();
			x = as.nextInt();
			s=0;
			
			if(n == 0 && x == 0){
				break;
			}
			
			for(i=1;i<=n;i++){
				for(j=1;j<=n;j++){
					for(k=1;k<=n;k++){
						
						if(i != j && j != k && i != k){
								
							if((i+j+k) == x){
								
								s++;
								
							}
								
						}
							
					}	
				}	
			}
			
			str=String.valueOf(s/6);
			System.out.println(str);
			
		}
		
		

	}

}

Measured memory_bytes: 26760
(defun App ()
    (let ((a (read))
        (b (read))
        (c (read))
        (d (read)))

        (loop while (or (> a 0) (> c 0))
        do (progn
            (setf a (- a d))
            (setf c (- c b))
            (if (<= c 0)
                (progn
                (format t "Yes~%")
                 	(return)
                )
            )
            (if (<= a 0)
                (progn
                (format t "No~%")
                (return)
                )
            )
        )
        )
    )
    
)

(App)

Measured memory_bytes: 23432
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    for(int i = 0; i < K; i++){
      if(i%2==0){
        A /= 2;
        B += A;
      }else{
        B /= 2;
        A += B;
      }
    }
    
    System.out.println(A+" "+B);
  }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
    ll a,b,c,k;
    ll ans = 0;
    cin >> a >> b >> c >> k;
    if(a>=k)ans = k;
    else if(a+b>=k)ans = a;
    else ans = a-(k-(a+b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3616
def root(x):
    path_to_root = []
    while P[x] != x:
        path_to_root.append(x)
        x = P[x]
    for node in path_to_root:
        P[node] = x # パス圧縮
    return x
def is_same_set(x,y):
    return root(x) == root(y)
def unite(x,y):
    P[root(x)] = root(y)

n,q = map(int,input().split())
P = [i for i in range(n)]
for _ in range(q):
    a,b,c = map(int,input().split())
    if a==0:
        unite(b,c)
    elif a==1:
        if is_same_set(b,c):
            print(1)
        else:
            print(0)


Measured memory_bytes: 5988
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	vector<int> Number(5);
	for(int i = 0; i < 5; i++){
		scanf("%d", &Number[i]);
	}
	sort(Number.begin(), Number.end(), greater<int>());
	for(int i = 0; i < 5; i++){
		if(i != 4){
			printf("%d ", Number[i]);
		}else{
			printf("%d\n", Number[i]);
		}
	}
	return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>

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

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

	public Main() {
		//		new AOJ0262().doIt();
		new AOJ0261().doIt();
	}

	class AOJ0261{
		void doIt(){
			while(true){
				int n = in.nextInt();
				if(n==0)return;
				ArrayList<Integer> p = new ArrayList<Integer>();
				ArrayList<Integer> j = new ArrayList<Integer>();
				for(int i=0;i<n;i++)p.add(in.nextInt());
				for(int i=0;i<n-1;i++)j.add(in.nextInt());
				Collections.sort(j);
				Collections.reverse(j);
				long kei = 0;
				for(int i=0;i<p.size();i++)kei+=p.get(i);
				long memo = kei*n;
				for(int i=0;i<n-1;i++){
					kei+=j.get(i);
					long conv = kei*(n-i-1);
					memo = Math.max(memo, conv);
				}
				System.out.println(memo);
			}
		}
	}


	class AOJ0262{
		int n,m;
		int[] masu;
		int[] map;

		boolean dfs(int index,int cost){
			//			System.out.println(index+" "+cost);
			index = index+masu[index];
			if(index<0)index = 0;
			if(index>n)return true;
			if(map[index]<cost)return false;
			map[index] = cost;
			for(int i=1;i<=m;i++){
				if(dfs(index+i, cost+1))return true;
			}
			return false;
		}

		void doIt(){
			while(true){
				m = in.nextInt();
				if(m==0)break; 
				n = in.nextInt();
				masu = new int[n+505];
				for(int i=1;i<=n;i++)masu[i] = in.nextInt();
				boolean sw = false;
				map = new int[n+505];
				for(int i=1;i<=n;i++){
					Arrays.fill(map, Integer.MAX_VALUE);
					sw = dfs(i,0);
					if(sw==false)break;
				}
				System.out.println(sw? "OK":"NG");
			}
		}
	}

}

Measured memory_bytes: 167188
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] c = new int[100000];
		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			c[a]++;
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < 100000 - 2; i++) {
			int val = c[i] + c[i + 1] + c[i + 2];
			ans = Math.max(ans, val);
		}
		System.out.println(ans);
	}
}


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

int main(){
    int n,x;cin>>n>>x;
    vector<int> v(n);
    rep(i,n){
        cin >>v[i];
    }
    int sum =0;
    int i=0;
    while(sum<=x){
        if(i==n){
          i++;
            break;
        }
        sum+=v[i];
        i++;
    }
    cout << i << endl;
}

Measured memory_bytes: 256
n, m = map(int,input().split())

a = list(map(int,input().split()))

#総投票数
s = sum(a)

a.sort(reverse=True)

b = 0

for i in range(m): 
  if a[i] >= s/(4*m) :
    b += 1
    
if b == m :
  print("Yes")
else :
  print("No")


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    if (n==m){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
import sys, math
n, p = map(int, input().split())

sqp = math.floor(math.sqrt(p)) + 1
if n == 1:
    print(p)
    sys.exit(0)
insu = {}
for i in range(2, sqp + 1):
    while p % i == 0:
        p //= i
        if i in insu:
            insu[i] += 1
        else:
            insu[i] = 1
ans = 1
for i in insu:
    while insu[i] >= n:
        insu[i] -= n
        ans *= i
print(ans)

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

const ll INF = 1LL << 62;
const double PI = acos(-1);
const double eps = 1e-10;

int main() {
  ll n;
  cin >> n;
  char c;
  map<char, int> mp;
  rep(i, n) {
    cin >> c;
    mp[c]++;
  }
  cout << (mp.size() == 3 ? "Three" : "Four") << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;
	int ans = INF;
	for (int i = 0; i < N; i += 2)
	{
		ans = min(ans, max(0, x - i / 2) * a + max(0, y - i / 2) * b + i * c);
	}
	cout << ans << endl;
	return 0;
}


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

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(void)
{
  int n;
  int d,r;
  int a[200000]={0};
  long int ans;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    scanf("%d",&a[i]);
  }

  qsort(a,n,sizeof(int),compare_int);
  ans = a[0];
  d = (n-2)/2;
  r = (n-2)%2;
  for(int i=0;i<d;i++)
  {
    ans += a[i+1];
    ans += a[i+1];
  }
  if(r==1) ans += a[d+1];

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

  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

int main()
{
  int N, Q;
  while (N = in(), Q = in(), N || Q){
    int bkt[128] = {};
    for (int i = 0; i < N; i++){
      for (int x = in(); x--;){
        bkt[in()]++;
      }
    }
    int maxi = 0;
    for (int i = 1; i < 128; i++){
      if (bkt[i] >= Q && bkt[maxi] < bkt[i]){
        maxi = i;
      }
    }
    cout << maxi << endl;
  }
  return 0;
}

Measured memory_bytes: 1196
class UnionFindTree():
    def __init__(self, values=[]):
        self.__parent_of = {}
        self.__rank_of = {}
        self.__size = {}
        for value in values:
            self.add(value)

    def add(self, value):
        if value in self.__parent_of:
            raise RuntimeError("Dupulicated Value Added")
        self.__parent_of[value] = None
        self.__rank_of[value] = 0
        self.__size[value] = 1

    def __root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.__root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.__root(a)
        r2 = self.__root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
                self.__size[r2] += self.__size[r1]
            else:
                self.__parent_of[r2] = r1
                self.__size[r1] += self.__size[r2]
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1

    def is_same(self, a, b):
        return self.__root(a) == self.__root(b)

    def size(self, a):
        return self.__size[self.__root(a)]

    def groups(self):
        groups = {}
        for k in self.__parent_of.keys():
            r = self.__root(k)
            if r not in groups:
                groups[r] = []
            groups[r].append(k)
        return [groups[x] for x in groups]


def main():
    N, M = map(int, input().split())
    E = [tuple(map(int, input().split())) for _ in range(M)]
    ans = 0
    for i in range(M):
        uft = UnionFindTree(list(range(1, N+1)))
        for j in range(M):
            if i == j:
                continue
            a, b = E[j]
            uft.unite(a, b)
        if uft.size(1) != N:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 44396
// AtCoder_Beginner_Contest_159_C

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

using namespace std;

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

  int N;
  N = S.length();

  string s11, s12;
  s11 = S.substr(0,(N-1)/2);
  s12 = S.substr((N-1)/2 + 1, (N-1)/2);
  reverse(s12.begin(), s12.end());

  string s2, s21, s22;
  s2 = S.substr(0, (N-1)/2);
  char N2;
  N2 = (int)(s2.length());
  s21 = s2.substr(0, N2/2);
  s22 = s2.substr((N2+1)/2, N2/2);
  reverse(s22.begin(), s22.end());


  string s3, s31, s32;
  s3 = S.substr((N-1)/2 + 1, (N-1)/2);
  char N3;
  N3 = (int)(s3.length());
  s31 = s3.substr(0, N3/2);
  s32 = s2.substr((N3+1)/2, N3/2);
  reverse(s32.begin(), s32.end());

  string ans = "No";
  if(s11 == s12){
      if(s21 == s22){
          if(s31 == s32)
            ans = "Yes";
      }
  }

  cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

int main(){
  int n; cin >> n;
  if(n<1200) cout << "ABC" << endl;
  else if(n <2800) cout << "ARC" << endl;
  else cout << "AGC" << endl; 

  return 0;
}


Measured memory_bytes: 256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000; 
const lo MIN = 1000000000000000000; 
const lo inf = 1000000000; 
const lo KOK = 100000; 
const lo LOG = 30; 
const lo li = 100005; 
const lo mod = 1000000007; 

int n,m,b,a[li],k,flag;
int cev;
string s;
vector<int> v;

int main(void){
	scanf("%d",&n);
	if(n==5 || n==7 || n==3){printf("YES");}
	else printf("NO");
	return 0;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define nl '\n'
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cerr << #x << " = " << (x) << endl;

// template starts
typedef long long int ll;

// template ends here

void solve(){
	// code starts from here
	ll S;
	cin >> S;
	//S = 2000;
	vector<ll> dp(S+1);
	dp[0] = 1;
	for(int i = 3; i <= S; i++){
		for(int j = 0; j <= i-3; j++){
			dp[i] += dp[j];
			dp[i] %= MOD;
		}
	}
	cout << dp[S] << endl;
}

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	//startTime = clock();
	
	int T;
	//cin >> T;
	T = 1;
	while(T--){
		solve();
	}
	
	//cerr << getCurrentTime() << endl;
	return 0;
}


Measured memory_bytes: 3672
#include<bits/stdc++.h>
#define lli long long int 
using namespace std;
int main(){
    lli n,k,ans=0;
    cin >> n >> k;
    lli a[n];
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    sort(a,a+n);
    for(int i=n-1;i>=0;--i){
        if(k>0){
            a[i]=0;
            k--;
        }
        else{
            break;
        }
    }
    for(int i=0;i<n;++i){
        ans+=a[i];
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <array>
#include <bitset>
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define inf 0x3f3f3f3f3f3f3f3f
#define endl '\n'
using namespace std;

signed main() {
    fastio;
    int x; cin >> x;
    if (x == 0) {
        cout << 1 << endl;
        return 0;
    } else {
        cout << 0 << endl;
        return 0;
    }
}

Measured memory_bytes: 3200