akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cassert>

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

using namespace std;

int plen,cnum,width,cspace;

void compute()
{
  char text[plen][cnum*width+(cnum-1)*cspace];  
  string line;
  int x,y,r;
  x = y = r = 0;
  rep(i,plen)rep(j,cnum*width+(cnum-1)*cspace)text[i][j] = '.';
  cin.ignore();
  bool printed = false;
  bool update = false;
  while(true)
    {

      getline(cin,line);
      if(line == "?")break;
      update = true;
      if(printed)printed = false;
      //cout << "line : " << line << endl;

      if(line == "")
	{
	  x = 0;
	  y++;
	  if(y >= plen)
	    {
	      y = 0;
	      r++;
	    }
	  if(r >= cnum)
	    {
	      printed = true;
	      x = y = r = 0;
	      rep(j,plen)
		{
		  rep(k,width*cnum+cspace*(cnum-1))
		    {
		      cout << text[j][k];
		    }
		  cout << endl;
		}
	      cout << "#" << endl;

	      rep(j,plen)rep(k,width*cnum+(cnum-1)*cspace)text[j][k] = '.';
	    }
	  continue;
	}
      rep(i,line.size())
	{

	  if(x >= width)
	    {
	      x = 0;
	      y++;
	    }
	  if(y >= plen)
	    {
	      y = 0;
	      r++;
	    }
	  if(r >= cnum)
	    {
	      printed = true;
	      x = y = r = 0;
	      rep(j,plen)
		{
		  rep(k,width*cnum+cspace*(cnum-1))
		    {
		      cout << text[j][k];
		    }
		  cout << endl;
		}
	      rep(j,plen)rep(k,width*cnum+(cnum-1)*cspace)text[j][k] = '.';
	      cout << "#" << endl;
	    }

	  text[y][x+r*(width+cspace)] = line[i];
	  x++;
	  printed = false;

	}
      x = 0;
      y++;
      if(y >= plen)
	{
	  y = 0;
	  r++;
	}
      if(r >= cnum)
	{
	  printed = true;
	      x = y = r = 0;
	      rep(j,plen)
		{
		  rep(k,width*cnum+(cnum-1)*cspace)
		    {
		      cout << text[j][k];
		    }
		  cout << endl;
		}
	      cout << "#" << endl;
	      rep(j,plen)rep(k,width*cnum+(cnum-1)*cspace)text[j][k] = '.';
	}
      // cout << "x,y,r = " << x << "," << y << "," << r<< endl;
    }
  // cout << "printed ? " << printed << endl;
  if(!update)printed =true;
  if(!printed)
    {
      rep(j,plen)
		{
		  rep(k,width*cnum+cspace*(cnum-1))
		    {
		      cout << text[j][k];
		    }
		  cout << endl;
		}
	      cout << "#" << endl;
	      rep(j,plen)rep(k,width*cnum+cspace*(cnum-1))text[j][k] = '.';
    }
  cout << "?" << endl;
}

int main()
{
  while(cin >> plen,plen)
    {
      cin >> cnum >> width >> cspace;
      compute();
    }
  return 0;
}

