akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using namespace std;

int dist[2001][2001];

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

    rep(i, N) rep(j, N) dist[i][j] = abs(i - j);

    int x, y;
    cin >> x >> y;
    x--; y--;

    rep(i, N) rep(j, N) {
        dist[i][j] = min(dist[i][j], dist[i][x] + dist[y][j] + 1);
        dist[i][j] = min(dist[i][j], dist[i][y] + dist[x][j] + 1);
    }

    vector<int> cnt(N, 0);
    rep(i, N) rep(j, N) cnt[dist[i][j]]++;
    rep(i, N-1) {
        cout << cnt[i+1] / 2 << endl;
    }

    return 0;
}


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

int main(){
  
int n,a,b;
cin >> n >> a >> b ;
int tmp,tmp2;
long long sum = 0;
for(int i = 1; i <= n; i++){
	tmp = 0;
	tmp2 = i;
	while(tmp2){
		tmp += tmp2%10;
		tmp2/=10;
    }
    if(a <= tmp && tmp <= b){
    	sum += (long long) i;
    }
    
  }

  	cout << sum << endl;
  
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var p = new int[N];
		for (var i = 0; i < N; i++) p[i] = F - 1;
		var q = new int[N];
		for (var i = 0; i < N; i++) q[p[i]] = i;
		var ans = N + 10;
		var l = 0;
		while (l < N)
		{
			var r = l + 1;
			while (r < N && q[r] >= q[r - 1]) r++;
			ans = Min(ans, N - r + l);
			// Console.WriteLine($"l = {l}, r = {r}, {N - r + l}");
			l = r;
		}
		Console.WriteLine(ans);
	}
}


