akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iA = int.Parse(sS[0]) - 1;
            int iB = int.Parse(sS[1]) - 1;

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            // 出力
            System.Console.WriteLine("{0}", (iA * iB).ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define x first
#define y second
#define debug(...) cout << "[" << #__VA_ARGS__ << ": " << __VA_ARGS__ << "]\n"
#define rd() abs((int)rng())
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int>pii;
const int maxn = 1e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n; cin >> n;
	vector<pair<pair<string, int>, int> >v(n);
	for(int i = 0; i < n; i++)
	{
		cin >> v[i].x.x >> v[i].x.y;
		v[i].y = i + 1;
	}
	sort(all(v), [&](pair<pair<string, int>, int>a, pair<pair<string, int>, int>b)
	{
		if(a.x.x == b.x.x)
			return a.x.y > b.x.y;
		else
			return a.x.x < b.x.x;
	});
	for(int i = 0; i < n; i++)
		cout << v[i].y << "\n";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		
		while(input.hasNext()){
			String s = input.next();
			
			System.out.printf("%c%d%c\n", s.charAt(0), s.substring(1, s.length() - 1).length(), s.charAt(s.length() - 1));
		}

	}

}


Measured memory_bytes: 22740
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
  int n, h;
  cin >> n >> h;
  int a[n], b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  sort(a, a + n, greater<int>());
  sort(b, b + n, greater<int>());
  int c = a[0];
  int b_i = 0, count = 0;
  while (h > 0 and b[b_i] > c) {
    count++;
    h -= b[b_i];
    b_i++;
    if (b_i == n) break;
  }
  if (h > 0) count += ceil(h * 1.0 / c);
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 2e5+10;
int n,Log[N],f1[20][N],f0[20][N],a[N];
int c1[N],c0[N];
void init(int a[N], int f[20][N], int n) {
    Log[0]=-1;
    REP(i,1,n) f[0][i] = i, Log[i]=Log[i>>1]+1;
    REP(j,1,19) for (int i=0; i+(1<<j)-1<=n; i++) {
        int x = f[j-1][i], y = f[j-1][i+(1<<(j-1))];
        f[j][i]=a[x]<a[y]?x:y;
    }
}
int RMQ(int a[N], int f[20][N], int l, int r) {
    int k = Log[r-l+1];
    int x = f[k][l], y = f[k][r-(1<<k)+1];
    return a[x]<a[y]?x:y;
}

struct _ {
	int l,r,pl,pr;
	_ (int x, int y) {
		l = x, r = y;
		if (l&1) { 
			pl = RMQ(c1,f1,l,r);
			pr = RMQ(c0,f0,pl,r);
		}
		else {
			pl = RMQ(c0,f0,l,r);
			pr = RMQ(c1,f1,pl,r);
		}
	};
	bool operator < (const _ &rhs) const {
		return a[pl]>a[rhs.pl];
	}
};

priority_queue<_> q;
int ans[N];

int main() {
	scanf("%d",&n);
	REP(i,1,n) { 
		scanf("%d",a+i);
		if (i&1) c1[i]=a[i],c0[i]=INF;
		else c0[i]=a[i],c1[i]=INF;
	}
	init(c1,f1,n),init(c0,f0,n);
	q.push(_(1,n));
	while (q.size()) {
		_ t = q.top(); q.pop();
		ans[++*ans] = a[t.pl];
		ans[++*ans] = a[t.pr];
		if (t.l<t.pl-1) q.push(_(t.l,t.pl-1));
		if (t.pr+1<t.r) q.push(_(t.pr+1,t.r));
		if (t.pl+1<t.pr-1) q.push(_(t.pl+1,t.pr-1));
	}
	REP(i,1,n) printf("%d ",ans[i]); hr;
}








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

signed main(){
    int N;
    cin>>N;
    if(N%2==1) cout<<0<<endl;
    else{
        N/= 2;
      	int ans=0;
        while(N>=5){
            ans+=N/5;
            N/=5;
        }
        cout<<ans<<endl;
    }
}

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

