akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n[2];
	while(cin>>n[0]>>n[1],n[0],n[1]){
		int num[2][101],sum[2]={};
		for(int i=0;i<2;i++){
			for(int j=0;j<n[i];j++){
				cin>>num[i][j];
				sum[i]+=num[i][j];
			}
			sort(num[i],num[i]+n[i]);
		}
		int ans[2]={101,101};
		for(int i=0;i<n[0];i++){
			int now[2]={sum[0]-num[0][i],sum[1]+num[0][i]};
			for(int j=0;j<n[1];j++){
				if(now[0]+num[1][j]==now[1]-num[1][j]&&num[0][i]+num[1][j]<ans[0]+ans[1]){
					swap(num[0][i],ans[0]);
					swap(num[1][j],ans[1]);
				}
			}
		}
		if(ans[0]==101)cout<<-1<<endl;
		else cout<<ans[0]<<" "<<ans[1]<<endl;
	}
}

Measured memory_bytes: 1180
#include<stdio.h>

int main(){
  int minv,maxv,n,x,i,j;

  scanf("%d",&n);
  scanf("%d",&minv);
  scanf("%d",&x);
  maxv=x-minv;
  if(x<minv)minv=x;
  
  for(j=1; j<n-1; j++){
    scanf("%d",&x);
    if(maxv<x-minv)maxv=x-minv;
    if(minv>x)minv=x;
  }

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

  return 0;
}



Measured memory_bytes: 2144
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
int a[114514];
int b[114514];
signed main(){
	ic(n)
	rep(0,i,n)cin>>a[i]>>b[i];
	int ans=0;
	for(int i=n-1;i>=0;i-=1){
		a[i]+=ans;
		if(b[i]==1)continue;
		if(a[i]%b[i]!=0)ans+=b[i]-(a[i]%b[i]);
	}
	c(ans)		
}	

Measured memory_bytes: 1792
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let mut a: Vec<i64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    a.sort();
    a.reverse();

    let mut ans = a[1];
    let mut val = 1i64 << 60;
    for i in 1..n {
        let tmp = (a[0] / 2 - a[i]).abs();
        if val > tmp {
            val = tmp;
            ans = a[i];
        }
    }
    println!("{} {}", a[0], ans);
}


Measured memory_bytes: 6396
n, m, c = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
ans = 0

for i in range(n):
    a = [int(i) for i in input().split()]
    if sum(_a*_b for  _a,_b in zip(a,b)) + c > 0:
        ans += 1

print(ans)


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

//read_code(drken)
typedef pair<int, int>pint;
typedef pair<int, int>Edge;

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

const int Max = 200007;
vector<Edge> G[Max];

int l[Max],r[Max],d[Max],dp[Max];
bool isOK[Max];

int n,m;

string solve(){
    rep(i,n)dp[i]=1e+9;
    rep(i,n){
        if(isOK[i])continue;
        dp[i]=0;
        priority_queue<pint, vector<pint>,greater<pint>>que;
        que.push(pint(0,i));
        while(!que.empty()){
            pint p = que.top();
            que.pop();
            for(auto e:G[p.second]){
                if(chmin(dp[e.first],dp[p.second]+e.second)){
                    que.push(pint(dp[e.second],e.first));
                }
            }
        }
    }
    rep(i,m) if(dp[r[i]] - dp[l[i]] != d[i])return "No";
    return "Yes";
}

int main() {
    cin>>n>>m;
    rep(i,Max)G[i].clear();
    memset(isOK,0,sizeof(isOK));
    rep(i,m){
        cin>>l[i]>>r[i]>>d[i];
        --l[i];--r[i];
        G[l[i]].push_back(Edge(r[i],d[i]));
        isOK[r[i]]=true;
    }
    cout<<solve()<<endl;
	return 0;
}

Measured memory_bytes: 15252
#include<bits/stdc++.h>
            using namespace std;
            #define rep(i,b) for(i=0;i<b;++i)
            #define repp(i,a,b) for(i=a;i<b;++i)
            #define endl "\n"
            #define pi 3.14159265358979323846
            #define LLONG_MAX 99999999999999
            typedef long long int lli;
            int main(){
                lli i,t,n,j,k,m,g;
                cin>>n>>k;
                string s;
                cin>>s;
                s[k-1]=tolower(s[k-1]);
                cout<<s<<endl;
                

                return 0;
            }


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    cout << max<int>({
        10 * a + b + c,
        a + 10 * b + c,
        a + b + 10 * c,
    }) << endl;
}

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

int main() {
  int N;
  cin >> N;
  std::map<string, int> m;
  string value;
  for (int i = 0; i < N; i++){
    cin >> value;
    m[value] = 1;
  }   
  cout << m.size() << endl;
}

