akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
/////////////////////////////////////////////////////////////////////
int main()
{ ll x,k,d;
	cin>>x>>k>>d;
	ll i = abs(x)/d;
if(i>k)
	i = k;	
ll res = (k - i)%2;
cout<<abs(abs(x)-(i*d)-res*d);

return 0;
}

Measured memory_bytes: 3612
import sys
import math
from collections import Counter
import itertools
import fractions
#import numpy as np
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

N,M,X=MI()
CA=LLI(N)

mi=10000000000000
ans=0

for i in range(1,N+1):
    kumi = itertools.combinations(CA,i)
    for k in kumi:
        target=[0]*(M+1)
        su=0
       
        for x in k:
            target = [a + b for (a,b) in zip(x,target)]
            su+=x[0]
        flag=True   
        for j in range(1,len(target)):
            if X > target[j]:
                flag=False
                break
        if flag:    
            mi=min(mi,su)
            ans+=1
if ans ==0:
    print(-1)
else:
    print(mi)


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

int main() {
  string S; cin >> S;
  string ans = "aaa";
  rep(i, 3){
    ans[i] = S[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n;
vector<pair<int, int> > adj[MAX];

void dijkstra() {
	priority_queue<pair<int, int> > PQ;
	int color[MAX];
	int d[MAX];
	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		color[i] = WHITE;
	}

	d[0] = 0;
	PQ.push(make_pair(0, 0));
	color[0] = GRAY;

	while (!PQ.empty()) {
		pair<int, int> f = PQ.top(); PQ.pop();
		int u = f.second;

		color[u] = BLACK;

		if (d[u] < f.first * (-1)) continue;

		for (int j = 0; j < adj[u].size(); j++) {
			int v = adj[u][j].first;
			if (color[v] == BLACK) continue;
			if (d[v] > d[u] + adj[u][j].second) {
				d[v] = d[u] + adj[u][j].second;
				PQ.push(make_pair(d[v] * (-1), v));
				color[v] = GRAY;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
	}
}

int main() {
	int k, u, v, c;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v >> c;
			adj[u].push_back(make_pair(v, c));
		}
	}

	dijkstra();

	return 0;
}


Measured memory_bytes: 8088
/// [Amberjack] CUT BEGIN
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef int _loop_int;
#define __GET_REP_MACRO(_1,_2,_3,NAME,...) NAME
#define __REP0(i,n) for(_loop_int i=0;i<(n);++i)
#define __REP1(i,a,b) for(_loop_int i=(a);i<(b);++i)
#define __REPR0(i,n) for(_loop_int i=(n)-1;i>=0;--i)
#define __REPR1(i,a,b) for(_loop_int i=(b)-1;i>=(a);--i)
#define REP(...) __GET_REP_MACRO(__VA_ARGS__,__REP1,__REP0)(__VA_ARGS__)
#define REPR(...) __GET_REP_MACRO(__VA_ARGS__,__REPR1,__REPR0)(__VA_ARGS__)

#ifdef BURI
#define __DEBUG0() "Hello"
#define __DEBUG1(x) #x"("<<(x)<<")"
#define __DEBUG2(x,...) #x"("<<(x)<<"), " __DEBUG1(__VA_ARGS__)
#define __DEBUG3(x,...) #x"("<<(x)<<"), " __DEBUG2(__VA_ARGS__)
#define __DEBUG4(x,...) #x"("<<(x)<<"), " __DEBUG3(__VA_ARGS__)
#define __DEBUG5(x,...) #x"("<<(x)<<"), " __DEBUG4(__VA_ARGS__)
#define __GET_DEBUG_MACRO(_1,_2,_3,_4,_5,NAME,...) NAME
#define __DEBUG(...) __GET_DEBUG_MACRO(__VA_ARGS__,__DEBUG5,__DEBUG4,__DEBUG3,__DEBUG2,__DEBUG1,__DEBUG0)(__VA_ARGS__)
#define DEBUG(...) cerr<<__DEBUG(__VA_ARGS__)<<endl
#else
#define DEBUG(...)
#endif

inline void getll(ll &x){
  int sgn=1;x=0;
  char c=getchar();
  while(c!='-'&&(c<'0'||c>'9'))c=getchar();
  if(c=='-') sgn=-1; else x=c-'0';
  c=getchar();
  while('0'<=c&&c<='9'){
    x*=10;
    x+=c-'0';
    c=getchar();
  }
  x*=sgn;
}
inline void read(ll &x){getll(x);}
inline void read(int &x){ll y;getll(y);x=y;}
inline void read(float &x){scanf("%f",&x);}
inline void read(double &x){scanf("%lf",&x);}
inline void read(long double &x){scanf("%Lf",&x);}
inline void read(char *s){scanf("%s",s);}
inline void read(string &s){int len=s.size();char *buf=(char*)malloc(len*sizeof(char));scanf("%s",buf);s=string(buf);free(buf);}
inline void read(char &c){char *buf=(char*)malloc(5*sizeof(char));scanf("%s",buf);c=buf[0];free(buf);}
inline void read(){}
template<typename S,typename ...T>
inline void read(S& first, T&... rest){
  read(first);
  read(rest...);
}
/// [/Amberjack] CUT END

int n;
int a[125252];
int main(){
  read(n);
  REP(i,n)read(a[i]);
  ll ans = a[0]-1;
  int ban = 2;
  REP(i,1,n){
    if(a[i]==ban){
      ban++;
    }else{
      ans += (a[i]-1)/ban;
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(void)
{
	int N;
		scanf("%d",&N);
	if(N==0){
		puts("0");
		return 0;
	}
	string ans;
	while(N!=0){
		if(N&1){
			ans='1'+ans;
			N--;
		}
		else
			ans='0'+ans;
		N/=-2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
#define ll long long
double pow1(double x, double a = 1.0 / 5)
{
	return pow(x, a);
}
int main()
{
	int x;
	cin >> x; int f = 0;
	for (int i = 0; i <= 125; i++)
	{
		for (int j = -125; j <= 125; j++)
		{
			ll t = pow(i, 5) - pow(j, 5);
			if (t == x)
			{
				cout << i << " " << j; f = 1; break;
			}

		}if (f == 1)break;
	}


}

Measured memory_bytes: 4104
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var works = new List<Tuple<long, long>>();
            for (var i = 0; i < N; ++i)
            {
                var ab = Sarray();
                works.Add(new Tuple<long, long>(ab[0], ab[1]));
            }
            works.Sort((l, r) => (int)(l.Item2 - r.Item2));
            var now = 0L;
            foreach (var w in works)
            {
                now += w.Item1;
                if (now <= w.Item2) { }
                else
                {
                    WriteLine("No");
                    return;
                }
            }
            WriteLine("Yes");
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 26892
#include<bits/stdc++.h>
using namespace std;
int cnt=0;
int main()
{
  if('2'==getchar())++cnt;
  if('2'==getchar())++cnt;
  if('2'==getchar())++cnt;
  if('2'==getchar())++cnt;
  return printf("%d\n",cnt),0;
}

Measured memory_bytes: 256
N = int(input())
cur = -10**9

ppair = [[0,0]]*N
for i in range(N):
    tmp = list(map(int,input().split()))
    ppair[i] = [tmp[0]+tmp[1],tmp[0]-tmp[1]]

ppair.sort()
ans = 0
for i in range(N):
    if (cur <= ppair[i][1]):
        ans += 1
        cur = ppair[i][0]

print(ans)



Measured memory_bytes: 53848
from fractions import gcd
import sys
#input = sys.stdin.readline()
sys.setrecursionlimit(4100000)

def ols(): return input()
def oli(): return map(int, input().split())
def olai(): return list(map(int, input().split()))
def olas(): return list(input().split())
def mlai(L): return [int(input()) for _ in range(L)]
def mlas(L): return [input() for _ in range(L)]

def palindrome(S):
    return S == S[::-1]

n = oli()
a = olai()
num = [0] * 200001
for i in a:
    num[i]+=1
ans = 0
for i in num:
    ans += i*(i-1)//2

for i in a:
    k = num[i]
    print(ans - (k*(k-1)//2) + ((k-2)*(k-1)//2))


Measured memory_bytes: 27324
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

count=0
for i in range(N):
    if A[i]<B[i]:
        count+=(B[i]-A[i])//2
    else:
        count+=(B[i]-A[i])
    
if count<0:
    print("No")
else:
    print("Yes")

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

int main() {
  int W, H, N;
  cin >> W >> H >> N;
  vector<int> x(N), y(N), a(N);
  for (int i= 0; i < N; i++) {
    cin >> x.at(i) >> y.at(i) >> a.at(i);
  }
  
  int x_min = 0, x_max = W;
  int y_min = 0, y_max = H;
  
  for (int i = 0; i < N; i++) {
    if (a.at(i) == 1) {
      if (x.at(i) > x_min) x_min = x.at(i);
    }
    if (a.at(i) == 2) {
      if (x.at(i) < x_max) x_max = x.at(i);
    }
    if (a.at(i) == 3) {
      if (y.at(i) > y_min) y_min = y.at(i);
    }
    if (a.at(i) == 4) {
      if (y.at(i) < y_max) y_max = y.at(i);
    }
  }
  if (x_min >= x_max || y_min >= y_max) cout << 0 << endl;
  else cout << (x_max - x_min) * (y_max - y_min) << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int mod = 1e9+7;
const int maxn = 4e5+5;
string s;
int dp[maxn];
int pre[maxn]; 
int num[maxn];
vector<int> v;
int n,k,c;
void dfs(int pos,int dep){
	int flag = 0;
	for(int i=0;i<c;i++){
		if(pos-i>0&&s[pos-i-1]=='o'&&pre[pos-i]==0&&pre[pos+1]<=1&&dp[pos-i]==dep){
			v.push_back(pos-i);
			dfs(pos-i-c-1,dep-1);
			return;
		}
	}
	for(int i=pos;i>=1;i--){
		if(s[i-1]=='o'){
			if(pre[i]==0&&pre[pos+1]<=1) v.push_back(i);
			int flag = 0;
			for(int j=1;j<=c;j++){
				if((i-j-1)>=0&&s[i-j-1]=='o'&&dp[i-j]==dep){
					break;
				}
				if((i-j-1)>=0&&s[i-j-1]=='o'&&dp[i-j]==dep-1){
					flag = 1;
					break;
				}
			}
			if(flag&&(v.size()==0||v[v.size()-1]!=i)) v.push_back(i);
			dfs(i-c-1,dep-1);
			return;
		} 
	}
}
int main() {
	cin>>n>>k>>c;
		cin>>s;
	for(int i=1;i<=c;i++){
		if(s[i-1]=='o') {
			dp[i] = 1,num[dp[i]]++;
		}
		else dp[i] = dp[i-1];
		
	}
	for(int i=c+1;i<=n;i++){
		if(s[i-1]=='o')
			dp[i] = dp[i-c-1]+1,num[dp[i]]++;
		else dp[i] = dp[i-1];
		
	} 
	for(int i=1;i<=n+1;i++){
		if(i>1)
			pre[i] = pre[i-1]+(s[i-2]=='o'?1:0);
		if(i>c+1){
			pre[i] = pre[i]-(s[i-c-2]=='o'?1:0);
		}
	}
	if(dp[n]!=k){
		return 0;
	}
	else {
		dfs(n,k);
	}
	if(v.size()==0) {
		return 0;
	}
	sort(v.begin(),v.end());
	for(int i=0;i<v.size();i++){
		cout<<v[i]<<"\n";
	}
	
	return 0;
}



Measured memory_bytes: 24696
/*
 * main.cpp
 *
 *  Created on: 2020/04/10
 *      Author: SkAaO
 */

#include <iostream>

using namespace std;

int main(){
	int A, B;
	string S;
	cin >> A >> B;
	cin >> S;

	bool is_correct = true;

	if(A + B + 1 != (int)S.size()){
		is_correct = false;
	}

	if(S.at(A) != '-'){
		is_correct = false;
	}

	for(int i = 0; i < (int)S.size(); i++){
		if(i != A){
			if((int)S.at(i) > '9' || (int)S.at(i) < '0'){
				is_correct = false;
				break;
			}
		}
	}

	if(is_correct){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}




Measured memory_bytes: 764
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PII;
 
const PLL M = mp(1e9+7, 1e9+9);        ///Should be large primes
const LL base = 875329;               ///Should be a prime larger than highest value
const int N = 1e5+7;                 ///Highest length of string
 
ostream& operator<<(ostream& os, PLL hash) {
    return os<<"("<<hash.ff<<", "<<hash.ss<<")";
}
 
PLL operator+ (PLL a, LL x)     {return mp(a.ff + x, a.ss + x);}
PLL operator- (PLL a, LL x)     {return mp(a.ff - x, a.ss - x);}
PLL operator* (PLL a, LL x)     {return mp(a.ff * x, a.ss * x);}
PLL operator+ (PLL a, PLL x)    {return mp(a.ff + x.ff, a.ss + x.ss);}
PLL operator- (PLL a, PLL x)    {return mp(a.ff - x.ff, a.ss - x.ss);}
PLL operator* (PLL a, PLL x)    {return mp(a.ff * x.ff, a.ss * x.ss);}
PLL operator% (PLL a, PLL m)    {return mp(a.ff % m.ff, a.ss % m.ss);}
 
PLL pb[N];      ///powers of base mod M
///Call pre before everything
void pre() {
    pb[0] = mp(1,1);
    for (int i=1; i<N; i++)
        pb[i] = (pb[i-1] * base)%M;
}
 
///Calculates hashes of all prefixes of s including empty prefix
vector<PLL> hashList(string &s) {
    int n = s.size();
    vector<PLL> ans(n+1);
    ans[0] = mp(0,0);
 
    for (int i=1; i<=n; i++)
        ans[i] = (ans[i-1] * base + s[i-1])%M;
    return ans;
}
 
///Calculates hash of substring s[l..r] (1 indexed)
PLL Hash(vector<PLL> &hashlist, int l, int r) {
    int len = (r-l+1);
    return ((hashlist[r] - hashlist[l-1]*pb[len])%M+M)%M;
}
vector<PLL>hashVec;
int n; 
bool ok(int len) {

    for(int i =1 ; i+len-1 <= n ; i++ ) {
        
        PLL val1 = Hash(hashVec , i , i+len-1);
        
        for(int j = i+len ; j+len-1 <=n ; j++ ) {
            
            PLL val2 = Hash(hashVec , j , j+len-1);
            if(val1 == val2) return true;
        }
    }
    return false;
}


int main() {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    pre();
    
    
    string str;
    
    cin>>n>>str;
    
    hashVec = hashList(str);
    
    int lo = 0 , hi = n;
    int ans = 0;
    
    while(lo <= hi) {
        
        int mid = (lo+hi)/2;
        
        if(ok(mid)) {
            ans = mid;
            lo = mid+1;
        }
        else hi = mid-1;
    }
    cout<<ans<<'\n';
    return 0;
    

}

Measured memory_bytes: 1920
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<cstdlib>
#include<bitset>
#define mall (nxd*)mallxc(sizexf(nxd))
using namespace std;
typedef long long ll;
ll dp[2003][2003]={0};
ll mod=1000000000+7;
int main(void)
{
	ll n;
	scanf("%lld",&n);
	for(ll i=3;i<=n;i++)
	{
		dp[1][i]=1;
	}
	for(ll i=2;i<=n/3;i++)
	{
		ll now=0;
		for(ll j=i*3;j<=n;j++)
		{
			now=(now+dp[i-1][j-3])%mod;
			dp[i][j]=now;
//			for(ll k=3;j-k>=3;k++)
//			{
//				dp[i][j]=(dp[i][j]+dp[i-1][j-k])%mod;
//			}
		}
	}
	ll ans=0;
	for(ll i=1;i<=2000;i++)
	{
		ans+=dp[i][n];
	}
	printf("%lld\n",ans%mod);
}

Measured memory_bytes: 11228
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 30
#define MAX_D 400

    /*
    いろいろ
    int x = rand()%100;
    double x = (double)rand()/RAND_MAX;
    mt19937 get_rand_mt;
    shuffle(vec.begin(), vec.end(), get_rand_mt);
    int dx[4] = {-1, 0, 1, 0};
    int dy[4] = {0, -1, 0, 1};
    char cc[4] = {'U','L','D','R'};
    */

int D;
int c[MAX_N];
int s[MAX_D][MAX_N];
int ma;
int ans[MAX_D];

int calc(){
    int las[26] = {};
    int res = 0;
    rep(i,D){
        res += s[i][ans[i]];
        las[ans[i]] = i+1;
        rep(j,26){
            res -= (i + 1 - las[j]) * c[j];
        }
        cout << res << endl;
    }
    return res;
}

int main() {
    srand((unsigned) time(NULL));
    clock_t start,end;
	start = clock();


    string fileNameIfs = "input_1.txt";
    const char* cstrIfs = fileNameIfs.c_str();
    ifstream ifs(cstrIfs);
    if(!ifs.is_open()){ // 標準入力する
        cin >> D;
        rep(i,26)cin >> c[i];
        rep(i,D)rep(j,26)cin >> s[i][j];
        rep(i,D){
            cin >> ans[i];
            ans[i]--;
        }
    }else{ // ファイル入力する
        ifs >> D;
        rep(i,26)ifs >> c[i];
        rep(i,D)rep(j,26)ifs >> s[i][j];
    }    
    
    /*
    rep(i,D){
        int max_s = -1;
        int arg = -1;
        rep(j,26){
            if(s[i][j] > max_s){
                max_s = s[i][j];
                arg = j;
            }
        }
        ans[i] = arg;
    }
    */

    ma = calc();
    /*
    start = clock();
    while(true){
        int x = rand()%D;
        int y = rand()%26;

        int keep = ans[x];
        ans[x] = y;

        int tmp = calc();

        if(tmp >= ma){
            ma = tmp;
        }else{
            ans[x] = keep;
        }

        end = clock();
        if((double)(end-start)/CLOCKS_PER_SEC > 1.7)break;
    }


    rep(i,D){
        cout << ans[i] + 1 << endl;
    }

    string fileName = "sample_out1.txt";
    const char* cstr = fileName.c_str();
    ofstream ofs(cstr);
    rep(i,D){
        ofs << ans[i] + 1 << endl;
    }
    ofs.close();
    */
    return 0;
}
 
 


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

int main(){
	while(1){
		int t,p,r;
		cin>>t>>p>>r;
		if(t==0&&p==0&&r==0) break;
		int qstats[55][15];
		int score[55],pn[55];
		lp(i,55){
			score[i]=0;
			pn[i]=0;
			lp(j,15){
				qstats[i][j]=0;
			}
		}
		lp(i,r){
			int a,b,c;
			string d;
			cin>>a>>b>>c>>d;
			if(d=="CORRECT"){
				score[a]++;
				pn[a]+=c+qstats[a][b]*1200;
			}
			else{
				qstats[a][b]++;
			}
		}
		tuple<int,int,int> ans[50];
		lp(i,t){
			ans[i]=make_tuple(score[i+1],-pn[i+1],500-i-1);
		}
		sort(ans,ans+t);
		reverse(ans,ans+t);
		lp(i,t){
			int ans1,ans2,ans3;
			ans1=get<2>(ans[i]);
			ans2=get<0>(ans[i]);
			ans3=get<1>(ans[i]);
			cout<<500-ans1<<" "<<ans2<<" "<<-ans3<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3192
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Deque;
import java.util.ArrayDeque;
import java.util.Collections;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
    
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DChatInACircle solver = new DChatInACircle();
        solver.solve(1, in, out);
        out.close();
    }
    
    static class DChatInACircle {
        
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            Integer[] a = new Integer[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            
            Arrays.sort(a, Collections.reverseOrder());
            long ans = a[0];
            
            Deque<Integer> dq = new ArrayDeque<>();
            dq.offerLast(a[1]);
            dq.offerLast(a[1]);
//        debug(a);
            for (int i = 2; i < n; i++) {
//            debug(dq);
                ans += dq.pollFirst();
                for (int j = 0; j < 2; j++) {
                    dq.offerLast(a[i]);
                }
            }
            // 出力
            out.println(ans);
        }
        
    }
}



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

using namespace std;

typedef long long ll;

const int MAX_N = 2e5 + 5;

void solve() {
  int n, x, y, ans = 0, len = 0;
  cin >> n;
  while (n -- ) {
    cin >> x >> y;
    if (x == y) {
      ++len;
    } else {
      len = 0;
    }
    ans = max(ans, len);
  }
  if (ans >= 3) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}

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


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){long long a[3][3],q,i,j;
for(i=0;i<3;i++){
    for(j=0;j<3;j++){
        cin>>a[i][j];
    }
}cin>>q;
for(i=0;i<q;i++){
    long long p,r,b;
    cin>>p;
    for(r=0;r<3;r++){
        for(b=0;b<3;b++){
            if(a[r][b]==p){
                a[r][b]=101;
            }
        }
    }
}if((a[0][0]==101&&a[0][0]==a[0][1]&&a[0][1]==a[0][2])||(a[1][0]==101&&a[1][0]==a[1][1]&&a[1][1]==a[1][2])||(a[2][0]==101&&a[2][0]==a[2][1]&&a[2][1]==a[2][2])||(a[0][0]==101&&a[0][0]==a[1][0]&&a[1][0]==a[2][0])||(a[0][1]==101&&a[0][1]==a[1][1]&&a[0][1]==a[1][2])||(a[0][2]==101&&a[0][2]==a[1][2]&&a[0][2]==a[2][2])||(a[1][1]==101&&a[0][0]==a[1][1]&&a[1][1]==a[2][2])||(a[1][1]==101&&a[2][0]==a[1][1]&&a[1][1]==a[0][2]))
cout<<"Yes";
else
cout<<"No";
    return 0;
  
}


Measured memory_bytes: 256
import itertools
import copy

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

c = list()
for _ in range(H):
    c.append(list(input()))

ns = [i for i in range(H + W)]

res = 0
for n in range(H + W + 1):
    for tup in itertools.combinations(ns, n):
        _c = copy.deepcopy(c)
        for r in tup:
            if r < H:
                for w in range(W):
                    _c[r][w] = '-'
            else:
                for h in range(H):
                    _c[h][r - H] = '-'
        count = 0
        for h in range(H):
            for w in range(W):
                if _c[h][w] == '#':
                    count += 1

        if count == K:
            res += 1

print(res)


Measured memory_bytes: 9328
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <math.h>
#include <time.h>
using namespace std;
int main() {
	int a;
	cin >> a;
	if (a / 10 == 9 || a % 10 == 9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  long long n, a, b;
  cin >> n >> a >> b;
  long long ans = (n / (a + b)) * a;
  ans += min(a, n % (a + b));
  cout << ans;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		
//		System.out.println(process(line));
		char[] in = line.toCharArray();
		boolean c = false, b = true;
		long count = 0; long res = 0;
		for(int i = in.length-1; i >= 0; i--){
			if(b && in[i] == 'C'){
				b = false; c = true;
			}
			else if(c && in[i] == 'B'){
				b = true; count++; c = false;
			}
			else if(b && in[i] == 'A'){
				res += count;
			}
			else if(in[i] == 'C'){
				count = 0; c = true; b = false;
			}
			else{
				count = 0; c = false; b = true;
			}
		}
		System.out.println(res);
	}
	
	static long process(String line){
		long count = 0;
		while(true){
			String newline = line.replaceFirst("ABC", "BCA");
			if(newline.equals(line)) break;
			line = newline;
			count++;
		}
		return count;
	}

}


Measured memory_bytes: 27732
#include<bits/stdc++.h>
using namespace std;
string a,b,c;
int ab[100000],ac[100000],bc[100000];
inline int ok(char x,char y){return (x=='?'||y=='?'||x==y);}
int main()
{
	cin>>a>>b>>c;
	int A=a.size(),B=b.size(),C=c.size();
	for(int i=0;i<A;i++)
		for(int j=0;j<B;j++)
			if(!ok(a[i],b[j]))ab[i-j+50000]=true;
	for(int i=0;i<A;i++)
		for(int j=0;j<C;j++)
			if(!ok(a[i],c[j]))ac[i-j+50000]=true;
	for(int i=0;i<B;i++)
		for(int j=0;j<C;j++)
			if(!ok(b[i],c[j]))bc[i-j+50000]=true;
	int ans=6000;
	for(int i=-4000;i<=4000;i++)
		for(int j=-4000;j<=4000;j++)
			if(!(ab[i+50000]||ac[j+50000]||bc[j-i+50000]))	
				ans=min(ans,max(A,max(B+i,C+j))-min(0,min(i,j)));
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  map<ll, ll> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    m[a[i]]++;
  }
  ll M      = 1000000007;
  ll ans    = 1;
  bool even = n % 2 == 0 ? true : false;
  map<ll, ll> checker;
  for (int i = 0; i < n; i++) {
    if (i == 0 && even) continue;
    checker[i]++;
    i++;
  }
  int oneCnt = 0;
  for (auto v : m) {
    if (v.second > 2) {
      cout << 0 << endl;
      return 0;
    }
    if (v.second == 1) {
      if (even || oneCnt >= 1) {
        cout << 0 << endl;
        return 0;
      } else {
        if (v.first != 0) {
          cout << 0 << endl;
          return 0;
        }
        oneCnt++;
      }
    } else if (v.second != 2) {
      cout << 0 << endl;
      return 0;
    }
    if (checker[v.first] == 0) {
      cout << 0 << endl;
      return 0;
    }
    ans = (ans % M) * (v.second % M);
  }
  if (oneCnt == 0 && !even) {
    cout << 0 << endl;
  } else {
    cout << ans % M << endl;
  }
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384626433832795

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int n, in;
	vector<int> v;
	cin >> n;
	rep(i, n) {
		cin >> in;
		v.push_back(in);
	}
	rep(i, n) {
		int no = i + 1;
		//node 2: key = 8, parent key = 7, left key = 2, right key = 3,
		cout << "node " << no << ": key = "<<v[i]<<", ";
		if (no != 1) {
			cout << "parent key = " << v[no / 2 - 1] << ", ";
		}
		if (no * 2 <= v.size()) {
			cout << "left key = " << v[no * 2 - 1] << ", ";
		}
		if (no * 2+1 <= v.size()) {
			cout << "right key = " << v[no * 2] << ", ";
		}
		cout << endl;

	}

}


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

#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
// #define int long long 

using namespace std;
int A[15][15];

int ans;
void findAns(int n,int m,int x,int algo[],int c=0,int i=0)
{
	if(i==n)
	{
		bool flag=true;
		for(int j=0;j<m;j++)
		{
			if(algo[j]<x)
			{
				flag=false;
				break;
			}
		}

		if(flag)
		{
			ans=min(ans,c);
		}
		return;
	}

	findAns(n,m,x,algo,c,i+1);
	for(int j=0;j<m;j++)
	{
		algo[j]+=A[i][j+1];
	}
	c+=A[i][0];
	findAns(n,m,x,algo,c,i+1);

	for(int j=0;j<m;j++)
	{
		algo[j]-=A[i][j+1];
	}
}

int32_t main()
{
	fio;
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			cin>>A[i][j];
		}
	}
	ans=INT_MAX;
	int algo[15];
	fill(algo,algo+15,0);
	findAns(n,m,x,algo);

	if(ans==INT_MAX)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[0]=='A' && s[1]=='A' && s[2]=='A')
     cout<<"No\n";
  else if(s[0]=='B' &&  s[1]=='B' && s[2]=='B')
    cout<<"No\n";
  else 
    cout<<"Yes\n";
  return 0;
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(itr, v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl

const int NIL = -1;
struct Node {
  int parent = NIL;
  int leftChild = NIL;
  int rightSibling = NIL;
};
vector<Node> tree(100000);
vector<int> depthV(100000);

int getRoot () {
  REP(i, (ll)tree.size()) {
    if(tree.at(i).parent == NIL) {
      return i;
    }
  }
}

void getAllDepth (int id, int depth) {
  depthV.at(id) = depth;
  if (tree.at(id).rightSibling != NIL) {
    getAllDepth(tree.at(id).rightSibling, depth);
  }
  if (tree.at(id).leftChild != NIL) {
    getAllDepth(tree.at(id).leftChild, depth+1);
  }
}

vector<int> getChild (int parentId) {
  vector<int> v(0);

  if (tree.at(parentId).leftChild == NIL){
    return v; 
  }

  int childId = tree.at(parentId).leftChild;

  while (childId != NIL) {
    v.push_back(childId);
    childId = tree.at(childId).rightSibling;
  }

  return v;
}

string getType (int id) {
  if (tree.at(id).parent == NIL){
    string s = "root";
    return s;
  } else
  if (tree.at(id).leftChild == NIL) {
    string s = "leaf";
    return s;
  } else {
    string s = "internal node";
    return s;
  }
}

signed main(){
  int N; cin >> N;

  REP(i, N) {
    int id, k; cin >> id >> k; 
    vector<int> c(k);
    REP(j, k){
      cin >> c.at(j);
    }
    
    // 子があれば
    if (k != 0) {
      tree.at(id).leftChild = c.at(0);
    } else {
      tree.at(id).leftChild = NIL;
    }

    REP(j, k) {
      // 親の情報をいれる
      tree.at(c.at(j)).parent = id;

      // 右兄弟の情報を入力
      if (j == k-1) {
        tree.at(c.at(j)).rightSibling = NIL;
      } else {
        tree.at(c.at(j)).rightSibling = c.at(j+1);
      }
    }
  }

  // 深さを調べる
  getAllDepth(getRoot(), 0);

  REP(i, N) {
    int node = i;
    int parent = tree.at(i).parent;
    int depth = depthV.at(i);
    string type = getType(i);
    vector<int> list = getChild(i);

    cout << "node " << node << ": parent = " << parent << ", depth = " << depth << ", " << type << ", ["; 
    REP(j, (ll)list.size()) {
      if(j != (ll)list.size()-1) {
        cout << list.at(j) << ", ";
      } else {
        cout << list.at(j);
      }
    }
    cout << "]" << endl;
  }
}



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

int some_sum(int n) {
    string n_str = to_string(n);
    int res = 0;
    for (int i=0; i<n_str.size(); i++) {
        int n_int = n_str[i] - '0';
        res += n_int;
    }
    return res;
}

int main() {
    int N, A, B, ans;
    cin >> N >> A >> B;
    ans = 0;
    for (int i=1; i<=N; i++) {
        int sum_i = some_sum(i);
        if (A <= sum_i && sum_i <= B) {
            ans += i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
#define p(x) cout<<(x)<<endl;
#define pv(v) for(auto a: v){ cout << a << endl; }

int main() {
  string s; cin >> s;
  sort(s.begin(), s.end());
  rep(i, s.size()-1) {
    if (s[i] == s[i+1]) {
      p("no");
      return 0;
    }
  }
  p("yes");
}


Measured memory_bytes: 256
h = {
  ?I => 1,
  ?V => 5,
  ?X => 10,
  ?L => 50,
  ?C => 100,
  ?D => 500,
  ?M => 1000
}
$<.map{|x|
  a=x.chop.split("").map{|c|h[c]}
  i,p,s=a.size-1,0,0
  while i>=0 do
    n=a[i]
    if n<p
      n=-n
    else
      p=n
    end
    s+=n
    i-=1
  end
  p s
}
  

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


int main() {
	int x, y;
	int legs;
	cin >> x >> y;

	for (int i = 0; i <= x; i++) {
		legs = 2 * i + 4 * (x - i);
		if (legs == y) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3596
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;


public class A
{
	public static void Main()
	{
		int N = getInt();
		Console.WriteLine((N < 1000) ? "ABC" : "ABD");
	}

	public static string[] getArgs(){ return Console.ReadLine().Split(' '); }
	public static int getInt(){ return Int32.Parse(Console.ReadLine()); }
}





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

int main(){
  int N;
  cin >> N;
  
  int ans = 0;
  if(N==105) ans = 1;
  else if(N>105){
    ans = 1;
    rep(i,107,N){
      int j = 1;
      int cnt = 0;
      while(j<=i){
        if(i%j==0) cnt++; 
        j++;
      }
      if(cnt==8) ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[] = {0, 1, 2, 1, 3, 1, 3, 1, 1, 3, 1, 3, 1};
int main()
{
	int x, y;
	
	scanf("%d%d", &x, &y);
	puts(a[x] == a[y] ? "Yes" : "No");
}

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

int main(){
  int N, ans = 0, ma = 0;
  string S;
  cin>>N;
  cin>>S;
  for(int i =0; i < S.size(); i++){
    if(S[i]=='I')ans++;
    else ans--;
    ma = max(ma, ans);
  }

  cout<<ma<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <cstring>
#include <algorithm>
#include <set>
#include <climits>
#include <numeric>
#include <iomanip>

//usings
using namespace std;

//type def
typedef long long int64;
typedef pair<int, int> ii;

//consts
const int mod = 1e9 + 7;

//methods
template<typename T>
bool chmax(T& source, const T& compare_to) {
    if(source < compare_to) {
        source = compare_to;
        return true;
    }
    return false;
}

int modpow(int64 base, int n) {
    int64 ret = 1;
    while(n) {
        if(n & 1) ret = ret * base % mod;
        base = base * base % mod;
        n >>= 1;
    }
    return ret;
}

class Solution {
private:
public:
    long double solve(long double l) {
        return powl(l / 3, 3);
    }
};

int main() {
    int n;
    cin >> n;
    Solution sol;
    auto ret = sol.solve(n);
    cout<< fixed <<setprecision(10) << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    rep(i, 365) {
        cout << (i+5)%26 + 1 << endl;
    }
}

Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	long long int ans = 0;
	int n;
	cin >> n;
	ans += n * 800;
	ans -= 200 * (n / 15);
	cout << ans << endl;

	return 0;

}




Measured memory_bytes: 256
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int K = sc.nextInt();
    int[] A = new int[M];
    int[] B = new int[M];
    for (int i = 0; i < M; i++) {
      A[i] = sc.nextInt();
      B[i] = sc.nextInt();
    }
    int[] C = new int[K];
    int[] D = new int[K];
    for (int i = 0; i < K; i++) {
      C[i] = sc.nextInt();
      D[i] = sc.nextInt();
    }
    sc.close();

    int[] fc = new int[N + 1];
    @SuppressWarnings("unchecked")
    List<Integer>[] g = new List[N + 1];
    for (int i = 0; i < M; i++) {
      int a = A[i];
      int b = B[i];
      fc[a]++;
      fc[b]++;
      if (g[a] == null && g[b] == null) {
        List<Integer> set = new ArrayList<>();
        set.add(a);
        set.add(b);
        g[a] = set;
        g[b] = set;
      } else if (g[a] == null) {
        List<Integer> set = g[b];
        set.add(a);
        g[a] = set;
      } else if (g[b] == null) {
        List<Integer> set = g[a];
        set.add(b);
        g[b] = set;
      } else if (g[a] != g[b]) {
        List<Integer> setL = g[a];
        List<Integer> setS = g[b];
        if (setL.size() < setS.size()) {
          List<Integer> temp = setL;
          setL = setS;
          setS = temp;
        }
        setL.addAll(setS);
        for (int c : setS) g[c] = setL;
      }
    }

    int[] bc = new int[N + 1];
    for (int i = 0; i < K; i++) {
      int c = C[i];
      int d = D[i];
      if (g[c] == g[d]) {
        bc[c]++;
        bc[d]++;
      }
    }

    int[] ans = new int[N + 1];
    for (int i = 1; i < N + 1; i++)
      if (g[i] != null)
        ans[i] = g[i].size() - 1 - fc[i] - bc[i];

    StringBuilder buf = new StringBuilder();
    for (int i = 1; i < N + 1; i++)
      buf.append(ans[i]).append(' ');
    System.out.println(buf);
  }
}

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

int dist(int arr[], int n){
    int dp[n+1], op1, op2 = INT_MAX;
    dp[1] = 0;
    for(int i=2;i<=n;i++){
         op1 = abs(arr[i]- arr[i-1]) + dp[i-1];
        if(i!=2){
            op2 = abs(arr[i]- arr[i-2]) + dp[i-2];
            
        }
        dp[i] = min(op1, op2);
     //   cout<<dp[i]<<" ";
    }
    
    return dp[n];
}

int main() {
	int n;
	cin>>n;
	int arr[n+1];
	for(int i=1;i<=n;i++){
	    cin>>arr[i];
	}
	cout<<dist(arr,n)<<endl;
	return 0;
}

Measured memory_bytes: 4368
n,k = [int(e) for e in input().split(" ")[:2]]
a_ls = [int(e) for e in input().split(" ")[:n]]

a_dic = {i+1: a_ls[i] for i in range(n)}
v_f_dic = {i+1: False for i in range(n)}

pos = 1
v_ls = [pos]
v_f_dic[pos] = True
# 繰り返しの探索
for i in range(k):
	# 更新
	pos = a_dic[pos]
	v_ls.append(pos)
	if v_f_dic[pos] is True:
		# 繰り返しの長さを計算
		idx0, idx1 = [i for i,e in enumerate(v_ls) if e == pos][:2]
		rep_l = idx1 - idx0
		rep_ls = v_ls[idx0:idx1]
		ans_idx = (k-idx0)%rep_l
		print(rep_ls[ans_idx])
		import sys
		sys.exit()
	v_f_dic[pos] = True
print(pos)

Measured memory_bytes: 60032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

const int maxn=1e6;
int n,k;
int a[maxn];

int main()
{
#ifndef ONLINE_JUDGE
    //freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
#endif
	cin >> n >> k;
	int ma=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		if(a[i]==k)
			return 0*puts("POSSIBLE");
	}
	sort(a,a+n);
	int g=a[0];
	for(int i=1;i<n;i++)
		g=__gcd(g,a[i]);
	if(k < a[n-1] && (g==1 || k%g==0))
		return 0*puts("POSSIBLE");
	else
		return 0*puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <queue>
#include <utility>
using namespace std;
typedef long long ll;

int main(void) {
  ll i, j, k, l, h, w, now;
  scanf("%lld%lld", &h, &w);
  char s[h + 1][w + 10];
  for(i = 0; i < h; ++i) scanf("%s", s[i + 1] + 1);
  ll dp[h + 1][w + 1];
  bool b[h + 1][w + 1];
  queue< pair<ll, ll> > q;
  for(i = 0; i <= h; ++i) for(j = 0; j <= w; ++j) dp[i][j] = 1e9;
  dp[0][1] = 0;
  for(i = 1; i <= h; ++i) for(j = 1; j <= w; ++j) {
    if(s[i][j] == '.') {
      now = dp[i - 1][j] < dp[i][j - 1] ? dp[i - 1][j] : dp[i][j - 1];
      q.push(make_pair(i, j));
      for(k = 0; k <= h; ++k) for(l = 0; l <= w; ++l) b[k][l] = true;
      while(q.size()) {
        pair<ll, ll> p = q.front();
        q.pop();
        if(dp[p.first][p.second] > now) dp[p.first][p.second] = now;
        if(p.first != h && s[p.first + 1][p.second] == '.' && b[p.first + 1][p.second]) q.push(make_pair(p.first + 1, p.second)), b[p.first + 1][p.second] = false;
        if(p.second != w && s[p.first][p.second + 1] == '.' && b[p.first][p.second + 1]) q.push(make_pair(p.first, p.second + 1)), b[p.first][p.second + 1] = false;
      }
    } else {
      now = dp[i - 1][j] < dp[i][j - 1] ? dp[i - 1][j] : dp[i][j - 1];
      now++;
      q.push(make_pair(i, j));
      for(k = 0; k <= h; ++k) for(l = 0; l <= w; ++l) b[k][l] = true;
      while(q.size()) {
        pair<ll, ll> p = q.front();
        q.pop();
        if(dp[p.first][p.second] > now) dp[p.first][p.second] = now;
        if(p.first != h && s[p.first + 1][p.second] == '#' && b[p.first + 1][p.second]) q.push(make_pair(p.first + 1, p.second)), b[p.first + 1][p.second] = false;
        if(p.second != w && s[p.first][p.second + 1] == '#' && b[p.first][p.second + 1]) q.push(make_pair(p.first, p.second + 1)), b[p.first][p.second + 1] = false;
      }
    }
  }
  printf("%lld", dp[h][w]);
  return 0;
}

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

int dp[100010],a[100010];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++)
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    /*
    for(int i=1;i<=n;i++)
        cout<<dp[i]<<' ';*/
    
    printf("\n%d",dp[n]);
}


Measured memory_bytes: 1024
#include <stdio.h>

int main()
{

    int a, b, ans = 0, i;
    scanf("%d %d", &a, &b);
    for (i = 0; i < 2; i++)
    {
        if (a >= b)
        {
            ans += a;
            a--;
        }
        else
        {
            ans += b;
            b--;
        }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 128
import math
n,k = map(int,input().split())

for i in range(1,n+1):
    ex = math.ceil(math.log2(k/i))
    if ex < 0:
        ex = 0
    if i == 1:
        ans = (1/n) * (1/2)**(ex)
    else:
        ans += (1/n) * (1/2)**(ex)    
        
print(ans)

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

using namespace std;

#define fcout(d) cout << fixed << setprecision(d)
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rep1(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define repU(i,s,t) for(int (i) = (s); (i) <= (t); ++(i))
#define repD(i,t,s) for(int (i) = (t); (i) >= (s); --(i))
#define all(v)  begin(v),end(v)
#define clr(v) fill(all(v),0)
#define l_bnd lower_bound
#define u_bnd upper_bound
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define q_ceil(n,d) ((n - 1)/(d) + 1)
#define parity(a,b) ((a)^(b) & 1LL ^ 1LL)

typedef long long ll;
typedef unsigned long long ull;
typedef double db;

const pair<int,int> DIR[] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const int INF_32 = -1 + (1 << 30);
const ll INF_64 = -1 + (1LL << 62);
const int MOD = 1e9 + 7;

ull next_subset(ull subset){
	ull tem = subset + (subset & -subset);
	ull btm = (~tem & subset) / (subset & -subset) >> 1;
	return btm | tem;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int h,w,n,c[100][100],a[10000];
	cin>>h>>w>>n;
	rep(i,n) cin>>a[i];
	int cur = 0;
	rep(i,h)rep(j,w){
		if(!a[cur]) ++cur;
		--a[cur];
		c[i][(i & 1)? w - 1 - j : j] = cur + 1;
	}
	rep(i,h){
		rep(j,w) cout<<c[i][j]<<' ';
		cout<<endl;
	}
	return 0;
}





Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskD {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			List<Integer>[] adj = new List[n];
			for (int i = 0; i < n; i++) {
				adj[i] = new ArrayList<>();
			}
			for (int i = 0; i < n - 1; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				adj[a].add(b);
				adj[b].add(a);
			}
			int m = dfs(0, -1, adj);
			int ans = 31 - Integer.numberOfLeadingZeros(m);
			out.println(ans);
		}

		private int dfs(int root, int parent, List<Integer>[] adj) {
			int setBits = 0;
			int atLeastTwice = 0;
			for (int ch : adj[root]) {
				if (ch == parent) {
					continue;
				}
				int mask = dfs(ch, root, adj);
				atLeastTwice |= (setBits & mask);
				setBits |= mask;
			}
			// weight(mask) = sum(M^i) for all set bits i in mask and
			// a large number M. Find the smallest mask such that
			// weight(rootmask) > sum of weights of children's masks.
			int last = 31 - Integer.numberOfLeadingZeros(atLeastTwice);
			int mask = setBits & ~((1 << (last + 1)) - 1);
			mask += 1 << (last + 1);
			return mask;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

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

	}
}



Measured memory_bytes: 62716
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005;
char s[MAXN];
int main(){
	scanf("%s",s);
	int len=strlen(s);
	int a=-1,b=-1;
	for(int i=1;i<len;i++){
		if(s[i]==s[i-1]){
			a=i-1,b=i;
			break;
		}
	}
	if(a==-1){
		for(int i=2;i<len;i++){
			if(s[i]==s[i-2]){
				a=i-2,b=i;
				break;
			}
		}
	}
	if(a==-1){
		printf("-1 -1\n");
	}
	else{
		printf("%d %d\n",a+1,b+1);
	}
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=1e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int a,b;
char s1[15],s2[15];
int main(){	
	read(a),read(b);
	for(int i=0;i<a;i++){
		s1[i]=b+'0';
	}
	for(int i=0;i<b;i++){
		s2[i]=a+'0';
	}
	if(strcmp(s1,s2)<0)cout<<s1<<endl;
	else cout<<s2<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

n,m,c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    tmp = 0
    for j in range(m):
        tmp += b[j] * a[i][j]
    tmp += c
    if tmp > 0:
        ans += 1

print(ans)


Measured memory_bytes: 9120
#include <cstdio>
#include <iostream>

using namespace std;

int main() {

	int cnt = 0;
	int a, b;

	while (cin >> a >> b,a) {
		for (int i = 1;i <= a - 2;i++) {
			for (int j = i + 1;j <= a - 1;j++) {
				for (int k = j + 1; k <= a;k++) {
					if (i + j + k == b)
						cnt++;
				}
			}
		}
		cout << cnt << endl;
		cnt = 0;
	}


	return 0;
}

Measured memory_bytes: 3080