akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define REP(i,x,y) for(ll i = x;i <= y;++i)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
const ll N = 30;
ll po[N];
int main() {

    localTest();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    po[0] = 1;
    for(ll i = 1;i < 30;++i) po[i] = po[i - 1] * 26;
    ll n;
    cin >> n;
    ll mul = 26, len = 1, val = mul;
    while(val < n) mul *= 26, ++len, val += mul;
    // debug(len);
    for(ll i = 1;i < len;++i) n -= po[i];
    // debug(n);
    string ans = "";
    for(ll i = 0;i < len - 1;++i) {
        for(ll j = 25;j >= 0;--j) {
            if(j * po[len - i - 1] < n) {
                // debug(i, j);
                ans += (char)(j + 'a');
                n -= po[len - i - 1] * (j);
                break;
            }
        }
    }
    // debug(n);
    ans += (char)(n - 1 + 'a');
    cout << ans << "\n";

    
    return 0;
}

Measured memory_bytes: 3652
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class BContestWithDrinksEasy {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n;
        in >> n;
        vi T(n);
        in >> T;
        int sum = accumulate(all(T), 0);
        int m;
        in >> m;
        FOR(i, 0, m) {
            int p, x;
            in >> p >> x;
            int res = sum - T[p - 1] + x;
            out << res << '\n';
        }
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    BContestWithDrinksEasy solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3660
#include<stdio.h>
#define M 100000
#define SE 2000000000

struct C{
	char su;
	int va;
};

struct C l[M/2+2],r[M/2+2];

void me(struct C a[],int n,int left,int mid,int right){
	int i,j,k;
	int n1=mid-left;
	int n2=right-mid;
	for(i=0;i<n1;i++)l[i]=a[left+i];
	for(i=0;i<n2;i++)r[i]=a[mid+i];
	l[n1].va=r[n2].va=SE;
	i=j=0;
	for(k=left;k<right;k++){
		if(l[i].va<=r[j].va){
			a[k]=l[i++];
		}else{
			a[k]=r[j++];
		}
	}
}

void meS(struct C a[],int n,int left,int right){
	int mid;
	if(left+1<right){
		mid=(left+right)/2;
		meS(a,n,left,mid);
		meS(a,n,mid,right);
		me(a,n,left,mid,right);
	}
}

int par(struct C a[],int n, int p,int r){
	int i,j;
	struct C t,x;
	x=a[r];
	i=p-1;
	for(j=p;j<r;j++){
		if(a[j].va<=x.va){
			i++;
			t=a[i];
			a[i]=a[j];
			a[j]=t;
		}
	}
	t=a[i+1];
	a[i+1]=a[r];
	a[r]=t;
	return i+1;
}

void quick(struct C a[],int n, int p, int r){
	int q;
	if(p<r){
		q=par(a,n,p,r);
		quick(a,n,p,q-1);
		quick(a,n,q+1,r);
	}
}

int main(){
	int n,i,v;
	struct C a[M],b[M];
	char s[10];
	int stable=1;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%s %d",s,&v);
		a[i].su=b[i].su=s[0];
		a[i].va=b[i].va=v;
	}
	
	meS(a,n,0,n);
	quick(b,n,0,n-1);
	
	for(i=0;i<n;i++){
		if(a[i].su!=b[i].su)stable=0;
	}
	
	if(stable==1)printf("Stable\n");
	else printf("Not stable\n");
	for(i=0;i<n;i++){
		printf("%c %d\n",b[i].su,b[i].va);
	}
	
	return 0;
}


Measured memory_bytes: 4016
#include <iostream>
#include <string>
#define rep(i,n) for (int i = 0; i<n; i++)
using namespace std;

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

    int now;
    int bef;
    long long ans = 0;

    cin >> bef;
    
    rep(i,n-1) {
        cin >> now;
        if(bef > now) {
            ans += (bef - now);
        }else{
            bef = now;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define show(x) {for(auto i: x){cout << i << " ";} cout<<endl;}
#define showm(m) {for(auto i: m){cout << m.x << " ";} cout<<endl;}
typedef long long ll;
typedef pair<int, int> P;
ll gcd(int x, int y){ return y?gcd(y, x%y):x;}
ll lcm(ll x, ll y){ return (x*y)/gcd(x,y);}


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int h_max = 0;
    int h_min = 100;
    rep(i, n){
        cin >> a[i];
        h_max = max(a[i], h_max);
    }

//    cout << h_min << ":"<< h_max << endl;
    int ans=0;
    for (int i = h_max; i > 0; i--)
    {
        int flag = 0;
        rep(j, n){
            if (a[j]==i){
                a[j]--; 
                if(flag == 0){
                    ans++;
                    flag = 1;
                }
            } else {
                flag = 0;
            }
 //           cout << a[j] << ":";
        }
//        cout << ans << endl;
    }

    cout << ans << endl;
    


}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = (a); (i) < (b); (++(i)))
#define rep(i, n)     repd(i, (0), (n))
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