Measured memory_bytes: 19180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int inf=1000001000;
ll INF=1e18;
ll mod=1000000007;
ll MOD=INF;


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  int ans=0;
  rep(i,n){
      if (i%2==0 && a[i]%2==1) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    vector<int> diff(n, 0);
    for(int i = 1; i < n; i++) {
        diff[i] = h[i] - h[i - 1];
    }

    for(int i = 1; i < n; i++) {
        if(diff[i] < -1) {
            cout << "No" << endl;
            return 0;
        }
        if(diff[i - 1] <= -1 && diff[i] <= -1) {
            cout << "No" << endl;
            return 0;
        }
    }

    bool dec = false;
    for(int i = 1; i < n; i++) {
        if(dec && h[i] < h[i - 1]) {
            cout << "No" << endl;
            return 0;
        }
        if(h[i] < h[i - 1]) dec = true;
        else if(h[i] > h[i - 1]) dec = false;
    }

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


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<vector>
#include<sstream>
#define int long long
#include<string>
#define float long double
using namespace std;
   signed main()
 {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin>>n;
  int a[n],b[n],c[n-1];
  for(int i=0;i<n;i++)
    cin>>a[i];
  for(int i=0;i<n;i++)
    cin>>b[i];
  for(int i=0;i<n-1;i++)
    cin>>c[i];
  int s=b[a[0]-1];
  for(int i=1;i<n;i++)
  {
      s=s+b[a[i]-1];
      if(a[i]==a[i-1]+1&&a[i]>1)
        s=s+c[a[i]-2];
  }
  cout<<s;
 }


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

int main() {
  string a;
  
  while(true) {
    cin >> a;
    if(a == "0") break;
    int sum = 0;
    for (int i = 0; i < a.size(); i++) {
      sum += a[i] - '0';
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    string S;
    cin>>N>>S;

    int E=count(S.begin(),S.end(),'E');
    
    int left=0;
    int right=E;
    int min;
    
    if(S[0]=='E'){
        min=E-1;
    }else{
        min=E;
    }
    
    for(int i=1;i<N;i++){
        if(S[i-1]=='W'){
            left++;
        }else{
            right--;
        }
        
        int tmp=0;
        if(S[i]=='E')tmp=-1;
        
        if(right+left+tmp<=min){
            min=right+left+tmp;
        }
    }
    
    cout<<min<<endl;
}

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

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n, h, ans, i, maxi = 0, t = 0;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> h;
		if (i > 0 and h <= ans) {
			t++;
		} else {
			maxi = max(maxi, t);
			t = 0;
		}
		ans = h;
	}
	maxi = max(maxi, t);
	cout << maxi << "\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;




int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a+b+1>=c){
        cout<<b+c<<endl;
    }
    else{
        cout<<a+2*b+1<<endl;
    }
    return 0;
}


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

using namespace std;

bool visited[100002];
int dp[100002];

vector<int> graph[100002];

int N, M ,x, y;

int solve(int i){
    if (visited[i]) return dp[i];
    int longest = 0;
    vector<int> connected_list = graph[i];
    // cout  << "i = " << i << ": connected_list.size() = " << connected_list.size() << endl;
    for(int j=0; j<connected_list.size(); j++){
        int connected = connected_list[j];
        if (visited[connected]==true){
            if (longest < dp[connected] + 1) longest = dp[connected] + 1;
        }else{
            int candid = solve(connected);
            if (longest < candid + 1) longest = candid + 1;
        }
    }
    dp[i] = longest;
    visited[i] = true;
    return longest;
}


int main(){
    cin >> N >> M;
    for(int i=1; i<=M; i++){
        cin >> x >> y;
        graph[x].push_back(y);
    }
    for(int i=1; i<=N; i++){
        visited[i] = false;
    }

    int longest = 0, candid;
    for(int i=1; i<=N; i++){
        int candid = solve(i);
        // cout << "i = " << i << ": candid = " << candid << endl;
        if (candid > longest) longest = candid;
    }

    cout << longest << endl;
    return 0;
}

Measured memory_bytes: 9600
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var N = cin.ReadInt;
            var valueList = cin.ReadIntArray(N);
            var ans = Math.Abs(valueList.Max()-valueList.Min());
            WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}

Measured memory_bytes: 13396
#include<stdio.h>

int main()
{

  int i,j,k=0,tmp;
  int N;
  scanf("%d",&N);
  int L[N];
  
  for(i=0;i<N;i++)
    scanf("%d ",&L[i]);
  
  for (i=0; i<N; ++i) {
    for (j=i+1; j<N; ++j) {
      if (L[i] > L[j]) {
        tmp =  L[i];
        L[i] = L[j];
        L[j] = tmp;
      }
    }
  }
  
  for(i=0;i<N-1;i++)
    k+=L[i];
  
  if(L[N-1] >= k)
    puts("No");
  
  else
    puts("Yes");
  
  return 0;
}
    
    


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

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

int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << min(A, B) + min(C, D) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	
	int A, B;
	
	scanf("%d %d", &A, &B);
	
	if ((A*B*1)%2!=0 || (A*B*2)%2!=0 || (A*B*3)%2!=0){
		printf("Yes");
	}
	else{
		printf("No");
	}
	
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define vll vector<ll>
#define sz size()
#define pb emplace_back
#define mp make_pair
#define MOD 1000000007
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL))
const int N = 100005;

