akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,m;
  cin >> n >>m;
  vector<int>a(n);
  vector<int>b(n);
  vector<int>c(m);
  vector<int>d(m);
  for(int i=0;i<n;i++){
    int A,B;
    cin >> A >>B;
    a.at(i) =A;
    b.at(i)=B;
  }
  for(int i=0;i<m;i++){
    int C,D;
    cin >> C >> D;
    c.at(i)=C;
    d.at(i)=D;
  }
  int ans1 = 1<<30;
  int ans2;
  for(int i = 0;i<n;i++){
    int nowa = a.at(i);
    int nowb = b.at(i);
    for(int j=0;j<m;j++){
      int dx = abs(nowa - c.at(j))+abs(nowb -d.at(j));
      if( dx < ans1){
        ans1 = dx;
        ans2 = j+1;
      }
    }
    cout << ans2<<endl;
    ans1 = 1<<30;
  }
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define each(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define clr(a) memset((a),0,sizeof(a))
#define nclr(a) memset((a),-1,sizoef(a))
#define sz(s) (int)((s).size())
#define INRANGE(x,s,e) ((s)<=(x) && (x)<(e))
#define pb push_back
#define MP(x,y) make_pair((x),(y))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int main()
{
	const string AZ = "AZ";

	ios_base::sync_with_stdio(0);
	string s; cin >> s;
	int n = s.length();
	string t = "";
	rep (i, n )
		if ((t.length() % 2 == 0 && s[i] == 'A' ) 
		|| ( t.length() % 2 != 0 && s[i] == 'Z' ) ) t += s[i];
	
	int m = t.length();
	bool ok = (t.length() == 0 ? false : true );
	rep (i, m ){
		if (t[i] != AZ[i%2] ){
			ok = false;
			break;
		} // end if
	} // end rep

	if (ok && t[m-1] == 'A' ) t = t.substr(0,m-1); 

	if (!ok || t.length() == 0 ){
		cout << -1 << endl;
	}else{
		cout << t << endl;
	} // end if

	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
 
// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
 
#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;
 
#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>
 
#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()
 
// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //
 
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;
 
int n, Q;
int arr[N + 2];
 
 
void solve()
{
     cin >> n;
     bool f = 1;
     lop(i, 0, n)
     {
          cin >> arr[i];
          if (arr[i] == 0 ) f = 0;
     }
 
     if (f == 0)
     {
          cout << 0 << endl;
          return;
     }
 
 
     long double sum = arr[0];
     lop(i, 1, n)
     {
          // cout << sum << endl;
          sum = sum * arr[i];
          if ( sum > (long double)1e18 )
          {
               cout << -1 << endl;
               return ;
          }
     }
 
     cout << fixed << setprecision(0) << sum << endl;
 
}
 
int32_t main()
{
     ios_base::sync_with_stdio(0);   cin.tie(0);   cout.tie(0);
 
     int test = 1;
     // cin >> test;
     while (test--)solve();
 
 
}

Measured memory_bytes: 4584
/**Bismillahir Rahmanir Rahim.**/
/*gcd=--gcd(a,b);*/
/*double p =log(a);
    p=p-floor(p);
    int x=pow(10,p);    m s di
 int x =floor(log10(a)) + 1;  d co
 a=ceil(log2(n)) == floor(log2(n)); pow of 2*/

#include<bits/stdc++.h>
#include<iostream>
#include<math.h>
#include<string>
using namespace std;
#define nl endl
#define in cin
#define out cout
#define ll long long
int main()
{
    ll a,b,c,d,e,x[100100],y,z,i,j,n,xx,mi;
    char s[100];
    in>>s;
    if(s[0]=='S')out<<"Cloudy"<<nl;
    else if(s[0]=='C')out<<"Rainy"<<nl;
    else if(s[0]=='R')out<<"Sunny"<<nl;


}


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

int n;
long long dp[15][15] = {0}, ans = 0;

int fun (int xx) {
	while (xx >= 10)
		xx /= 10;
	return xx;
}

int main () {
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) {
		int tem = fun (i);
		dp[tem][i%10]++;
	}
	for (int i = 1; i <= 9; i++)
		for (int j = 1; j <= 9; j++)
			ans += dp[i][j]*dp[j][i];
	printf ("%lld", ans);
	return 0;
}
	

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

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

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

mod = 1000000007

if __name__ == "__main__":
    s=[]#"\\"のindexが入るスタック
    p=[]#popしたindexと面積のタプルが入るスタック
    i=0#index番号
    a=0#
    for c in input():
        if "\\"==c:#"\"だと認識できない仕様
            s+=[i]#index番号の取得とスタックへの挿入
        elif "/" ==c and s:#index番号が空の時はやらない
            j=s.pop()#末尾のindex番号を取得して削除
            t=i-j
            a+=t
            while p and p[-1][0]>j:
                t+=p[-1][1];
                p.pop()
            p+=[(j,t)]
        i+=1
    print(a)
    if p:
        print(len(p),*list(zip(*p))[1])
    else:
        print(0)


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n;
  while(1){
    cin >> n;
    if(n==0) return 0;
    vector<int> s(n);
    for(int i=0;i<n;i++){
      cin >> s[i];
    }
    sort(s.begin(),s.end());
    int ans=0;
    for(int i=1;i<n-1;i++){
      ans+=s[i];
    }
    cout << ans/(n-2) << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
import java.util.Scanner;

public class Main {

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

	    int n=gi();
	    int m=gi();
	    String[] A=new String[n];
	    String[] B = new String[m];
	    
	    for (int i=0; i<n; i++) {
	    	A[i]=gs();
	    }
	    for (int i=0; i<m; i++) {
	    	B[i]=gs();
	    }
	    
	    for (int i=0; i<n-m+1; i++) {
	    	for (int j=0; j<n-m+1; j++) {
	    		boolean f=true;
	    		for (int k=0; k<m; k++) {
	    			for (int l=0; l<m; l++) {
	    			    if(A[j+l].charAt(k+i) != B[l].charAt(k)) {
	    			    	f=false;
	    			    	break;
	    			    }
    			    }
	    			if(!f) {
	    				break;
	    			}
    		    }
	    		if (f) {
	    			System.out.print("Yes");
	    			return;
	    		}
	 	    }
	    }

        System.out.println("No");
//        if (a<=8&&b<=8) {
//        	System.out.print("Yay!");
//        }else {
//        	System.out.print(":(");
//        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
	
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35576
import collections
n = int(input())
a = [int(_) for _ in input().split()]
c = collections.Counter(a).items()
ans = 0
for i in c:
    if i[0] == i[1]:
        pass
    elif i[0] > i[1]:
        ans += i[1]
    else:
        ans += i[1] - i[0]
print(ans)

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

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

Measured memory_bytes: 256
from collections import defaultdict
n, c = map(int, input().split())
org = defaultdict(list)
for _ in range(n):
    s, t, ch = map(int, input().split())
    org[ch].append((s, t))


all = []
for ch in range(1, c+1):
    org[ch].sort()
    m = len(org[ch])
    for i in range(m):
        s, t = org[ch][i]
        if i == 0:
            pre_s, pre_t = s, t
            if i == m-1:
                all.append((2*pre_s-1, 2*pre_t))
        else:
            if pre_t == s:
                pre_t = t
            else:
                all.append((2*pre_s-1, 2*pre_t))
                pre_s, pre_t = s, t
            
            if i == m-1:
                all.append((2*pre_s-1, 2*pre_t))


time = [0]*(2*10**5+2)
for l, r in all:
    time[l] += 1
    time[r+1] -= 1
for i in range(2*10**5+1):
    time[i+1] += time[i]

print(max(time))


Measured memory_bytes: 64472
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N;
char A[505][505];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; ++i) scanf("%s", A[i]);

	bool isok = false;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) if (A[i][j] == '#') isok = true;
	}
	if (!isok) {
		puts("-1");
		return 0;
	}
	for (int i = 0; i < N; ++i) {
		bool full = true;
		for (int j = 0; j < N; ++j) {
			if (A[i][j] != '#') full = false;
		}
		if (full) {
			int ret = 0;
			for (int x = 0; x < N; ++x) {
				bool f2 = true;
				for (int y = 0; y < N; ++y) {
					if (A[y][x] != '#') f2 = false;
				}
				if (!f2) ++ret;
			}
			printf("%d\n", ret);
			return 0;
		}
	}
	int ret = N + 10;
	for (int r = 0; r < N; ++r) {
		bool al = false;
		for (int i = 0; i < N; ++i) {
			if (A[i][r] == '#') al = true;
		}
		int cc = 0;
		for (int i = 0; i < N; ++i) if (A[r][i] == '.') ++cc;
		if (al) {
			ret = min(ret, cc);
			continue;
		}
		for (int a = 0; a < N; ++a) {
			bool has = false;
			for (int i = 0; i < N; ++i) if (A[a][i] == '#') has = true;
			if (!has) continue;

			int cc2 = cc;
		//	if (A[r][r] == '.') --cc2;
		//	if (A[a][r] == '.') ++cc2;
			ret = min(ret, cc2 + 1);
		}
	}
	for (int x = 0; x < N; ++x) {
		bool f2 = true;
		for (int y = 0; y < N; ++y) {
			if (A[y][x] != '#') f2 = false;
		}
		if (!f2) ++ret;
	}
	printf("%d\n", ret);
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	int s[50][50];
	int m[50][50];
	for (int i = 0; i < h; i++) {
		string a;
		cin >> a;
		for (int j = 0; j < w; j++) {
			s[i][j] = (int)a[j] - '0';
		}
	}
	m[0][0] = s[0][0];
	for (int i = 1; i < w; i++) {
		m[0][i] = m[0][i - 1] + s[0][i];
	}
	for (int i = 1; i < h; i++) {
		m[i][0] = m[i - 1][0] + s[i][0];
	}
	for (int i = 1; i < h; i++) {
		for (int j = 1; j < w; j++) {
			m[i][j] = min(m[i - 1][j]+s[i][j], m[i][j - 1]+s[i][j]);
		}
	}
	cout << m[h - 1][w - 1] << endl;
}

Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll a[100100],b[100100],c[100100],d[100100];

