akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

void Add(int &a, int b) {
  a += b;
  while (a >= MOD) a -= MOD;
  while (a < 0) a += MOD;
}
 
void Mul(int &a, int b) {
  a = 1LL * a * b % MOD;
}
 
int Pow(int b, int e) {
  if (e < 0) e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}
 
namespace Math {
  const int NMAX = (int)1e7;
  int pow2[1 + NMAX];
  int fact[1 + NMAX], tcaf[1 + NMAX];
  void Precalc() {
    fact[0] = pow2[0] = 1;
    for (int i = 1; i <= NMAX; ++i) {
      pow2[i] = pow2[i - 1];
      Add(pow2[i], pow2[i]);
 
      fact[i] = fact[i - 1];
      Mul(fact[i], i);
    }
    tcaf[NMAX] = Pow(fact[NMAX], -1);
    for (int i = NMAX - 1; i >= 0; --i) {
      tcaf[i] = tcaf[i + 1];
      Mul(tcaf[i], i + 1);
      assert(1LL * fact[i] * tcaf[i] % MOD == 1);
    }
  }
  int Choose(int n, int k) {
    if (k > n || n < 0) return 0;
    return 1LL * fact[n] * tcaf[n - k] % MOD * tcaf[k] % MOD;
  }
};

int main() {
  ll n,k;
  cin >> n >> k;
  Math::Precalc();
  ll ans=Math::Choose(n*2-1,n-1);
  if (k>=n-1) cout << ans << endl;
  else{
      for (ll i=n-1;i>k;i--){
          ll w=i;
          ll u=Math::Choose(n-1,w);
          u=(u*Math::Choose(n,w))%MOD;
          ans=(ans+MOD-u)%MOD;
      }
      cout << ans << endl;
  }
}


Measured memory_bytes: 117376
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#define pb push_back
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int A,B,C;
  A=max(a,max(b,c));
  C=min(a,min(b,c));
  B=a+b+c-A-C;

  cout<<A*10+B+C<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;


int main(void){
  string s;
  cin >> s;

  int ng = 0, np = 0, score = 0;
  for(int i=0;i<s.size();i++){
    if(s[i] == 'g'){
      if(ng == np){
        //g
        ng++;
        score += 0;
      }
      else{
        //p
        np++;
        score += 1;
      }
    }
    else if(s[i] == 'p'){
      if(ng == np){
        //g
        ng++;
        score += -1;
      }
      else{
        //p
        np++;
        score += 0;
      }
    }
  }
  cout << score << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
#define FIND(v,i) find(v.begin(),v.end(),i);

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	string s;
    cin >> s;
    vector<char> v;
    bool bb=1;
    SREP(i,s){
        if(i>0){
           auto res=FIND(v,s[i]);
           if(res!=v.end()) bb=0;
        }
        v.push_back(s[i]);
    }
    cout << (bb ? "yes" : "no") << endl;
/////////////////////////////////////////////
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
#include<numeric>
using namespace std;
typedef long long ll;
//ll mod = 1e9+7;
ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int score = 0;
    rep(i, n-1) {
        if ( s[i] == s[i+1] ) ++score;
    }
    int ans = min(score+2*k, n-1);
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void){
	vector<int> a;
	int k, t;
	scanf("%d", &t); a.push_back(t);
	scanf("%d", &t); a.push_back(t);
	scanf("%d", &t); a.push_back(t);
	scanf("%d", &k);

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

	printf("%d\n", a[1] + a[2] + (a[0] * (int)pow(2, k)));
	return 0;
}

Measured memory_bytes: 512
h, w = [int(i) for i in input().split()]
map_list = [[j for j in input()] for i in range(h)]

def func1(a, th):
    tmp = [a]
    if a-1 >= 0:
        tmp.append(a-1)

    if a+1 < th:
        tmp.append(a+1)
    return tmp

def func(x,y):
    count = 0
    for i in func1(x, h):
        for j in func1(y, w):
            if map_list[i][j] == "#":
                count += 1
    return str(count)