Measured memory_bytes: 16604
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 205;
ll a[N];
char s[N];
int main()
{
    int T; scanf("%d", &T);
    while(T--) {
        int n; scanf("%d", &n);
        for(int i = 1; i <= n; i++) scanf("%lld", &a[i]);
        scanf("%s", s + 1);
        vector<ll> v;
        bool flag = 1;
        for(int i = n; i >= 1; i--) {
            ll b = a[i];
            for(int k = 0; k < v.size(); k++) b = min(b, b ^ v[k]);
            if (b) {
                if(s[i] == '1') {flag = 0; break;}
                v.push_back(b);
            }
        }
        if(flag) puts("0");
        else puts("1");
    }
    return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>

using namespace std;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

    int minCost = 99999;
    for (int i = 0; i < n; i++)
    {
        int cost = 0;
        int time = 0;

        cin >> cost >> time;

        if (t >= time && minCost > cost)
        {
            minCost = cost;
        }
    }
    
    if (minCost == 99999)
    {
        cout << "TLE" << endl;
    }
    else
    {
        cout << minCost << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def abc175_b():
    n = int(input())
    l = list(map(int, input().split(' ')))
    cnt = 0

    for i in range(0, n - 2):
        for j in range(i + 1, n - 1):
            for k in range(j + 1, n):

                # 辺の長さが同じ場合は却下
                if l[i] == l[j] or l[j] == l[k] or l[k] == l[i]:
                    continue
                # 三角形になるにはa+b>c,b+c>a,c+a>b
                if (l[i] + l[j] > l[k]) and (l[j] + l[k] > l[i]) and (l[k] + l[i] > l[j]):
                    cnt += 1
    print(cnt)

if __name__ == '__main__':
    abc175_b()

Measured memory_bytes: 9168
xya=[]
whn=list(map(int,input().split()))
for i in range(whn[2]):
    xya.append(list(map(int,input().split())))

threshold=[0,whn[0],0,whn[1]]
for i in range(whn[2]):
    if xya[i][2]==1:
        if xya[i][0]>threshold[0]:
            threshold[0]=xya[i][0]
    elif xya[i][2]==2:
        if xya[i][0]<threshold[1]:
            threshold[1]=xya[i][0]
    elif xya[i][2]==3:
        if xya[i][1]>threshold[2]:
            threshold[2]=xya[i][1]
    else:
        if xya[i][1]<threshold[3]:
            threshold[3]=xya[i][1]
w=max(threshold[1]-threshold[0],0)
h=max(threshold[3]-threshold[2],0)
print(w*h)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <queue>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define vsort(v) sort(v.begin(),v.end)
using namespace std;
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if ((a*b) % 2 == 1 && (c+d) % 2 == 1)cout << "No" << endl;
	else cout << "Yes" << endl;
}


Measured memory_bytes: 3088
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int x, y, z; cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int h,w,n;

int main(){
	cin>>h>>w>>n;
	if(h<w) swap(h,w);
	cout<<(n+h-1)/h<<endl;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc157/submissions/10472433
#include <algorithm>
#include <iostream>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

// 友達関係の数 person: number of the friends
int deg[100005];
// ブロック関係の隣接リスト
vector<int> to[100005];

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  // friends-relations
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    deg[a]++;
    deg[b]++;
    // UFにaとbの友達関係を追加
    uf.unite(a,b);
  }
  // block-relations
  rep(i,k) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n) {
    // 同じグループのサイズ - 自分自身 - 友達の数
    int ans = uf.size(i)-1-deg[i];
    // さらにブロックリストに同じグループの人がいたら引く
    for (int u : to[i]) {
      if (uf.same(i,u)) --ans;
    }
    printf("%d%c", ans, i==n-1?'\n':' ');
  }
  return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    

    int n;
    cin >> n;
    int ary[n];
    rep(i,n) cin >> ary[i];
    int hani[101010];
    rep(i,101010) hani[i] = 0;
    rep(i,n)
    {
        rep(j,3)
        {
            if (ary[i]==0 && j==0) continue;

            hani[ary[i]-1+j]++;
        }
    }
    int ans = 0;
    rep(i,101010)
    {
        ans = max(ans, hani[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
/* Author- Abhijeet Trigunait */

#include<bits/stdc++.h>
#define lld long long int
#define F first
#define S second
#define P pair<int,int>
#define pb push_back
#define mod 1e9+7
#define setbits(x) __builtin_popcountll(x)
#define zerobits(x) __builtin_ctzll(x)
#define gcd(x,y) __gcd(x,y)
#define endl '\n'

using namespace std;


string solve(vector<lld> vec,lld k){
	bool dp[k+1];
	memset(dp,0,sizeof(dp));
	for(lld i=1;i<=k;++i){
		for(auto x:vec){
			if(x>i)continue;
			if(dp[i-x]==0){
				dp[i]=1;
			}
		}
	}return dp[k] ? "First" : "Second";

}

int main(){

	#ifndef ONLINE_JUDGE 
 	freopen("input.txt","r",stdin);
 	freopen("output.txt","w",stdout);
 	#endif
 	lld n,k;
 	cin>>n>>k;
    vector<lld> vec(n);
    for(lld i=0;i<n;++i)cin>>vec[i];
    cout<<solve(vec,k)<<endl;
}

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

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> a(n);
	long long sum = 0;
	unordered_map <int, int> m;
	for (int &i : a)  { cin >> i; sum += i; ++m[i];}
	int q;
	cin >> q;
	int b, c;
	while (q--) {
		cin >> b >> c;
		sum += (m[b] * (c - b));
		m[c] += m[b];
		m[b] = 0;
		cout << sum << '\n';
	}
}


Measured memory_bytes: 7520
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N; cin >> N;
    vector<string > s(N);
    for (int i=0; i<N; i++) cin >> s[i];
    
    int ans = 0;
    int ab = 0;
    int a = 0;
    int b = 0;
    for (int i=0; i<N; i++){
        int n = s[i].size() - 1;
        if (s[i][0] == 'B' && s[i][n] == 'A'){
            ab++;
        }else if(s[i][0] == 'B'){
            b++;
        }else if(s[i][n] == 'A'){
            a++;
        }
    }
    
    for (int i=0; i<N; i++){
        for (int j=0; j<s[i].size() - 1; j++){
            if(s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
        }
    }
    // cout << ab << " " << a << " " << b << " " << ans <<  endl;
    int p = 0;
    if (ab > 0){
        ans += ab - 1;
        p = 1;
    }
    
    ans += min(a, b);
    if (a + b >  0 && p == 1) ans += 1;
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3704
def solve():
    N = int(input())
    H = [int(i) for i in input().split()]
    ans = 0
    tmp = 0
    for i in range(N - 1):
        if H[i] >= H[i + 1]:
            tmp += 1
        else:
            ans = max(ans, tmp)
            tmp = 0
    print(max(ans, tmp))

if __name__ == "__main__":
    solve()

Measured memory_bytes: 85440
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define fe(vec,lambda) std::for_each(vec.begin(), vec.end(), lambda );
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#define printv(val) std::for_each(val.begin(),val.end(),[](auto x){cout<<x<<"\n";});
#define lim 1000000007ll
#include<bits/stdc++.h>
using ll = long long;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T chmin(T& a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T& b,T a){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template <class T> T gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T lcm(T a, T b){return a * b / gcd(a, b);}
inline bool operator<(const pii &lhs,const pii &rhs){return(lhs.second<rhs.second);}
template<class T> vector<pair<T,T>> duplicator(const vector<T>& input){vector<pair<T,T>> out(input.size()-1);rep(i,input.size()-1){out[i].first =input[i  ];out[i].second=input[i+1];}return(out);}
vector<char> String_to_vector_char(const string& input){vector<char> out(input.size());rep(i,input.size()){out[i]=input[i];}return out;}


ll a,b,c;
vector<ll>v;
map<ll,ll>m;
string s,s2;
void input(){
    cin>>a>>s>>b;
}
void src(){
    cout<<(s=="+"? a+b:a-b);
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
d = set(map(int, input().split()))
s = set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
dd = s - d

for i in range(n, 100001):
    ss = set([int(i) for i in list(str(i))])
    if dd >= ss:
        print(i)
        break

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

int main(){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    if(a+b <= 2*c){
        cout << a*x + b*y << endl;
        return 0;
    }else{
        int mn = min(x,y);
        int mx = max(x,y);
        int ans;
        int num;
        ans = 2*mn*c + max(x - mn, 0)*a + max(y - mn, 0)*b;
        num = 2*mx*c;
        ans = min(ans,num);
        cout << ans << endl;
        return 0;
    }
} 

Measured memory_bytes: 256
import collections
import numpy as np

n = int(input())
l = input().split()
v = [ int(s) for s in l ]

#n = 4
npv = np.array( v, dtype=np.int32)
#npv = np.array( [3,1,3,2], dtype=np.int32)
npv_dic = {}
npv_dic['even'] = npv[0::2]
npv_dic['odd']  = npv[1::2]

#print('n = ', n)
#print('npv = ', npv)
#print('npv_dic[\'even\'] = ', npv_dic['even'])
#print('npv_dic[\'odd\']  = ', npv_dic['odd'])

dict0 = collections.Counter(npv_dic['even'])
dict1 = collections.Counter(npv_dic['odd'])

list0 = list(dict0.items())
list1 = list(dict1.items())

list0.sort(key= lambda x:x[1], reverse=True)
list1.sort(key= lambda x:x[1], reverse=True)

#print(list0[0] ,list1[0])
#print(list0[1] ,list1[1])

if list0[0][0] == list1[0][0]:
    if (list0[0][1] == list1[0][1]) and \
        (list0.__len__() > 1) and (list0.__len__() > 1):
        if list0[1][1] > list1[1][1]:
            del list0[0]
        else:
            del list1[0]
    elif list0[0][1] > list1[0][1]:
        del list1[0]
    else:
        del list0[0]
#print(list0[0] ,list1[0])
#print(list0[1] ,list1[1])

if list0.__len__() != 0:
    change0 = n//2 - list0[0][1]
else:
    change0 = n//2
if list1.__len__() != 0:
    change1 = n//2 - list1[0][1]
else:
    change1 = n//2
#print('change:', change0, change1)

print(change0 + change1)


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

int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i =0 ; i < n ; ++i){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),greater<int>());
    int s1,s2=s1=0;
    for(int i=0 ; i < n ; ++i){
        if(i&1)
            s2+=a[i];
        else
            s1+=a[i];
    }
    cout<<s1-s2<<endl;

}


Measured memory_bytes: 256
K = int(input())

x = 7 % K
s = set()
count = 0
while(True):
    count += 1
    if x in s:
        print(-1)
        break
    else:
        s.add(x)
        if x == 0:
            print(count)
            break
        x = (10*x+7) % K

Measured memory_bytes: 200420
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }

int main(){
    INT(n,c);
    int x,sum=0;
    rep(i,c){
        in(x);
        sum+=x;
    }
    int ans=sum/(n+1);
    if(sum%(n+1)!=0)ans++;
    out(ans);
}


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

int main(){
    int h , w;
    while(cin >> h >> w,!(h==0&&w==0)){
        for(int y = 0; y < h; y++){
            for(int x = 0; x < w; x++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3048
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int w=sc.nextInt();
			int h=sc.nextInt();
			String gomi = sc.nextLine();
			if(w==0&&h==0) break;
			int[][] map = new int[h][w];
			int start_w=0,start_h=0;
			for(int i=0;i<h;++i){
				String line = sc.nextLine();
				String[] line2=line.split("");
				for(int j=0;j<w;++j){
					if(line2[j].equals("#")){
						map[i][j]=-1;
					} else if(line2[j].equals("@")){
						map[i][j]=1;
						start_w=j; start_h=i;
					}
				}
			}
			int[][] flag = new int[h][w];
			flag[start_h][start_w]=1;
			int count=1;
			Queue<Node> queue = new LinkedList<Node>();
			queue.add(new Node(start_h, start_w));
			while(!queue.isEmpty()){
				Node cur = queue.remove();
				if(cur.h!=0){
					if(map[cur.h-1][cur.w]==0 && flag[cur.h-1][cur.w]==0){
						count++; flag[cur.h-1][cur.w]=1;
						queue.add(new Node(cur.h-1,cur.w));
					}
				}
				if(cur.h!=h-1){
					if(map[cur.h+1][cur.w]==0 && flag[cur.h+1][cur.w]==0){
						count++; flag[cur.h+1][cur.w]=1;
						queue.add(new Node(cur.h+1,cur.w));
					}
				}
				if(cur.w!=0){
					if(map[cur.h][cur.w-1]==0 && flag[cur.h][cur.w-1]==0){
						count++; flag[cur.h][cur.w-1]=1;
						queue.add(new Node(cur.h,cur.w-1));
					}
				}
				if(cur.w!=w-1){
					if(map[cur.h][cur.w+1]==0 && flag[cur.h][cur.w+1]==0){
						count++; flag[cur.h][cur.w+1]=1;
						queue.add(new Node(cur.h,cur.w+1));
					}
				}
			}
			System.out.println(count);
		}
	}
}
class Node{
	int h,w;
	Node(int w,int h){
		this.h=w;
		this.w=h;
	}
}


Measured memory_bytes: 57724
#include "bits/stdc++.h"
using namespace std;
int main(){
    int n,m,i,a,ans=1;
    cin >> n;
    vector<int> d(n);
    map<int,int> vad,vat;
    for(i=0;i<n;i++){
        cin >> a;
        d.at(i)=a;
        vad[a]++;
    }
    cin>>m;
    vector<int> t(m);
    for(i=0;i<m;i++){
        cin >> a;
        t.at(i)=a;
        vat[a]++;
    }
    for(i=0;i<m;i++){
        if(vad[t.at(i)]<vat[t.at(i)]) ans = 0;
    }
    if(ans) cout<<"YES"<<endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main()
{
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<long> p(A), q(B), r(C);
  for (int i = 0; i < A; i++) cin >> p.at(i);
  for (int i = 0; i < B; i++) cin >> q.at(i);
  for (int i = 0; i < C; i++) cin >> r.at(i);
  sort(p.begin(), p.end()); reverse(p.begin(), p.end());
  sort(q.begin(), q.end()); reverse(q.begin(), q.end());
  sort(r.begin(), r.end()); reverse(r.begin(), r.end());
  long long ans = 0;
  for (int i = 0; i < X; i++) ans += p.at(i);
  for (int i = 0; i < Y; i++) ans += q.at(i);
  int index = 0;
  while (true)
  {
    bool check = true;
    // cout << "index X Y" << index << X << Y << endl;
    if (index == C) break;
    if (X != 0 && Y != 0)
    {
      if (p.at(X-1) < q.at(Y-1))
      {
        if (p.at(X-1) < r.at(index))
        {
          ans += r.at(index) - p.at(X-1);
          X--;
          index++;
          check = false;
        }
      }
      else
      {
        if (q.at(Y-1) < r.at(index))
        {
          ans += r.at(index) - q.at(Y-1);
          Y--;
          index++;
          check = false;
        }
      }
    }
    else if (X != 0)
    {
      if (p.at(X-1) < r.at(index))
      {
        ans += r.at(index) - p.at(X-1);
        X--;
        index++;
        check = false;
      }
    }
    else if (Y != 0)
    {
      if (q.at(Y-1) < r.at(index))
      {
        ans += r.at(index) - q.at(Y-1);
        Y--;
        index++;
        check = false;
      }
    }
    else break;
    if (check) break;
  }
  cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e15;
const int MOD = 1e9+7;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};
typedef pair<ll, ll> pll;

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

  rep(i, k){
    vector<int> b(n, 0);
    for (int i=0; i < n; i++){
      int l = max(0, i-a[i]);
      int r = min(n-1, i+a[i]);

      b[l]++;
      if(r+1 < n) b[r+1]--;
    }
    rep(i, n-1) b[i+1] += b[i];

    bool same = true;
    rep(i, n){
      if(a[i] != b[i]) same = false;
    }
    a = b;
    if(same) break;
  }

  rep(i, n){
    cout << a[i] << endl;
  }
}


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());

  int count;
  int GCD = 1;
  for(int i = max(A.at(0), A.at(1)); i > 1 ; i--){
    count = 0;
    for(int x : A){
      if(x % i != 0) count++;
    }
    if(count <= 1){
      GCD = i;
      break;
    }
  }
  cout << GCD << endl;
}