Measured memory_bytes: 1208
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b,c = readInts()
print(min(c, b//a))


Measured memory_bytes: 10204
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, A, B, C = MAP()

l = [INT() for _ in range(N)]

ans = INF
for x in product(range(4), repeat=N):
	tmp = 0
	bamboo = [0]*4 #[不使用、Aに使用、Bに使用、Cに使用]
	for i in range(N):
		if 0 < x[i] and bamboo[x[i]]:
			tmp += 10
		bamboo[x[i]] += l[i]

	if 0 in bamboo[1:]:
		continue

	tmp += abs(bamboo[1]-A) + abs(bamboo[2]-B) + abs(bamboo[3]-C)

	ans = min(ans, tmp)

print(ans)



Measured memory_bytes: 10396
s = input()
s1 = s[:(len(s)-1) // 2]
s2 = s[(len(s)+3) // 2 - 1:]
if s1 == s1[::-1] and s1 == s2[::-1] and s2 == s2[::-1]:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9092
#include <iostream>

int main() {
  int32_t a, b, c;
  std::cin >> a >> b >> c;

  int32_t k;
  std::cin >> k;

  if (a < b && b < c) {
    std::cout << "Yes" << std::endl;
    return 0;
  }

  for (int32_t i = 0; i < k; ++i) {
    if (b <= a) {
      b *= 2;
    } else if (c <= b) {
      c *= 2;
    }
  }

  if (a < b && b < c) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define rep(a,b) for(int a=0;a<b;a++)
#define int long long int

using namespace std;

const int INF = 1000000009;

int day,al;
int almost[200];
int ans=1;
int used[200];

int pasu(int p){
    if(p==3)return 1;
    else if(p==2)return 3;
    else if(p==1)return 2;
}

int pasu2(int p){
    if(p==3)return 2;
    else if(p==2)return 1;
    else if(p==1)return 3;
}

int kaburi1(int date){
    if(almost[date+1]!=0){
        return almost[date+1];
    }else return 0;
}

int kaburi2(int date){
    if(almost[date+2]!=0){
        return almost[date+2];
    }else return 0;
}

int memo[200][200][200];

int pasuta(int d2, int d1, int date){
    if(date>day)return 1;
    else if(memo[d2][d1][date]>0)return memo[d2][d1][date];
    else if(almost[date]>0){
            ///?±??????£?????????
            if(d2==d1&&d1==almost[date])return 0;
        else return pasuta(d1,almost[date],date+1)%10000;
    }/*else if(d2==d1&&d1!=0){
        ///?????\??¨?????????????????¨???
       return memo[d2][d1][date]=(pasuta(d1,pasu(d1),date+1)+pasuta(d1,pasu2(d1),date+1))%10000;
    }else if(d1==dd1&&d1!=0){
        ///?????\??¨?????????????????¨???
       return memo[d2][d1][date]=(pasuta(d1,pasu(d1),date+1)+pasuta(d1,pasu2(d1),date+1))%10000;
    }else if(dd1==dd2&&dd1!=0){
        ///?????¨?????¨?????????
       return memo[d2][d1][date]=(pasuta(dd1,dd2,date+3)+pasuta(dd1,dd2,date+3))%10000;
    }*/else{
    int an=0;
    for(int i=1;i<=3;i++){
        if(d1==d2&&d1==i)continue;
        an+=pasuta(d1,i,date+1);
    }
    return memo[d2][d1][date]=an%10000;
    }
}

signed main(){
    fill(almost,almost+200,0);
    fill(used,used+200,0);
    cin >> day >> al;
    rep(a,al){
        int da,pa;
        cin >> da >> pa;
        almost[da]=pa;
    }
    ans = pasuta(0,0,1);
    cout << ans%10000 << endl;
return 0;
}

Measured memory_bytes: 1200
I = [input() for i in range(2)]
sn = int(I[0])
ss = str(I[1])
if sn%2 == 1 :
    A = 'No' 
else:
    sl = int(sn/2) 
    # print(sl)
    if sl >= 2 : 
        H1 = ss[:sl]
        H2 = ss[sl:]
    #     print(H1)
    #     print(H2)
    elif sl == 1 :
        H1 = str(ss[0])
        H2 = str(ss[1])
    if  H1 == H2 :
        A = 'Yes'
    else:
        A = 'No'
print(A)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    
		String x = "";
		try {
			x = in.readLine();
			int num = Integer.parseInt(x);
			
			x = in.readLine();
			String[] num_s = x.split(" ");
			
			for (int i = 1; i < num; i++) {
				System.out.print(num_s[num - i] + " ");
			}
			System.out.println(num_s[0]);
		} catch (NumberFormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24220
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==
*/

f(X, [Y|Ys]) :- X = Y.

main :-
    get_chars(S1),
    get_chars(S2),
    get_chars(S3),
    f(X, S1),
    f(Y, S2),
    f(Z, S3),
    W = [X, Y, Z],
    string_chars(S, W),
    writeln(S).


Measured memory_bytes: 8032
//I love Nanami Chiaki
#include<bits/stdc++.h>
using namespace std;
const int maxn=5007;
const int mod=1e9+7;
struct Edge{int nxt,to;}G[maxn<<1];
int bG=0,hG[maxn],sz[maxn],dp[maxn][maxn][2],ans=0,n,fac[maxn];  //dp_i_j_k:子树i中,有j个点还没有匹配,一定没经过的边数量%2=k的方案数 
inline void add(int x,int y){G[bG].nxt=hG[x];G[bG].to=y;hG[x]=bG++;G[bG].nxt=hG[y];G[bG].to=x;hG[y]=bG++;}
inline void Add(int &x,int y){x+=y;if (x>=mod) x-=mod;}
void solveit(int v,int p){
	sz[v]=1;dp[v][1][0]=1;
	for (int i=hG[v];i!=-1;i=G[i].nxt){
		int u=G[i].to;if (u==p) continue;solveit(u,v);
		for (int szv=sz[v];szv>0;szv--){
			int cnt[2]={dp[v][szv][0],dp[v][szv][1]};
			dp[v][szv][0]=0;dp[v][szv][1]=0;
			for (int e1=0;e1<=1;e1++){
				if (!cnt[e1]) continue;
				for (int szu=1;szu<=sz[u];szu++){
					for (int e2=0;e2<=1;e2++){
						if (!dp[u][szu][e2]) continue;
						int nsz=szv+szu,ne=(e1+e2)%2;
						Add(dp[v][nsz][ne],1ll*cnt[e1]*dp[u][szu][e2]%mod);
						if (!(szu%2)) Add(dp[v][szv][ne^1],1ll*cnt[e1]*dp[u][szu][e2]%mod*fac[szu]%mod);
					}
				}
			}
		}
		sz[v]+=sz[u];
	}
}
int main(){
	scanf("%d",&n);memset(hG,-1,sizeof(hG));
	for (int i=0;i<n-1;i++){int x,y;scanf("%d%d",&x,&y);x--;y--;add(x,y);}
	fac[0]=1;for (int i=2;i<=n;i+=2) fac[i]=1ll*fac[i-2]*(i-1)%mod;
	solveit(0,-1);
	for (int i=0;i<=sz[0];i+=2){Add(ans,1ll*dp[0][i][0]*fac[i]%mod);Add(ans,mod-1ll*dp[0][i][1]*fac[i]%mod);}
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 195072
#include<bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define all(v) v.begin(),v.end()
#define mem(v,x) memset(v,x,sizeof(v))
#define N 200005

using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++){
        cin>>a[i];
	}
	int dp[n+1]={0};
	for(int i=1;i<n;i++){
        dp[i+1] = abs(a[i]-a[i-1])+dp[i];
        for(int j=i-2;j>=0 && i-j<=k;j--){
            dp[i+1] = min(dp[i+1], abs(a[i]-a[j])+dp[j+1]);
        }
	}
	cout<<dp[n];
	return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
h = list(map(int, input().split()))
s = set()
for i in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if h[a] > h[b]:
        s.add(b)
    elif h[b] > h[a]:
        s.add(a)
    else:
        s.add(a)
        s.add(b)
print(n-len(s))

Measured memory_bytes: 20144
#include <stdio.h>

int main(){
	int a;
	int b;
	scanf("%d %d",&a,&b);
	int d = a / b;
	int r = a % b;
	double fa = a;
	double fb = b;
	double f = fa / fb;
	if(a>=1&&b>=1&&a<=1000000000&&b<=1000000000){
		printf("%d",d);
		printf(" %d",r);
		printf(" %f\n",f);
	}
	return 0;
}


Measured memory_bytes: 2724
n,k = map(int,input().split())
s = [0] * n
sum = 0
if n >= k:
  #k~nのn+1個は0回
  #k//2+1~k-1のk-k//2-1個は1回
  sum += (n-k+1)/n
  b = k-1
  for i in range(1,18):
    a = b
    if k//2**i==k/2**i:
      b = k//2**i-1
    else:
      b = k//2**i
    for l in range(b,a):
      s[l] = i
    sum += (a-b)/(n*2**i)
else:
  #k//2**i+1~nのn-k//2**i個はi回
  #k//2**(i+1)+1~k//2**iのk//2**i-k//2**(i+1)個はi+1回
  b = n
  for i in range(1,18):
    a = b
    if k//2**i == k/2**i:
      b = min(k//2**i-1,b)
    else:
      b = min(k//2**i,b)
    for l in range(b,a):
      s[l] = i
    sum += (a-b)/(n*2**i)
'''b = min(n,k)-1
for i in range(1,18): #1~k-1について
  a = b
  b = k//(2**i)-1
  if b > a:
    b = a
  for l in range(b,a):
    s[l] = i
    sum += 1/(n*2**i)'''
print(sum)

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

int main(){
    long long a, b, c, d;
    std::cin >> a >> b >> c >> d;
    
    long long pat1 = a * c;
    long long pat2 = a * d;
    long long pat3 = b * c;
    long long pat4 = b * d;
    
    long long max = std::max(pat1, pat2);
    max = std::max(max, pat3);
    max = std::max(max, pat4);
    std::cout << max << std::endl;
    
    return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
#define sz(x) (x.size())
#define pb push_back
#define fi first
#define se second
using namespace std;
const int inf = 9e18, N = 1e6 + 5;
struct Node {
    int cost, dir, id;
    bool operator < (const Node &x) const
    {
        return cost > x.cost;
    }
};
int n;
string a[55];
int c[55], ans = inf;
int dist[2][N], ispal[N];
map <string, int>mp;
priority_queue <Node>q;
inline bool check (string a) {
    string tmp = a;
    reverse (tmp.begin(), tmp.end());
    return tmp == a;
}
signed main() {
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i = 1; i <= n; i++) {
        cin>>a[i]>>c[i]; int len = sz(a[i]);
        string tmp = a[i]; reverse (tmp.begin(), tmp.end());
        if (tmp == a[i]) ans = min (ans, c[i]); tmp = "";
        for (int j = 0; j < len; j++) {
            tmp.pb (a[i][j]);
            if (mp.count (tmp) == 0) mp[tmp] = sz(mp);
        } tmp = "";
        for (int j = len - 1; j >= 0; j--) {
            tmp = a[i][j] + tmp;
            if (mp.count (tmp) == 0) mp[tmp] = sz(mp);
        }
    }
    vector <string> v(sz(mp) + 5);
    map <string, int>::iterator it;
    it = mp.begin ();
    while (it != mp.end()) {
        //cout<<it->fi<<" "<<it->se<<endl;
        ispal[it -> se] = check (it -> fi);
        dist[0][it -> se] = dist[1][it -> se] = inf;
        v[it -> se] = it -> fi;
        it++;
    }
    for (int i = 1; i <= n; i++) {
        int id = mp[a[i]];
        dist[0][id] = dist[1][id] = inf;
        q.push ((Node) {c[i], 0, id});
        q.push ((Node) {c[i], 1, id});
    }
    while (q.size()) {
        Node now = q.top (); q.pop ();
        if (dist[now.dir][now.id] < now.cost) continue;
        for (int i = 1; i <= n; i++) {
            string Le = v[now.id], Ri = a[i];
            if (now.dir) swap (Le, Ri);
            int pos = 0, nowx = now.cost + c[i];
            while (pos < min (sz(Le), sz(Ri))) {
                if (Le[pos] != Ri[sz(Ri) - pos - 1]) break;
                pos++;
            }
            if (pos < min (sz(Le), sz(Ri))) continue;
            if (pos == sz(Le) && pos == sz(Ri)) ans = min (ans, nowx);
            else if (pos == sz(Le)) {
                string rm = Ri.substr (0, sz(Ri) - pos);
                if (ispal[mp[rm]]) ans = min (ans, nowx);
                else {
                    int npi = mp[rm];
                    if (dist[1][npi] > nowx) dist[1][npi] = nowx, q.push((Node) {nowx, 1, npi});
                }
            }
            else {
                string rm = Le.substr (pos);
                if (ispal[mp[rm]]) ans = min (ans, nowx);
                else {
                    int npi = mp[rm];
                    if (dist[0][npi] > nowx) dist[0][npi] = nowx, q.push((Node) {nowx, 0, npi});
                }
            }
        }
    }
    if (ans == inf) printf ("-1\n");
    else printf ("%lld\n", ans);
    return 0;
}


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

int main(){
   int a,b,n,ans=0;
   cin>>a>>b;
   n=1;
   for(int i=1;n<b;i++){
   	n=(a-1)*i+1;
   	ans++;
   }
   cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] l = new int[100001];
        for(int i = 0;i < N;i++)    l[sc.nextInt()]++;
        int ans = 0;
        ans = l[0]+l[1];
        for(int i = 1;i < 100000;i++)   ans = Math.max(ans, l[i-1]+l[i]+l[i+1]);
        ans = Math.max(ans, l[99999]+l[100000]);
        System.out.println(ans);
    }
}

Measured memory_bytes: 51428
int main(){
    char str[27]={'\0'};
    scanf("%s",str);
    int flag=0;
    for(int i=0;i<strlen(str);i++){
        for(int j=i+1;j<strlen(str);j++)
        if(str[i]==str[j]){printf("no");flag=1;break;}
        if(flag==1)break;
    }
    if(flag==0)printf("yes");
    return 0;
    }


Measured memory_bytes: 128
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a-1)/b+1;}
//Read:
//Use __builtin_popcountll for ll

signed main(){
    int n;cin>>n;
    int ans=0;
    for(int i=2;i*i<=n;i++){
        int cnt=0;
        if(n%i==0){
            while(n%i==0){
                n/=i;
                cnt++;
            }
            ans+= (int)((-1.0 + sqrt(1+8*cnt))/2.0);
        }
    }
    if(n!=1)ans++;
    cout<<ans;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) cin >> v[i];
  ll ans=0;
  rep(i,n){
    int x=v[i];
    ans+=x;
    for(int j=i;j<n;j++){
      if(v[j]>=x) v[j]-=x;
      else{
        x=v[j];
        v[j]=0;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

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


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

	int c;
	VI odd(0);
	VI even(0);

	int now = 1;
	int reserve = 2;

	REP(i, n) {
		cin >> c;
		if (now == 1) {
			odd.push_back(c);
		}
		else {
			even.push_back(c);
		}
		swap(now, reserve);
	}

	if (n % 2 == 0) {
		REVERSE(even);
		even.insert(even.end(), odd.begin(), odd.end());
		REP(i, n - 1) {
			cout << even[i] << " ";
		}
		cout << even[n - 1] << endl;
	}
	else {
		REVERSE(odd);
		odd.insert(odd.end(), even.begin(), even.end());
		REP(i, n - 1) {
			cout << odd[i] << " ";
		}
		cout << odd[n - 1] << endl;
	}

	return 0;
}



Measured memory_bytes: 3564
'use strict';
(function(stdin) {
  //declare function
  function sumLine(a, b) {
    return a + b;
  }

  function result(matrix) {
    var size = matrix.shift();
    matrix.map(function(v) {
      return v.push(v.reduce(sumLine));
    });
    var sumColumn = [];
    for (var i = 0; i < size[1] + 1; i++) {
      var sumValue = 0;
      for (var j = 0; j < size[0]; j++) {
        sumValue += matrix[j][i];
      }
      sumColumn.push(sumValue);
    }
    matrix.push(sumColumn);
    return matrix.join('\n').replace(/,/g, ' ');
  }
  //declare variable
  var inputs = stdin.toString().trim().split('\n');
  var sheet = inputs.map(function(v) {
    return v.split(' ').map(Number);
  });
  //main

  //display
  console.log(result(sheet));
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 17504
/*
Author : N_o_o_B
Created : March 01 2020 17:42:57 
*/
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define trav(x,a) for(auto& x:a)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int n,m;
    cin >> n >> m;
    vi a(n,-1);
    bool ok = 1;
    fori(i,m){
        int ind,x;
        cin >> ind >> x;
        ind--;
        if(a[ind]==-1) a[ind] = x;
        else ok &= (a[ind]==x);
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    if(n==1){
        a[0] = max(a[0],0);
        cout << a[0] << endl;
        return 0;
    }
    ok &= (a[0]!=0);
    if(!ok) {
        cout << -1 << endl;
        return 0;
    }
    fori(i,n){
        if(a[i]==-1){
            if(i) a[i] = 0;
            else a[i] = 1;
        }
    }
    for(int x:a) cout << x;
    cout << endl;

    time_taken();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int n, x, t;
  cin >> n >> x >> t;
  cout << ((n + x - 1) / x * t);
}
#endif


Measured memory_bytes: 3636
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

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

    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--;
    b--;
    c--;
    d--;
    string s;
    cin >> s;

    for(int i = a; i < max(c, d); i++){
        if(s[i] == '#' && s[i] == s[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }

    if(c > d){
        bool ok = false;
        for(int i = b; i <= d; i++){
            if(s[i] == '.' && s[i-1] == '.' && s[i+1] == '.'){
                ok = true;
            }
        }
        if(not ok){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


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

int main() {
int a,b,c;
cin>>a>>b>>c;
if(a>b)
{
    cout<<0;
}
if(a<=b)
{
    int d=b/a;
    if(d<c)
    {
        cout<<d;
    }
    else
    cout<<c;
}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int> > edges;

bool isValid(vector<int> v){
    if(v[0] != 0)
        return false;
    for(int i = 0; i< v.size()-1; i++){
        if(!edges[v[i]][v[i+1]]){
            return false;
        }
    }
    return true;
}

int main() {
    int n,m; cin >> n >> m;
    vector<int> edge(n,0);
    vector<int> v;
    for(int i = 0;i<n;i++){
        v.push_back(i);
        edges.push_back(edge);
        for(int j = 0; j< n;j++){
            edges[i][j] = 0;
        }
    }
    int from,to;
    for(int i = 0; i< m;i++){
        cin >> from >> to;
        edges[from-1][to-1] = 1;
        edges[to-1][from-1] = 1;
    }
    int count = 0;
    do {
        if(isValid(v)){
            count++;
        }
    } while(next_permutation(v.begin(), v.end()));
    cout << count << endl;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $cnt);
$ins = explode(' ', trim(fgets(STDIN)));
while ($cnt > 0) {
    sort($ins);
    if (isset($ins[1])) {
        $ins[] = ($ins[0] + $ins[1]) / 2;
        unset($ins[0]);
        unset($ins[1]);
    }
    $ins = array_values($ins);
    $cnt--;
}
$ans = array_sum($ins);
echo "$ans\n";

Measured memory_bytes: 4728
#include <iostream>
#include <queue>
#define MAX_VERTICE_NUM 100001
#define INF 2147483647
using namespace std;

typedef pair<int, int> pii;

int V, E, r, si, ti, di;
int d[MAX_VERTICE_NUM];
int S[MAX_VERTICE_NUM];
vector< vector<pii> > graph;
priority_queue< pii, vector<pii>, greater<pii> > q;

void init() {
    cin >> V >> E >> r;
    graph.resize(V);

    for (int i = 0; i < V; ++i) {
        S[i] = 0;
        d[i] = i == r ? 0 : INF;
    }
    for (int i = 0; i < E; ++i) {
        cin >> si >> ti >> di;
        graph[si].push_back(make_pair(di, ti));
    }
    q.push(make_pair(d[r], r));
}

void dijkstra() {
    while (!q.empty()) {
        pii tmp = q.top(); q.pop();
        int x = tmp.second;
        if (S[x]) {continue;}
        S[x] = 1;
        for (int i = 0; i < graph[x].size(); ++i) {
            if (d[x] + graph[x][i].first < d[graph[x][i].second]) {
                d[graph[x][i].second] = d[x] + graph[x][i].first;
                q.push(make_pair(d[graph[x][i].second], graph[x][i].second));
            }
        }
    }
}

void opAns() {
    for (int i = 0; i < V; ++i) {
        if (d[i] < INF) {
            cout << d[i] << endl;
        } else {
            cout << "INF" << endl;
        }
    }
}

int main() {
    //freopen("in14.txt", "r", stdin);

    init();
    dijkstra();
    opAns();
}

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

int main(){
    long long A, B, K;
    cin >> A >> B >> K;

    if (A > K){
        A = A - K;
        K = 0;
    }
    else if (A <= K){
        K = K - A;
        A = 0;
    }

    if (B > K){
        B = B - K;
    }
    else if (B <= K){
        K = 0;
        B = 0;
    }
    
    cout << A << " " << B << endl;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N,M = I()
maze1 = [list(s()) for _ in range(N)]
maze2 = [list(s()) for _ in range(M)]
L = [[-1]*N for _ in range(N)]
def dfs(x,y):
    if x == N or y == N:
        return
    if x-i == M or y-j == M:
        return
    if maze1[x][y] != maze2[x-i][y-j]:
        L[i][j] = 0
        return
    dfs(x+1,y)
    dfs(x,y+1)
for i in range(N-M+1):
    for j in range(N-M+1):
        dfs(i,j)
        if L[i][j] == -1:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 79860
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

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

Measured memory_bytes: 256
object Main {
  import java.util.Scanner

  def readStrings(n: Int)(implicit sc: Scanner): Array[String] = Array.fill(n) { sc.next() }
  def readInts(n: Int)(implicit sc: Scanner): Array[Int] = Array.fill(n) { sc.nextInt() }
  def readLongs(n: Int)(implicit sc: Scanner): Array[Long] = Array.fill(n) { sc.nextLong() }
  def readLineStrings(implicit sc: Scanner): Array[String] = sc.nextLine().split(' ')
  def readLineInts(implicit sc: Scanner): Array[Int] = readLineStrings.map(_.toInt)
  def readLineLongs(implicit sc: Scanner): Array[Long] = readLineStrings.map(_.toLong)

  def main(args: Array[String]): Unit = solve(new Scanner(System.in))

  def solve(implicit sc: Scanner): Unit = {
    val x = readLineInts
    val Array(a, b, c) = x.sorted.reverse
    println(a * 10 + b + c)
  }
}


Measured memory_bytes: 26056
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

vector<ll>relation[20], money(20, 1);

int main() {
	int n;
	cin >> n;
	vector<ll>a(n);
	ll total = 0;
	rep(i, n) {
		cin >> a[i];
		a[i] -= i;
	}
	sort(a.begin(), a.end());
	ll b = 0;
	if (n % 2 == 0) {
		b = (a[n / 2 - 1] + a[n / 2]) / 2;
	}
	else {
		b = a[(n - 1) / 2];
	}
	ll ans = 0;
	rep(i, n) {
		ans += abs(a[i] - b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
string s;
int a,b,c,i,j,k,n,m;
int main(){
	cin>>s;
	a=0; b=0;
	n=s.length()/2;
	for(i=0;i<n;i++){
		if(s[i]!=s[s.length()-i-1])
			a++;
	}
	if(s.length()%2==0)
        n=n-1;
	for(i=s.length()-1;i>n;i--)
	{
		if(s[i]!=s[s.length()-i-1])
			b++;
	}
	printf("%d",a<b?a:b);
	return 0;
}


Measured memory_bytes: 256
// abc173_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    map<string, int> mp;
    REP(i, N){
        string s;
        cin >> s;
        mp[s]++;
    }

    for (auto s: {"AC", "WA", "TLE", "RE"}){
        print(s, "x", mp[s]);
    }


    return 0;
}


Measured memory_bytes: 3596
#include <stdio.h>
int main(void){
  int N;
  int H[1000010];
  scanf("%d",&N);
  int i;
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
  }
  for(i=N-1;i>0;i--){
    if(H[i-1]-H[i]>=2){
      printf("No\n");
      return 0;
    }
    else if(H[i-1]-H[i]==1){
      H[i-1]=H[i-1]-1;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 2016
n = int(input())
ls = []
for i in range(n):
    a,b = map(int, input().split())
    ls.append((a,b))
cnt = 0
for i, j in ls[::-1]:
    m = (i+cnt) % j
    cnt += 0 if m == 0 else (j-m)
print(cnt)

Measured memory_bytes: 17428
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
vector<string>s;
int a[605][605];
int ruiseki[605][605];
int n;
ll ans;
void rot(){
    int temp[605][605];
    rep(i,n){
        rep(j,n){
            temp[i][j] = a[j][n-1-i];
        }
    }
    swap(temp,a);
}
void cal(){
    memset(ruiseki,0,sizeof(ruiseki));
    rep(i,n){
        ruiseki[i][0] = 0;
        rep(j,n){
            ruiseki[i][j+1] = ruiseki[i][j] + a[i][j];
        }
    }
    /*rep(i,n){
        rep(j,n+1){
            cout << ruiseki[i][j];
        }
        cout << endl;
    }*/
    rep(i,n){
        rep(j,n){
            if(a[i][j] == 0)continue;
            for(int k = j + 1; k < n; k++){
                if(a[i][k] == 0)continue;
                if(i+k-j<n){
                    ans += ruiseki[i+k-j][k]-ruiseki[i+k-j][j];
                }
            }
        }
    }
}
int main(){
    int h,w;
    cin >> h >> w;
    s.resize(h);
    rep(i,h)cin >> s[i];
    rep(i,h){
        rep(j,w){
            a[i+j][i-j+w-1] = (s[i][j] == '#' ? 1 : 0);
        }
    }
    n = h + w;
    /*rep(i,n){
        rep(j,n){
            cout << a[i][j];
        }
        cout << endl;
    }*/
    rep(i,4){
        cal();
        rot();
    }
    cout << ans << endl;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int BIG = 2e9 + 55;

int n, m;
string s, t;

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

    cin >> n >> m;
    cin >> s;
    cin >> t;

    int g = __gcd(n, m);

    int N = n / g;
    int M = m / g;

    for(int i = 0, j = 0; i < n && j < m; i += N, j += M){
        if(s[i] != t[j]){
            cout << "-1\n";
            return 0;
        }
    }

    ll lcm = N * (ll)m;

    cout << lcm << '\n';

    return 0;
}


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

using namespace std;

long long arr[10000007] ;

int main()
{
    long long n , sum = 0 , i , j  ;
    scanf("%lld",&n);
    for ( i=1 ; i<=n ; i++)
    {
                 for ( j = i ; j<=n ; j+= i )
                 {
                              arr[j]++;
                 }
    }
    for (i=1 ; i<=n ; i++)
    {
                 sum += (arr[i])*i ;
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 81908
#include <stdio.h>

int main(){
  int W,H,x,y,r;
  int  ans=1;

  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x-r<0)ans=0;
  if(r+x>W)ans=0;
  if(y-r<0)ans=0;
  if(y+r>H)ans=0;

  if(ans)printf("Yes\n");
  else printf("No\n");

  return 0;
}

Measured memory_bytes: 580
// This code Write By chtholly_micromaker(MicroMaker)
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
#define reg register
#define int long long
using namespace std;
const int MaxN=100051;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
string s[MaxN];
char inp[21];
signed main(void)
{
	int n;rd(n);
	reg int len;
	reg int ans=0,cnt=1;
	for(int i=1;i<=n;++i)
	{
		s[i]="";
		cin>>inp;
		len=strlen(inp);
		sort(inp,inp+len);
		for(int j=0;j<len;++j)
			s[i]+=inp[j];
	}
	sort(s+1,s+n+1);
	for(int i=1;i<n;++i)
	{
		if(s[i]==s[i+1])
			++cnt;
		else
			ans+=cnt*(cnt-1)/2,cnt=1;
	}
	if(cnt)
		ans+=cnt*(cnt-1)/2;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 7936
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var MIN int = 0

var sc = bufio.NewScanner(os.Stdin)

func next() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i

}

type RMQ struct {
	data []int
	size int
}

func NewRMQ(size int) *RMQ {
	s := 1
	for s < size {
		s *= 2

	}
	r := make([]int, s*2+2)
	return &RMQ{data: r, size: s}
}

func (r *RMQ) update(k, a int) {
	k += r.size - 1
	r.data[k] += a
	for k > 0 {
		k = (k - 1) / 2
		r.data[k] = r.data[k*2+1] + r.data[k*2+2]
		//r.data[k] += a
	}

}

/// [a,b]
func (r *RMQ) findSum(a, b int) int {
	return r.query(a, b+1, 0, 0, r.size)
}

// [a,b)
func (rmq *RMQ) query(a, b, k, l, r int) int {
	// case1
	if r <= a || b <= l {
		return MIN
	}
	if a <= l && r <= b {
		return rmq.data[k]
	}

	vl := rmq.query(a, b, k*2+1, l, (l+r)/2)
	vr := rmq.query(a, b, k*2+2, (l+r)/2, r)
	return vl + vr
}

func main() {
	sc.Split(bufio.ScanWords)

	n, q := next(), next()

	rmq := NewRMQ(n)

	for i := 0; i < q; i++ {
		com, x, y := next(), next(), next()

		if com == 0 {
			x -= 1
			rmq.update(x, y)

		} else {
			x -= 1
			y -= 1
			fmt.Println(rmq.findSum(x, y))

		}
	}

}



Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define MAX 1000000000000000
int n,c,dp[3005][3005],val[3005][3005];
void lcs(string s1,string s2,int n,int m)
{
	for(int i=0;i<=n;i++)
	for(int j=0;j<=m;j++)
	{
		if(i==0)
		dp[i][j]=0;
		else if(j==0)
		dp[i][j]=0;
		else if(s1[i-1]==s2[j-1])
		{
		  val[i][j]=0;
		dp[i][j]=dp[i-1][j-1]+1;
	}
		else if(dp[i-1][j]>dp[i][j-1])
		{
		val[i][j]=1;
		dp[i][j]=dp[i-1][j];
	}
		else
		{
		val[i][j]=2;
		dp[i][j]=dp[i][j-1];
	}
	}
}
void prin(string s1,string s2,int n,int m)
{
	if(n>0&&m>0)
	{
	if(val[n][m]==0)
	{
		prin(s1,s2,n-1,m-1);
		cout<<s1[n-1];
	}
	else if(val[n][m]==1)
	{
		prin(s1,s2,n-1,m);
	}
	else
	prin(s1,s2,n,m-1);
}
}

signed main()
{
	string s1,s2;
	int n,m;
	cin>>s1>>s2;
	n=s1.size();
	m=s2.size();
	lcs(s1,s2,n,m);
	prin(s1,s2,n,m);
}

Measured memory_bytes: 141696
#include <stdio.h>
#include <ctype.h>

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int h[ 'z' - 'a' + 1 ] = { };
  int i;

  for ( ; ; )
  {
    const int ch = getchar ( );

    if ( ch == EOF ) break ;
    if ( isalpha ( ch ) )
    {
      ++h[ tolower ( ch ) - 'a' ];
    }
  }

  for ( i = 'a'; i <= 'z'; ++i )
  {
    printf ( "%c : %d\n", i, h[ i - 'a' ] );
  }

  return ( 0 );
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            int N = Integer.parseInt(br.readLine());
            List<Integer> numbers = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                numbers.add(Integer.parseInt(br.readLine()) - 1);
            }

            int now = 0;
            int ans = 0;
            for (int i = 0; i < numbers.size() + 1; i++) {
                if (now == 1) {
                    System.out.println(ans);
                    break;
                }

                if (ans >= N) {
                    ans = -1;
                    System.out.println(ans);
                    break;
                }

                ans++;
                now = numbers.get(now);
            }

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 34908
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int r;
    cin >> r;
    cout << r*r << endl;
    
    return 0;
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, size):
        self.parent = [-1] * size
        self.rank = [0] * size
        self.num = self.parent

    def unite(self, n1, n2):
        rank, parent, num = self.rank, self.parent, self.num
        root, root_2 = self.find(n1), self.find(n2)

        if rank[root] > rank[root_2]:
            pass
        elif rank[root] < rank[root_2]:
            root_2, root = root, root_2
        else:
            rank[root] += 1

        num[root] += num[root_2]
        parent[root_2] = root
        return root

    def find(self, n0):
        if self.parent[n0] < 0:
            return n0
        else:
            ret = self.find(self.parent[n0])
            self.parent[n0] = ret
            return ret


n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]

ans = n * (n - 1) // 2
t = UnionFind(n + 1)
v = []

for a, b in reversed(ab):
    v.append(ans)
    root_a = t.find(a)
    root_b = t.find(b)
    if root_a == root_b:
        pass
    else:
        ans -= t.num[root_a] * t.num[root_b]
        t.unite(a, b)

for x in reversed(v):
    print(x)


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

int max(int a,int b){
	if(a>b)return a;
	return b;
}

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

int compare_char(char *a,char *b){
	return strcmp(a,b);
}

int intsort(const void *a, const void *b){
	return *(int*)b - *(int*)a;
	/*qsort(a,aの配列数,sizeof(int),intsort);*/
}

int longsort(const void *a, const void *b){
	long *A=(long *)a;
	long *B=(long *)b;
	if(*A>*B) return -1;
	if(*A<*B) return 1;
	return 0;
}

int main(){
  int i,N,K;
  char ss[10000];
  scanf("%d",&N);
  scanf("%d",&K);
  scanf("%s",ss);
  switch(ss[K-1]%3){
    case 0:
      ss[K-1]='b';
      break;
    case 1:
      ss[K-1]='c';
      break;
    case 2:
      ss[K-1]='a';
      break;
  }
  printf("%s",ss);
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		while (true) {
			int n = sc.nextInt();

			if (n == 0)
				break;

			if (n == 1)
				System.out.println("deficient number");
			else if(n > 1) {
				int sum = 1;
				for (int i = 2; i * i <= n; i++) {
					if (n % i == 0) {
						if (n / i == i) {
							sum += i;
						} else {
							sum += i + n/i;
						}
					}
				}
				
				if (n == sum) {
					System.out.println("perfect number");
					// System.out.println("N " + N + " sum " + sum);
				} else if (n > sum) {
					System.out.println("deficient number");
					// System.out.println("N " + N + " sum " + sum);
				} else {
					System.out.println("abundant number");
					// System.out.println("N " + N + " sum " + sum);
				}
			}
		}
	}
}

Measured memory_bytes: 18128
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main()
{	
	int n;

	cin >> n;

	while (n >= 0) {
		double t = 0;

		for (int i = 1; i < n; i++)
			t += atan( 1 / sqrt(i) );

		cout << fixed << setprecision(2)
			 << sqrt(n) * cos(t) << endl
			<< sqrt(n) * sin(t) << endl;

		cin >> n;
	}

	return 0;
}


Measured memory_bytes: 3464