akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	boolean check(TreeSet<int[]> C, int[] S) {
		int[] Sl = C.lower(S);
		if (Sl != null && Sl[1] < S[1]) {
			return true;
		} else {
			return false;
		}
	}

	@SuppressWarnings("unchecked")
	void solve(int N, int[][] S) {
		TreeSet<int[]>[] C = new TreeSet[N];
		for (int i = 0; i < N; ++i) {
			C[i] = new TreeSet<>(new Comparator<int[]>() {
				@Override
				public int compare(int[] o1, int[] o2) {
					if (o1[0] != o2[0]) {
						return Integer.compare(o1[0], o2[0]);
					} else {
						return -Integer.compare(o1[1], o2[1]);
					}
				}
			});
		}
		C[0].add(S[0]);
		int maxLen = 1;
		for (int i = 1; i < N; ++i) {
			int left = -1;
			int right = maxLen;
			while (right - left > 1) {
				int middle = (right + left) / 2;
				if (check(C[middle], S[i])) {
					left = middle;
				} else {
					right = middle;
				}
			}

			if (left + 1 == maxLen) {
				C[left + 1].add(S[i]);
				++maxLen;
				continue;
			} else {
				int[] tmp = C[left + 1].floor(S[i]);
				if (tmp != null && tmp[1] == S[i][1])
					continue;
				tmp = C[left + 1].higher(S[i]);
				while (tmp != null && S[i][1] <= tmp[1]) {
					C[left + 1].remove(tmp);
					tmp = C[left + 1].higher(S[i]);
				}
				C[left + 1].add(S[i]);
			}
		}
		System.out.println(maxLen);
	}

	int nextA(int a, int M) {
		return 36969 * (a & M) + (a >> 16);
	}

	int nextB(int b, int M) {
		return 18000 * (b & M) + (b >> 16);
	}

	int nextVal(int a, int b, int C) {
		return (C & ((a << 16) + b)) % 1000000;
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int m = sc.nextInt();
			int n = sc.nextInt();
			int A = sc.nextInt();
			int B = sc.nextInt();
			if (m == 0 && n == 0 && A == 0 && B == 0)
				break;
			int[][] S = new int[m + n][3];
			for (int i = 0; i < m; ++i) {
				S[i][0] = sc.nextInt();
				S[i][1] = sc.nextInt();
				S[i][2] = sc.nextInt();
			}
			int a = A, b = B, C = ~(1 << 31), M = (1 << 16) - 1;
			for (int i = 0; i < n; ++i) {
				for (int j = 0; j < 3; ++j) {
					a = nextA(a, M);
					b = nextB(b, M);
					S[i + m][j] = nextVal(a, b, C);
				}
			}
			Arrays.sort(S, new Comparator<int[]>() {
				@Override
				public int compare(int[] o1, int[] o2) {
					if (o1[0] != o2[0])
						return Integer.compare(o1[0], o2[0]);
					else if (o1[1] != o2[1]) {
						return -Integer.compare(o1[1], o2[1]);
					} else {
						return -Integer.compare(o1[2], o2[2]);
					}
				}
			});

			int[][] tmp = new int[m + n][2];
			for (int i = 0; i < m + n; ++i) {
				tmp[i][0] = S[i][1];
				tmp[i][1] = S[i][2];
			}
			solve(m + n, tmp);
		}
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 487712
<?php
class Echoes {
    var $N, $S;
    
    function __construct() {
        fscanf(STDIN, "%d", $this->N);
        fscanf(STDIN, "%s", $this->S);
    }
    
    function __invoke() {
        $S1 = substr($this->S, 0, $this->N / 2);
        $S2 = substr($this->S, $this->N / 2);
        return $this->N % 2 !== 0 ? "No" : ($S1 === $S2 ? "Yes" : "No");
    }
}

$obj = new Echoes();
echo $obj();


Measured memory_bytes: 4728
#define mod 1000000007
#define PI acos(-1)
#include<time.h>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
#include<queue>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll INF=0x7fffffffffffffff;
const int inf=0x7fffffff;
const int N=4e5+5;
clock_t start,finish;
void time_in(){start=clock();}
void time_out(){finish=clock();double tim=(double)(finish-start)/CLOCKS_PER_SEC;printf("Running time is %lf\n",tim);}
inline ll mul(ll a,ll b){ll s=0;while(b){if(b&1)s=(s+a)%mod;a=(a<<1)%mod;b>>=1;}return s%mod;}
inline ll pow_mul(ll a,ll b){ll s=1;while(b){if(b&1)s=mul(s,a);a=mul(a,a);b>>=1;}return s;}
inline ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}
inline bool read(int &ret){char c=getchar();int sgn;if(c==EOF)return 0;while(c!='-'&&(c<'0'||c>'9'))c=getchar();
	sgn=((c=='-')?-1:1);ret=((c=='-')?0:(c-'0'));while(c=getchar(),c>='0'&&c<='9')ret=ret*10+(c-'0');ret*=sgn;return 1;}
