akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+18;

Int n, q;
Int a[100005];
Int x[100001];

int main() {
    ios::sync_with_stdio(false);   
    cin >> n >> q;
    a[0] = -INF;
    a[n + 1] = INF;
    for (Int i = 1; i <= n; i++) cin >> a[i];
    for (Int i = 0; i < q; i++) cin >> x[i];
    vector<Int> c(n + 1, 0), d(n + 1, 0);
    for (Int i = 1; i <= n; i++) c[i] = a[i];
    for (Int i = n; i > 1; i--) c[i - 1] += c[i];
    if (n % 2 == 1) {
        for (Int i = 1; i <= n; i++) d[i] = i % 2 == 1 ? a[i] : a[i - 1];
    }
    else {
        for (Int i = 2; i <= n; i++) d[i] = i % 2 == 0 ? a[i] : a[i - 1];
    }
    for (Int i = 1; i <= n - 2; i++) d[i + 2] += d[i];
    for (Int i = 0; i < q; i++) {
        Int l = 0;
        Int r = n + 1;
        while (abs(r - l) > 1) {
            Int mid = (l + r) / 2;
            Int cur = mid;
            Int A = (n + cur) / 2;
            Int B = cur + 1;
            // cout << l << " " << r << endl;
            if (abs(x[i] - a[cur]) <= abs(a[A] - x[i])) {
                r = mid;
            }
            else {
                l = mid;
            }
            
            //cout << endl;
        }
        //cout << l << " " << r << endl;
        //cout << c[r + (n - l) / 2] << " " << d[l] << endl;
        dump(c[r + (n - l) / 2] + d[l]);
    }
    return 0;
}

Measured memory_bytes: 4864
# -*- coding: utf-8 -*-
"""
Created on Sat May 25 20:54:22 2019

@author: Yamazaki Kenichi
"""

A,B = map(int,input().split())

if A >= 13:
    print(B)
elif A > 5:
    print(B//2)
else:
    print(0)

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

int main()
{
    long A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    if ((V-W)*T >= abs(A-B))
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	map<string, int> mp;
	rep(i,n) {
		string s; cin >> s;
		mp[s]++;
	}
	printf("AC x %d\n", mp["AC"]);
	printf("WA x %d\n", mp["WA"]);
	printf("TLE x %d\n", mp["TLE"]);
	printf("RE x %d\n", mp["RE"]);
	return 0;
}


Measured memory_bytes: 3728
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int mod = 1e9+7;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}
const int N = 1e6+5;
int arr[N];

int32_t main(){
   
   speed_cubing

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

   int a[n];

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

   int si = 1,ei = 1e9,ans = 1e9;


   while(si<=ei){
        
        int mid = (si+ei)/2;

        int cnt = 0;

        for(int i=0;i<n;i++){
           cnt += a[i]/mid - (a[i]%mid==0); 
        }

        if(cnt>k)
          si = mid+1;
        else 
          ei = mid-1,ans = mid;  

   }   


   cout<<ans;
   
  

   return 0;
}

