akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;

class Program
{
	static void Main(string[] args)
	{
		int ans = 0;
		string S = Console.ReadLine();
		string T = Console.ReadLine();
		for (int i = 0; i < 3; i++) {
			if(S[i] == T[i]) ans++;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 11092
import math
import collections

def main():
    n = int(input())
    a=[int(i) for i in input().split()]

    #0 < i < N+1 の iについて、iの倍数が書かれた箱に入ってるボールの個数を2で割った余りがai
    # 1 <= N < 2*10**5
    good = [0]*(n+1)
    for i in range(n//2+1,n+1):
        good[i] = a[i-1]
    for i in range(n//2,0,-1):
        tmp = 0
        odd_even = a[i-1]
        for j in range(i+i,n+1,i):
            tmp += good[j]
        if(odd_even!=tmp%2):
            good[i] = 1

    print(sum(good))

    for i in range(1,n+1):
        if(good[i]):
            print(i,end=" ")
    print()

if __name__ == '__main__':
    main()


Measured memory_bytes: 12832
n, q = map(int , input().split())
queue = []
for _ in range(n):
    line = input().split()
    queue.append([line[0], int(line[1])])

class my_queue:
    def __init__(self, queue):
        self.queue = queue
    def enqueue(self, item):
        self.queue = self.queue + [item]
        self.queue.append(item)
    def dequeue(self):
        if len(self.queue) != 0:
            item = self.queue[0]
            self.queue = self.queue[1:]
        else :
            item = None
        return item


time = 0
finish_task = []

while(len(queue) != 0):
    item = queue.pop(0)
    if item == None:
        break
    elif item[1] <= q:
        time += item[1]
        finish_task.append([item[0], time])
    else :
        time += q
        queue.append([item[0], item[1] - q])

for item in finish_task:
    print(item[0], item[1])

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n;
	cin >> n;
	int B[n - 1], A[n], ans = 0;
	for (int i = 0; i < n - 1; ++i)
		cin >> B[i];
	A[0] = A[1] = B[0];
	ans = A[0];
	for (int i = 1; i < n - 1; ++i) {
		A[i + 1] = B[i];
		A[i] = min(A[i], B[i]);
		ans += A[i];
	}
	cout << ans + A[n - 1] << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            
         int a = sc.nextInt();
         int b = sc.nextInt();
         int c = sc.nextInt();
        
        int x = 0;
		
        for(int i=a; i <= b;i++){
        
         if(c%i==0){
             
             x++;
            
             
     	    }
            
        }
        System.out.println(x);
    }
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    string s;
    cin >> s;
    string ss = s;
    int n = s.size();
    string x = s.substr(0, n/2), y = s.substr(n/2+1, n/2);
    string xx = x, yy = y;
    reverse(all(x));
    reverse(all(y));
    reverse(all(s));
    if(x == xx && y == yy && ss == s) cout << "Yes" << '\n';
    else cout <<   "No"  << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
import math

n, k = map(int, input().split())

tmp = []
for i in range(1, n + 1):
    if i < k:
        num = (-1 * math.log2(k / i)) // 1 * -1 
        tmp.append(num)
    else:
        tmp.append(0)
        
ans = 0
for i in range(n):
    ans += 2**(tmp[0] - tmp[i])

print(ans / (n * 2**tmp[0]))

Measured memory_bytes: 9776
import numpy as np
N = int(input())
A = list(map(int,input().split())) #準備度
B = list(map(int,input().split())) #試験

A = np.array(A)
B = np.array(B)


sumA = sum(A)
sumB = sum(B)

if sumA < sumB:
    print(-1)
else:
    gap = A - B
    minus = gap[gap<0]
    numminus = len(gap[gap<0])
    if numminus == 0:
        print(0)
    else:
        needs = - minus.sum()
        sortgap = np.sort(gap)[::-1]
        s = 0
        for i in range(N):
            s += sortgap[i]
            if s >= needs:
                changedplus = i+1
                break
        print(changedplus + numminus)

Measured memory_bytes: 34680
k=int(input())
a,b=map(int,input().split())
if a%k==0 or b%k==0:
    print('OK')
elif b-a>=k:
    print('OK')    
elif a%k>b%k:
    print('OK')
elif k==1:
    print('OK')
else:
    print('NG')

Measured memory_bytes: 9180
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] L = new int[N];
        for (int i = 0; i < N; i++) {
            L[i] = sc.nextInt();
        }

        Arrays.sort(L);

        long ans = 0;
        for (int i = N-1; i >= 2; i--) {
            for (int j = i-1; j >= 1; j--) {
                int key = L[i] - L[j] + 1;
                int minIdx = search(L, key, j);
                if (minIdx < j) {
                    ans += j - minIdx;
                }
            }
        }
        System.out.println(ans);
    }

    private static int search(int[] L, int key, int right) {
        int left = -1;
        while (right - left > 1) {
            int mid = left + (right-left)/2;
            if (L[mid] >= key) {
                right = mid;
            } else {
                left = mid;
            }
        }
        return right;
    }
}


Measured memory_bytes: 26916
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
//#define int ll

int main () {
	//freopen("ladder.in", "r", stdin); 
	//freopen("ladder.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a, b, c;
	cin >> a >> b >> c;
	ll ans1 = (((a >> 1) + (a & 1)) * b * c) - ((a >> 1) * b * c);
	ll ans2 = (((b >> 1) + (b & 1)) * a * c) - ((b >> 1) * a * c);
	ll ans3 = (((c >> 1) + (c & 1)) * b * a) - ((c >> 1) * b * a);		
	cout << min(ans1, min(ans2, ans3));
	return 0;
}
/*
	If you only do what you can do, 
			You will never be more than you are now!
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vp vector<pi>
#define mp map<ll,ll>
#define pb push_back
#define endl '\n'
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int32_t main(){
    fast;
    char a;
  cin>>a;
  cout<<(char)(a+1);
}


Measured memory_bytes: 256
from collections import defaultdict
if __name__ == '__main__':
    N = int(input())
    words = defaultdict(int)
    before = ''
    flag = True
    for n in range(N):
        s = str(input())
        if words[s] == 0:
            if n == 0 or before[-1] == s[0]:
                words[s] += 1
                before = s
            else:
                flag = False
                break
        else:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')

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

int main(){
  int x,y;
  cin >> x >> y;
  int a = y-2*x;
  if(a%2 == 0){
    if(a/2 <= x && a/2 >= 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3628
// #pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define String std::string
#define fi first
#define se second
#define mp std::make_pair
#define Pair std::pair<int, int>
#define Map std::map< int, int >
#define Vector std::vector<int>
 
using std::cin;
using std::cout;
using std::endl;
 
typedef long long ll;
typedef unsigned long long ull;
 
const int N = 100000 + 5;
const int M = 1000 + 5;
const int K = 1e7 + 5;
const int MOD = 1e9 + 7;
const int inv2 = 500000004;
const int LOG = 40;
const ull BASE = 19260817;
const int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };
const int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };
const double PI = acos(-1);

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
template<class T>
inline T readT() {
    T res = 0, f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); ch = getchar()) res = (res << 1) + (res << 3) + ch - '0';
    return res * f;
}
#define read readT<int>

std::vector<int> v;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    v.push_back(std::abs(a - b));
    v.push_back(std::abs(a - c));
    v.push_back(std::abs(b - c));
    std::sort(v.begin(), v.end());
    printf("%d\n", v[0] + v[1]);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int n, t, a;
	cin >> n >> t >> a;

	pair<double, int> ans = {INF, 0};
	rep(i, n) {
		int h;
		cin >> h;
		double ct = t - h * 0.006;
		ct = abs(a - ct);
		if (ct < ans.first) {
			ans = {ct, i + 1};
		}
	}
	cout << ans.second << endl;
}

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

	solve();
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
pair<long long,pair<long long,long long> > p[110000];
long long x[110000];
long long y[110000];
long long z[110000];
double d[110];
long long tx[110];
long long ty[110];
long long tz[110];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		for(int i=0;i<a;i++){
			scanf("%lld%lld%lld",x+i,y+i,z+i);
			p[i]=make_pair(x[i],make_pair(y[i],z[i]));
		}
		std::sort(p,p+a);
		for(int i=0;i<a;i++){
			x[i]=p[i].first;
			y[i]=p[i].second.first;
			z[i]=p[i].second.second;
		}
		while(b--){
			int c;scanf("%d",&c);
			for(int i=0;i<c;i++){
				long long X,Y,Z;
				scanf("%lld%lld%lld",&X,&Y,&Z);
				tx[i]=X;ty[i]=Y;tz[i]=Z;
				int ind=lower_bound(x,x+a,X)-x;
				double tmp=999999999;
				for(int j=ind;j<a;j++){
					if((double)(x[j]-X)>tmp)break;
					tmp=min(tmp,sqrt((x[j]-X)*(x[j]-X)+(y[j]-Y)*(y[j]-Y)+(z[j]-Z)*(z[j]-Z)));
				}
				for(int j=ind-1;j>=0;j--){
					if((double)(X-x[j])>tmp)break;
					tmp=min(tmp,sqrt((x[j]-X)*(x[j]-X)+(y[j]-Y)*(y[j]-Y)+(z[j]-Z)*(z[j]-Z)));
				}
				d[i]=tmp;
	//			printf("%f ",d[i]);
			}
			double ret=0;
			for(int i=0;i<c-1;i++){
				ret+=min(sqrt((tx[i+1]-tx[i])*(tx[i+1]-tx[i])+(ty[i+1]-ty[i])*(ty[i+1]-ty[i])+(tz[i+1]-tz[i])*(tz[i+1]-tz[i])),d[i]+d[i+1]);
			}
			printf("%.12f\n",ret);
		}
	}
}

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

int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  if(n%2==1){
    cout << "No" << endl;
  }
  else{
    int judge = 1;
    for(int i = 0; i < n/2; i++){
      if(s[i] != s[n/2+i]){
        judge = 0;
      }
    }
    if(judge == 1){
      cout << "Yes";
    }
    else{
      cout << "No";
    }
  }
}

Measured memory_bytes: 256
(N, K), As = readlines.map{|l| l.split.map(&:to_i)}

require 'prime'

ds = As.inject(:+).prime_division.inject([1]){|a, (p, e)| (0 .. e).map{|f| p**f}.product(a).map{|a, b| a*b}}.sort.reverse
puts (ds.find do |d|
  ms = As.map{|a| a % d}.sort.reverse
  (0 ... ms.inject(:+)/d).inject(0){|s, i| s + d - ms[i]} <= K
end)

Measured memory_bytes: 13304
N = int(input())
S = []
for i in range(N):
    S.append(input())
    
import collections

c = collections.Counter(S)
mc = c.most_common()
max_count = mc[0][1]

lst = []

for x, y in mc:
    if y == max_count:
       lst.append(x)
    
for z in sorted(lst):
    print(z)

Measured memory_bytes: 120016
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;

int main(){
    int n,m;
    cin>>n>>m;
    int s[m],c[m];
    for(int i=0;i<m;i++)cin>>s[i]>>c[i];
    for(int i=0;i<=999;i++){
        stringstream ss;ss<<i;
        string str=ss.str();
        if(str.size()!=n)continue;
        bool flag=true;
        for(int j=0;j<m;j++){
            if(str[s[j]-1]!=(char)(c[j]+'0'))flag=false;
        }
        if(flag){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

struct edge {
    int to;
    int len;
};

void dfs(int from, int d, int len, vector< vector<edge> >& edges, vector<int>& dist) {
    dist[from] = d + len;
    for(edge e: edges[from]) {
        if(dist[e.to] > 0) continue;
        dfs(e.to, dist[from], e.len, edges, dist);
    }
}


int main() {
    int N;
    cin >> N;
    vector<vector<edge> > edges(N);
    REP(i, N-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        edges[a].push_back(edge{b, c});
        edges[b].push_back(edge{a, c});
    }

    vector<int> dist(N, -1);
    dfs(0, 0, 0, edges, dist);
    REP(i, N) {
        if(dist[i]%2 == 0) cout << 0 << endl;
        else cout << 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 17024
n,m,q = map(int,input().split())
cd = 0
score_list = [list(map(int,input().split())) for i in range(q)]

def sum_d(l):
    s = 0
    
    for a,b,c,d in score_list:
        if (l[b-1] - l[a-1])==c:
            s += d
    return s

def f(l,ans):
    if(len(l)==n):
        return sum_d(l)

    if(len(l)==0):
        num=1
    else:
        num=l[-1]

    while(num <= m):
        ret = f(l+[num],ans)
        if(ans < ret):
            ans = ret
        num += 1

    return ans

ans = f([],ans=0)
print(ans)

Measured memory_bytes: 9232
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<(ll)m; i++)
#define FOR(i,n,m) for(long long i=n; i<(ll)m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vector<ll> a(n);
	REP(i,n) cin>>a[i];
	REP(i,n) {
		REP(j,n) {
			if(i==j) continue;
			if(abs(a[i]-a[j])%(n-1)==0) {
				cout<<a[i]<<" "<<a[j]<<endl;
				return 0;
			}
		}
	}
}



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

int main(){
    int x,a;
    cin >> x >> a;
    if(x<a) cout << 0 << endl;
    else cout << 10 << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#define INF 2147483647

using namespace std;

class segtree{
public:
  int Node;
  vector<int> table;
  segtree(int);
  int ope(const int,const int);
  void update(int index,const int value){ // index is 0-indexed.
    index += Node; // query function
    table[index] = value;
    while(index > 0){
      index /= 2;
      table[index] = ope(table[2*index],table[2*index+1]);
    }
  }
  int find(int l, int r);
};
int segtree::find(int l,int r){ // l,r is 0-indexed.
    if(l == r) return table[r+Node];
    l += Node; r += Node;
    long long ans = INF;
    for(; l <= r;l >>=1, r >>=1){
      if(r == l){ans=ope(ans,table[l]); return ans;}
      if(r%2 == 0){ ans=ope(ans,table[r]);--r;}
      if(l%2){ ans=ope(ans,table[l]);++l;}
    }
    return ans;
}
segtree::segtree(int Max_Node){  // initialize
  Node = 2;
  while(Node < Max_Node)
    Node *= 2;
  table.resize(2*Node);
  for(int i = Node;i < Node*2; i++){
    table[i] = INF; // initialize
  }
  for(int i= Node-1; i > 0; i--){
    table[i] = ope(table[i*2],table[i*2+1]);
  }
}

int segtree::ope(const int a,const int b){
  return min(a,b);
}

int main(){
  int n,q;
  cin>>n>>q;
  segtree seg(n);
  for(int i=0;i<q;i++){
    int com,x,y;
    cin>>com>>x>>y;
    if(com){
      cout<<seg.find(x,y)<<endl;
    }else{
      seg.update(x,y);
    }
  }
  return 0;
}

Measured memory_bytes: 3864
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int H, N;
    cin >> H >> N;

    vector<int> vec(N);
    int S = 0;
    for(int i=0; i<N; i++){
        cin >> vec.at(i);
        S += vec.at(i);
    }

    if(S >= H){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;

int main(void){
    int H,W,N;
    cin >> H >> W >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a.at(i);
    }
    vector<int> longans;
    vector<vector<int>> ans(H, vector<int> (W));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < a.at(i); j++){
            longans.push_back(i+1);
        }
    }
    for(int i = 0; i < H; i++){
        if(i % 2 == 1){
            reverse(longans.begin() + i*W, longans.begin() + i*W + W);
        }
    }
    for(int i = 0; i < H*W; i++){
        printf("%d ",longans.at(i));
        if(i % W == W-1){
            printf("\n");
        }
    }
    
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strN = scan.next();
		char[] nArray = strN.toCharArray();
		for (int i=0;i<nArray.length;i++) {
			if (nArray[i] == '1') {
				nArray[i] = '9';
			} else {
				nArray[i] = '1';
			}
		}
		strN="";
		for (char c : nArray) {
			strN+=c;
		}
		System.out.println(strN);
	}
}


Measured memory_bytes: 23380
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
#include <iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
typedef pair<string,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
bool pairCompare2(P firstElof,P secondElof){
    return (firstElof.second)%1000>(secondElof.second)%1000;
}
bool less_mod1000(int lhs, int rhs) {
  if ((lhs - rhs) % 1000 != 0)
    return lhs % 1000 < rhs % 1000;
  else // 5で割った余りが等しいなら普通に大小比較する
    return lhs < rhs;
}
string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string a="abcdefghijklmnopqrstuvwxyz";
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n;cin>>n;
    ll w[n];
    rep(i,0,n)cin>>w[i];
    ll front_sum=w[0];
    ll end_sum=w[n-1];
    ll i=0;
    ll j=n-1;
    while(1){
      if(front_sum<=end_sum){
        i++;
        if(i==j)break;
        front_sum+=w[i];
      }
      else{
        j--;
        if(i==j)break;
        end_sum+=w[j];
      }
    }
    cout<<abs(front_sum-end_sum)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using L = long long;
const L INF=1e15;
#define F first
#define S second
#define I XH[i]


L N,D,A,now=0,res=0,t;
pair<L,L>XH[200005];
queue<pair<L,L> >P;
int main() {cin>>N>>D>>A;for(L i=0;i<N;i++){cin>>I.F>>I.S;}sort(XH,XH+N);for(L i=0;i<N;i++){while(!P.empty()&&P.front().F<I.F){now-=P.front().S;P.pop();}I.S-=now;if(I.S>0){t=(I.S+A-1)/A;res+=t;P.push({I.F+2*D,t*A});now+=t*A;}}cout<<res;} 

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

public class Main{

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null ) {
            	int a=Integer.parseInt(line);
            	int b=Integer.parseInt(br.readLine());
            	int c=Integer.parseInt(br.readLine());
            	int d=Integer.parseInt(br.readLine());
            	int p=Integer.parseInt(br.readLine());
            	int x=0,y=b;

            	x=a*p;
            	if(p>c){
            		y=b+d*(p-c);
            	}
            	System.out.println(Integer.min(x,y));
            	break;
            }
		}
	}

}

Measured memory_bytes: 24180
#include <iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
	int i,c;
	cout<<"node "<<u<<": ";
	cout<<"parent = "<<T[u].p<<", ";
	cout<<"depth = "<<D[u]<<", ";
	
	if(T[u].p==NIL) cout<<"root, ";
	else if(T[u].l==NIL) cout<<"leaf, ";
	else cout<<"internal node, ";
	
	cout<<"[";
	
	for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
		if(i) cout<<", ";
		cout<<c;
	}
	cout<<"]"<<endl;
}

// ?????°????????±???????±???????
void rec(int u,int p){
	D[u]=p;
	if(T[u].r!=NIL) rec(T[u].r,p);
	if(T[u].l!=NIL) rec(T[u].l,p+1);
}

int main(){
	int i,j,d,v,c,l,r;
	cin>>n;
	for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;
	
	for(i=0;i<n;i++){
		cin>>v>>d;
		for(j=0;j<d;j++){
			cin>>c;
			if(j==0) T[v].l=c;
			else T[l].r=c;
			l=c;
			T[c].p=v;
		}
	}
	for(i=0;i<n;i++){
		if(T[i].p==NIL) r=i;
	}
	
	rec(r,0);
	
	for(i=0;i<n;i++) print(i);
	
	return 0;
}

Measured memory_bytes: 7768
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/
*/

#include <bits/stdc++.h>
using namespace std;

// utility of stdin,stdout
#define _CRT_SECURE_NO_WARNINGS
#define OUT cout << 
#define BR << endl
#define RET return 0
#define TLong long long
#define TBMod 1000000007

int main(int argc, char const *argv[])
{
	int a, b;
	int ans = 0;
	int outlet = 1;

	cin >> a >> b;
	while (outlet < b) {
		--outlet;
		outlet += a;
		++ans;
	}
	OUT(ans) BR;
	RET;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    int q = sc.nextInt();

    int[] ary = new int[n + 1];
    Arrays.fill(ary,0);

    for (int i = 0; i < q; ++i) {
      int index = sc.nextInt();
      ++ary[index];
    }

    for (int i = 1; i <= n; ++i) {
      if (k - q + ary[i] > 0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }

    sc.close(); 
  }
}


Measured memory_bytes: 62008
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(0);
	