inline void write(int x){if(x>9)write(x/10);putchar(x%10+'0');}
int fact[10]={1,1,2,6,24,120,720,5040,40320,362880};
int st[4][2]={1,0,0,1,-1,0,0,-1};
int t,cas;
int n,m,k;
struct xxx{ll x,y;}a[N];
bool cmp(xxx b,xxx c)
{
	return b.y<c.y;
}
int main()
{
	while(~scanf("%d",&n))
	{
		for(int i=0;i<n;i++)
		{
			scanf("%lld%lld",&a[i].x,&a[i].y);
		}
		sort(a,a+n,cmp);
		ll ans=0;
		for(int i=0;i<n;i++)
		{
			ans+=a[i].x;
			if(ans>a[i].y){printf("No\n");goto e;}
		}
		printf("Yes\n");
		e:;
	}
}



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

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 1000000007LL
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(i=a;i<=b;i++)

#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

ll mypow(ll a, ll b) { if(b == 0) return 1; ll temp=mypow(a,b/2); temp=(temp*temp)%INF; if(b%2 == 1) temp=(a*temp)%INF; return temp; }
int mygcd(int a, int b) { if(b==0) return a; return mygcd(b,a%b); }
int cntBits(ll a) { int ret=0; while(a>0) { ret++; a/=2; } return ret; }

vii g[100010];

int ans[100010];

void dfs(int n, int p)
{
	if(p == 0) ans[n]=1;
	for(int i=0;i<g[n].size();i++)
	{
		if(g[n][i].ff == p) continue;
		if(g[n][i].ss%2) ans[g[n][i].ff]=1-ans[n];
		else ans[g[n][i].ff]=ans[n];
		dfs(g[n][i].ff, n);
	}
	return;
}

int main()
{
	ios::sync_with_stdio(0);
	int tt=1,tcase; 
	//cin >> tt;
	rep(tcase,1,tt)
	{
		int n; cin >> n;
		for(int i=1;i<n;i++)
		{
			int u,v,w; cin >> u >> v >> w;
			g[u].pb(mp(v,w));
			g[v].pb(mp(u,w));
		}
		dfs(1,0);
		for(int i=1;i<=n;i++) cout << ans[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

const int bound = 500100;
ll fact[bound], fact_inv[bound];

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

ll inv( ll x ){
	return power(x, mod-2);
}

void init(){
	fact[0] = 1;
	int b = bound-10;
	for( int i = 0; i < b; ++i ){
		fact[i+1] = fact[i]*(i+1) % mod;
	}
	fact_inv[b] = inv(fact[b]);
	for( int i = b-1; i >= 0; --i ){
		fact_inv[i] = fact_inv[i+1]*(i+1) % mod;
	}
}

ll comb( ll n, ll r ){
	if( n < r ) return 0;
	return ( fact[n]*fact_inv[r] ) % mod * fact_inv[n-r] % mod;
}

int main(){
	init();
	ll n, m; cin >> n >> m;
	ll ans = 0;
	for( ll s = 1; s <= n; ++s ){
		ll diff = comb(n, s) * comb(m, s) % mod * fact[s] % mod * comb(m-s, n-s) % mod * fact[n-s] % mod * comb(m-s, n-s) % mod * fact[n-s] % mod;
		if( s % 2 == 1 ) diff = (mod-diff)%mod;
		ans += diff;
		ans %= mod;
	}
	cout << ( comb(m, n) * fact[n] % mod * comb(m, n) % mod * fact[n] % mod + ans ) % mod << endl;
}

Measured memory_bytes: 11448
#include <bits/stdc++.h>
#define ll long long int
#define INF 1000000000000
#define MOD 1000000007
#define DEBUG(x) cerr<<'>'<<#x<<':'<<x<< endl
using namespace std;

long double dp[305][305][305];
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll N;
    cin >> N;
    ll a = 0, b = 0, c = 0;
    for(ll  i= 0;  i < N; i++)
    {
        ll el;
        cin >> el;
        if(el == 1)
            a += 1;
        else if(el == 2)
            b += 1;
        else
            c += 1;
    }    
    for(ll k = 0; k <= N; k++) {
        for(ll j = 0; j + k <= N; j++) {
            for(ll i = 0; i + j + k <= N; i++) 
            {
                if(i == 0 && j == 0 && k == 0) 
                    continue;
                if(i + j + k > N)
                    continue;
                long double expt = (long double) N / (i + j + k);
                long double expi = (long double) i / (i + j + k);
                long double expj = (long double) j / (i + j + k);
                long double expk = (long double) k / (i + j + k);

                dp[i][j][k] += expt;
                if(i >= 1)
                    dp[i][j][k] += expi * dp[i - 1][j][k];
                if(j >= 1)
                    dp[i][j][k] += expj * dp[i + 1][j - 1][k];
                if(k >= 1) 
                    dp[i][j][k] += expk * dp[i][j + 1][k - 1];
            }
        }
    }
    printf("%.10Lf\n", dp[a][b][c]);
    return 0;
}


Measured memory_bytes: 436480
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        class Solver
        {
            const int N = 100000;
            private int[] sums = new int[N + 1];
            public Solver()
            {
                var p1 = new HashSet<int>() { 2 };
                var p2 = new HashSet<int>();
                for (int i = 3; i <= N; ++i)
                {
                    if (p1.All(j => i % j != 0))
                    {
                        if (i * i <= N) { p1.Add(i); } else { p2.Add(i); }
                    }
                }
                Predicate<int> prime = n => (n * n <= N) ? p1.Contains(n) : p2.Contains(n);
                for (int i = 3; i < N; ++i)
                {
                    sums[i] = (i % 2 != 0 && prime(i) && prime((i + 1) / 2)) ? 1 + sums[i - 1] : sums[i - 1];
                    sums[i + 1] = sums[i];
                }
            }
            public int Solve(int l, int r)
            {
                return sums[r] - sums[l - 1];
            }
        }
        static void Main(string[] args)
        {
            int Q = ReadInt();
            var solver = new Solver();
            for (int i = 0; i < Q; ++i)
            {
                int[] v = ReadInts();
                Console.WriteLine(solver.Solve(v[0], v[1]));
            }
        }
    }
}