Measured memory_bytes: 640
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC88D
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] DPArray = new int[N+1];

            for (int i = 1; i <= N; i++)
            {
                //一円ずつ
                DPArray[i] = i;
            }

            for (int i = 0; i <= N; i++)
            {
                //6^n乗
                int index6 = 1;
                while (true)
                {
                    int money = (int)Math.Pow(6, index6)+i;
                    if (money > N) break;
                    DPArray[money] = Math.Min(DPArray[money], DPArray[i] + 1);
                    index6++;
                }

                //9^n乗
                int index9 = 1;
                while (true)
                {
                    int money = (int)Math.Pow(9, index9)+i;
                    if (money > N) break;
                    DPArray[money] = Math.Min(DPArray[money], DPArray[i] + 1);
                    index9++;
                }
            }

            Console.WriteLine(DPArray[N]);
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13216
s = input()
n = len(s)
s += 'E'
A = [0]*n
R=0
L=0
for i in range(n):
    if s[i]=='R':
        R += 1
        if s[i+1] == 'L':
            if R%2 == 0:
                A[i] += R//2
                A[i+1] += R//2
            else:
                A[i] += R//2+1
                A[i+1] += R//2
            R = 0
    elif s[i]=='L' and s[i-1] == 'R':
        Lg = i
        L += 1
        if i == n-1:
            A[i] += 1
            L = 0
        elif i < n-1:
            if s[i+1] =='R':
                A[i] += 1
                L = 0
    elif s[i]=='L' and s[i-1] == 'L':
        L += 1
        if i == n-1:
             if L%2 == 0:
                A[Lg] += L//2
                A[Lg-1] += L//2
             else:
                A[Lg] += L//2+1
                A[Lg-1] += L//2
             L = 0
        elif i < n-1:
             if s[i+1] =='R':
                 if L%2 == 0:
                    A[Lg] += L//2
                    A[Lg-1] += L//2
                 else:
                    A[Lg] += L//2+1
                    A[Lg-1] += L//2
                 L = 0