	int a,b,c, k, ct=0;
	cin>>a>>b>>c>>k;
	while(b<=a){
		b*=2;
		ct++;
	}
	while(c<=b)
	{
		c*=2;
		ct++;
	}
	if(ct>k)
		cout<<"No";
	else if(a<b and b<c)
		cout<<"Yes";
	else
		cout<<"No";
			
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
using namespace std;
typedef long long ll;

int n,k;
int h[100005];
int f[100005];

int main(){
	scanf("%d%d",&n,&k);
	fore(i,0,n)scanf("%d",h+i);
	for(int i=n-2;i>=0;--i){
		f[i]=1<<30;
		fore(j,1,k+1){
			if(i+j>=n)break;
			f[i]=min(f[i],abs(h[i]-h[i+j])+f[i+j]);
		}
	}
	printf("%d\n",f[0]);
	return 0;
}

Measured memory_bytes: 1024
//AtCoder ABC061 B - Counting Roads
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
    int N,M; //都市、道
    cin>>N>>M;
    vector<int> roadnum(N+1,0);
    for(int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        ++roadnum[a];
		++roadnum[b];
	}
    for(int i=1;i<=N;++i){
        cout<<roadnum[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))

x_max, x_min = max(X), min(X)

min_cost = float('inf')
for p in range(x_min, x_max+1):
    cost = 0
    for j in range(N):
        cost += (X[j] - p) ** 2
    if cost < min_cost:
        min_cost = cost

print(min_cost)


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

using namespace std;

#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define INF 0x3f3f3f3f
#define f1(n) for(int i=0 ; i<n ; i++)
#define f2(m) for(int j=0 ; j<m ; j++)
#define ll long long
typedef pair<int, int> iPair;
const double epsilon = 1e-7;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  priority_queue<int, vector<int>, greater<int>> pq;
  int x;
  f1(n) {
    cin >> x;
    pq.push(x);
  }
  int sum = 0;
  while (k--) {
    sum += pq.top();
    pq.pop();
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

long p[100000];
long maxileft[100000];
long maxiright[100000];

int argmax(int l, int r){
  if(maxileft[r]==maxiright[l]) return maxileft[r];
  int nowmax=p[l];
  int maxindex=l;
  for(int i=l+1;i<=r;i++){
    if(p[i]>nowmax){
      maxindex=i;
      nowmax=p[i];
    }
  }
  return maxindex;
}

int ascending(int l, int r){
  for(int i=l;i<=r-1;i++){
    if(p[i]>p[i+1]) return 0;
  }
  return 1;
}

int descending(int l, int r){
  for(int i=l;i<=r-1;i++){
    if(p[i]<p[i+1]) return 0;
  }
  return 1;
}

long firstsum(int l, int r, int n){
  int i,imax;
  long ans;
  if(l==n && r==n) return 0;
  if(l!=n) imax=l;
  else imax=l+1;
  for(i=l+1;i<=r;i++){
    if(i!=n && p[i]>p[imax]){
      imax=i;
    }
  }
  if(imax<n){
    ans=p[imax]*(imax-l+1)*(r-n+1)+firstsum(imax+1,r,n);
  }else{
    ans=p[imax]*(n-l+1)*(r-imax+1)+firstsum(l,imax-1,n);
  }
  return ans;
}

long secondsum(int l, int r){
  long ans=0;
  int imax,i,j;
  int ll[100000];
  int rr[100000];

  if(r-l<1) return 0;
  if(ascending(l,r)){
    for(i=l;i<=r-1;i++){
      ans+=p[i]*(i-l+1);
    }
    return ans;
  }
  if(descending(l,r)){
    for(i=r;i>=l+1;i--){
      ans+=p[i]*(r-i+1);
    }
    return ans;
  }
  imax=argmax(l,r);
  
  if(imax==l)
    ans=secondsum(imax+1,r)+firstsum(l,r,imax);
  else if(imax==r)
    ans=secondsum(l,imax-1)+firstsum(l,r,imax);
  else
    ans=secondsum(l,imax-1)+secondsum(imax+1,r)+firstsum(l,r,imax);
  return ans;
}

int main()
{
  int i,n;
  long ans;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d", &p[i]);
  }
  maxileft[0]=0;
  for(i=1;i<n;i++){
    if(p[i]>p[maxileft[i-1]]) maxileft[i]=i; else maxileft[i]=maxileft[i-1];
  }
  maxiright[n-1]=n-1;
  for(i=n-2;i>=0;i--){
    if(p[i]>p[maxiright[i+1]]) maxiright[i]=i; else maxiright[i]=maxiright[i+1];
  }
  ans=secondsum(0,n-1);
  printf("%ld\n",ans);  
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  int n;
  cin>>n;
  vector<int> h(n);
  rep(i,n) cin>>h[i];
  int cnt=0;
  rep(i,n){
    while(h[i]>0){
      cnt++;
      rep(j,n-i){
       if(h.at(i+j)>0) {
        h.at(i+j)--; 
       }
       else{
         break;
       }
      }
    }
  }
  cout<<cnt<<endl;
}






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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

const int mod = 1000000007;

int main() {
    int N, X, T;
    cin >> N >> X >> T;

    int cnt = N / X;
    if (N % X) cnt++;
    cout << cnt * T << endl;
}


Measured memory_bytes: 3604
n = int(input())
p = list(map(int,input().split()))
ans = 0
currentMin = 10 ** 9
s = []

for i in range(n):
    if currentMin > min(currentMin,p[i]):
        currentMin = min(currentMin,p[i])
        s.append(currentMin)
    else:
        s.append(currentMin)

for i in range(len(p)):
    if p[i] == s[i]:
        ans += 1

print(ans)


Measured memory_bytes: 85712
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;