int main(void){
	int n,i;
	ll tmp=0ll,ans=0ll,s,t;
	cin >> n;
	for(i=0; i<=n; ++i){
		cin >> a[i];
		c[i] = a[i];
	}
	for(i=0; i<n; ++i){
		cin >> b[i];
		d[i] = b[i];
	}
	for(i=0; i<n; ++i){
		s = min(c[i],d[i]);
		c[i] -= s;
		d[i] -= s;
		t = min(d[i],c[i+1]);
		c[i+1] -= t;
		d[i] -= t;
		ans += s+t;
	}
	for(i=n; i>0; --i){
		s = min(a[i],b[i-1]);
		a[i] -= s;
		b[i-1] -= s;
		t = min(b[i-1],a[i-1]);
		a[i-1] -= t;
		b[i-1] -= t;
		tmp += s+t;
	}
	ans = max(ans,tmp);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>

using namespace std;
using ll = long long;

ll DivideRoundUp(ll x, ll y) {
    return (x - 1) / y + 1;
}

int main() {
    int n;
    ll x = 1, y = 1;

    cin >> n;

    for (size_t _ = 0; _ < n; _++) {
        ll t, a;
        cin >> t >> a;
        ll sum = max(DivideRoundUp(x + y, t + a), max(DivideRoundUp(x, t), DivideRoundUp(y, a)));
        x = sum * t;
        y = sum * a;
        //cout << ":::: " << x << " " << y << endl;
    }

    cout << (x + y) << endl;
}

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

using namespace std;

using vi = vector<int>;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN(N); IN(x);

  vi A(N);
  REP(i, N) {
    cin >> A[i];
  }
  ll ans = 0;
  if (A[0] > x) {
    ans += A[0] - x;
    A[0] = x;
  }
  REP(i, N-1) {
    if (A[i] + A[i+1] > x) {
      ans += A[i+1] - (x - A[i]);
      A[i+1] = x - A[i];
    }
  }
  if (A[N-1] > x) {
    ans += A[N-1] - x;
    A[N-1] = x;
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 640
import java.util.*;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s=sc.next();
        boolean a=false,b=false,c=false,d=false;
        if(Integer.parseInt(s.substring(0,2))>0&&Integer.parseInt(s.substring(0,2))<=12){
            a=true;
        }
        if(Integer.parseInt(s.substring(0,2))>0&&Integer.parseInt(s.substring(0,2))<=99){
            b=true;
        }
        if(Integer.parseInt(s.substring(2,4))>0&&Integer.parseInt(s.substring(2,4))<=12){
            c=true;
        }
        if(Integer.parseInt(s.substring(2,4))>0&&Integer.parseInt(s.substring(2,4))<=99){
            d=true;
        }
        if(!(a||c)){
            System.out.println("NA");
        }else if(a&&!c){
            System.out.println("MMYY");
        }else if((!a)&&c){
            System.out.println("YYMM");
        }else{
            System.out.println("AMBIGUOUS");
        }
 
    }

}

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