int main()
{
	ll n;
	cin>>n;
	string a;
	cin>>a;
	if(n==1)
	cout<<"No";
	else
	{
		string b="",c="";
		for(ll i=0;i<n/2;i++)
		b=b+a[i];
		for(ll i=n/2;i<n;i++)
		c=c+a[i];
		if(b==c)
		cout<<"Yes";
		else
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    bool flag=0;
    for(int i=a;i<=b;i++){
        if(i%n==0)
        {
            flag=1;
            break;
        }
    }if(flag)
    cout<<"OK";
    else
        cout<<"NG";
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
int depth[214514];
int cnt[214514];
vector<int> es[214514];
LL pw2[214514];
LL rev2[214514];

struct Val {
  int S; // \sum ki
  LL b;
  LL P;
  LL em;
};

using Map = map<int, Val>;

const LL REV2 = 500000004;

LL mypow(LL base, LL exp) {
  if (exp == 0) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base%MOD;
  return res;
}

Map dfs(int v, int p) {
  Map ret;

  depth[v] = depth[p]+1;

  set<int> ds;
  vector<Map> mers;
  for (int u : es[v]) {
    if (u == p) continue;

    auto res = dfs(u, v);
    if (ret.size() < res.size()) swap(ret, res);
    mers.eb(res);
  }

  for (auto &res : mers) {
    for (auto &itr : res) {
      int d = itr.X;
      auto &v = itr.Y;

      if (!ret.count(d)) {
        auto &r = ret[d];
        r.S = 0;
        r.b = 0;
        r.P = 1;
        r.em = 0;
      }

      auto &r = ret[d];
      
      LL term = (pw2[v.S]+MOD-v.em)%MOD;
      (r.P *= term) %= MOD;
      LL inv = mypow(term, MOD-2);
      (r.b += v.em*inv%MOD) %= MOD;
      
      r.S += v.S;
      
      ds.insert(d);
    }
  }
  
  for (int d : ds) {
    auto &r = ret[d];

    r.em = r.P * r.b % MOD;
    r.P = (pw2[r.S] + MOD - r.em) % MOD;
    r.b = r.em * mypow(r.P, MOD-2) % MOD;
  }

  auto &r = ret[depth[v]];
  r.S = 1;
  r.em = 1;
  r.P = 1;
  r.b = 1;
  return move(ret);
}

int main() {
  scanf("%d", &N);
  rep(i, N) {
    int p;
    scanf("%d", &p);
    es[p].eb(i+1);
  }

  ++N;

  pw2[0] = rev2[0] = 1;
  reps(i, 1, N+10) {
    pw2[i] = pw2[i-1]*2 % MOD;
    rev2[i] = rev2[i-1]*REV2 % MOD;
  }

  LL ans = 0;
  depth[0] = -1;
  auto res = dfs(0, 0);
  for (auto &itr : res) {
    int d = itr.X;
    auto &r = itr.Y;
    ans += r.em * pw2[N-r.S] % MOD;
    ans %= MOD;
  }
  printf("%lld\n", ans);
}



Measured memory_bytes: 103040
x1, y1, x2, y2 = [int(i) for i in input().split()]

x = x2 - x1
y = y2 - y1

x23 = -y
y23 = x

x3 = x2 + x23
y3 = y2 + y23

x4 = x1 + x23
y4 = y1 + y23

print(x3, y3, x4, y4)



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
typedef long long ll;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int i,j,k;
int n;
int height[int(1e6)];
int cache[int(1e6)];


int dp(int x,int k){
    
    int miner = INT_MAX;

    if(x==0){
        return 0;
    }
    if(cache[x] != -1){
        return cache[x];
    }
    else{
        for(int b=1;b<k+1;b++){
        if(x-b >= 0){
        miner = min(dp(x-b,k) + abs(height[x]-height[x-b]) ,miner);
        }
        
    }
    return cache[x]=miner;

}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);

    cin >> n >> k;
    for(i = 0 ; i < n ; i++){
        cin >> height[i];
        cache[i] = -1; 
    }
    cout << dp(n-1,k) << endl;
}

Measured memory_bytes: 9472
n = int(input())
a = [i for i in range(n+1)]

x = 6
while x <= n:
  for i in range(n-x+1):
    a[i+x] = min(a[i+x], a[i]+1)
  x *= 6

x = 9
while x <= n:
  for i in range(n-x+1):
    a[i+x] = min(a[i+x], a[i]+1)
  x *= 9

print(a[n])

Measured memory_bytes: 7064
#include <stdio.h>

int main() {
    int i,data[5];
    for(i=0;i<3;i++){
        scanf("%d",&data[i]);
    }
    if(data[0]>data[1]){
        data[3]=data[0];
        data[0]=data[1];
        data[1]=data[3];
    }
    if(data[1]>data[2]){
        data[3]=data[1];
        data[1]=data[2];
        data[2]=data[3];
    }
    if(data[0]>data[1]){
        data[3]=data[0];
        data[0]=data[1];
        data[1]=data[3];
    }
    printf("%d %d %d\n",data[0],data[1],data[2]);

    return 0;
}

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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  set<int> st;

  rep(i, n) {
    int a;
    cin >> a;
    st.insert(a);
  }
  
  if (st.size() == n)
    cout << "YES"
         << "\n";
  else cout << "NO" << "\n";

  return 0;
}


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