const int MAXN = 100010;
struct Seg {
	int l, r;
	bool operator <(const Seg& rhs) const {
		if (r == rhs.r)
			return l<rhs.l;
		return r<rhs.r;
	}
}seg[MAXN];
int main() {
	int n,m;
	cin>>n>>m;
	for (int i=0; i<m; i++) {
		int a,b;
		cin>>a>>b;
		seg[i].l = a;
		seg[i].r = b-1;
	}
	sort(seg, seg+m);
	
	int ans=0;
	for (int i=0, pos=1; i<m && pos<=n; ) {
		if (pos < seg[i].r)
			pos++;
		else if (pos == seg[i].r) {
			ans++;
			while(i<m && seg[i].l<=pos)
				i++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()



int main(){
  int h,w;
  cin >> h >> w;
  vs a(h);
  rep(i,h) cin >> a[i];
  vvl dp(h+1,vl(w+1,0));
  dp[1][1] = 1;
  rep(i,h){
    rep(j,w){
      if(i == 0 && j == 0) continue;
      if(a[i][j] == '#') dp[i+1][j+1] = 0;
      else dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % MOD;
    }
  }
  cout << dp[h][w] << endl;
}

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

#define pb push_back
#define sp " "
#define sl "\n"
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define tra(a,b) for (auto a:b) 
#define fo(a,b,c) for (int a=b;a<=c;a++) 
#define ms(a,b) memset(a,b,sizeof(a)) 
#define all(a) a.begin(),a.end()
#define rev(a) reverse(a.begin(),a.end())
#define bit(i,j) (i&(1<<j))

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef pair<int,ii> iii;

const int N=5e4+5,mod=1000000007;

string a;
int main()
{
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	cin>>a;
	if (sz(a)%2!=0) { cout<<"No"; return 0; }
	for (int i=0;i<sz(a);i+=2) {
		if (!(a[i]=='h' && a[i+1]=='i') ) { cout<<"No"; return 0; }
	}
	cout<<"Yes";
	return 0;
}


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

using ll = long long;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

const ll INF = (ll)1e16;

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    int prev = s[0] - '0', ans = 0;
    for (int i = 1; i < s.length(); ++i) {
        prev = 1 - prev;
        if (s[i] == s[i-1]) {
            ++ans;
            s[i] = '0' + prev;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
// https://atcoder.jp/contests/agc019/tasks/agc019_b
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define EPS (1e-9)
#define INF (1e9)
#define INFL (1e18)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define BIT(n) (1LL << (n))
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }

ll mp[26];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    ll len = s.length();
    for (auto &x : s) {
        mp[x - 'a']++;
    }
    ll ans = len * (len - 1) / 2;
    REP(i, 26) ans -= (mp[i] * (mp[i] - 1)) / 2;
    cout << ans + 1 << endl;

    return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple
 
int main(){
  string s; cin >> s;
  if(s.substr(0,4) == "YAKI")
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

int main(){
    long long x;
    cin >> x;
    long long q = x/11;
    long long r = x%11;
    long long ans = q*2;
    if(r&&r<=6)
    	ans += 1;
  	else if(r>6)
    	ans += 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for(int i = 0;i < n;i++){
            a.add(sc.nextInt()-(i+1));
        }
        Collections.sort(a);
        //System.out.println(a);
        int b = 0;
        b = a.get(n/2);
        long ans = solve(a,b,n);
        System.out.println(ans);
    }
    public static long solve(List<Integer> a,int b,int n){
        long d = 0;
        for(int i = 0;i < n;i++){
            d += Math.abs(a.get(i)-b);
        }
        return d;
    }
}


Measured memory_bytes: 93456
N = int(input())
*a, = map(int, input().split())
four, two, odd = 0, 0, 0
for i in a:
	if i % 4 == 0:
		four += 1
	elif i % 2 == 0:
		two += 1
	else:
		odd += 1

if two == 0:
	if four >= odd - 1:
		print("Yes")
	else:
		print("No")
else:
	if four >= odd:
		print("Yes")
	else:
		print("No")


Measured memory_bytes: 15020
MAX_NUM = 10 ** 9 + 7

N = input()
memo = [{} for _ in range(N + 1)]

def ok(last4):
  if 'AGC' in last4 or \
  'GAC' in last4 or \
  'ACG' in last4 or \
  last4[0] == 'A' and last4[2:] == 'GC' or \
  last4[:2] == 'AG' and last4[-1] == 'C':
    return False
  return True

def dfs(cur, last3):
  if cur == N:
    return 1

  if last3 in memo[cur]:
      return memo[cur][last3]

  res = 0
  for c in 'ACGT':
    last4 = last3 + c
    if ok(last4):
      res += dfs(cur + 1, last4[1:])
      res %= MAX_NUM

  memo[cur][last3] = res
  return res

print dfs(0, 'TTT')

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

using namespace std;
using ll = long long;

int main() {
	int a, b; scanf("%d %d", &a, &b);
	for (int k = 1; k <= 100000; ++k) {
		if (8 * k / 100 == a && k / 10 == b) {
			printf("%d\n", k);
			return 0;
		}
	}
	printf("-1\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int H, W;
vector<string> mp;

const Int N_MAX = 310;
Int calcCost(Int idx,Int a,Int b){
  static _int used[N_MAX][N_MAX][N_MAX];
  static _int mem[N_MAX][N_MAX][N_MAX];
  if(a == 0 || b == 0) return 0;
  if(used[idx][a][b]++)return mem[idx][a][b];

  int I = (H - 1 - (H - a));
  int J = (H - 1 - (H - b));
  int cost = (mp[I][idx] == mp[J][idx+1]) + calcCost(idx, a - 1, b - 1);
  return mem[idx][a][b] = cost;
}


Int dfs(Int idx, Int a, Int b){
  static _int used[N_MAX][N_MAX][N_MAX];
  static _int mem[N_MAX][N_MAX][N_MAX];
  if(a == 0 || b == 0) return 0;
  if(used[idx][a][b]++) return mem[idx][a][b];
  Int p = INF, q = INF;
  if(a) p = dfs(idx, a - 1, b) + calcCost(idx, a, b);
  if(b) q = dfs(idx, a, b - 1) + calcCost(idx, a, b);
  Int res = min(p, q);
  return mem[idx][a][b] = res;
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin>>H>>W;
  mp.resize(H);
  cin>>mp;
  
  Int ans = 0;
  for(Int i=0;i<W-1;i++) ans += dfs(i, H, H);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 457216
#include <stdio.h>
int Judge(int *,int,int,int);
int main(){
  int q,n,A[20],m[200],i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
    if(Judge(A,m[i],0,n))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int Judge(int *A,int m,int i,int n){
  if(m==0)return 1;
  else if(i>=n)return 0;
  return  Judge(A,m,i+1,n)||Judge(A,m-A[i],i+1,n);
}



Measured memory_bytes: 2612
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <map>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  int r, D, x;
  cin >> r >> D >> x;

  for (int i = 1; i <= 10; i++) {
    x = r * x - D;
    cout << x << endl;
  }

  return 0;
}

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

int main(){
  string ans="No";
  int H,N;
  cin >> H >> N;
  vector<int> A(N);
  rep(i,N) {
    cin >> A[i];
    H=H-A[i];
    if(H<=0) ans="Yes";
  }
  
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3736
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    
    
    char buf[300];
    stack<char> S;
    bool Broken;
    
    while(true){
        fgets(buf,300,stdin);
        if(buf[0] == '.' && buf[1] == '\n')break;
        
        Broken = false;
        
        for(int i = 0; buf[i] != '\0' && buf[i] != '\n'; i++){
            if(buf[i] == '('){
                S.push('(');
            }else if(buf[i] == '['){
                S.push('[');
            }else if(buf[i] == ')'){
                if(S.empty() == true || S.top() != '('){
                    Broken = true;
                    break;
                }else{
                    S.pop();
                }
            }else if(buf[i] == ']'){
                if(S.empty() == true || S.top() != '['){
                    Broken = true;
                    break;
                }else{
                    S.pop();
                }
            }
        }
        
        if(!S.empty()){
            Broken = true;
            while(!S.empty())S.pop();
        }
        
        if(!Broken)printf("yes\n");
        else{
            printf("no\n");
        }
    }
    
    return 0;
    
}




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

using namespace std;

int main() {
  int N;
  cin >> N;
  int count = 0;
  
  for (int i = 0; i < 9; i++) {
    for (int j = 0; j < 9; j++) {
      int a = (i + 1) * (j + 1);
      if (N == a) {
        count+= 1;
      }
    }
  }
  if (count >= 1) {
    cout << "Yes" << endl;
  }
  else if (count == 0) {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        
        int k = sc.nextInt();
        int s = sc.nextInt();
        int ans=0;
        
        for(int i=0; i<=k; i++){
            for(int j=0; j<=k; j++){
                int z = s-i-j;
          		if(z >=0 && z<=k) {
          			ans++;
                }
            }
        }
		System.out.println(ans);
	}
}


Measured memory_bytes: 35792
// Problem : D - Sum of Divisors
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e7 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

int n;
ll a[N];

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	ll res=1;
	for(int i=2;i<=n;++i){
		for(int j=i;j<=n;j+=i){
			a[j]++;
		}
	}
	for(int i=2;i<=n;++i){
		res+=(a[i]+1)*i;
	}
   cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 81692
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> S(H + 2, vector<char>(W + 2,'.'));
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      cin >> S[i][j];
    }
  }
  int dx[8] = {1,0,-1,0,1,1,-1,-1};
  int dy[8] = {0,1,0,-1,1,-1,1,-1};
  for (int i = 1; i <= H; i++){
    for (int j = 1; j <= W; j++){
      if (S[i][j] == '#'){
        cout << S[i][j];
      } else{
        int res = 0;
        for (int k = 0; k < 8; k++){
          if (S[i + dx[k]][j + dy[k]] == '#'){
            res++;
          }
        }
        cout << res;
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>

#define MAX 500000
#define SENTINEL 2000000000

int cnt = 0;
int L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(int *s, int n, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) L[i] = s[left + i];
	for (int i = 0; i < n2; i++) R[i] = s[mid + i];
	L[n1] = R[n2] = SENTINEL;
	//L[n1] = SENTINEL;
	//R[n2] = SENTINEL;
	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		cnt++;
		if (L[i] <= R[j]) {
			s[k] = L[i++];
		}
		else {
			s[k] = R[j++];
		}
	}
	return;
}

void mergeSort(int *s, int n, int left, int right) {
	//printf("@@@");
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(s, n, left, mid);
		mergeSort(s, n, mid, right);
		merge(s, n, left, mid, right);
	}
	return;
}

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

	mergeSort(s, n, 0, n);
	for (int i = 0; i < n; i++) {
		if (i) printf(" ");
		printf("%d", s[i]);
	}
	printf("\n");
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 6604
//clear adj and visited vector declared globally after each test case
//check for long long overflow
//while adding and subs check if mod becomes -ve
//while using an integer directly in a builtin function add ll
//Mod wale question mein last mein if dalo ie. Ans<0 then ans+=mod;
//Dont keep array name as size or any other key word

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);cout.precision(dbl::max_digits10);
#define pb push_back
#define mod 1000000007 //998244353
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second 
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)    
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
#define print2d(dp,n,m) for(int i=0;i<=n;i++){for(int j=0;j<=m;j++)cout<<dp[i][j]<<" ";cout<<"\n";}
typedef std::numeric_limits< double > dbl;
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const long long N=1000000, INF=2000000000000000000;
lld pi=3.1415926535897932;
int lcm(int a, int b)
{
    int g=__gcd(a, b);
    return a/g*b;
}
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }


int32_t main()
{
    IOS;
    int n,m;
    cin>>n>>m;
    cout<<((n*(n-1))/2)+((m*(m-1))/2);
}

Measured memory_bytes: 3628
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int cnth = 0;
    int cntw = 0;
    if (h > w) {
        while(n > 0) {
            if (w - cntw >0) {
                n-=h;
                ++cntw;
            } else {
                n-=(w - cntw);
            }
        } 
    
    } else {
        while(n>0) {
            if (h - cnth>0) {
                n-=w;
                ++cnth;
            } else {
                n-=(h-cnth);
            }
        }
    
    }

    cout << (cntw + cnth) << endl;
    return 0;
}


























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

int f(int n){
 if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

int main(void){
  long long S;
  long long l = 1000, r = 1;
  int min = 753;
  cin >> S;
  while(S * 10 / l > 0){
    int d = (S % l) / r;
    //cout << d << endl;
    if( abs(d - 753) < min) min = abs(d - 753);
    l *= 10;
    r *= 10;
  }
  cout << min;
  return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	llong N;
	cin >> N;
	cout << (N-30)/2 << endl;

	return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

int a[50000];

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	a[1]=1;
	for(int i=2;i<50000;i++)
	{
		a[i]=a[i-1]+i;
	}
	int x;
	scanf("%d",&x);
	if(x==1)
	{
		printf("1\n");
		return 0;
	}
	if(x==2||x==3)
	{
		printf("2\n");
		return 0;
	}
	for(int i=2;i<50000;i++)
	{
		if(x>a[i]&&x<=a[i+1])
		{
			printf("%d\n",i+1);
			return 0;
		}
	}
	return 0;
}

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

namespace kyopro
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ap = Console.ReadLine().Split();
            int a = int.Parse(ap[0]);
            int p = int.Parse(ap[1]);
            Console.WriteLine((3 * a + p) / 2);
        }
    }
}