int main(int argc, const char* argv[]) {
  u64 n, k;
  cin >> n >> k;
  
  vector<u64> h(n);
  rep(i, n) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  
  u64 ret = 0xFFFFFFFFFFFFFFFF;
  rep(i, n-k+1) {
    debug(i);
    u64 tmp = h[i+k-1] - h[i];
    if(tmp < ret) ret = tmp;
  }
  
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
S = input()

s1 = set()
s2 = set()
s3 = set()

for s in S[::-1]:
  for _s in s2:
    s3.add(s+_s)
  for _s in s1:
    s2.add(s+_s)
  s1.add(s)

print(len(s3))

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int N, K; cin >> N >> K;
	vector<vector<int>>GRID(K, vector<int>(K));
	vector<vector<int>>SUM1(K, vector<int>(K));
	vector<vector<int>>SUM2(K, vector<int>(K));
	int cntB = 0, cntW = 0;
	for (int i = 0; i < N; i++) {
		int x, y;
		char c;
		cin >> x >> y >> c;

		x %= 2 * K;
		y %= 2 * K;

		if (y >= K && x < K) {
			if (c == 'B')c = 'W';
			else c = 'B';
		}
		else if (x >= K&&y < K) {
			if (c == 'B')c = 'W';
			else c = 'B';
		}

		x %= K;
		y %= K;

		if (c == 'B') {
			SUM1[x][y]++;
			cntB++;
		}
		else {
			SUM2[x][y]++;
			cntW++;
		}
	}

	for (int i = 0; i < K; i++) {
		for (int j = 1; j < K; j++) {
			SUM1[i][j] += SUM1[i][j - 1];
			SUM2[i][j] += SUM2[i][j - 1];
		}
	}
	for (int i = 1; i < K; i++) {
		for (int j = 0; j < K; j++) {
			SUM1[i][j] += SUM1[i - 1][j];
			SUM2[i][j] += SUM2[i - 1][j];
		}
	}

	int ans = 0;
	for (int i = 0; i < K; i++) {
		for (int j = 0; j < K; j++) {
			int cnt1 = 0, cnt2 = 0;

			cnt1 = SUM1[K - 1][K - 1] - SUM1[i][K - 1] - SUM1[K - 1][j] + 2 * SUM1[i][j];
			cnt2 = SUM2[K - 1][K - 1] - SUM2[i][K - 1] - SUM2[K - 1][j] + 2 * SUM2[i][j];

			ans = max(ans, max(cnt1 + cntW - cnt2, cnt2 + cntB - cnt1));
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12032
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    String S = sc.next();
    if (N % 2 == 1) {
      System.out.println("No");
      return;
    }
    for (int i = 0; i < N / 2; i++) {
      if (S.charAt(i) != S.charAt(i + N/2)) {
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}


Measured memory_bytes: 22612
#include <stdio.h>
#include <stdbool.h>

bool is_leap_year(int y);

int get_leap_years(int* lyl,int yb,int ye)
{
  int n=0;
  for(int i=yb;i<=ye;i++) {
      if(is_leap_year(i)) {
	  lyl[n]=i;
	  n++;
	}
    }
  return n;
}

int main()
{
    int leap_years_list[1000]; //A.D. 0 - A.D. 3000 の間に閏年は高々1000個しかない

    bool first_set = true; //一つ目のセットの前にだけは改行を入れてはいけないので

    while (true) {
        int year_begin, year_end;

        //読み込み
        scanf("%d %d", &year_begin, &year_end);

        //終了判定
        if (year_begin == 0 && year_end == 0) {
            break;
        }

        //閏年を計算する
        int leap_years_count = get_leap_years(leap_years_list, year_begin, year_end);

        //セットとセットの間には空行を入れる
        if (first_set) {
            first_set = false;
        } else {
            putchar('\n'); //putcharは一文字だけ出力する関数です
        }

        //閏年を出力
        if (leap_years_count == 0) {
            puts("NA"); //putsは与えられた文字列を出力した後改行する関数です
        } else {
            for (int i = 0; i < leap_years_count; i++) {
                printf("%d\n", leap_years_list[i]);
            }
        }
        
    }
}

bool is_leap_year(int y)
{
    if (y % 400 == 0) {
        return true; 
    } else if (y % 100 == 0) {
        return false;
    } else {
        return y % 4 == 0;
    }
}

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

int main(void){
    string s;
    int a = 0;
    bool check = true;
    cin >> s;
    for(int i = 2;i < s.size()-1;i++){
        if(s[i] == 'C'){
            if(a > 0)check = false;
            else a = i;
        }
    }
    if(a == 0)check = false;
    if(s[0] != 'A')check = false;
    for(int i = 0;i < s.size();i++){
        if(i != 0 && i != a){
            if(islower(s[i]) == 0)check = false;
        }
    }
    if(check == true)cout << "AC" << endl;
    else cout << "WA" << endl;
}

Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: i, j, n, result = 0
  integer(8), allocatable :: a(:), l(:), r(:)

  read *, n
  allocate (a(n), l(0:n), r(n+1))
  read *, a

  l(0) = 0
  l(1) = a(1)
  r(n+1) = 0
  r(n) = a(n)
  do i = 2, n
    l(i) = euclid(l(i-1), a(i))
    r(n+1-i) = euclid(r(n+2-i), a(n+1-i))
  end do

  do i = 1, n
    result  = max(euclid(l(i-1), r(i+1)), result)
  end do

  print '(i0)', result

contains
  function euclid(a, b) result (res)
    integer(8) :: a, b, u, v, res
    u = a; v = b
    do while(v /= 0)
      res = mod(u, v)
      u = v
      v = res
    end do
    res = u
  end function
end program

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        string s;
        cout << "0\n";
        cout << flush;
        cin >> s;
        if(s == "Vacant"){
            return 0;
        }
        int l = 0, r = n - 1;
        while(l <= r){
            int mid = (l + r) / 2;
            cout << mid << '\n';
            cout << flush;
            string str;
            cin >> str;
            if(str == "Vacant"){
                return 0;
            }
            if(mid % 2){
                if(str != s){
                    l = mid + 1;
                }else{
                    r = mid - 1;
                }
            }else{
                if(str == s){
                    l = mid + 1;
                }else{
                    r = mid - 1;
                }
            }
        }
    }
}

Measured memory_bytes: 32084
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>

using lli = long long int;
int inf = 1000000007;
using namespace std;
#define sort(X) sort(X.begin(),X.end())

int N, M;
int X, Y, Z;

int root(vector<int>& p, int x) { return (p[x] == x ? x : p[x] = root(p, p[x])); }
void unite(vector<int> & p, int a, int b) {
	int x = root(p, a);
	int y = root(p, b);
	if (x != y)p[x] = y;
}

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

	vector<int> parent(N);
	for (int i = 0; i < N; i++)parent[i] = i;

	for (int i = 0; i < M; i++) {
		cin >> X >> Y >> Z;
		unite(parent, X - 1, Y - 1);
	}

	vector<bool> unique(N);
	int ans = 0;
	for (int i = 0; i < N; i++)
		if (!unique[root(parent, i)]) { ans++; unique[root(parent, i)] = true; }

	cout << ans << endl;
	return 0;
}

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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N;
	cin >> N;
	vector<int64_t> A(N);
	for(int i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	
	int64_t counter = 0;
	sort(A.begin(), A.end());
	if (N == 2) {
		counter = A.at(1) - A.at(0);
	}
	else if (N == 3) {
		counter = max(2*A.at(2)-A.at(0)-A.at(1), A.at(2)+A.at(1)-2*A.at(0));
	}
	
	else if(N % 2 == 0) {
		//int64_t counter1 = 0;
		//int64_t counter2 = 0;
		int M = N / 2;
		for (int i = M+1; i < N; i++) {
			counter = counter + 2*A.at(i);
		//	counter2 = counter2 - 2*A.at(i);	
		}
		for (int i = 0; i < M-1; i++) {
			counter = counter - 2*A.at(i);
		//	counter2 = counter2 + 2*A.at(i);
		}
		//counter = max(counter1+A.at(M)+A.at(M-1), counter2-A.at(M)-A.at(M-1));
		counter = counter + A.at(M) - A.at(M-1);
	}
	else {
		int64_t counter1 = 0;
		int64_t counter2 = 0;
		int M = (N-1) / 2;
		for (int i = M+1; i < N; i++) {
			counter1 = counter1 + 2*A.at(i);
			counter2 = counter2 - 2*A.at(N-1-i);	
		}
		for (int i = 0; i < M-1; i++) {
			counter1 = counter1 - 2*A.at(i);
			counter2 = counter2 + 2*A.at(N-1-i);
		}
		counter = max(counter1-A.at(M)-A.at(M-1), counter2+A.at(N-1-M)+A.at(N-1-(M-1)));
	}
	
	cout << counter << endl;

}



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

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
  int n;
  cin >> n;
  double res = 0;
  for (int i = 1; i <= n; ++i) {
    int x;
    cin >> x;
    res += 1. / x;
  }
  res = 1 / res;
  cout << fixed << setprecision(10) << res << "\n";
}

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  test_case();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    
    if((a*b)%2==0){
      System.out.println("Even");
    }else{
      System.out.println("Odd");
    }
  }
}

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