int main() {
     int n;
     cin >> n;
     
     int temp = n, divider = 0;
     for(;temp != 0; temp/=10)
          divider += temp%10;
          
     if(n%divider == 0)
          cout << "Yes";
     else
          cout << "No";
     
    return 0; 
} 

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
string st;
long long a,b;
int main()
{
	cin>>a>>b;
	cin>>st;
	if(st[a]!='-')
	  {
	  	cout<<"No"<<endl;
	  	return 0;
	  }
	for(int i=0;i<st.size();i++)
		if(st[i]>='0'&&st[i]<='9');else if(i!=a)
		{
			cout<<"No"<<endl;
			return 0;
		}
	cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
from itertools import permutations

def f(i, j):
  return ((XY[i][0] - XY[j][0]) ** 2 + (XY[i][1] - XY[j][1]) ** 2) ** .5

n = int(input())
XY = [list(map(int, input().split())) for _ in range(n)]

ptn = permutations(range(n))

diff = 0
for p in ptn:
  diff += sum([f(i, j) for i, j in zip(p, p[1:])])
ans = diff / math.factorial(n)

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
  cin>>n;
  int i;
  for( i=1;i<10;i++)
  {
    if(n%i==0)
    {
      int b=n/i;
      if(b>=1 && b<=9)
      {
        break;
      }
    }
  }
  
  if(i!=10)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
   cout<<"No"<<endl; 
  }
  return 0;
}

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

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

using namespace std;
typedef long long ll;

int main(void) {
  int a, b, h ,m;
  cin >> a >> b >> h >> m;
  int hun = h * 60 + m;
  double hr = (360.0 / 720) * hun;
  double mr = (360.0 / 60) * m;
  double r = max(hr, mr) - min(hr, mr);
  double rad = r * (M_PI/180);
  double c = sqrt(a*a + b*b - 2 * a * b * cos(rad));
  cout << fixed << setprecision(15) << c << endl;
}

Measured memory_bytes: 4108
class Node():
    def __init__(self, key, pri):
        self.key = key
        self.pri = pri
        self.left = self.right = None
        

def insert(t, key, pri):
    if t == None:
        return Node(key, pri) 
    if key == t.key:
        return t                             

    if key < t.key:
        t.left = insert(t.left, key, pri)
        if t.pri < t.left.pri:
            t = rightRotate(t)
    else:
        t.right = insert(t.right, key, pri)
        if t.pri < t.right.pri:
            t = leftRotate(t)

    return t
        
def rightRotate(node):
    global root
    a = node.left
    node.left = a.right
    a.right = node
    if node == root:
        root = a
    return a

def leftRotate(node):
    global root
    a = node.right
    node.right = a.left
    a.left = node
    if node == root:
        root = a
    return a
    
        
def pre(node):
    if node == None:return
    print('',node.key, end = '');pre(node.left);pre(node.right)
    
def ino(node):
    if node == None:return
    ino(node.left);print('',node.key,end='');ino(node.right)

def find(node, key):
    if node == None:
        print('no');return
    if node.key == key:
        print('yes');return
    elif node.key > key:
        find(node.left, key)
    else:
        find(node.right, key)

def delete(t, key):
    global root
    if t == None:
        return None
    if key < t.key:
        t.left = delete(t.left, key)
    elif key > t.key:
        t.right = delete(t.right, key)
    elif key == t.key:
        if t.left == None and t.right == None:
            return None
        elif t.left == None:
            t = leftRotate(t)
        elif t.right == None:
            t = rightRotate(t)
        else:
            if t.left.pri > t.right.pri:
                t = rightRotate(t)
            else:
                t = leftRotate(t)
        return delete(t, key)
    return t

    

n = int(input())
root = None
for j in range(n):
    s, *i = input().split()
    if s[0] == 'i':root = insert(root,int(i[0]), int(i[1]))
    elif s[0] == 'f':
        find(root, int(i[0]))
    elif s[0] == 'd':
        delete(root, int(i[0]))
    else:
        ino(root);print();pre(root);print()
        
    


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

bool contain(string &str, char c){
    return str.find(c) != string::npos;
}

