akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int solve(int n){
  int res = 0;
  while(n != 0){
    res += n % 10;
    n /= 10;
  }

  return res;
}

int main(){

  int n, a, b;
  scanf("%d %d %d", &n, &a, &b);

  llong ans = 0;
  for(int i = 1; i <= n; i++){
    int t = solve(i);
    if(t >= a && t <= b){
      ans += i;
    }
  }

  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 256
def xor(x):
    if x%2==1:
        if ((x+1)//2)%2==0:
            return 0
        else:
            return 1
    else:
        if (x//2)%2==0:
            return x
        else:
            return x^1 

def main():
    a,b = map(int,input().split())
    ans = xor(b)^xor(a-1)
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
import java.awt.Point;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
     
    static int n;
	
    private static int[] primetable(int max)
    {
    	int[] ret = new int[max + 1];
    	int loop;
    	
    	for (int i = 0; i < max + 1; i++) ret[i] = 1;
    	ret[0] = ret[1] = 0;
    	loop = (int)(Math.sqrt(max) + 1);
    	
    	for (int i = 2; i <= loop; i++) {
			if (ret[i] == 0) {
				continue;
			}
			for (int j = i*2; j < max+1; j+=i) {
				ret[j] = 0;
			}
		}
    	return ret;
    }
    
    static void start()
    {
    	int[] prime = primetable(246912);
    	
    	int count = 0;
    	for (int i = n+1; i <= 2*n; i++) {
			if(prime[i] == 1) count++;
		}
    	
    	System.out.println(count);
    }
     
    public static void main(String[] args)
    {
         
        Scanner sca = new Scanner(System.in);
        
        while(true)
        {
        	n = sca.nextInt();
        	if(n == 0) break;
            
            start();
        }
        
    }
}

Measured memory_bytes: 89016
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main{
	public static void main(String[] args)throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int N = Integer.parseInt(br.readLine());
		String[] strs  = br.readLine().split(" ");
		
		int max = 0;
		BigInteger sum = new BigInteger("0");
		for(String str : strs){
			int n = Integer.parseInt(str);
			if(n < max){
				sum =  sum.add(new BigInteger("" + (max - n)));
			}else{
				max = n;
			}
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 71980
S = input()
N = 3


for x in range(1<<N):
    ans = S[0]
    sum = int(S[0])
    for i in range(N):
        if x & (1 << i):
            ans += "+" + S[i+1]
            sum += int(S[i+1])
        else:
            ans += "-" + S[i+1]
            sum -= int(S[i+1])
    if sum == 7:
        break

print(ans + "=7")

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;



int main()
{
	int A,B;
	cin>>A>>B;
	int ans = -1;
	for(double i = 1; i <= 2000; i++){
		if( (int)(i * 0.08) == A && (int)(i * 0.1) == B){
			ans = i;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    A = list(map(int, input().split()))
    a = len(set(A))
    res = len(A)-a
    if res%2==0:
        print(a)
    else:
        print(a-1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14940
#include<iostream>
#include<vector>
  
using namespace std;
  
int n, q;
vector<bool> isE(2001);
  
int main()
{
    cin>>n;
    int num;
      
    for( int i=0; i<n; i++ ) {
        cin>>num;
        for( int j=2000-num; 0<j; j-- ) {
            if( isE.at( j ) ) {
                isE.at( j+num ) = true;
            }
        }
        isE.at( num ) = true;
    }
    cin>>q;
    for( int i=0; i<q; i++ ) {
        cin>>num;
        if( isE.at( num ) ) {
            cout<<"yes"<<'\n';          
        } else {
            cout<<"no"<<'\n';
        }
    }
    return 0;
}  

Measured memory_bytes: 1160
# -*-  coding utf-8 -*-

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

A=[list(map(int,input().split())) for i in range(n)]
B=[list(map(int,input().split())) for j in range(m)]


for a in A:
    D=[]
    for i in range(m):
        D.append([abs(a[0]-B[i][0])+abs(a[1]-B[i][1]),i+1])
    D=sorted(D,key=lambda x:(x[0],x[1]))
    print(D[0][1])




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

ll n;

int main()
{
    cin >> n;
    int res = 1e9;
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            res = min(res, (int)to_string(max(i, n / i)).size());
        }
    }
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
    long long N,A,B;
    cin>>N>>A>>B;
    if((abs(A-B))%2==0) cout<<abs(A-B)/2<<"\n";
    else if(B==N||A==1){
        cout<<abs(A-B)/2+1<<"\n";
    }
    else{
        if(A-1<N-B) cout<<(A-1)+(B-A)/2+1<<"\n";
        else cout<<(N-B)+(B-A)/2+1<<"\n";
    }
   return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
    int n, m;
    std::cin >> n >> m;

    char a[60][60];
    bool flag = true;

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            std::cin >> a[i][j];
        }
    }

    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < m; ++j)
        {
            if (a[i][j] == '.')
                continue;

            bool flag = false;

            if (i != 0)
            {
                if (a[i - 1][j] == '#')
                    flag = true;
            }

            if (j != 0)
            {
                if (a[i][j - 1] == '#')
                    flag = true;
            }

            if (i != n - 1)
            {
                if (a[i + 1][j] == '#')
                    flag = true;
            }

            if (j != m - 1)
            {
                if (a[i][j + 1] == '#')
                    flag = true;
            }

            if (!flag)
            {
                std::cout << "No";
                return 0;
            }
        }
    }

    std::cout << "Yes";
}


Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
 
i = 0
a = 0
t = 0
w = 0
r = 0
 
for i in range(n):
  if s[i] == "AC":
    a += 1
    i += 1
  elif s[i] == "TLE":
    t += 1
    i += 1
  elif s[i] == "WA":
    w += 1
    i += 1
  else:
    r += 1
    i += 1
 
print("""AC x {0}
WA x {1}
TLE x {2}
RE x {3}""". format(a, w, t, r))

Measured memory_bytes: 16316
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    ll A,B,C; cin >> A >> B >> C;
    ll cnt = 0;
    ll M = max({A,B,C});
    cnt += (M-A)/2; A += (M-A)/2*2;
    cnt += (M-B)/2; B += (M-B)/2*2;
    cnt += (M-C)/2; C += (M-C)/2*2;
    ll cnt2 = 0;
    if(M != A) cnt2++;
    if(M != B) cnt2++;
    if(M != C) cnt2++;
    
    if(cnt2 == 0) cout << cnt << endl;
    else if(cnt2 == 1) cout << cnt + 2 << endl;
    else cout << cnt + 1 <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int[] a = new int[28];
		int[] check = new int[30];
		
		for(int i = 0; i < 28; i++){
			a[i] = stdIn.nextInt();
			check[a[i]-1] = 1;
		}
		
		for(int i = 0; i < 30; i++){
			if( check[i] == 0 ){
				System.out.println(i+1);
			}
		}
	}
}