Al=[str(a) for a in A]
Al=" ".join(Al)
print(Al)

Measured memory_bytes: 10612
#include <stdio.h>

int main(void) {
 int a, b, c, d;
 scanf("%d", &a);
 scanf("%d", &b);
 scanf("%d", &c);
 scanf("%d", &d);
 if(a*b > c*d) printf("%d", a*b);
 else printf("%d", c*d); 
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#define ll long long
using namespace std;

int main() {
  int N,cnt=0,a;
  cin>>N;
  a=N+1;
  int A[N];
  for(int i=0;i<N;i++) cin>>A[i];

  for(int i=0;i<N;i++){
    if(a>A[i]) cnt++;
    a=min(a,A[i]);
  }
  cout<<cnt<<endl;
}	


Measured memory_bytes: 1024
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.array;

ulong gcd(ulong a, ulong b) {
	return b ? gcd(b, a%b) : a;
}

ulong lcm(ulong a, ulong b, ulong c) {
	return a/c*b;
}

void main() {
	while(1){
		ulong[] v = readln.split.map!(to!ulong).array;
		if (stdin.eof) break;

		ulong g = gcd(v[0], v[1]),
			  l = lcm(v[0], v[1], g);

		writefln("%s %s", g, l);
	}

}

Measured memory_bytes: 1068
N=int(input())

arr=[list(map(int,input().split())) for i in range(N)]

brr=sorted(arr,key=lambda x:(x[1]))

time=0
work=0
count=0

for i in range(N):
    time=brr[i][1]
    work+=brr[i][0]
    if work<=time:
        count+=1
if count==N:
    print("Yes")
else:
    print("No")

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

using namespace std;

int main() {
    int n, x[100];
    cin >> n;
    for (int i=0; i<n; i++) {
        scanf("%d", &x[i]);
    }
    int sum = 0;
    for (int i=0; i<n; i++) {
        sum += x[i];
    }
    int p = round((double)sum/n);
    int ans = 0;
    for (int i=0; i<n; i++) {
        ans += (x[i]-p)*(x[i]-p);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <list>

using namespace std;

int main() {
	char c[1025];
	int i,n,k;
	list<char> tr;
	list<char>::iterator it;
	cin >> n;
	for (n;n>0;n--) {
	  cin >> c; 
	  k=strlen(c);
	  tr.push_back(c[0]);
	  it=tr.begin();
	  for (i=0;i<k-3;i+=3) { 
		  if (c[i+1]=='-') {it++; if (it==tr.end()) { it--; tr.push_back(c[i+3]); it++;}}
		  else { if (it==tr.begin()) tr.push_front(c[i+3]); it--;}
	  }
	  for (it=tr.begin();it!=tr.end();it++) cout << *it; cout << endl;
	  tr.clear();
	}
	return 0;
}

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

int X;

int main(){
    cin >> X;

    int num_items = X / 100;
    int resid = X % 100;

    if(resid <= 5 * num_items){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

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

int main()
{

    string s;
    cin >> s;
    int l = s.size();
    for(l = l-1 ; l > 1; l--)
    {
        if(l%2 == 0)
        {
            int i, j;
            for(i = 0, j = l/2; j < l; i++, j++)
            {
                if(s[i] != s[j])break;
            }
            if(i == l/2)break;
        }
    }
    printf("%d", l);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repe(i, n) for(int (i) = 0; i <= (n); (i)++)
#define repr(i, n) for(int (i) = (n); (i) > 0; --(i))
#define repre(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define elm1(pair) (pair).first
#define elm2(pair) (pair)).second
typedef long long ll;
typedef unsigned long long ull;
const ull MOD = 1000000007;
ull mpow(ull a, ull n);
ull inv_mod(ull a){return mpow(a, MOD-2);}

ull mpow(ull a, ull n)
{
    ull ans = 1;
    while(n>>=1){
        if(n & 1)(ans *= a)%= MOD;
        (a*=a)%=MOD;
    }
    return ans;
}

ull nCr(ull n, ull r)
{
    vector<ull> factorial(n+1);
    factorial[0]=1;
    rep(i, n)factorial[i+1] = factorial[i]*(i+1)%MOD;
    return factorial[n]*(inv_mod(factorial[n-r])%MOD*inv_mod(factorial[r])%MOD) % MOD;
}

ll dp[3000][3000] = {0};

//max manpuku
ll naps(vector<pair<ll, ll>> F, ll T, ll n, ll M)
{
    if(n >= F.size())return M;
    if(T <= 0.5)return M;
    return max(naps(F, T-F[n].first, n+1, M+F[n].second), naps(F, T, n+1, M));
}

int main()
{
    int N;
    cin >> N;
    vector<vector<int>> h(N, vector<int>(3, 0));
    rep(i, N)cin >> h.at(i).at(0) >> h.at(i).at(1) >> h.at(i).at(2);
    vector<vector<int>> dp(N, vector<int>(3));
    dp[0][0] = h[0][0];dp[0][1] = h[0][1];dp[0][2] = h[0][2];
    for(int i = 1; i < N; i++){
        /* 前日に遊んだものをK当日に選んだ遊びをJとする*/
        for(int j = 0; j <= 2; j++){
            for(int k = 0; k <= 2; k++){
                if(j == k)continue;
                dp[i][j] = max(dp[i][j], dp[i-1][k]+h[i][j]);
            }
        }
    }
    int tmp = max(dp[N-1][0], dp[N-1][1]);
    cout << max(tmp, dp[N-1][2]) << endl;



    return 0;
}


Measured memory_bytes: 11136
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int AC = 0, WA = 0, TLE = 0, RE = 0;
            for (int i = 0; i < N; i++) {
                string S = Console.ReadLine();
                if (S == "AC") {
                    AC++;
                }
                if (S == "WA") {
                    WA++;
                }
                if (S == "TLE") {
                    TLE++;
                }
                if (S == "RE") {
                    RE++;
                }
            }
            Console.WriteLine("AC x " + AC);
            Console.WriteLine("WA x " + WA);
            Console.WriteLine("TLE x " + TLE);
            Console.WriteLine("RE x " + RE);
        }
    }
}


Measured memory_bytes: 30704
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		String s = sc.next() , t = sc.next();
		sc.close();
		char[] ss = s.toCharArray();
		char[] tt = t.toCharArray();
		Arrays.sort(ss);
		Arrays.sort(tt);
		s = "";
		t = "";
		for(char i : ss) s += i;
		for(char i : tt) t = i + t;
		String[] yo = {s , t};
		Arrays.sort(yo);
		if(s.equals(t)) ou.println("No");
		else if(yo[0] == s) ou.println("Yes");
		else ou.println("No");
		ou.flush();
	}
}

Measured memory_bytes: 39764
using System;
using System.Collections.Generic;
using System.Linq;

namespace Problemex5_1
{
	class Program
	{
		static void Main(string[] args)
		{
			int.Parse(Console.ReadLine());
			var array = Console.ReadLine().Split().Select(long.Parse).ToArray();
			Console.WriteLine(array.Min()+" "+array.Max()+ " " + array.Sum());

		}

	}
}

Measured memory_bytes: 10596
#include <bits/stdc++.h>
#define rep(i, n) for (ll(i) = 0; (i) < (n); (i)++)
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl;

typedef long long ll;
const ll INF = 99999999999999;
const ll MOD = 1000000007;

using namespace std;

int main()
{
    int h, w, n, ans = 0;
    cin >> h >> w >> n;
    if (h >= w)
    {
        ans = (n + h - 1) / h;
    }
    else
    {
        ans = (n + w - 1) / w;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
class BisectSearch:
    def __init__(self, f, l=0, r=10**9):
        self.f = f
        self.l = l
        self.r = r
    def __call__(self, dist):
        f = self.f
        l = self.l
        r = self.r
        if dist <= f(l):
            return l
        if f(r) <= dist:
            return r
        while r-l > 1:
            n = (r+l) // 2
            if f(n) <= dist:
                l = n
            else:
                r = n
        return l

n = int(input())
def f(n):
    return (n+1)*n // 2
m = BisectSearch(f, l=1, r=10**7)(n)
m += f(m) != n
A = set(range(1, m+1))
A.discard(f(m) - n)
print(*A, sep='\n')

Measured memory_bytes: 9276
N=input()
An = input()
list_An=[]
a = 0
for i in range(len(An)):
    if An[i]==" ":
        list_An.append(int(An[a:i]))
        a = i+1
list_An.append(int(An[a:len(An)]))
list_An.sort()
A = 0
for i in range(len(list_An)):
    if list_An[i-1]==list_An[i]:
        print("NO")
        A = 1
        break    
if A == 0:
    print("YES")


Measured memory_bytes: 13628
import collections


class CursorList():
    def __init__(self):
        self.vector = collections.deque()
        self.cursor = 0

    def insert(self, x):
        self.vector.appendleft(x)
        return self

    def move(self, d):
        self.vector.rotate(-d)
        self.cursor += d
        return self

    def erase(self):
        self.vector.popleft()
        return self


num_queue = int((input()))
L = CursorList()

for i in range(0, num_queue):
    queue = tuple(map(int, input().split(' ')))
    if queue[0] == 0:
        L.insert(queue[1])
    elif queue[0] == 1:
        L.move(queue[1])
    elif queue[0] == 2:
        L.erase()

L.vector.rotate(L.cursor)
print('\n'.join(map(str, L.vector)))


Measured memory_bytes: 53380
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int main(){

    int N,A[110]={},L,d=0;
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>A[i];
    }

    if(N>1){
        L=lcm(A[1],A[2]);
        for(int i=3;i<=N;i++){
            L=lcm(L,A[i]);
        }

        for(int i=1;i<=N;i++){
            d+=L/A[i];
        }

        double ans = L/(d * 1.00);
        cout<<ans<<endl;
    }else{
        cout<<A[1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define all(obj) obj.begin(), obj.end()
#define dbg(x) cerr << #x << ":" << x << " "
#define dbgl(x) cerr << #x << ":" << x << "\n"
#define dbgv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbgvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main () {
	int N; cin >> N;
	vvi A(2, vi(N));
	rep(i, 2) rep(j, N) cin >> A.at(i).at(j);
	vi b(N), c(N);
	b.at(0) = A.at(0).at(0); rep2(j, 1, N) b.at(j) = b.at(j - 1) + A.at(0).at(j);
	c.at(N - 1) = A.at(1).at(N - 1); for(int j = N - 2; j >= 0; j--) c.at(j) = c.at(j + 1) + A.at(1).at(j);
	int ans = 0;
	rep(j, N) ans = max(ans, b.at(j) + c.at(j));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  int AB, BC, CA;
  cin >> AB >> BC >> CA;

  cout << AB*BC/2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, m;
    int min = 0;
    int max = 100001;
    scanf("%d %d", &n, &m);
    for(int i = 0; i < m; i++){
        int l, r;
        scanf("%d %d", &l, &r);
        if(min < l){
            min = l;
        }
        if(r < max){
            max = r;
        }
    }
    int result = max - min + 1;
    if(result < 0) result = 0;
    printf("%d", result);
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type city struct {
	p, y, i int
	ans     string
}

type byPref []city

func (a byPref) Len() int      { return len(a) }
func (a byPref) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a byPref) Less(i, j int) bool {
	if a[i].p == a[j].p {
		return a[i].y < a[j].y
	}
	return a[i].p < a[j].p
}

type byIdx []city

func (a byIdx) Len() int           { return len(a) }
func (a byIdx) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a byIdx) Less(i, j int) bool { return a[i].i < a[j].i }

func main() {
	_ = getInt()
	m := getInt()

	cities := make([]city, m)
	for i := range cities {
		cities[i].p = getInt()
		cities[i].y = getInt()
		cities[i].i = i
	}

	sort.Sort(byPref(cities))
	nowP := -1
	cnt := 0
	for i, c := range cities {
		if nowP == c.p {
			cnt++
		} else {
			nowP = c.p
			cnt = 1
		}
		cities[i].ans = fmt.Sprintf("%06d%06d", nowP, cnt)
	}

	sort.Sort(byIdx(cities))

	for _, c := range cities {
		fmt.Println(c.ans)
	}
}

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}


Measured memory_bytes: 9856
# 4 5
import math
field = [int(i) for i in input().split(" ")]
field_num = field[0] * field[1]
if field[0] == 1 or field[1] == 1:
    print(1)
else:
    canFillBlock = 0
    canFillBlock += math.ceil(field[1]/2) * math.ceil(field[0]/2)
    canFillBlock += math.floor(field[1]/2) * math.floor(field[0]/2)
    print(canFillBlock)


Measured memory_bytes: 3060
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

const (
	initialBufSize = 64 * 1024
	maxBufSize     = 10000000
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	n := scanInt()
	x := scanInts(n)
	len := len(x)

	ans := math.MaxInt64
	for p := 1; p <= 100; p++ {

		sum := 0
		for i := 0; i < len; i++ {
			sum += (x[i] - p) * (x[i] - p)
		}

		if sum < ans {
			ans = sum
		}
	}

	fmt.Println(ans)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

func min(n []int) (min, idx int) {
	min = math.MaxInt64
	for i := 0; i < len(n); i++ {
		if n[i] < min {
			min = n[i]
			idx = i
		}
	}
	return
}

func max(n []int) (max, idx int) {
	max = math.MinInt64
	for i := 0; i < len(n); i++ {
		if n[i] > max {
			max = n[i]
			idx = i
		}
	}
	return
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    val b = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    var sum = 0L
    for (i in 0 until n) {
        if (a[i] < b[i]) {
            sum += a[i]
            val x = b[i] - a[i]
            if (a[i + 1] < x) {
                sum += a[i + 1]
                a[i + 1] = 0
            } else {
                sum += x
                a[i + 1] -= x
            }
            a[i] = 0
        } else {
            sum += b[i]
            a[i] -= b[i]
        }
    }
    println(sum)
}

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

const int INF = 1e+8;

int main(){
	int T, N;
	while( cin >> T, T ){
		int t[31], day[101], maxd = 0;
		fill(day, day + 101, INF);
		
		for(int i = 0; i < T; i++) cin >> t[i];
		cin >> N;
		for(int i = 0; i < N; i++){
			int D, M;
			cin >> D >> M;
			day[D-1] = min(day[D-1], M);
			maxd = max(maxd, D);
		}
		
		// dp[k][t] := k日目で周期がt番目のときの最小コスト
		int dp[101][31];
		for(int i = 0; i < 101; i++) fill(dp[i], dp[i] + 31, INF);
		dp[0][0] = 0;
		
		for(int i = 0; i < maxd; i++){
			for(int j = 0; j < T; j++){
				if( t[j] <= day[i] ){
					dp[i+1][(j+1)%T] = min(dp[i+1][(j+1)%T], dp[i][j]);
				}
				// 周期をリセットする
				dp[i+1][1] = min(dp[i+1][1], dp[i][j] + 1);
			}
		}
		int ans = INF;
		for(int i = 0; i < T; i++){
			ans = min(ans, dp[maxd][i]);
		}
		cout << ans << endl;
	} 
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	int a[3],i,m,n;
	scanf("%d %d %d",&a[0],&a[1],&a[2]);
	m=0;
	while(1){
		if(a[0]==a[1]&&a[0]==a[2]) break;
		sort(a,a+3);
		if(a[2]-2>=a[0]){
			a[0]+=2;
			m++;
		}
		else {
			a[1]++;
			a[0]++;
			m++;
		}
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
  long long x = 1;
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  ll h,n;
  std::cin>>h>>n;

  ll sum=0;
  rep(i,0,n){
    ll a;
    std::cin>>a;
    sum+=a;
  }

  if(sum>=h)std::cout<<"Yes\n";
  else std::cout<<"No\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
using namespace std;

int main(){
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            cout << s.at(i);
        }

    }
    cout << endl;

    }


Measured memory_bytes: 512
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
int main(void){
    string s;
    cin >> s;
    for(auto &x : s){
        if(x == 'A'){
            x = 'T';
        } else if(x == 'T'){
            x = 'A';
        } else if(x == 'C'){
            x = 'G';
        } else if(x == 'G'){
            x = 'C';
        }
    }
    cout << s;
}

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[] = new int [4];
		int b[] = new int [4];		
		while(sc.hasNext()){
			int hit = 0;
			int blow = 0;
			for(int i = 0; i<4;i++){
				a[i]=sc.nextInt();
			}
			for(int i = 0; i<4;i++){
				b[i]=sc.nextInt();
			}
			
			for(int i = 0; i<4; i++){
				for(int  c = 0; c<4; c ++){
					if(i == c){
						if(a[i]==b[c]){
							blow ++ ;
						}
					}else{
						if(a[i]==b[c]){
							hit++;
						}
					}
				}
			}
			System.out.println(blow+" "+hit);
		}
	}
}

Measured memory_bytes: 26372
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

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

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def main():
    n = int(input())
    a = [x for x in map(int,input().split())]
    now = 1
    ans = 0
    for i in range(n):
        if a[i]==now:
            now += 1
        else:
            ans += 1
    if ans==n:
        print(-1)
    else:
        print(ans)
    return

if __name__=='__main__':
    main()

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





int main(void){
    // 自分の得意な言語で
    // Let's チャレンジ！！
    int N;
    cin>>N;
    int data[N];
    int i,j;
    int count=0;
    rep(i,N){
        cin>>data[i];
        if(i>0&&data[i-1]==data[i]){
            data[i]=0;
            count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256