for x, rows in enumerate(map_list):
    new_lines = ""
    for y, p in enumerate(rows):
        if p == ".":
            new_lines += func(x, y)
        else:
            new_lines += p
    print(new_lines)

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int h = -1, w = -1;
    int i,j;
    while(h != 0 && w != 0)
    {
        if (h != -1 && w != -1)
        {
            putchar('\n');
        }
        scanf("%d %d", &h ,&w);
        for (i = 0; i < h; i++)
        {
            for (j = 0; j < w; j++){
                if (i % 2 ^ j % 2 == 0){
                    putchar('#');
                }
                else {
                    putchar('.');
                }
            }
            putchar('\n');
        }
        
        
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 2024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

ll n,m,c,x,y;
vi adj[N];
ll ans[N],depth[N];
bool vis[N];

void solve()
{
    cin>>n>>m;
    rep(i,0,m)
    {
        cin>>x>>y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    queue<ll>q;
    q.push(1);
    vis[1]=1;
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        c++;
        for(auto u:adj[x])
        {
            if(!vis[u])
            {
                ans[u]=x;
                vis[u]=1;
                q.push(u);
            }
        }
    }
    if(c!=n)
    {
        cout<<"No"<<endl;
        return;
    }
    cout<<"Yes"<<endl;
    rep(i,2,n+1)
    cout<<ans[i]<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 13112
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld long double
#define dd double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;
typedef vector<pll> vplll;
ll mod = 1e9+7;
const ld PI = 2 * acos(0.0);
const vector<ll> dx = {1, -1, 0, 0};
const vector<ll> dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
    if (y > x)     \
        x = y;
#define amin(x, y) \
    if (y < x)     \
        x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
    vector <ll> v[100002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c,t,n,m,k,q; 
    t = 1;
    // cin>>t;
    while(t--)
    {
    	cin>>n>>m;
    	ll ar[n];
    	for(int i=0;i<n;i++)
    		cin>>ar[i];
    	for(int i=0;i<m;i++)
    	{
    		cin>>a>>b;
    		v[a].pb(b);
    		v[b].pb(a);
    	}
    	int ans = 0;
    	for(int i=0;i<n;i++)
    	{
    		int val = ar[i];
    		int fl =0;
    		for(auto j: v[i+1])
    		{
    			if(ar[j-1]>=val)
    			{
    				fl = 1;
    				break;
    			}
    		}
    		if(!fl)
    			ans++;
    	}
    	cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 10232
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] A = new int[n+1];
        for(int i=1;i<=n;i++) A[i]=sc.nextInt();
        int[] rec = new int[n+1];
        for(int i=1;i<=n;i++) rec[A[i]] = i;
        int[] dp = new int[n+1];
        Arrays.fill(dp,1);
        boolean[] visited = new boolean[n+1];
        for(int i=1;i<=n-1;i++){
            if(visited[i]) continue;
            visited[i]=true;
            int cur = i;
            int len=1;
            while(cur<=n-1&&rec[cur+1]>rec[cur]){
                cur++;
                len++;
                visited[cur]=true;
            }
            dp[i]=len;
        }
        int res = 0;
        for(int i=1;i<=n;i++) res=Math.max(dp[i],res);
        System.out.println(n-res);
    }
}


Measured memory_bytes: 88636
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define come return
constexpr auto AC = 0;
using namespace std;




int main() {
	int a, b,c;
	cin >> a >> b>>c;
	int ans = 0;
	int abc = 0;
	
	rep(i, min(a, b) + 1) {
		if (abc >= c) {
			ans = i;
			break;
		}
			abc += max(a, b);
	}

	cout << ans << endl;
	come AC;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>

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

using namespace std;

typedef long long ll;

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int n, m; cin >> n >> m;

  vector<int> k(m);
  int s[12][12] = {0};

  rep(i, m) {
    cin >> k[i];
    rep(j, k[i]) {
      cin >> s[i][j];
    }
  }

  vector<int> p(m);
  rep(i, m) {
    cin >> p[i];
  }

  int ans = 0;

  rep(bit, 1<<n) {
    bool is_all_fire = true;
    rep(i, m) {
      int c = 0;
      rep(j, k[i]) {
        int b = bit;
        if ( ( b >> (s[i][j]-1) ) & 1 ) { c++; }
      }
      if ( c % 2 != p[i] ) { is_all_fire = false; }
    }
    if (is_all_fire) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

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

#define endl "\n"

typedef long long ll;
typedef pair <ll, ll> pii;
typedef long double ld;

const ll D = 100007;
const ll Inf = 1000000007;
ll n,m,k;
ll a,b,c;
ll v[D];
ll mas[D][3];
ll func(ll k,ll ans1,ll ans2){
    ll a,b;

    if(k==n)return max(ans1+v[k],ans2-v[k]);
    a=max(ans1+v[k],ans2-v[k]);
    b=max(ans1-v[k],ans2+v[k]);

    return func(k+1,a,b);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n;
    for(ll i=1;i<=n;i++){
        cin>>v[i];
    }
    cout<<func(2,v[1],-v[1]);

    return 0;
}


Measured memory_bytes: 1024
def search(n):
    idx = n
    while A[n-1] != n:
        n = A[n-1]
    A[idx-1] = n

    return n

N, M = list(map(int, input().split()))
A = [i for i in range(1, N+1)]
ans = 0

for i in range(M):
    X, Y, Z = list(map(int, input().split()))
    X_root, Y_root = search(X), search(Y)

    if X_root != Y_root:
        A[X_root-1] = Y_root
        ans += 1

print(N-ans)

Measured memory_bytes: 7088
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a,b;	cin >> a >> b;
  long long x=__gcd(a,b);
  
  int ans=1;
  for(long long i=2;i*i<x;i++){
    if(x%i!=0)	continue;
    ans++;
    while(x%i==0){
      x/=i;
    }
  }
  if(x!=1)	ans++;
  cout << ans;
}

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

void tree(int p, vector<unordered_map<int,int>> &t){
  if (t.at(p).size()==0) return;
  for (auto i: t.at(p)){
    t.at(i.first).erase(p);
    tree(i.first,t);
  }
}

void paint(int p, vector<unordered_map<int,int>> &t, vector<bool> &ans){
  if (t.at(p).size()==0) return;
  for (auto i: t.at(p)){
    if (i.second%2==0) ans.at(i.first)=ans.at(p);
    else ans.at(i.first)=!ans.at(p);
    paint(i.first,t,ans);
  }
}

int main(){
  int n,u,v,w;
  cin>> n;
  vector<unordered_map<int,int>> t(n); //[頂点,長さ]の配列
  for (int i=0; i<n-1; i++){
    cin>> u >> v >> w;
    t.at(u-1)[v-1]=w; t.at(v-1)[u-1]=w;
  }
  
  tree(0,t); //lengthの整理がなってなかった
  
  vector<bool> ans(n);
  paint(0,t,ans);
  
  for (int i=0; i<n; i++) cout<< ans.at(i) <<endl;
}

Measured memory_bytes: 19584
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = scan!(i64, i64, i64);
    if a == b {
        println!("{}", c);
    } else if b == c {
        println!("{}", a);
    } else {
        println!("{}", b)
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000000000
#define INF 1000000 
#define M 1000000007
#define PI 2 * acos(0.0)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std; 
int main(){
    fast_io 
    ll n,m;
    cin>>n>>m;
    ll y = (n*(n-1))/2;
    ll x = (m*(m-1))/2;
    cout<<x+y<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pii;
int main()
{
	int num;
	scanf("%d", &num);
	vector<pii>v;
	for (int i = 0; i < num; i++)
	{
		ll za, zb;
		scanf("%lld%lld", &za, &zb);
		v.push_back(make_pair(za + zb, za));
	}
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	ll s = 0;
	for (int i = 0; i < num; i++)s += (i % 2 == 0) ? v[i].second : v[i].second - v[i].first;
	printf("%lld\n", s);
}

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

int main() {
	int n,count;
	while ( cin >> n && n ) {
		count = 0;
		for ( int i = 0; i < 10; i++ ) 
			for ( int j = 0; j < 10; j++ ) 
				for ( int k = 0; k < 10; k++ ) 
					for ( int l = 0; l < 10; l++ ) 
						if ( i + j + k + l  == n )
							count ++;
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std;
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto ans = new bool[](N);
    ans[0] = true;
    auto cnt = new long[](N);
    cnt[] = 1;
    foreach (_; 0 .. M)
    {
        long x, y;
        scan(x, y);
        x--, y--;
        ans[y] = ans[y] || ans[x];
        cnt[y]++;
        cnt[x]--;
        if (cnt[x] == 0)
            ans[x] = false;
    }
    ans.sum().writeln();
}


Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mkp make_pair
#define fi first
#define se second
void read(int &x){
	scanf("%d",&x);
}
void write(ll x){
	if (x>9) write(x/10);
	putchar(x%10+'0'); 
}
int n;
pii a[2003];
bool cmp(pii A,pii B){return A.fi>B.fi;}
ll dp[2003][2003],ans;
int main(){
	read(n);
	for (int i=1;i<=n;i++) read(a[i].fi),a[i].se=i;
	sort (a+1,a+1+n,cmp);
	for (int i=0;i<=n;i++)
		for (int j=0;i+j<=n;j++){
			if (i>0)dp[i][j]=max(dp[i][j],dp[i-1][j]+1ll*abs(a[i+j].se-i)*a[i+j].fi);
			if (j>0)dp[i][j]=max(dp[i][j],dp[i][j-1]+1ll*abs(n-j+1-a[i+j].se)*a[i+j].fi);
		}
	for (int i=0;i<=n;i++) ans=max(ans,dp[i][n-i]);
	write(ans);
}

Measured memory_bytes: 26428
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c,s,f,t[501]={};
  scanf("%d",&n);
  for(int i=1;i<n;i++){
    scanf("%d%d%d",&c,&s,&f);
    for(int j=1;j<=i;j++)
      t[j]=c+max(s,(t[j]+f-(t[j]%f==0?f:t[j]%f)));
  }
  for(int i=1;i<=n;i++) printf("%d\n",t[i]);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc_060_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] a = Console.ReadLine().Split();

            Console.WriteLine((a[0][a[0].Length-1]==a[1][0]&&a[2][0]==a[1][a[1].Length-1])?"YES":"NO");
            read.Read();
        }
        public static bool IsPrime(long n)
        {
            if (n < 2) return false;
            if (n == 2) return true;

            for (int i = 2; i < n; i++)
            {
                if (n % i == 0) return false;
            }
            return true;
        }

    }
    public static class read
    {
        public static string Read() { return Console.ReadLine(); }
        public static void outl(string n = "") { Console.WriteLine(n); return; }
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }
        public static int[] Ints()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static string Str() { return Console.ReadLine(); }
        public static string[] Strs() { return Console.ReadLine().Split(); }
    }
}


Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main()
{
	int sum = 0;
	int a[3][3];
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++){
			cin >> a[i][j];
		}
	}
	int N;
	cin >> N;
	int b[N];
	for(int i = 0;i < N;i++){
		cin >> b[i];
	}
	for(int i = 0;i < 3;i++){
		for(int j = 0;j < 3;j++){
			for(int k = 0;k < N;k++){
				if(a[i][j] == b[k]){
					a[i][j] = 0;
					break;
				}
			}
		}
	}
	for(int i = 0;i < 3;i++){
		if(a[i][0] == a[i][1] && a[i][1] == a[i][2]){
			sum += 1;
		}
		if(a[0][i] == a[1][i] && a[1][i] == a[2][i]){
			sum += 1;
		}
	}
	if(a[0][0] == a[1][1] && a[1][1] == a[2][2]){
		sum += 1;
	}
	if(a[0][2] == a[1][1] && a[1][1] == a[2][0]){
		sum += 1;
	}
	if(sum == 0){
		cout << "No";
	}
	else{
		cout << "Yes";
	}
	
	return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll R;
    cin >> R;

    if(R<1200){
        cout << "ABC" << endl;
    }
    else if(R < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b + 1) / 2 << endl;
  return 0;
}