Measured memory_bytes: 11348
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int h, a;
    cin >> h >> a;

    if(h % a == 0){
        cout << h / a << endl;
    } else {
        cout << h / a + 1 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n);
  for(Int i=0;i<n;i++) cin>>a[i];
  Int ans=-1;
  auto check=[&ans](Int x){
    string s=to_string(x);
    for(Int i=0;i<(Int)s.size()-1;i++)
      if(s[i]+1!=s[i+1]) return;
    ans=max(ans,x);
  };
  for(Int i=0;i<n;i++)
    for(Int j=0;j<i;j++)
      check(a[i]*a[j]);
  cout<<ans<<endl;
  return 0;
}

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48 && c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
int n,t,a[200190],ans,f[200098];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=n;i;--i){
		t=0;
		for(int j=i+i; j<=n;j+=i)t^=f[j];
		if(t!=a[i])f[i]=1;
	}
	
	for(int i=1;i<=n;++i)ans+=f[i];
	printf("%d\n",ans);
	for(int i=1;i<=n;++i)if(f[i])printf("%d ",i);
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define y_n(ans) cout<<(ans?"Yes":"No")<<endl;

int main() {
    int n; cin >> n;
    if (n%10==3) cout << "bon" << endl;
    else if (n%10==0 || n%10==1 || n%10==6 || n%10==8) cout << "pon" << endl;
    else cout << "hon" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main(void) {
  int A,B,sum=0;
  cin >> A >> B;
  if(A>B){
    sum = A;
    A--;
    if(A>B){
      sum += A;
      A--;
    }else
      sum += B;
  }
  else{
    sum = B;
    B--;
    if(B>A){
      sum += B;
      B--;
    }else
      sum += A;
  }
  cout << sum << endl;
  return 0;
}
      


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll K; cin >> K;

    ll ans = 0;

    for (ll a = 1;a <= K;a++){
        for (ll b = 1;b <= K;b++){
            for (ll c = 1;c <= K;c++){
                ll ab = __gcd(a,b);
                ans += __gcd(ab,c);
            }
        }
    }

    cout << ans << endl;

    return 0;

}

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