	int r = A - B;
	if (C - r >= 0) cout << C - r << endl;
	else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a) for(auto &i:a)
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
#define NO "NO"
#define YES "YES"
typedef long long ll;
//---------------------------------------------------------------------------------------------------
ll N, A, B, C, D;
string solve() {
    ll d = abs(A - B);
 
    ll i = 0LL;
    while (i * 2LL <= N - 1LL) {
        ll ma = D * (N - 1LL - i * 2LL);
        ll mi = C * (N - 1LL - i * 2LL);
 
        ll mma = abs(C - D) * i;
        ll mmi = 0LL;
 
        if (mi - mma <= d && d <= ma + mma) return YES;
 
        i++;
    }
    return NO;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    while(cin >> N >> A >> B >> C >> D) cout << solve() << endl;
}

Measured memory_bytes: 256
s =int(input())
sl =[s]
for i in range(10**6):
    if sl[-1]%2 ==0:
        new_sl =sl[-1] //2
    else:
        new_sl =3*sl[-1]+1
    if new_sl in sl:
        print(i+2)
        break

    sl.append(new_sl)

Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<cmath>
#include<map> 
#include<string>
#include<queue>
#include<stack> 
#include<bitset>
#include<list>
#include<set>
#include<utility>
#include<iomanip>
#define IO ios::sync_with_stdio(false)
#define eps 1e-7
#define int long long
using namespace std;
int p[1005],k,n,ans;
signed main()
{
	IO;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		cin>>p[i];
	}
	sort(p+1,p+n+1);
	for(int i=1;i<=k;i++)
	{
		ans+=p[i];
	}
	cout<<ans;
}

