akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO.Pipes;
using System.Linq;
using System.Text;

namespace cswork
{
    class Program
    {
        class Scanner
        {
            string[] s;
            int i;

            char[] cs = new char[] { ' ' };

            public Scanner()
            {
                s = new string[0];
                i = 0;
            }

            public string next()
            {
                if (i < s.Length) return s[i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();

                s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                i = 0;
                return next();
            }

            public int nextInt()
            {
                return int.Parse(next());
            }

            public long nextLong()
            {
                return long.Parse(next());
            }

            public double nextDouble()
            {
                return double.Parse(next());
            }
        }

        public Program() { }

        static void Main(string[] args)
        {
            new Program().Omame();
        }

        Scanner cin;
        const int MAXIN = 1024;
        bool[] used = new bool[MAXIN];
        int[] perm = new int[MAXIN];

        List<int[]> permList = new List<int[]>();

        public void Permutation(int pos, int n, int length)
        {
            if (pos == n)
            {
                permList.Add((int[])perm.Clone());
            }

            for (int i = 0; i < n; i++)
            {
                if (!used[i])
                {
                    perm[pos] = i;
                    used[i] = true;
                    Permutation(pos + 1, n, length);
                    used[i] = false;
                }
            }
        }

        void Omame()
        {
            cin = new Scanner();
            long N = cin.nextLong();
            long M = cin.nextLong();

            Console.WriteLine(N * (N - 1) / 2 + M * (M - 1) / 2);
        }
    }
}


Measured memory_bytes: 13268
#include<stdio.h>
int main(void)

{
int i;
  char str[10];

  for(i=0;i<=4;i++)
    scanf("%s",str);
  
  if(str[0]==str[1]||str[1]==str[2]||str[2]==str[3])
    printf("Bad");
  else 
    printf("Good");
  
  return 0;
}


Measured memory_bytes: 128
/**
  * Created by ??\??? on 2016/12/7.
  */
object Main{
    def main(args: Array[String]): Unit = {
        val T = Console.readLine().toInt
        val h = T/3600
        val m = T%3600/60
        val s = T%3600%60
        Console.println(h+":"+m+":"+s)
    }
}

Measured memory_bytes: 43584
#include <iostream>
#include <vector>
#include <string>
int main(void) {

	int n,k,q,s;
	std::cin >> n >> k >> q;
	std::vector<int> a(n,k-q);
	std::vector<int> b(q);
	for (int i = 0; i < q; i++) {
		std::cin >> b.at(i);
		a.at(b.at(i) - 1) += 1;
	}
	for (int i = 0; i < n; i++) {
		if (a.at(i) > 0) {
			std::cout << "Yes" << std::endl;
		}
		else {
			std::cout << "No" << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
//#define READ_NUMBER(i) scanf("%d",i)
 
int main(){
	int N;
	double X;
	char U;
	char dummy;
	double Ans = 0;
	cin >> N;
	for(int i = 0;i < N;i++){
		cin >> X >> U >> dummy >> dummy;
		if(U == 'J'){
			Ans += X;
		}else{
			Ans += X * 380000;
		}
	}
	cout << Ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;

ll ds(int x){
    ll ans = 0;
    while(x){
        ans += x%10;
        x/=10;
    }
    return ans;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    ll ans = INF;
    for(int a=1; a<n; a++){
        int b = n-a;
        ans = min(ans,ds(a)+ds(b));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Mo 1000000007
#define N 100000
typedef long long LL;
typedef long double LD;
using namespace std;
LL n, k, ans;

int main() {
	cin >> n >> k;
	if (k % 2 != 0) ans = (n / k) * (n / k) * (n / k);
	else {
		k /= 2;
		LL tmp = n / k, tmp1 = tmp / 2, tmp2 = tmp - tmp1;
		ans = tmp1 * tmp1 * tmp1 + tmp2 * tmp2 * tmp2; 
	}
	cout << ans << endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN
 
    ll a,b,c,k;cin>>a>>b>>c>>k;
    ll ans=0;
    if(k<=a) ans = k;
    else if(k <=a + b) ans = a;
    else ans = a - (k-a-b);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
from collections import Counter
n = int(input())
d = [int(i) for i in input().split()]
m = int(input())
t = [int(i) for i in input().split()]
d_count = Counter(d)
for k, v in Counter(t).items():
    if k not in d_count.keys():
        print("NO")
        exit()
    elif d_count[k] < v:
        print("NO")
        exit()
print("YES")

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

int W, H;
int p[100010], q[100010];

signed main()
{
	cin >> W >> H;
	rep(i,W) cin >> p[i];
	rep(i,H) cin >> q[i];

	sort(p, p + W);
	sort(q, q + H);
	p[W] = 99999999999999;
	q[H] = 99999999999999;

	int yoko_nokori = H + 1;
	int tate_nokori = W + 1;
	
	//printf("AAA W = %lld, H = %lld\n", W, H);
	//printf("AAA yoko_nokori = %lld, tate_nokori = %lld\n", yoko_nokori, tate_nokori);

	int ans = 0;
	int pi = 0, qi = 0;
	while (yoko_nokori > 0 || tate_nokori > 0) {
	//rep(i,30) {
		//printf("yoko_nokori = %lld, tate_nokori = %lld\n", yoko_nokori, tate_nokori);
		//printf("pi = %lld, qi = %lld\n", pi, qi);
		if (pi < W && p[pi] <= q[qi]) {
			ans += p[pi] * yoko_nokori;
			pi++;
			tate_nokori--;
		} else if (qi < H && q[qi] < p[pi]) {
			ans += q[qi] * tate_nokori;
			qi++;
			yoko_nokori--;
		}
		if (pi >= W && qi >= H) break;
	}

	cout << ans << endl;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <bitset>
#include <iostream>
#include <iomanip>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <numeric>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e16;

/*
<url:>
問題文============================================================

=================================================================

解説=============================================================

================================================================
*/
typedef complex<double> Point;
const double eps = 1e-9;
Point P[305];
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    int N;
    while(true){
        scanf("%d",&N);
        if(N == 0) break;
        for(int i = 0; i < N;i++){
            double x,y; scanf("%lf%lf",&x,&y);
            P[i] = Point(x,y);
        }
        if(N == 1){
            printf("1\n");
            continue;
        }
        int ans = 1;
        for(int i = 0; i < N;i++){
            for(int j = i + 1; j < N;j++){
                double dist = abs(P[i] - P[j]);
                if(dist > 2) continue;
                double r = sqrt(1 - dist*dist/4);
                double dx = -(P[i] - P[j]).imag()*r/dist;
                double dy = (P[i] - P[j]).real()*r/dist;
                Point np(dx,dy);
                Point cp(np + (P[i] + P[j])/2.0);
                
                int cnt = 0;
                for(int k = 0; k < N;k++){
                    if(abs(cp - P[k]) < 1.0 + eps) cnt++;
                }
                ans = max(ans,cnt);
            }
        }
        printf("%d\n",ans);
    }
	return 0;
}



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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    int x[5];
    for(int i = 0; i < 5; i++){
        cin >> x[i];
        if(x[i] == 0){
            cout << i+1 << endl;
        }
    }    
    
    return 0;
}

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

int main(){
  int N,M;long K;cin>>N>>M>>K;
  vector<long> A(N+1,0),B(M+1,0);
  for(int i=1;i<=N;i++){
    long W;cin>>W;
    A.at(i)=W+A.at(i-1);
  }
  for(int i=1;i<=M;i++){
    long W;cin>>W;
    B.at(i)=W+B.at(i-1);
  }
  priority_queue<int> X;
  int best;
  for(int i=M;i>=0;i--){
    if(K>=B.at(i)){
      best=i;
      break;
    }
  }
  X.push(best);
  for(int i=1;i<=N;i++){
    if(A.at(i)>K) break;
    for(int j=best;j>=0;j--){
      if(K>=A.at(i)+B.at(j)){
        X.push(i+j);
        best=j;
        break;
      }
    }
  }
  cout<<X.top()<<endl;
}
    


Measured memory_bytes: 7388
H,W = map(int,input().split())

if H%3==0 or W%3==0:
    print(0) 
else:              
    ans = min(H,W)
    for i in [0,1]:
        for j in [0,1]:
            a = (H//3) + i
            b = (W//2) + j
            tmp = max(a*W,(H-a)*b,(H-a)*(W-b))-min(a*W,(H-a)*b,(H-a)*(W-b))
            ans = min(ans,tmp)
    for i in [0,1]:
        for j in [0,1]:
            a = (W//3) + i
            b = (H//2) + j
            tmp = max(a*H,(W-a)*b,(W-a)*(H-b))-min(a*H,(W-a)*b,(W-a)*(H-b))
            ans = min(ans,tmp)          
    print(ans)        

Measured memory_bytes: 3188
#include<stdio.h>
#include<iostream>
using namespace std;
int main(void){
	int x=0;
	cin>>x;
	int answer=x%7;
	switch(answer){
		case 1:
			cout<<"fri"<<endl;
			break;
		case 2:
			cout<<"sat"<<endl;
			break;
		case 3:
			cout<<"sun"<<endl;
			break;
		case 4:
			cout<<"mon"<<endl;
			break;
		case 5:
			cout<<"tue"<<endl;
			break;
		case 6:
			cout<<"wed"<<endl;
			break;
		case 0:
			cout<<"thu"<<endl;
			break;
	}
	return 0;
	
}


Measured memory_bytes: 3104
#include <algorithm>
#include <cstdio>
#include <cstring>
const int N = 2005;
int n, A[N], _f[N][N], _g[N][N];
int f(int, int);
int g(int, int);
int f(int x, int y) {
  if (x == n - 1) return std::abs(A[x] - A[y]);
  if (~_f[x][y]) return _f[x][y];
  return _f[x][y] = std::max(f(x + 1, y), g(x, x + 1));
}
int g(int x, int y) {
  if (y == n - 1) return std::abs(A[x] - A[y]);
  if (~_g[x][y]) return _g[x][y];
  return _g[x][y] = std::min(f(y + 1, y), g(x, y + 1));
}
int main() {
  scanf("%d%d%d", &n, &A[0], &A[1]);
  n += 2;
  for (int i = 2; i < n; ++i) scanf("%d", &A[i]);
  memset(_f, -1, sizeof _f);
  memset(_g, -1, sizeof _g);
  printf("%d\n", f(0, 1));
  return 0;
}


Measured memory_bytes: 31616
//himanshu manwani
//knapsack - 2.. 1D array
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long int
#define ld long double
#define f(t) for(ll i =0;i<t;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define umpl unordered_map<ll,ll>
#define pb push_back
#define ff first
#define ss second
#define MOD 1000000007
#define inf 2e18
#define EPS 1e-3
#define PI 3.1415926535897932385
const double h = 1e-6;
const int MAX_  = 100005;
ll sqr(ll x){return abs(x) * abs(x);}

inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > MOD) c -= MOD; return c; }
 //////////////////////*********CODE***********/////////////////////
 //////////////////////////////////////////////////////////////////

int main()
 {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    ll w; cin>>n>>w;
    vi wg(n),val(n);
    f(n)cin>>wg[i]>>val[i];
    ll VS = accumulate(val.begin(),val.end(),0);   //value sum.
    vl dp(VS+1,inf);  dp[0] = 0;
    for(int item = 0;item<n;item++)
    {
        for(int VA = VS - val[item];VA>=0;VA--)
        {
            dp[VA+val[item]] = min(dp[VA+val[item]],dp[VA] + wg[item]);
        }
    }
     ll gmax = INT_MIN;
     for(ll i =0;i<VS+1;i++)
     {
         if(dp[i] <= w)
         {
             gmax = max(gmax,i);
         }
     }
     cout << gmax;
    return 0;
 }


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int N; std::cin >> N;
	std::vector<double> v(N);
	for (auto& r : v) std::cin >> r;
	std::sort(v.begin(), v.end());
	double ans = v[0];
	for (int i = 1; i < N; ++i)
		ans = (ans + v[i]) / 2;
	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 3804
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <stack>
#include <algorithm>
using namespace std;
const int Max = 1e5;

long long Q, H, S, D, N;
long long sq, th, se;
long long ans;

int main()
{
	scanf ("%lld %lld %lld %lld %lld", &Q, &H, &S, &D, &N);
	if (2 * Q >= H)	sq = H;
	else sq = 2 * Q;
	if (2 * sq >= S)	th = S;
	else th = 2 * sq;
	if (2 * th >= D)	se = D;
	else se = 2 * th;
	int w = N / 2;
	N = N - (w * 2);
	ans += w * se;
	if (N == 0.25)	ans += Q;
	else if (N == 0.5)	ans += sq;
	else if (N == 1)	ans += th;
	printf ("%lld\n", ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>

using namespace std;

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

	long long ans=0;
	long long acount=0;
	bool bflag=false;
	bool cflag=false;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='A')
		{
			if(bflag)acount=0;
			if(bflag)acount=0;
			bflag=false;
			cflag=false;
			acount++;
		}
		if(s[i]=='B')
		{
			if(bflag)acount=0;

			bflag=true;
			cflag=false;
		}
		if(s[i]=='C')
		{
			if(bflag)ans+=acount;
			else acount=0;
		
			bflag=false;
			cflag=true;
		}
	}

	cout << ans << endl;




}

Measured memory_bytes: 640
#include <iostream>
#include <cassert>

using namespace std;

const int DR[6] = {0, -1, -1, 0, 1, 1};
const int DC[2][6] = {
    {-1, -1, 0, 1, 0, -1}, // Even
    {-1, 0, 1, 1, 1, 0}, // Odd
};

int W, H;
int field[102][102];
bool outside(int r, int c) {
    return r < 0 || H <= r || c < 0 || W <= c;
}
int paint_area(int r, int c, bool &valid) {
    field[r][c] = 2;
    int len = 0;
    for(int edge = 0; edge < 6; ++edge) {
        const int nr = r + DR[edge];
        const int nc = c + DC[r&1][edge];
        if(outside(nr, nc)) {
            valid = true;
        }
        else { // inside
            int obj = field[nr][nc];
            if(obj == 1) {
                ++len;
            }
            else if(obj == 0) {
                len += paint_area(nr, nc, valid);
            }
        }
    }
    return len;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> W >> H;
    for(int r = 1; r <= H; ++r) {
        for(int c = 1; c <= W; ++c) {
            cin >> field[r][c];
        }
    }
    W += 2;
    H += 2;
    /*
    for(int r = 0; r < H; ++r) {
        if(r % 2 == 1) cout << ' ';
        for(int c = 0; c < W; ++c) {
            cout << field[r][c] << ' ';
        }
        cout << endl;
    }
    */

    int ans = 0;
    for(int r = 0; r < H; ++r) {
        for(int c = 0; c < W; ++c) {
            if(field[r][c] == 0) {
                bool valid = false;
                int len = paint_area(r, c, valid);
                if(valid) ans += len;
                //cout << r << ' ' << c << endl;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

const int H = 50, W = 100;

void f(const char fore, const char back, const int n) {
  int cnt = 0;
  for (int i = 0; i < H; ++i) {
    char s[100];
    for (int j = 0; j < W; ++j) {
      char c = back;
      if (i & 1 != 0 && j & 1 != 0) {
        if (++cnt < n)
          c = fore;
      }
      s[j] = c;
    }
    puts(s);
  }
}

int main(void) {
  int A, B;
  scanf("%d%d", &A, &B);
  printf("%d %d\n", H*2, W);

  f('.', '#', A);
  f('#', '.', B);

  return 0;
}


Measured memory_bytes: 128
from collections import Counter
from collections import defaultdict
from scipy.misc import comb

N = int(input())
S = [input() for _ in range(N)]

dd = defaultdict(int)
for i in range(N):
  s = "".join(sorted(S[i]))
  dd[s] += 1

ans = 0
for key, val in dd.items():
  ans += comb(val, 2, exact=True)

print(int(ans))

Measured memory_bytes: 35124
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
using namespace std;

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

    int n,k;
    cin >> n >> k;
    vector<long> h(n);
    rep(i,0,n) cin >> h[i];
    sort(h.begin(), h.end());
    long long ans;
    for(int i=n-k-1; i>=0; --i) ans += h[i];
    cout << ans << "\n";




}

Measured memory_bytes: 1792
n=int(input())  #数値入力 「N」だけの入力のとき

s=[""]*n
c0=0
c1=0
c2=0
c3=0
for i in range(n):
    si=input()
    if si=="AC":
        c0+=1
    elif si=="WA":
        c1+=1
    elif si=="TLE":
        c2+=1
    elif si=="RE":
        c3+=1

print("AC x",c0) 
print("WA x",c1) 
print("TLE x",c2) 
print("RE x",c3) 


Measured memory_bytes: 9656
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

H,N=LI()
if H <= sum(LI()):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 13716
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  while(cin>>n,n){
    vector<Int> p(n),q(n),r(n),s(n);
    for(Int i=0;i<n;i++) cin>>p[i]>>q[i]>>r[i]>>s[i];
    
    for(Int i=0;i<n;i++){
      Int k=__gcd(p[i],q[i]);
      p[i]/=k;q[i]/=k;
      r[i]--;s[i]--;
    }

    vector<Int> dp(n,-1);
    function<Int(Int)> dfs=[&](Int x){
      Int &res=dp[x];
      if(~res) return res;
      Int a=(~r[x]?dfs(r[x]):Int(1))*p[x];
      Int b=(~s[x]?dfs(s[x]):Int(1))*q[x];
      Int k=a/__gcd(a,b)*b;
      return res=k/p[x]+k/q[x];
    };
    
    Int ans=0;
    for(Int i=0;i<n;i++) chmax(ans,dfs(i));
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3048
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]


def get_output():
    dist = [0 for _ in range(N)]
    X, Y = [], []

    for i, (x, y) in enumerate(xy):
        x, y = x-y, x+y
        X.append(x)
        Y.append(y)

    a = max(X) - min(X)
    b = max(Y)-min(Y)
    return max(a, b)


print(get_output())


Measured memory_bytes: 100656
s=input()[::-1]
while 0<len(s):
    if s[:5] in "maerd":
        s=s[5:]
    elif s[:5] in "esare":
        s=s[5:]
    elif s[:6] in "resare":
        s=s[6:]
    elif s[:7] in "remaerd":
        s=s[7:]
    else:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int[] a = new int[26];
        for (int i = 0; i < s.length(); i++) {
            a[s.charAt(i) - 'a']++;
        }
        for (int i = 0; i < a.length; i++) {
            if (a[i] == 0) {
                System.out.println((char)(i + 'a'));
                return;
            }
        }
        System.out.println("None");
    }
}

Measured memory_bytes: 24236
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	ll count = 0;
	ll ans = -inf;
	for (int i = 0; i < n - 1; i++) {
		count = 0;
		vector<ll>check(1000, inf);
		for (int j = i + 1; j < n; j++) {
			for (int k = 0; k <= i; k++) {
				if (s[k] == s[j] && check[s[k]] == inf) {
					count++;
					check[s[k]] = 1;
				}
			}
		}
		ans = max(ans, count);
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
#include <cstdio>

#include <iostream>
#include <string>

using namespace std;

int main() {
	char str[4];
	scanf("%s", str);
	
	for (auto& i : str) {
		switch (i)
		{
		case '1':
			cout << '9';
			break;
		case '9':
			cout << '1';
		default:
			break;
		}
	}
	cout << "\n";
}


Measured memory_bytes: 256
#include <iostream>

char aizu(int pm, int pe, int pj)
{
    if (pm==100 || pe==100 || pj==100) {
        return 'A';
    } else if ((pm+pe) >= 180){
        return 'A';
    } else if ((pm+pe+pj) >= 240){
        return 'A';
    } else if ((pm+pe+pj) >= 210){
        return 'B';
    } else if ((pm+pe+pj) >= 150 && (pm>=80 || pe>=80)) {
        return 'B';
    } else {
        return 'C';
    }
}

int main()
{
    int n,pm,pe,pj;
    while(1){
        std::cin >> n;
        if(n==0){
            break;
        }
        for (int i=0; i<n; i++) {
            std::cin >> pm >> pe >> pj;
            std::cout << aizu(pm, pe, pj) << std::endl;
        }
    }
}

Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, a;
bool ok = true;
int main(){
	scanf("%d", &n);
	rep(i,n){
		scanf("%d", &a);
		if((~a&1) && a%3 && a%5) ok = false; 
	}
	puts(ok ? "APPROVED" : "DENIED");
}

Measured memory_bytes: 256
from collections import defaultdict
def main():
    n = int(input())
    d = defaultdict(int)
    sn = int(n ** 0.5)
    for x in range(1, sn + 1):
        for y in range(x, sn + 1):
            for z in range(y, sn + 1):
                a = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
                b = len(set([x, y, z]))
                if b == 1:
                    d[a] += 1
                elif b == 2:
                    d[a] += 3
                else:
                    d[a] += 6
    [print(d[i]) for i in range(1, n + 1)]


if __name__ == '__main__':
    main()


Measured memory_bytes: 11916
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}



struct prime {
    vector<int> f,prime_list;
    
    prime(int n=1):f(n+1){
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i){
            if(f[i]) continue;
            f[i] = i;
            prime_list.pb(i);
            for (ll j = i*i; j <= n; j+=i){
                if(!f[j]) f[j] = i;
            }
        }
    }
    
    bool is_prime(int a){return f[a] == a;}
    
    vector<int> ve_prime(int a){
        vector<int> res;
        while (a != 1) {
            res.pb(f[a]);
            a /= f[a];
        }
        return res;
    }
    
    vector<pair<int,int>> num_prime(int a){
        vector<int> flist = ve_prime(a);
        if(flist.size() == 0) return {};
        vector<pii> res(1,{flist[0],0});
        for(int p : flist){
            if(res.back().fi == p) res.back().se++;
            else res.pb({p,1});
        }
        return res;
    }
    
};



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

    int N;
    cin >> N;
    //int ti = clock();
    prime P(10000000);
    ll ans = 0;
    reps(i,1,N+1){
        ve<pii> aa = P.num_prime(i);
        ll aaa = 1;
        rep(i,si(aa)) aaa *= (ll)(aa[i].se+1);
        ans += (ll)(i)*aaa;
    }
    cout << ans << endl;
    
    //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
    

    return 0;
}


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

int main()
{
	long long int h,n;
	cin>>h>>n;
	long long int i,j,k,l,a,sum=0;
	for(i=0;i<n;i++)
	{
		cin>>a;
		sum=sum+a;
	}
	if(sum>=h)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define eb emplace_back


typedef long long ll;
typedef long double ld;


const ll inf = 2e9;
const ll base = 998244353;
ll mod = 1e9 + 7;



int main() {
//    srand(time(NULL));
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    auto start = clock();

    string s; cin >> s;
    int n = s.length();
    int ans = 0;
    for (int i = 0; i < n / 2; ++i) {
        if (s[i] != s[n - 1 - i]) ++ans;
    }
    cout << ans << endl;


    std::cerr << double(clock() - start) / CLOCKS_PER_SEC << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<valarray>
#define array valarray<long long>
using namespace std;
long long a[200011],b[200011],p[200011]={1},q[200011]={1},moda=1000000007,modb=2147483647,cnt[300000][27];
char s[300000];
pair<long long,long long> query(long long l,long long r){return make_pair((p[r-l]*a[l]-a[r]+moda)%moda,(q[r-l]*b[l]-b[r]+modb)%modb);}
pair<array,long long> f(long long n,long long l,const array &left,long long r,const array &right)
{
	array ans(26);
	if(l+r<=n)
	{
		auto x=f(n,l+r,left+right,l,left);
		ans+=x.first;
		n=x.second;
	}
	if(l<=n)
	{
		ans+=left;
		n-=l;
	}
	return make_pair(ans,n);
}
int main()
{
	long long l,r;
	string s;
	cin>>s>>l>>r;l--;
	s=s.substr(0,s.size()>>1);
	long long n=s.size();
	for(long long i=1;i<=n;i++)
	{
		a[i]=(a[i-1]*17+s[i-1]-'a')%moda;
		b[i]=(b[i-1]*19+s[i-1]-'a')%modb;
		p[i]=p[i-1]*17%moda;
		q[i]=q[i-1]*19%modb;
	}
	for(long long i=0;i<n;i++)
	{
		for(long long j=0;j<26;j++)cnt[i+1][j]=cnt[i][j];
		cnt[i+1][s[i]-'a']++;
	}
	long long k=0;
	for(long long i=0;i<n;i++)
		if(query(0,i)==query(n-i,n))k=i;
	if(!k)
	{
		for(long long i=0;i<26;i++)cout<<cnt[n][i]*(r/n)-cnt[n][i]*(l/n)+cnt[r%n][i]-cnt[l%n][i]<<' ';
		cout<<endl;
		return 0;
	}
	array left(26),right(26);
	for(long long i=0;i<26;i++)
	{
		left[i]=cnt[n-k][i];
		right[i]=cnt[n][i]-cnt[n-k][i];
	}
	auto lower=f(l,n-k,left,k,right),upper=f(r,n-k,left,k,right);
	for(long long i=0;i<26;i++)cout<<upper.first[i]+cnt[upper.second][i]-lower.first[i]-cnt[lower.second][i]<<' ';
	cout<<endl;
	return 0;
}

Measured memory_bytes: 27320
#                         author:  kagemeka 
#                         created: 2019-11-06 12:47:30(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics

def main():
    a, b = (int(x) for x in sys.stdin.readline().split())
    print('Even' if a * b % 2 == 0 else 'Odd')

if __name__ == "__main__":
    # execute only if run as a script
    main()


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

int main(){
    int n; cin >>n;
    int ans=0;
    int h=0;
    int tmp =0;
    for(int i=0; i<n; ++i){
        int h2; cin >> h2;
        if(h>=h2){
            tmp ++;
            ans = max(tmp,ans);
        }
        else{
            tmp =0;
        }
        h = h2;
    }
    cout << ans << endl;
}

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

int main()
{
    string s;
    cin >> s;
    int k;
    cin >> k;
    for(int i = 0; i < s.size(); i++)
    {
        if (s[i] != '1' && (i+1) <= k) {
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << '1' << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <set>
#include <ctime>
using namespace std;
typedef long long ll;
#define inf 2147483647
const ll mod = 1e9+7;
#define IosF ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define N 200004

ll Fast_Pow(ll a, ll b) {
    ll res = 1;
    while ( b ) {
        if ( b & 1 ) res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res % mod;
}

int main() {
    IosF;
    ll n;
    cin >> n;
    ll res = Fast_Pow(10ll, n) - 2ll * Fast_Pow(9ll, n) + Fast_Pow(8ll, n) ;
    res %= mod;
    res = (res + mod) % mod;
    cout << res << endl;
    // system("pause");
    return 0;
}

Measured memory_bytes: 3580
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;

void solve(){
    vector<pair<string,int>>days={mp("SUN",7),mp("SAT",1),mp("MON",6),mp("TUE",5),mp("WED",4),mp("THU",3),mp("FRI",2)};
    string x;
    cin>>x;
    rep(i,0,7){
        if(days[i].F==x){
            cout<<days[i].S;
            break;
        }
    }
}
    
int main(){
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    // fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    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 = Integer.parseInt(sc.next());
      int m = Integer.parseInt(sc.next());
      int sum = 0;
      int[] ary = new int[m];
      for (int i = 0; i < ary.length; i++) {
        ary[i] = Integer.parseInt(sc.next());
        sum += ary[i];
      }
      
      if (sum > n) {
        System.out.println(-1);
      } else {
        System.out.println(n - sum);
      }
    }
}

Measured memory_bytes: 41588
#include <bits/stdc++.h>
using namespace std;
 
const int table[6][20] = {{},
  {1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 36, 108, 220, 334, 384, 0, 0, 0, 0, 0, 0, 0, 0},
  {0, 0, 0, 0, 0, 976, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001, 1001}};
 
#define ll long long
 
vector<int> G (105);
void prepare() {
  G[1] = 0;
  for (int n = 2; n <= 100; n++) {
    for (int k = 1; k < n; k++) {
      if ((1 << k) >= n && ((1 << k) - n) >= G[k]) {
        G[n] = k;
        break;
      }
    }
  }
}
 
int g(ll n) {
  if (n <= 100) {
    return G[n];
  }
  for (int k = 1; ; k++) {
    if ((1ll << k) >= n && ((1ll << k) - n) >= g(k)) {
      return k;
    }
  }
  assert(false);
  return -1;
}
 
int solve(ll n, ll k) {
  if (n < k) {
    swap(n, k);
  }
  if (k < 63 && (1ll << k) - n < n) {
    return solve((1ll << k) - n, k);
  }
  if (k > 5) {
    return 1001;
  }
  return k == 0 ? 1 : table[k][n];
}
 
int main() {
  ll n;
  prepare();
  scanf("%lld", &n);
  int ans = solve(n, g(n));
  ans += (n == 4);
  ans += (n == 7) * 2;
  printf("%d\n", (ans > 1000) ? -1 : ans);
  return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[100000+10];
int vis[100000+10];
struct node
{
    int num,id;
    node(){
    num=0;
    id=0;
    }
} b[100000+10],c[100000+10];
bool cmp(node x,node y)
{
    return x.num<y.num;
}
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
            cin>>a[i];
    }
    for(int i=0;i<n;i+=2){
        vis[a[i]]++;
    }
    int m1=0;
    for(int i=0;i<n;i+=2){
        if(vis[a[i]]){
            b[m1].num=vis[a[i]];
            b[m1++].id=a[i];
            vis[a[i]]=0;
        }
    }
    memset(vis,0,sizeof(vis));
    int m2=0;
    for(int i=1;i<n;i+=2){
        vis[a[i]]++;
    }
    for(int i=1;i<n;i+=2){
         if(vis[a[i]]){
            //cout<<a[i]<<endl;
            c[m2].num=vis[a[i]];
            c[m2++].id=a[i];
            vis[a[i]]=0;
        }
    }
    sort(b,b+m1,cmp);
    sort(c,c+m2,cmp);
    int f=0;
        int ans=2*n;
    for(int i=m2-1;i>=0;i--){
        //cout<<c[i].id<<" "<<c[i].num<<endl;
        if(c[i].id!=b[m1-1].id){
                f=1;
            ans=min(ans,n-b[m1-1].num-c[i].num);
            //cout<<c[i].id<<endl;
            break;
        }
    }

    if(f==0)ans=min(ans,n-b[m1-1].num);
    f=0;
    for(int i=m1-1;i>=0;i--){
        if(b[i].id!=c[m2-1].id){
                f=1;
            ans=min(ans,n-c[m2-1].num-b[i].num);
            break;
        }
    }
    if(f==0)ans=min(ans,n-c[m2-1].num);
    /*cout<<n1<<" "<<m1<<endl;
    cout<<n2<<" "<<m2<<endl;
    cout<<n3<<" "<<m3<<endl;
    cout<<n4<<" "<<m4<<endl;*/
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int n,m;
  cin >> n >> m;
  priority_queue<int> q;
  rep(i,n){
    int a;
    cin >> a;
    q.push(a);
  }
  rep(i,m){
    int a = q.top(); q.pop();
    q.push(a/2);
  }
  ll ans = 0;
  rep(i,n){
    ans += q.top(); q.pop();
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int p, a, b;
void check(int p, int a, int b){
    if(p*a < b){cout << p*a; return;}
    if(p*a == b){cout << p*a; return;}
  cout << b;
}
int main() {
  cin >> p >> a >> b;
  check(p, a, b);

  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	// Code for C - Many Formulas
	var S string
	fmt.Scan(&S)

	var n int = len(S) - 1
	var flag string
	var temp string
	var ans int
	var sum int
	var num int
	for i := 0; i < (1 << n); i++ { // 全ての探索候補 00,01,10,11
		flag = ""
		for j := 0; j < n; j++ { // 各行の網羅
			flag += S[j : j+1]
			if i>>j&1 == 1 { // 判定
				flag += "+"
			}
		}
		flag += S[len(S)-1 : len(S)]
		temp = ""
		ans = 0
		for j := 0; j < len(flag); j++ {
			if flag[j] == '+' {
				num, _ = strconv.Atoi(temp)
				temp = ""
				ans += num
			} else {
				temp += flag[j : j+1]
			}
		}

		if temp != "" {
			num, _ = strconv.Atoi(temp)
			ans += num
		}

		sum += ans
	}

	fmt.Println(sum)
}


Measured memory_bytes: 1852
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;

int main(){
    
    int N,ans=0,tmp;
    cin >> N;

    for(int i=1;i<=N;i++){
        tmp=fmod(floor(log10(i))+1,2.0);
        if(tmp==1){
            ans+=1;
        }
    }

    cout << ans <<endl;

    return 0;

}

Measured memory_bytes: 512
import java.io.*;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int count=0;
    int n=sc.nextInt();
    int[] a;
    a=new int[n];
    for(int i=0;i<n;i++){
      a[i]=sc.nextInt();
    }
    for(int i=0;i<n-1;i++){
      int min=i;
      for(int j=i+1;j<n;j++){
        if(a[min]>a[j]) min=j;
      }
      if(min!=i){
        int c=a[i];
        a[i]=a[min];
        a[min]=c;
        count++;
      }
    }
    for(int i=0;i<n;i++){
      System.out.print(a[i]);
      if(i!=n-1) System.out.print(" ");
      else System.out.println();
    }
    System.out.println(count);
  }
}



Measured memory_bytes: 26364
# https://atcoder.jp/contests/abc065/tasks/abc065_b
n = int(input())
nums = []
for i in range(n):
    nums.append(int(input()))

done = set()
b = 0
ans = 0
while True:
    if b == 1:
        print(ans)
        break
    if b in done:
        print(-1)
        break
    done.add(b)
    ans += 1
    b = nums[b] - 1

Measured memory_bytes: 56024
from collections import deque

H, W = map(int, input().split())

G = []
G.append(["#" for _ in range(W + 2)])
for i in range(H):
    G.append(["#"] + list(input()) + ["#"])
G.append(["#" for _ in range(W + 2)])

# print(G)

dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]

INF = 10 ** 18
d = [[INF for i in range(W + 2)] for j in range(H + 2)]


def bfs(i, j):
    q = deque()
    q.append((i, j))
    d[i][j] = 0
    while q:
        a, b = q.popleft()
        for k in range(4):
            if G[a + dx[k]][b + dy[k]] == "#":
                continue
            if d[a + dx[k]][b + dy[k]] != INF:
                continue
            d[a + dx[k]][b + dy[k]] = d[a][b] + 1
            q.append((a + dx[k], b + dy[k]))


bfs(1, 1)
# print(d)
# print(d[H][W])

# (H+2)*(W+2) から「経路+1」と、全ての'#'の数を引いたものが答え
if d[H][W] == INF: # 到達できないときは -1を出力
    print(-1)
else:
    ans = (H + 2) * (W + 2)
    ans -= d[H][W] + 1
    cnt = 0
    for h in range(H + 2):
        for w in range(W + 2):
            if G[h][w] == "#":
                cnt += 1
    ans -= cnt
    print(ans)


Measured memory_bytes: 3316
N,A,B = map(int,input().split())
if (B-A+1) % 2 != 0 :
    flag = 1
else :
    flag = -1

if flag == 1 :
    ans = "Alice"
elif flag == -1 :
    ans = "Borys"
else :
    ans = "Draw"
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
//#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 100100;
int good[N];

struct kmp{
  vector<int> b, pos;
  string s, p;
  //A = texto, B = padrao
  void build(string A, string B){
    s = A, p = B;
    int n = sz(s), m = sz(p);
    b.resize(m + 1);
    b[0] = -1;
    for(int i = 0, j = -1; i < m; i++) {
      while(j >= 0 and p[i] != p[j]) j = b[j];
      j ++;
      b[i + 1] = j;
    }

    //achar posicoes onde o padrao aparece
    for(int i = 0, j = 0; i < n; i++){
      while(j >= 0 and s[i] != p[j]) j = b[j];
      j ++;
      if(j == m){ pos.push_back(i - j + 1);
      }
    }

  }
  void clear(){
    s="", p="";
    pos.clear();
    b.clear();
  }
};



 int n;
 string s;
bool ok(int len){
  string t1="";
  for(int i=0;i+len-1<n;i++){
    string cur="";

    for(int j=i;j<i+len;j++){
      cur+=s[j];
    }

    if(t1!=""){
       kmp KMP;
       KMP.build(t1,cur);
       if(sz(KMP.pos)>0){
        return true;
      }

    }
      

   
    t1+=s[i];
  }
  return false;

}

int32_t main(){
 fastio;
 cin>>n;
 cin>>s;
 int l = 1,r = n;
 int ans =0;
 while(l<=r){
  int mid = (l+r)/2;
  if(ok(mid)){
    ans = mid;
    l = mid+1;
  }else r = mid-1;
 }
 cout << ans << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll n;
    cin>>n;
    vector<pair<ll,ll>> v;
    if(n%2 == 0){
        // even
        fr(i,1 , n){
            fr(j, i+1, n+1){
                if(i + j == n + 1) continue;
                v.push_back(make_pair(i, j));
            }
        }
        pr(v.size());
        for(auto it:v){
            cout<<it.first<< " " << it.second<<endl;
        }
    }else{
        n--;
        fr(i,1 , n){
            fr(j, i+1, n+1){
                if(i + j == n + 1) continue;
                v.push_back(make_pair(i, j));
            }
        }
        rep(i, n){
            v.push_back(make_pair(i+1, n+1));
        }
        pr(v.size());
        for(auto it:v){
            cout<<it.first<< " " << it.second<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<int,int> P;


int main(void){
    char x;
    cin>>x;
    x++;
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
int main(){
	int n;
	string s,t;
	cin>>n;
	cin>>s>>t;
	for(int i=100;i>=0;i--){
		int fl=0;
		for(int j=0;j<i;j++){
			if(s[n-i+j] != t[j])fl=1;
		}
		if(fl==0){
			cout<<2*n-i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007
//P pa(114,514);   ,vector<P>vec(N,0);
//vector<vector<int>> vec(縦, vector<int>(横));
#define REP(i,N) for(int i=0;i<N;i++)
int gcd(int a, int b) {
    if(a>b){
        swap(a,b);
        }
    while(b%a!=0){
        b%=a;
        swap(a,b);
    }
    return a;
}
int kaijou(int n){
    int a=1;
  if(n==0){
    return 1;
  }
    REP(i,n){
        a*=i+1;
    }
    return a;
}
int ncr(int n,int r){
  int a;
  if(n<0||r<0||n<r){
    return 0;
  }
  a=kaijou(n)/kaijou(r)/kaijou(n-r);
  return a;
}
//cout << setprecision(123);
int main(){
  int N;
  bool ok=true;
  cin>>N;
  vector<pair<int,int>>v(N);
  REP(i,N){
    cin>>v[i].second>>v[i].first;
  }
  sort(v.begin(),v.end());
  
      if(v[0].second>v[0].first){
        ok=false;
      }
  if(ok){
  REP(i,N-1){
    v[i+1].second+=v[i].second;
    if(v[i+1].second>v[i+1].first){
      ok=false;
      break;
    }
  }
  
  }
  
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

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

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
 int a,b,c;
 cin>>a>>b>>c;
  if(a==b && a!=c)cout<<"Yes"<<endl;
  else if(a==c&& a!=b) cout<<"Yes"<<endl;
  else if(b==c&& c!=a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
    #include <math.h>
    #include <vector>
    #include <string>
    using namespace std;
    int main() 
    {
        int n;
      	cin>>n;
        int sum=0;
        int max=0;
        for(int i=0;i<n;i++)
        {
            int tlen;
            cin>>tlen;
            sum+=tlen;
            max = (tlen > max)? tlen : max;
        }
        string out =  (max < (sum-max)) ? "Yes":"No"; 
        cout << out << endl;
    }


Measured memory_bytes: 256
# 入力
n = int(input())
a = [int(num) for num in input().split()]

# 主処理
count = 0
isEven = True
while isEven:
  for num in a:
    isEven = num % 2 == 0 and isEven
  if isEven:
    a = [num/2 for num in a]
    count += 1

# 出力
print(count)



Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

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

        final int N = sc.nextInt();
        final int M = sc.nextInt();

        int ans = 0;
        for (int i = 0; i < N; i++) ans += i;
        for (int i = 0; i < M; i++) ans += i;
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 21716