int main() {
	// your code goes here
	string s;
	int tmp;
	
	cin >> s;
	tmp = s.find(",");
	 while(tmp != -1){
		 s.replace(tmp, 1, " ");
		 tmp = s.find(",");
	 }

	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    bool being=false;
    string ans;
    for(int type=0;type<4;type++){
        vector<bool> sorw(n); // sheep=true; wolf=false;
        sorw[0]=type&1;
        sorw[0]=!sorw[0];
        sorw[1]=(type>>1)&1;
        sorw[1]=!sorw[1];
        for(int i=2;i<n;i++){
            if(sorw[i-1]){
                if(s[i-1]=='o'){
                    sorw[i]=sorw[i-2];
                }else{
                    sorw[i]=!sorw[i-2];
                }
            }else{
                if(s[i-1]=='x'){
                    sorw[i]=sorw[i-2];
                }else{
                    sorw[i]=!sorw[i-2];
                }
            }
        }
        bool f=true;
        if(sorw[0]){
            if(s[0]=='o' && sorw[1]!=sorw[n-1]) f=false;
            if(s[0]=='x' && sorw[1]==sorw[n-1]) f=false;
        }else{
            if(s[0]=='x' && sorw[1]!=sorw[n-1]) f=false;
            if(s[0]=='o' && sorw[1]==sorw[n-1]) f=false;
        }

        if(sorw[n-1]){
            if(s[n-1]=='o' && sorw[0]!=sorw[n-2]) f=false;
            if(s[n-1]=='x' && sorw[0]==sorw[n-2]) f=false;
        }else{
            if(s[n-1]=='x' && sorw[0]!=sorw[n-2]) f=false;
            if(s[n-1]=='o' && sorw[0]==sorw[n-2]) f=false;
        }

        if(f){
            being=true;
            for(int i=0;i<n;i++){
                if(sorw[i]){
                    ans+='S';
                }else{
                    ans+='W';
                }
            }
            break;
        }
    }
    if(!being){
        cout<<-1<<endl;
        return 0;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3936
#include<bits/stdc++.h>
using namespace std;
const int N=15;

char a[N][N],b[N][N];
int n,m,match[N],use[N];

inline int Equal(int x,int y) {
	for (int i=1;i<=n;i++) {
		if (b[i][x]!=b[n-i+1][y]) return 0;
	}
	return 1;
}

inline void check() {
	int res=m&1;
	memset(use,0,sizeof(use));
	int now=1;
	for (int i=1;i<=n;i++) {
		if (i==match[i]) {
			for (int j=1;j<=m;j++)
				b[(n+1)>>1][j]=a[i][j];
		}
		if (i<match[i]) {
			for (int j=1;j<=m;j++) {
				b[now][j]=a[i][j];
				b[n-now+1][j]=a[match[i]][j];
			}
			++now;		
		}
	}		
	for (int i=1;i<=m;i++) {
		if (use[i]) continue;
		for (int j=i+1;j<=m;j++)
			if (!use[j]&&Equal(i,j)) {
				use[i]=j; use[j]=i;
				break;
			}
		if (!use[i]) {
			int flag=1;
//			for (int j=1;j<=n;j++) 
//				if (b[j][i]!=b[n-j+1][i]) flag=0;
			if (!flag) return;
			if (--res<0) return;
		}
	}
	puts("YES"); exit(0);
}

void dfs(int x,int res) {
	if (x==n+1) return (void) (check());
	if (match[x]) return (void) (dfs(x+1,res));
	if (res) {
		int flag=1;
//		for (int i=1;i<=m;i++) 
//			if (a[x][i]!=a[x][m-i+1]) flag=0;
		if (flag) {
			match[x]=x;
			dfs(x+1,0);
			match[x]=0;			
		}
	}
	for (int i=x+1;i<=n;i++) {
		if (!match[i]) {
			match[i]=x; match[x]=i;
			dfs(x+1,res);
			match[i]=0; match[x]=0;
		}
	}
}

int main() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) scanf("%s",a[i]+1);
	dfs(1,n&1);
	puts("NO");
	return 0;
}
/*
3 3
aac
bab
cba
*/

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    while (cin >> a >> b) {
        int x = a + b;
        int i = 0;
        while (x > 0) {
            x /= 10;
            i++;
        }
        cout << i << "\n";
    }
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = a; i < n; i++)
#define Repr(i, n, a) for (int i = n; i >= a; i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    int num = 30000;
    vector<int> a(n), b(n);
    rep(i, n) a[i] = num * (i + 1);
    rep(i, n) b[i] = num * (n - i);
    rep(i, n)
    {
        int a;
        cin >> a;
        b[a - 1] += i;
    }
    rep(i, n) cout << a[i] << " ";
    cout << endl;
    rep(i, n) cout << b[i] << " ";
    cout << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N, M;
  cin >> N >> M;
    int a = 0;
    set<int> se;
    rep(i, M) {
      int b = N-i-(i+1);
      if(a == 0 && (se.count(min(b, N-b)) || b == N-b)) a = 1;
      cout << i+1 << ' ' << N-i-a << endl;
      if(a == 0) se.insert(min(b, N-b));
    }
  return 0;
}


