akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int N,M;
vector<int> g[100100];
int S,T;
int dist[3][100100];

void solve(int s){
    for(int i=0;i<3;i++){
        for(int j=0;j<N;j++){
            dist[i][j]=-1;
        }
    }
    queue<pair<int,int>> que;
    que.push({0,s});
    dist[0][s]=0;
    while(!que.empty()){
        pair<int,int> p=que.front(); que.pop();
        int parity=p.first;
        for(auto v:g[p.second]){
            //cout << parity << v << endl;
            if(dist[(parity+1)%3][v]!=-1) continue;
            dist[(parity+1)%3][v]=dist[parity][p.second]+1;
            que.push({(parity+1)%3,v});
        }
    }
}

int main(){
    cin >> N >> M;
    for(int i=0;i<M;i++){
        int u,v; cin >> u >> v;
        u--;v--;
        g[u].push_back(v);
    }
    cin >> S >> T; S--,T--;
    solve(S);
    if(dist[0][T]==-1){
        cout << -1 << endl;
    }else{
        cout << dist[0][T]/3 << endl;
    }
    
}

Measured memory_bytes: 6912
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){
    int h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    m1 += 60 * h1;
    m2 += 60 * h2;

    P(m2 - m1 - k);
    return  0;
}


Measured memory_bytes: 3580
import sys
import math
import copy

def multiply(N, AList):
    Multiply = 1
    for Num in range(N):
        if(AList[Num] == 0):
            return 0
    for Num in range(N):
        Multiply *= AList[Num]
        if(Multiply > 10**18):
            return -1
    return Multiply


if(__name__ == "__main__"):

    N = int( input().strip() )
    AList_Str = input().strip().split()
    AList = [0] * N
    for Num in range(N):
        AList[Num] = int( AList_Str[Num] )


    Multiplies = multiply(N, AList)
    print(Multiplies)


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

using namespace std;

typedef long long LL;
typedef vector<int>    VI;
typedef vector<bool>   VB;
typedef vector<string> VS;

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int a, b, c;
VI used;

bool check (int t) {
	rep (i, used.size()) {
		if (t == used[i]) return true;
	}
	return false;
}

int main(void) {
	cin >> a >> b >> c;
	int t = 0;
	int h = 0;
	int ans = -1;
	while (1) {
		if (check(t)) break;
		if (t <= c && c <= t + a) {
			ans = t + h * 60 + (c - t);
			break;
		}
		used.PB(t);
		t += a;
		t += b;
		h += t >= 60? 1 : 0;
		t %= 60;
	}
	cout << ans << endl;
    return 0;
}

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

string field[12];

void solve( int x, int y ){
	field[y][x] = '0';
	if( x>0 && field[y][x-1]=='1' )
		solve( x-1, y );
	if( x<11 && field[y][x+1]=='1' )
		solve( x+1, y );
	if( y>0 && field[y-1][x]=='1' )
		solve( x, y-1 );
	if( y<11 && field[y+1][x]=='1' )
		solve( x, y+1 );
}

int main(){
	string in;
	do{
		for( int i=0; i<12; i++ ){
			getline(cin, field[i]);
		}
		int count = 0;
		for( int y=0; y<12; y++ ){
			for( int x=0; x<12; x++ ){
				if( field[y][x] == '1' ){
					solve( x, y );
					count++;
				}
			}
		}
		cout << count << endl;
	}while(getline(cin, in));
	return 0;
}

Measured memory_bytes: 1188
'use strict';

function Main(input) {
  const N = input.split("");
  let answer = [];

  for (let val of N) {
    if (val == 1) {
      answer.push(9);
    } else if (val == 9) {
      answer.push(1);
    }
  }

  console.log(answer.join(""))

};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 21064
#include <iostream>
#include <string>

using namespace std;

char v[10] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};
int a[15] = {0};

void func(int i, int n, int mx) {
    if (i == n) {
        for (int j = 0; j < n; j++) 
            cout << v[a[j]];
        cout << endl;
    }
    else {
        for (int j = 0; j <= mx+1; j++) {
            a[i] = j;
            func(i+1, n, max(mx, a[i]));
        }
    }
}

int main() {
    int n;  cin >> n;
    func(1, n, 0);
    return 0;
}

Measured memory_bytes: 1536
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<climits>
#include<iostream>
#include<map>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f
typedef long long ll;