#define INF 1145141919
using LL = long long int;
#define II pair<int, int>

using namespace std;

const int MAX_N = 10;
int N;
int A[MAX_N];

int main()
{
  cin >> N;
  for (size_t i = 0; i < N; i++) {
    cin >> A[i];
  }

  LL ans = pow((LL)3, N);

  LL diff = 1;
  for (size_t i = 0; i < N; i++) {
    if(A[i] % 2 == 0) {
      diff *= 2;
    }
  }

  cout << ans - diff << endl;

  return 0;
}


Measured memory_bytes: 640
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N;
	string S;
	cin >> N>> S;
	int ans = 0;
	
	for (int i = 0; i < N; i++) {
		vector<int> V(26, 0);
		int now = 0;
		for (int j = 0; j < i; j++) {
			V[(int)S[j] - 97]++;
		}

		for (int j = i; j < N; j++) {
			if (V[(int)S[j] - 97]) {
				now++;
				V[(int)S[j] - 97] = 0;
			}
		}
		ans = max(ans, now);
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
void swap(int* a, int* b) { int c = *a; *a = *b; *b = c; }

int main(void) {
	int n, l;
	int tunnel_l[101], tunnel_r[101]; /* トンネルの状態 */
	int t, lastant;
	int i;

	/* データセット毎の処理 */
	while (scanf("%d%d", &n, &l) == 2 && n >= 1 && n <= 20 && l >= n + 1 && l <= 100) {
		/* 初期化する */
		for (i = 0; i < l + 1; i++) {
			tunnel_l[i] = 0;
			tunnel_r[i] = 0;
		}
		t = 0;

		/* アリを読み込む */
		for (i = 1; i <= n; i++) {
			char d; int p;
			scanf("%1s%d", &d, &p);
			if (d == 'L') tunnel_l[p] = i; /* 左向きのアリを入れる配列 */
			else if (d == 'R') tunnel_r[p] = i; /* 右向きのアリを入れる配列 */
		}

		/* アリの動きをシミュレートする */
		int f = 1;
		while (f) {
			t++;
			/* アリを歩かせる */
			for (i = 0; i <= l - 1; i++) {
				tunnel_l[i] = tunnel_l[i+1];
				tunnel_r[l-i] = tunnel_r[l-i-1];
			}
			/* 衝突を判定する */
			for (i = 1; i <= l - 1; i++) {
				if (tunnel_l[i] && tunnel_r[i]) swap(tunnel_l + i, tunnel_r + i); /* 衝突した2匹の向きを変える */
			}

			/* 全てのアリがトンネルを出たか調べる */
			f = 0;
			for (i = 1; i <= l - 1; i++) {
				if (tunnel_l[i] || tunnel_r[i]) {
					f = 1; /* トンネルにアリがいる */
					break;
				}
			}
			if (f == 0) {
				/* シミュレーション終了 */
				if (tunnel_l[0]) lastant = tunnel_l[0];
				else lastant = tunnel_r[l];
			}
		}

		printf("%d %d\n", t, lastant);
	}
	return 0;
}

Measured memory_bytes: 596
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val w = sc.next().toLong()
    val h = sc.next().toLong()
    val x = sc.next().toLong()
    val y = sc.next().toLong()

    println(abc130c(w, h, x, y))
}