Measured memory_bytes: 5196
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{
    string str;
    cin >> str;
    int cnt[30];
    for (int i=0; i<30; ++i) cnt[i] = 0;

    for (int i=0; i<str.size(); ++i)
    {
        cnt[str[i]-'a'] += 1;
    }
    bool isBeautiful = true;
    for (int i=0; i<26; ++i)
    {
        if(cnt[i] % 2 != 0) isBeautiful = false;
    }
    if(isBeautiful) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
P = [0] * M
S = [""] * M
for i in range(M):
    p, s = input().split()
    P[i] = int(p)
    S[i] = s
ACP = [[0,0] for _ in range(N)]
for i in range(M):
    if ACP[P[i]-1][1] == 1:
        pass
    elif S[i] == "WA":
        ACP[P[i]-1][0] += 1
    else:
        ACP[P[i]-1][1] = 1
ac = 0
pena = 0
for i in range(N):
    ac += ACP[i][1]
    pena += ACP[i][0] * ACP[i][1]
print(ac, pena)


Measured memory_bytes: 23568
s = list(input())
t = list(input())

roop_count = len(s) - len(t) + 1
score = -1

for i in range(roop_count):
    match = 0
    for j,v in enumerate(s[i:len(t)+i]):
        if t[j] == v:
            match += 1
    if match > score:
        score = match

print(len(t) - score)


Measured memory_bytes: 9096
#include <iostream>

using namespace std;

char b;

int main()
{

    cin >> b;
    if (b == 'A') cout << "T" << endl;
    if (b == 'T') cout << "A" << endl;
    if (b == 'C') cout << "G" << endl;
    if (b == 'G') cout << "C" << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c;
  while(cin>>a>>b>>c){
    if(a==0&&b==0&&c==0) break;
  int ans[a+b+c+1];
  for(int i=1;i<=a+b+c;i++) ans[i] = 2;
  int n;
  cin >> n;
  int ag[n],bg[n],cg[n],r[n];
  for(int i=0;i<n;i++){
    cin >> ag[i] >> bg[i] >> cg[i] >> r[i];
    if(r[i]==1) ans[ag[i]] = ans[bg[i]] = ans[cg[i]] = 1;
  }
  for(int i=0;i<n;i++){
    if(r[i]==0){
      if(ans[ag[i]]==2&&ans[bg[i]]==1&&ans[cg[i]]==1) ans[ag[i]] = 0;
      if(ans[ag[i]]==1&&ans[bg[i]]==2&&ans[cg[i]]==1) ans[bg[i]] = 0;
      if(ans[ag[i]]==1&&ans[bg[i]]==1&&ans[cg[i]]==2) ans[cg[i]] = 0;
    }
  }
  for(int i=1;i<=a+b+c;i++) cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 1176
import java.util.*;

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

        int N = scanner.nextInt();

        int[] C = new int[N];
        int[] S = new int[N];
        int[] F = new int[N];

        for(int i=0; i<N-1; i++){
            C[i] = scanner.nextInt();
            S[i] = scanner.nextInt();
            F[i] = scanner.nextInt();
        }

        for(int s=0; s<N; s++){
            if(s == N-1){
                System.out.println(0);
                return;
            }

            int cnt = 0;
            for(int i=s; i<N-1; i++){

                if(cnt < S[i]){
                    cnt = S[i];
                    cnt += C[i];
                }else if(cnt % F[i] == 0){
                    cnt += C[i];
                }else{
                    cnt += F[i] - (cnt % F[i]);
                    cnt += C[i];
                }
            }

            System.out.println(cnt);
        }


    }
}


Measured memory_bytes: 28756
#include<stdio.h>

int main(void){

int a,b,c,d,e,min=5000;

scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
scanf("%d",&e);

if(min>a+d-50){
min=a+d-50;
}
if(min>a+e-50){
min=a+e-50;
}
if(min>b+d-50){
min=b+d-50;
}
if(min>b+e-50){
min=b+e-50;
}
if(min>c+d-50){
min=c+d-50;
}
if(min>c+e-50){
min=c+e-50;
}

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

return 0;
}


Measured memory_bytes: 2116
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 要素の入力、格納
		int N = sc.nextInt();
		long m = 0;
		long a = 0;
		long r = 0;
		long c = 0;
		long h = 0;
		String head = "";

		for (int i = 0; i < N; i++) {
			head = sc.next().substring(0, 1);
			if (head.equals("M")) {
				m++;
			} else if (head.equals("A")) {
				a++;
			} else if (head.equals("R")) {
				r++;
			} else if (head.equals("C")) {
				c++;
			} else if (head.equals("H")) {
				h++;
			}
		}

		long ans = m * a * r + m * a * c + m * a * h + m * r * c + m * r * h + m * c * h + a * r * c + a * r * h
				+ a * c * h + r * c * h;

		// 出力
		System.out.println(ans);
	}
}


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

