akhauriyash/Code-Regression huggingface dataset:
# include <cstring>
# include <cstdio>
# include <iostream>
# include <queue>
# define N 100050 //N为顶点个数 
# define M 200050 //N为顶点个数 
# define WQD 0x7f7f7f7f//无穷大 
int n;//图的顶点个数
int m;//图的边数 
struct Edge{int next,to, w;}  e[M<<1];//不用0号单元 
int head[N+1]; 
int dis[N+1];//存放源点到其他点的路径
bool vis[N+1];
bool book[N+1];
bool spfa(int s);//差分约束判断 
using namespace std;
int main()
{
	ios::sync_with_stdio ( false ) ;
	int u,v,w;
	memset(head,-1,sizeof(head));
	cin>>n>>m;
	for(int i=1; i<=m; i++)  //本题约束关系为=，要添加两条边 
	{
		cin>>u>>v>>w;//输入第i条边 ,i为编号 
		e[i]=(Edge){head[u],v,w};head[u]=i;
		e[m+i]=(Edge){head[v],u,-w};head[v]=m+i;
	}
	memset(book,0,sizeof(book));
	memset(dis,0x7f,sizeof(dis));
	for(int i=1; i<=n; i++)//每一个点都要校验到 
		if(!vis[i]) //如果i点没有校验，就用spfa校验和i点连通的区域 
		{
			vis[i]=1;
			if(spfa(i)==false)  {cout<<"No";return 0;}//有约束自相矛盾 
		}
	cout<<"Yes";//所有的点都符合条件 
	return 0;
}
bool spfa(int s)
{
 	queue<int>q;
 	//memset(book,0,sizeof(book));
	//memset(dis,0x7f,sizeof(dis));
	dis[s]=0;
	q.push(s);book[s]=1;	
	//如果没松弛就松弛，如果松弛过就判断是否符合约束条件，如果自相矛盾就是不可能的数据
	while(q.size()>0) 
	{
		int k=q.front();q.pop();//对头元素出队 
		book[k]=0;
		for(int i=head[k]; i!=-1; i=e[i].next)
		{
			int v=e[i].to;
			//题目的约束条件是= ，不相等，自相矛盾 
			if(dis[v]<WQD && dis[k]<WQD && dis[v]!=dis[k]+e[i].w)	return false;
			else if(dis[v]==WQD && dis[k]<WQD)//如果v点没松弛过，就松弛更新dis[v]的值 				
			{				
				dis[v]=dis[k]+e[i].w;//更新 
				if(book[v]==0)	{q.push(v);	book[v]=1;}//入队标记
				vis[v]=1;//标记该点已经检验过 
			}
			
		}		
    }
	return true;//别掉了这句 
}

Measured memory_bytes: 6400
loop do
  a,b = gets.split().map(&:to_i)
  break if a == 0 && b == 0
  a.times do |c|
    if c == 0 || c % 2 == 0
      b.times do |d|
        if d == 0 || d % 2 == 0
          print "#"
        else
          print "."
        end
      end
    else
      b.times do |e|
        if e == 0 || e % 2 == 0
          print "."
        else
          print "#"
        end
      end
    end
  print "\n"
  end
  puts ""
end


Measured memory_bytes: 6876
#include <stdio.h>
#include <string.h>
#define LEN 100001

typedef struct process {
  char name[100];
  int t;
} P;

static P queue[LEN];
static int head, tail;

static P dequeue(void) {
  P x = queue[head];
  head = (head + 1) % LEN;
  return x;
}

static void enqueue(P x) {
  queue[tail] = x;
  tail = (tail + 1) % LEN;
}

int min(int a, int b) { return a < b ? a : b; }

int main(void) {
  int elaps = 0, c, num;
  int i, q;
  P u;
  scanf("%d %d", &num, &q);

  for (i = 1; i <= num; i++) {
    scanf("%s", queue[i].name);
    scanf("%d", &queue[i].t);
  }
  head = 1;
  tail = num + 1;

  while (head != tail) {
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if (u.t > 0) enqueue(u);
    else {
      printf("%s %d\n", u.name, elaps);
    }
  }
  return 0;
}


Measured memory_bytes: 11928
/*
Author- Aasav Badera
Time- Sun Mar 22 17:30:45 2020
*/
#include<bits/stdc++.h> 
#define ll                 long long                            
#define pb                 push_back                                                     
#define s                  second
#define mii                map<ll ,ll >
#define dbg(x)             { cerr<<#x<<": "<<x<< endl; }
#define dbg2(x,y)          { cerr<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define rep(i, a, b)         for(ll  i=a;i<b;i++)
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define f                  first 
#define vi                 vector<ll >
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define hell               1000000007
#define mp                 make_pair
#define yes                cout << "YES" << endl;
#define no                 cout << "NO" << endl;
#define inf                1e18L+1
#define endl               '\n' 
using namespace std;
#define N  300005

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll tests = 1;
    // cin >> tests;
    while(tests--)
    {
    	ll n,m;
    	cin >> n >> m;
    	ll ans = n * (n-1) + m*(m-1);
    	ans /=2;
    	cout << ans ;
    }
    return 0;
}

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