private fun abc130c(w: Long, h: Long, x: Long, y: Long): String {
    var area = w * h / 2.0
    var ok = 0
    if (x + x == w && y + y == h) ok = 1

    return "$area $ok"
}

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

using namespace std;

#define MOD 1000000007
#define ll long long int
#define ld long double
#define pb push_back
#define mkp make_pair
#define pii pair<int, int> 
#define pll pair<long long int, long long int>
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%lld", &x)
#define fi first
#define sc second
#define deb 0

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

	int A[5];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A+3);
	cout << A[0] + A[1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a,b,c,tmp;

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

  if(a > b)
    {
      tmp = a;
      a = b;
      b = tmp;
    }
  if(b > c)
    {
      tmp = b;
      b = c;
      c = tmp;
    }
  if(a > b)
    {
      tmp = a;
      a = b;
      b = tmp;

    }

  printf("%d %d %d\n",a,b,c);
  return 0;
}


      
 



Measured memory_bytes: 2084
unittest
{
	assert( [ "5", "IIDID" ].parse.expand.solve == 2 );
	assert( [ "7", "DDIDDII" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto s = input.front;
	return tuple( s );
}

auto solve( string s )
{
	auto ans = 0L;
	auto x = 0L;
	
	foreach( c; s )
	{
		switch( c )
		{
			case 'I': x++; ans = max( ans, x ); break;
			case 'D': x--;                      break;
			default : assert( false );
		}
	}
	
	return ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
#define _GLIBCXX_DEBUG
#define ll long long
#define rep(i,n) for (ll i = 0; i < n; i++)
#define vl vector<ll>
#define vpl vector<pair<ll,ll>>
#define vvl vector<vector<ll>> //a(縦行,vector<ll>(横列));
#include<algorithm>//__gcd(a,b)
#include <iostream>
#include <vector>
#include <cstdlib>
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL << 60;

int main(){
    char c;cin>>c;
    if('A'<=c&&c<='Z')cout<<"A"<<endl;
    if('A'+32<=c&&c<='z')cout<<"a"<<endl;
}

Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <utility>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <deque>
#include <cstdlib>
#include <set>
#include <chrono>
#include <climits>
#include <unordered_map>
#include <iomanip> 

#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define repf(i,st,end,inc) for(int i = st; i < end; i += inc)
#define repb(i,st,end,dec) for(int i = st; i >= end; i -= dec) 

#define MOD 1000000007

#define trace1(a) cout << a << endl;
#define trace2(a,b) cout << a << " | " << b << endl;
#define trace3(a,b,c) cout << a << " | " << b << " | " << c << endl;
#define trace4(a,b,c,d) cout << a << " | " << b << " | " << c << " | "<< d << endl;

using namespace std;
using namespace std::chrono;

int main(){
	fast;
	#ifdef LOCAL_PROJECT
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif

	auto start = high_resolution_clock::now(); 

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	vector<ll> f(n);
	for(int i = 0; i < n; i++)
		cin >> a[i];
	for(int i = 0; i < n; i++)
		cin >> f[i];

	sort(a.begin(), a.end());
	sort(f.begin(), f.end(), greater<ll>());

	// for(int i = 0; i < n; i++)
	// 	cout << a[i] <<"|" << f[i] << endl;

	ll l = 0;
	ll r = 1e18;
	ll ans = r;
	while(l <= r){
		ll mid = l + (r-l)/2;
		
		ll cnt = 0;
		for(int i = 0; i < n; i++){
			ll req_a = mid/f[i];
			cnt += max(0LL, a[i] - req_a);
		}

		if (cnt <= k){
			r = mid-1;
			ans = min(ans, mid);
		}
		else{
			l = mid+1;
		}
	}

	cout << ans << endl;

	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start);	
	// cout << endl;
	// cout << fixed << setprecision(9) << double(duration.count()) / 1000000 << endl; 

	return 0;
}


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

int main()
{
    long n, i;
    cin >> n;
    vector<long> a(n);
    for (i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    long max = a.at(0);
    long ans = 0;
    for (i = 1; i < n; i++)
    {
        if (a.at(i) > max)
        {
            max = a.at(i);
        }
        else
        {
            ans += max - a.at(i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4788
from collections import Counter
N, P = map(int, input().split())

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

res = 1
for k, v in factorization(P):
    if v < N:
        continue
    res *= k**(v//N)

print(res)

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

int main() {
    string s;
    getline(cin, s);
    for (auto x : s) {
        if (islower(x))
            cout << (char)toupper(x);
        else if (isupper(x))
            cout << (char)tolower(x);
        else
            cout << x;
    }
    cout << endl;
}


Measured memory_bytes: 3200
#include <stdio.h>
int main(void)
{
   int xgyou,xretu;
   int yretu;
   static int x[101][101];
   static int y[101][101];
   int i,j;
   int k;
   long long sum;
   sum = 0;
   scanf("%d",&xgyou);
   scanf("%d",&xretu);
   scanf("%d",&yretu); 
   for (i = 1; i <= xgyou; i++){
      for (j = 1; j <= xretu; j++){
         scanf("%d",&x[i][j]);
      }
   }

   for (i = 1; i <= xretu; i++){
      for (j = 1; j <= yretu; j++){
         scanf("%d",&y[i][j]);
      }
   }
   for (i = 1;i <= xgyou; i++){
      for (j = 1;j <= yretu; j++){
         for (k = 1;k <= xretu; k++){
            sum += x[i][k]*y[k][j];
         }
         if (j != yretu)
            printf("%lld ",sum);
         else 
            printf("%lld",sum);
         sum = 0;
      }
      printf("\n");
   }


   return 0;
}

Measured memory_bytes: 1112
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;
const int MAXM=MAXN-1;

int n;
int ghead[MAXN],gnxt[2*MAXM],gto[2*MAXM];

int path[MAXN],npath;
int col[MAXN];

bool dfs(int at,int par) {
	if(at==n-1) { npath=0; path[npath++]=at; return true; }
	for(int x=ghead[at];x!=-1;x=gnxt[x]) {
		int to=gto[x]; if(to==par) continue;
		if(dfs(to,at)) { path[npath++]=at; return true; }
	}
	return false;
}
void dfscol(int at,int par) {
	for(int x=ghead[at];x!=-1;x=gnxt[x]) {
		int to=gto[x]; if(to==par||col[to]!=-1) continue;
		col[to]=col[at]; dfscol(to,at);
	}
}

void run() {
	scanf("%d",&n);
	REP(i,n) ghead[i]=-1;
	REP(i,n-1) {
		int a,b; scanf("%d%d",&a,&b); --a,--b;
		gnxt[2*i+0]=ghead[a],ghead[a]=2*i+0,gto[2*i+0]=b;
		gnxt[2*i+1]=ghead[b],ghead[b]=2*i+1,gto[2*i+1]=a;
	}
	assert(dfs(0,-1));
	reverse(path,path+npath);
	//printf("path:"); REP(i,npath) printf(" %d",path[i]+1); puts("");
	REP(i,n) col[i]=-1;
	REP(i,npath) col[path[i]]=i<(npath+1)/2?0:1;
	REP(i,npath) dfscol(path[i],-1);
	int na=0,nb=0; REP(i,n) if(col[i]==0) ++na; else ++nb;
	//printf("na=%d nb=%d\n",na,nb);
	printf("%s\n",na>nb?"Fennec":"Snuke");
}

int main() {
	run();
	return 0;
}


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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define ALLTRUE(xs) all_of(ALL(xs),[](bool x){return x;})
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define ANYTRUE(xs) any_of(ALL(xs),[](bool x){return x;})
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define DUMPP(xs) for (auto x:xs) cout<<'('<<x.first<<','<<x.second<<')';cout<<endl
#define FOR(i,a,b) for (ll i=(ll)(a);i<(ll)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

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

struct edge { int to,cost; };
const int MOD=1e9+7;

int main() {
  // 色の数は、頂点の中で最も多く編が生えている所の本数
  // それが決まったら、1から順番に塗り分けていけばいい
  int N;cin>>N;
  vector<P> es(N-1);
  vector<vector<int>> G(N);

  // その頂点を木に追加するために使った編の色が入る（0~color_cnt-1）
  vector<int> colors(N,-1);

  REP(i,N-1) {
    int a,b;cin>>a>>b;
    a--;b--;
    es[i] = {a,b};
    G[a].push_back(b);
  }

  // 頂点の中で最も多い数
  int color_cnt = G[0].size();
  FOR(i,1,N) {
    color_cnt = max(color_cnt, (int)G[i].size()+1);
  }
  // 編の色を入力
  REP(i,N) {
    int used_color = colors[i];
    int cur_color = 0;
    for (int p:G[i]){
      if (cur_color==used_color) cur_color++;
      colors[p] = cur_color;
      cur_color++;
    }
  }
  
  OUT(color_cnt);
  REP(i,N-1) {
    OUT(colors[es[i].second]+1);
  }

  return 0;
}

Measured memory_bytes: 6400
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main(){
  ll n;
  scanf("%d", &n);
  ll A[n], sum = 0;
  ll d[n+1];
  FOR(i,0,n)
  {
    scanf("%lld",A+i);
    sum += A[i];
  }
  ll k = (n * (n + 1)) / 2;
  if(sum%k!=0)
  {
    puts("NO");
    return 0;
  }
  k = sum / k;
  // 差
  A[n] = A[0];
  FOR(i,0,n)
  {
    d[i] = A[i+1] - A[i];
  }
  ll t = 0;
  FOR(i,0,n)
  {
    d[i] -= k;
    d[i] *= -1;
    if(d[i]<0 || d[i]%n!=0)
    {
      puts("NO");
      return 0;
    }
    t += d[i] / n;
  }
  cout << (t == k ? "YES" : "NO") << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define THE using
#define DARK namespace
#define ONE std
#define dbg(x) cout << #x << " = " << x << endl

THE DARK ONE;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    freopen("out.txt", "w", stdout);
//    freopen("input.txt", "r", stdin);
    vector<int> x(100005), y(100005), z[100005];
    int n, m;
    cin >> n >> m;
    for(int i = 0; i < m; i++){
        cin >> x[i] >> y[i];
        z[x[i]].push_back(y[i]);
    }
    for(int i = 1; i <= n; i++)
        sort(z[i].begin(), z[i].end());
    for(int i = 0; i < m; i++){
        long long s = (long long) x[i] * 1000000;
        s += lower_bound(z[x[i]].begin(), z[x[i]].end(), y[i]) - z[x[i]].begin() + 1;
        printf("%012lld\n", s);
    }
    return 0;
}


Measured memory_bytes: 7808
N, M = map(int,input().split())
ninzu = [0]*M
kasetsu = False

A = []
for i in range(N):
    array = list(map(int,input().split()))
    del array[0]
    A.append(array)

for j in range(N):
    for cnt in A[j]:
        suki = int(cnt) - 1
        ninzu[suki] += 1

ans = ninzu.count(N)
print(ans)

Measured memory_bytes: 3064
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    if n % 2 == 0:
        if s[:n // 2] == s[n//2:]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
  	cin >> n;
  	string a, b;
  	cin >> a >> b;
  	for(int i = 0; i < n; i++)
    {
      cout << a[i] << b[i];
    }
  

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1000000007;
string alp="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N,K;
    cin >> N >> K;
    int count=0;
    rep(i,N){
        int h;
        cin >> h;
        if (h>=K){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
my_stack = []
for my_str in input().split():
  if my_str in "+-*":
    b = my_stack.pop()
    a = my_stack.pop()
    my_stack.append(str(eval(a+my_str+b)))
  else:
    my_stack.append(my_str)
    
print(my_stack.pop())


Measured memory_bytes: 5568
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.nextLine();

        char before = s.charAt(0);
        for (int i = 1; i < s.length(); i++) {
            if (before == s.charAt(i)) {
                System.out.println("Bad");
                return;
            }

            before = s.charAt(i);
        }

        System.out.println("Good");
    }
}


Measured memory_bytes: 22740
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;

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

int p[30];

int main() {
    int n;
    cin >> n;
    rep(i, n){
        cin >> p[i];
    }

    int ans = 0;
    for(int i = 1; i < n - 1; ++i){
        if((p[i - 1] < p[i] && p[i] < p[i + 1]) || (p[i - 1] > p[i] && p[i] > p[i + 1])){
            ans++;
        }
    }

    cout << ans << endl;
}

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

using namespace std;
 
int main()
{
    // ここにプログラムを追記
    int counter=0;
    string s;
    cin >> s;
    
    if(s[0]=='1')
    {
        counter++;
    }
    if(s[1]=='1')
    {
        counter++;
    }
    
    if(s[2]=='1')
    {
        counter++;
    }
    cout << counter << endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define ll long long
#define M 1000000007

ll power(ll a, ll b, ll m)
{
	ll ret = 1;
	if(a == 0)return 0;
	
	while(b)
	{
		if(b%2)ret = (ret *a)%m;
		
		a = (a*a)%m;
		b = b>>1;
	}
	return (ret%m);
}

int main() {
	ll n,ans;
	cin>>n;
	ll T = power(10,n,M);
	ll A = power(9,n,M);
	ll B = A;
	ll AIB = power(8,n,M);
	
	ans = (T-(A+B-AIB)%M)%M;
	ans = (ans +M)%M;
	
	cout<<ans;
	return 0;
}

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

int main(){
  string a;
  int u,x = 0;
  cin >> u;
  cin >> a;
  for(int i = 1;i < u;i++){
      if(a[i] == a[i-1])x--;
      x++;
  }
  cout << x+1 << endl;
}
      

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/


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

	int n;
	cin >> n;
	int d, x;
	cin >> d >> x;
	vector<int> a(n);
	rep(i, n)cin >> a[i];

	int ans = x;
	rep(i, n) {
		int cnt = 1;
		while (cnt <= d) {
			ans++;
			cnt += a[i];
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(void) {
 int N, M;
 cin >> N >> M;

 const int NMMAX = 50;
 int A[NMMAX], B[NMMAX];

 for (int i = 0; i < M; ++i) {
 cin >> A[i] >> B[i];
 }

 int road[NMMAX];
 for (int i = 0; i < N; ++i) {
 road[i] = 0;
 }

for (int i = 0; i < M; ++i) {
road[A[i] - 1] += 1;
road[B[i] - 1] += 1;
}

for (int i = 0; i < N; ++i) {
cout << road[i] << endl;
}

 return 0;
 }


Measured memory_bytes: 256
# ABC073D - joisino's travel
from heapq import heapify, heappop, heappush
from itertools import permutations


def dijkstra(G: "Array[Array[int]]", size: int, start: int) -> list:
    dist = [1 << 60] * size
    unchecked = size - 1  # vertex_0 won't appear in 1-idx graph
    queue = [(0, start)]
    heapify(queue)
    while queue:
        cost, v = heappop(queue)
        if cost > dist[v]:
            continue
        dist[v] = cost
        for next_cost, u in G[v]:
            if cost + next_cost < dist[u]:
                heappush(queue, (cost + next_cost, u))
        unchecked -= 1
        if not unchecked:
            return dist


def main():
    global G, N
    N, M, R, *RABC = map(int, open(0).read().split())
    visit, ABC = RABC[:R], RABC[R:]
    G = [[] for _ in range(N + 1)]
    for v, u, cost in zip(*[iter(ABC)] * 3):
        G[v].append((cost, u)), G[u].append((cost, v))
    dist = {v: dijkstra(G, N + 1, v) for v in visit}
    ans = 1 << 60
    for perm in permutations(visit):
        cur = sum(dist[v][u] for v, u in zip(perm, perm[1:]))
        ans = min(ans, cur)
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9832
import sys
n,m = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(m)]

if n>1:#一桁目が指定されない場合の最小値(初期値)を予め入れておく
    b=[pow(10,n-1)]
else:
    b=[0]
    
count=[]#桁ごとに数字が指定された回数を記録する配列
for i in range(0,n):
    count.append(0)

count0=[]#桁ごとに0が指定された回数を記録する配列
for i in range(0,n):
    count0.append(0)

for i in range(0,m):#指定された数字を桁数倍してbに代入
    b.append(A[i][1]*pow(10,n-A[i][0]))
    count[A[i][0]-1]+=1#桁ごとに指定された回数の記録
    
    if A[i][1]==0:#桁ごとに0が指定された回数の記録
        count0[A[i][0]-1]+=1

for i in range(0,n):
    if count0[i]!=0 and count0[i]!=count[i]:#同じ桁に0とそれ以外が指定された場合-1を出力する
        print(-1)
        sys.exit()

if count[0]>0 and n>1:#一桁目が指定された場合(count[0]>0)初期値を削除
    b.remove(pow(10,n-1))
elif count[0]>0 and n<=1:
    b.remove(0)
   
b=list(set(b))#ダブりの排除

if n>1:#0が指定された場合は0を削除する
    b=[i for i in b if i != 0]

c=[]
for i in range(len(b)):#bに入っている数字の桁数をcに代入
    c.append(len(str(b[i])))
c=list(set(c))#ダブりが存在する場合は同じ桁に対し違う数字が複数回指定されている

if len(b)==len(c) and len(str(sum(b)))==n:#もしlen(b)==len(c)かつb内を全て合計した桁数がnと一致するならそれが最小
    print(sum(b))
else:
    print(-1)

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  
  long long a,b;
  int k;
  cin>>a>>b>>k;
  REP(i,k){
    if(i%2==0){
      if(a%2==0){
        b += a/2;
        a /= 2;
      }else{
        a--;
        b += a/2;
        a /= 2;
      }
    }else{
      if(b%2==0){
        a += b/2;
        b /= 2;
      }else{
        b--;
        a += b/2;
        b /= 2;
      }
    }
  }
  cout<<a<<' '<<b<<endl;
  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
if K == 1:
    print(N*N*N)
else:
    if K%2==0:
        b = N // (K//2)
        if b % 2 == 0:
            b0 = b//2
            print(2 * (b0*b0*b0))
        else:
            b1 = (b+1)//2
            b2 = (b-1)//2
            print(b1*b1*b1+b2*b2*b2)
    else:
        c = N//K
        print(c*c*c)

Measured memory_bytes: 3064
// トポロジカルソート : 深さ優先探索
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<queue>
#include<list>

using namespace std;

const int MAX = 10000;

// 各辺のつながりを格納する動的配列
vector<int> G[MAX];
// 訪問情報を保持する配列
bool V[MAX];
// トポロジカルソートの結果を格納するリスト
list<int> out;

int N;

void dfs(int u);

int main(void)
{

    int s, t, M;

    cin >> N >> M;

    for(int i = 0; i < N; i++)
    {
        // 配列の初期化
        V[i] = false;
    }

    for(int i = 0; i < M; i++)
    {
        cin >> s >> t;

        // 各辺のつながりを記憶する
        G[s].push_back(t);
    }

    for(int i = 0; i < N; i++)
    {
        if( !V[i] )
        {
            // 頂点を順番に訪れる
            dfs(i);
        }
    }

    // 結果の表示
    // トポロジカルソートの結果の表示
    for(list<int>::iterator it = out.begin(); it != out.end(); it++)
    {
        cout << *it << endl;
    }

    return 0;
}

// トポロジカルソートを実施するためのメソッド
// u : 訪問する頂点
void dfs(int u)
{
    // 訪問情報を記録
    V[u] = true;

    for(unsigned int i = 0; i < G[u].size(); i++ )
    {
        // 接続先の頂点No.の格納
        int v = G[u][i];

        if( !V[v] )
        {
            // 接続している頂点を順番に訪れる
            dfs(v);
        }
    }

    // 入力辺が無くなった頂点をトポロジカルキューに追加する
    out.push_front(u);

}



Measured memory_bytes: 4108
while true
    numbers = gets.split.map(&:to_i)
    if numbers[0] == 0 && numbers[1] == 0
        break
    else
        (numbers[0]).times do |num_r|
            st = ""
            (numbers[1]).times do |num_c|
                if num_r %2 ==0
                    if num_c %2 ==0
                        st+= "#"
                    else
                        st+= "."
                    end
                else
                    if num_c %2 ==0
                        st+= "."
                    else
                        st+= "#"
                    end
                end
            end
            puts st
        end
    end
    puts ""
end


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

typedef long long ll;
// #define int ll
#define pb push_back
// const int INF = 1e18;
const int inf = 1e9;

signed main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);




	int k,a,b;

	cin>>k>>a>>b;
	for(int i=a;i<=b;i++){
		if (i%k == 0){
			cout<<"OK";
			return 0;
		}
	}

	cout<<"NG";

	return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e9;
const static ll MOD = 1e9+7;


int main(){
    int N, M; cin >> N >> M;
    vector<pair<ll, ll>> S(N), CP(M);
    for(int i = 0; i < N; i++){
        ll a, b; cin >> a >> b; S[i] = make_pair(a, b);
    }
    for(int i = 0; i < M; i++){
        ll c, d; cin >> c >> d; CP[i] = make_pair(c, d);
    }
    for( auto p : S){
        ll x = p.first, y = p.second;
        ll Min = 1e18;
        int idx;
        for(int i = 0; i < M; i++){
            ll d = abs(x - CP[i].first) + abs(y - CP[i].second);
            if(d < Min) {Min = d; idx = i+1;}
        }
        cout << idx << endl;
    }
}

Measured memory_bytes: 256
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり

N = I()
a = LI()

x = 0
for i in range(N):
    x = x ^ a[i]
    
ANS = [0]*N
for i in range(N):
    ANS[i] = a[i] ^ x

print(*ANS)

Measured memory_bytes: 98664
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

char a[99][99];
int main()
{
  int h, w;
  scanf("%d%d", &h, &w);
  for (int i = 0; i < h; i++)
  {
    scanf("%s", a[i + 10] + 10);
  }
  for (int i = 0 + 10; i < h + 10; i++)
  {
    for (int j = 0 + 10; j < w + 10; j++)
    {
      if (a[i][j] == '#')
      {
        putchar('#');
      }
      else
      {
        int count = 0;
        for (int k = -1; k <= 1; k++)
        {
          for (int l = -1; l <= 1; l++)
          {
            if (k != 0 || l != 0)
            {
              if (a[i + k][j + l] == '#')
              {
                count++;
              }
            }
          }
        }
        printf("%d", count);
      }
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void) {
  string s, t;
  cin >> s;
  t = s;
  reverse(t.begin(), t.end());
  if (s == t) {
    cout << 0 << endl;
    return 0;
  }
  int head = 0, tail = s.size() - 1, ans = 0;
  while (head < tail) {
    int i = 0, j = 0;
    while (s[head] == 'x')
      i++, head++;
    while (s[tail] == 'x')
      j++, tail--;
    if (s[head] != s[tail]) {
      cout << -1 << endl;
      return 0;
    }
    ans += abs(i - j);
    head++;
    tail--;
    if (head >= tail)
      break;
  }
  cout << ans << endl;
}

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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod 		1000000007
#define inf 		1e12
#define IOS 		ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)


int32_t main() {

	IOS;

	int n, h;
	cin >> n;
	int mx = 0;
	int sum = 0;

	for (int i = 0; i < n; i++) {

		cin >> h;
		mx = max(mx, h);

		if (!i)
			continue;

		if (h < mx)
			sum += mx - h;
	}

	cout << sum;

	return 0;

}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <math.h>
using namespace std;

/* define const */

/* end up defineing const */

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  if (a+b == c) cout << "Yes" << endl;
  else if (a+c == b) cout << "Yes" << endl;
  else if (b+c == a) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256