using namespace std;
typedef long long ll;

int main (){
	ll n,k;
	cin >> n >> k;
	ll h=n/k;
	ll h2=n/k;
	if((n - (h * k)) >= (k / 2)){
		h2++;
	}
	cout << ((h2*h2*h2)*((k+1)%2))+(h*h*h) << endl;
	return 0;
}


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

int n;

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

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

using namespace std;
typedef long long ll;
ll n,W;
ll wt[100000+1],v[100000+1];
ll mo(ll x){
  if(x>0) return x;
  else return -x;
}
int main() {
  string s;
  string t;
  cin>>s>>t;
  int dp[s.size()+1][t.size()+1];
  memset(dp,0,sizeof dp);
  for(int i=1; i<=s.size(); i++){
    for(int j=1; j<=t.size(); j++){
      if(s[i-1]==t[j-1]) dp[i][j]=dp[i-1][j-1]+1;
      else dp[i][j]= max(dp[i-1][j],dp[i][j-1]);
    }
  }
  string ans="";
  int i=s.size(),j=t.size();
  while(i>=1 && j>=1){
      if(dp[i][j]!=max(dp[i-1][j],dp[i][j-1])) {ans=ans+s[i-1];i--;j--;}
      else if(dp[i][j]==dp[i-1][j]) i--;
      else j--;
  }
  reverse(ans.begin(),ans.end());
  cout<<ans<<endl;
      
}