Measured memory_bytes: 3660
import math
import collections
from operator import mul
from functools import reduce
import bisect

b=[]
def test(a):
    if len(a)>=8:
        b.append(a+"3")
        b.append(a+"5")
        b.append(a+"7")
    else:
        b.append(a+"3")
        b.append(a+"5")
        b.append(a+"7")
        test(a+"3")
        test(a+"5")
        test(a+"7")

#n,m=map(int,input().split())

n=int(input())
m=[(0,0,0)]*n
for i in range(n):
    m[i]=tuple(map(int,input().split()))

for x in range(101):
    for y in range(101):
        h=-1
        flag=0
        err=0
        for mi in m:
            hh=abs(mi[0]-x)+abs(mi[1]-y)
            if  mi[2]==0:
                if flag==0:
                    h=-hh
                    flag=1
                elif flag==1:
                    h=-min(abs(h),hh)
                else:
                    if h>hh:
                        err=1
                        break
            else:
                if flag==0:
                    h=mi[2]+hh
                    flag=2
                elif flag==1:
                    if abs(h)>=mi[2]+hh:
                        flag=2
                        h=mi[2]+hh
                    else:
                        err=1
                        break
                else:
                    if mi[2]+hh!=h:
                        err=1
                        break
        if err==0:
            print (x,y,h)
            exit()