Measured memory_bytes: 7812
s = []
A = 0
B = 1
C = 2
player = ["A", "B", "C"]
for i in range(3):
    s.append(list(input()))

nextPlayer = 0

while len(s[nextPlayer]) != 0:
    tmp = s[nextPlayer].pop(0)
    if tmp == "a":
        nextPlayer = A
    elif tmp == "b":
        nextPlayer = B
    elif tmp == "c":
        nextPlayer = C

print(player[nextPlayer])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    map<ll,ll> mp;
    ll a,b,c;cin>>a>>b>>c;
    mp[a]++;
    mp[b]++;
    mp[c]++;
    if(mp[5]==2 && mp[7]==1)cout<<"YES";
    else cout<<"NO";
}




Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
import math

def solve(N: int):
    ans=0
    if N%2==0:
        n5=10
        while(N>=n5):
            ans+=max(0,N//n5)
            n5*=5
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


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

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInts();
            var a = n[0];
            var b = n[1];
            var list = new List<int>() { 0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1 };
            var z = list[a];
            var x = list[b];
            if (x == z)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  double x[30],y[30],ans=0;
  for(int i=0;;i++){
    if(scanf("%lf,%lf",&x[i],&y[i]) == EOF) break;
    if(i>1){
      double a,b,c,z;
      a = sqrt((x[i]-x[i-1])*(x[i]-x[i-1])+(y[i]-y[i-1])*(y[i]-y[i-1]));
      b = sqrt((x[i-1]-x[0])*(x[i-1]-x[0])+(y[i-1]-y[0])*(y[i-1]-y[0]));
      c = sqrt((x[0]-x[i])*(x[0]-x[i])+(y[0]-y[i])*(y[0]-y[i]));
      z = (a+b+c)/2;
      ans+=sqrt(z*(z-a)*(z-b)*(z-c));
    }
  }
  printf("%.6lf\n",ans);
  return 0;
}