Measured memory_bytes: 35456
d = {'N':(0,1), 'E':(1,0), 'S':(0,-1), 'W':(-1,0)}
while True:
    N = int(input())
    if N == 0: break
    field = [[0 for i in range(21)] for j in range(21)]
    for i in range(N):
        x,y = map(int,input().split())
        field[x][y] = 1
    x = y = 10
    got = 0
    M = int(input())
    for i in range(M):
        dj,lj = input().split()
        dx,dy = d[dj]
        for k in range(int(lj)):
            x,y = x+dx, y+dy
            if field[x][y]:
                got += 1
                field[x][y] = 0
    print('Yes' if got == N else 'No')

Measured memory_bytes: 5620
#include<iostream>
#include<queue>
#include<cctype>
#include<algorithm>

using namespace std;

struct S{
  int p[3][2];
  int t;
};

int main(){
  for(int w,h,n;cin>>w>>h>>n,w;){
    cin.ignore();
    char g[16][16];
    S is={{},0};
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin.get(g[i][j]);
	if(islower(g[i][j])){
	  auto x=g[i][j]-'a';
	  is.p[x][0]=i;
	  is.p[x][1]=j;
	}
      }
      cin.ignore();
    }
    queue<S> que;
    que.push(is);
    static bool p[1<<24];
    fill(begin(p),end(p),false);
    for(;;){
      S cs=que.front();
      bool f=false;
      for(int i=0;i<n;i++){
	f|=g[cs.p[i][0]][cs.p[i][1]]!='A'+i;
      }
      if(!f)break;
      que.pop();
      // int b=0;
      // for(int i=0;i<n;i++){
      // 	b=b<<8|cs.p[i][0]<<4|cs.p[i][1];
      // }
      // if(!p.insert(b).second)continue;
      static int dy[]={-1,0,0,0,1};
      static int dx[]={0,-1,0,1,0};
      for(int i=0;i<5;i++){
	int y1,x1,y2,x2,y3,x3;
	auto enqueue=[&](){
	  S ns{{y1,x1,y2,x2,y3,x3},cs.t+1};
	  int b=0;
	  for(int i=0;i<n;i++){
	    b=b<<8|ns.p[i][0]<<4|ns.p[i][1];
	  }
	  if(!p[b]++){
	    que.push(ns);
	  }
	};
	y1=cs.p[0][0]+dy[i];
	x1=cs.p[0][1]+dx[i];
	y2=cs.p[1][0];
	x2=cs.p[1][1];
	y3=cs.p[2][0];
	x3=cs.p[2][1];
	if(g[y1][x1]=='#')continue;
	if(n==1){
	  enqueue();
	}else{
	  for(int j=0;j<5;j++){
	    y2=cs.p[1][0]+dy[j];
	    x2=cs.p[1][1]+dx[j];
	    if(g[y2][x2]=='#'||y2==y1&&x2==x1||y1==cs.p[1][0]&&x1==cs.p[1][1]&&y2==cs.p[0][0]&&x2==cs.p[0][1])continue;
	    if(n==2){
	      enqueue();
	    }else{
	      for(int k=0;k<5;k++){
		y3=cs.p[2][0]+dy[k];
		x3=cs.p[2][1]+dx[k];
		if(g[y3][x3]=='#'||y3==y1&&x3==x1||y3==y2&&x3==x2||y3==cs.p[0][0]&&x3==cs.p[0][1]&&y1==cs.p[2][0]&&x1==cs.p[2][1]||y3==cs.p[1][0]&&x3==cs.p[1][1]&&y2==cs.p[2][0]&&x2==cs.p[2][1])continue;
		enqueue();
	      }
	    }
	  }
	}
      }
    }
    cout<<que.front().t<<endl;
  }
}

      

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