int main(){
    // あとで消す
    //std::ifstream in("bin3.txt");
    //std::cin.rdbuf(in.rdbuf());

    double res = 0.0;

    int N;
    cin >> N;

    int tmp;
    for(int i=0;i<N;i++){
        cin >> tmp;
        res += 1.0/tmp;
    }

    cout << (1.0/res) << endl;

    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n), w(n);
  for (auto&& e : v) cin >> e;
  copy(begin(v), end(v), begin(w));
  sort(begin(v), end(v));
  int a = v[n / 2 - 1];
  int b = v[n / 2];
  for (auto&& e : w) {
    cout << (e >= b ? a : b) << endl;
  }
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){

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

         vector<int>vect;

          int matrix[n][m];

          for(int i=0;i<n;i++)
          {
             int t;
              cin>>t;
               vect.push_back(t);

             for(int j=0;j<m;j++)
                 cin>>matrix[i][j];
          }
           int r = pow(2,n);

            long long int value=-1;

          for(int i=1;i<=r-1;i++){

              vector<int>bit;
               int j=i;

               while(j > 0){

                  int rem = j % 2;
                    bit.push_back(rem);

                     j=j/2;
               }
                int p = n - bit.size();
                 for(int i=1;i<=p;i++)
                  bit.push_back(0);

                vector<long long int>ger(m,0);
                long long int yer = 0;

                for(int i=0;i<bit.size();i++){

                     if(bit[i]==1)
                     {
                        for(int e=0;e<m;e++)
                         ger[e]+=matrix[i][e];

                          yer+=vect[i];
                     }
                }
               int u=0;


                for(int e=0;e<m;e++)
                {
                   if(ger[e] < x)
                   {
                      u=1;
                      break;
                   }
              }
              
                  if(u==0){

                        if(value==-1)
                         value = yer;

                         else{

                             if(value > yer)
                              value = yer;
                         }
                  }
          }
            if(value )
           cout<<value;
}


Measured memory_bytes: 4064
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}


#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;
main(){
    string s,t;cin>>s>>t;
    int ans=0;
    rep(i,3){
        ans+=(s[i]==t[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

struct UnionFind
{
    int n, num;
    vector<int> sz, par;
    UnionFind() {}
    UnionFind(int n_) : n(n_), num(n_), sz(n_, 1), par(n_, 0) { iota(par.begin(), par.end(), 0); }
    int find(int x)
    {
        return (x == par[x] ? x : par[x] = find(par[x]));
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (sz[x] < sz[y])
            swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
        num--;
    }
    int size(int x)
    {
        return sz[find(x)];
    }
    int count() const
    {
        return num;
    }
};


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

    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);

    vector<int> fr(n, 0);
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
        fr[a]++;
        fr[b]++;
    }

    REP(i, k) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        if(uf.same(a,b)) fr[a]++, fr[b]++;
    }

    REP(i, n) {
        int sz = uf.size(i);
        cout << sz - fr[i] - 1 << " \n"[i==n-1];
    }

    return 0;
}

Measured memory_bytes: 2048
n = gets.to_i
x = gets.split.map(&:to_i)
m = gets.to_i
a = gets.split.map(&:to_i)
a.each do |i|
  x[i - 1] += 1 if x[i - 1] < 2019 && x[i - 1] + 1 != x[i]
end
puts x


Measured memory_bytes: 8896
#include <stdio.h>

int main(void)
{
	int num_A[4],num_B[4],i,j;
	int Hit,Blow;
	while(scanf("%d",&num_A[0])!=EOF){
		for(i=1;i<4;i++){
			scanf("%d",&num_A[i]);
		}
		for(i=0;i<4;i++){
			scanf("%d",&num_B[i]);
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(i==j && num_A[i]==num_B[j]) Hit++;
				else if(num_A[i]==num_B[j]) Blow++;
			}
		}
		printf("%d %d\n",Hit,Blow);
		Hit=0,Blow=0;
	}
	return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int a[1003];
int main(){
	int n,num=0,ans=1e9,qub=0;
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a[i];
		num+=a[i]; 
	}
	ans=num;
	for (int i=0;i<n;i++){
		qub+=a[i];
		ans=min(ans,abs(num-2*qub));
	}
	cout<<ans;
}

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