Measured memory_bytes: 1240
//
// Created by yamunaku on 2019/11/05.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

ll modpow(ll x, ll a){
    ll ans = 1;
    while(a){
        if(a & 1) ans = ans * x % MOD;
        a >>= 1;
        x = x * x % MOD;
    }
    return ans;
}

ll inv(ll x){
    return modpow(x, MOD - 2);
}

vector<ll> fact;

void buildFact(int n){
    fact = vector<ll>(n + 1, 1);
    for(int i = 1; i <= n; i++){
        fact[i] = fact[i - 1] * i % MOD;
    }
}

ll perm(ll x, ll y){
    return fact[x] * inv(fact[x-y]) %MOD;
}

mti e;

ll k;

ll dfs(int x, int p){
    ll ans = 1;
    if(x == p){
        ans = perm(k, e[x].size() + 1);
    }else if(e[x].size() > 1){
        ans = perm(k - 2, e[x].size() - 1);
    }
    for(auto nx:e[x]){
        if(nx == p) continue;
        ans = ans * dfs(nx, x) % MOD;
    }
    return ans;
}

int main(){
    int n;
    cin >> n >> k;
    e = mti(n);
    buildFact(k);
    int u, v;
    rep(i, n - 1){
        cin >> u >> v;
        e[u - 1].push_back(v - 1);
        e[v - 1].push_back(u - 1);
    }
    rep(i, n){
        if(e[i].size() + 1 > k){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << dfs(0, 0) << endl;
    return 0;
}


Measured memory_bytes: 10368
arr = gets.chomp.split('').map(&:to_i)

count_1 = 0
color_1 = -1

arr.each do |s_i|
	if color_1 < 0
		color_1 = s_i
		next
	end
	if color_1 == s_i
		count_1 += 1
		if s_i == 1
			color_1 = 0
		else
			color_1 = 1
		end
	else
		color_1 = s_i
	end
end

count_2 = 0
if arr[0] == 1
	color_2 = 0
else
	color_2 = 1
end
color_2 = arr[0]

arr.each do |s_i|
	if color_2 == s_i
		count_2 += 1
		if s_i == 1
			color_2 = 0
		else
			color_2 = 1
		end
	else
		color_2 = s_i
	end
end

puts count_1 < count_2 ? count_1 : count_2


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

int a[100000+1], b[100000+1], s[100000+1];

int main(){
	int i, j;
	
	for (i=2; i<=100000; i++)  a[i]=1;
	
	for (i=2; i<=int(sqrt(100000)); i++){
	  if (a[i]==1)
	    for (j=i+i; j<=100000; j+=i)  a[j] = 0;
    }
    
    b[1]=0; b[2]=0;
    for (i=3; i<=100000; i++)
       if (a[i]==1 && a[(i+1)/2]==1)  b[i]=1;
    
    s[1]=0; s[2]=0;
    for (i=3; i<=100000; i++)
       s[i]= s[i-1] + b[i];
    
    int q, L, r;
    cin >> q;
    
    for (i=1; i<=q; i++){
    	cin >> L >> r;     //5 21
    	cout << s[r] - s[L-1] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <time.h>

#define mst(a,b)memset(a, b, sizeof(a))
#define repi(a,b)for(int i = a; i < b; i++)
#define repj(a,b)for(int j = a; j < b; j++)
#define pii pair<int,int>
#define print_time()cout<<clock()/CLOCKS_PER_SEC<<" s"<<endl;

#ifdef LOCAL
#define fre()freopen("in.txt","r",stdin)
#endif
#ifndef LOCAL
#define fre()
#endif

//static int x = []() {
//	std::ios::sync_with_stdio(false);
//	std::cin.tie(NULL);
//	return 0;
//}();

#define FASTIO
#ifdef FASTIO
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
//#define scanf abcabc
//#define printf abcabc
#endif
//#ifndef FASTIO
//#define cin abcabc
//#define cout abcabc
//#endif

typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;

using namespace std;


int a[50][50], n, d;
double D(int ind1, int ind2) {
	double ret = 0;
	int ans = 0;
	repi(0, d) {
		ans += (a[ind1][i] - a[ind2][i]) * (a[ind1][i] - a[ind2][i]);
	}
	ret = sqrt(ans);
	return ret;
}
int main() {
	cin >> n >> d;
	int cnt = 0;
	repi(0, n) {
		repj(0, d) {
			cin >> a[i][j];
		}
	}
	repi(0, n) {
		repj(i + 1, n) {
			double tmp = D(i, j);
			if (tmp == (int)tmp)cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
 
#define mod 1000000007
#define inf 1000000000
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define popcount(x) __builtin_popcountll(x)
 
const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
  ll n = 0;
  cin >> n;
  map<string, ll> mp;
  ll ans = 0;
  for(ll i = 0; i < n; i++){
    string s;
    cin >> s;
    sort(all(s));
    ans += mp[s]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11264
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 999999
#define rep(i,j) for(int i=0;i<(j);++i)
#define reps(i,j,k) for(int i=j;i<k;++i)
typedef long long ll;
typedef unsigned long long ull;

int main(){
	char c[120]={0};
	string str;
	int cnt = 0;
	bool flg = false;
	bool f = false;
	while(getline(cin,str) && str != ""){
	    str += " ";
        stack<double> S;
		int len = str.size();
		rep(i,len){
			if(str[i] == '+'){
				double a = S.top();
				S.pop();
				double b = S.top();
				S.pop();
				S.push(b+a);
			}
			else if(str[i] == '-' && str[i+1] ==' '){
				double a = S.top();
				S.pop();
				double b = S.top();
				S.pop();
				S.push(b-a);
			}
			else if(str[i] == '-' && str[i+1] != ' '){
                flg = true;
			}
			else if(str[i] == '*'){
				double a = S.top();
				S.pop();
				double b = S.top();
				S.pop();
				S.push(b*a);
			}
			else if(str[i] == '/'){
				double a = S.top();
				S.pop();
				double b = S.top();
				S.pop();
				if(a == 0)continue;
				S.push(b/a);
			}
			else if(str[i] == ' '){
				if(f)if(!flg)S.push(atof(c));
				if(f)if(flg)S.push(-1*atof(c));
				f = false;
				cnt = 0;
				memset(c,0,sizeof(c));
				flg = false;
			}
			else if(str[i] > 47 && str[i] < 58){
				f = true;
				c[cnt] = str[i];
				cnt++;
			}
		}
		printf("%lf\n",S.top());
		S.pop();
	}
	return 0;
}

Measured memory_bytes: 1252
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T>
vector<T> Dijkstra(const vector<vector<Edge<T>>> &edges, const int st) {

	const int V = (int)edges.size();
	const T inf = numeric_limits<T>::max() / 2;
	vector<T> cost(V, inf);
	cost[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> pq;
	pq.emplace(st, cost[st]);

	while (!pq.empty()) {

		Edge<T> now(pq.top().to, pq.top().cost);
		pq.pop();

		if (cost[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (cost[e.to] > tmp_cost) {
				cost[e.to] = tmp_cost;
				pq.emplace(e.to, cost[e.to]);
			}
		}
	}

	return cost; // min cost to vertex idx from st
}

template<class T>
inline bool chmax(T &a, const T b) { return a < b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	int t, a;
	cin >> t >> a;
	t--, a--;

	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		edges[u].emplace_back(v, 1);
		edges[v].emplace_back(u, 1);
	}

	auto d_t = Dijkstra(edges, t);
	auto d_a = Dijkstra(edges, a);

	DMP(d_t, d_a);

	int max_d = 0;

	auto dfs = [&](auto &&f, int now, int prev) -> void {
	
		chmax(max_d, d_a[now] - 1);

		for (const auto &e : edges[now]) {
			if (e.to == prev) continue;

			if (d_t[e.to] < d_a[e.to]) {
				chmax(max_d, d_a[e.to] - 1);
				DMP(max_d);
				f(f, e.to, now);
			}
			else if (d_t[e.to] == d_a[e.to]) chmax(max_d, d_a[e.to]);

		}

	};
	dfs(dfs, t, -1);

	cout << max_d << "\n";

	return 0;
}


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

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    if(c -a - b <= 0){
        cout << "No" << endl;
    }else if(a * a + b * b + c * c - 2 * a * b - 2 * b * c - 2 * c * a <= 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    system("pause");
    return 0;
}

Measured memory_bytes: 504
// ABC093_C
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    vector<ll> vec(3);
    REP(i, 3) cin >> vec[i];
    sort(vec.begin(), vec.end());
    REP(i, 3) vec[i] = vec[2] - vec[i];  // 差を取る
    
    // トップとの差が偶数かどうかを調べる
    ll num_odd = 0;  // 0 ~ 2
    REP(i, 3) if (vec[i]%2 != 0) num_odd++;
    
    if (num_odd == 0) {
        // 差分が二つとも２の倍数
        cout << (vec[0] + vec[1])/2 << "\n";
    } else if (num_odd == 1) {
        // ここが一番複雑
        // 差が奇数：トップも奇数
        ll res = 0, diff0 = vec[0], diff1 = vec[1];
        
        // top と 差が偶数の方に数字に１を足す
        // 当然奇数じゃないものの差も増える
        if (diff0%2 == 0) {
            diff0++;
        } else {
            diff1++;
        }
        res++;
        // ここまででどっちも奇数になる．
        
        diff0--;
        diff1--;
        res++;
        cout << (diff0 + diff1)/2 + res << "\n";
    } else if (num_odd == 2) {
        // 差分が二つとも奇数
        ll res = 0;
        vec[0]--;
        vec[1]--;
        res++;
        // ここまでで偶数になった
        cout << (vec[0] + vec[1])/2 + res << "\n";
    }
    
    return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args)throws Exception{
		InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        
        String[] nm = br.readLine().split(" ");
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);
        int[][] an = new int[n][m];
        int[] bn = new int[m];
		for (int i = 0; i < n; i++)
		{
			String[] aninput = br.readLine().split(" ");
			for (int j = 0; j < m; j++)
			{
				an[i][j] = Integer.parseInt(aninput[j]);
			}
		}
		for (int i = 0; i < m; i++)
		{
			String bninput = br.readLine();
			bn[i] = Integer.parseInt(bninput);
		}
		
		
		for (int i = 0; i < n; i++)
		{
			int sum = 0;
			for (int j = 0; j < m; j++)
			{
				sum += an[i][j] * bn[j];
			}
			System.out.println(sum);
		}
		
	}

}

Measured memory_bytes: 27508
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long count=1;
      for(int i=0;i<n;i++){
        int a = sc.nextInt();
        int c;
        if(a%2==0){
          c=2;
        }else{
          c=1;
        }
        count=count*c;
      }
      long all = (long)Math.pow(3,n);
      System.out.println(all-count);
    }
}

Measured memory_bytes: 35792
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
const int M=100010;
const int MOD=1000000007;
const long long INF=1000000007;
using ll=long long;


//vars;
int W,H,ans=0,shortest_pass=0;
char s[55][55];

int BFS(){
	//前後左右に動くことを想定するため,
	//(x,y)を(x+dx[i],y+dy[i])に移動させることを考える.
	int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
	queue<P> que;
	//初期位置からの距離(distance)を調べる.
	int dist[55][55];
	//わかりやすさのため,初期位置を(0,0)ではなく(1,1)にした.
	//すべての点をINF(=未訪であるというフラグ)にする.
	rep(j,1,H+1)rep(i,1,W+1)dist[i][j]=INF;
	//最初の点をスタートでありゴールと考えると,
	//dist[1][1]==1である.
	dist[1][1]=1;
	//まず最初は(1,1)を起点にして考える.
	que.push(P(1,1));
	//s[i][j]がゴール,もしくはゴールに行けないと
	//わかったときに終了する.
	while(que.size()){ 
		P p=que.front();
		que.pop();
		rep(i,0,4){
			//まず(1,1)の前後左右を調べる.
			int next_x=p.first+dx[i];
			int next_y=p.second+dy[i];
			if(s[next_x][next_y]=='.'&&
				next_x>=1&&next_x<=W&&
				next_y>=1&&next_y<=H&&
				dist[next_x][next_y]==INF){
				que.push(P(next_x,next_y));
				dist[next_x][next_y]=dist[p.first][p.second]+1;
			}
		}
	}
	return dist[W][H];
}

int main() {
	//input;
	cin>>H>>W;
	rep(j,1,H+1)rep(i,1,W+1){
		cin>>s[i][j];
		//'.'の点を数える.
		if(s[i][j]=='.')ans++;
	}

	//output;
	shortest_pass=BFS();
	//ゴールに行けないとき,dist[W][H]は更新されず
	//INFのままなので,"-1"を出力する.
	if(shortest_pass==INF)cout<<"-1"<<endl;
	//ゴールに行けるとき、その最短コース以外の'.'は
	//全て'#'にしても問題ない.
	else cout<<ans-shortest_pass<<endl;
}

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

int main(){
    string a, b;
    cin >> a >> b;
    string c = a + b; 
    double ans = atoi(c.c_str());
    ans = sqrt(ans);

    if(ans - (int)ans <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

}

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

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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.141592653589793238462643383279;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353

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

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

int main(void){
    int N; cin >> N;
    string s; cin >> s; s = "<" + s;

    ll dp[N+1][N+1]; REP(i,N+1)REP(j,N+1) dp[i][j] = 0;

    dp[0][N] = 1;
    REP(i,N){
        ll sum = 0;
        if(s[i] == '<'){
            REP(j,N-i){
                sum += dp[i][N-i-j];
                (dp[i+1][N-i-j-1] += sum) %= MOD;
            }
        }
        else{
            REP(j,N-i){
                sum += dp[i][j];
                (dp[i+1][j] += sum) %= MOD;
            }
        }
    }

    ll ans = dp[N][0];
    cout << ans << en;
    return 0;
}

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

int dfs(vector<int>(&dp), pair<int, int> num[], int n, int m)
{
    if (n <= 0)
    {
        return 0;
    }

    if (dp[n] == INT_MIN)
    {
        for (int i = 0; i < m; i++)
        {
            if (n - num[i].second >= 0)
            {
                dp[n] = max(dp[n], dfs(dp, num, n - num[i].second, m) + 1);
            }
        }
    }
    return dp[n];
}

int main()
{
    int N, M;
    cin >> N >> M;
    int stick[10] = {INT_MAX, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    pair<int, int> num[M];
    int A;
    for (int i = 0; i < M; i++)
    {
        cin >> A;
        num[i] = make_pair(A, stick[A]);
    }
    sort(num, num + M);
    reverse(num, num + M);

    vector<int> dp(N + 1, INT_MIN);
    dp[0] = 0;
    int digit = dfs(dp, num, N, M);

    string ans = "";
    while (digit > 0)
    {
        for (int i = 0; i < M; i++)
        {
            if (N - num[i].second >= 0 && dp[N - num[i].second] == digit - 1)
            {
                ans += to_string(num[i].first);
                digit--;
                N -= num[i].second;
                break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderD
{
    private static int n;
    private static List<Tuple<int, long>>[] to;
    private static long[] d;

    static void Main()
    {
        n = int.Parse(Console.ReadLine());

        Tuple<int, int, long>[] edges = new Tuple<int, int, long>[n - 1];
        for (int i = 0; i < n - 1; i++)
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            int u = int.Parse(words[0]);
            int v = int.Parse(words[1]);
            long w = long.Parse(words[2]);
            edges[i] = Tuple.Create(u - 1, v - 1, w);
        }

        to = new List<Tuple<int, long>>[n];
        for (int i = 0; i < n; i++)
        {
            to[i] = new List<Tuple<int, long>>();
        }


        for (int i = 0; i < n - 1; i++)
        {
            var edge = edges[i];
            to[edge.Item1].Add(Tuple.Create(edge.Item2, edge.Item3));
            to[edge.Item2].Add(Tuple.Create(edge.Item1, edge.Item3));
        }

        d = new long[n];
        for (int i = 0; i < n; i++)
        {
            d[i] = -1;
        }

        d[0] = 0;
        Process(0);

        for (int i = 0; i < n; i++)
        {
            Console.WriteLine(d[i] % 2);
        }
    }

    private static void Process(int index)
    {
        long current = d[index];
        List<Tuple<int, long>> nexts = to[index];
        foreach (var next in nexts)
        {
            int node = next.Item1;
            long distance = next.Item2;
            if (d[node] == -1)
            {
                d[node] = current + distance;
                Process(node);
            }
        }
    }
}

Measured memory_bytes: 43412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
double a;
double k=0;
int main()
{
    cin >> a;
    for(double i = 100; ; i *= 1.01){
        i = (ll)i;
        if(i >= a)break;
        k++;
    }
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 3784
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    vector<ll> a(n), b(n);
    // ll ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    vector<ll> added(n, 0);

    for(int i = n - 1; i >= 0; i--){
        if(i < n - 1) a[i] += added[i + 1];
        if(i < n - 1){
            if(a[i] % b[i] != 0){
                added[i] = added[i + 1] + (b[i] - a[i] % b[i]);
            } else {
                added[i] = added[i + 1];
            }
        } else {
            if(a[i] % b[i] != 0){
                added[i] = b[i] - a[i] % b[i];
            } else {
                added[i] = added[i + 1];                
            }
        }
                  

    }

    cout << added[0] << endl;




}


Measured memory_bytes: 2560
#!/usr/bin/python3
# -*- coding: utf-8 -*-

MOD = 1000000007


def solve():
  N = int(input())
  Sn = str(input())
  Slr = ["L" for _ in range(2*N)]

  for i in range(1,2*N):
    if Sn[i-1] == Sn[i]:
      Slr[i] = "LR".strip(Slr[i-1])
    else:
      Slr[i] = Slr[i-1]

  if Slr.count("L")!=Slr.count("R"):
    return 0
  if Sn[0]!="B" or Sn[-1]!="B":
    return 0

  ans,l,r = [1,1,0]
  for i in range(1,2*N):
    if Slr[i]=="L":
      l += 1
    else:
      ans = (ans*(l-r)) % MOD
      r += 1
  for i in range(1,N+1):
    ans = (ans*i)%MOD
  return ans


ans = solve()
print(ans)

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

#define INF 1LL << 60
#define pb push_back
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)

int N;
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

/**
 * 累積GCDの計算
 * L[i] := GCD(A[0]..A[i-1])
 * R[i] := GCD(A[i]..A[N-1])
 */
vi L, R;
int cumulativeGcd(vi A) {
    L.resize(N + 1, 0);
    R.resize(N + 1, 0);
    for (int i = 0; i < N; i++) L[i+1] = gcd(L[i], A[i]);
    for (int i = N - 1; i >= 0; i--) R[i] = gcd(R[i+1], A[i]);
}

int main() {
    cin >> N;
    vi A(N);
    REP(i, N) cin >> A[i];

    cumulativeGcd(A);

    int M = 0;
    REP(i, N) {
        M = max(M, gcd(L[i], R[i+1]));
    }

    cout << M << endl;

    return 0;
}


Measured memory_bytes: 1792