Measured memory_bytes: 3620
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [-int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    x = LI()

    for i in range(5):
        if x[i] == 0:
            print(i+1)
            return

if __name__ == '__main__':
    main()

Measured memory_bytes: 68764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>


/* 
*    coder :: ATUL_PANDEY_2608
*        >>> INDIA <<<
*/
using namespace std;
using namespace __gnu_pbds;

// #define  part ..
#define pb(a) push_back(a)
#define all(a) a.begin(),a.end() 
#define mod 1000000007
//#define maxx 200006
#define ll long long 
#define quick    ios_base::sync_with_stdio(NULL),cin.tie(0);
#define listll vector< long long > 
#define listi vector< int> 
#define pii   pair<int , int> 
#define pll pair<long long , long long > 
#define minheap priority_queue<long long , vector< long long >, greater<long long > >
#define rep(i,a,b) for(int i=a;i<b;i++)
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


template < class T > using oset = tree< T , null_type, less  < T  > , rb_tree_tag , tree_order_statistics_node_update > ;


// end of #define 

// define globals ...
const int maxx = 2e5+26;

//write function from here ...







int Main(){
	
	
	
	int n;
	cin>>n;
	
	vector   < int >  arr(n);
	
	for(int i=0 ; i  <n;i++)
	cin>>arr[i];
	
	for(int i =0 ; i  <n;i++)
	arr[i] -= i+1;
	
	sort(all(arr));
	
	ll ans = LONG_LONG_MAX;
	
 	if( n%2==0){
		
		ll temp = 0 , tmp = 0;
		int  l = n/2, m =(n-1)/2;
		
		for(int i=0 ; i < n;i++){
			
			temp+= abs(arr[i]-arr[l]);
			tmp += abs(arr[i] -arr[m]);
			
		}
		ans = min({temp,tmp});
		
		
		
	}
	else{
		
		int  l = n/2;
		ll temp  =0 ;
		 for(auto it: arr){
			 
			 
			 temp += abs(it - arr[l]);
			 
		 }
		 
		 ans = min({ans,  temp});
		
	}
	
	
	cout<<ans<<endl;
	
	




return 0;

}






int main(){
 quick;
int t =1; 
//cin>>t;
while(t-- )
 Main();

 return 0;


}


Measured memory_bytes: 3972
#include <iostream>

using namespace std;

int main()
{
    long long a, b, c, k;
    
    cin >> a >> b >> c >> k;
    
    long long sum = 0;
    
    if(a - k >= 0) {
        sum = k;
        cout << sum << endl;
    }else {
        sum += a;
        
        a -= k;
        
        if(b + a >= 0) {
            cout << sum << endl;
        }else {
            b += a;
            
            sum += -1 * (-1) * b;
            cout << sum << endl;
        }
        
    }

    return 0;
}


Measured memory_bytes: 3636
from heapq import heappop,heappush
n,m,s=map(int,input().split())
g=[[]for i in range(n)]
x=0
for i in range(m):
    u,v,a,b=map(int,input().split())
    g[u-1].append([v-1,a,b])
    g[v-1].append([u-1,a,b])
    x=max(x,a)
for i in range(n):
    c,d=map(int,input().split())
    g[i].append([i,-c,d])
x*=(n-1)
t=[[2**64 for i in range(x+1)]for i in range(n)]
q=[]
heappush(q,(0,0,s))
while q:
    a,b,c=heappop(q)
    for i,j,h in g[b]:
        if c>=j and a+h<t[i][min(x,c-j)]:
            t[i][min(x,c-j)]=a+h
            heappush(q,(a+h,i,c-j))
for i in range(1,n):
    print(min(t[i]))

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

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

    int maxCount = 0;
    for (int i = 0; i < s.size(); ++i) {
        int counter = 0;
        for (int j = i; j < s.size(); ++j) {
            if (s[j] != 'R')
                break;
            ++counter;
        }
        if (counter > maxCount)
            maxCount = counter;
    }

    cout << maxCount;
    return 0;
}


