akhauriyash/Code-Regression huggingface dataset:
import itertools
import copy

n = int(input())
indexes = [_ for _ in range(1, n+1)]

def ifCorrect(data, fakes):
    answer_sheet = [-1 for i in range(n+1)]
    for i in fakes:
        answer_sheet[i] = 0

    #このあたりで、fakeでない人の情報とも比較して、正直者の証言がそれらのリストと合致しているかを確認すれば良い
    for i in range(len(data)):
        for j in data[i]:
            if not i in fakes:
                if answer_sheet[j[0]] == -1:
                    if j[1] == 0 and not j[0] in fakes:
                        return False
                    else:
                        answer_sheet[j[0]] = j[1]
                elif not answer_sheet[j[0]] == j[1]:
                    return False
                    
    return True

data = [[] for _ in range(n+1)]
for i in range(n):
    id = int(input())
    for _ in range(id):
        x, y = map(int, input().split(" "))
        data[i+1].append([x,y])

fakePersonCount = 0
flag = True
while fakePersonCount <= n and flag:
    comb = itertools.combinations(indexes, fakePersonCount)
    for fakePeople in comb:
        if ifCorrect(data, fakePeople):
            print(n - fakePersonCount)
            flag = False
            break
    fakePersonCount += 1

if flag:
    print(0)

#[[], [[2, 1], [3, 0]], [[3, 1], [1, 0]], [[1, 1], [2, 0]]]

Measured memory_bytes: 3440
n = input()
s1, s2 = input().split()

s3 = ""
cs1 = 0
cs2 = 0
for i in range(2 * len(s1)):
	if not i % 2:
		s3 += s1[cs1]
		cs1 += 1
	else:
		s3 += s2[cs2]
		cs2 += 1
print(s3)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);
#define loop(n) for (int i = 0; i < n; i++)
#define loopo(i, n) for (int i = 0; i < n; i++)
#define double long double
#define mod 998244353
#define pi 3.1415926535897
#define F first
#define S second
#define pb push_back
#define getvar(x) \
	int x;        \
	cin >> x;
#define getvector(v, n)            \
	vector<int> v(n);              \
	for (int bc = 0; bc < n; bc++) \
	{                              \
		cin >> v[bc];              \
	}

using namespace std;

signed main()
{
	fast;
	int test = 1;
	// cin >> test;
	for (int index = 0; index < test; index++)
	{
		string s;
		cin >> s;
		string ans = s.substr(0, 3);
		cout << ans << endl;
	}
}


Measured memory_bytes: 3652
from sys import exit
import copy
#import numpy as np
#from collections import deque


d, = map(int, input().split())
c= list(map(int, input().split()))
s=[list(map(int, input().split())) for _ in range(d)]
#  t=[int(input()) for _ in range(d)]

sche=[0 for _ in range(d)]
s_tmp=float("inf")*(-1)
for off in range(0,13):
    last=[0 for _ in range(26)]
    sche=[0 for _ in range(d)]
    for day in range(1,d+1):
        idx=day-1
        d_tmp=float("inf")*(-1)
        i_tmp=0
        for t in range(26):    
            delta=0
            l_tmp=copy.copy(last)
            delta+=s[idx][t]
            l_tmp[t]=day
            for l in range(26):
                delta-=0.5*(off+1)*c[l]*((day-l_tmp[l])+(day+off-l_tmp[l]))
            if delta>=d_tmp:
                d_tmp=delta
                i_tmp=t
        
        sche[idx]=i_tmp+1
        # score+=d_tmp
        last[i_tmp]=day
        # print(score)
        # print(i_tmp+1)

    score=0
    last=[0 for _ in range(26)]
    for i in range(1,d+1):
        idx=i-1
        score+=s[idx][sche[idx]-1]
        for l in range(26):
            score-=c[l]*(i-last[l])
        last[sche[idx]-1]=i
    
    # print(score)
    if score>=s_tmp:
        s_tmp=score
        sche_tmp=copy.copy(sche)


for i in sche_tmp:
    print(i)
# print(s_tmp)






Measured memory_bytes: 9552
#include <cstdio>

int main(){
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++){
    char s[1];
    scanf("%c", s);
    if (s[0] == 'Y') {
      printf("Four\n");
      return 0;
    }
  }
  printf("Three\n");
  return 0;
}


Measured memory_bytes: 128
n=int(input())
an=[["AC",0],["WA",0],["TLE",0],["RE",0]]
for i in range(n):
  s=input()
  for j in an:
    if j[0]==s:
      j[1]+=1;break
      
for j in an:
  print(j[0],"x",j[1])

Measured memory_bytes: 9084
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void dfs(vector<vector<int>>&g,vector<vector<int>> &dp,int from,int to,LL &res){
	dp[to][0] = 1;
	dp[to][1] = 1;
	for(auto item:g[to]){
		if(item==from) continue;
		dfs(g,dp,to,item,res);
		dp[to][0] = (1ll*dp[to][0]* (dp[item][0]+dp[item][1]))%MOD;
		dp[to][1] = (1ll * dp[to][1] * dp[item][0])%MOD;
	}
}