Measured memory_bytes: 44780
#include<stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[N][N];
int color[N],d[N],f[N],tt;

void dfs_visit(int); 
void dfs(void);

int main(){

  int u,v,k,i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }


  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
    }
  }

  dfs();

  return 0;
}


void dfs_visit(int u){

  int v;
  color[u]=GRAY;
  d[u]=++tt;
  for(v=0;v<n;v++){
    if(M[u][v]==0)continue;
    if(color[v]==WHITE){
      dfs_visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++tt;
}


void dfs(){
  
  int u;
  
  for(u=0;u<n;u++){
    color[u]=WHITE;
  }
  tt=0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE)dfs_visit(u);
  }

  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

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

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

constexpr long double EPS=1e-8;


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N;
	cout<<N*N<<endl;
}

Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))
mina = min(a)
maxa = max(a)
if mina == maxa:
    print(0)
    exit()

sousa = 0
index = 0
if abs(mina) <= abs(maxa):
    sousa = maxa
    index = a.index(maxa)
else:
    sousa = mina
    index = a.index(mina)

print(2 * N - 1)
for i in range(N):
    print(index + 1, i + 1)

if sousa >= 0:
    for i in range(N - 1):
        print(i + 1, i + 2)
else:
    for i in range(N, 1, -1):
        print(i, i - 1)