using namespace std;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, W;
    cin >> N >> W;
    // dp[i, j]
    long long dp[2][W + 1];
    memset(dp, 0, sizeof dp);
    vector<int> ws(N), vs(N);
    for(int i = 0; i < N; ++i) {
        cin >> ws[i] >> vs[i];
    }
    for(int i = 1; i <= N; ++i) {
        int cur = i & 1;
        int pre = 1 - cur;
        for(int j = 1; j <= W; ++j) {
            dp[cur][j] = dp[pre][j];
            if(j >= ws[i - 1]) {
                dp[cur][j] = max(dp[cur][j], dp[pre][j - ws[i - 1]] + vs[i - 1]);
            }
        }
    }
    cout << dp[N & 1][W] << endl;
    return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int n;
    string s[50];
    cin >> n;
    imfor(i, n) {
        cin >> s[i];
    }
    int minc[26];
    fill(minc, minc + 26, 99);
    imfor(i, n) {
        map<char, int> mp;
        imfor(j, s[i].size()) {
            mp[s[i][j]] += 1;
        }
        imfor(j, 26) {
            char c = 'a' + j;
            if (mp[c] < minc[j]) {
                minc[j] = mp[c]; 
            }
        }
    }
    imfor(i, 26) {
        char c = 'a' + i;
        imfor(j, minc[i]) {
            cout << c;
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
def f(n):
    if (n+1) % 4 == 0:
        return 0
    elif (n+1) % 4 == 1:
        return n
    elif (n+1) % 4 == 2:
        return 1
    else:
        return n +1
a, b = map(int, input().split())

print(f(a-1) ^ f(b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string n;
    cin>>n;
    int sum = 0;
    for(int i=0;i<n.length();i++){
        sum+=n[i]-48;
    }
    if(stoi(n)%sum==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
	return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  
  int x=0;
  while(b<=a){
    b*=2;
    x++;
  }
  while(c<=b){
    c*=2;
    x++;
  }
  if(x<=k) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
//#include <vector>
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pii = pair<int, int>; // これ以降 pii という型名はpair<int, int> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
  unsigned long long h,w;
  cin>>h>>w;
  if(h==1||w==1)cout<<1<<endl;
  else if(h%2==0)    cout<<h/2*w<<endl;
  else if(w%2==0) cout<<w/2*h<<endl;
  else cout<<ll(h*0.5*w+1)<<endl;
  
}

Measured memory_bytes: 256
import math
A, B, H, M = map(int, input().split())
k = (60 * H - 11 * M)/2
if abs(k) > 180:
    cos = math.cos(math.radians(360-k))
else:
    cos = math.cos(math.radians(k))

a2 = A**2 + B**2 - 2* A* B* cos

print(a2**0.5)


Measured memory_bytes: 9532
using System;
using System.Collections.Generic;
using static System.Math;
using System.Linq;
using System.Text;
 
class DandA {
    static void Main(string[] args) {
        int n = ReadLineInt();
        long[] aArr = ReadLineLongArray();
        long[] bArr = ReadLineLongArray();
        long rtn = 0;
        for (int i = 0; i < n;i++) {
            if ((aArr[i] + aArr[i + 1]) >= bArr[i]) {
                rtn += bArr[i];
                if (aArr[i] < bArr[i]) {aArr[i + 1] -= bArr[i] - aArr[i];}
            } else {
                rtn += aArr[i] + aArr[i + 1];
                aArr[i + 1] = 0;
            }
        }
        Console.WriteLine(rtn);
    }
 
    static string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
    static string[] strAry = new string[] {"L", "R", "U", "D"};
    static int[] intArray = new int[10];
    static List<int> intList = new List<int>();
  
    static private string ReadLineStr() {return Console.ReadLine();}
    static private int ReadLineInt() {return int.Parse(Console.ReadLine());}
    static private long ReadLineLong() {return long.Parse(Console.ReadLine());}
    static private double ReadLineDouble() {return double.Parse(Console.ReadLine());}
    static private string[] ReadLineStrArray() {return Console.ReadLine().Trim().Split();}
    static private int[] ReadLineIntArray() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToArray();}
    static private long[] ReadLineLongArray() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToArray();}
    static private double[] ReadLineDoubleArray() {return Console.ReadLine().Trim().Split().Select(a => double.Parse(a)).ToArray();}
    static private decimal[] ReadLineDecimalArray() {return Console.ReadLine().Trim().Split().Select(a => decimal.Parse(a)).ToArray();}
    static private List<int> ReadLineIntList() {return Console.ReadLine().Trim().Split().Select(a => int.Parse(a)).ToList();}
    static private List<long> ReadLineLongList() {return Console.ReadLine().Trim().Split().Select(a => long.Parse(a)).ToList();}
    static private string[][] ReadMLineStrArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split()).ToArray();}
    static private int[][] ReadMLineIntArray(int arg) { return new int[arg].Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).ToArray();}
 
    static private bool IsPrime(int num) {
        if (num < 2) return false;
        if (num == 2) return true;
        else if (num % 2 == 0) return false;
        double sqrtNum = Math.Sqrt(num);
        for (int i = 3; i <= sqrtNum; i += 2) {
            if (num % i == 0) return false;
        }
        return true;
    }
  
    static private string IntToNString(int x, int n) {
        var nstring = "";
        var numbers = new string[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
        int r = 1;
        int q = x;
        while (q > 0) {
            r = q % n;
            nstring += numbers[r];
            q = q / n;
        }
        return string.Join("",nstring.Reverse());
     }
}