int main()
{
    string n, s;
    getline(cin, n);
    getline(cin, s);

    cout << (contain(s, 'Y') ? "Four" : "Three") << endl;
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  string s;
  cin >> s;

  // 解答
  cout << (s[0] != s[1] && s[1] != s[2] && s[0] != s[2] ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define HSORT(V,n) sort(V,V+n)
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    int c[n-1];
    REP(i,n) cin >> a[i];
    REP(i,n) cin >> b[i];
    REP(i,n-1) cin >> c[i];
    int man = b[a[0] - 1];
    REP(i,n-1){
        man += b[a[i+1] - 1];
        if (a[i+1] == a[i] + 1){
            man += c[a[i]-1];
        }
    }
    PRINT(man);
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll dp[85][2][2];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    dp[0][0][0] = 1000;
    dp[0][0][1] = 0;
    dp[0][1][0] = 1000;
    dp[0][1][1] = 0;
    rep(i,n){
        dp[i+1][0][0] = dp[i][0][0] + a[i] * dp[i][0][1];
        dp[i+1][0][1] = 0;
        ll mon = dp[i][1][0] + a[i] * dp[i][1][1];
        if(dp[i+1][0][0] < mon){
            dp[i+1][0][0] = mon;
            dp[i+1][0][1] = 0;
        }
        ll stk = dp[i][0][0] / a[i];
        dp[i+1][1][1] = dp[i][0][1] + stk;
        dp[i+1][1][0] = dp[i][0][0] - stk * a[i];
        stk = dp[i][1][0] / a[i];
        if(dp[i+1][1][1] < stk + dp[i][1][1]){
            dp[i+1][1][1] = stk + dp[i][1][1];
            dp[i+1][1][0] = dp[i][1][0] - stk * a[i];
        }
        else if(dp[i+1][1][1] == stk + dp[i][1][1]){
            chmax(dp[i+1][1][0], dp[i][1][0] - stk * a[i]);
        }
    }
    ll ans = max(dp[n][0][0], dp[n][1][0]);
    cout << ans << endl;
    return 0;
}


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

typedef pair<long long int,int> P; //cost,to

struct vec{
    vector<P> edge;
};

vector<vec> V;

long long int dfs(int i, int pre){
    if(V[i].edge.size()==1&&V[i].edge[0].second==pre) return 0;
    long long int maxiumum=0;
    int cost=0;
    for(auto& e:V[i].edge){
        if(e.second==pre){
            cost=e.first;
            continue;
        }
        maxiumum=max(maxiumum,dfs(e.second,i));
    }
    return cost+maxiumum;
}

int main(){
    int n;
    while(cin>>n,n){
        V.clear();
        for(int i=0;i<n;i++)V.push_back(vec());
        int P[1000];
        int D[1000];
        for(int i=1;i<n;i++) cin>>P[i];
        for(int i=1;i<n;i++) cin>>D[i];
        for(int i=1;i<n;i++){
            int p=P[i]-1;
            V[i].edge.emplace_back(D[i],p);
            V[p].edge.emplace_back(D[i],i);
        }
        long long int ans=0;
        for(int i=1;i<n;i++) ans+=3*D[i];
        for(int i=0;i<n;i++){
            if(V[i].edge.size()==1) ans-=2*V[i].edge[0].first;
        }
        long long int longest=0;
        for(int i=0;i<n;i++){
            if(V[i].edge.size()==1)continue;
            longest=max(longest,dfs(i,-1));
        }
        ans-=longest;
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<vector<PII> > VVPII;
typedef priority_queue<PII, vector<PII>, greater<PII> > PQPII;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int DX[] = {0, 1, 0, -1};
const int DY[] = {-1, 0, 1, 0};

//other
//--------------------------------------------
#define RANGE(a, c, b) ((a <= b) && (b < c))

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int INF = (int) 10e9;

int solve(int n, int m){
	VVPII node(n);
	vector<bool> done(n, false);
	REP(i, m){
		int from, to, cost;
		cin >> from >> to >> cost;
		node[from].PB(MP(cost, to));
		node[to].PB(MP(cost, from));
	}
	PQPII q;
	VI costs(n, INF);
	costs[0] = 0;
	q.emplace(0, 0);
	int result = 0;
	while(!q.empty()){
		int w = q.top().first, u = q.top().second;
		q.pop();
		if(costs[u] < w) continue;
		result += w;
		for(PII p : node[u]){
			if(p.first < costs[p.second] && !done[p.second]){
				done[u] = true;
				costs[p.second] = p.first;
				q.emplace(p.first, p.second);
			}
		}
	}
	return result;
}

int main(int argc, char const *argv[])
{
	for(int n, m; cin >> n >> m, n | m;){
		cout << solve(n, m) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;

long long n, k, now = 0;
// 65:tmp,70:ans
long long memo[75][60][60] = {0};

void setm(int f1, int f2, int to);
long long solve();

int main() {
  cin >> n >> k;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) cin >> memo[0][i][j];
  cout << solve() << endl;
  return 0;
}

void setm(int f1, int f2, int to) {
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) memo[to][i][j] = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      for(int l = 0; l < n; ++l) {
        memo[to][i][l] +=
            memo[f1][i][j] * memo[f2][j][l] % N;
        memo[to][i][l] %= N;
      }
}

long long solve() {
  long long ans = 0, now = 0;
  while((1LL << now) <= k) {
    setm(now, now, now + 1);
    ++now;
  }
  for(int i = 0; i < n; ++i) memo[65][i][i] = 1;
  for(int i = now; i >= 0; --i)
    if(k >= (1LL << i)) {
      k -= (1LL << i);
      setm(65, i, 70);
      for(int j = 0; j < n; ++j)
        for(int l = 0; l < n; ++l)
          memo[65][j][l] = memo[70][j][l];
    }
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j) {
      ans += memo[70][i][j];
      ans %= N;
    }
  return ans;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        long[] shrine = new long[a];
        int b =sc.nextInt();
        long[] temple = new long[b];
        int q = sc.nextInt();
        for (int i = 0; i < a; i++){
            shrine[i] = sc.nextLong();
        }
        for (int i = 0; i < b; i++){
            temple[i] = sc.nextLong();
        }
        for (int k = 0; k < q; k++){
            long val = sc.nextLong();
            int ind1 = binSearch(val,shrine);
            int ind2 = binSearch(val,temple);
            long min = Long.MAX_VALUE;
            min = Math.min(min,Math.abs(shrine[ind1]-val)+Math.abs(shrine[ind1]-temple[ind2]));
            if(ind2 < temple.length-1)
                min = Math.min(min,Math.abs(shrine[ind1]-val)+Math.abs(shrine[ind1]-temple[ind2+1]));
            if (ind1 < shrine.length-1)
                min = Math.min(min,Math.abs(shrine[ind1+1]-val)+Math.abs(shrine[ind1+1]-temple[ind2]));
            if (ind1 < shrine.length-1 && ind2 < temple.length-1)
                min = Math.min(min,Math.abs(shrine[ind1+1]-val)+Math.abs(shrine[ind1+1]-temple[ind2+1]));
            min = Math.min(min,Math.abs(temple[ind2]-val)+Math.abs(temple[ind2]-shrine[ind1]));
            if (ind1 < shrine.length-1)
                min = Math.min(min,Math.abs(temple[ind2]-val)+Math.abs(temple[ind2]-shrine[ind1+1]));
            if(ind2 < temple.length-1)
                min = Math.min(min,Math.abs(temple[ind2+1]-val)+Math.abs(temple[ind2+1]-shrine[ind1]));
            if (ind1 < shrine.length-1 && ind2 < temple.length-1)
                min = Math.min(min,Math.abs(temple[ind2+1]-val)+Math.abs(temple[ind2+1]-shrine[ind1+1]));
            System.out.println(min);
        }
    }
    public static int binSearch(long find, long[] arr){
        int low = 0;
        int high = arr.length-1;
        while (low < high){
            int middle = (low+high)/2;
            if(arr[middle] == find){
                return middle;
            }else if (middle < arr.length-1 && arr[middle] < find && arr[middle+1] > find){
                return middle;
            }else if (middle > 0 && arr[middle] > find && arr[middle-1] < find){
                return middle-1;
            }
            else if (arr[middle] < find){
                low = middle+1;
            }else{
                high = middle-1;
            }
        }
        return low;
    }
}


Measured memory_bytes: 103804
N, T = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

Dp = [0 for _ in range(T+1)]

ab = sorted(ab, key = lambda x: x[0])

for i in range(N):
    for j in range(T-1,-1, -1):
        if j+ab[i][0] <= T-1:
            kari2 = Dp[j] + ab[i][1]
            if  Dp[j+ab[i][0]] < kari2:
                Dp[j+ab[i][0]] = kari2
        else:
            kari2 = Dp[j] +ab[i][1]
            if Dp[T] < kari2:
                Dp[T] = kari2
                
print(max(Dp))

Measured memory_bytes: 45928
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(int i=l;i<r;i++)
#define INF (1LL<<62)

//union-find
#define UFLIMIT (1<<17)
int unicnt[UFLIMIT+10];//正ならcnt、非正なら親のindex
ll uniwei[UFLIMIT+10];
void ufinit(int n){rep(i,0,n)unicnt[i]=1;}
int uniroot(int x){int r;return unicnt[x]<=0?r=uniroot(-unicnt[x]),uniwei[x]+=uniwei[-unicnt[x]],-(unicnt[x]=-r):x;}
int unisame(int x,int y){return uniroot(x)==uniroot(y);}
ll unidiff(int x,int y){return unisame(x,y)?uniwei[y]-uniwei[x]:INF;}
//diff(x,y)=wになるようにする。矛盾したらfalse
int uni(int x,int y,ll w){
	int rx=uniroot(x),ry=uniroot(y);
	if(rx==ry)return unidiff(rx,x)+unidiff(x,y)+unidiff(y,ry)==unidiff(rx,ry);
	w=unidiff(rx,x)+w+unidiff(y,ry);
	if(unicnt[rx]<unicnt[ry]){int t=rx;rx=ry;ry=t;w=-w;}
	unicnt[rx]+=unicnt[ry];
	unicnt[ry]=-rx;
	uniwei[ry]=w;
	return 1;
}
#undef UFLIMIT

int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	ufinit(n);
	while(q--){
		int t,x,y;
		scanf("%d%d%d",&t,&x,&y);
		if(t){
			ll d=unidiff(x,y);
			printf(d==INF?"?\n":"%lld\n",d);
		}else{
			int w;
			scanf("%d",&w);
			uni(x,y,w);
		}
	}
}