Measured memory_bytes: 12000
from collections import defaultdict
import heapq as pq
N,M = map(int,input().split())
dic = defaultdict(list)
for i in range(N):
    a,b = map(int,input().split())
    if a <= M:
        dic[a].append(b)
ls = []
ans = 0
for i in range(0,M+1):
    for j in dic[i]:
        pq.heappush(ls,-j)
    if ls:
        ans -= pq.heappop(ls)
print(ans)
    


Measured memory_bytes: 27684
#include <cstdio>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

vector<int> ns;

int solve(int c){
	int ans = 0;
	
	for(int m=c;;m+=c){
		auto it = lower_bound(ns.begin(),ns.end(),m);
		if(it == ns.end()){
			ans = max(ans,ns.back()%c);
			break;
		}else if(it != ns.begin()){
			--it;
			ans = max(ans,*it%c);
		}
	}
	return ans;
}

int main(){
	int N,Q;
	cin >> N >> Q;
	for(int i=0;i<N;++i){
		int t;
		scanf("%d",&t);
		ns.push_back(t);
	}
	sort(ns.begin(),ns.end());
	for(int i=0;i<Q;++i){
		int t;
		scanf("%d",&t);
		printf("%d\n",solve(t));
	}
	return 0;
}

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

int main() {
	int n, d;
	cin >> n >> d;
	int a = 2 * d + 1;
	cout << (n+a-1)/a << endl;
	
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//  
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
// const double PI=3.1415926535897932;

//#define __DBG__


void solve(void){
  
  int N;
  
  cin >> N;
  
  vector<pair<int,int>> A;
  
  int ans=0;
  
  REP(i,N){
    int tmp;
    cin >> tmp;
 	A.push_back(make_pair(tmp,i+1));
  }
  sort(ALL(A));
  
  REP(i,N){
    if(i<N-1){
      cout << A[i].second << " ";
    }
    else
    {
      cout << A[i].second << endl;
    }
  }

  return;
   
}


int main(int argc, const char * argv[]) {

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

    solve();
 
    return 0;
}




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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 112345;
ll A[MAX_N];
ll S[MAX_N];

pair<ll, ll> f(int N, ll M, ll V) {
  // A[x] + A[y] >= V の {個数, 合計} を返す
  ll count = 0, sum = 0;
  REP(i, N) {
    int p = distance(A, lower_bound(A, A+N, V-A[i]));
    ll C = (N - p);
    count += C;
    sum += C * A[i] + (S[N] - S[p]);
  }
  return {count, sum};
}

int main2() {
  int N = nextInt();
  ll M = nextLong();
  REP(i, N) A[i] = nextLong();
  sort(A, A+N);
  S[0] = 0;
  REP(i, N) S[i+1] = S[i] + A[i];

  ll hi = 1LL << 61;
  ll lo = 0;
  while (hi - lo > 1) {
    ll mid = (hi + lo) / 2;
    auto val = f(N, M, mid);
    if (val.first >= M) lo = mid; else hi = mid;
  }
  auto val = f(N, M, hi);
  ll ans = 0;
  ans += val.second;
  ans += (M - val.first) * (hi-1);
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
ll A[MAX_N] = {};

signed main()
{
    cin >> N;
    ll max_n = 0;
    REP(i, N) {
        cin >> A[i];
        max_n = max(max_n, A[i]);
    }
    ll cand = 0;
    if(max_n % 2 == 0) {
        ll peek = max_n / 2;
        REP(i, N) {
            if( abs(peek - cand) > abs(peek - A[i]) ) {
                cand = A[i];
            }
        }
    } else {
        ll peek = max_n / 2;
        REP(i, N) {
            if(A[i] == peek || A[i] == peek + 1) {
                cand = A[i];
                break;
            }
            if( abs(peek - cand) > abs(peek - A[i]) ||
                abs(peek + 1 - cand) > abs(peek + 1 - A[i])) {
                cand = A[i];
            }
        }
    }
    printf("%lld %lld\n", max_n, cand);
    return 0;
}


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

using namespace std;

int a[123];

int main() {
  int n;
  scanf("%d", &n);
  n += n;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  reverse(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i += 2) {
    if (i + 1 < n) {
      ans += a[i + 1];
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
($x, $y) = glob <>;

if ($x == 0) {
    print abs($y)+($y<0);
} elsif ($y == 0) {
    print abs($x)+($x>0);
} elsif ($x * $y < 0) {
    print abs(abs($x) - abs($y))+1;
} elsif ($x < $y) {
    print $y-$x;
} else {
    print abs(abs($y)-abs($x))+2;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;
        vector<pair<double,string>> ord(n);
        REP(i, n) {
            string l; cin >> l;
            int p, a, b, c, d, e, f, s, m;
            cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
            double totalTime = a + b + c + (d + e) * m;
            double totalIncome = f * s * m - p;
            ord[i] = { -totalIncome / totalTime, l };

        }
        sort(ALL(ord));
        for (auto &tp : ord) {
            cout << tp.second << endl;
        }
        cout << "#" << endl;
   }

    return 0;
}



Measured memory_bytes: 3148
n=int(input())
a=[list(map(int,input().split()))for i in range(n)]
p=0
for i in range(n):
    for j in range(n):
        if i!=j:
            p+=((a[i][0]-a[j][0])**2+(a[i][1]-a[j][1])**2)**0.5
print(p/n)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int n,a[200010],wz[200010];
int read(){
	int x = 0,c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)){
		x = (x << 1) + (x << 3) + (c ^ '0');
		c = getchar();
	}
	return x; 
}
int p1[200010],p2[200010];
int main(){
	int i,j;
	n = read();
	for(i = 1;i <= n;++i){
		a[i] = read();
		wz[a[i]] = i;
	} 
	int ans = n - 1,nw = 1;
	for(i = 2;i <= n;++i){
		if(wz[i] > wz[i - 1]){
			++nw;
			ans = min(ans,n - nw);
		}
		else nw = 1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n;
  cin >> n;
  if (n < 10) {
    cout << n << endl;
    return 0;
  }

  map<pair<int, int>, int> mp;

  for (int x = 1; x <= 9; x++) {
    for (int y = 1; y <= 9; y++) {
      for (int i = 1; i <= n; i++) {
        int xx;
        if (i >= 100000) xx = i / 100000;
        else if (i >= 10000) xx = i / 10000;
        else if (i >= 1000) xx = i / 1000;
        else if (i >= 100) xx = i / 100;
        else if (i >= 10) xx = i / 10;
        else xx = i;
        int yy = i % 10;
        if (yy == y && xx == x) {
          mp[{x, y}]++;
        }
      }
    }
  }

  int ans = 0;
  for (int x = 1; x <= 9; x++) {
    for (int y = 1; y <= 9; y++) {
      ans += mp[{x, y}] * mp[{y, x}];
    }
  }

  cout << ans << endl;

  return 0;
}


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


int main(){
    double N,K;
    cin >> N >> K;
    double ans = 0.0,tmp,prb;

    for(int i=1;i<N+1;++i){
        if(i>=K) ++ans;
        else{
            tmp = i;
            prb = 1.0;
            while(tmp<K){
                prb /= 2;
                tmp *= 2;
            }
            ans += prb;
        }
    }    
    ans *= 1/N;
    cout << setprecision(10) << ans << endl;
    }

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

using namespace std;

#define MAX_N 16


int N;//データセットの数
int P;//マタタビの数
int map[16][16]; //経路の配列
int mata[16][16]; //マタタビの配列
int X,Y;//町の大きさ

int T(int x, int y){
	
	if(x == 0 && y == 0){return 1;}
	if(x < 0 || x > X){return 0;}
	if(y < 0 || y > Y){return 0;}
	if(mata[x][y] == -1){return map[x-1][y];}
	if(mata[x][y] == -2){return map[x][y-1];}
	if(mata[x][y] == -3){return 0;}
	
	return map[x-1][y] + map[x][y-1];
}

int main()
{

	cin >> N;
	for(int i=0; i<N; ++i)
	{
		cin >> X >> Y;
		//初期化
		for(int x=0; x<MAX_N; ++x){
			for(int y=0; y<MAX_N; ++y){
				map[x][y] = 0;
				mata[x][y] = 0;
				if(x == 0){mata[x][y] += -2;}
				if(y == 0){mata[x][y] += -1;}
			}
		}
		
		cin >> P;
		for(int i=0; i<P; ++i)
		{
			int x1,x2,y1,y2;
			cin >> x1 >> y1 >> x2 >> y2;
			if(x1 == x2){mata[x1][max(y1,y2)] += -1;}
			if(y1 == y2){mata[max(x1,x2)][y1] += -2;}
		}
		
		map[0][0] = 1;
		for(int y=0; y<=Y; ++y)
		{
			for(int x=0; x<=X; ++x)
			{
				map[x][y] = T(x,y);
			}
		}
		
		if(map[X][Y] == 0){
			cout << "Miserable Hokusai!" << endl;
		}else{
			cout << map[X][Y] << endl;
		}
	}
}

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

using namespace std;
long long int L;
int N;
long long int X[200005];

long long int SL[200005], SR[200005];

int main(void) {

	cin >> L >> N;

	for (int i = 1; i <= N; i++) {
		cin >> X[i];
	}
	

	for (int i = 1; i <= N; i++) {
		SL[i] = SL[i - 1] + X[i];
	}

	for (int i = N; i >= 1; i--) {
		SR[i] = SR[i+1]+L - X[i];
	}
	
	long long int ans = 0;

	for (int k = 1; k <= N; k++) {
		long long int tmp;
		int m;
		
		//=== R R=====
		m = min(k - 1, N - k);
		tmp = (SR[k + 1] - SR[k + 1 + m]) * 2 + (SL[k - 1] - SL[k - 1 - m]) * 2 + L - X[k];
		ans = max(ans, tmp);
		//cout << "k= " << k << "  "<< (SR[k + 1] - SR[k + 1 + m]) * 2<<"  "<< (SL[k - 1] - SL[k - 1 - m]) * 2 <<  "tmp= " << tmp << endl;

		//==== L L =======//
		m = min(k - 1, N - k);
		tmp = (SL[k - 1] - SL[k - 1 - m]) * 2 + (SR[k + 1] - SR[k + 1 + m]) * 2 + X[k];
		ans = max(ans, tmp);
		//cout << "k= " << k << "  "<< (SL[k - 1] - SL[k - 1 - m]) * 2<<" " << (SR[k + 1] - SR[k + 1 + m]) * 2<< "  tmp= " << tmp << endl;

		//=== R L =====//
		m = min(k, N - k);
		tmp = (SR[k + 1] - SR[k + 1 + m]) * 2 + (SL[k - 1] - SL[k - 1 - m + 1]) * 2 + X[k];
		ans = max(ans, tmp);
		//cout << "k= " << k << "  " << (SR[k + 1] - SR[k + 1 + m]) * 2 << " " << (SL[k - 1] - SL[k - 1 - m + 1]) * 2 << "  tmp= " << tmp << endl;

		//==== L R ======//
		m = min(N - k + 1, k - 1);
		tmp = (SL[k - 1] - SL[k - 1 - m]) * 2 + (SR[k + 1] - SR[k + 1 + m - 1]) * 2 + L - X[k];
		ans = max(ans, tmp);
		//cout << "k= " << k << "  " << (SL[k - 1] - SL[k - 1 - m]) * 2 << " " << (SR[k + 1] - SR[k + 1 + m]) * 2 << "  tmp= " << tmp << endl;
			
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 4992
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("sse,sse2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

template<class T>
using ordered_set = tree <T, null_type ,  less<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

template<class T>
using ordered_multiset = tree <T, null_type ,  less_equal<T> ,  rb_tree_tag ,  tree_order_statistics_node_update>;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using vi = vector<int>;
using ii = pair<int, int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vvii = vector<vii>;

#define all(x) x.begin(), x.end()
#define all_r(x) x.rbegin(), x.rend()
#define pb push_back
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, n) for(int i = n; i >= 0; --i)
#define f first
#define s second

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s, t;
	int k = 0;
	cin >> s >> t;
	FOR(i, (int)s.size()) {
		if(s[i] != t[i]) ++k;
	}
	cout << k << '\n';
 	return 0;
}

Measured memory_bytes: 3836
/* ANTHOR KUMAR DAS
KUET ECE 2K18*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define sc(a) scanf("%d",&a)
#define sc1(n) scanf("%lld",&n)
#define sc2(b,c) scanf("%lld%lld",&b,&c)
#define f(a,b) for(a=0;a<b;a++)
#define pb(a) push_back(a)
#define br break
int main()
{
    double a,b,c=2.0,n;

    cin>>n;
    a=n/c ;
    if(fmod(n,c)==0.0)
    {
        b=a/n;
        printf("%.10lf\n",b);
    }
    else{
        b=(a+0.50)/n;
        printf("%.10lf\n",b);
    }


    return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

bool is_prime(int n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	int p = (int)sqrt(n);
	for (int i = 3; i <= p; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	vector<int> p;
	for (int i = 1; i < 1000000; i++)
	{
		if (is_prime(i))
		{
			p.push_back(i);
		}
	}

	int n;
	for (; cin >> n;)
	{
		int i;
		for (i = 0; i < p.size(); i++)
		{
			if (p.at(i) > n)
			{
				break;
			}
		}

		cout << i << endl;
	}
}


Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
#define size(v)  (int) v.size()
#define fast ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
ll power_mod(ll a,ll x){if(x==0) return 1;ll y=power_mod(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power_mod(a,mod-2);}    
ll power(ll a, ll x){ if(x==0) return 1; ll y= power(a,x/2); ll ans=(y*y); if(x%2) ans*=a; return ans;}
vector<int> pos(6),c(6);
bool check(int curr,int m){
  string s;
  if(curr==0){
    s.pb('0');
  }
  while(curr>0){
      s.pb((curr%10)+'0');
      curr/=10;
  }
  int n = size(s);
  reverse(all(s));
  bool flag = true;
  for(int i=0;i<m;i++){
     if(pos[i]-1>=n){
        flag = false;
        break;
     }
     if((s[pos[i]-1]-'0')!=c[i]){
         flag = false;
         break;
     }
  }


  return flag;
}


int main(){

  int n,m;
  cin>>n>>m;

  for(int i=0;i<m;i++){
     cin>>pos[i]>>c[i];
  }

  int mn = power(10,n-1);
  int mx = power(10,n)-1;
  if(n==1) mn--;
  for(int i=mn;i<=mx;i++){
     if(check(i,m)){
       cout<<i<<endl;
       return 0;
     }
     
  }
  
  cout<<-1<<endl;
  return 0;

}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Collections;
using System.IO;
using System.Linq;
using System.Text;
using System;

class Prog
{
    public static void Main(string[] args)
    {
        new Prog().Solve();
    }

    void Solve(){
        int a = int.Parse(Console.ReadLine());
        Console.WriteLine(Math.Pow(a, 1) + Math.Pow(a, 2) + Math.Pow(a, 3));
        Console.ReadKey();
    }
}

public struct Vector2
{
    public Vector2(double x, double y)
    {
        this.@this = new double[] { x, y };
    }


    public double[] @this;

    public double x
    {
        get
        {
            return @this[0];
        }
        set
        {
            @this[0] = value;
        }
    }

    public double y
    {
        get
        {
            return @this[1];
        }
        set
        {
            @this[1] = value;
        }
    }

    public double magnitude { get { return Math.Pow(sqrMagnitude, 1 / 2); } }

    public double sqrMagnitude { get { return Math.Pow(x, 2) + Math.Pow(y, 2); } }

    public Vector2 normalized { get { return this * (1 / this.magnitude); } }

    public static Vector2 operator +(Vector2 a, Vector2 b)
    {
        return new Vector2(a.x + b.x, a.y + b.y);
    }

    public static Vector2 operator -(Vector2 a, Vector2 b)
    {
        return new Vector2(a.x - b.x, a.y - b.y);
    }

    public static Vector2 operator *(Vector2 a, double b)
    {
        return new Vector2(a.x * b, a.y * b);
    }


    public static Vector2 operator /(Vector2 a, double b)
    {
        if (b == 0)
        {
            throw new DivideByZeroException();
        }
        else return new Vector2(a.x / b, a.y / b);
    }

    public bool Equals(Vector2 other)
    {
        return (@this[0] == other.@this[0] && @this[1] == other.@this[1]);
    }

}

Measured memory_bytes: 19104
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdint>
using namespace std;

const int N_MAX = 3000;

int culc_gcd(int a, int b) {
    int u, v, r;

    if(a < b) {
        u = b;
        v = a;
    }
    else {
        u = a;
        v = b;
    }

    do {
        r = u % v;
        u = v;
        v = r;
    } while(r != 0);
    
    return u;
}

int main() {
    int N;
    int a[N_MAX];

    cin >> N;
    // unsigned long long lcm;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        ans += a[i] - 1;
        // lcm = (i == 0) ? a[i] : (lcm * a[i]) / culc_gcd(lcm, a[i]);
    }

    // for(int i = 0; i < N; i++) {
    //     ans += (lcm - 1) % a[i];
    // }

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


Measured memory_bytes: 256
import copy

n = int(input())
lst = ['a']
alphabet = 'abcdefghij'

for i in range(n - 1):
  new_list = []
  for word in lst:
    ch = ''
    for k in alphabet:
      ch = k
      if k in word:
        new_list.append(word + k)
      else:
        break
    new_list.append(word + k)
  lst = copy.copy(new_list)

for word in lst:
  print(word)

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

int main(){
	int n;
	cin >> n;
	int b[240], f[240], r[240], v[240], A[4][3][10] = {0};
	for(int i = 0; i < n; i++){
		cin >> b[i] >> f[i] >> r[i] >> v[i];
		A[b[i]-1][f[i]-1][r[i]-1] += v[i];
		if(A[b[i]-1][f[i]-1][r[i]-1] < 0) A[b[i]-1][f[i]-1][r[i]-1] = 0;
		if(A[b[i]-1][f[i]-1][r[i]-1] > 9) A[b[i]-1][f[i]-1][r[i]-1] = 9;
	}
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 10; k++) cout << ' ' << A[i][j][k];
			cout << endl;
		}
		if(i < 3){
			for(int j = 0; j < 20; j++) cout << '#';
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,k=map(int,input().split());print((n//k)**3+[((n-k//2)//k+1)**3,0][k%2])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 3280
x = int(input())
if x < 600:
    print(8)
elif x < 800:
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9172
#include <iostream>
#include <string>

using namespace std;

int main() {
    int N, K;
    string S;
    cin >> N;
    cin >> S;
    cin >> K;

    for(int i = 0; i < S.length(); i++) {
        if(S[i] != S[K-1]) {
            S[i] = '*';
        }
    }
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
t=sum(l)
x=[0]*(10**5+1)
for i in range(n):
    x[l[i]-1]+=1
r=int(input())
for i in range(r):
    a,b=map(int,input().split())
    if(x[a-1]>0):
       x[b-1]+=x[a-1]
       print(t+b*x[a-1]-a*x[a-1])
       t=t+b*x[a-1]-a*x[a-1]
       x[a-1]=0
    else:
        print(t)

Measured memory_bytes: 20744
#include<iostream>
    #include<bits/stdc++.h>
    using namespace std;
    #define size 200000
    #define NUM 998244353
    #define ll long long int
     
    int main()
    {
      int n;
      cin>>n;
      ll arr[n+1];
       for(int i=0;i<n+1;i++)
         arr[i]=0;
      ll arr2[n];
      for(int i=0;i<n;i++)
      {
        cin>>arr2[i];
        arr[arr2[i]]++;
      }
      ll ans=0;
      for(int i=1;i<n+1;i++)
      {
        ans+=(arr[i]*(arr[i]-1))/2;
      }
      for(int i=0;i<n;i++)
      {
    	ll ans1=ans;
        ans1=ans1-(arr[arr2[i]]*(arr[arr2[i]]-1))/2;
        ans1+=((arr[arr2[i]]-1)*(arr[arr2[i]]-2))/2;
        cout<<ans1<<endl;
      }
    }

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

int main(void){
	const char *classes[] = {"AAA","AA","A","B","C","D","E"};
	const double class500M[] = {35.5,37.5,40,43,50,55,70};
	const double class1000M[] = {71,77,83,89,105,116,148};

	while( true ){
		bool bNA = true;
		double c500, c1000;
		
		cin >> c500 >> c1000;
		
		if(cin.eof()) break;

		for(int i = 0; i < sizeof(class500M)/sizeof(*class500M); ++i){
			if( c500 < class500M[i] && c1000 < class1000M[i] ){
				cout << classes[i] << '\n';
				bNA = false;
				break;
			}
		}
		if( bNA )
			cout << "NA\n";
	}
	return 0;
}

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

void Sieve(vector<bool> &IsPrime,ll n){
    rep(i,n+1) IsPrime[i]=1;
    IsPrime[0]=IsPrime[1]=0;
    for(ll i=2;i*i<=n;i++){
        if(IsPrime[i]){
            for(ll j=i;i*j<=n;j++){
                IsPrime[i*j]=0;
            }
        }
    }
}

int main(){
    ll n,rn=0;
    cin>>n;
    for(ll i=1;i*i<=n;i++) rn=i;
    vector<bool> isp(rn+1);
    Sieve(isp,rn);
    ll ans=0;
    for(ll i=1;i<=rn;i++){
        if(isp[i]){
            for(ll j=1;;j++){
                if(n%(ll)pow(i,j)==0){
                    n/=(ll)pow(i,j);
                    ans++;
                }
                else break;
            }
        }
    }
    if(n>rn) ans++;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4072
n = int(input())
h = list(map(int, input().split()))
last = 0
cnt_lis = []
for i in range(n):
    if h[i] <= last:
        cnt_lis.append(cnt_lis[i - 1] + 1)
    else:
        cnt_lis.append(0)
    last = h[i]
print(max(cnt_lis))

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

struct point {
	double x, y;
};

void koch(int d,point p1, point p2) {
	if (d == 0) {
		return;
	}
	point s, t, u;
	s.x = (2 * p1.x + p2.x) / 3;
	s.y = (2 * p1.y + p2.y) / 3;
	t.x = (p1.x + 2 * p2.x) / 3;
	t.y = (p1.y + 2 * p2.y) / 3;
	u.x = (t.x - s.x) / 2 - sqrt(3) / 2 * (t.y - s.y) + s.x;
	u.y = sqrt(3) / 2 * (t.x - s.x) + (t.y - s.y) / 2 + s.y ;
	koch(d - 1, p1, s);
	printf("%.8f %.8f\n", s.x, s.y);
	koch(d - 1, s, u);
	printf("%.8f %.8f\n", u.x, u.y);
	koch(d - 1, u, t);
	printf("%.8f %.8f\n", t.x, t.y);
	koch(d - 1, t, p2);
}

int main() {
	int n;
	cin >> n;
	point a, b;
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	printf("%.8f %.8f\n", a.x, a.y);
	koch(n, a, b);
	printf("%.8f %.8f\n", b.x, b.y);

	return 0;
}


Measured memory_bytes: 3144
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    string str1,str2;
    int S1{};
    int S2{};
    while(cin>>str1>>str2){
    
    if(str1==str2)S1++;
    if(str1==str2)S2++;
    if(str1>str2)S1+=3;
    if(str1<str2)S2+=3;
    
    string str1,str2;
    }
    cout<<S1<<" "<<S2<<endl;
    return 0;
}



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


int main(){
    int K;
    int X;
    cin >> K >> X;
    if ( K * 500 >= X){
        cout << "Yes" <<endl;
        return 0;
    }
    else{
        cout << "No" << 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 ll long long
int main(){
  string s;
  cin >> s;
  int l=s.size();
  string ans;
  rep(i,l){
    if(ans.size()>=1 && s.at(i)=='B'){
      ans=ans.erase(ans.size()-1,1);
    }else if(s.at(i)!='B'){
      ans+=s.at(i);
    }
  }
  cout << ans;
}
    

Measured memory_bytes: 3600
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(H: int, W: int, S: "List[str]"):
    d = [[0] * W for _ in range(H)]
    for y in range(H):
        x = 0
        while x < W:
            while x < W and S[y][x] == "#":
                x += 1
            xstt = x
            while x < W and S[y][x] == ".":
                x += 1
            xend = x
            for x2 in range(xstt, xend):
                d[y][x2] += xend - xstt
    for x in range(W):
        y = 0
        while y < H:
            while y < H and S[y][x] == "#":
                y += 1
            ystt = y
            while y < H and S[y][x] == ".":
                y += 1
            yend = y
            for y2 in range(ystt, yend):
                d[y2][x] += yend - ystt

    print(max(max(r) for r in d) - 1)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(H)]  # type: "List[str]"
    solve(H, W, S)


if __name__ == '__main__':
    main()


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

int main() {

  int n;
  cin >> n;

  vector<int> p(n);

  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  int answer = 0;

  for (int i = 1; i < n-1; i++) {
    if (p[i] < p[i + 1] && p[i - 1] < p[i]) {
      answer++; 
    } else if (p[i] < p[i - 1] && p[i + 1] < p[i]){
      answer++;
    }
  }

  cout << answer << endl;
  
}

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

#define ll   long long int
#define ull   unsigned long long int
#define PI 3.14159265358979
#define zig ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

const ll N=1e18;

int main()
{
    zig
    ull a, ans;
    double b;
    cin>>a>>b;
    ans=a*(long)round(b*100);
    cout<<ans/100;
    return 0;
}


Measured memory_bytes: 3756
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define pb push_back
#define mp make_pair
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    bool ok = false;
    ll res;
    rep(i,n+1){
        ld temp = i*1.08;
        if(floor(temp) == n){
            res = i;
            ok = true;
            break;
        }
    }
    if(ok)cout << res << endl;
    else cout << ":(" << endl;
}

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

int main(){
	int h,w,n;
	cin >> h>>w>>n;
	int a;
	int c[100][100] = {};
	int x=0,y=0;	//initializeはこれしかないみたい
	for (int k=1;k<=n;k++) {
	cin >> a;
	for (int i=0;i<a;i++) {
	c[x][y] = k;
	if (x%2==0 && y!=(w-1)) {
	y++;
	}
	else if (x%2==0 && y==(w-1)) {
	x++;
	}
	else if (y==0) {
	x++;
	}
	else {
	y--;
	} 
	}
	}

	for (int i=0;i<h;i++) {
	for (int j=0;j<w;j++) {
	if (j) cout << " ";
	cout << c[i][j];
	}
	cout << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

int euler_phi(int n) {
  int ret = n;

  for(int i=2; i*i<=n; i++) {
    if(n % i == 0) {
      ret -= ret/i;
      while(n % i == 0)	n /= i;
    }
  }
  if(n > 1) ret -= ret/n;
  
  return ret;
}

int main() {
  int n;
  cin >> n;
  
  cout << euler_phi(n) << endl;
  
  return 0;
}

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

int P[10010];
void init(int N){
 for(int i=0; i<=N; i++){
  P[i] = i;
 }
}

int root(int a){
 if(P[a]==a)return a;
 return (P[a] = root(P[a]));
}
bool is_same_set(int a, int b){
 return root(a) == root(b);
}
void unite(int a, int b){
 P[root(a)] = root(b);
}

int main(){
 int n, q, com, x, y;
 cin >> n >> q;
 init(n);
 for(int i=0; i<q; i++){
  cin >> com >> x >> y;
  if(com==0){
   unite(x,y);
  }
  else{
   cout << is_same_set(x,y) << endl;
  }
 }
}

Measured memory_bytes: 1320
#include <stdio.h>
int main(){
    int X,A;
    
    scanf("%d%d",&X,&A);
    if (X>=0 && X<=9 && A>=0 && A<=9){
    

    if (X<A) {
        
        printf("0\n");
       
    }
    
    else
        printf("10\n");
        
        }
    
    
    return 0;
}


Measured memory_bytes: 1640
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        int n = Integer.parseInt(a+b);
        if(Math.sqrt(n) - (int)Math.sqrt(n) == 0) System.out.println("Yes");
        else System.out.println("No");
    }  
}

Measured memory_bytes: 23124
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))

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

	int now = 1;
	int res = 0;
	while (now < B) {
		res++;
		now += A - 1;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val K = sc.next().toInt()
        val A = sc.next().toInt()
        val B = sc.next().toInt()
        for (i in A..B) {
            if (i % K == 0) {
                pw.println("OK")
                return
            }
        }
        pw.println("NG")
    }
}


Measured memory_bytes: 34232
#include<iostream>
using namespace std;
int main()
{
	int w,h,x,y,r;
	cin>>w>>h>>x>>y>>r;
	if(x-r>=0&&y-r>=0&&x+r<=w&&y+r<=h)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3104
from sys import stdin


def main():
    n = int(stdin.readline())
    a = list(map(int, stdin.readline().split()))

    a2 = [[a[i], i] for i in range(n)]
    a2.sort(reverse=True)

    dp = [[0 for _ in range(n + 1)] for _ in range(n + 1)]

    ans = 0

    for i in range(n + 1):
        for j in range(n + 1 - i):
            s1 = s2 = 0
            if i > 0:
                s1 = dp[i - 1][j] + a2[i + j - 1][0] * (a2[i + j - 1][1] - (i - 1))
            if j > 0:
                s2 = dp[i][j - 1] + a2[i + j - 1][0] * ((n - j) - a2[i + j - 1][1])
            dp[i][j] = max(s1, s2)
        ans = max(ans, dp[i][n - i])

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 101432
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int nam = sc.nextInt();
      	int yen = sc.nextInt();
      
      int r10000 = -1; int r5000 = -1; int r1000 = -1;
      		
 		for(int a = 0;a <= nam ;a++){
          	for(int b = 0;a+b <= nam ; b++){
              int	c = nam-a-b;
              	int sum = a*10000 + b*5000 + c*1000;
              	if(sum == yen){
                	r10000 = a;
                  	r5000  = b;
                  	r1000  = c;
                  System.out.print(r10000 +" "+r5000+" "+r1000);
                  System.exit(0); 
                }
            }
        }
      System.out.print(r10000 +" "+r5000+" "+r1000);
    }
}

Measured memory_bytes: 21844
dp = 21.times.map{ 11.times.map{ [0] * 156 } }

cnt = 1
(1..20).each do |n|
  (1..cnt).each do |j|
    (1..155).each do |k|
      dp[n][j][k] += dp[n - 1][j][k]
    end
  end
  cnt.downto(2).each do |j|
    (1..155).each do |k|
      dp[n][j][n + k] += dp[n][j - 1][k] if n + k <= 155
    end
  end
  dp[n][1][n] = 1
  cnt += 1 if cnt < 10
end
 
loop do
  n, k, s = gets.split.map(&:to_i)
  break if n == 0
  p dp[n][k][s]
end

Measured memory_bytes: 8844
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  int N;
  vector<vector<int> > A(3, vector<int>(3));
  vector<vector<bool> > BINGO(3, vector<bool>(3));
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) {
      cin >> A[i][j];
      BINGO[i][j] = false;
    }

  cin >> N;
  for (int i = 0; i < N; i++) {
    int input;
    cin >> input;

    for (int j = 0; j < 3; j++)
      for (int k = 0; k < 3; k++) {
        if (A[j][k] == input) {
          BINGO[j][k] = true;
          break;
        }
      }
  }

  for (int i = 0; i < 3; i++)
    if (BINGO[i][0] && BINGO[i][1] && BINGO[i][2]) {
      cout << "Yes" << endl; return 0;
    }

  for (int j = 0; j < 3; j++)
    if (BINGO[0][j] && BINGO[1][j] && BINGO[2][j]) {
      cout << "Yes" << endl; return 0;
    }

  if ((BINGO[0][0] && BINGO[1][1] && BINGO[2][2]) || 
      (BINGO[0][2] && BINGO[1][1] && BINGO[2][0])) {
        cout << "Yes" << endl; return 0;
      }

  cout << "No" << endl;

  return 0;
}

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


int main() {
    int n; cin >> n;
    map<string, int> cnt;
    rep(i, n) {
        string s; cin >> s;
        cnt[s]++;
    }

    cout << cnt.size() << endl;
}


Measured memory_bytes: 19120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
const ll INF=1LL<<60;
const ll MOD=1000000007;



int main(){
    string s;
    cin >> s;
    string t;
    cin >> t;
    ll u=s.size();
    ll v=t.size();
    map<char,vl> M;
    for(ll i=0;i<u;i++){
        M[s[i]].emplace_back(i);
    ;}
    ll round=0;
    ll mark=-1;
    for(ll i=0;i<v;i++){
        char T=t[i];
        if(M[T].empty()){cout<<-1<<endl;return 0;}
        else if(upper_bound(M[T].begin(), M[T].end(), mark)!=M[T].end())
            mark=*upper_bound(M[T].begin(), M[T].end(), mark);
        else {
            round++;
            mark=M[T][0];
        }
    ;}
    cout<<round*u+mark+1LL<<endl;
    return 0;
}


Measured memory_bytes: 1728