Measured memory_bytes: 9128
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int a[50][50],c[50];
int main()
{
 	ios::sync_with_stdio(false);
	int n,m,x;
	cin>>n>>m>>x;
	for(int i=0;i<n;i++){
		cin>>c[i];
		for(int j=0;j<m;j++)
			cin>>a[i][j];
	}
	int ans = 1e9;
	for(int t=0;t<(1<<n);t++){
		int sum = 0,cnt[50];
		memset(cnt,0,sizeof(cnt));
		for(int i=0;i<n;i++)
			if(t&(1<<i)){
				sum += c[i];
				for(int j=0;j<m;j++)
					cnt[j] += a[i][j];
			}
		bool bad = 0;
		for(int i=0;i<m;i++)
			if(cnt[i]<x)
				bad = 1;
		if(!bad)ans = min(ans,sum);
	}
	if(ans==1e9)puts("-1");
	else cout << ans << endl;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, a;
    cin >> n >> a;
    cout << n * n - a << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using ld = long double;                  //   | grep -v ' .* '  1300111 ~2^20.31
using vl = vector<ll>;                   //                    10300777 ~2^23.30
using vvl = vector<vl>;                  //                   100400999 ~2^26.58
using pll = pair<ll,ll>;                 //                  1300400999 ~2^30.28
using vpll = vector<pll>;                //                 10200500333 ~2^33.25
using vb = vector<bool>;                 //                100200400777 ~2^36.54
using vs = vector<string>;               //               1200300700111 ~2^40.13
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //              10200300500777 ~2^43.21
const ld eps = 1e-9;                     //             100200300400777 ~2^46.51
#define sz(c) ll((c).size())             //            1200300400600999 ~2^50.09
#define all(c) begin(c),end(c)           //           10200300400600111 ~2^53.18
#define mp make_pair                     //          100200300400600333 ~2^56.48
#define mt make_tuple                    //         1200300400500800999 ~2^60.06
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(0) cerr << "TR: " << (#X) << " = " << (X) << endl; })

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

	ll N, W; cin >> N >> W;
	vpll items(N+1);
	FOR(i,1,N+1) cin >> items[i].xx >> items[i].yy;

	vvl dp(N+1, vl(W+1, 0));
	FOR(i,1,N+1) {
		TR(i);
		ll w, v;
		tie(w, v) = items[i];
		TR(w);
		TR(v);

		FOR(j,1,W+1) {
			TR(j);
			if (j >= w && dp[i-1][j] < dp[i-1][j-w] + v) {
				TR("take");
				dp[i][j] = dp[i-1][j-w] + v;
			} else {
				TR("leave");
				dp[i][j] = dp[i-1][j];
			}
			TR(dp[i][j]);
		}
	}

	cout << dp[N][W] << "\n";

	return 0;
}


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

int main() {

	int	N;
	int	a;

	cin >> N;

	if( N % 2 == 0 )
	{
		a = ( N - 1 )/ 2;
	}
	else
	{
		a = N / 2;
	}


	cout << a << endl;

	return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
typedef long long ll;
#include <bits/stdc++.h>

using namespace std;

ll mod = 1000000007;

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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n)
	{
		if (n & 1)
		{
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y)
	{
		swap(x, y);
	}

	while (0 < y)
	{
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
bool isPrime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2)
	{
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++)
	{
		if (isPrime[i])
		{
			Type j = i + i;
			while (j <= n)
			{
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binarySearchJudge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binarySearch(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok))
	{
		int mid = (ng + ok) / 2;
		if (binarySearchJudge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	vector<int> c(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
	}

	vector<int> dpA(n, a[0]);
	vector<int> dpB(n, b[0]);
	vector<int> dpC(n, c[0]);
	int ans = 0;
	for (int i = 1; i < n; i++)
	{
		dpA[i] = max(dpB[i - 1] + a[i], dpC[i - 1] + a[i]);
		dpB[i] = max(dpC[i - 1] + b[i], dpA[i - 1] + b[i]);
		dpC[i] = max(dpA[i - 1] + c[i], dpB[i - 1] + c[i]);
	}
	ans = max(ans, dpA[n - 1]);
	ans = max(ans, dpB[n - 1]);
	ans = max(ans, dpC[n - 1]);
	cout << ans << endl;
}

Measured memory_bytes: 2560
import sys
import math
for i in sys.stdin.readlines():
    i = i.rstrip()
    i = i.split()
    x = int(i[0])
    y = int(i[1])
    if x == 0 and y == 0:
        break
    print(str(min(x,y))+" "+str(max(x,y)))

Measured memory_bytes: 7980
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int nn = sc.nextInt();
		int i=0;
		
		for (i=1;i<10;i++){
			if(nn%i==0 && (int)nn/i<10){
				System.out.print("Yes");
				break;
			}
		}
		
		if(i==10){
			System.out.print("No");
		}
		
	}
}

Measured memory_bytes: 21844
from operator import xor

A,B = map(int,input().split())

def f(a) :
    if a % 4 == 1 :
        res = 1
    elif a % 4 == 2 :
        res = a+1
    elif a % 4 == 3 :
        res = 0
    else :
        res = a
    
    return res

x = f(B)

if A == 0 :
    y = 0
else :
    y = f(A-1)

ans = xor(x,y)

print(ans)


Measured memory_bytes: 3060
q, h, s, d = map(int, input().split())
n = int(input())

if n % 2 == 0:
    l = [4*q*n, 2*h*n, s*n, d*(n//2)]
    l.sort()
    print(int(l[0]))
else:
    l = [4*q*(n-1), 2*h*(n-1), s*(n-1), d*((n-1)//2)]
    l_rest =  [4*q, 2*h, s]
    l.sort()
    l_rest.sort()
    if n > 1:
        print(int(l[0]+l_rest[0]))
    elif n == 1:
        print(l_rest[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    string s, t; cin >> s >> t;
    int n = SZ(s);
    int res = 0;
    for (int i = 0; i < n; i++) {
        res += (s[i] != t[i]);
    }
    cout << res;
}


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

int main(){
	int a, b;
	cin >> a >> b;
	
	if(a < b){
		cout << "a < b" << endl;
	}else if(a > b){
		cout << "a > b" << endl;
	}else{
		cout << "a == b" << endl;
	}
    return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int64_t x, r = 2;
  cin >> x;
  for (int i = 0; i < x; ++i) r = 2 * r + 2;
  cout << r << endl;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

def ind(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default

cnt = 0
for i in range(1000):
    tmp = S
    t = str(i).zfill(3)

    pos_1 = ind(tmp,t[0])
    if pos_1>=0:
        tmp = tmp[pos_1+1:]
    elif pos_1 == -1:
        continue

    pos_2 = ind(tmp,t[1])
    if pos_2>=0:
        tmp = tmp[pos_2+1:]
    elif pos_2 == -1:
        continue

    pos_3 = ind(tmp,t[2])
    if pos_3>=0:
        tmp = tmp[pos_3+1:]
    elif pos_3 == -1:
        continue
    cnt += 1
print(cnt)

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

int main(){
  int N;
  std::cin >> N;
  std::vector<int> a(N);
  for(auto& x: a){
    std::cin >> x;
  }
  int ans = 0;
  for (int i = 0;i<N;){
    int j= 0;
    for (;j<N-i;j++){
      if (a[i] != a[i+j]){
        break;
      }
    }
    i = i + j;
    
    ans += j/2;
  }
  std::cout << ans << std::endl;
}



Measured memory_bytes: 256