int main(void)
{
  int a,b,c,d;
  int i;

  scanf("%d %d %d %d",&a,&b,&c,&d);

  while(1)
  {
    c-=b;
    if(c<1)
    {
      printf("Yes\n");
      break;
    }
    a-=d;
    if(a<1)
    {
      printf("No\n");
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 1656
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
//#include <vector>
//#include <unordered_map>
//#include <string>
//typedef long long LL;
//typedef long double LD;
using namespace std;

int main() {
    int n;
    int tmp_ans;
    int ans = -1;
    cin >> n;
    tmp_ans = (double)n / 1.08;
    for(int i = -1; i<2; i++){

        if((int)((double)(tmp_ans+i)*1.08)==n){
            ans = tmp_ans + i;
        }
    }
    if(ans==-1){
        cout << ":(" << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

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

int main() {
  ll n; cin >> n;
  ll ans = 0;
  rep(i,n)
    ans += i;
  cout << ans << endl;
}

Measured memory_bytes: 3620
s = input()
if s == "SUN":
  print("7")
elif s == "MON":
  print("6")
elif s == "TUE":
  print("5")
elif s == "WED":
  print("4")
elif s == "THU":
  print("3")
elif s == "FRI":
  print("2")
elif s == "SAT":
  print("1")

Measured memory_bytes: 8928
/*
????????????????????§???????????????????????£???????????????????????????
 */

using System;
using System.IO;
using System.Diagnostics;
using System.Linq;
using System.Collections.Generic;

class Program{
    static void Main(){
        TextReader reader;
        string filename = "";
        if(filename.Length!=0){
            reader = new StreamReader(filename);
        }else{
            reader = Console.In;            
        }
        var watch = new Stopwatch();

        var nk = reader.ReadLine().Split().ToArray();
        var n = Int64.Parse(nk[0]);
        var k = Int64.Parse(nk[1]);
        var lis = new long[n];
        for(long x=0; x<n; x++){
            lis[x]=Int64.Parse(reader.ReadLine());
        }

        watch.Start();
        /*
        //?????´?§£
        int i = 0;
        while(Func(i, k, n, lis)<n){
            //????´?????¶???????????????????
            i++;
        }
        watch.Stop();
        Console.WriteLine($"?????????:{i}");
        Console.WriteLine($"???????????? {watch.ElapsedMilliseconds}???????§?");
        */
        //???????????????????????§?§£???
        long left = 0;
        long right = 10000*100000;
        long mid;
        while(right-left>1){
            //??????1???????????????????????????????????????
            //left==right??????????????¨???????????????????????? ????????????????????§???2???????????????
            mid = (left+right)/2;
            long v = Func(mid, k, n, lis);
            if(v>=n)right = mid;
            else left = mid;
        }
        watch.Stop();
        Console.WriteLine(right);
        //Console.WriteLine($"???????????? {watch.ElapsedMilliseconds}???????§?");

    }

    static long Func(long p, long k, long n, long[] weights){
        //?????????????????????p??¶???????????????????????????????????§??????
        //?????????????????¶??????????????????
        long ans = 0;
        for(long i=0; i<k; i++){
            long tmp = 0;
            while(tmp+weights[ans] <= p){
                tmp+=weights[ans];
                ans++;
                if(ans==n) return n;
            }
        }
        return ans;
    }  
}

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

public class Program
{
	public static void Main()
	{
		int[] arr = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();
		int N = arr[0];
		int K = arr[1];
		List<int> dislike = Console.ReadLine().Split().Select(i => int.Parse(i)).ToList();
		for (int i = N; ; i++)
		{
			bool flag = true;
			for (int j = i; j > 0; j /= 10)
			{
				if (dislike.Contains(j % 10))
				{
					flag = false;
					break;
				}
			}
			if (flag)
			{
				Console.WriteLine(i);
				return;
			}
		}
	}
}

Measured memory_bytes: 2904
#include <stdio.h>

int main(void){
  int c, A, B, C;
  scanf("%d %d", &A, &B);
  c = 0;
  C = 1;
  while(C < B){
    c++;
    C += A - 1;
  }
  printf("%d\n", c);
  return 0;
}


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

int main() {
	int n;
	cin >> n;
	long s = 100000;
	for (int i = 0; i<n; i++) {
		s = s * 1.05;
		int s1 = s % 1000;
		if (s1 != 0) {
			s = s - s1 + 1000;
		}
	}
	cout << s << "\n";
	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;

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

int main()
{
	int n;
	int d[100];
	cin >> n;

	rep(i, n)
	{
		cin >> d[i];
	}

	ll ret = 0;
	rep(i, n)
	{
		rep(j, n)
		{
			if (i == j) continue;
			ret += d[i] * d[j];
		}
	}
	
	cout << ret / 2;

	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int ans = new BigInteger("2").modPow(BigInteger.valueOf(n / 2), new BigInteger("1000000007")).intValue();
		int[] tmp = new int[n];
		if (n % 2 == 0) {
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				if (a % 2 == 0 || ++tmp[a] > 2) {
					ans = 0;
					break;
				}
			}
		} else {
			for (int i = 0; i < n; i++) {
				int a = sc.nextInt();
				if (a % 2 == 1 || (a == 0 && ++tmp[a] > 1) || a < 0 || (a > 0 && ++tmp[a] > 2)) {
					ans = 0;
					break;
				}
			}
		}
		
		out.println(ans);
		out.flush();
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	
	private byte readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	
	private boolean isPrintableChar(int c) {
		return '!' <= c && c <= '~';
	}
	
	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}
	
	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}
	
	public int nextInt() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		int n = 0;
		boolean minus = false;
		byte b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
}

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

int main(){
  int N;
  cin >> N;
  vector<string> vecs(N);
  for (int i = 0; i < N; i++) {
      cin >> vecs.at(i);
  }
  int M;
  cin >> M;
  vector<string> vect(M);
  for (int i = 0; i < M; i++) {
      cin >> vect.at(i);
  }
  map<string, int> maps;
  for(int i = 0; i < N; i++){
    string S = vecs.at(i);
    if(!maps.count(S)){
    	maps[S] = 1;
    }
    else{
    	maps.at(S)++;
    }
  }
  map<string, int> mapt;
  for(int i = 0; i < M; i++){
    string S = vect.at(i);
    if(!mapt.count(S)){
    	mapt[S] = 1;
    }
    else{
    	mapt.at(S)++;
    }
  }
  int res = 0;
  for(auto p: maps){
    string key = p.first;
    int value = p.second;
    if(mapt.count(key)){
    	res = max(value - mapt.at(key), res);
    }
    else{
    	res = max(value, res);
    }
  }
  cout << res << endl;
}

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

using namespace std;

string expr(const string& S, int i) {
    string e;
    for (int j = 0; j < 3; ++j) {
        e += S[j];
        if (i >> j & 1) {
            e += '+';
        } else {
            e += '-';
        }
    }
    e += S[3];
    return e;
}

int eval(const string& S) {
    int i = 0;
    int r = S[i++] - '0';
    while (i < S.size()) {
        if (S[i++] == '+') {
            r += S[i++] - '0';
        } else {
            r -= S[i++] - '0';
        }
    }
    return r;
}

int main() {
    string S;
    cin >> S;
    for (int i = 0; i < (1 << 3); ++i) {
        string e = expr(S, i);
        if (eval(e) == 7) {
            cout << e << "=7" << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
//#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <string>
#include <set>
#include <functional>
#include <numeric>
#include <sstream>
#include <stack>
#include <map>
#include <queue>

#define CL(arr, val)    memset(arr, val, sizeof(arr))

#define ll long long
#define inf 0x7f7f7f7f
#define lc l,m,rt<<1
#define rc m + 1,r,rt<<1|1
#define pi acos(-1.0)

#define L(x)    (x) << 1
#define R(x)    (x) << 1 | 1
#define MID(l, r)   (l + r) >> 1
#define Min(x, y)   (x) < (y) ? (x) : (y)
#define Max(x, y)   (x) < (y) ? (y) : (x)
#define E(x)        (1 << (x))
#define iabs(x)     (x) < 0 ? -(x) : (x)
#define OUT(x)  printf("%I64d\n", x)
#define lowbit(x)   (x)&(-x)
#define Read()  freopen("a.txt", "r", stdin)
#define Write() freopen("dout.txt", "w", stdout);
#define maxn 1000000000
#define N 1010
using namespace std;

int h,w,x;
int dir[4][2]={-1,0,0,1,0,-1,1,0};
typedef pair<int,int> P;
P p;
char maze[N][N];
int d[N][N];

int bfs(char c)
{
    queue<P>que;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++) d[i][j]=maxn;
    que.push(p);
    d[p.first][p.second]=0;
    P p1,p2;
    while(que.size())
    {
        p1=que.front(); que.pop();
        if(maze[p1.first][p1.second]==c)
        {
            p=p1; break;
        }
        for(int i=0;i<4;i++)
        {
            p2.first=p1.first+dir[i][0];
            p2.second=p1.second+dir[i][1];
            if(p2.first>=0&&p2.first<h&&p2.second>=0&&p2.second<w&&maze[p2.first][p2.second]!='X'&&d[p2.first][p2.second]==maxn)
            {
                que.push(p2);
                d[p2.first][p2.second]=d[p1.first][p1.second]+1;
            }
        }
    }
    return d[p.first][p.second];
}

int main()
{
    //freopen("a.txt","r",stdin);
    while(~scanf("%d%d%d",&h,&w,&x))
    {
        getchar();
        int sum=0;
        for(int i=0;i<h;i++)
        {
            scanf("%s",maze[i]);
            //printf("%s\n",maze[i]);
            for(int j=0;j<w;j++)
            {
                if(maze[i][j]=='S')
                {
                    p.first=i;
                    p.second=j;
                }
            }
        }
        //printf("%d %d\n",p1.first,p1.second);
        for(int i=1;i<=x;i++)
        {
            sum+=bfs('0'+i);
        }
        printf("%d\n",sum);
    }
   return 0;
}

Measured memory_bytes: 6192
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, Sum = 0;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int l, r;
    cin >> l >> r;
    Sum += r-l+1;
  }
  cout << Sum << endl;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
ll ans;llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,q;sc(n);sc(q);
 char s[100010];
 sc(s);
 ll ac[100010];
 rep(i,0,n)ac[i]=0;
 rep(i,1,n){
  ac[i]+=ac[i-1];
  if(s[i]=='C'&&s[i-1]=='A'){
   ac[i]++;
  }
  //pr(ac[i]);
 }
 ll l,r;
 rep(i,0,q){
  sc(l);sc(r);
  pr(ac[r-1]-ac[l-1]);
  //cout<<ac[r-1]<<" "<<ac[l-1]<<endl;
 }
 
return 0;}

Measured memory_bytes: 4532
#include <iostream>
#include <algorithm>
 
using namespace std;
 
int x,y;
int calc(int pp){
    int p = 0;
    for(int i = 1 ; i < 1000 ; i++){
	if(i*(100+x)/100 == pp){
	    p = i;
	    break;
	}
    }
    return p*(100+y)/100;
}
 
int main(){
    int s;
    while(cin >> x >> y >> s,(x|y|s)){
	int max = 0;
	for(int i = 1 ; i <= s/2 ; i++){
	    max = std::max(max,calc(i)+calc(s-i));
	}
	cout << max << endl;
    }
    return 0;
}

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

int main() {
  int k, n;
  cin >> k >> n;
  int a[n];
  int interval[n];
  for ( int i = 0; i < n; i++ ) {
    cin >> a[i];
  }
  for ( int i = 0; i < n; i++ ) {
    interval[i] = ( i+1 < n ) ? a[i+1] - a[i] : k-a[i] + a[0];
  }
  sort(interval, interval+n);
  cout << k - interval[n-1] << endl;
  return 0;
}


Measured memory_bytes: 5156
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }


bool check(string s){
    if(s.size() % 2 != 0) return false;
    for(LL i = 0; i < s.size(); i += 2){
        if(s[i] != 'h') return false;
        if(s[i+1] != 'i') return false;
    }
    return true;
}

int main(){
    string s;
    cin >> s;
    if(check(s)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long[] line = Stream.of(sc.nextLine().split(" ", 0)).mapToLong(Long::parseLong).toArray();
		long min = 0;

		if(Math.abs(line[1] - (line[0] % line[1])) > line[0] % line[1]) {
			min = line[0] % line[1];
		}else {
			min = Math.abs(line[1] - (line[0] % line[1]));
		}


		System.out.println(min);
	}
}


Measured memory_bytes: 35992
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        int donuts[] = new int[n];
        int count = 0;
        for(int i = 0; i < n ; i++){
            donuts[i] = sc.nextInt();
        }
        Arrays.sort(donuts);
        for(int value : donuts){
            x -= value;
            count++;
        }
        while(x >= donuts[0]){
            x -= donuts[0];
            count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23636
a,n1=map(int,input().split())
b,n2=map(int,input().split())
c,n3=map(int,input().split())
d,n4=map(int,input().split())

t1=6000
t2=4000
t3=3000
t4=2000

if a==1:
    if b==2:
        if c==3:
            print(t1*n1)
            print(t2*n2)
            print(t3*n3)
            print(t4*n4)
        else:
            print(t1*n1)
            print(t2*n2)
            print(t4*n3)
            print(t3*n4)
    elif b==3:
        if c==2:
            print(t1*n1)
            print(t3*n2)
            print(t2*n3)
            print(t4*n4)
        else:
            print(t1*n1)
            print(t3*n2)
            print(t4*n3)
            print(t2*n4)
    else:
        if c==2:
            print(t1*n1)
            print(t4*n2)
            print(t2*n3)
            print(t3*n4)
        else:
            print(t1*n1)
            print(t4*n2)
            print(t3*n3)
            print(t2*n4)


elif a==2:
    if b==1:
        if c==3:
            print(t2*n1)
            print(t1*n2)
            print(t3*n3)
            print(t4*n4)
        else:
            print(t2*n1)
            print(t1*n2)
            print(t4*n3)
            print(t3*n4)
    elif b==3:
        if c==1:
            print(t2*n1)
            print(t3*n2)
            print(t1*n3)
            print(t4*n4)
        else:
            print(t2*n1)
            print(t3*n2)
            print(t4*n3)
            print(t1*n4)
    else:
        if c==1:
            print(t2*n1)
            print(t4*n2)
            print(t1*n3)
            print(t3*n4)
        else:
            print(t2*n1)
            print(t4*n2)
            print(t3*n3)
            print(t*n4)

elif a==3:
    if b==1:
        if c==2:
            print(t3*n1)
            print(t1*n2)
            print(t2*n3)
            print(t4*n4)
        else:
            print(t3*n1)
            print(t1*n2)
            print(t4*n3)
            print(t2*n4)
    elif b==2:
        if c==1:
            print(t3*n1)
            print(t2*n2)
            print(t1*n3)
            print(t4*n4)
        else:
            print(t3*n1)
            print(t2*n2)
            print(t4*n3)
            print(t1*n4)
    else:
        if c==1:
            print(t3*n1)
            print(t4*n2)
            print(t1*n3)
            print(t2*n4)
        else:
            print(t3*n1)
            print(t4*n2)
            print(t2*n3)
            print(t1*n4)

else:
    if b==1:
        if c==2:
            print(t4*n1)
            print(t1*n2)
            print(t2*n3)
            print(t3*n4)
        else:
            print(t4*n1)
            print(t1*n2)
            print(t3*n3)
            print(t2*n4)
    elif b==2:
        if c==1:
            print(t4*n1)
            print(t2*n2)
            print(t1*n3)
            print(t3*n4)
        else:
            print(t4*n1)
            print(t2*n2)
            print(t3*n3)
            print(t1*n4)
    else:
        if c==1:
            print(t4*n1)
            print(t3*n2)
            print(t1*n3)
            print(t2*n4)
        else:
            print(t3*n1)
            print(t3*n2)
            print(t2*n3)
            print(t1*n4)



Measured memory_bytes: 5748
#include<stdio.h>

int a[200005],c[200005],d[200005];

int _max(int x,int y){return x>y?x:y;}
int _gcd(int x,int y){return y==0?x:_gcd(y,x%y);}

int main(){
	
	/*freopen("10.in","r",stdin);
	freopen("10.out","w",stdout);*/
	int n,i,ans=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
		c[i]=_gcd(a[i],c[i-1]);
	}
	for(i=n;i>=1;i--)
		d[i]=_gcd(d[i+1],a[i]);
	for(i=1;i<=n;i++)
		ans=_max(ans,_gcd(c[i-1],d[i+1]));
	printf("%d",ans);
	return 0;
}
	
		
		
 

Measured memory_bytes: 1280
def prime_factorization(n):
    P = set()
    i = 2
    while i * i <= n:
        while n % i == 0:
            n //= i
            P.add(i)
        i += 1
    if n > 1:
        P.add(n)

    return P

a, b = map(int, input().split())
print(len(prime_factorization(a) & prime_factorization(b)) + 1)


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

int main() {
    string s;
    cin >> s;
    vector<long long> ans(s.size(), 0);

    int index = -1;
    for(int i=1; i<s.size(); i++){
        if(s[i-1] == 'R' && s[i] == 'L'){
            index = i;
        }
        
        if(index != -1 && s[i] == 'L'){
            if((i-index)%2 == 0){
                ans[index]++;
            }else{
                ans[index-1]++;
            }
        }
    }

    index = -1;
    for(int i=s.size()-2; i>=0; i--){
        if(s[i+1] == 'L' && s[i] == 'R'){
            index = i;
        }
        
        if(index != -1 && s[i] == 'R'){
            if((i-index)%2 == 0){
                ans[index]++;
            }else{
                ans[index+1]++;
            }
        }
    }

    string o = "";
    for(int i=0; i<s.size(); i++){
        o += to_string(ans[i]);
        if(i != s.size()-1){
            o += " ";
        }
    }
    cout << o << endl;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>

using namespace std;

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

    for(int i = a;i <= b;i++){
        string s = to_string(i);
        if(s[0] == s[4] && s[1] == s[3])ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class ABeginner {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n,r;
        in >> n >> r;
        int ans = r + max(0,100*(10-n));
        out << ans << endl;
	}
};


int main() {
	ABeginner solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

namespace ConsoleApp15
{
    class Class276
    {
        static void Main()
        {
            string N = Console.ReadLine();
            for(int i = 0; i < 3; i++)
            {
                if(N[i] == '7')
                {
                    Console.WriteLine("Yes");
                    return;
                }
            }
            Console.WriteLine("No");
        }
    }
}


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

int main(){
    long long int a,b,n;
    cin>>a>>b>>n;
    long long int ans=0;
    if(b>n){
        ans=(1ll*a*n)/b;
    }
    else{
        ans=(1ll*a*(b-1))/b;
    }
   cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3468
#include<bits/stdc++.h>
#define pb push_back 
 #define fo(i,n) for(int i=0;i<n;i++)
#define ll long long
#define Mod 1000000009 
#define MAX 4294967296  // 2^32

using namespace std;



int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
   
ll ans=Mod;

   ll a,b,c;
   cin>>a>>b>>c;
   a=abs(a);
   
   long long t=a/c;
    if(a>0 && (a/c)>=b ){
        cout<<abs(a-b*c);
        return 0;
    }



a-=t*c;
   b-=t;
   if(b%2==0){
    cout<<abs(a);
   }else cout<<min((abs(a+c)),abs(a-c));
   






}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long
#define moder 1234567
#define inf 1000000000000000000
#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>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;


signed main() {
	string s;
	int a=0,b=-1;
	cin>>s;
	rep(i,s.size()){
		if(s[i]=='A'&&b==-1)b=i;
		if(s[i]=='Z')a=i;
	}
	cout<<a-b+1<<endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {

  long n,t;
  scanf("%ld %ld", &n, &t);
  long a[n],b[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld %ld", &a[i], &b[i]);
  }
  long dp1[n][t],dp2[n][t];
  for (long i = 0; i < t; i++) {
    dp1[0][i] = 0;
  }
  if (a[0] < t) {
    dp1[0][a[0]] = b[0];
  }
  for (long i = 1; i < n; i++) {
    for (long j = 0; j < t; j++) {
      dp1[i][j] = dp1[i-1][j];
    }
    for (long j = 0; j < t; j++) {
      if (j+a[i] >= t) {
        break;
      }
      if (dp1[i-1][j]+b[i] > dp1[i][j+a[i]]) {
        dp1[i][j+a[i]] = dp1[i-1][j]+b[i];
      }
    }
  }
  for (long i = 0; i < t; i++) {
    dp2[n-1][i] = 0;
  }
  if (a[n-1] < t) {
    dp2[n-1][a[n-1]] = b[n-1];
  }
  for (long i = n-2; i >= 0; i--) {
    for (long j = 0; j < t; j++) {
      dp2[i][j] = dp2[i+1][j];
    }
    for (long j = 0; j < t; j++) {
      if (j+a[i] >= t) {
        break;
      }
      if (dp2[i+1][j]+b[i] > dp2[i][j+a[i]]) {
        dp2[i][j+a[i]] = dp2[i+1][j]+b[i];
      }
    }
  }
  for (long i = 0; i < n; i++) {
    for (long j = 1; j < t; j++) {
      if (dp1[i][j] < dp1[i][j-1]) {
        dp1[i][j] = dp1[i][j-1];
      }
      if (dp2[i][j] < dp2[i][j-1]) {
        dp2[i][j] = dp2[i][j-1];
      }
    }
  }
  long score,max = 0;
  for (long last = 0; last < n; last++) {
    score = 0;
    if (last == 0) {
      for (long i = 0; i < t; i++) {
        if (dp2[1][i] > score) {
          score = dp2[1][i];
        }
      }
    } else if (last == n-1) {
      for (long i = 0; i < t; i++) {
        if (dp1[n-2][i] > score) {
          score = dp1[n-2][i];
        }
      }
    } else {
      for (long i = 0; i < t; i++) {
        if (dp1[last-1][i]+dp2[last+1][t-1-i] > score) {
          score = dp1[last-1][i]+dp2[last+1][t-1-i];
        }
      }
    }
    score += b[last];
    if (score > max) {
      max = score;
    }
  }
  printf("%ld\n", max);

  return 0;
}

Measured memory_bytes: 142364
#include <iostream>

using namespace std;

int main() {
	int a;
	int b;
	cin >> a;
	cin >> b; 
	if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a < b) {
		cout << "a < b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}
}


Measured memory_bytes: 3080
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main(){
  string a; cin>>a;
  for(int i = 0; i < a.length(); ++i){
    if(a[i]=='7'){
      cout<<"Yes"<<endl;
      exit(0);
    }
  }
  cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;
 
LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;
 
}
 
LL exp(LL a, LL b){
    LL res = 1;
    LL sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}
 
double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}
 
LL LCM(LL a, LL b){
    LL c = a;
    LL d = b;
    while(d){
        c%=d;
        swap(c, d);
    }
    return a/c*b;
}
 
signed  main(){
    LL sum = 0;
    LL A, B, C, D;
    cin >> A >> B >> C >> D;
    sum += B / C;
    sum += B / D;
    sum -= B / LCM(C, D);
    sum -= (A-1) / C;
    sum -= (A-1) / D;
    sum += (A-1) / LCM(C, D);
    cout << B-A+1-sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=(a);i<=(b);++i)
#define rv(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define SZ(x) (int)(x.size())
#define pb(x) push_back(x)
#define P pair<int,int>
using namespace std;
const int M = 210000;
const ll inf = 9e18;
int n,m,k;
void solve() {
    string t,s;
    cin >> s >> t;
    int ans=0;
    fo(i,0,SZ(s)-1) {
        int cnt=0;
        fo(j,0,SZ(t)-1) {
            if(i+j>SZ(s)-1) {
                cnt=0;
                break;
            }
            cnt += (t[j]==s[i+j]);
        }
        ans = max(cnt, ans);
    }
    cout << SZ(t) - ans << endl;
}
int main()
{ 
    int t;
    //cin >> t;
    t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int a = scan.nextInt();
		
		int b = scan.nextInt();
		
		if(a > b) {
			System.out.println("a > b");
		} else if(a < b) {
			System.out.println("a < b");
		} else {
			System.out.println("a == b");
		}
		
	}

}


Measured memory_bytes: 26004
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	fastio;

	int n; cin>>n;
	cout<<((n+999)/1000)*1000 - n<<ln;

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i<N; i++)
#define RVROOP(i, N) for(int i=N; i>=0; i--)
#define INF 1e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  ll N; cin>>N;
  ll A[N];
  ROOP(i, N){
    cin>>A[i];
  }
  ll ans=0;
  ROOP(i, 60){
    ll a=0;
    ROOP(j, N){
      if(A[j]%2==0){
        a++;
      }
      A[j]/=2;
    }
    ll ans2=(N-a)*a%MOD;
    ROOP(j, i){
      ans2*=2;
      ans2%=MOD;
    }    
    ans=(ans+ans2)%MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
	if (n == 0)
	{
		putchar('0');
		putchar('\n');
	}
	else if (n == -1)
	{
		putchar('-');
		putchar('1');
		putchar('\n');
	}
	else
	{
		char buf[11];
		buf[10] = '\n';
		int i = 9;
		while (n)
		{
			buf[i--] = n % 10 + '0';
			n /= 10;
		}
		while (buf[i] != '\n')
			putchar(buf[++i]);
	}
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
	if(g==0)return 1;

	if(g%2==1)return (num*power((num*num)%mod,g/2))%mod;
	return power((num*num)%mod,g/2);
}
int n;
ld a[3000][3000];
ld b[3000];
ld solve(int i,int j)
{
	if(i+j==n)
	{
		if(i<j)a[i][j]=0.0;
		else a[i][j]=1.0;
		return a[i][j];
	}
	if(a[i][j]>=0.0)
	{
		return a[i][j];
	}
	a[i][j]=0.0;
	a[i][j]=solve(i+1,j)*b[i+j];
	a[i][j]+=solve(i,j+1)*((ld)1.0-b[i+j]);
	return a[i][j];
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);

  	cin>>n;
  	For(i,n)cin>>b[i];
  	For(i,n)For(j,n)a[i][j]=-1.0;
  	cout<<fixed<<setprecision(13)<<solve(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 141056
(* O(1) *)
Scanf.scanf " %d %d %d %d %d" @@ fun a b c x y ->
  let both = min x y in
  let d, z = if x > y then a, x - both else b, y - both in
  both * min (a + b) (2 * c) + z * min d (2 * c) |> Printf.printf "%d\n"

Measured memory_bytes: 2432
def mk_table(n):
    res = [1] * (n + 1)
    res[:2] = 0, 0

    for i in range(2, n):
        if i ** 2 > n:
            break

        if res[i] == 1:
            for j in range(i*2, n + 1, i):
                res[j] = 0

    return res


tbl = mk_table(999999)
try:
    while 1:
        print(len([x for x in tbl[:int(input())+1] if x == 1]))
except Exception:
    pass

Measured memory_bytes: 24296
from collections import defaultdict 
import sys,heapq,bisect,math,itertools,string

sys.setrecursionlimit(10**8)

#N:頂点数   M:辺数
A,B,K = map(int,input().split())


if (B-A+1) >= 2*K: 
	for i in range(K):
		print(A+i)
		
	for i in range(K)[::-1]:
		print(B-i)
	
else:
	for i in range(A,B+1):
		print(i)

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

const int MAX=100005;
vector<pair<int,long long int>> S[MAX];
int color[MAX],K,now[MAX];
long long int D[MAX];
stack<pair<int,long long int>> T;

void DFS(){
    T.push(make_pair(K,0));
    color[K]=1;
    D[K]=0;
    while(T.size()){
        int a=T.top().first;
        long long int b=T.top().second;
        bool check=true;
        int i=now[a];
        for(;i<S[a].size();i++){
            int c=S[a][i].first;
            long long int d=S[a][i].second;
            if(color[c]==0){
                D[c]=b+d;
                color[c]=1;
                T.push(make_pair(c,D[c]));
                check=false;
                now[a]=i+1;
                break;
            }
        }
        if(check) T.pop();
    }
    return;
}

int main(){
   
    int N;cin>>N;
    for(int i=0;i<N-1;i++){
        int a,b;
        long long int c;
        cin>>a>>b>>c;
        a--;b--;
        S[a].push_back(make_pair(b,c));
        S[b].push_back(make_pair(a,c));
    }
    int Q;cin>>Q>>K;
    K--;
    
    DFS();
    for(int i=0;i<Q;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        cout<<D[a]+D[b]<<endl;
    }
}



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

int main() {
	char s[10000];
	string a;
	int n;
	cin >> n;
	cin >> a;
	for (int i = 0; i < a.length(); i++) {
		if (a[i] + n > 90)s[i] = a[i] + n - 26;
		else s[i] = a[i] + n;
	}
	for (int i = 0; i < a.length(); i++) cout << s[i];
	cout << endl;
}

Measured memory_bytes: 256