Measured memory_bytes: 3592
#include <stdio.h>

int main(){
  int n,q,i,left,right,mid,counter=0;
  int s[100000],t[50000];
  
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
    left=0;
    right=n;
    while(left<right){
      mid=(left+right)/2;
      if(s[mid]==t[i]){
	counter++;
	break;
      }
      else if(s[mid]>t[i])right=mid;
      else if(s[mid]<t[i])left=mid+1;
    }
  }
  printf("%d\n",counter);  
  return 0;
}

Measured memory_bytes: 1188
using System;

public class Hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        var t = Console.ReadLine().Trim();
        var count = 0;
        for (int i = 0; i < 3; i++)
            if (s[i] == t[i]) count++;
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 13140
#include <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#include <iomanip>
#include <unordered_map>

using namespace std;

int main()
{
    char ch;
    cin>>ch;
    ch=ch+1;
    cout<<ch;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>

using namespace std;

int lenght(char *s){
    int i = 0;
    while (s[i]){
        i++;
    }
    return i;
}

int main()
{
    int c = 1;
    char s[99];
    cin >> s;
    
    int n = lenght(s);
    
    for (int i = 0;i < (n-1)/2;i++){
        if (s[i] != s[n-1-i]){
            c = 0;
            goto EXIT;
        }
        
    }
    for (int i = 0;i < n/4;i++){
        if (s[i] != s[(n-1)/2-i-1] || s[(n+3)/2+i-1] != s[n-1-i]){
            c = 0;
            goto EXIT;
        }
    }
    EXIT:
    if(c == 0){
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
def gcd(a,b):
  a,b=max(a,b),min(a,b)
  while b!=0:
    a,b=b,a%b
  return a
ct=0
k=int(input())
for i in range(1,k+1):
  for j in range(1,k+1):
    for k in range(1,k+1):
      ct+=gcd(gcd(i,j),k)
print(ct)

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

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(' ');
        var N = int.Parse(input[0]);
        var M = int.Parse(input[1]);
        var list = new List<Hoge>();
        
        for (var i = 0; i < N; i++) {
            var input2 = Console.ReadLine().Split(' ');
            list.Add(new Hoge());
            list[i].key = decimal.Parse(input2[0]);
            list[i].value = decimal.Parse(input2[1]);
        }
        
        var newList = list.OrderBy(x => x.key);
        decimal yen = 0;
        decimal cnt = 0;
        foreach (var item in newList) {
            if (cnt > 0) {
                if ((M - cnt) < item.value) {
                    yen += (M - cnt) * item.key;
                    break;
                } else {
                    yen += item.key * item.value;
                    cnt += item.value;
                }
            } else {
                if (item.value < M) {
                    yen += item.key * item.value;
                    cnt += item.value;
                } else {
                    yen = M * item.key;
                    break;
                }   
            }
        }
        
        Console.WriteLine(yen);
    }
}

public class Hoge {
    public decimal key { get; set; } 
    public decimal value { get; set; }
}


Measured memory_bytes: 28352
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		String s = String.valueOf(n);
		char c1 = s.charAt(0);
		char c2 = s.charAt(1);
		if (c1!='9' && c2!= '9') {			
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll N,M;
ll table[100005];
map<ll,ll> MAP;

int main(){

	scanf("%lld %lld",&N,&M);

	table[0] = 0;
	MAP[0]++;

	ll ans = 0;

	for(ll i = 1; i <= N; i++){

		scanf("%lld",&table[i]);
		table[i] += table[i-1];
		table[i] %= M;

		ans += MAP[table[i]];
		MAP[table[i]]++;
	}

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

	return 0;
}


Measured memory_bytes: 8408
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
#include<random>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> ps(n); cin >> ps;
    sort(ps.begin(), ps.end());
    ps.back() /= 2;
    cout << accumulate(ps.begin(), ps.end(), 0ll) << '\n';
}


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

using ll = long long;

const int MOD = (int) 1e9 + 7;

int dp[101][4][4][4];

bool ng(int a, int b, int c) {
    return a == 1 && b == 2 && c == 3;
}


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

    int N;
    cin >> N;

    // TAGC = 0123

    dp[0][0][0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int pre3 = 0; pre3 < 4; ++pre3) {
            for (int pre2 = 0; pre2 < 4; ++pre2) {
                for (int pre = 0; pre < 4; ++pre) {
                    for (int cur = 0; cur < 4; ++cur) {
                        if (ng(pre2, pre, cur) || ng(pre, pre2, cur) || ng(pre2, cur, pre))
                            continue;
                        if (ng(pre3, pre, cur) || ng(pre3, pre2, cur))
                            continue;
                        dp[i + 1][pre2][pre][cur] += dp[i][pre3][pre2][pre];
                        dp[i + 1][pre2][pre][cur] %= MOD;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int pre2 = 0; pre2 < 4; ++pre2) {
        for (int pre = 0; pre < 4; ++pre) {
            for (int cur = 0; cur < 4; ++cur) {
                ans += dp[N][pre2][pre][cur];
                ans %= MOD;
            }
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
base_num = input()
a = int(base_num)
end_num = 0

suit_list = []
while True:
    base_suit = input()
    suit_list.append(base_suit)

    end_num += 1
    if a == end_num:
        break

master_list = [("{} {}".format(x,y)) for x in ['S','H','C','D'] for y in (x + 1 for x in range(13))]

for p in suit_list:
    master_list.remove(p)

for m in master_list:
    print(m)



Measured memory_bytes: 5604
from itertools import product
import copy
H,W,K = map(int,input().split())
S = [input().strip() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            A[i][j] = 1
cnt = 0
for x in product((0,1),repeat=H):
    for y in product((0,1),repeat=W):
        B = copy.deepcopy(A)
        for i in range(H):
            if x[i]==1:
                for j in range(W):
                    B[i][j]=0
        for j in range(W):
            if y[j]==1:
                for i in range(H):
                    B[i][j]=0
        tot=0
        for i in range(H):
            for j in range(W):
                tot += B[i][j]
        if tot==K:
            cnt += 1
print(cnt)

Measured memory_bytes: 77244
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define POS(i, j) ((i) * (m + 1) + (j))

void run (void) {
  i32 n, c;
  scanf ("%" SCNi32 "%" SCNi32, &n, &c);
  const i32 m = 400;
  i32 *s = (i32 *) calloc ((c + 1) * (m + 1), sizeof (i32));
  const i32 mod = 1000000007;
  for (i32 i = 1; i <= m; ++i) {
    for (i32 j = 0, t = 1; j <= c; ++j, t = (i64) t * i % mod) {
      s[POS(j, i)] = t;
    }
  }
  for (i32 i = 0; i <= c; ++i) {
    for (i32 j = 1; j <= m; ++j) {
      s[POS(i, j)] = (s[POS(i, j)] + s[POS(i, j - 1)]) % mod;
    }
  }
  i32 *a = (i32 *) calloc (2 * n, sizeof (i32));
  i32 *b = a + n;
  for (i32 i = 0; i < 2 * n; ++i) {
    scanf ("%" SCNi32, a + i);
  }
  i32 *dp = (i32 *) calloc (c + 1, sizeof (i32));
  dp[0] = 1;
  for (i32 i = 0; i < n; ++i) {
    for (i32 j = c; j >= 0; --j) {
      i32 local = 0;
      for (i32 k = 0; k <= j; ++k) {
        local = (local + (i64) (s[POS(k, b[i])] + mod - s[POS(k, a[i] - 1)]) * dp[j - k]) % mod;
      }
      dp[j] = local;
    }
  }
  printf ("%" PRIi32 "\n", dp[c]);
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define RI(a) scanf("%d",&a)
#define RII(a,b) scanf("%d%d",&a,&b)
#define RIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define REP(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll mod=ll(1e9+7);

int a[maxn];

int main()
{
	IOS;
   int n;
   cin>>n;
   REP(i,n) cin>>a[i];
   sort(a,a+n);
   cout<<unique(a,a+n)-a<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <complex>
#include <queue>
#include <set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF LLONG_MAX

void solve(){
	ll n;
	cin >> n;
	ll a[n];
	vector<set<ll> > gr(n);
	forn(i,n) a[i]=0;
	forn(i,n-1){
		ll t1,t2;
		cin >> t1 >> t2;
		t1--,t2--;
		a[t1]++,a[t2]++;
		gr[t1].insert(t2);
		gr[t2].insert(t1);
	}
	ll v[n];
	forn(i,n) cin >> v[i];
	sort(v,v+n);
	ll b[n];
	forn(i,n) b[i]=-1;
	ll in=0;
	ll ans=0;
	forn(i,n-1) ans+=v[i];
	forn(i,n){
		ll t1 = i;
		while(a[t1]==1){
			b[t1]=v[in];
			a[t1]--;
			ll temp;
			for(auto it : gr[t1]){
				a[it]--;
				gr[it].erase(t1);
				temp=it;
			}
			gr[t1].clear();
			in++;
			t1 = temp;
		}
	}
	cout << ans << ln;
	forn(i,n){
		if(b[i]==-1) b[i]=v[n-1];
		cout << b[i] << " ";
	}
	cout << ln;
}


int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
    // cin >> t;
    forn(i,t) solve();
    return 0;
}

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

using namespace std;

int main(){
	int x,y;
	cin>>x>>y;
	vector<int>arr;
	int p,i;
	for (i=0;i<x;i++){
		cin>>p;
		arr.push_back(p);
	} 
	sort(arr.begin(),arr.end());
	int j,sum=0;
	for (j=0;j<y;j++){
		sum=sum+arr[j];
	}
	cout<<sum;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll n,a,b;
V<ll> v;

int main(void){
	cin>>n;
	for(int a=0; a<=n; a++){
		if(a>0 && 5*pow(a-1,4)>n)break;
		v.push_back(a);
		v.push_back(-a);
	}
	rep(i,v.size()){
		rep(j,v.size()){
			if(pow(v[i],5)-pow(v[j],5)==n){
				cout<<v[i]<<" "<<v[j]<<endl;
				return 0;
			}
		}
	}
	// rep(i,v.size())cout<<v[i]<<" ";
	// cout<<endl;
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  int x ; 
  cin >> x ; 
  
  cout << (1000 - (x%1000)) % 1000 ;
  
}


Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map> 
#include <map> 
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
#include <bitset>
#include <memory>
using namespace std;
typedef long long LL;
//#define _USE_MATH_DEFINES

int main(void) {
	int y = 0;
	string a;
	cin >> a;
	for (int i = 0; i < 3; i++) {
		if (a[i] == 'o') {
			y++;
		}
	}
	cout << 700 + (y * 100) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main () { 
string s;
cin>>s;
int sz=s.length();
int a=s.find("A");
int z=s.rfind("Z");
if (a >=0 && a < sz && z >=0 && z<sz) 
cout<< abs(a - z)  + 1 ;






  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    string s;
    cin >> s;

    rep(i, s.length()) {
        rep(j, s.length()) {
            if(i != j) {
              if (s[i] == s[j]) {
                  cout << "no";
                  return 0;
              }
            }
        }
    }
    cout << "yes";

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int N = S.length();
		for(char c = 'a' ; c <= 'z' ; c++) {
			if(S.indexOf(c) == -1) {
				System.out.println(c);
				return;
			}
		}
		System.out.println("None");
	}
}

Measured memory_bytes: 23888
/*
PROG: acf17b
LANG: C++11
    _____
  .'     '.
 /  0   0  \
|     ^     |
|  \     /  |
 \  '---'  /
  '._____.'
 */
#include <bits/stdc++.h>

using namespace std;

long long readi()
{
	long long input = 0;
	char c = ' ';
	while (c < '-')
	{
		c = getchar();
	}
	bool negative = false;
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	while (c >= '0')
	{
		input = 10 * input + (c - '0');
		c = getchar();
	}
	if (negative)
	{
		input = -input;
	}
	return input;
}
void printi(long long output)
{
	if (output == 0)
	{
		putchar('0');
		return;
	}
	if (output < 0)
	{
		putchar('-');
		output = -output;
	}
	int aout[20];
	int ilen = 0;
	while(output)
	{
		aout[ilen] = ((output % 10));
		output /= 10;
		ilen++;
	}
	for (int i = ilen - 1; i >= 0; i--)
	{
		putchar(aout[i] + '0');
	}
	return;
}
string reads()
{
	string input = "";
	char c = ' ';
	while (c <= ' ')
	{
		c = getchar();
	}
	while (c > ' ')
	{
		input += c;
		c = getchar();
	}
	return input;
}
int sgn(long long x)
{
	if (x < 0) 
	{
		return -1;
	}
	if (x > 0) 
	{
		return 1;
	}
	return 0;
}
long long randomize(long long x)
{
	return (((1ll << 31) * rand()) + rand()) % x;
}

#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second

const long double PI = 4.0 * atan(1.0);
const long double EPS = 0.000000000000001;

#define SINF 10007
#define INF 1000000007
#define LLINF 2696969696969696969ll
#define CO 1000037
#define MAXN 100010

long long normalize(long long x)
{
	return (((x % INF) + INF) % INF);
}

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int N;
string s;
int zero, one, two;

int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	srand(time(0));
	//	cout << fixed << setprecision(12);	
	//	cerr << fixed << setprecision(12);
	if (fopen("acf17b.in", "r"))
	{	
		freopen ("acf17b.in", "r", stdin);
		freopen ("acf17b.out", "w", stdout);
	}
	cin >> s;
	N = s.length();
	for (int i = 0; i < N; i++)
	{
		if (s[i] == 'a')
		{
			zero++;
		}
		else if (s[i] == 'b')
		{
			one++;
		}
	}
	two = N - zero - one;
	int small = min(zero, min(one, two));
	zero -= small;
	one -= small;
	two -= small;
	if (zero >= 2 || one >= 2 || two >= 2)
	{
		cout << "NO\n";
	}
	else
	{
		cout << "YES\n";
	}
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    string S;
    int N;

    cin >> N >> S;;

    REP(i, S.length()){
        if(S[i] + N > 90){
            S[i] = 'A' + (S[i] + N - 91);
        }
        else S[i] += N;

        cout << S[i];
    }
    cout << "\n";
}

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

int main() {
    int N, M;
    int long sum = 0;
    int count = 0;
    cin >> N >> M;
    vector<long int> A(N);
    vector<pair <long int,int>> BC(M);
    vector<long int> D(0);

    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < M; i++) {
        cin >> BC.at(i).second >> BC.at(i).first;
    }
    sort(BC.begin(), BC.end());
    reverse(BC.begin(), BC.end());
    sort(A.begin(), A.end());

    for (int j = 0; j < M; j++) {
        for (int k = 0; k < BC.at(j).second; k++) {
            count++;
            D.push_back(BC.at(j).first);
            if (count == N) {
                break;
            }
        }
        if (count == N) {
            break;
        }
    }

    for (int i = 0; i < N; i++) {
        D.push_back(0);
    }

    for (int i = 0; i < N; i++) {
        sum += max(D.at(i), A.at(i));
    }

    cout << sum << endl;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORE(i, a, b) for (int i = (a); i <= (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(v) (v).begin(), (v).end()
#define sp cout << fixed << setprecision(10)
typedef pair<int, int> P;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

    char b;
    cin >> b;
    if (b == 'A')
        cout << 'T' << endl;
    else if (b == 'T')
        cout << 'A' << endl;
    else if (b == 'C')
        cout << 'G' << endl;
    else if (b == 'G')
        cout << 'C' << endl;

    return 0;
}

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

#define mod 1000000007
#define LOCAL 0
#define pb push_back
#define ll long long

ll po(ll a,ll b){
	ll x = 1,y=a;
	while(b>0){
		if(b%2){
			x = x*y;
			x %= mod;
		}
		y=y*y;
		y%=mod;
		b/=2;
	}
	return x;
}

int main(){
	if(LOCAL){
    	freopen("C:/Users/gold/Desktop/sublime IO/input.txt","r",stdin);
    	freopen("C:/Users/gold/Desktop/sublime IO/output.txt","w",stdout);
	}
	int T = 1;
	//scanf("%d",&T);
	while(T--){
		int n,m,k;
		scanf("%d %d %d",&n,&m,&k);
		int total = n * m;
		bool res = 0;
		for(int i=0;i<=m;i++){
			int other = m - i;
			for(int j=0;j<=n;j++){
				if((j*i + (n-j)*other) == k){
					res = true;
				} 
			}
		}
		puts(res?"Yes":"No");
	}
	return 0;	
}

Measured memory_bytes: 256