akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,a[500005],ans,z,sz[500005];
vector<ll>cm,s[500005];
int main(void){
	scanf("%lld",&n);
	cm.PB(0);
	for(int i=0;i<n;i++){
		scanf("%lld",a+i);
		if(i>0)a[i]=a[i-1]^a[i];
		if(a[i]==0)z++,sz[i]++;
		cm.PB(a[i]);
		if(i>0)sz[i]+=sz[i-1];
	}
	sort(cm.begin(),cm.end());
	cm.erase(unique(cm.begin(),cm.end()),cm.end());
	for(int i=0;i<n;i++){
		a[i]=lower_bound(cm.begin(),cm.end(),a[i])-cm.begin();
		s[a[i]].PB(i);
	}
	if(a[n-1]==0){
		ll tp=1;
		for(int i=0;i<z-1;i++)tp=tp*2LL%M;
		ans=(ans+tp)%M;
		for(int i=1;i<cm.size();i++){
			ll x=1,y=1;
			for(int j=1;j<s[i].size();j++){
				ll p=sz[s[i][j]]-sz[s[i][j-1]];
				y=(y+x*p)%M;
				x=(x+y)%M;
			}
			ans=(ans+x)%M;
		}
	}else{
		ll x=1,y=1;
		for(int j=1;j<s[a[n-1]].size();j++){
			ll p=sz[s[a[n-1]][j]]-sz[s[a[n-1]][j-1]];
			y=(y+x*p)%M;
			x=(x+y)%M;
		}
		ans=(ans+y)%M;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 34924
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
struct data{
    int a,b,c;
};

//降順
int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
#define MAXSIZE 200000
int list[MAXSIZE];
int tail;

void Init(void){
    tail=0;
}
int Top(void){
    return 0;
}

int Next(int pos){
    if(pos<tail-1){
        return pos+1;
    }else{
        return -1;
    }
}
int Count(void){
    return tail;
}

int Item(int pos){
    if((pos>=0)&&(pos<tail)){
        return list[pos];
    }else{
        return 0;
    }
}
void Add(int value){
    if(tail<MAXSIZE){
        list[tail]=value;
        tail++;
    }
}
void Delete(int pos){
    if((pos>=0)&&(pos<tail)){
        int i;
        for(i=pos;i<tail-1;i++){
            list[i]=list[i+1];
        }
        tail--;
    }
}

int main(){
    int K,N;
    scanf("%d%d",&K,&N);
    int pos[N];
    rep(i,N){
        scanf("%d",&pos[i]);
    }
    int min=0;
    rep(i,N-1){
        int sa=0;
        sa=pos[i+1]-pos[i];
        if(min<sa){
            min=sa;
        }else{
            ;
        }
    }
    if(((K-pos[N-1])+pos[0])>min){
        min=((K-pos[N-1])+pos[0]);
    }
    printf("%d",K-min);
}


Measured memory_bytes: 2488
import java.util.*

fun main(args: Array<String>) {
    val s = readNext().split(" ").map{
        Integer.parseInt(it)
    }
    val m = s.get(0)
    val d = s.get(1)
    if(d < 10) {
        println(0)
        return
    }
    var resultcount = 0
    for(i in 1..m) {
        if (i == 1) continue
        for(j in 20..d) {
            var d10 = j / 10
            var d1 = j % 10
            if (i == (d10 * d1) && d10 > 1 && d1 > 1){
                resultcount++
            }
        }
    }

    println(resultcount)
}

    fun readNext(): String {
        return readLine()!!
    }

Measured memory_bytes: 37920
#include <bits/stdc++.h>
using namespace std;
#define MAX_WORK_TIME 222222

struct Writer{
  int idx;
  int diff;
  int len;
};

int main(void){
  int n, m;
  while(cin >> n >> m, n | m){
    vector<Writer> writer;
    int tmp_min = MAX_WORK_TIME;
    for(int i = 0; i < n; i++){
      Writer tmp;
      tmp.idx = i+1;
      cin >> tmp.diff;
      int d = (m/tmp.diff)*tmp.diff;
      tmp.len = d;
      
      while(tmp.len - tmp.diff  > tmp_min){
	tmp.len -= tmp.diff;
      }
	
      writer.push_back(tmp);
      tmp_min = min(tmp_min, tmp.len);
    }
    /*
    for(int i = 0; i < n; i++){
      cout << writer[i].idx << " " << writer[i].diff << " " << writer[i].len << endl;
    }
    */

    int lenmin = MAX_WORK_TIME;
    for(int i = 0; i < writer.size(); i++){
      lenmin = min(lenmin, writer[i].len);
    }
    vector<Writer> possible_with_worktime;
    for(int i = 0; i < writer.size(); i++){
      if(writer[i].len == lenmin){
	possible_with_worktime.push_back(writer[i]);
      }
    }
    if(possible_with_worktime.size() == 1){
      cout << possible_with_worktime[0].idx << endl;
      continue;
    }

    int diffmin = MAX_WORK_TIME;
    for(int i = 0; i < possible_with_worktime.size(); i++){
      diffmin = min(diffmin, possible_with_worktime[i].diff);
    }
    vector<Writer> possible_with_difficulty;
    for(int i = 0; i < possible_with_worktime.size(); i++){
      if(possible_with_worktime[i].diff == diffmin){
	possible_with_difficulty.push_back(possible_with_worktime[i]);
      }
    }
    if(possible_with_difficulty.size() == 1){
      cout << possible_with_difficulty[0].idx << endl;
    }else{
      cout << n << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1244
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
#define N 610
bool vis[N][N]; int top,n;
void work(int dis)
{
	int rem=0; while(!(dis&3))	dis>>=2,rem++;
	if(dis&1)
	{
		for(int i=0;i<top;i++)	for(int j=0;j<top;j++)
			if((i>>rem)+(j>>rem)&1)	vis[i][j]=1;
	}
	else
	{
		for(int i=0;i<top;i++)	if(i>>rem&1)
			for(int j=0;j<top;j++)	vis[i][j]=1;
	}
}
int main()
{
	n=read(); int d1=read(),d2=read(); top=n<<1;
	work(d1); work(d2); int owo=0;
	for(int i=0;i<top;i++)	for(int j=0;j<top;j++)
	{
		if(!vis[i][j])	printf("%d %d\n",i,j),owo++;
		if(owo==n*n)	return 0;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>

#define SIZE 100001

int main(){
  int n;
  scanf("%d", &n);

  int s[SIZE];
  int sum = 0;
  for(int i=0; i<n; i++){
    scanf("%d", &s[i]);
    sum += s[i];
  }

  if(sum%10!=0){
    printf("%d\n", sum);
    return 0;
  }

  int sum2 = sum;
  int max = 0;
  for(int i=0; i<n; i++){
    sum = sum2;
    if(s[i]%10!=0){
      sum -= s[i];
    }
    if(sum%10==0)sum=0;
    if(max<sum) max = sum;
  }
  if(max!=0){
    printf("%d\n", max);
    return 0;
  }
  else{
    printf("%d\n", 0);
    return 0;
  }

  sum = sum2;
  
  
  /*
  while(1){
    int break_f = 1;
    for(int i=1; i<n; i++){
      if(s[i-1]<s[i]){
	int tmp = s[i-1];
	s[i-1] = s[i];
	s[i] = tmp;
	break_f = 0;
      }
    }
    if(break_f) break;
  }
  */
  /*
  int sel[SIZE] = {0};
  int ans;
  int loop = 0;
  while(1){
    int sum = 0;
    sel[0]++;
    int break_flag = 1;
    for(int i=0; i<n; i++){
      if(sel[i] == 2 && i<n-1){
	sel[i+1]++;
	sel[i] = 0;
      }
    }
    for(int i=0; i<n; i++){
      sum += sel[i]*s[i];
      if(sel[i]==0) break_flag=0;
      //      printf("%d ", sel[i]);
    }
    if(sum%10==0)sum=0;
    if(loop==0 || ans<sum) ans=sum;
    //    printf("sum=%d\n", sum);
    loop++;
    if(break_flag) break;
  }
  */
  


  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define ii pair<int, int>
#define int long long
using namespace std;

int row, col, s, t;
const int INF = 10000;
vector<int> ed[255];
int f[255][255];
int c[255][255];
int pre[255];
string str[105];
int ans = 0;

bool avail()
{
    for (int i = 1; i <= 241; i++) {
        pre[i] = -1;
    }

    pre[s] = s;
    queue<int> q;
    q.push(s);
    while(!q.empty())
    {
        int u = q.front(); q.pop();
        for (int i = 0; i < ed[u].size(); i++)
        {
            int v = ed[u][i];
            if (pre[v] == -1 && f[u][v] < c[u][v])
            {
                pre[v] = u;
                q.push(v);
            }
        }
    }
    return (pre[t] != -1);
}

void increase()
{
    int pos = t, mn = INF;
    while(pos != s)
    {
        mn = min(mn, c[pre[pos]][pos] - f[pre[pos]][pos]);
        pos = pre[pos];
    }

    pos = t; ans += mn;
    while (pos != s)
    {
        f[pre[pos]][pos] += mn;
        f[pos][pre[pos]] -= mn;
        pos = pre[pos];
    }
}

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

//    freopen("in.inp", "r", stdin);
//    freopen("out.out", "w", stdout);

    cin >> row >> col;

    s = 0; t = row + col + 1;

    for (int i = 1; i <= row; i++)
    {
        cin >> str[i];
        for (int j = 0; j < col; j++)
        {
            if (str[i][j] == 'S')
            {
                ed[0].push_back(i);
                ed[0].push_back(row + j + 1);
                c[0][i] = INF;
                c[0][row + j + 1] = INF;
            }
            if (str[i][j] == 'T')
            {
                ed[i].push_back(t);
                ed[row + j + 1].push_back(t);
                c[row + j + 1][t] = INF;
                c[i][t] = INF;
            }
            if (str[i][j] == 'o')
            {
                ed[i].push_back(row + j + 1);
                ed[row + j + 1].push_back(i);
                c[i][row + j + 1] = 1;
                c[row + j + 1][i] = 1;
            }
        }
    }

    while (avail())
        increase();

    if (ans >= INF)
        ans = -1;
    cout << ans << "\n";
}


Measured memory_bytes: 4700
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll N, D; cin >> N >> D;
    ll cnt = 0;
    rep(i, N){
        ll x, y; cin >> x >> y;
        if(x*x+y*y<=D*D) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3632
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = Console.ReadLine().Trim().Length;
            for (int p = 0; p < n; p++)
            {
                var fcond = 1; var lcount = 0; var startpoint = p; var found57577 = 0;
                for (int i = p; i < n; i++)
                {
                    switch (fcond)
                    {
                        case 1: 
                            if (lcount + a[i] < 5) lcount += a[i];
                            else if (lcount + a[i] == 5)
                            {
                                fcond++;
                                lcount = 0;
                            }
                            else { goto exit; }
                            break;
                        case 2:  
                            if (lcount + a[i] < 7) lcount += a[i];
                            else if (lcount + a[i] == 7)
                            {
                                fcond++;
                                lcount = 0;
                            }
                            else { goto exit; }
                            break;
                        case 3:  
                            if (lcount + a[i] < 5) lcount += a[i];
                            else if (lcount + a[i] == 5)
                            {
                                fcond++;
                                lcount = 0;
                            }
                            else { goto exit; }
                            break;
                        case 4:  
                            if (lcount + a[i] < 7) lcount += a[i];
                            else if (lcount + a[i] == 7)
                            {
                                fcond++;
                                lcount = 0;
                            }
                            else { goto exit; }
                            break;
                        case 5: 
                            if (lcount + a[i] < 7) lcount += a[i];
                            else if (lcount + a[i] == 7)
                            {
                                fcond++;
                                lcount = 0;
                                found57577 = 1;
                                goto exit;
                            }
                            else {  goto exit; }
                            break;
                    }
                }
                exit:;
                if (found57577 == 1)
                {
                    Console.WriteLine(startpoint + 1);
                    goto bigloopend;
                }
            }
            bigloopend:;
        }
    }
}

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

using namespace std;

typedef long long ll;

const ll MAXN = 111000;
const ll MAXK = 333;
ll dp[MAXK][MAXN];
ll arr[MAXN];

void solve(ll test_num) {
  (void) test_num;
  ll N, M, K;
  cin >> N >> M >> K;
  for (ll i = 1; i <= N; ++i) {
    cin >> arr[i];
  }
  memset(dp, 0xC0, sizeof(dp));
  for (ll j = 1; j <= N; ++j)
    dp[1][j] = arr[j];
  deque<ll> deq;
  for (ll i = 2; i <= K; ++i) {
    deq.clear();
    for (ll j = i, fr = 1; j <= N; ++j) {
      for (; fr < j; ++fr) {
        while (!deq.empty() && dp[i - 1][fr] >= dp[i - 1][deq.back()])
          deq.pop_back();
        deq.push_back(fr);
      }
      while (deq.front() < j - M)
        deq.pop_front();
      dp[i][j] = i * arr[j] + dp[i - 1][deq.front()];
    }
  }
  const ll res = *max_element(dp[K], dp[K] + N + 1);
  cout << res << endl;
}

void init() {

}

int main() {
#ifdef AZN
  const auto start_time = chrono::system_clock::now();
  freopen("/home/azneye/Documents/Stuff/input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  init();
  ll tests = 1;
  //cin >> tests;
  for (ll test = 1; test <= tests; ++test) {
    solve(test);
  }
#ifdef AZN
  cerr << "Took: " << ((chrono::system_clock::now() - start_time).count() / 1e9) << " s" << endl;
#endif
  return 0;
}

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

signed main(){
	int n,m;cin>>n>>m;
	vector<int>x(n);
	for(auto&& u:x)cin>>u;
	map<int,int>cnt,cntp,cntm;
	for(auto&& u:x){cnt[u]++;cntm[u%m]++;}
	for(auto&& u:cnt){cntp[u.first%m]+=u.second/2;}

	int ret=0;
	ret+=cntm[0]/2;
	if(m%2==0)ret+=cntm[m/2]/2;
	for(int i=1;i<=(m-1)/2;i++){
		int x=i,y=m-x;
		if(cntm[x]>cntm[y])swap(x,y);
		int nx=cntm[x],ny=cntm[y];
		ret+=nx;
		ret+=min((ny-nx)/2,cntp[y]);
	}
	cout<<ret<<endl;

}


Measured memory_bytes: 19840
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

int main(){
  vector<vector<int> > vec(100, vector<int>(100, 0));

  int h=0, w=0;
  int n=0;
  int d; char c;
  while(scanf("%d%c", &d, &c)!=EOF){
    vec[h][w]=d;
    if(c==',') w++;
    if(c=='\n'){
      n = max(n, w+1);
      h++;w=0;
    }
  }

  repl(i,1,n*2-1){
    if(i<n){
      vec[i][0] += vec[i-1][0];
      repl(j,1,i+1){
        vec[i][j] += max(vec[i-1][j-1], vec[i-1][j]);
      }
    } else {
      rep(j, 2*n-i-1){
        vec[i][j] += max(vec[i-1][j], vec[i-1][j+1]);
      }
    }
  }

  cout << vec[n*2-2][0] << endl;

  return 0;
}

Measured memory_bytes: 3204
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define range(x,l,r) (l<=x && x<r)
#define fs first
#define sc second
using namespace std;
typedef pair<int,int> pii;
typedef pair<pii,int> tri;

int w,h;
int g[20][20];
int rem[20][20];
vector<tri> carpet[20][20];
int depth;

void search(int d){
  if(d==depth)return;

  int y=-1, x=-1, mink = h*w;
  vector<tri> priority;
  rep(i,h)rep(j,w){
    if(rem[i][j] && mink > (int)carpet[i][j].size()){
      y = i; x = j;
    }
  }

  if(y<0){
    depth = d;
    return;
  }

  rep(k,carpet[y][x].size()){
    tri t = carpet[y][x][k];
    
    int tmp[20][20];
    for(int i=t.fs.fs;i<t.fs.fs+t.sc;i++){
      for(int j=t.fs.sc;j<t.fs.sc+t.sc;j++){
	tmp[i][j] = rem[i][j];
      }
    }

    for(int i=t.fs.fs;i<t.fs.fs+t.sc;i++){
      for(int j=t.fs.sc;j<t.fs.sc+t.sc;j++){
	rem[i][j] = 0;
      }
    }
    
    search(d+1);

    for(int i=t.fs.fs;i<t.fs.fs+t.sc;i++){
      for(int j=t.fs.sc;j<t.fs.sc+t.sc;j++){
	rem[i][j] = tmp[i][j];
      }
    }
    if(depth == d+1)return;
  }
}

int main(){
  while(cin >> w >> h, w){
    memset(g,0,sizeof(g));
    rep(i,h)rep(j,w){
      cin >> g[i][j];
      rem[i][j] = g[i][j];
      carpet[i][j].clear();
    }

    vector<tri> c;
    rep(i,h)rep(j,w){
      int k = 0;
      while(true){
	if(!range(i+k,0,h) || !range(j+k,0,w))break;
	int f = 1;
	for(int y=i;y<=i+k;y++)f &= g[y][j+k];
	for(int x=j;x<=j+k;x++)f &= g[i+k][x];
	if(!f)break;
	k++;
      }
      if(k)c.push_back( tri(pii(i,j), k) );
    }
    
    rep(i,c.size()){
      bool f = false;
      rep(j,c.size()){
	if(i==j)continue;
	if( range(c[i].fs.fs, c[j].fs.fs, c[j].fs.fs + c[j].sc) &&
	    range(c[i].fs.fs + c[i].sc, c[j].fs.fs, c[j].fs.fs + c[j].sc+1) &&
	    range(c[i].fs.sc, c[j].fs.sc, c[j].fs.sc + c[j].sc) &&
	    range(c[i].fs.sc + c[i].sc, c[j].fs.sc, c[j].fs.sc + c[j].sc+1) ){
	  f = true;
	  break;
	}
      }

      if(f){
	c.erase(c.begin()+i);
	i--;
      }
    }

    rep(i,c.size()){
      for(int y=c[i].fs.fs;y<c[i].fs.fs+c[i].sc;y++){
	for(int x=c[i].fs.sc;x<c[i].fs.sc+c[i].sc;x++){
	  carpet[y][x].push_back(c[i]);
	}
      }
    }

    int ans = 0;
    while(true){
      bool f = false;
      rep(i,h)rep(j,w){
	if(rem[i][j] && carpet[i][j].size()==1){
	  f = true;
	  ans++;
	  tri t = carpet[i][j][0];
	  for(int y=t.fs.fs;y<t.fs.fs+t.sc;y++){
	    for(int x=t.fs.sc;x<t.fs.sc+t.sc;x++){
	      rem[y][x] = 0;
	    }
	  }
	}
      }
      if(!f)break;
    }

    depth = h*w;
    search(0);
    
    cout << ans + depth  << endl;
  }
}

Measured memory_bytes: 1252
#include<iostream>
#include<set>

using namespace std;

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

	set<char> s;
	for (size_t i = 0; i < N; i++)
	{
		char c;
		cin >> c;
		s.insert(c);
	}

	if (s.size() == 3)
		cout << "Three" << endl;
	else	
		cout << "Four" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int main()
{   long long n;
    scanf("%lld",&n);
    long long ans=1000100010001001;
    long long num1,num2;
    for(long long i=1;i*i<=n+1;i++){
        if(n%i==0&&llabs(n/i-i)<ans){
            ans=llabs(n/i-i);
            num1=i;
            num2=n/i;
        }
    }
    printf("%lld",num1-1+num2-1);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string.h>
#include <queue>
#include <string>
#include <stack>
#include <utility>
#include <queue>
#include <cmath>
#define mp make_pair
#define pii pair<int,int> 
#define ff first
#define ss second
#define ll long long 
#define vi vector<int>

using namespace std;

int counts[1000];
char str[1000][100];
int maxl,i,indexml,indexma;

int main()
{
	maxl=0;
	indexml=0;
	indexma=0;
	i=0;
	memset(counts, 0, sizeof(counts));
	while(scanf("%s",str[i])!=EOF)
	{
		//if(str[i][0]=='z')break;
		if(maxl<strlen(str[i]))
		{
			maxl=strlen(str[i]);
			indexml=i;
		}
		for(int z=0;z<i;z++)
		{
			if(strcmp(str[i],str[z])==0)
			{
				counts[z]++;
				i--;
				break;
			}
		}
		i++;
	}
	for(int c=0;c<i;c++)
	{
		if(counts[indexma]<counts[c])
		indexma=c;
	}
	printf("%s %s\n",str[indexma],str[indexml]);
	return 0;
}

Measured memory_bytes: 1152
N = int(input())
L = [int(input()) for i in range(N)]
L = [0]+L
L = sorted(L)

p = sum(L)

flag = 0
while flag == 0 :
    counter = 0
    for i in range(len(L)) :
        q = p - L[i]
        if q % 10 != 0 :
            ans = q
            flag = 1
            break
        else :
            counter += 1
            if counter == len(L) :
                ans = 0
                flag = 1
                break
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    vector<vector<int>> s(h, vector<int>(w));
    rep(i,h){
        int num;
        if (i < b) num = 0;
        else num = 1;
        rep(j,w){
            if (j < a) s[i][j] = num;
            else s[i][j] = !num;
        }
    }

    rep(i,h){
        rep(j,w) cout << s[i][j];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 7448
var r;
var n;
var x = [];
var e = [];

function fill(a, b, h){
	a += 20;
	b += 20;
	x[a][0] += 1;
	x[a][h] -= 1;
	x[b][0] -= 1;
	x[b][h] += 1;
}

function integrate(){
	rep(40, function(i){
		rep(19, function(j){
			x[i][j + 1] += x[i][j];
		});
	});
	rep(39, function(i){
		rep(20, function(j){
			x[i + 1][j] += x[i][j];
		});
	});
}

function access(i, j){
	return x[i + 20][j];
}

function calc_edge(){
	e[0] = Infinity;
	rep(20, function(i){
		var a = 0;
		rep(20, function(j){
			if(access(-j - 1, i)){
				++a;
			}
			else{
				return false;
			}
		});

		var b = 0;
		rep(20, function(j){
			if(access(j, i)){
				++b;
			}
			else{
				return false;
			}
		});

		var c = Math.min(a, b);
		e[i + 1] = c;
		e[i] = Math.min(c, e[i]);
	});
}

function judge(h){
	var b = true;
	rep(21, function(i){
		var dh = Math.abs(i - h);
		var lim = r * r - dh * dh;
		if(lim < 0){
			return;
		}
		lim = Math.sqrt(lim);
		if(lim > e[i]){
			b = false;
			return false;
		}
	});
	return b;
}

function main(){
	while(r = scan()){
		rep(41, function(i){
			x[i] = [];
			rep(21, function(j){
				x[i][j] = 0;
			});
		});

		n = scan();
		rep(n, function(){
			var a = scan();
			var b = scan();
			var h = scan();
			fill(a, b, h);
		});
		integrate();

		calc_edge();
		
		var a = 0, b = 20;
		while(b - a > 1e-4){
			var c = (a + b) / 2;
			if(judge(c - r)){
				a = c;
			}
			else{
				b = c;
			}
		}
		print(a);
	}
}

function rep(a, b, c, u){
	if(c === u){
		c = b;
		b = a;
		a = 0;
	}
	for(var i = a; i < b; ++i){
		if(c(i) === false){
			break;
		}
	}
}

var input = '';

function scan(){
	return +input.pop();
}
function scan_string(){
	return input.pop();
} 
function print(val){
	console.log(val);
}
 
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk){
	input += chunk;
});
process.stdin.on('end', function(){
	input = input.trim().split(/\s+/).reverse();
	main();
});

Measured memory_bytes: 20460
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
    string s,t;cin>>s>>t;
     ll n =  s.size();
    unordered_map<char,vector<ll> > sf;
    for(int i = 0; i < n; i++)   sf[s[i]].push_back(i);
    unordered_map<int,ll> cnt, ccnt;
    for(int i = 0; i < n; i++)  cnt[s[i]]++, ccnt[s[i]]++;
    for(auto ch:t){
        if(sf.find(ch) == sf.end()){
            cout<<"-1\n"; return 0;
        }
    }


    ll ans = 0;
    ll prev = -1;
    ll tn = t.size();
    for(int i = 0; i < tn; i++)
    {
        ll nc =  ccnt[t[i]];
        // ll idx = sf[t[i]][nc-cnt[t[i]]];
        // cnt[t[i]]--;
        // bool f = 0;
        // if(cnt[t[i]] == 0){
        //     f = 1;
        //     cnt[t[i]] = ccnt[t[i]];
        // }
        // cout<<t[i]<<" "<<prev<<",";
        if(prev == -1)
        {
            // cout<<sf[t[i]][0]<<"\n";
            ans += sf[t[i]][0];
            prev = sf[t[i]][0];
        }
        else{
            auto it = upper_bound(sf[t[i]].begin(), sf[t[i]].end(), prev);
            if(it == sf[t[i]].end())
            {
                
                ans+= (n-prev+sf[t[i]][0]);
                prev = sf[t[i]][0];
            }
            else{
                // cout<<*it<<"\n";
                ans += *it-prev;
                prev = *it;
            }
        }
        
        // if(prev == -1)
        //     ans += idx, prev = idx;
        // else if(prev < idx)
        //     ans += idx-prev, prev= idx;
        // else if(prev > idx)
        //     ans += n-prev+idx, prev = idx;
    }

    cout<<ans+1<<"\n";
    return 0;
}


Measured memory_bytes: 1724
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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


int main(){
    string s;
    cin >> s;
    if(s.size() == 2){
        if(s[0] == s[1]){
            cout << 1 << " " << 2 << endl;
            return 0;
        }
    }

    rep(i, 26){
        int num = 0;
        if(s[0] - 'a' == i) num++;
        if(s[1] - 'a' == i) num++;
        for (int j = 2; j < s.size(); j++){
            if(s[j] - 'a' == i) num++;
            if(num >= 2){
                cout << j - 1 << " " << j + 1 << endl;
                return 0;
            }
            if(s[j-2] - 'a' == i) num--;
        }
    }
    cout << -1 << " " << -1 << endl;

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

bool is_prime[1000010];

int main() {
    int n,now = 1000;
    cin >> n;
    while(1){
        if(now < n) now += 1000;
        else{
            cout << now-n << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define int lint
typedef long long lint;
typedef pair<int,int> P;
const int    INF=(1<<31)-1;
const int    MOD=(int)1e9+7;
const double EPS=(double)1e-10;
struct Accelerate_Cin{
    Accelerate_Cin(){
        cin.tie(0);ios::sync_with_stdio(0);cout<<fixed<<setprecision(20);
    };
};

//前処理Ｏ(n)
//クエリ処理Ｏ(log n)
//与えられた区間内の「最小値」を求める。

const int MAX_N=(1<<17);

int n,dat[2*MAX_N-1];

//初期化
void init(int n_){
  n=1;
  while(n<n_)n*=2;
  for(int i=0;i<2*n-1;i++)dat[i]=INF;
}

//k番目の値（０-indexed）をaに変更。
void update(int k,int a){
  //葉の節点
  k+=n-1;
  dat[k]=a;
  //根に向かって登りながら更新。
  while(k>0){
    k=(k-1)/2;
    dat[k]=min(dat[2*k+1],dat[2*k+2]);
  }
}

//[a,b)の最小値を求める。
//kは節点番号。ｌ、ｒは節点kに対応する区間[l,r)を表す。
//呼び出し方：query(a,b,0,0,n);
int query(int a,int b,int k,int l,int r){
  //[a,b)と[l,r)が交差しないとき。解に影響がない値ＩＮＦを返す。
  if(r<=a||b<=l)return INF;

  //[a,b)の中に[l,r)が完全に含まれているとき。節点kの値を返す。
  if(a<=l&&r<=b)return dat[k];
  else{
    //交差はするが、完全には含まれていないとき。二つの子の最小値を再帰で求める。
    int vl=query(a,b,2*k+1,l,(l+r)/2);
    int vr=query(a,b,2*k+2,(l+r)/2,r);
    return min(vl,vr);
  }
}


signed main(){
  int q;cin>>n>>q;
  init(n);
  queue<int>que;
  for(int i=0;i<q;i++){
    int com,x,y;cin>>com>>x>>y;
    if(com==0){
      update(x,y);
    }else if(com==1){
      que.push(query(x,y+1,0,0,n));
    }
  }
  while(!que.empty()){
    cout<<que.front()<<endl;
    que.pop();
  }
  return 0;
}



Measured memory_bytes: 5456
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <numeric>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
string a, b;
/**********************************************/

int main(){
    cin >> a >> b;
    
    int num = stoi(a + b);
    int heihou = sqrt(num);
    if(heihou * heihou == num){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
vector<vector<int>> g;
vector<bool> vis;
int n, m, x, y, res(-1);
inline void DFS(const int& x) {
    vis[x] = true;
    for (const int& y : g[x])
        if (!vis[y])
            DFS(y);
}
int main() {
    DAU
    cin >> n >> m;
    g.resize(n + 1);
    while (m--) {
        cin >> x >> y;
        g[x].emplace_back(y);
        g[y].emplace_back(x);
    }
    vis.resize(n + 1);
    for (int i = 1; i <= n; ++i)
        if (!vis[i])
            ++res, DFS(i);
    cout << res;
    PLEC
}


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

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

  if( a < b )cout<<"a < b"<<endl;
  if( a > b )cout<<"a > b"<<endl;
  if( a ==b )cout<<"a == b"<<endl;
  return 0;
}



Measured memory_bytes: 3080
/*  
     author : hursh29    
     g++ : 17.3.20 
*/        
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << "\n"
#define speedup            ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x) 			   cout << x << "\n" ; 
#define MOD                998244353
#define pi                 pair<ll,ll>
#define vi                 vector <ll>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             x.begin(),x.end() 
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set; 
const int N = 2e5+7; 
/*   
    time : 17 : 28      
    date : 20.12.2019
*/    
int n ; 
ll A,B ,g;  
int solve(){ 
	cin >> A >> B ; 
	g = __gcd(A,B) ; 
    A *= B ; 
    A /= g ; 
    cout << A ; 
    return 0 ; 
}
int main() { 
	speedup ;  
    int test  = 1 ; 
	//cin >> test  ; 
	while(test--)
    	solve() ; 
	 
	return 0;
} 


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    k = int(input())
    X = list(map(int, input().split()))

    res = 0
    for i in range(n):
        res += min(X[i] * 2, abs(k - X[i]) * 2)

    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 38640
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
   int t,n,s,f;
   int ch;
   while(cin>>t,t){
       ch=0;
       cin>>n;
       for(int i=0;i<n;i++){
           cin>>s>>f;
            ch+=(f-s);
       }
       if(ch>=t) cout<<"OK"<<endl;
       else cout<<t-ch<<endl;
   }
    return 0;
}


Measured memory_bytes: 5428
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX;
const long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll P = 1e9 + 7;
	//const ll P = 998244353;

	ll x;
	cin >> x;
	if (x < 600) cout << 8 << endl;
	else if (x < 800) cout << 7 << endl;
	else if (x < 1000) cout << 6 << endl;
	else if (x < 1200) cout << 5 << endl;
	else if (x < 1400) cout << 4 << endl;
	else if (x < 1600) cout << 3 << endl;
	else if (x < 1800) cout << 2 << endl;
	else cout << 1 << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int x,y;
int main(){
	scanf("%d%d",&x,&y);
	if (abs(x)<abs(y)){
		int ans=0;
		if (x<0) ans++;
		if (y<0) ans++;
		ans+=(abs(y)-abs(x));
		cout<<ans<<endl;
	} else if (abs(x)>abs(y)){
		int ans=0;
		if (x>0) ans++;
		if (y>0) ans++;
		ans+=(abs(x)-abs(y));
		cout<<ans<<endl;
	} else cout<<1<<endl;
	return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())

A = list()
for i in range(N):
    a,b = map(int,input().split())
    A.append([a,b])

A.sort()
ans = 0
for i in range(N):
    if M>A[i][1]:
        ans += A[i][0]*A[i][1]
        M -= A[i][1]
    else:
        ans += A[i][0]*M
        break
print(ans)


Measured memory_bytes: 20048
//  Created by Sengxian on 2017/6/18.
//  Copyright (c) 2017年 Sengxian. All rights reserved.
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
inline int readInt() {
	int n = 0, ch = getchar();
	while (!isdigit(ch)) ch = getchar();
	while (isdigit(ch)) n = n * 10 + ch - '0', ch = getchar();
	return n;
}

const int MAX_N = 500 + 3, MAX_M = 500 + 3, S = 5000;
int n, m, a, b;
int mat[MAX_N][MAX_M];
int main() {
	n = readInt(), m = readInt(), a = readInt(), b = readInt();
	if (n == 1 && m == 1) printf("No");
	else if (m % b) {
		puts("Yes");
		for (int i = 0; i < n; ++i)
			for (int j = 0; j < m; ++j)
				if (j % b == b - 1) mat[i][j] = -5000 * (b - 1) - 1;
				else mat[i][j] = 5000;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j)
				printf("%d ", mat[i][j]);
			putchar('\n');
		}
	} else if (n % a) {
		puts("Yes");
		for (int j = 0; j < m; ++j)
			for (int i = 0; i < n; ++i)
				if (i % a == a - 1) mat[i][j] = -5000 * (a - 1) - 1;
				else mat[i][j] = 5000;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j)
				printf("%d ", mat[i][j]);
			putchar('\n');
		}
	} else {
		puts("No");
	}
	return 0;
}


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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

// uniform_int_distribution<int>
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int v[100005], l[100005], r[100005];

int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}

int main() {
	int n;

	scanf("%d", &n);

	for(int i = 1; i <= n; i++)
		scanf("%d", &v[i]);

	int ans = 0;
	for(int i = 1; i <= n; i++)
		l[i] = gcd(l[i-1], v[i]);

	for(int i = n; i; i--)
		r[i] = gcd(r[i+1], v[i]);

	for(int i = 1; i <= n; i++) {
		if(i == 1) ans = max(ans, r[2]);
		else if(i == n) ans = max(ans, l[n-1]);
		else ans = max(ans, gcd(l[i-1], r[i+1]));
	}

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

    return 0;
}

Measured memory_bytes: 1408
//by shubham_bitsg

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector <string> vs;

//#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define forl(i,a,b) for (int i = a; i < b; i++)
#define rfor(i,b,a) for (int i = b; i >= a; i--)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define srt(x) sort(x.begin(), x.end())
#define sumup(x) accumulate(x.begin(), x.end(), 0)
#define PI 3.141592653589793238
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a; cin>>a;
    int b = a*a;
    int c = a*a*a;
    int d = a + b + c;
    cout<<d<<"\n";
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    string S;
    cin >> S;
    cout << S[0] << S[1] << S[2] << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3652
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static string S;
        static void Main(string[] args)
        {
            //N = long.Parse(Console.ReadLine());
            //var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            S = Console.ReadLine();
            long ans = S.Length;
            for (char moji = 'a'; moji <= 'z'; ++moji)
            {
                ans = Min(ans,Cul(moji));
            }
            Console.WriteLine(ans);
        }
       
        static long Cul(char spi)
        {
            var tmp = S.Split(spi).ToArray();
            long ans = 0;
            foreach (var item in tmp)
            {
                ans = Max(ans, item.Length);
            }
            return ans;
        }
    }


}


Measured memory_bytes: 26436
from sys import stdin
input = stdin.readline

N, M, X = map(int, input().split())
pricelist = [0] * N
matrix = [[0] * M for _ in range(N)]
for i in range(N):
    row = list(map(int, input().split()))
    pricelist[i] = row.pop(0)
    matrix[i] = row

mintotalprice = 10**5 * 12 + 1
for bit in range(2**N):
    flag = True
    for j in range(M):
        totalscore = 0
        for i in range(N):
            if (bit>>i & 1) == 1:
                totalscore += matrix[i][j]
        if totalscore < X:
            flag = False
            break
    if flag:
        totalprice = 0
        for i in range(N):
            if (bit>>i & 1) == 1:
                totalprice += pricelist[i]
        mintotalprice = totalprice if mintotalprice > totalprice else mintotalprice
        
print(mintotalprice if mintotalprice != 10**5 * 12 + 1 else -1)

Measured memory_bytes: 9260
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>

using namespace std;

template <class T>
using vc = vector<T>;

using vi = vector<int>;

int main() {
    cout << setprecision(20) << fixed;
    int n;
    cin >> n;

    auto a = vi(n);

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

    for (auto i = n-1; i > 0; --i) {
        cout << a[i] << " ";
    }
    cout << a[0] << "\n";
    return 0;
}



Measured memory_bytes: 3072
void main(){
	long x, t;
	scanf("%ld %ld", &x, &t);
	(x-t>0?x-t:0).writeln();
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2500
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <cmath>
#include <bitset>
#include <cassert>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <fstream>

using namespace std;
typedef long long ll;
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main()
{
    fast_io;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    string str;
    cin >> n >> str;

    int x = 0, y = 0, c = 0;
    for (int i = 0; i < n; i++)
    {
        if (str[i] == 'W')
            y++;
        else
            x++;
    }

    int res = min(x, y);

    for (int i = 0; i < x; i++)
    {
        if (str[i] == 'W')
            c++;
    }

    res = min(res, c);
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3348
program main
  implicit none

  character(len=100000) :: s, s1 , s2
  integer :: n, i, ans1, ans2
  

  read(*,*) s
  s1 = s
  s2 = s
  n = len_trim(s)

  ans1 = 0
  ans2 = 0
  do i = 2, n
     if(s1(i:i) == s1(i-1:i-1)) then
        select case(s1(i:i))
        case('0')
           s1(i:i) = '1'
        case('1')
           s1(i:i) = '0'
        end select
        ans1 = ans1 + 1
     end if

  end do

  do i = 1, n-1
     if(s2(n-i:n-i) == s2(n-i+1:n-i+1)) then
        select case(s2(n-i:n-i))
        case('0')
           s2(n-i:n-i) = '1'
        case('1')
           s2(n-i:n-i) = '0'
        end select
        ans2 = ans2 + 1
     end if
  end do
  
  write(*,*) min(ans1, ans2)

end program main

  


Measured memory_bytes: 3352
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  bool fl=false;
  for(auto &a:A){
    cin>>a;
    if(a==0)fl=true;
  }
  ll ans=0;
  if(fl){
    for(int i=0;i<n;i++){
      ans+=abs(A[i]);
    }
  }else{
    ll minus=0;
    bool flfl=false;
    for(int i=0;i<n;i++){
      if(A[i]<0)minus++;

    }
    if(minus%2)flfl=true;
    if(flfl){
      for(int i=0;i<n;i++)A[i]=abs(A[i]);
      sort(ALL(A));
      for(int i=1;i<n;i++)
	ans+=abs(A[i]);
      ans-=A[0];
    }else{
      for(int i=0;i<n;i++)
	ans+=abs(A[i]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
(* unihernandez22
 * https://atcoder.jp/contests/abc126/tasks/abc126_c
 * math
 * *)

let log2 n = log n /. log 2.;;

Printf.printf "%.15f\n" @@
Scanf.scanf "%f %f\n" @@ fun n k ->
    let ans = ref 0.0 in
    for dice = 1 to int_of_float n do
        let steps = ceil @@ log2 (k /. (float_of_int dice)) in
        let prob = ref (1.0 /. n) in
        if float_of_int dice < k then
            prob := !prob *. (Float.pow (1.0 /. 2.0) steps);
        ans := !ans +. !prob;
    done;
    !ans;;


Measured memory_bytes: 6424
#include<iostream>
#define MOD 1000000007

using namespace std;

int Fact[1000005],P3[1000005],Inv[1000005],Dp[1000005];

int put(int a, int b)
{
    int rez=1;
    for(int i=0; (1<<i)<=b; i++)
    {
        if((1<<i)&b)
            rez=(1LL*rez*a)%MOD;
        a=(1LL*a*a)%MOD;
    }
    return rez;
}

int comb(int n, int k)
{
    if(k>n)
        return 0;

    int rez=(1LL*Fact[n]*Inv[k])%MOD;
    rez=(1LL*rez*Inv[n-k])%MOD;
    return rez;
}

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

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

    Fact[0]=1;
    P3[0]=1;
    for(int i=1; i<=n+m+k+1; i++)
    {
        Fact[i]=(1LL*Fact[i-1]*i)%MOD;
        P3[i]=(3LL*P3[i-1])%MOD;
    }

    Inv[n+m+k+1]=put(Fact[n+m+k+1],MOD-2);
    for(int i=n+m+k; i>=0; i--)
        Inv[i]=(1LL*Inv[i+1]*(i+1))%MOD;

    Dp[0]=1;
    for(int i=1; i<=m+k; i++)  //nr de moduri de a pune B si C a.i. sa nu castige nici b nici c
    {
        Dp[i]=(Dp[i-1]-comb(i-1,m)+MOD)%MOD; //pun pe poz i B
        Dp[i]=(1LL*Dp[i]+Dp[i-1]-comb(i-1,k)+MOD)%MOD; //pun pe poz i C
    }

    int rez=0;
    for(int i=n+1; i<=n+m+k+1; i++)
    {
        int val=comb(i-2,n-1); //prima si ultima val e a
        val=(1LL*val*P3[n+m+k+1-i])%MOD;
        val=(1LL*val*Dp[i-n-1])%MOD;
        rez=(rez+val)%MOD;
    }
    cout<<rez<<"\n";
    return 0;
}


Measured memory_bytes: 15488