Measured memory_bytes: 2976
from collections import Counter
n = int(input())
A = list(map(int, input().split()))

cnt = Counter(A)

ans = 0
for v in cnt.values():
    ans += v * (v - 1) // 2

for k in A:
    # n*(n-1)//2 - (n-1)*(n-2)//2 = n - 1
    print(ans - (cnt[k] - 1)) 


Measured memory_bytes: 33940
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


def cmb(n, r):
    mod = 10 ** 9 + 7
    ans = 1
    for i in range(r):
        ans *= n - i
        ans %= mod
    for i in range(1, r + 1):
        ans *= pow(i, mod - 2, mod)
        ans %= mod
    return ans


# 実装を行う関数
def resolve(test_def_name=""):
    n, m = map(int, input().split())

    if n == 1 or m == 1:
        print(1)
        return

    # ターゲットを素因数分解
    factor_list = factorization(m)

    ans = 1
    for i in factor_list:
        ans = ans * cmb((n - 1) + i[1], i[1])
        ans = ans % (pow(10, 9) + 7)

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """2 6"""
        output = """4"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """3 12"""
        output = """18"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """100000 1000000000"""
        output = """957870001"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def tes_t_1original_1(self):
        test_input = """データ"""
        output = """データ"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 77440
#include<iostream>
#include<algorithm>
#include<vector>
#include<utility>
#include<string>

using namespace std;

bool check(const string &s1,const string &s2,int d){
  if(s1==s2)return true;
  if(d==1){
    if(s1.empty()&&s2.size()==1||s2.empty()&&s1.size()==1)return true;
    int ld=abs(int(s1.size())-(int)(s2.size()));
    if(ld>1)return false;
    int h1=0,h2=0;
    int t1=s1.size(),t2=s2.size();
    while(h1<s1.size()&&h2<s2.size()&&s1[h1]==s2[h2]){
      h1++;
      h2++;
    }
    while(t1>0&&t2>0&&s1[t1-1]==s2[t2-1]){
      t1--;
      t2--;
    }
    if(ld==1){
      return h1==t1||h2==t2;
    }else{
      return h1+1==t1||h1+2==t1&&s1[h1]==s2[t2-1]&&s1[t1-1]==s2[h2];
    }
  }else{
    for(int i=0;i<s1.size()+1;i++){
      string ns=s1;
      ns.insert(ns.begin()+i,' ');
      for(char c='a';c<='z';c++){
	ns[i]=c;
	if(check(ns,s2,1))return true;
      }
    }
    for(int i=0;i<s1.size();i++){
      if(check(s1.substr(0,i)+s1.substr(i+1),s2,1))return true;
      string ns=s1;
      for(char c='a';c<='z';c++){
	ns[i]=c;
	if(check(ns,s2,1))return true;
      }
    }
    string ns=s1;
    for(int i=0;i+1<s1.size();i++){
      swap(ns[i],ns[i+1]);
      if(check(ns,s2,1))return true;
      swap(ns[i],ns[i+1]); 
    }
    return false;
  }
}

int main(){
  for(int n;cin>>n,n;){
    int d;
    cin>>d;
    string names[223];
    for(int i=0;i<n;i++){
      cin>>names[i];
    }
    sort(names,names+n);
    vector<pair<string,string> > ans;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	if(check(names[i],names[j],d)){
	  ans.emplace_back(names[i],names[j]);
	}
      }
    }
    for(auto e:ans){
      cout<<e.first<<','<<e.second<<endl;
    }
    cout<<ans.size()<<endl;
  }
}

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

using namespace std;

int dp[1000][8];

bool check(int a, char c)
{
	int shift;

	if (c == 'J') shift = 2;
	if (c == 'O') shift = 1;
	if (c == 'I') shift = 0;

	return (a >> shift) & 1;
}

int main()
{
	int n; cin >> n;
	char sche[1001]; cin >> sche;

	for (int i = 1; i <= 7; ++i) if (i >> 2 & 1) dp[0][i] = check(i, sche[0]);

	for (int i = 1; i < n; ++i) {
		for (int j = 1; j <= 7; ++j) {
			if (!check(j, sche[i])) continue;
			for (int k = 1; k <= 7; ++k) {
				if ((j & k) && dp[i - 1][k]) {
					dp[i][j] += dp[i - 1][k];
					dp[i][j] %= 10007;
				}
			}
		}
	}

	int ans = 0;

	for (int i = 1; i <= 7; ++i) ans += dp[n - 1][i];

	printf("%d\n", ans % 10007);
}

Measured memory_bytes: 1180
#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const int INF =100100100;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back 
#define mp make_pair



signed main (){	
	string hoge;
	cin >> hoge;
	int count1=0,count2=0;
	rep(i, hoge.length()){
		if(i%2 == 0){
			if(hoge[i] == '0'){
				count2++;
			} else {
				count1++;
			}
		} else {
			if(hoge[i] == '1'){
				count2++;
			} else {
				count1++;
			}
		}
	}
	if (count2 > count1 ) {
		cout << count1 ;
	} else {
		cout << count2 ;
	}
	cout << endl;
}


Measured memory_bytes: 512
import java.util.*;
import java.math.*;
public class Main {
	static int r; 
	static int c;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int x = in.nextInt();
		int y = in.nextInt();
		int[] ans = new int[n];
		for(int i = 1; i < n; i++) {
			for(int j = i + 1; j <= n; j++) {
				int dist = j - i;
				dist = Math.min(dist, Math.abs(i - x) + Math.abs(j - y) + 1);
				dist = Math.min(dist, Math.abs(i - y) + Math.abs(j - x) + 1);
				ans[dist] += 1;
			}
		}
		for(int i = 1; i < n; i++) {
			System.out.println(ans[i]);
		}
	}
} 


Measured memory_bytes: 21844
#include <iostream>

using namespace std;

//Compiler version g++ 6.3.0

int main()

{

    char str[8];

    

    for(int i=0 ; i<6;i++)

    {

    	cin>> str[i];    }

    

    if(str[2]==str[3] && str[4]== str[5])

    cout<<"Yes"<<endl;

    else

    cout<<"No"<<endl;

}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]
li = []
for ab in AB:
    if ab[0] == 1:
        li.append(ab[1])
    if ab[1] == N:
        li.append(ab[0])
se = set(li)
if len(se) != len(li):
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')

Measured memory_bytes: 62592
#include <stdio.h>

int main(void) {
    int i,a[5] = {0,0,0,0,0},n;
    char str[8];
    scanf("%d",&n);
    for(i = 0;i < n;i++){
        while(1){
        scanf("%s",str);
        switch(str[1]){
            case 'I':
                a[3] += a[2];
                a[2] = a[1];
                a[1] = a[0];
                a[0] = 1;
                break;
            case 'U':
                a[4]++;
                break;
            case 'O':
                a[3] = a[3] + a[2] + a[1] + a[0] + 1;
                a[2] = 0;
                a[1] = 0;
                a[0] = 0;
                break;
        }
        if(a[4] == 3){
            printf("%d\n",a[3]);
            a[0] = 0;
            a[1] = 0;
            a[2] = 0;
            a[3] = 0;
            a[4] = 0;
            break;
        }
        }
    }
	return 0;
}

Measured memory_bytes: 596
from collections import deque
n, k = map(int, input().split())
p = list(map(int, input().split()))
c = 0
l = [1] * (n - k + 1)
for i in range(k - 1):
    if p[i] > p[i + 1]:
        c += 1
if c == 0:
    l[0] = 0
for i in range(k - 1, n - 1):
    if p[i] > p[i + 1]:
        c += 1
    if p[i - k + 1] > p[i - k + 2]:
        c -= 1
    if c == 0:
        l[i - k + 2] = 0
k -= 1
qa = deque([])
a = [0] * (n - k + 1)
qb = deque([])
b = [0] * (n - k + 1)
for i in range(n):
    while qa and p[qa[-1]] > p[i]:
        qa.pop()
    while qb and p[qb[-1]] < p[i]:
        qb.pop()
    qa.append(i)
    qb.append(i)
    if qa[0] == i - k:
        qa.popleft()
    if qb[0] == i - k:
        qb.popleft()
    if i >= k - 1:
        a[i - k + 1] = p[qa[0]]
        b[i - k + 1] = p[qb[0]]
ans = l[0]
for i in range(n - k - 1):
    if (p[i] > a[i + 1] or b[i + 1] > p[i + k + 1]) and l[i + 1]:
        ans += 1
print(ans + 1 - min(l))


Measured memory_bytes: 93008
puts [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51].map(&:to_i)[gets.to_i - 1]

Measured memory_bytes: 3836
#include<stdio.h>
int main()
{
    int a,i,j,temp,count,key,m;
    while(~scanf("%d",&a))
    {
        count =0;
        int arr[a];
        for (i=0;i<a ;i++ )
            scanf("%d",&arr[i]);
        for (m=0;m<a ;m++ )
        {
            printf("%d",arr[m]);
            if(m!=a-1)printf(" ");
        }
        printf("\n");
        for (i=1;i<a ;i++ )
        {
            key=arr[i];
            j=i-1;
            while(j>=0&&(arr[j]>key))
            {
                arr[j+1]=arr[j];
                j--;
            }
            arr[j+1]=key;

            for (m=0;m<a ;m++ )
            {
                printf("%d",arr[m]);
                if(m!=a-1)printf(" ");
            }
            printf("\n");
        }

    }
    return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  if (a + b >= 10) {
  	cout << "error\n";
  }else {
  	cout << a + b << "\n";
  }
}

Measured memory_bytes: 256