Measured memory_bytes: 18492
// https://atcoder.jp/contests/abc119/tasks/abc119_a
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#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; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    int n, m;
    string s;
    cin >> s;

    if (s.compare("2019/04/30") <= 0) {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }

    return 0;
}


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

int main() {
	string s;
    cin >> s;
    vector<string> t={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    for(int i=0;i<7;i++){
      if(s==t.at(i)){
        cout << 7-i << endl;
      }
    }
}


Measured memory_bytes: 256
def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 998244353 #出力の制限
N = 3*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,A,B,K=map(int,input().split())
ans=0
for i in range(0,N+1):
    if (K-A*i)%B==0 and N>=(K-A*i)//B>=0:
        j=(K-A*i)//B
        ans+=cmb(N,i,mod)*cmb(N,j,mod)
        ans%=mod

print(ans)


Measured memory_bytes: 101104
a = input()

kotae = 'No'

if a[0] == a[1] and a[2] == a[3] and a[0] != a[2]:
  kotae= 'Yes'

if a[0] == a[2] and a[1] == a[3] and a[0] != a[1]:
  kotae= 'Yes'

if a[0] == a[3] and a[1] == a[2] and a[0] != a[1]:
  kotae= 'Yes'

print(kotae)

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

#define MAXN 1000010
#define ll long long
#define mod 1000000007

using namespace std;

bool cmp(int x, int y) {
	return x > y;
}

int n, m, x, y, z;

int tot;

int a[MAXN], b[MAXN], c[MAXN], ans[MAXN];


int main() {
	scanf("%d%d%d%d%d", &n, &m, &x, &y, &z);
	for (int i = 1; i <= x; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= y; i++) scanf("%d", &b[i]);
	for (int i = 1; i <= z; i++) scanf("%d", &c[i]);
	
	sort(a + 1, a + x + 1, cmp); sort(b + 1, b + y + 1, cmp);
	
	for (int i = 1; i <= n; i++) ans[++tot] = a[i];
	for (int i = 1; i <= m; i++) ans[++tot] = b[i];
	for (int i = 1; i <= z; i++) ans[++tot] = c[i];
	
	sort(ans + 1, ans + tot + 1, cmp);
	
	ll sum = 0;
	for (int i = 1; i <= n + m; i++) {
		sum += ans[i];
	}
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 11520
# -*- coding: utf-8 -*-
N = int(input())

ans = []
n = 0
for i in range(1, N+1):
    n += i
    ans.append(i)

    if n >= N:
        break

# print(ans)

m = n - N
if m > 0:
    ans.pop(m-1)

# print(n)
for a in ans:
    print(a)


Measured memory_bytes: 41584
#include<iostream>
#include<bitset>
using namespace std;
int h,w;
string s[300];
bitset<300>f[300];
long ans,now;
main()
{
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		cin>>s[i];
		for(int j=0;j<w;j++)f[i][j]=s[i][j]=='#';
	}
	for(int x=1;x<h;x++)for(int y=1;y<w;y++)
	{
		if((x*2+y*2)%3)continue;
		int cnt=(x*2+y*2)/3;
		if(cnt<x||cnt<y)continue;
		now=0;
		if(x==y*2)
		{
			for(int i=0;i<h-x;i++)now+=(f[i]&f[i+x]&f[i+x/2]>>y).count();
			//for(int j=0;j<w-y;j++)now+=f[i][j]&&f[i+x][j]&&f[i+x/2][j+y];
			for(int i=0;i<h-x;i++)now+=(f[i]&f[i+x]&f[i+x/2]<<y).count();
			//for(int j=y;j<w;j++)now+=f[i][j]&&f[i+x][j]&&f[i+x/2][j-y];
		}
		else if(y==x*2)
		{
			for(int i=0;i<h-x;i++)now+=(f[i]&f[i]>>y&f[i+x]>>y/2).count();
			//for(int j=0;j<w-y;j++)now+=f[i][j]&&f[i][j+y]&&f[i+x][j+y/2];
			for(int i=x;i<h;i++)now+=(f[i]&f[i]>>y&f[i-x]>>y/2).count();
			//for(int j=0;j<w-y;j++)now+=f[i][j]&&f[i][j+y]&&f[i-x][j+y/2];
		}
		else
		{
			for(int i=0;i<h-x;i++)now+=(f[i]&f[i+x]>>cnt-x&f[i+cnt-y]>>y).count();
			//for(int j=0;j<w-y;j++)now+=f[i][j]&&f[i+x][j+cnt-x]&&f[i+cnt-y][j+y];
			for(int i=0;i<h-x;i++)now+=(f[i]&f[i+x]<<cnt-x&f[i+cnt-y]<<y).count();
			//for(int j=y;j<w;j++)now+=f[i][j]&&f[i+x][j-cnt+x]&&f[i+cnt-y][j-y];
			for(int i=x;i<h;i++)now+=(f[i]&f[i-x]>>cnt-x&f[i-cnt+y]>>y).count();
			//for(int j=0;j<w-y;j++)now+=f[i][j]&&f[i-x][j+cnt-x]&&f[i-cnt+y][j+y];
			for(int i=x;i<h;i++)now+=(f[i]&f[i-x]<<cnt-x&f[i-cnt+y]<<y).count();
			//for(int j=y;j<w;j++)now+=f[i][j]&&f[i-x][j-cnt+x]&&f[i-cnt+y][j-y];
		}
		ans+=now;
	}
	cout<<ans<<endl;
}

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

#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<ii>

using namespace std;

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vii vs(n);
	for(int i=0;i<n;++i){
		cin>>vs[i].ff;
		vs[i].ss=i+1;
	}
	sort(all(vs));
	for(int i=0;i<n;++i){
		cout<<vs[i].ss<<" \n"[i==n-1];
	}
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>

int main() {
	long long int a, b, c, d, x;
	std::cin >> a >> b >> x;
	long long int ans = 0;
	if (a != 0) {
		c = (a - 1) / x + 1;
	}
	else {
		c = 0;
	}
	d = b / x + 1;
	ans += d - c;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n; char s[4040];

int main()
  
{
scanf ("%d",&n);
  scanf ("%s",s);
  
  int r =0,g=0,b=0;
  for (int i=0;i<n;i++){
if (s[i] == 'R') r++;
if (s[i] == 'G') g++;
if (s[i] == 'B') b++;
  }
  
  long long ans = 1ll * r * g * b;
  
  for (int i=0;i<n;i++){

for (int d=1;0<=i-d&&i+d<n;d++){
if (s[i] != s[i-d] && s[i] != s[i+d] && s[i-d]!=s[i+d]) ans--;
}
  }
  printf ("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll const m=1e9+7;
int main(){
	ll n,k;
	cin>>n>>k;
	
	ll st=0;
	ll end=0;
	ll ans=0;
	for(int i=1;i<=n+1;i++){
		
		 st+=i;
		 //st%=m;
		 end+=(n+2-i);
		 //end%=m;
		 
		 if(i>=k){
			 ans+=end-st+1;
			 ans%=m;
		 }
	}
	cout<<ans;
	
	}


Measured memory_bytes: 3628
#include<stdio.h>

int main(){
    int N;
    int A[110];
    int max = 0;
    int min = 1100000000;

    scanf("%d", &N);

    for(int i=0; i<N; i++){
        scanf("%d", &A[i]);
        if(max<A[i]){
            max = A[i];
        }
        if(A[i]<min){
            min = A[i];
        }
    }

    printf("%d", max-min);

    return 0;
}

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

int n, k, c = 0, m;

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

	vector<int> v(n);

	for (int i = 0; i < n; i++)
		cin >> v[i];

	m = min(n, k);

	for (int a = 0; a <= m; a++) {
		for (int b = 0; b <= m - a; b++) {
			int c1 = 0;
			vector<int> u;

			for (int i = 0; i < a; i++)
				u.push_back(v[i]);

			for (int i = 0; i < b; i++)
				u.push_back(v[n - 1 - i]);

			sort(u.begin(), u.end());

			for (int i = 0; i < a + b; i++) {
				if (i < k - a - b && u[i] < 0)
					continue;
				
				c1 += u[i];
			}

			c = max(c, c1);
		}
	}

	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		boolean flag = false;
		if (A*B*1 % 2 != 0){
			flag = true;
		} else if (A*B*2 % 2 != 0){
			flag = true;
		} else if (A*B*3 % 2 != 0){
			flag = true;
		}
		if(flag){
			System.out.println("Yes");						
		} else {
			System.out.println("No");						
		}
		
		
		// 入力
		/*
		String S = sc.next();                
		String T = sc.next();                
		
		for (int i = 0; i < S.length(); i++) {
			if (!S.substring(i,i+1).equals(T.substring(i,i+1))) {
				if (S.indexOf(T.substring(i,i+1)) == -1) {
					S = S.replace(S.substring(i,i+1), T.substring(i,i+1));
				} else {
					String s = S.substring(0, S.length());
					StringBuilder sb = new StringBuilder("");
					for (int j = 0; j < s.length(); j++) {
						if (s.substring(j, j+1).equals(S.substring(i, i+1))) {
							sb.append(T.substring(i, i+1));
						} else if (s.substring(j, j+1).equals(T.substring(i, i+1))) {
							sb.append(S.substring(i, i+1));							
						} else {
							sb.append(s.substring(j, j+1)); 
						}
					}
					S = sb.toString();
				}
			}
		}
		if(S.equals(T)){
			System.out.println("Yes");			
		} else {
			System.out.println("No");			
		}
	*/
	}	
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int deg[10];
int main(void) {
    for(int i = 0;i<3;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        deg[a]++;
        deg[b]++;
    }
    for(int i=0;i<4;i++) {
        if(deg[i] ==3) {
            cout << "NO" << endl;
        return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
# a = [2,3,4,7,5,7]

# b = a[0:1]
# print(b)


N = int(input())
S = str(input())

ls = list(S)
# print(ls)

# a = []

max = 0
# counter = 0

x = 1
# y = -1
for i in range(len(S)):
  a = ls[0:x]
  b = ls[x:]
  a_s = set(a)
  b_s = set(b)
  c = len(list(a_s & b_s))
  x +=1

  if c > max:
    max = c
    # print(a[-1])

print(max)









Measured memory_bytes: 3064
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath> 
#define ll int
#define maxn 40010
using namespace std;
int T,n,m;
long long a[1000010],b[1000010];
long long read()
{
    long long x=0,f=1;
    char c=getchar();
    while(c>'9'||c<'0')
    {
        if(c=='-')
        {
            f=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=x*10+c-'0';
        c=getchar();
    }
    return x*f;
}
int main()
{
	long long ans=1000000009;
	long long minn=1000000009,minx=1000000009;
	long long x,y,z;
	n=read();
	m=read();
	T=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read();
		minx=min(minx,a[i]);
	}
	for(int j=1;j<=m;j++)
	{
		b[j]=read();
		minn=min(minn,b[j]);
	}
	for(int i=1;i<=T;i++)
	{
		x=read();
		y=read();
		z=read();
		ans=min(ans,a[x]+b[y]-z);
	}
	ans=min(ans,minn+minx);
	printf("%lld\n",ans);
    return 0;
}
/*

*/

Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define sim template < class c
#define ris return *this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", ", d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; it++)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); ++i)
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<long long,long long>;
using veci = vector<int>;
using vecl = vector<long>;
using vecveci = vector<vector<int>>;
using vecvecl = vector<vector<long long>>;

int main() {
    string S;
    cin >> S;
    string pre = "";
    int ans = 0;
    int N = S.size();
    string T = "";
    REP(i,N) {
        T += S[i];
        if(T != pre) {
            ans++;
            pre = T;
            T = "";
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9; 

void solve(){
    ll n, k;
    cin >> n >> k;
    ll x = n % k; 
    set <ll> s;
    s.ins(x);
    for(int i = 1; i <= 1e3; ++i){
        s.ins(abs(x - k));
        x = abs(x - k);
    }    
    cout << *s.begin();
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

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

using namespace std;

void solve(void)
{
	int n, x;
	cin >> n >> x;
	long ans = 0, pre = 0;
	while(n--)
	{
		long a;
		cin >> a;
		long ate = max(0L, pre + a - x);
		ans += ate;
		pre = a - ate;
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define int             long long
#define mp              make_pair
#define pr              pair<long long,long long>
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

int32_t sum_of_digit(int n)  
{  
    if (n == 0)  
    return 0;  
    return (n % 10 + sum_of_digit(n / 10));  
}  



int32_t main()
{ 
    int n;
    cin>>n;
    int a[n+1];
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i%2==1 && a[i]%2==1)
        ans++;
    }
    cout<<ans<<"\n";
    return 0;
	}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(x) scanf("%lld",&x)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll x,k,d;
  cin>>x>>k>>d;
  ll p = abs(x)/d;
  if(x>0){
  	if(p>=k) cout<<abs(x-k*d);
  	else{
  		k-=p;
  		ll z = x-p*d;
  		if(z==0){
  			if(k%2==0) cout<<0;
  			else cout<<abs(d);
  			return 0;
  		}
  		if(k%2==1) cout<<abs(z-d);
  		else  cout<<abs(z);

  	}


  }else if(x<0){
  	if(p>=k) cout<<abs(x+k*d);
  	else{
  		k-=p;
  		ll z = x+p*d;
  		if(z==0){
  			if(k%2==0) cout<<0;
  			else cout<<abs(d);
  			return 0;
  		}
  		if(k%2 == 1) cout<<abs(z+d);
  		else cout<<abs(z);
  	}
  }
  else{
  	if(k%2 == 0) cout<<0;
  	else cout<<abs(d);
  }

  return 0;
}

Measured memory_bytes: 3648
object Main extends App {
    def find(m: Int, ar: Array[Int]): Int = 
        if(ar(m) == m) m else {ar(m) = find(ar(m), ar); ar(m)}
 
    def unite(x: Int, y: Int, ar: Array[Int]) = {
        val _x = find(x, ar)
        val _y = find(y, ar)
        if(_x != _y) ar(_x) = _y
    }
 
    val in = io.Source.stdin.getLines.map(_.trim.split(" ").map(_.toInt))
    val n = in.next.head
    val d = in.toList
    val es = (for (i <- (0 to n-2); j <- (i+1 to n-1) if d(i)(j) != -1) yield (i, j, d(i)(j))).sortBy(_._3)
    val t = (0 to n-1).toArray
    var cost = 0
    es.foreach(e => if (find(e._1, t) != find(e._2, t)) {unite(e._1, e._2, t); cost += e._3})
    println(cost)
}

Measured memory_bytes: 49212
#include<iostream>
#include<map>
#include<unordered_set>
#include<utility>
#include<set>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;


long long various_sushi(long long n, long long k, long long t[], long long d[]) {
  priority_queue<pair<long long, long long>> oishisa_que;
  for(long long i =0;i<n;i++) {
    oishisa_que.push(make_pair(d[i], t[i]));
  }
  map<long long, bool> sushi_base_map;

  long long base_point =0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>>> chosen_que;

  for(long long i=0;i<k;i++) {
    pair<long long, long long> sushi_d = oishisa_que.top();
    oishisa_que.pop();
    base_point += sushi_d.first;
    //if(sushi_base_set.find(sushi_d.second) == sushi_base_set.end()) {
    if(!sushi_base_map[sushi_d.second]) {
      // new
      //sushi_base_set.insert(sushi_d.second);
      sushi_base_map[sushi_d.second] = true;
      continue;
    }
    // existing
    chosen_que.push(sushi_d);
  }
  //long long max_total_point = base_point + (sushi_base_set.size() * sushi_base_set.size());
  long long max_total_point = base_point + (sushi_base_map.size() * sushi_base_map.size());
  //cout << "base: " << max_total_point << endl;
  //cout << "size: "  << (sushi_base_map.size() * sushi_base_map.size()) << endl;
  //cout << "cho:" << chosen_que.size() << endl;
  while(!oishisa_que.empty() && !chosen_que.empty()) {
    //cout << "cho:" << chosen_que.size() << endl;
    pair<long long, long long> sushi_d = oishisa_que.top();
    oishisa_que.pop();
    pair<long long, long long> min_sushi_d = chosen_que.top();
    chosen_que.pop();
    base_point -= min_sushi_d.first;
    base_point += sushi_d.first;

    //if(sushi_base_set.find(sushi_d.second) == sushi_base_set.end()) {
    if(!sushi_base_map[sushi_d.second]) {
      //sushi_base_set.insert(sushi_d.second);
      sushi_base_map[sushi_d.second] = true;
    } else {
      chosen_que.push(sushi_d);
    }
    //long long siz = (long long) (sushi_base_set.size() * sushi_base_set.size());
    long long siz = (long long) (sushi_base_map.size() * sushi_base_map.size());
    max_total_point = max(base_point + siz, max_total_point);
  }

  return max_total_point;
}
     int main() {
     long long n, k;
     cin >> n;
     cin >> k;
     long long t[n];
     long long d[n];
     for(int i=0;i<n;i++) {
     cin >> t[i];
     cin >> d[i];
     }
     cout << various_sushi(n, k, t, d);
     }

Measured memory_bytes: 11064
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<cctype>
#include<math.h>
using namespace std;
#define ll long long
int main(){
    ll N;
    cin >> N;
    ll i;
    for(i=0;i<=50000;i++){
        if(i*108/100==N){
            cout << i;
            return 0;
        }
    }
    cout << ":("<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 100
#define W 0
#define G 1
#define B 2

int n,M[N][N];
int color[N],d[N],f[N],tt;


void dfs_v(int u){
  int v;
  color[u] = G;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0) continue;
    if(color[v]==W){
      dfs_v(v);
    }
  }
  color[u]=B;
  f[u]=++tt;
}


void dfs(){
  int u;

  for(u=0;u<n;u++) color[u]=W;
  tt=0;
  
  for(u=0;u<n;u++){
    if(color[u]==W) dfs_v(u);
  }

   for(u=0;u<n;u++){
     printf("%d %d %d\n",u+1,d[u],f[u]);
   }
}


int main(){

  int u,v,k,i,j;

  scanf("%d",&n);
  
   for(i=0;i<n;i++){
     for(j=0;j<n;j++){
       M[i][j]=0;
     }
   }

    for(i=0;i<n;i++){
      scanf("%d %d",&u,&k);
      u--;
      for(j=0;j<k;j++){
	scanf("%d",&v);
	v--;
	M[u][v]=1;
      }
    }

    dfs();

    return 0;
}




Measured memory_bytes: 2052
<?php

// 入力値の取得
$AB = explode(" ", fgets(STDIN));
$A = intval($AB[0]);
$B = intval($AB[1]);

for ($price = 1; $price < 1010; $price++) {
    // 消費税が条件を満たしているかチェック
    if (
        (int) floor($price * 0.08) === $A &&
        (int) floor($price * 0.1) === $B)
    {
        echo $price;
        exit;
    }
}

// ここまできてる時は条件を満たすものがないので-1を表示
echo -1;

?>

Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    double r; cin >> r;
    double ans = r * 2 * 3.14159265358979;
    printf("%.10f\n",ans);
}


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

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define ANS(ans) cout<<(ans)<<endl;
typedef vector<int> VI;


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



int main() {
	VI v(3);
	REP(i, 3) {
		cin >> v[i];
	}
	int k;
	cin >> k;

	SORT(v);

	cout << v[2] * pow(2, k)+v[0]+v[1] << endl;;


	


	return 0;
}



Measured memory_bytes: 384
N = list(map(int,list(input())))
l = len(N)
start1 =0
start0 =0

for i in range(l):
    if(N[i] != 0 and i%2 == 0):
        start0 += 1
    elif(N[i] != 1 and i%2 == 1):
        start0 += 1
    
    if(N[i] != 1 and i%2 == 0):
        start1 += 1
    elif(N[i] != 0 and i%2 == 1):
        start1 += 1

print(min((start0,start1)))

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

int main() {
  char C;
  cin >> C;
  
  if ( C == 'a'||C == 'e'||C == 'i'||C == 'o'||C == 'u' ) {
	  cout << "vowel" << endl;
  }
  else {
  	  cout << "consonant" << endl;
  }
  
}


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

using namespace std;

int main() {
    vector<int> A(3);
    for (int i = 0; i < 3; i++) {
        cin >> A[i];
    }
    int evenNum = 0;
    for (int i = 0; i < 3; i++) {
        if (A[i] % 2 == 0) {
            evenNum++;
        }
    }
    int ans = 0;
    if (evenNum % 2 == 0) {
        for (int i = 0; i < 3; i++) {
            if (A[i] % 2 == 0) {
                ++A[i];
                ++ans;
            }
        }
        ans /= 2;
    } else {
        for (int i = 0; i < 3; i++) {
            if (A[i] % 2 == 1) {
                ++A[i];
                ++ans;
            }
        }
        ans /= 2;
    }
    sort(A.begin(), A.end());
    for (int i = 0; i < 2; i++) {
        ans += (A[2] - A[i]) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  int N=s.size();
  map<char,int>M;
  M['a']=0;
  M['b']=0;
  M['c']=0;
  for(int i=0;i<N;i++){
  char x=s.at(i);
    M.at(x)++;
  }int A=M.at('a');
  int B=M.at('b');
  int C=M.at('c');
  if(abs(A-B)<=1&&abs(B-C)<=1&&abs(A-C)<=1)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h,w;cin>>h>>w;
  int n;cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int id=0;
  int res[h][w];
  rep(i,h)
  {
    rep(j,w)
    {
      if(i%2)
      {
        res[i][w-1-j]=id+1;
      }
      else
      {
        res[i][j]=id+1;
      }
      a[id]--;
      if(a[id]==0)id++;
    }
  }
  rep(i,h)
  {
    rep(j,w)
    {
      cout<<res[i][j]<<" ";
    }
    cout<<"\n";
  }

}


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

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


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {

	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			final int N = sc.nextInt();
			
			HashSet<Long> set = new HashSet<Long>();
			for(int i = 0; i < N; i++) {
				final long A = sc.nextLong();
				
				if(set.contains(A)) {
					System.out.println("NO");
					return;
				}
				
				set.add(A);
			}
			
			System.out.println("YES");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 55476
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N;
	cin>>N;
	int ans=0;
	int res;
	for(int i=0;i<N;++i){
		cin>>res;
		ans+=res;
	}
	ans-=N;
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define MAXN 200005
const int mod = 1e9+7;
int f[MAXN];
int dp[3005];

int mul(int a,int b){
	return (lli) a * b % mod;
}

int sub(int a, int b){
	return (lli) (a + mod - b) % mod;
}

int powmod(int a,int b){
	int ans = 1ll;
	while(b){
		if(b&1) ans = mul(ans,a);
		b>>=1;
		a = mul(a,a);
	}
	return ans;
}

int inv(int a){
	return powmod(a,mod-2);
}

int ncr(int n, int m){
	if(m > n) return 0;
	return mul(f[n],inv(mul(f[m],f[n-m])));
}

int caminos(int a, int b){
	return ncr(a+b,b);
}

int main(){__
	f[0] = 1;
	for(int i =1; i < MAXN; i++){
		f[i] = mul(f[i-1],i);
	}

	int n,m;
	cin >> n >> m;
	int x;
	cin >> x;
	vector<pii> a(x);
	for(int i=0; i < x; i++){
		cin >> a[i].fi >> a[i].se;
	}

	sort(a.begin(),a.end(),[&](pii u, pii v){
		if(u.se == v.se) return u.fi < v.fi;
		return u.se < v.se;
	});

	a.push_back(pii(n,m));
	for(int i =0; i <= x; i++){
		dp[i] = caminos(a[i].fi-1,a[i].se-1);
		for(int j =0; j < i; j++){
			if(a[j].fi <= a[i].fi && a[j].se <= a[i].se){
				dp[i] = sub(dp[i],mul(dp[j],caminos(a[i].fi - a[j].fi,a[i].se - a[j].se)));
			}
		}
	}
	cout << dp[x] << endl;
	return 0;
}



Measured memory_bytes: 1152
import sys
import numpy as np
INF = 10000000000
M = 10


def main():
    n = int(input())
    fveclist = [np.array([int(e) for e in input().split()]) for _ in range(n)]
    plist = [[int(e) for e in input().split()] for _ in range(n)]
    ans = -INF
    for b in range(1, pow(2, M)):
        joisino = np.array([b >> i & 1 for i in range(M)])
        subans = 0
        for i in range(n):
            subans += plist[i][(fveclist[i] * joisino).sum()]
        ans = max(ans, subans)
    print(ans)


main()


Measured memory_bytes: 13896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a.at(i);
    sort(all(a));
    if(n%2==0){
        int tmp=0;
        rep(i,n){
            if(i<n/2-1)tmp-=a.at(i)*2;
            else if(i==n/2-1)tmp-=a.at(i);
            else if(i==n/2)tmp+=a.at(i);
            else tmp+=a.at(i)*2;
        }
        cout<<tmp<<endl;
    }else{
        int tmp=0;
        rep(i,n){
            if(i<=n/2-2)tmp-=a.at(i)*2;
            else if(i<=n/2)tmp-=a.at(i);
            else tmp+=a.at(i)*2;
        }
        int tmp2=0;
        rep(i,n){
            if(i<n/2)tmp2-=a.at(i)*2;
            else if(i<n/2+2)tmp2+=a.at(i);
            else tmp2+=a.at(i)*2;
        }
        cout<<max(tmp,tmp2)<<endl;
    }
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var edge = new List<int>[N + 1];
            for (int i = 0; i < N + 1; i++) edge[i] = new List<int>();
            for (int i = 0; i < N - 1; i++)
            {
                var input = ReadArrayInt();
                var a = input[0];
                var b = input[1];
                edge[a].Add(b);
                edge[b].Add(a);
            }
            var fenDFS = new DFS(N, edge);
            fenDFS.Seach(1, 0);
            var snuDFS = new DFS(N, edge);
            snuDFS.Seach(N, 0);
            var fenC = 0;
            var snuC = 0;
            for (int i = 1; i <= N; i++)
            {
                if (fenDFS.Dis(i) <= snuDFS.Dis(i)) fenC++;
                else snuC++;
            }

            Console.WriteLine(fenC > snuC ? "Fennec" : "Snuke");
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }

    class DFS
    {
        int[] dis;
        List<int>[] edge;

        public DFS(int n, List<int>[] edge)
        {
            dis = Enumerable.Repeat(int.MaxValue, n + 1).ToArray();
            this.edge = edge;
        }

        public void Seach(int a, int d)
        {
            dis[a] = d++;
            for (int i = 0; i < edge[a].Count; i++)
            {
                if (dis[edge[a][i]] == int.MaxValue)
                {
                    Seach(edge[a][i], d);
                }
            }
        }

        public int Dis(int a)
        {
            return dis[a];
        }
    }
}

Measured memory_bytes: 36220
#include <stdio.h>
const int N = 15;

int main()
{
    int n;

    scanf("%d", &n);
    int S[N] = {0}, H[N] = {0}, C[N] = {0}, D[N] = {0}, num;
    char card;

    for (int i = 0; i < n; i++)
    {
        scanf(" %c %d", &card, &num);
        if (card == 'S')
            S[num]++;
        if (card == 'H')
            H[num]++;
        if (card == 'C')
            C[num]++;
        if (card == 'D')
            D[num]++;
    }
    for (int i = 1; i <= 13; i++)
    {
        if (S[i] == 0)
            printf("S %d\n", i);
    }
    for (int i = 1; i <= 13; i++)
    {
        if (H[i] == 0)
            printf("H %d\n", i);
    }
    for (int i = 1; i <= 13; i++)
    {
        if (C[i] == 0)
            printf("C %d\n", i);
    }
    for (int i = 1; i <= 13; i++)
    {
        if (D[i] == 0)
            printf("D %d\n", i);
    }
    return 0;
}


Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,ans=0;
cin >>n;
if (n/1000==2)ans++;
if((n%1000)/100==2 )ans++;
if((n%100)/10==2)ans++;
if(n%10==2)ans++;
cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int main(void)
{
	int a,i;
	int t=0;
	FOR(i,0,3){
		scanf("%d",&a);
		t=t*10+a;
	}
	if(t%4==0) puts("YES");
	else puts("NO");
	return 0;
}


Measured memory_bytes: 128