int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> L(m), R(m);
    for(int i = 0; i < m; i++){
        cin >> L.at(i) >> R.at(i);
    }
    int andl, andr;
    andl = *max_element(L.begin(), L.end());
    andr = *min_element(R.begin(), R.end());
    
    if(andr - andl >= 0)  cout << andr - andl + 1 << endl;
    else cout << 0 << endl;
   
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    //cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);N;
    int N; cin >> N;
    int r[N], c[N];
    REP(i,N){
        cin >> r[i] >> c[i];
    }

    /*if(N == 2){
        cout << r[0] * c[0] * c[1] << endl;
        return 0;
    }*/

    int dp[N][N];
    REP(i,N){
        REP(j,N){
            //dp[i][j] = INF;
            if(i == j) {dp[i][j] = 0;}
            else dp[i][j] = INF;
        }
    }
    //cout << dp[3][4] << endl;

    for(int w = 1; w < N; w++){
        for(int left = 0; left + w < N; left++){
            int right = left + w;
            //int mini = INF;
            for (int k = left;k < right; k++){
                int num = r[left] * r[k+1] * c[right];
                /*if(left == 3 && right == 4) {
                    cout << num << endl;
                    //cout << r[left] << " " << r[k+1] << " " << c[right] << endl;
                } */
                dp[left][left+w] = min(dp[left][left+w], dp[left][k] + dp[k+1][right] + num);
            }
        }   
    }

    cout << dp[0][N-1] << endl;
    
}


Measured memory_bytes: 3216
#include <iostream>
using namespace std;
#define Nmax 200000

int main()
{
	int n;
	int p[Nmax] = { 0 };
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}

	int cnt = 1;
	int imin = p[0];
	for (int i = 1; i < n; i++) {
		if (p[i] <= imin) {
			cnt++;
		}
		if (imin > p[i]) {
			imin = p[i];
		}
	}

	cout << cnt << endl;
	return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> P(N);
  int tmp = 1e9, cnt = 0;
  for (int i = 0; i < N; i++) {
    cin >> P.at(i);
    if (P.at(i) > tmp) cnt++;
    tmp = min(tmp, P.at(i));
  }
  cout << N - cnt << "\n";
}

Measured memory_bytes: 1024
#coding:utf-8

import sys
import bisect

SUM_P = [2**x for x in range(0, 31, 2)]
SUM_M = [2**x for x in range(1, 31, 2)]
for i in range(len(SUM_P)-1):
    SUM_P[i+1] += SUM_P[i]
for i in range(len(SUM_M)-1):
    SUM_M[i+1] += SUM_M[i]


N = int(input())

ret = 0
while N != 0:
    if N > 0:
        idx = bisect.bisect_left(SUM_P, N)
        idx = idx * 2
        N -= 2 ** idx
        ret += 2**idx
    else:
        idx = bisect.bisect_left(SUM_M, abs(N))
        idx = (idx * 2) + 1
        N += 2 ** idx
        ret += 2**idx

print(format(ret, "b"))