void solve(){
	int n;
	cin>>n;
	vector<vector<int>> dp(n+1,vector<int>(2,0));
	vector<vector<int>> g(n+1);
	for(int i=0;i<(n-1);i++){
		int x,y;
		cin>>x>>y;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	LL res = 0ll;
	dfs(g,dp,0,1,res);
	res = (dp[1][0]+dp[1][1])%MOD;
	cout<<res<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 19584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef pair<ll, ll> P;

int main(){
    ll n;
    string s;
        cin >> n >> s;
    ll wc=0, ec=0;
    for(int i=1; i<n; i++){
        if(s[i]=='E') ec += 1;
    }
    ll mini=ec+wc;
    for(int i=1; i<n; i++){
        if(s[i]=='E') ec-=1;
        if(s[i-1]=='W') wc += 1;
        mini = min(wc+ec, mini);
    }
    cout << mini << endl;
}
    

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

int main(){
	int N;
  	cin >> N;
	int p[N];
	for (int i=0;i<N;i++){
		cin >> p[i];
	}
	int k = -1,max = -1;
	for (int i=0;i<N;i++){
		if (p[i] > max){
			k = i;
			max = p[i];
		}
	}
	int sum = 0;
	for (int i=0;i<N;i++){
		if (i == k)
			sum = sum + (p[i]/2);
		else
			sum = sum + p[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin >> n;
		int a[n];
		rep(i,0,n) cin >> a[i];
		int cur = 0;
		rep(i,0,n){
			if(a[i]==cur+1) cur++;
		}
		if(cur==0) cout<<-1;
		else cout<<n-cur;
	}   
}     

Measured memory_bytes: 1792
fun main(args: Array<String>) = yorukatsu22e()

fun yorukatsu22e() {
    operator fun List<Int>.component6() = this[5]
    val (a, b, c, d, e, f) = readLine()!!.split(' ').map { it.toInt() }

    var pair = a * 100 to 0
    var maxPercentage = 0.0

    for (aw in 0..f step a * 100) for (bw in 0..f step b * 100) {
        for (cw in 0..f step c) for (dw in 0..f step d) {
            val sugarWeight = cw + dw
            val waterWeight = aw + bw
            val sumWeight = sugarWeight + waterWeight

            val sugarPerWater = sugarWeight.toDouble() * 100 / waterWeight.toDouble()
            val percentage = sugarWeight.toDouble() * 100 / sumWeight.toDouble()

            if (sumWeight <= f && sugarPerWater <= e.toDouble() && percentage > maxPercentage) {
                maxPercentage = percentage
                pair = sumWeight to sugarWeight
            }
        }
    }

    val answer = "${pair.first} ${pair.second}"

    println(answer)
}


Measured memory_bytes: 38764
#include <stdio.h>
#define whi 0
#define gry 1
#define bla 2
#define MAX 103
void dfs(void );
void sorry_visit(int );


int dt[MAX],ft[MAX],ho,cin,i,j,ku,ver,ru,chi,ko,ri,timeis;
int abc[MAX][MAX]={};
int color[MAX];



int main(){
  
  scanf("%d",&ko);
  for(i=1;i<=ko;i++){
    scanf("%d%d",&chi,&ru);
    for(j=1;j<=ru;j++){
      scanf("%d",&ri);
      abc[chi][ri]=1;
    }
  }
  dfs();
    for(i=1;i<=ko;i++){
      printf("%d %d %d\n",i,dt[i],ft[i]);
    }
    return 0;
    
}



void dfs(void ){
  int cou;
  for(cou=1;cou<=ko;cou++){
    color[cou]=whi;
  }
  timeis=0;
  for(cou=1;cou<=ko;cou++){
    if(color[cou]==whi){
      sorry_visit(cou);
	}
  }
}

void sorry_visit(int user){
  int roop;
  color[user]=gry;
  dt[user]=++timeis;
  for(roop=1;roop<=ko;roop++){
    if(abc[user][roop]==0){continue;}
    if(color[roop]==whi){
      sorry_visit(roop);
    }
  }
  color[user]=bla;
  ft[user]=++timeis;
}



  
      



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

#define ll long long int

int main() 
{ 
    string t, s;
    cin>>s>>t;
    int i=0, j=t.length()-1;
    int min_=1001;
    while(j< s.length()){
        int count = 0, l=0;
        for(int k=i; k<=j; k++){
            if(s[k] != t[l]) count++;
            l++;
        }
        min_ = min(count, min_);
        i++; j++;
    }
    cout<<min_<<"\n";
}

Measured memory_bytes: 3568
#include<iostream>
#include<cmath>
#include<algorithm>
#include<iomanip>
using namespace std;
int n,m,t[1000000]={0};
int main()
{
	int s=0,f=1;
	cin>>n>>m;
	int l[m+1],r[m+1],min=0,max=1000000;
	for(int i=1;i<=m;i++)
	{
		cin>>l[i]>>r[i];
		if(r[i]<min)
		{
			f=0;
			break;
		}
		if(l[i]>max)
		{
			f=0;
			break;
		}
		if(l[i]>min)
		min=l[i];
		if(r[i]<max)
		max=r[i];
	}
	if(f==1)
	cout<<max-min+1;
	else
	cout<<0;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


string solve(int N, vector<string>& a) {
    // map<char, int> st;
    vector<int> st(26, 0x7fffffff);
    rep(i,N){
        vector<int> local(26, 0);
        for (int ch : a[i]) {
            ++local[ch-'a'];
        }
        rep(c,26) st[c] = min(st[c], local[c]);
    }

    vector<char> w;
    rep(c,26){
        rep(i,st[c]) w.pb('a'+c);
    }
    return string(ALL(w));
}

int main() {
    int N;cin >> N;
    vector<string> s(N);
    rep(i,N) cin>>s[i];
    cout << solve(N,s) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter
def input():
    return sys.stdin.readline()[:-1]
def main():
    N, M = map(int,input().split())
    A = list(map(int,input().split()))
    S = [0]*N
    S[0] = A[0]%M
    for k in range(1,N):
        S[k] = (S[k-1] + A[k])%M
    C = Counter(S)
    C[0] += 1
    ans = 0
    for e in C:
        ans += (C[e]*(C[e]-1))//2
    print(ans)
if __name__ == '__main__':
    main()


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 h1,m1,h2,m2,k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    ANS(h2*60+m2-(h1*60+m1)-k);
    return 0;
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int a, b, c,r=0;
  for (int a=0 ;a<=A;a++){
    for (int b=0;b<=B;b++){
      for(int c = 0;c<=C;c++){
        if (X== 500*a + 100*b + 50 *c ){
          r++;}
      }
  }
  }
  cout << r <<endl;
}


 
        

      

    

    
   

        

      
    

  


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

string f(long long n){
    if (n == 0) return "";
    --n;
    return f(n / 26) + string(1, 'a' + n % 26);
}

int main(){
    long long n;
    cin >> n;
    string ans;
    ans = f(n);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define FOR(i,a,n) for(int i=a,i##_len=(int)(n);i<i##_len;++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i=(int)n;i>=0;--i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
    #ifdef int
        #undef INF
        #define INF INFLL
        cerr<<"\x1b[7m"<<"'int' is defined as 'long long' !!!!"<<"\x1b[m"<<endl;
    #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

signed main() {
    int n;
    cin>>n;
    int ans=1;
    const int MOD=1e9+7;
    while(true) {
        ans*=n;
        ans%=MOD;
        n--;
        if(n==0) break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<ctime>
#include<map>
#include<tr1/unordered_map>
using namespace std;
tr1::unordered_map<unsigned long long,int> s;
inline int mabs(int x){if(x<0)return -x;return x;}
inline void swap(char &a,char &b){char tmp;tmp=a,a=b,b=tmp;}
inline int mmin(int a,int b){if(a<b)return a;return b;}
//int pla[16][2]={{4,4},{1,1},{1,2},{1,3},{1,4},{2,1},{2,2},{2,3},{2,4},{3,1},{3,2},{3,3},{3,4},{4,1},{4,2},{4,3},};
unsigned long long nod[16];
unsigned long long to;
int val(){
	int ret=0;
	for(int i=0;i<4;++i)
		for(int j=0;j<4;++j){
			if(!nod[i*4+j]) continue;
			ret+=mabs(i-(nod[i*4+j]-1)/4)+mabs(j-(nod[i*4+j]-1)%4);
		}
	return ret;
}
int ans=50,limit;
void dfs(int pos,int step){
	if(step+val()>=ans||step+val()>limit)	return;
	unsigned long long zt=0;
	for(int i=0;i<16;i++) zt=(zt+(nod[i]<<(i*4)));
	if(s[zt]!=0&&s[zt]<=step) return;
	s[zt]=step;
	if(zt==to) ans=mmin(ans,step);
	else{
		if(pos<12)  swap(nod[pos],nod[pos+4]),dfs(pos+4,step+1),swap(nod[pos],nod[pos+4]);
		if(pos>3)	swap(nod[pos],nod[pos-4]),dfs(pos-4,step+1),swap(nod[pos],nod[pos-4]);
		if(pos%4!=0)	swap(nod[pos],nod[pos-1]),dfs(pos-1,step+1),swap(nod[pos],nod[pos-1]);
		if(pos%4!=3)	swap(nod[pos],nod[pos+1]),dfs(pos+1,step+1),swap(nod[pos],nod[pos+1]);
	}
}
int main(){
	unsigned long long tmp=1;
	for(unsigned long long i=0;i<15;i++){
		to=to+((i+1)<<(i*4));
	}
	int sta;
	for(int i=0,tmp;i!=4;++i)
		for(int j=0;j!=4;++j){
			cin>>nod[i*4+j];
			if(!nod[i*4+j]) sta=i*4+j;
		}
 	int sav;
	for(int i=0;i!=46;++i){
		s.clear();
		sav=ans;
		limit=i,dfs(sta,0);
		if(ans<sav){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 22344
#include<bits/stdc++.h>
using namespace std;
main(){
  string s;
  while(getline(cin,s),s!="END OF INPUT"){
    for(int i=0,n=0,l=s.size();i<=l;i++){
      if(i==l||s[i]==' '){cout<<n;n=0;}
      else n++;
    }cout<<endl;
  }
}

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

using namespace std;

#define MAX 100001
#define INF (1<<29)
typedef pair<int,int> pii;

int field[MAX],N,dist[MAX];

bool inField(int x){
  return 0 <= x && x < N;
}

int dijkstra(int s){
  priority_queue<pii,vector<pii>,greater<pii> > Q;
  Q.push(pii(dist[s],s));
  while(!Q.empty()){
    pii p = Q.top(); Q.pop();
    int v = p.second;
    if(dist[v] < p.first) continue;
    if(field[v] == 0){
      for(int i = 0 ; i < 6 ; i++){
        int next = v+i+1;
        if(!inField(next)) continue;
        if(dist[v] + 1 < dist[next]){
          dist[next] = dist[v] + 1;
          Q.push(pii(dist[next],next));
        }
      }
    }else{
      int next = v + field[v];
      if(!inField(next)) continue;
      if(dist[v] < dist[next]){
        dist[next] = dist[v];
        Q.push(pii(dist[next],next));
      }
    }
  }
  return dist[N-1];
}

int main(){
  cin >> N;
  for(int i = 0 ; i < N ; i++){
    cin >> field[i];
  }
  fill(dist,dist+MAX,INF);
  dist[0] = 0;
  cout << dijkstra(0) << endl;
  return 0;
}

Measured memory_bytes: 1996
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
typedef long long ll;

using namespace std;

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;

    vector<int> v(b);
    for (int i=0; i<b; i++) {
        cin >> v[i];
    }

    int data[a][b];
    for (int i=0; i<a; i++) {
        for (int j=0; j<b; j++) {
            cin >> data[i][j];
        }
    }

    int cnt = 0;
    int sum = 0;
    for (int i=0; i<a; i++) {
        sum = 0;
        for (int j=0; j<b; j++) {
            sum += data[i][j] * v[j];
        }
        if (sum + c > 0)
            cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long 
#define int ll
#define pb push_back
#define sz(i) (int)(i.size())
#define fi first
#define se second
#define ld long double
#define pii pair<int, int>
#ifdef ONLINE_JUDGE
#define endl '\n'
#endif
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = 1e9 + 7;
using namespace std;
#ifndef ONLINE_JUDGE
#define tr(...) {__l(__LINE__);__f(#__VA_ARGS__, __VA_ARGS__);}
inline void __l(int line) { cerr << "#" << line << ": "; }template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << std::endl;}template <typename Arg1, typename... Args>void __f(const char* names, Arg1&& arg1, Args&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);}
#else
#define tr(...)
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}template<typename T>inline std::ostream &operator << (std::ostream & os,const std::vector<T>& v){bool first = true;os << "[";for(auto i: v){if(!first)os << ", ";os << i;first = false;}return os << "]";}
const int N = 400 + 10;
// make sure N size is correctttt!!!!!!!!!

int n, a[N], dp[N][N];
int pref[N];

int solve(int idx1, int idx2){
   if(idx1 == idx2){
      return 0;
   }
   int &ans = dp[idx1][idx2];
   if(ans != -1)
      return ans;
   ans = inf;

   for (int i = idx1; i+1 <= idx2; ++i)
   {
      smin(ans, solve(idx1, i) + solve(i+1, idx2) + pref[idx2] - pref[idx1-1]);
   }

   return ans;
}

int32_t main(){_

   cin>>n;
   for (int i = 1; i <= n; ++i)
   {
      cin>>a[i];
      pref[i] = pref[i-1] + a[i];
   }

   memset(dp, -1, sizeof dp);
   cout<<solve(1,n);

   //make sure N size is correct!!!!!!!!!
   return 0;
}

Measured memory_bytes: 1664
// Mehul Mathur randi hai
// Murali big ghey
// RisHiH is slave
// Anamaya is Sexy
// Arihanth is gay
// Aakash Aanegola is god

#include <bits/stdc++.h>
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define pb push_back
#define mp make_pair
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define endl "\n"
#define sz(x) ((ll)((x).size()))
#define pq priority_queue

using namespace std;

typedef long long int ll;
typedef long double ld;
vll dp;
vll a;
ll n;

ll calc(ll idx){
    if(dp[idx]!=-1){
        return dp[idx];
    }

    else if(idx==n-2){
        dp[n-2] = abs(a[idx]-a[idx+1]) + calc(n-1);
        return dp[n-2];
    }

    else if(idx>=(n-1)){
        dp[n-1] = 0;
        return dp[n-1];
    }

    dp[idx] = min( abs(a[idx]-a[idx+1]) + calc(idx+1), abs(a[idx]-a[idx+2]) + calc(idx+2));
    return dp[idx];
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    cin>>n;
    ll ans = 0;
    dp.resize(n);
    dp.assign(n,-1);
    a.resize(n);
     
    lp(i,0,n) cin>>a[i];

    cout<<calc(0)<<endl;
    
}


Measured memory_bytes: 4224
import Control.Monad
import Data.List
main=do
 n<-readLn;s<-replicateM n (sort<$>getLine)
 putStrLn(f (head s) (tail s) [])
  where f x [] _ = x
        f _ ([]:s) u = f (reverse u) s []
        f [] (_:s) u = f (reverse u) s []
        f (c:x) ((d:t):s) u |c==d = f x (t:s) (d:u)
                            |c<d  = f x ((d:t):s) u
                            |c>d  = f (c:x) (t:s) u

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// Range Max Quely
int op(int a, int b) {
    return max(a, b);
}

int e() {
    return (int)(0);
}

int main(void)
{
    IOS
    constexpr int N = 300000;
    int n, k;
    cin >> n >> k;
    atcoder::segtree<int,op,e> seg(N+1);
    int ans = 0;
    REP(_,n) {
        int a; cin >> a;
        seg.set(a,seg.prod(max(0,a-k),min(N+1,a+k+1))+1);
        ans = max(ans,seg.get(a));
        //cerr << ans << endl;
    }
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 8516
l = list()
n = int(input())
original_list = list(range(1,n+1))
for x in original_list:
      ans = 0
      while x % 2 == 0:
        x = x / 2
        ans = ans + 1
      l.append(ans)

a = l.index(max(l))
print(original_list[a])




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

string s;

int main() {
	cin >> s;
	if (s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

using namespace std;

/**************************************************************/
#define int          long long
#define mem(a , v)   memset(a , v , sizeof a)
#define all(v)       v.begin() , v.end()
#define ff           first
#define ss           second
#define err(x)       cerr << #x << " is : " << x << endl
#define endl         "\n"




/***************************************************************/

int ans[100000];
const int N = 100;

void pre()
{
    for(int i = 1 ; i <= N ; i++)
    {
        for(int j = 1 ; j <= N ; j++)
        {
            for(int k = 1 ; k <= N ; k++)
            {
                ans[i * i + j * j + k * k + i * j + i * k + j * k]++;
            }
        }
    }
    return;
}

void solve()
{
    int n;
    cin >> n;
    for(int i = 1 ; i <= n ; i++)
        cout << ans[i] << "\n";
}


int32_t main()
{
    pre();
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
   //cin >> t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 4032
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <deque>
#include <string.h>
#include <math.h>

using namespace std;

#define PI 4.0*atan(1.0)
#define epsilon 0.000000001
#define INF 1000000000000000000
#define MOD 1000000007

int rows, cols, freq [26], groups [5], filled = 0;
string s;

int main(){
    //freopen("roboherd.in", "r", stdin); freopen("roboherd.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(18);
    cin >> rows >> cols; getline(cin, s);
    for(int i = 0; i < rows; i++){
        string s; getline(cin, s);
        for(int j = 0; j < cols; j++) freq[s[j]-'a']++;
    }
    for(int i = 1; i <= rows; i++)
        for(int j = 1; j <= cols; j++){
            if(i > (rows+1)/2 || j > (cols+1)/2) continue;
            int temp = 1;
            if(i != (rows+1)/2 || rows%2 == 0) temp++;
            if(j != (cols+1)/2 || cols%2 == 0) temp++;
            if(temp == 3) temp++;
            groups[temp]++;
        }
    sort(freq, freq+26);
    for(int i = 25; i > -1; i--)
        for(int j = 4; j > 0; j--){
            while(freq[i] >= j && groups[j] > 0){
                freq[i] -= j; groups[j]--;
                filled += j;
            }
        }
    if(filled == rows*cols) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){
    int a, b, c, d;
    cin >>a >> b >> c >> d;
    if( abs(a-c)<= d || ( abs(a-b) <= d && abs(b-c) <= d ))
        cout <<"Yes\n";
    else
        cout <<"No\n";
  
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
#pragma GCC target ("sse4.2")
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define time cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";

int main()
{


    fast;
    map<lli,lli>mp;
    lli n;
    cin>>n;
    vector<lli>a(n);
    for(lli i=0;i<n;i++)
    {
        cin>>a[i];
    }
    lli mn=a[0];
    lli c=0;
    for(lli i=0;i<n;i++)
    {
        if(mn>=a[i])
            c++;
        mn=min(mn,a[i]);
    }
    cout<<c;




    return 0;

}


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

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

using namespace std;
using lint=long long;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long y,const mint& m){ return m+y; }
mint operator*(long long y,const mint& m){ return m*y; }

int main(){
	int h,w; scanf("%d%d",&h,&w);

	vector<bool> row(h*w),col(h*w);
	rep(i,h){
		int a; scanf("%d",&a); a--;
		if(row[a]) return puts("0"),0;
		row[a]=true;
	}
	rep(j,w){
		int b; scanf("%d",&b); b--;
		if(col[b]) return puts("0"),0;
		col[b]=true;
	}

	mint ans=1;
	lint cnt1=0,cnt2=0;
	rep(t,h*w){
		int num=h*w-t-1;
		if(row[num] && col[num]){
			cnt1++;
			cnt2++;
		}
		else if(row[num]){
			ans*=cnt2;
			cnt1++;
		}
		else if(col[num]){
			ans*=cnt1;
			cnt2++;
		}
		else{
			if(cnt1*cnt2<t) return puts("0"),0;
			ans*=cnt1*cnt2-t;
		}
	}
	printf("%d\n",ans.to_int());

	return 0;
}


Measured memory_bytes: 512
N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = [] 
for i in range(M):
  AB.append(list(map(int, input().split())))
  
lis = [0 for _ in range(N)]
for i in range(M):
  A = AB[i][0]
  B = AB[i][1]
  if H[A-1] > H[B-1]:
    lis[B-1] = 1
  elif H[B-1] > H[A-1]:
    lis[A-1] = 1
  else:
    lis[A-1] = 1
    lis[B-1] = 1
count = 0
for i in range(N):
  if lis[i] == 0:
    count += 1
print(count)

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

#define mod 1000000007
typedef int integer;
#define int long long
using namespace std;

const int N = 100005;

int n, m;
char ar[100][100];
int D[][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
int vis[100][100];

int bfs(int x, int y){
    memset(vis, 0, sizeof vis);
    queue<pair<int, pair<int, int>>> q;
    q.push({0, {x, y}});
    vis[x][y] = 1;
    int ans = 0;
    while (!q.empty()){
        auto k = q.front();
        int d = k.first;
        ans = max(ans, d);
        int r = k.second.first;
        int c = k.second.second;
        q.pop();
        for (int i = 0; i < 4; i++){
            int xx = r + D[i][0];
            int yy = c + D[i][1];
            if (xx < 0 || yy < 0 || xx >= n || yy >= m) continue;
            if (ar[xx][yy] == '#') continue;
            if (vis[xx][yy]) continue;
            q.push({d+1, {xx, yy}});
            vis[xx][yy] = 1;
        }
    }
    return ans;
}



integer main() {
    ios_base::sync_with_stdio(false);

    cin >> n >> m;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            cin >> ar[i][j];
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (ar[i][j] == '#') continue;
            ans = max(ans, bfs(i, j));
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <complex>
#include <vector>
#include <cstdio>
#include <cmath>
#include <utility>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
using namespace std;
 
template<class T>inline string toString(T x){
        ostringstream sout; sout<<x; return sout.str();
}
const ll MOD=1e9+7;
const int inf=(ll)1e9;
const double PI=acos(-1.0);
 
 
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    int n,m;
    while(cin>>n>>m,n){
        int ldp[201][201];
        int sdp[201][201];
        for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                ldp[i][j]=inf;
                sdp[i][j]=inf;
            }
        }
        for(int i=0;i<n;i++){
            ldp[i][i]=0;
            sdp[i][i]=0;
        }
        for(int i=0;i<m;i++){
            int a,b,c;
            char d;
            cin>>a>>b>>c>>d;
            a--;b--;
            if(d=='L'){
                ldp[a][b]=c;
                ldp[b][a]=c;
            }else{
                sdp[a][b]=c;
                sdp[b][a]=c;
            }
        }
        for(int k=0;k<n;k++){
            for(int i=0;i<n;i++){
                for(int j=0;j<n;j++){
                    ldp[i][j]=min(ldp[i][k]+ldp[k][j],ldp[i][j]);
                    sdp[i][j]=min(sdp[i][k]+sdp[k][j],sdp[i][j]);
                }
            }
        }
        int r;cin>>r;
        int a[1002];
        for(int i=0;i<r;i++){
            cin>>a[i];
            a[i]--;
        }
        int dp[1001][201];
        for(int i=0;i<1001;i++)for(int j=0;j<201;j++)dp[i][j]=inf;
        dp[0][a[0]]=0;
        for(int i=0;i<r-1;i++){
            for(int j=0;j<n;j++){
                if(dp[i][j]==inf)continue;
                for(int k=0;k<n;k++){
                    dp[i+1][k]=min(dp[i+1][k],dp[i][j]+ldp[a[i]][j]+sdp[j][k]+ldp[k][a[i+1]]);
                    if(j==k)dp[i+1][k]=min(dp[i+1][k],dp[i][j]+ldp[a[i]][a[i+1]]);
                }
            }
        }
        /*for(int i=0;i<r;i++){
            for(int j=0;j<n;j++){
                cerr<<dp[i][j]<<" ";
            }
            cerr<<"\n";
        }*/
        int ans=inf;
        for(int i=0;i<201;i++){
            ans=min(ans,dp[r-1][i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<pair<long, long>> eng(N);
    for(auto& i : eng)cin >> i.first >> i.second;
    auto d = static_cast<unsigned long>(partition(eng.begin(), eng.end(), [](auto i){return i.first == 0 ? i.second < 0 : i.first > 0;}) - eng.begin());
    for(unsigned long i = 0; i < N; ++i)eng.emplace_back(-eng[i].first, -eng[i].second);
    for(unsigned long i = 0; i < d; ++i)eng.emplace_back(eng[i].first, eng[i].second);
    auto cmp = [](auto i, auto j){return atan2(static_cast<long double>(i.first), static_cast<long double>(i.second)) < atan2(static_cast<long double>(j.first), static_cast<long double>(j.second));};
    sort(eng.begin(), eng.begin() + d, cmp);
    sort(eng.begin() + d, eng.begin() + d + N, cmp);
    sort(eng.begin() + d + N, eng.end(), cmp);
    long a{0}, b{0};
    unsigned long ans{0};
    for(unsigned long i = 0; i < 2 * N + d; ++i){
        a += eng[i].first;
        b += eng[i].second;
        ans = max<unsigned long>(ans, a * a + b * b);
    }
    printf("%.12Lf\n", sqrt(static_cast<long double>(ans)));
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
a.sort()
count1 = 1
ans = 0
i = 0
while i < n-1:
    if a[i] == a[i+1]:
        count1 = count1 + 1
    else:
        if count1 >= a[i]:
            ans = ans + count1 - a[i]
        else:
            ans = ans + count1
        count1 = 1
    i = i + 1
if count1 >= a[i]:
    ans = ans + count1 - a[i]
else:
    ans = ans + count1
print(ans)

Measured memory_bytes: 14692
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[20];
vector<P> vec[20];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		llint x, y;
		for(int j = 0; j < a[i]; j++){
			cin >> x >> y;
			x--;
			vec[i].push_back(P(x, y));
		}
	}
	
	llint N = 1<<n, ans = 0;
	for(int i = 0; i < N; i++){
		bool flag = true;
		llint cnt = 0;
		for(int j = 0; j < n; j++){
			if((i & (1<<j)) == 0) continue;
			cnt++;
			for(int k = 0; k < vec[j].size(); k++){
				llint x = vec[j][k].first, y = vec[j][k].second;
				if(y == 1 && (i & (1<<x)) == 0) flag = false;
				if(y == 0 && (i & (1<<x))) flag = false;
			}
		}
		if(flag) ans = max(ans, cnt);
	}
	cout << ans << endl;
	
	return 0;
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

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

    vi a(n);
    rep(i, 0, n) { cin >> a[i]; }

    vector<vll> dp(n, vll(k + 1, 0));
    rep(j, 0, k + 1) { dp[0][j] = j <= a[0] ? 1 : 0; }

    rep(i, 1, n) {
        ll sum = 0;
        rep(j, 0, k + 1) {
            if (j <= a[i]) {
                sum = (sum + dp[i - 1][j]) % MOD;
            } else {
                sum = (sum + dp[i - 1][j] - dp[i - 1][j - a[i] - 1] + MOD) % MOD;
            }
            dp[i][j] = sum;
        }
    }

    cout << dp[n - 1][k] << endl;

    return 0;
}

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

const int nax = 1e5;

int d[nax];

int main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  int n; cin >> n; 
  for(int i=0; i<n; ++i){
    cin >> d[i];
  }
  long long ai = 0;
  for(int c=0; c<n; ++c){
     if(c&1)
      ai -= d[c];
     else
      ai += d[c];
  }
  cout << ai << " ";
  for(int i=1; i<n; ++i){
    cout << 2*d[i-1] - ai << " ";
    ai = 2*d[i-1] - ai;
  }
  cout << "\n";
  return 0; 
}


Measured memory_bytes: 1792
A, B = map(int, input().split())

ans = 0
for i in range(A, B+1):
    S = str(i)
    n = len(S)
    if n%2 == 0:
        m = n//2
        x = S[:m]
        y = S[m:]
    else:
        m = n//2
        x = S[:m]
        y = S[m+1:][::-1]
    if x == y:
        ans += 1

print(ans)

Measured memory_bytes: 3064
import java.util.*;

class Main {

    static boolean primes [];

    static void makeTable () {

        primes = new boolean [200000];
        
        for(int i = 2; i < 200000; i++) {
            primes[i] = true;
        }

        for(int i = 2; i < 200000; i++) {
            if(primes[i]) {
                for (int n = 2 * i; n < 200000; n += i) primes[n] = false;
            }
        }

    }

    static int solve(int n) {
        int sum = 0;
        int added = 0;
        int i = 2;

        while (added < n) {
            if (primes[i]) {
                sum += i;
                added += 1;
            }
            i += 1;
        }

        return sum;
    }

    public static void main (String [] args) {

        Scanner sc = new Scanner(System.in);

        makeTable();

        while(true) {
            int n = sc.nextInt();
            if (n == 0) break;
            else        System.out.println(solve(n));
        }


    }
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <fstream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define ll unsigned long long

const ll MOD = 1000000000000000000;

int main() {
	//入力
	ll n,m;
	cin >> n >> m;

	//処理
	ll ans = 0;
	if (n == 1 && m == 1) {
		ans = 1;
	}
	else if (n == 1) {
			ans = m - 2;
	}
	else if (m == 1) {
		ans = n - 2;
	}
	else if (n > 1 && m > 1) {
		ans = (n - 2) * (m - 2);
	}

	//出力
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3584
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim() {
  int u, minv;
  int d[MAX], p[MAX], color[MAX];

  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while (1) {
    minv = INFTY;
    u = -1;
    for (int i = 0; i < n; i++) {
      if (minv > d[i] && color[i] != BLACK){
        u = i;
        minv = d[i];
      }
    }
    if (u == -1) break;
    color[u] = BLACK;
    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && M[u][v] != INFTY) {
        if (d[v] > M[u][v]) {
          d[v] = M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }
      }
    }
  }
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if(p[i] != -1) sum += M[i][p[i]];
  }

  return sum;
}

int main() {
  cin >> n;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int e; cin >> e;
      M[i][j] = (e == -1) ? INFTY : e;
    }
  }

  cout << prim() << endl;

  return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  double t,x;
  cin >> t >> x;
  cout << setprecision(6) << t/x << endl;

  return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    hs = list(map(lambda x: int(x), input().split()))
    maxmove = 0
    movecount = 0
    temp = hs[0]
    for i in hs[1:]:
        if i <= temp:
            movecount += 1
            if movecount > maxmove:
                maxmove = movecount
        else:
            movecount = 0
        temp = i
    print(maxmove)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
int main(){
  int ans=700;
  string s;
  string a="o";
  cin >> s;
  for(int i=0;i<3;i++){
    if(s[i]==a[0]){
      ans+=100;
    }
  }
  cout << ans <<"\n";
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int k, s;

  std::cin >> k >> s;

  int cnt = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      if (0 <= s - (x + y) && s - (x + y) <= k) {
        cnt++;
      }
    }
  }
  std::cout << cnt << std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, a, b, nn, sum = 0;

	scanf("%d %d %d", &n, &a, &b);

	while (n != 0) {
		nn = n / 10000 % 10;
		nn = nn + n / 1000 % 10;
		nn = nn + n / 100 % 10;
		nn = nn + n / 10 % 10;
		nn = nn + n % 10;
		if (b >= nn && nn >= a) sum += n;
		n--;
	}
	
	printf("%d\n", sum);

	return 0;
}

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

int main(void)
{
  int N;
  cin >> N;
  unordered_map<int, int> mp;
  int a;
  for (int i=N-1; i>=0; --i)
  {
    cin >> a;
    ++mp[a];
  }

  int ans = 0;
  for(auto &elm : mp)
  {
    ++ans;
  }

  if ((ans & 1) == 0) --ans;

  cout << ans << endl;

  return 0;
}


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

using namespace std;

const int INF = 1000000;

int n, h[100000], dp[100000], K;

int main() {
	scanf("%d%d", &n, &K);
	
	for(int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	for(int i = 0; i < n; i++)
		for(int j = 1; j <= K; j++) 
			if(i + j < n)
				dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));


	printf("%d", dp[n-1]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int a, b;
	cin >> a >> b;
	cout << (b-a)*(b-a+1)/2 - b << endl;
	return 0;
}

Measured memory_bytes: 256
#include<math.h>
#include<iostream>
using namespace std;
typedef long long ll;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    ll x;
    cin >> n >> x;

    ll y[n];
    for(int i = 0; i < n; i++){
        cin >> y[i];
    }

    ll ans = abs(y[0] - x);

    //cout << ans << endl;

    for(int i = 1; i < n; i++){
        if(ans == 1){
            break;
        }else{
            ans = gcd(ans, abs(y[i] - y[i - 1]));
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 101010101000;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;

int main(){
  int a,b;
  cin>>a>>b;
  rep(i,3){
    if(a==i+1||b==i+1) continue;
    else cout << i+1;
  }
}


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

using namespace std;
typedef long long ll;

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

  int a, b;
  char c;
  cin >> a >> c >> b;

  if (c == '+') cout << a + b << "\n";
  else cout << a - b << "\n";

}


Measured memory_bytes: 3560
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i];
  sort(all(a));
  cout<<a[n-1]-a[0]<<endl;
}


Measured memory_bytes: 256