Measured memory_bytes: 33780
from collections import deque

n,q=map(int,input().split())
time=deque()
name=deque()
inst=[]*2
finish_time=0
time_inst=0
name_inst=0
string=""
for i in range(n):
    inst=input().split()
    name.append(inst[0])
    time.append(int(inst[1]))


while len(time)!=0:
    name_inst=name.popleft()
    time_inst=time.popleft()
    if time_inst<=q:
        finish_time+=time_inst
        string=name_inst+" "+str(finish_time)
        print(string)
    else:
        finish_time+=q
        time.append(time_inst-q)
        name.append(name_inst)



Measured memory_bytes: 9724
def yes?(s)
  return false if s.length.odd?

  half = s.length / 2
  s[0, half] == s[half, half]
end

s = gets.chomp
(s.length - 1).downto(1) do |i|
  if yes?(s[0, i])
    puts s[0, i].length
    exit
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
// #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);i++)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}
const ll inf = 1LL<<60;

ll n,W;
ll dp[110][110000];
vector<ll> w(110);
vector<ll> v(110);

int main(){
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);
  cin>>n>>W;
  rep(i,n){
    cin>>w[i]>>v[i];
  }
  
  rep(i,110000){
    dp[0][i]=inf;
  }

  dp[0][0]=0;
  for(int i=0;i<n;i++){
    ll now_w=w[i];
    ll now_v=v[i];
    for(int j=0;j<110000;j++){
      if(now_v<=j){
        dp[i+1][j]=min(dp[i][j],dp[i][j-now_v]+now_w);
      }else{
        dp[i+1][j]=dp[i][j];
      }
    }
  }

  ll ans=0;
  
  for(int i=0;i<110000;i++){
    if(dp[n][i]<=W){
      ans=i;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 88320
//

#include <iostream>
#include <list>
#include <map>
using namespace std;

int main(int argc, const char * argv[]) {
    
    int N = 0;
    int count = 0;
    int resultCount = 0;
    int nameSaveCount = 0;
    string nameSave[200000] = {};
    list<string> list = {};
    string s = "";
    map<string,int> result;
    
    //入力
    cin >> N;
    for (int i = 0; i < N ; i++) {
        cin >> s;
        list.push_front(s);
    }
    list.push_front("zzzzzzzzzzzzzzzzz");
    list.sort();
    string monitoringS = list.front();
    
    //カウント処理
    for (int i = 0; i < N + 1; i++) {
        s = list.front();
        list.pop_front();
    
        if (monitoringS == s) {
            count++;
        }else{
            nameSave[nameSaveCount] = monitoringS;
            nameSaveCount++;
            result[monitoringS] = count;
            if (resultCount < count) {
                resultCount = count;
            }
            count = 1;
            monitoringS = s;
        }
    }
    
    

    //書かれた回数が多いものを出力する処理。
    for (int i = 0; i < nameSaveCount; i++) {
        if (resultCount == result[nameSave[i]]) {
            cout << nameSave[i] + "\n";
        }
    }

    return 0;
}


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

int main()
{
  int a, b;
  while (cin >> a >> b, a){

    int n;
    cin >> n;

    int d[32][32] = {0};
    for (int i = 0; i < n; i++){
      int x, y;
      cin >> x >> y;
      d[x][y] = -1;
    }

    d[1][1] = 1;
    for (int i = 1; i < a + 1; i++){
      for (int j = 1; j < b + 1; j++){
        d[i][j] = (d[i][j] == -1 ? 0 : d[i][j] + d[i - 1][j] + d[i][j - 1]);
      }
    }

    cout << d[a][b] << endl;
  }
}

Measured memory_bytes: 3068
n, m = gets.split.map{|v|
      v.to_i
}
a = Array.new
b = Array.new

for i in 1..n
  a[i-1] = gets.split(" ").map(&:to_i)
end

for k in 1..m
  b[k-1] = gets.to_i
end

for i in 1..n
  c = 0
  for j in 1..m
    c += a[i-1][j-1] * b [j-1]
  end
  print c, "\n"
end


Measured memory_bytes: 6984
n = int(input())
ans = list(input())

for i in range(n - 1):
    s = list(input())
    tmp = []
    for i in range(len(s)):
        if s[i] in ans:
            tmp.append(s[i])
            ans.remove(s[i])
    ans = tmp
    
ans.sort()
print(''.join(ans))

Measured memory_bytes: 3060
from itertools import combinations
n = int(input())
s = input()
nrgb = [[0 for i in range(3)] for j in range(n+1)]
for i in range(1,n+1):
  for j in range(3):
    nrgb[i][j] = nrgb[i-1][j]
  if s[i-1] == "R":
    nrgb[i][0] += 1
  elif s[i-1] == "G":
    nrgb[i][1] += 1
  else:
    nrgb[i][2] += 1
ans = 0
for i,j in combinations(range(n-1),2):
  if s[i] == s[j]:
    continue
  jdg = 3
  for sk in s[i],s[j]:
    if sk == "G":
      jdg -= 1
    elif sk == "B":
      jdg -= 2
  ans += nrgb[n][jdg]-nrgb[j][jdg]
  if 2*j-i <= n-1 and s[2*j-i] != s[i] and s[2*j-i] != s[j]:
    ans -= 1
print(ans)

Measured memory_bytes: 74836
# -*- coding:utf-8 -*-

"""解法
公式PDF

A_1＋ A_2 ＋ ... A_N = X_1 + X_2 + ... + X_N = S とする

(X_i + X_{i+1})/2 = A_i より

X_i + X_{i+1} = 2A_i

X1 = S - (X_2 + ... + X_N)
   = S - 2(A_2 + A_4 + A_{N-1})

これにより、X_1, X_2 ... を順に求めればよいが、O(N^2)は難しい

そこでO(N)で解くために

X_i + X_{i+1} = 2A_i より
X_{i+1} = 2 * A_i - X_i

の漸化式をつくれるので、それを解く
"""
import sys


def solve():
    N = int(sys.stdin.readline())
    As = list(map(int, sys.stdin.readline().split()))

    S = sum(As)
    Xs = [0]*N
    # 初期状態を決める(Xs[0])
    Xs[0] = S - 2 * sum(As[1:N:2])

    for i in range(N-1):
        Xs[i+1] = 2*As[i] - Xs[i]

    print(*Xs)


if __name__ == "__main__":
    solve()


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

using namespace std;

typedef long long ll;

// if i and j is connected
bool connected[10][10];

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, M; cin >> N >> M;
  for(int i=0;i<M;i++){
    int a, b; cin >> a >> b;
    connected[a][b] = true;
    connected[b][a] = true;
  }
  int p[N-1];
  int cnt = 0;
  for(int i=0;i<N-1;i++) p[i] = i+2;
  do{
    int prev = 1;
    bool flag = true;
    for(int i=0;i<N-1;i++){
      if(!connected[prev][p[i]]){
        flag = false;
        break;
      }
      prev = p[i];
    }
    if(flag) cnt++;
  }while(next_permutation(p, p+(N-1)));
  cout << cnt << endl;
}

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

/* snippet: useful macros and functions */
#define ARC(i, a, b) for(Int i = (a); i < (b); ++i)
#define RC(i, n) ARC(i, 0, n)
#define ARCH(i, a, b) for(Int i = (a) - 1; i >= (b); --i)
#define RCH(i, n) ARCH(i, n, 0)
template<class T> T ant(const T &a, const T &b){ return a > b ? a : b; }
template<class T> T ont(const T &a, const T &b){ return a < b ? a : b; }
template<class T> T rng(const T &a, const T &b){ return a < b ? b - a : a - b; }
template<class T> void th(T &a, const T &b, T (*f)(const T &, const T &)){ a = f(a, b); }
#define anth(a, b) th(a, b, ant)
#define onth(a, b) th(a, b, ont)

/* snippet: modint library */
template<class T, int MOD>
class Modint{
	T val;
public:
	Modint(T val = 0) : val(val) {}
	operator T(){ return val; }
	Modint &operator+=(const Modint &a){ val += a.val; if(val >= MOD) val -= MOD; return *this; }
	Modint &operator-=(const Modint &a){ val -= a.val; if(val < 0) val += MOD; return *this; }
	Modint &operator*=(const Modint &a){ val = val * a.val % MOD; return *this; }
	void inverse(){T x[2]={MOD,val},a[2]={0,1};int i;for(i=0;x[!i];i^=1){a[i]-=x[i]/x[!i]*a[!i];x[i]=x[i]%x[!i];}if(!i)a[i]+= MOD;val=a[i];}
	Modint &operator/=(Modint a){ a.inverse(); return *this *= a; }
	friend Modint modpow(Modint a, int n){ Modint ret(1); while(n){ if(n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
	friend Modint operator+(Modint a, const Modint &b){ return a += b; }
	friend Modint operator-(Modint a, const Modint &b){ return a -= b; }
	friend Modint operator*(Modint a, const Modint &b){ return a *= b; }
	friend Modint operator/(Modint a, const Modint &b){ return a /= b; }
	friend std::ostream &operator<<(std::ostream &os, const Modint &a){ return os << a.val; }
};

/* snippet: using declarations */
using Int = long long;
using std::cout;
using std::cin;
using std::endl;
using Mint = Modint<long long, 1000000007>;

int n;
int count[212345];

int main(){
	cin >> n;
	ARC(i, 1, n){
		int a;
		cin >> a;
		++count[a - 1];
	}
	RC(i, n){
		cout << count[i] << endl;
	}
}


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

typedef long long ll;
ll n, k, a[100005], flag;
ll sum, ans;

int main() {
    scanf("%lld%lld", &n, &k);
    a[0] = -1;
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
        if (a[i] >= 0 && a[i - 1] < 0) flag = i;
    }
    if (!flag) flag = n + 1;
    // cout << flag << endl;
    ans = 1e18;
    if (flag + k - 1 <= n) {
        ans = min(ans, a[flag + k - 1]);
    }
    if (flag - k > 0) {
        ans = min(ans, -a[flag - k]);
    }
    /*for (int i = flag - 1; i > 0; i--) {
        int j = k + i - 1;
        if (j < flag || j > n) continue;
        ans = min(ans, min(2 * (-a[i]) + a[j], 2 * a[j] - a[i]));
    }*/
    for (int i = 1; i < flag; i++) {
        int j = i + k - 1;
        if (j < flag || j > n) continue;
        ans = min(ans, min(-a[i] - a[i] + a[j], a[j] * 2 - a[i]));
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
n = int(input())


if n == 3:
    print('2 5 63')
    exit()

ans = [2, 4, 3, 9]
n -= 4
for x in range(8, 30001, 6):
    if n < 2:
        break
    ans.append(x)
    ans.append(x+2)
    n -= 2

for x in range(15, 30001, 12):
    if n < 2:
        break
    ans.append(x)
    ans.append(x+6)
    n -= 2

for x in range(6, 30001, 6):
    if n <= 0:
        break
    ans.append(x)
    n -= 1

ans.sort()
print(*ans)
#print(sum(ans))

Measured memory_bytes: 4596
use std::cmp::{max, min};

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut pv = vec![0i32; n];
    for i in 0..n - 1 {
        pv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    pv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    for i in 1..n - 1 {
        let max_p = max(pv[i - 1], pv[i + 1]);
        let min_p = min(pv[i - 1], pv[i + 1]);
        if min_p < pv[i] && pv[i] < max_p {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <stack>
#include <string>

using namespace std;

typedef long long LL;

char s[11][11] = {
     "SUN","MON","TUE","WED","THU","FRI","SAT"
};

int main() {
    char j[20];
    scanf("%s", j);
    for (int i = 0; i < 7; ++i)
        if (!strcmp(s[i],j)) cout << 7-i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

#define INF (1<<31-1)
#define ll long long

int A, B, C, X, Y;

ll calc(int a, int b, int c){
	return (ll)a*A + (ll)b*B + (ll)c*C;
}

int main(){

	long long cost = (ll)INF;

	cin >> A >> B >> C >> X >> Y;

	cost = min(cost, calc(X, Y, 0));
	cost = min(cost, calc(0, 0, 2*max(X,Y)));
	if (X>Y)
		cost = min(cost, calc(X-Y, 0, 2*Y));
	else
		cost = min(cost, calc(0, Y-X, 2 * X));


	cout << cost << endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
template<typename tn> void read(tn &a){
    tn x=0,f=1;char c=' ';
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar() ) x=x*10+c-'0';
    a=x*f;
}
template<typename tn> void print(tn a){
    if(a<0) putchar('-'),a=-a;
    if(a>9) print(a/10);
    putchar(a%10+'0');
}
#define ll __int128
ll n;
ll a[25],b[25],c[25]; 
int v=-666;
ll ans;
int main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]);
	for(int i=1;i<=n;i++) read(b[i]);
	for(int i=2;i<=n;i++) read(c[i]);
	for(int i=1;i<=n;i++){
		ans+=b[a[i]];
		if(v==a[i]-1) ans+=c[a[i]];
		v=a[i];
	}
	print(ans);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const ll mod=1e9+7;

int main(){
	ll A,B;
	cin >> A >> B;
	if((A+B)%2==0){
		cout << (A+B)/2 << endl;
	}else{
		cout << "IMPOSSIBLE" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        int[] count = new int[n + 1];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
            count[a[i]]++;
        }

        // 主処理
        long[] combination = new long[n + 1];
        long[] diff = new long[n + 1];
        for (int i = 0; i < a.length; i++) {
            combination[i + 1] += calcCombination(count[i + 1], 2);
            int num = a[i];
            diff[i] = calcCombination(count[num], 2) - calcCombination(count[num] - 1, 2);
        }
        long sum = Arrays.stream(combination).sum();
        for (int i = 0; i < a.length; i++) {
            System.out.println(sum - diff[i]);
        }

        // 出力
        sc.close();
    }

    public static long calcCombination(int n, int m) {
        if (n < m || m < 0) {
            return 0;
        }
        long c = 1;
        m = (n - m < m ? n - m : m);
        for (int ns = n - m + 1, ms = 1; ms <= m; ns++, ms++) {
            c *= ns;
            c /= ms;
        }
        return c;
    }
}


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

#define ll long long

ll nya(stack<ll> minus, stack<ll> plus, int mc, int pc) {
    if(mc == 0) {
        ll n1 = plus.top();
        plus.pop();
        ll n2 = plus.top();
        plus.pop();
        minus.push(n1 - n2);
        pc -= 2;
        mc++;
    }
    for(;1 <= mc && 1 < pc;pc--) {
        ll n = minus.top() - plus.top();
        minus.pop();
        plus.pop();
        minus.push(n);
    }
    ll po = plus.top();
    for(;0 < mc;mc--) {
        po -= minus.top();
        minus.pop();
    }
    return po;
}

ll mya(stack<ll> minus, stack<ll> plus, int mc, int pc) {
    if(mc == 0) {
        ll n1 = plus.top();
        plus.pop();
        ll n2 = plus.top();
        plus.pop();
        minus.push(n1 - n2);
        pc -= 2;
        mc++;
        cout << n1 << " " << n2 << endl;
    }
    for(;1 <= mc && 1 < pc;pc--) {
        ll n1 = minus.top();
        ll n2 = plus.top();
        minus.pop();
        plus.pop();
        minus.push(n1 - n2);
        cout << n1 << " " << n2 << endl;
    }
    ll po = plus.top();
    for(;0 < mc;mc--) {
        cout << po << " " << minus.top() << endl;
        po -= minus.top();
        minus.pop();
    }
    return po;
}

int main() {
    int N;
    vector<ll> A;
    vector<ll> A_cp;
    cin >> N;
    A.resize(N);
    int minus_count = 0;
    int plus_count = 0;
    for(int i = 0;i < N;i++) {
        cin >> A[i];
        if(0 < A[i]) {
            plus_count++;
        }
        if(A[i] <= 0) {
            minus_count++;
        }
    }
    sort(A.begin(), A.end());
    if(N == 2) {
        cout << A[1] - A[0] << endl;
        cout << A[1] << " " << A[0] << endl;
        return 0;
    }
    copy(A.begin(), A.end(), back_inserter(A_cp));

    stack<ll> minus;
    stack<ll> plus;
    int pre = 0;

    if(plus_count == 0) {
        ll x = A_cp[N - 1] - A_cp[0];
        A_cp[N - 1] = x;
        pre = 1;
    }

    for(int i = pre;i < minus_count - pre;i++) {
        minus.push(A_cp[i]);
    }
    for(int i = N - 1;minus_count - pre <= i;i--) {
        plus.push(A_cp[i]);
    }

    cout << nya(minus, plus, minus_count - pre*2, plus_count + pre) << endl;

    if(pre) {
        cout << A[N - 1] << " " << A[0] << endl;
    }
    mya(minus, plus, minus_count - pre*2, plus_count + pre);
    return 0;
}

Measured memory_bytes: 5108
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong();
    long B = sc.nextLong();
    long C = sc.nextLong();
    long ans1 = Math.abs((A / 2 - (A - A / 2)) * B * C);
    long ans2 = Math.abs(A * (B / 2 - (B - B / 2)) * C);
    long ans3 = Math.abs(A * B * (C / 2 - (C - C / 2)));
    long ans = Math.min(Math.min(ans1, ans2), ans3);
    System.out.println(ans);
  }
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair



int main(){
    string s; cin>>s;
    ll N = s.size();
    ll K; cin >> K;
    REP(i,N-1){
        ll temp = ('z'+1-s[i])%('z'+1-'a');
        if(temp<=K){
            s[i] = 'a';
            K -= temp;
        }else{
            continue;
        }
    }
    K %= ('z'+1-'a');
    ll temp = ('z'+1-s[N-1])%('z'+1-'a');
    if(temp<=K){
        s[N-1] = ('a' + K - temp);
    }else{
        s[N-1] = (char)(s[N-1]+K);
    }
    cout << s << "\n";
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int> 
using namespace std ; 
signed main(){
    fast;
    int n;
    cin>>n;
    if(n>=30) cout<<"Yes";
    else cout<<"No";
}


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

int main() {
  int n, h, nh, c = 0, ans = 0;
  cin >> n >> h;
  for (int i = 1; i < n; i++) {
    cin >> nh;
    if (h >= nh) {
      c++;
    } else {
      if (ans < c) {
        ans = c;
      }
      c = 0;
    }
    h = nh;
  }
  if (ans < c) {
    ans = c;
    c = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    ll n,k,ans=-1e10;
    cin>>n>>k;
    vector<int> v(n+2);
    for(int i=1;i<=n;i++) cin>>v[i];

    for(int i=0;i<=k&&i<=n;i++){
        for(int j=0;i+j<=k&&i+j<=n;j++){
            ll tmp=0;
            priority_queue<int,vector<int>,greater<int>> que;
            for(int l=1;l<=i;l++){
                tmp+=v[l];
                if(v[l]<0) que.push(v[l]);
            }
            for(int r=1;r<=j;r++){
                tmp+=v[n-r+1];
                if(v[n-r+1]<0) que.push(v[n-r+1]);
            }
            if(!que.empty()){
                int cnt=i+j;
                while(!que.empty() && cnt<k){
                    tmp-=que.top();
                    que.pop();
                    cnt++;
                }
            }
            ans=max(ans,tmp);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int count = 0;
    for(int i=1;i<n-1;i++){
        if(p[i-1] < p[i] && p[i] < p[i+1] || p[i-1] > p[i] && p[i] > p[i+1]){
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	ll N,t,ANS=0;
	vector<ll>MON,YU;
	cin>>N;
	rep(i,N+1){
		cin>>t;
		MON.push_back(t);
	}
	rep(i,N){
		cin>>t;
		YU.push_back(t);
	}
	rep(i,N){
		if(MON[i]<=YU[i]){
			ANS=ANS+MON[i];
			YU[i]=YU[i]-MON[i];
			MON[i]=0;
			if(MON[i+1]<=YU[i]){
				ANS=ANS+MON[i+1];
				YU[i]=YU[i]-MON[i+1];
				MON[i+1]=0;
			}
			else{
				ANS=ANS+YU[i];
				MON[i+1]=MON[i+1]-YU[i];
				YU[i]=0;
			}
		}
		else{
			ANS=ANS+YU[i];
			YU[i]=0;
			MON[i]=MON[i]-YU[i];
		}
	}
	cout<<ANS<<endl;
}

Measured memory_bytes: 2548
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <vector>
using namespace std;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


const int DIRS = 4;
const int DR[DIRS] = {-1,  0, +1,  0};
const int DC[DIRS] = { 0, +1,  0, -1};

int N;
vector<vector<int>> dist;
vector<vector<bool>> remaining;

bool valid(int r, int c) {
    return 0 <= r && r < N && 0 <= c && c < N;
}

void propagate(int row, int col, int new_dist) {
    assert(new_dist < dist[row][col]);
    dist[row][col] = new_dist;

    for (int dir = 0; dir < DIRS; dir++) {
        int nr = row + DR[dir];
        int nc = col + DC[dir];

        if (valid(nr, nc) && new_dist + remaining[nr][nc] < dist[nr][nc])
            propagate(nr, nc, new_dist + remaining[nr][nc]);
    }
}

void decrement(int row, int col) {
    remaining[row][col] = false;
    propagate(row, col, dist[row][col] - 1);
}

int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    cin >> N;
    dist.assign(N, vector<int>(N));
    remaining.assign(N, vector<bool>(N, true));

    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            dist[i][j] = min({i, N - 1 - i, j, N - 1 - j});

    int total = 0;

    for (int i = 0; i < N * N; i++) {
        int p;
        cin >> p;
        p--;
        int row = p / N, col = p % N;
        total += dist[row][col];

        if (dist[row][col] > 0)
            dbg(row, col, dist[row][col]);

        decrement(row, col);
    }

    cout << total << '\n';
}


Measured memory_bytes: 19580
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    c = Counter(A)
    v = list(sorted(c.values()))
    if len(v) <= K:
        print(0)
        return
    print(sum(v[:-K]))






if __name__ == '__main__':
    main()


Measured memory_bytes: 32672
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    for(int i=0;i<s.length();i+=2)
        cout<<s[i];
    cout<<endl;
    
    
    return 0;   
}




 
 


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N, K;
  cin >> K >> N;
  vector< int > A(N);
  cin >> A;
  vector< int64 > D;
  for(int i = 1; i < N; i++) {
    D.emplace_back(A[i] - A[i - 1]);
  }
  D.emplace_back(A[0] + K - A[N - 1]);
  int64 sum = accumulate(begin(D), end(D), 0LL);
  int64 ret = infll;
  for(auto &p : D) chmin(ret, sum - p);
  cout << ret << "\n";
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,n) for(int i=0;i<n;++i)
#define pie 3.141592653589793238462643383279
#define mod 1e9+7
int x[100000];
signed main(){
	int a,b,ans=0,cnt=0,z=0,vz=0;
	string s;
	bool bo=false;
	cin>>a>>b>>s;
	f(i,a){
		if(vz>=b) bo=true;
		if(s[i]=='1'||(i<a-1&&s[i+1]=='0')){
			x[vz]++;
			if(s[i]=='0'&&bo)cnt++;
			if(i<a-1&&s[i]=='1'&&s[i+1]=='0'&&bo){
				cnt+=x[vz];
				ans=max(ans,cnt);
				cnt-=x[z];
			}
		}
		else{
			if(!bo){
				x[vz]++;
				cnt+=x[vz];
				vz++;
			}
			else{
				x[vz]++;
				cnt++;
				x[z]=0;
				vz=z;
				z=(z+1)%(b+1);
			}
		}
	}
	cnt+=x[vz];
	cout<<max(cnt,ans)<<endl;
}


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

typedef long long ll;

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll h = 0, s = 0;
    rep(i, N) {
        if (h > A[i]) {
            s += h - A[i];            
        } else {
            h = A[i];
        }
    }
    cout << s << "\n";
}

Measured memory_bytes: 4828
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=100;
const int M=6401;
const int Y=6400;
bitset<M*2> dp[N][N];
int n,m;
int a[N][N],b[N][N];
int main()
{
    //freopen("H:\\c++1\\in.txt","r",stdin);
    //freopen("H:\\c++1\\out.txt","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)scanf("%d",&b[i][j]);
    dp[1][0][Y]=1;dp[0][1][Y]=1;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++){
        int cha=abs(a[i][j]-b[i][j]);
        dp[i][j]|=((dp[i-1][j]<<cha)|(dp[i-1][j]>>cha));
        dp[i][j]|=((dp[i][j-1]<<cha)|(dp[i][j-1]>>cha));
    }
    int ans=inf;
    for(int i=0;i<M*2;i++){
        if(dp[n][m][i])ans=min(ans,abs(i-Y));
    }
    printf("%d\n",ans);
    return 0;
}    

Measured memory_bytes: 14080
from itertools import product
H, W = list(map(int, input().split()))
S = [['.'] * (W + 2)] + [['.', ] + list(input()) + ['.', ] for _ in range(H)] + [['.'] * (W + 2)]
ans = [[0] * W for _ in range(H)]
for i, j in product(range(1, H + 1), range(1, W + 1)):
    if S[i][j] == '.':
        count = 0
        for k, l in product(range(i - 1, i + 2), range(j - 1, j + 2)):
            if k == i and l == j:
                continue
            elif S[k][l] == '#':
                count += 1
        ans[i - 1][j - 1] = str(count)
    else:
        ans[i - 1][j - 1] = '#'
[print(''.join(a)) for a in ans]

Measured memory_bytes: 3188
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        n++;
        int count = 0;
        int count1 = 0;
        int count2 = 0;
        int count3 = 0;
        while(n-->0){
            String s = sc.nextLine();
            if(s.contains("AC")){
                count++;
            }
            else if(s.contains("WA")){
                count1++;
            }
            else if(s.contains("TLE")){
                count2++;
            }
            else if(s.contains("RE")){
                count3++;
            }

        }
        System.out.println("AC" + " x " + count);
        System.out.println("WA" + " x " + count1);
        System.out.println("TLE" + " x " + count2);
        System.out.println("RE" + " x " + count3);
    }
}

Measured memory_bytes: 61188
H, W = map(int, input().split())
g = [input() for _ in range(H)]
white = 0
black = 0
for i in range(H):
    for j in range(W):
        if g[i][j] == '#':
            black += 1
        else:
            white += 1
start = (0, 0)
goal = (H-1, W-1)
S = [start]
T = {start: 1}
while S and goal not in T:
    S2 = []
    for x, y in S:
        for pos in [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]:
            x2, y2 = pos
            if 0<= x2 <= H-1 and 0<= y2 <= W-1:
                if g[x2][y2] != '#' and pos not in T:
                    T[pos] = T[(x, y)] + 1
                    S2.append(pos)
    S = S2
if goal not in T:
    print(-1)
else:
    print(white - T[goal])

Measured memory_bytes: 3316