Measured memory_bytes: 9244
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long sum = 0;
        int neg = 0;
        boolean hasZero = false;
        long min = Long.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            if (a[i] == 0) {
                hasZero = true;
            }
            if (a[i] < 0) {
                neg++;
            }
            min = Math.min(Math.abs(a[i]), min);
            sum += Math.abs(a[i]);
        }
        if (hasZero || neg % 2 == 0) {
            System.out.println(sum);
            return;
        }
        System.out.println(sum - 2 * min);
    }

}


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

#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

const double PI = 3.14;


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

	vector< string > vec( a );

	for( int i=0 ; i<a ; i++ )
	{
		cin >> vec[i];
		sort( vec[i].begin(), vec[i].end() );
	}
	sort( vec.begin(), vec.end() );


	int64_t ans = a;
	int64_t cnt = 0;
	int64_t rate = 1;
	string tmp = "";

	for( auto &it : vec )
	{
		if( tmp != it )
		{
			tmp = it;
			rate = 1;
		}
		else if( tmp == it )
		{
			cnt += rate;
			rate ++;
		}
	}
		
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 7296
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
int a[100005];
int cmp(const void * a,const void * b)
    {
        return (*(int*)a-*(int*)b);
    }

int main()
{
	int n,i,cf=0;
	//freopen("2.in","r",stdin);
	//freopen("2.out","w",stdout);
	scanf("%d",&n);
	for(i=0;i<n;i++)
	scanf("%d",&a[i]);
	qsort(a,n,sizeof(int),cmp);
	int k=0,t=1;
	for(i=1;i<n;i++)
	{
		if(a[i]==a[i-1])
		cf++;
		else {
			t++;
		}
	}
	printf("%d\n",t-cf%2);
	return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<=(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define rev(v) reverse(all(v))
#define minvec(v) *min_element(all(v))
#define maxvec(v) *max_element(all(v))
#define sumvec(v) accumulate(all(v),0)
#define mapmax(v) v.rbegin()->first
#define mapmin(v) v.begin()->first
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define INF ((1LL<<62)-(1LL<<31))
#define zero(x,n) setw(x) << setfill('0') << n

typedef long long ll;

typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<string> vs;

typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

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

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

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

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

void YES(bool b) {cout << (b?"YES\n":"NO\n");}
void Yes(bool b) {cout << (b?"Yes\n":"No\n");}
void yes(bool b) {cout << (b?"yes\n":"no\n");}
void Yay(bool b) {cout << (b?"Yay!\n":":(\n");}

ll gcd(ll x, ll y) {return __gcd(x,y);}
ll lcm(ll x, ll y) {return x/__gcd(x,y)*y;}

int main()
{
	ll n,x,ans=0;
	cin >> n >> x;
	vll a(n);
	rep(i,n) cin >> a[i];
	a.pb(x);
	sort(all(a));
	rep(i,n) ans=gcd(ans,(a[i+1]-a[i]));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <cmath>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;

int main() {
	int n;
	cin >> n;
	string s = to_string(n);
	int res = 0;
	for (auto ss : s) {
		res += ss - '0';
	}
	if (res == 1) {
		cout << 10 << endl;
	} else {
		cout << res << endl;
	}
}






Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
int a[5001];
int main(){
    int n;
    while(cin >> n && n){
        rep(i, n) cin >> a[i];
        int ans = -INF;
        REP(i, 0, n){
            int sum = a[i];
            ans = max(ans, sum);
            REP(j, i + 1, n){
                sum += a[j];
                ans = max(ans, sum);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1172
N = int(input())
A = []
for i in range(N):
  A.append(int(input()))
a = sorted(A)
max = a[-1]
if max == a[-2]:
  for i in range(N):
    print(max)
else:
  n = A.index(max)
  for i in range(N):
    if i == n:
      print(a[-2])
      continue
    print(max)

Measured memory_bytes: 14112
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		while (true) {
			int H = scn.nextInt();
			int W = scn.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 37676
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
#include <bitset>

using namespace std;

inline bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }

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

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
const int mod = 1000000007;
const int INF = 1e9;

char d[10][10];

int search(int y, int x,char c){
	int ret = 0;
	rep(i, 8)
		for (int k = 1;; k++){
			int ty = y + dy[i] * k, tx = x + dx[i] * k;
			if (!cheak(tx, ty, 8, 8) || d[ty][tx] == '.')break;
			if (d[ty][tx] == c){
				for (int j = k - 1; j >= 1; j--){
					int cty = y + dy[i] * j, ctx = x + dx[i] * j;
					ret++;
				}
				break;
			}
		}
	return ret;
}

void setd(int y, int x, char c){

	d[y][x] = c;
	rep(i, 8)
	for (int k = 1;; k++){
		int ty = y + dy[i] * k, tx = x + dx[i] * k;
		if (!cheak(tx, ty, 8, 8) || d[ty][tx] == '.')break;
		if (d[ty][tx] == c){
			for (int j = k - 1; j >= 1; j--){
				int cty = y + dy[i] * j, ctx = x + dx[i] * j;
				d[cty][ctx] = c;
			}
			break;
		}
	}
}

int main()
{
	rep(y, 8)rep(x, 8){
		cin >> d[y][x];
	}

	for (int i = 0;i < 64 * 10;i++){
		char c = 'o';
		if (i % 2)c = 'x';

		bool f = true;
		int ty = (c == 'o' ? 8 : -1), tx = (c == 'o' ? 8 : -1); int val = 0;
		rep(y, 8)rep(x, 8)if(d[y][x] == '.'){
			int t = search(y, x, c);
			if (t)
			if ((c == 'o' && (val < t || ((val == t && y < ty) || (val == t && y == ty && x < tx)))) || 
			    (c == 'x' && (val < t || ((val == t && y > ty) || (val == t && y == ty && x > tx))))){
				val = t; ty = y; tx = x; f = false;
			}
		}

		if (!f){
			setd(ty, tx, c);
		}
	}

	rep(y, 8){
		rep(x, 8){
			cout << d[y][x];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1132
//
// Created by kuribohkute on 20/04/2019.
//
#include <iostream>
#include <cstring>
#include <vector>
using namespace std;
#define mp make_pair
#define X first
#define Y second
string s;
int md = 1000000000 + 7;
int f[100005][13];

int solve(string ss) {

    return f[ss.length()][0];
}

string fix(string s) {
    string ss = s;
    int n = s.length();
    for (int i = n - 2; i >= 0; i--) {
        if (ss[i] == '?') {
            break;
        } else{
            if (ss[i] == '0') {
                ss[i] = '9';
            } else {
                ss[i] --;
                break;
            }
        }
    }
    return ss;
}

int main () {
    cin >> s;

    memset(f, 0, sizeof(f));
    f[0][0] = 1;
    for (int n = 1; n <= s.length(); n++) {
        for (int rem = 0; rem < 13; rem++) {
            if (s[n - 1] == '?') {
                for (int i = 0; i < 10; i++) {
                    int cur_rem = (rem * 10 + i) % 13;
                    f[n][cur_rem] = (f[n][cur_rem] + f[n - 1][rem]) % md;
                }
            } else {
                int cur_rem = (rem * 10 + s[n - 1] - '0') % 13;
                f[n][cur_rem] = (f[n][cur_rem] + f[n - 1][rem]) % md;
            }
        }
    }
    cout << f[s.length()][5];
    return 0;

}


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

int main()
{
    int array[20] = {};
    array[0] = 1;
    int n;
    cin >> n;
    for(int i=2; i<=n; i++)
    {
        int carry = 0;
        for(int j=0; j<20; j++)
        {
            /* Multiply by the number and add carry from lower digit */
            array[j] = array[j] * i + carry;
            
            /* Calculate the carry */
            carry = array[j] / 10;
            
            /* Store the quotient to the array*/
            array[j] = array[j] % 10;
        }

    }
    /* Search the maximum digit*/
    int max_digit = 0;
    for(int i=19; i>=0; i--)
    {
        if(array[i])
        {
            max_digit = i;
            break;
        }
    }

    for(int i=max_digit; i>=0; i--)
    {
        cout << array[i];
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 2984
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,i,ans=0;
	cin>>n;
	for(i=1;i<=n;i++){
		if(i>=1&&i<=9)ans++;
		if(i>=100&&i<=999)ans++;
		if(i>=10000&&i<=99999)ans++;
	}
	cout<<ans;
	return 0;
}

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

int main(){
  int N, M, K;
  cin >> N >> M;
  int hist[M+1]={};
  int i,j,fav;
  fav = 0;
  for(i=1;i<=N;++i){
    cin >> K;
    for(j=1;j<=K;++j){
      cin >> fav;
      hist[fav-1]++;
    }
  }
  int n=0;
  for(i=0;i<M;++i){
    if(hist[i]==N) n++;
  }
  cout << n << endl;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var x = long.Parse(line[0]);
        var y = long.Parse(line[1]);
        var count = 0;
        while (true)
        {
            if (x  <= y) count++;
            else { Console.WriteLine(count); break; }
            x *= 2;
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) (V).begin(),(V).end()

int main(){
	string S;
	cin >> S;
	int ss = S.size();
	bool b = true;
	for (int i = 0;i < ss;i++) {
		if (i % 2) {
			if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D');
			else
				b = 0;
		}
		else {
			if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D');
			else
				b = 0;
		}
	}
	if (b)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256