int main() {
  string S;
  cin >> S;
  int c = 1;
  if(S.size() % 2 == 0) {
    c = 0;
    for(int i = 0; i < S.size(); i++) {
      if(i % 2 == 0 && S.at(i) != 'h') c++;
      else if(i % 2 == 1 && S.at(i) != 'i') c++;
    }
  }
  if(c != 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import math
N = int(input())
al = []
for _ in range(N):
    al.append(list(map(int,input().split())))
comb = 1
for i in range(1,N+1):
    comb *= i
combnum = comb//((N*(N-1))/2)
sumlen = 0
for i in range(N):
    for j in range(i,N):
        sumlen += math.sqrt((al[i][0]-al[j][0])**2+(al[i][1]-al[j][1])**2)*(combnum/N*2)

print(sumlen/combnum)


Measured memory_bytes: 38472
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(X, K, D):
    X = abs(X)
    a = X // D
    if a >= K:
        return X - K * D
    r = X % D
    K -= a
    if K % 2 == 0:
        return r
    else:
        return D - r


def main():
    # parse input
    X, K, D = map(int, input().split())
    print(solve(X, K, D))


# tests
T1 = """
6 2 4
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
2
"""

T2 = """
7 4 3
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
1
"""

T3 = """
10 1 2
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
8
"""

T4 = """
1000000000000000 1000000000000000 1000000000000000
"""
TEST_T4 = """
>>> as_input(T4)
>>> main()
1000000000000000
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()


Measured memory_bytes: 62004
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>

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

using namespace std;
typedef pair<int, int> pint;

int main() {
    int n, r;
    cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n)<< endl;
}


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

using namespace std;
const long INF=(long) 1e17;
vector<long> a;
vector<vector<long>> dp;
vector<vector<long>> sum;

int main(){
	int n,idx,i,j;
	cin>>n;
	a.assign(n+1,0);
	dp.assign(n+1,vector<long> (n+1,-1));	
	sum.assign(n+1,vector<long> (n+1,0));
	//dp[i][j] is minm cost of combining intervel i,j
	for( i=0;i<n;i++) cin>>a[i];
	for(i=n-1;i>=0;i--){
		for(j=i;j<n;j++){
			if(i==j) {
				sum[i][j]=a[i];
				dp[i][j]=0;
			}
			else if(j==i+1) {
				sum[i][j]=sum[i][j-1]+a[j];
				dp[i][j]=sum[i][j];
			}
			else { 
			  sum[i][j]=sum[i][j-1]+a[j];
			  long minm=INF;
			 
			  for(int y=i;y<j;y++){
				  minm=min(minm,dp[i][y]+dp[y+1][j]);
			//:	 dp[i][j]=sum[i][j]+min(dp[i][j-1],dp[i][j-2]+dp[j-1][j]);
			  }
			  dp[i][j]=sum[i][j]+minm;

			}
			//:cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
		}
	}
	cout<<dp[0][n-1];




	return 0;
}



Measured memory_bytes: 2816
#include <stdio.h>

int main()
{
	char b;
	scanf("%c", &b);
	if (b == 'A') printf("T\n");
	else if (b == 'T') printf("A\n");
	else if (b == 'C') printf("G\n");
	else printf("C\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1564
#include <iostream>
using namespace std;
int main(){
  while(true){
    int n,m,t,p;
    cin>>n>>m>>t>>p;
    if(n==0&&m==0){
      if(t==0&&p==0){
        break;
      }
    }
    int Ori[64][64]={{0}};
    for (int y=0;y<m;y++){
      for(int x=0;x<n;x++){
        Ori[y][x]=1;
      }
    }
    for(int i=0;i<t;i++){
      int d,c;
      cin>>d>>c;
      if(d==1){
        for(int x=0;x<c;x++){
          for(int y=0;y<m;y++){
            Ori[y][2*c-1-x]+=Ori[y][x];
            Ori[y][x]=0;
          }
        }
        for(int x=0;x<n;x++){
          for(int y=0;y<m;y++){
            Ori[y][x]+=Ori[y][x+c];
            Ori[y][x+c]=0;
          }
        }
      }else{
        for(int x=0;x<n;x++){
          for(int y=0;y<c;y++){
            Ori[2*c-1-y][x]+=Ori[y][x];
            Ori[y][x]=0;
          }
        }
        for(int x=0;x<n;x++){
          for(int y=0;y<m;y++){
            Ori[y][x]+=Ori[y+c][x];
            Ori[y+c][x]=0;
          }
        }
      }
    }
    for(int i=0;i<p;i++){
      int x,y;
      cin>>x>>y;
      cout<<Ori[y][x]<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3068
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

from collections import deque
q = deque()
q.append([0,0,0,0,0])
mp = []
while q:
    depth, a, b, c, mcnt= q.pop()
    if depth == N:
        mp.append(abs(A-a)+abs(B-b)+abs(C-c)+mcnt*10-30 if min(a,b,c) > 0 else 10**9)
    else:
        q.append([depth+1, a, b, c,mcnt])
        q.append([depth+1, a+l[depth], b, c,mcnt+1])
        q.append([depth+1, a, b+l[depth], c,mcnt+1])
        q.append([depth+1, a, b, c+l[depth],mcnt+1])

print(min(mp))


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

int main() {
	long long int m, n;
	cin >> m >> n;
	if (m > 0)
    	cout << "Positive" << endl;
	else if (m <= 0 && 0 <= n)
    	cout << "Zero" << endl;
	else {
    	if ((n - m) % 2 != 0) {
        	cout << "Positive" << endl;
        } else {
        	cout << "Negative" << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(a-c)<=d) {
        cout << "Yes" << endl;
    } else if(abs(a-b)<=d && abs(b-c)<=d) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
    
}

Measured memory_bytes: 256
class Node:
    def __init__(self,parent = -1,childs = []):
        self.p = parent
        self.c = childs


def main():
    n = int(input())
    t = [Node() for _ in range(n)]
    for i in range(n):
        b = list(map(int,input().split()))
        t[b[0]].c = b[2:]
        for d in b[2:]:t[d].p = b[0]

    def depth(i):
        res = 0
        while t[i].p!=-1:
            i = t[i].p
            res+=1
        return res

    for i in range(n):
        print('node %d: parent = %d, '%(i,t[i].p),end='')
        print('depth = %d, '%depth(i),end='')
        if t[i].p==-1      :print ('root,',t[i].c)
        elif len(t[i].c)!=0:print ('internal node,',t[i].c)
        else               :print ('leaf,',t[i].c)

if __name__ == '__main__':
    main()




Measured memory_bytes: 35692
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 ll = long long;

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

ll A, B;
ll K = 50;
bool fld[110][110];

int main()
{
  scanf( "%lld%lld", &A, &B );

  rep( i, 2*K ) rep( j, 2*K )
    fld[i][j] = i<K ? 0 : 1;

  int cnt = 0;

  rep( i, K ) rep( j, 2*K ) if( !(i&1) )
  {
    bool fl = !fld[i][j];

    rep( d, 4 )
    {
      int ni = i+dy[d], nj = j+dx[d];

      if( ni >= 0 && ni < 2*K && nj >= 0 && nj < 2*K )
        fl &= !fld[ni][nj];
    }

    if( fl && cnt < A-1 )
    {
      fld[i][j] = 1;
      ++cnt;
    }

    if( cnt >= A-1 )
      goto end;
  }
end:;

  cnt = 0;

  repi( i, K, 2*K ) rep( j, 2*K ) if( !(i&1) )
  {
    bool fl = fld[i][j];

    rep( d, 4 )
    {
      int ni = i+dy[d], nj = j+dx[d];

      if( ni >= 0 && ni < 2*K && nj >= 0 && nj < 2*K )
        fl &= fld[ni][nj];
    }

    if( fl && cnt < B-1 )
    {
      fld[i][j] = 0;
      ++cnt;
    }

    if( cnt >= B-1 )
      goto end2;
  }

end2:;

  puts( "100 100" );

  rep( i, 2*K )
  {
    rep( j, 2*K )
      printf( "%c", fld[i][j] ? '.' : '#' );

    puts("");
  }

  return 0;
}

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

int main() {
    string s;
    cin >> s;
    
    if (s == "Sunny") {
        cout << "Cloudy" << endl;
    }
    else if (s == "Cloudy") {
        cout << "Rainy" << endl;
    }
    else {
        cout << "Sunny" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int ,int> pi;
typedef pair<ll ,ll> pl;
typedef map<ll ,ll> ml;
#define modulo 1000000007
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N=1e6+1;


void solve()
{ 
    ll n,m,k;
    cin >> n >> m >> k;
    vector<ll>a(n),b(m),A,B;
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<m;i++)cin >> b[i];
    A.emplace_back(0);
    B.emplace_back(0);
    for(int i=0;i<n;i++)A.emplace_back(a[i]+A[i]);
    for(int i=0;i<m;i++)B.emplace_back(b[i]+B[i]);
    ll count=0,i=0,j=m;
    while(i<=n)
    {
        if(A[i]>k)break;
        while(B[j]>k-A[i])j--;
        count=max(count,i+j);
        i++;
    }
    cout << count << endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fast;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 11068
#include <iostream>
#include <iterator>
#include <functional>
#include <algorithm>

using std::cin;
using std::cout;

const int MaxN = 100005;

int n, arr[MaxN];

int main() {
	cin.sync_with_stdio(false);
	cin >> n;
	std::copy_n(std::istream_iterator<int>(cin), n, arr);
	std::sort(arr, arr + n, std::greater<int>());
	arr[n] = 0;
	int p = 0;
	while (arr[p + 1] > p + 1) ++p;
	int q = p;
	while (arr[q + 1] == p + 1) ++q;
	int a = arr[p] - p;
	int b = q - p + 1;
	cout << ((a & b & 1) ? "Second" : "First") << '\n';
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i=0;i<(int)(n);++i)
template <typename T> ll gcd(T a, T b) {return b?gcd(b, a%b):a;}
template <typename T> ll lcm(T a, T b) {return a * b / gcd(a, b);};
template <typename T> inline void chmin(T &a, const T& b){if(a>b)a=b;}
template <typename T> inline void chmax(T &a, const T& b){if(a<b)a=b;}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> vec = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int k; cin >> k;
  cout << vec[k - 1] << '\n';
}


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

int main() {
	int N;
	int A[1010];

	cin >> N;
	int count = 0;
	int j = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 0) {
			if (A[i] % 3 != 0 && A[i] % 5 != 0) {
				cout << "DENIED" << endl;
				j = 1;
				break;
			}
		}
	}

	if (j != 1) {
		cout << "APPROVED" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m; cin >> n >> m;
  vector<bool> v(n,true);
  vector<int> b(n);
  int a = 0,w = 0;
  int c; string s;
  for(int i=0;i<m;i++){
      cin >> c >> s;
      if(v[c-1]){
          if(s == "AC"){
              v[c-1] = false;
              a++;
              w += b[c-1];
          }else{
              b[c-1]++;
          }
      }
  }
  cout << a << " " << w << endl;
}

Measured memory_bytes: 3660
#include<iostream>
#include<vector>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

int main(){
  li v[7];
  rep(i,7) cin >> v[i];
  if(df)print(v[0]+v[1]+v[3]+v[4]);
  li s=v[1];
  if(v[0] && v[3] && v[4]){
    int f=(v[0]&1)+(v[3]&1)+(v[4]&1);
    if(f>=2){
      s+=3; v[0]--; v[3]--; v[4]--;      
    }
  }
  s+=v[0]/2*2;
  s+=v[3]/2*2;
  s+=v[4]/2*2;
  print(s);
}


Measured memory_bytes: 256
n = int(input())
ab_list = list(list(map(int,input().split())) for i in range(n))
sort_list = sorted(ab_list, key=lambda x: x[1])
sum_time = sort_list[0][0]
for i in range(1,len(ab_list)):
  if sum_time <= sort_list[i-1][1]:
    sum_time += sort_list[i][0]
  else:
    print("No")
    break
else:
  if sum_time <= sort_list[-1][1]:
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 55260
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main(){
  string a[3];
  cin >> a[0] >> a[1] >> a[2];
  int nxt=0;
  while(!(a[0].size()==0&&nxt==0) && !(a[1].size()==0&&nxt==1) && !(a[2].size()==0&&nxt==2)){
    int now=nxt;
    nxt = (int)(a[nxt][0]-'a');
    a[now].erase(0,1);
  }
  if(a[0].size()==0&&nxt==0){ cout << "A" <<endl; return 0; }
  if(a[1].size()==0&&nxt==1){ cout << "B" <<endl; return 0; }
  if(a[2].size()==0&&nxt==2){ cout << "C" <<endl; return 0; }
  return 0;
}


Measured memory_bytes: 256
n,*t=map(int,open(0).read().split())
A=sorted(t[0::2])
B=sorted(t[1::2])
if n%2==0:
    kl=n//2-1
    kr=n//2
else:
    kl=n//2
    kr=n//2
lm,lM=A[kl],A[kr]
rm,rM=B[kl],B[kr]
L,R=0,0
if n%2==0:
    L=lm+lM
    R=rm+rM
    a=R-L+1
else:
    a=rm-lm+1
print(a)

Measured memory_bytes: 134840
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector <int>
#define vl vector <long long>
#define pb push_back
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s;
	cin>>s;
	int n=s.size();
	ll ans=0,x=0;
	for(int i=0;i<n-1;i)
	{
		if(s[i]=='A')
		{
			x++;
			i++;
		}
		else if(s[i]=='B')
		{
			if(s[i+1]=='C')
				ans+=x;
			else if(s[i+1]=='A')
				x=1;
			else
				x=0;
			i+=2;
		}
		else
		{
			x=0;
			i++;
		}
	}
	cout<<ans<<endl;
}

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

int w,h,c;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
char fld[128][128];
bool vst[128][128];


void dfs(int y, int x)
{
	vst[y][x] = 1;
	for(int i=0; i<4; i++)
	{
		int nx = x+dx[i];
		int ny = y+dy[i];
		
		if(fld[y][x]==fld[ny][nx])
		if(!vst[ny][nx])
		{
			dfs(ny,nx);
		}
	}
}

int main()
{
	while(cin >> h >> w, h||w)
	{
		memset(vst,0,sizeof(vst));
		for(int y=0; y<h; y++)
		{
			cin >> fld[y];
		}

		c=0;

		for(int y=0; y<h; y++)
		for(int x=0; x<w; x++)
		{
			if(!vst[y][x])
			{
				c++;
				dfs(y,x);
			}
		}
		cout << c << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		String W, T = "";
		int count = 0;

		Scanner sc = new Scanner(System.in);
		W = sc.next();
		while (T.compareTo("END_OF_TEXT") != 0) {
			T = sc.next();
			if (W.compareToIgnoreCase(T) == 0) {
				++count;
			}
		}
		System.out.println(count);
		sc.close();
	}
}



Measured memory_bytes: 26152
program semi_common_multiple
    implicit none
    integer(16):: n, m, i
    integer(16), allocatable:: a(:)
    integer(16):: gcd, lcm

    read*, n, m
    allocate(a(n))
    read*, a(:)
    a(:) = a(:) / 2_16

    do while(mod(a(1), 2) == 0)
        do i=1, n
            if(mod(a(i),2) /= 0) call die
            a(i) = a(i) / 2
        end do
        m = m / 2
    end do

    do i = 1, n
        if (mod(a(i), 2) == 0) call die
    end do

    lcm = 1

    do i=1,n
        gcd = calc_gcd(lcm,a(i))
        lcm = lcm/gcd*a(i)
    end do

    print*, (m/lcm+1_16)/2_16

contains
recursive function calc_gcd(a,b) result(ret)
integer(16):: a, b, ret
    if (mod(a,b) == 0)then
        ret = b
    else
    ret = calc_gcd(b,mod(a,b))
    endif
end function

subroutine die
    print*, 0
    stop
end subroutine
end program

Measured memory_bytes: 2432
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };
       

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            List<char> ans = new List<char>();
            ans.Add(s[0]);
            for (var i = 1; i < N; i++)
            {
                if (s[i] != s[i - 1]) { ans.Add(s[i]); }
            }

            Console.WriteLine(ans.Count());

            

            //Console.Out.Flush();
        }
        


    }

    

    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


Measured memory_bytes: 11872
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""

N = int(sys.stdin.readline())
list_a = list(map(int, sys.stdin.readline().split()))

a_max = max(list_a)
a_min = min(list_a)

ans = []

if (a_max == a_min):
    cnt = 0
elif (math.fabs(a_max) > math.fabs(a_min)):
    # for a in list_a:
    #     a += math.fabs(a_max)
    newList = [item + a_max for item in list_a]
    # print(newList)
    for i in range(N):
        # print(format(list_a.index(max(list_a))+1) + " " + format(i+1))
        ans.append((list_a.index(max(list_a))+1, i+1))

    newList2 = newList
    for i in range(N-1):
        # if (newList2[i] > newList2[i+1]):
            newList2[i+1] += newList2[i]
            ans.append((i+1, i+2))


else:
    # for a in list_a:
    #     a -= math.fabs(a_min)
    newList = [item + a_min for item in list_a]
    for i in range(N):
        # print(format(list_a.index(min(list_a))+1) + " " + format(i+1))
        ans.append((list_a.index(min(list_a))+1, i+1))

    newList2 = newList
    # for i in range(N-1):
    #     if (newList2[(N-1)-i] < newList2[(N-1)-(i+1)]):
    #         newList2[(N-1)-(i+1)] += newList2[(N-1)-i]
    #         # print(format((N-1)-i+1) + " " + format((N-1)-i))
    #         ans.append(((N-1)-i+1, (N-1)-i))
    for i in range(N-1, 0, -1):
        # if (newList2[i] < newList2[i-1]):
            newList2[i-1] += newList2[i]
            ans.append((i+1, i))

# print(list_a)
# print(newList)

print(len(ans))
for i in range(len(ans)):
    s, t = ans[i]
    print(s, t)


Measured memory_bytes: 5076
#include <stdio.h>
 
#define N 100000
 
int partition(int*,int,int);
 
int p, q, r, n;
int A[N];
 
int main(){
 
  int i, judge;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){  
    scanf("%d",&A[i]);
  }
 
  r=n-1;
 
  judge=partition(A,0,r);
 
  printf("%d",A[0]);
 
  for(i=1;i<n;i++){
    if(judge==i)  printf(" [%d]",A[i]);
    else printf(" %d",A[i]);
  }
 
  printf("\n");
 
  return 0;
 
}
 
int partition(int *A,int p,int r){
 
  int x,temp,i,j;
 
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if (A[j]<=x){
      i=i+1;
      temp=A[i];
      A[i]=A[j];
      A[j]=temp;
    }
  }
  temp=A[i+1];
  A[i+1]=A[r];
  A[r]=temp;
 
  return i+1;
}

Measured memory_bytes: 992
from math import log2

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    if K > log2(N)+ 50:
        return print(*[N]*N,sep = " ")
    for _ in range(K):
        imos = [0]*(N + 1)
        for i in range(N):
            imos[max(0,i  - A[i])] += 1
            imos[min(N,i + 1 + A[i])] -= 1
        for j in range(N):
            imos[j+1] += imos[j]
        A = imos[:N].copy()
    print(*A,sep=" ")
    return

if __name__ == "__main__":
    main()

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];

	ll ans = 0;

	F0R(i, N) {
		ans += arr[i] / 2;
		if (i + 1 < N && (arr[i]&1) && arr[i+1]>0) ans++,arr[i+1]--;
	}
	print(ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#include <numeric>

using namespace std;

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

using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;
    int res = 0;
    while (n > 0)
    {
        n /= k;
        res++;
    }
    cout << res << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define chmax(x, y) x = max(x, y)

int dp[3001][3001];

int main() {
  int n, t;
  cin >> n >> t;
  vector<P> p(n);
  rep(i, n) cin >> p[i].first >> p[i].second;
  sort(p.begin(), p.end());
  int ans = 0;
  rep(i, n) {
    rep(j, t) {
      chmax(dp[i + 1][j], dp[i][j]);
      int nj = j + p[i].first;
      if (nj < t) chmax(dp[i + 1][nj], dp[i][j] + p[i].second);
    }
    int now = dp[i][t - 1] + p[i].second;
    chmax(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define io std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define M 1000000007
#define int long long
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define nl "\n"
#define yy "YES\n"
#define nn "NO\n"
using namespace std;
signed main()
{
    io;
    int n;
    cin>>n;
    vector<int>v(n);
    map<int,int>mp;
    for(int i=0;i<n;i++){
        cin>>v[i];
        mp[v[i]]++;
    }
    int fin=0;
    for(auto x:mp){
        int tmp=x.second;
        fin+=(tmp*(tmp-1)/2);
    }
    for(int i=0;i<n;i++){
        int tmp=mp[v[i]],t2=tmp-1;
        cout<<fin-(tmp*(tmp-1)/2)+(t2*(t2-1)/2)<<nl;
    }
}


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

int abs(int a){
  if(a>=0) return a;
  else return -1*a;
}

int main() {
  int n,ans=100,s=0,a=0,b=0,c=0,d=100000000;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
    s+=v[i];
  }
  for(int k=1;k<=n;k++){
    a=0;
    for(int i=0;i<k;i++){
      a+=v.at(i);
    }
    b=s-a;
    c=abs(a-b);
    d=min(c,d);
    if(c!=d) break;
  }
  cout<<d<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    if (a+b<=2*c)
    {
        cout << a*x+b*y << endl;
    }
    else
    {
        if (x>=y)
        {
            if (a>2*c)
            {
                cout << y*(2*c) + (x-y) * (2*c) << endl;
            }
            else
            {
                cout << y*2*c + (x-y) * a << endl;
            }
        }
        else
        {
            if (b>2*c)
            {
                cout << y*2*c << endl;
            }
            else
            {
                cout << x*2*c + (y-x) * b << endl;
            }
            
        }
        
    }
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();

		Set<Integer> foods = new HashSet<Integer>();
		for (int i = 0; i < m; i++) {
			foods.add(i+1);
		}

		Set<Integer> nextFoods = new HashSet<Integer>();
		for (int i = 0; i < n; i++) {
			int k = scanner.nextInt();
			for (int j = 0; j < k; j++) {
				int a = scanner.nextInt();
				if (foods.contains(a)) {
					nextFoods.add(a);
				}
			}
			foods = nextFoods;
			nextFoods = new HashSet<Integer>();
		}

		System.out.println(foods.size());

	}

}


Measured memory_bytes: 25092
def c_Otoshidama_C(N, Y):
    import math
    # a,b,cをそれぞれ1万円札/5千円札/千円札の枚数とする
    t = (Y - 1000 * N) // 1000  # 不定方程式 9a+4b=t を解く
    # 不定方程式の解はa=4k+t,b=-9k-2tとなる。
    # 問題の条件から、left<=rightとなれば非負整数解a,b,cが存在する。
    left = max(math.ceil(-t / 4), math.ceil(-(N + t) / 5))
    right = math.floor(-2 * t / 9)
    if left <= right:
        k = left
        a = 4 * k + t
        b = -9 * k - 2 * t
        c = N - a - b
        return '{} {} {}'.format(a, b, c)
    else:
        return '-1 -1 -1'

N,Y = [int(i) for i in input().split()]
print(c_Otoshidama_C(N, Y))

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    string s;
    li w;
    cin >> s >> w;
    li n = sz(s);
    li now = 0;
    while (now < n) {
        cout << s[now];
        now += w;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[110000];

// DP テーブル
long long dp[110000];

int main() {
    int N, K; cin >> N >> K;
    for (int i = 0; i < N; ++i) cin >> h[i];

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 110000; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        for (int j = 1; j <= K; ++j) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    // 答え
    cout << dp[N-1] << endl;
}  
        

Measured memory_bytes: 1920
s = input()

def func(s):
  dict = {}
  for i in s:
    dict[i] = 0
  for i in s:
    dict[i] += 1
  for k in dict:
    if not dict[k] == 2:
      print("No")
      return False
  print("Yes")
  return True

func(s)

Measured memory_bytes: 2940
a = gets.split.map(&:to_i).sort

penki = 0
char = nil

for i in 0...a.size
	if char.nil?
		char = a[i]
		penki += 1
	end

	if char != a[i]
		char = a[i]
		penki += 1
	end
end

puts penki

Measured memory_bytes: 1788
#include <iostream>
using namespace std;
int main(){
long long a,b;cin>>a>>b;
long long min=1,max=a;
while(b--){
    long long x,y;cin>>x>>y;
    if(x>min&&x<=a)min=x;
    if(y<max&&y>=1)max=y;
}
if(max-min+1<=0)cout<<0;
else cout<<max-min+1;
}

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

typedef long long int ll;
//Factors of an num
/*
vector<ll> fact(ll n){
	vector<ll>v;
	for(int i=1;i*i<=n;i++){
		if(n%i ==0){
			v.push_back(i);
		
		if(i!=n/i)
			v.push_back(n/i);
	    }
	}

	return v;
}
*/


/*
Seive Of Eratos..
int N=1e5;
vector<bool> isprime(N+1,true);
void pri(int n){
	for(int i=2;i*i<=n;i++){
		if(isprime[i]){
			for(int j=i*i;j<=n;j+=i){
				isprime[j]=false;
			}
		}
	}
	return;
}
*/

/*
//Prime Factors
vector<bool> isprime(1e6+1,true);
 vector<int> primes;
 void sieve()
 {

    ll  i,j;
    isprime[0] = false;
    isprime[1] = false;

    for(i=2; i<=1e6 ;i++)
  {

    if(isprime[i])
    {

      primes.push_back(i);

      for(j=i*i; j<=1e6; j+=i)
      {
        isprime[j]=false;
      }

    }

  }
}

vector<int> primefactors(int  N)

 {

    vector<int> factors;
    ll pf_idx = 0, pf=primes[pf_idx];

    while(pf*pf<=N)
    {
        while(N % pf == 0)
        {
            N/=pf;
            factors.push_back(pf);
        }
        pf = primes[++pf_idx];
    }
    
    if(N != 1) factors.push_back(N);
    return factors;
}
 */   




int main(){
	 
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  int x;
  cin>>x;
  if(x>=30)
  	cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
 }




Measured memory_bytes: 3632
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;

int main(void){
	int n;
	int a,b;
	int hyo[11][11];
	while(1){
		cin >> n;
		if(n==0)break;
		for(b=0;b<=n;b++){
			for(a=0;a<=n;a++){
				hyo[a][b]=0;
			}
		}
		for(b=0;b<n;b++){
			for(a=0;a<n;a++){
				cin >> hyo[a][b];
				hyo[n][b]+=hyo[a][b];
			}
		}
		for(b=0;b<=n;b++){
			for(a=0;a<n;a++){
				hyo[b][n]+=hyo[b][a];
			}
		}
		for(b=0;b<=n;b++){
			for(a=0;a<=n;a++){
				cout << setw(5) << hyo[a][b];
			}
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++)
#define dec(i, l, r) for (int i = l; i >= r; i--)

const int maxn = 1e6 + 5;

int t, n, k[maxn], l[maxn], r[maxn];
ll ans;
vector<int> pre[maxn], suff[maxn];

int main() {
    scanf("%d", &t);
    while (t--) {
        scanf("%d", &n);
        inc(i, 1, n) scanf("%d%d%d", &k[i], &l[i], &r[i]);
        ans = 0;
        inc(i, 1, n) pre[i].clear(), suff[i].clear();
        inc(i, 1, n) {
            if (l[i] > r[i]) {
                pre[k[i]].push_back(l[i] - r[i]);
                ans += r[i];
            } else if (l[i] < r[i] && k[i] < n) {
                suff[k[i] + 1].push_back(r[i] - l[i]);
                ans += l[i];
            } else
                ans += l[i];
        }
        priority_queue<int, vector<int>, greater<int> > que;
        inc(i, 1, n) {
            for (int elem : pre[i]) que.push(elem);
            while (que.size() > i) {
                //ans -= que.top();
                que.pop();
            }
        }
        while (que.size()) {
            ans += que.top();
            que.pop();
        }
        dec(i, n, 1) {
            for (int elem : suff[i]) que.push(elem);
            while (que.size() > n - i + 1) {
                //ans -= que.top();
                que.pop();
            }
        }
        while (que.size()) {
            ans += que.top();
            que.pop();
        }
        cout << ans << "\n";
    }
}

Measured memory_bytes: 57624
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())

dp = [[0]*2 for _ in range(N)]
# -, +
dp[0][0] = -As[0]
dp[0][1] = As[0]
for i in range(1, N-1):
    a = As[i]
    dp[i][0] = max(dp[i-1][0]+a, dp[i-1][1]-a)
    dp[i][1] = max(dp[i-1][0]-a, dp[i-1][1]+a)

dp[-1][0] = dp[-2][0]-As[-1]
dp[-1][1] = dp[-2][1]+As[-1]

print(max(dp[-1]))

Measured memory_bytes: 98984
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>
ll a[100005];
ll try1(ll i, ll n, ll dp[], ll k)
{
	if(dp[i]!=-1)
		return dp[i];
	if(i==n-1)
	{
		dp[i] = 0;
		return dp[i];
	}
	ll j;
	ll mini = abs(a[i]-a[i+1])+try1(i+1,n,dp,k);	
	for(j=2;j<=k;j++)
	{
		if(i+j>=n)
			break;
		mini =  min(mini,abs(a[i] - a[i+j]) + try1(i+j,n,dp,k));
	}
	dp[i] = mini;
	return dp[i];
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,n,k;
	cin>>n>>k;
	ll dp[100005];
	for(i=0;i<100005;i++)
		dp[i]=-1;

	for(i=0;i<n;i++)
		cin>>a[i];
	cout<<try1(0,n,dp,k)<<endl;
	return 0;
}	

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
const ll INFL = 1LL << 60;

struct Edge{
    int to;
    long long cost;
    Edge(int to,long long cost):to(to),cost(cost){}
};
using EdgeList = std::vector<std::vector<Edge>>;

//コストが負の平路を含む場合要素ゼロで返す
//ret[i] == INFならiには到達不可
vector<ll> bellmanford(int start, const EdgeList &G, vector<ll> dist = {}){
    int n = G.size();
    if(dist.size() == 0) {
        dist.resize(n, INFL);
        dist[start] = 0;
    }
    rep(cnt,n){
        bool updated = false;
        rep(i,n){
            for(Edge e : G[i]){
                if(dist[i] != INFL and dist[e.to] > dist[i] + e.cost){
                    dist[e.to] = dist[i] + e.cost;
                    updated = true;
                    // if( cnt == n-1 ) return {};
                }
            }
        }
        if(not updated) break;
    }
    return dist;
}

class Solver {
  public:
    bool solve() {
        int N, M; cin >> N >> M;
        EdgeList E(N);
        rep(i, M) {
            int a, b, c; cin >> a >> b >> c;
            a--; b--; 
            E[a].push_back(Edge(b, -c));
        }
        auto res = bellmanford(0, E);
        auto res2 = bellmanford(0, E, res);
        if(res[N-1] != res2[N-1]) cout << "inf" << endl;
        else cout << -res[N - 1] << endl;
        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 384