akhauriyash/Code-Regression huggingface dataset:
class Node{
  constructor(id, parent, children) {
    this.id = id;
    this.parent = parent;
    this.children = children;
  }

  get type() {
    if (this.parent === null) return 'root';
    if (this.children.length === 0) return 'leaf';
    return 'internal node';
  }

  get depth() {
    const getDepth = (node, i) => {
      return node.parent === null ? i : getDepth(node.parent, i + 1);
    };
    return getDepth(this, 0);
  }

  toString() {
    return `node ${this.id}: parent = ${this.parent !== null ? this.parent.id : -1}, depth = ${this.depth}, ${this.type}, [${this.children.map(n => n.id).join(', ')}]`;
  }
};

class Tree {
  constructor(n) {
    this.nodes = [];
  }

  add(id, childrenIds) {
    let node = this.find(id);
    childrenIds.forEach((cid) => {
      let c = this.find(cid);
      c.parent = node;
      c.id = cid;
      node.children.push(c);
    })
  }

  find(id) { return this.nodes[id] || (this.nodes[id] = new Node(id, null, []));}

  print() { console.log(this.nodes.sort((a, b) => a.id - b.id).map(n => n.toString()).join('\n')); }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());
  let tree = new Tree(n);
  let id, k, childrenIds;
  lines.map(l => l.split(' ').map(Number)).forEach(function(line) {
    [id, k, ...childrenIds] = line;
    tree.add(id, childrenIds);
  });
  tree.print();
})();



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

const int mod = 1e9 + 7;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> mp(h);
	for (int i = 0; i < h; i++) {
		cin >> mp[i];
	}
	
	vector<vector<int>> dp(h, vector<int>(w));
	dp[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (mp[i][j] == '#') continue;
			if (i-1 >= 0 && mp[i-1][j] != '#') dp[i][j] += dp[i-1][j];
			if (dp[i][j] >= mod) dp[i][j] -= mod;
			if (j-1 >= 0 && mp[i][j-1] != '#') dp[i][j] += dp[i][j-1];
			if (dp[i][j] >= mod) dp[i][j] -= mod;
		}
	}
	cout << dp[h-1][w-1] << endl;
}

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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

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

	ll a, b, c;
	cin >> a >> b >> c;

	cout << b + min(a + b + 1, c) << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
            WriteLine((tmp[0] - 1) * (tmp[1] - 1));
        }
    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <utility>
#include <vector>
#include <cmath>

using namespace std;

/*
 * cross product
 */

const double EPS = 1e-8;

typedef pair<double, double> pt;
#define x first
#define y second

pt operator-(pt a, pt b) {
  return pt(a.x - b.x, a.y - b.y);
}

bool zero(double x) {
  return fabs(x) <= EPS;
}

double cross(pt a, pt b) {
  return a.x*b.y - a.y*b.x;
}

double dot(pt a, pt b){
    return b.x*a.x + b.y*a.y;
}

bool ccw(pt a, pt b, pt c) {
  return cross(b - a, c - a) >= 0;
}

/*
 * segment segment intersection
 */

typedef pair<pt, pt> seg;
#define a first
#define b second

bool collinear(seg a, seg b) { // all four points collinear
    cout << a.a.x << " " << a.a.y << endl;
    cout << a.b.x << " " << a.b.y << endl;
    
    cout << b.a.x << " " << b.a.y << endl;
    cout << b.b.x << " " << a.b.y << endl;

    return zero(cross(a.b - a.a, b.a - a.a)) &&
           zero(cross(a.b - a.a, b.b - a.a));
}

double sq(double a) { return a * a; }

double dist(pt p, pt q) {
  return sqrt(sq(p.x - q.x) + sq(p.y - q.y));
}

int intersect(seg a, seg b) {
    if (ccw(a.a, a.b, b.a) != ccw(a.a, a.b, b.b) &&
        ccw(b.a, b.b, a.a) != ccw(b.a, b.b, a.b)) return 1;

    return 0;
 }

int inPolygon(vector<pt> polygon, pt from){
    int sum = 0;
    for (int j = 0; j < polygon.size(); ++j){
        int next = (j+1)%polygon.size();

        pt inf = make_pair(100001, from.y);
        seg line_inf = make_pair(from, inf);
        seg line_to = make_pair(polygon[j], polygon[next]);

        pt a = polygon[j] - from; pt b = polygon[next] - from;
        if (cross(a, b) == 0 && dot(a, b) <= 0) {
            return 1;
        }
        sum += intersect(line_inf, line_to);
    }
    if (sum % 2) return 2;
    return 0;
}

int main(){

    vector<pt> polygon;
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i){
        int x, y;
        cin >> x >> y;
        polygon.push_back(make_pair(x, y));
    }
    cin >> n;
    for (int i = 0; i < n; ++i){
        int p, q;
        cin >> p >> q;
        cout << inPolygon(polygon, make_pair(p, q)) << endl;

    }

    return 0;
}


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

int solve(int h, int w, int n)
{
    int ans = 200;

    // 横幅が広いとする
    if (w < h) {return solve(w, h, n);}

    for (int y = 1; y <= h; y++) {
        for (int x = 0; x <= w; x++) {
            int step = x + y;
            int area = y * w + x * (h - y);
            if (area >= n) {
                ans = std::min(ans, step);
            }
        }
    }

    return ans;
}

int main(int argc, char *argv[])
{
    int h, w, n;
    std::cin >> h >> w >> n;

    int ans = solve(h, w, n);

    std::cout << ans << std::endl;

    return 0;
}


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

using namespace std;

int main() {
  using ull = unsigned long long;
  ull ans[50];
  ull k;
  cin >> k;
  cout << 50 << endl;
  ull j = k / 50;
  int i = k % 50;
  for (auto &x : ans) {
    x = 49 + j;
  }
  for (int a = 0; a < i; ++a) {
    ans[a] += 51;
  }
  for (auto &x : ans) {
    x -= i;
    cout << x << " ";
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main() {
  int n,i,a[100],ire,k=0,j;
  
  scanf("%d",&n);
  if(n<1 || 100<n) exit(0);
  
  for(i=0;i<n;i++) {
    scanf("%d",&a[i]);
    if(a[i]<0 || 100<a[i]) exit(0);
  }

  for(i=n-1;i>=1;i--) {
    for(j=n-1;j>=1;j--) {
    if(a[j]<a[j-1]){
      ire=a[j-1];
    a[j-1]=a[j];
    a[j]=ire;
    k++;
    }
    }
  }

  for(i=0;i<n;i++) {
    printf("%d",a[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",k);
  return 0;
}



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

int main(){
	char in;
	int w,h,x,y,i;
	int myt[500][500],mdk;
	int obk_n;
	int obk_w[500],obk_h[500],obk_d[500];
	int max;
	
	while(1){
		cin>>w>>h;if(w==0 && h==0){break;}
		
		//-----
		for(y=0;y<h;y++){
			for(x=0;x<w;x++){
				cin>>in;
				if(in=='.'){
					if(y==0){myt[x][y]=1;}else{myt[x][y]=myt[x][y-1]+1;}
				}else{
					myt[x][y]=0;
				}
			}
		}
		//-----
		max=0;
		for(y=h-1;0<=y;y--){
			obk_n=0;
			for(x=0;x<w;x++){
				mdk=myt[x][y];
				for(i=obk_n-1;0<=i;i--){
					if(mdk<obk_h[i]){
						if(max<obk_w[i]*obk_h[i]){max=obk_w[i]*obk_h[i];}
						if(mdk<=obk_d[i]){obk_n--;continue;}else{obk_h[i]=mdk;}
					}
					obk_w[i]++;
				}
				if(obk_n!=0 && obk_h[obk_n-1]<mdk){obk_w[obk_n]=1;obk_h[obk_n]=mdk;obk_d[obk_n]=obk_h[obk_n-1];obk_n++;}
				if(obk_n==0 && mdk!=0){obk_w[0]=1;obk_h[0]=mdk;obk_d[0]=0;obk_n=1;}
			}
			for(i=obk_n-1;0<=i;i--){
				if(max<obk_w[i]*obk_h[i]){max=obk_w[i]*obk_h[i];}
			}
		}
		cout<<max<<endl;
	}
	
	return 0;
}

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



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int k;
    string s;
    cin>>k>>s;
    if(k>=s.size()) cout<<s;
    else {
        cout<<s.substr(0,k) + "...";
    }
    return 0;
}


Measured memory_bytes: 3624
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    x=LIST()
    ct=99999999999
    nmax=max(x)
    nmin=min(x)
    for i in range(nmin,nmax+1):
        temp=0
        for j in x:
            temp+=(j-i)**2
        ct=min(ct,temp)
    print(ct)
if __name__ == '__main__':
    do()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define pie 3.141592653589793
using namespace std;


int main()
{
   int a;
   string s;
   cin>>a;
   getchar();
   getline(cin,s);
   if(a>=3200)
    cout<<s<<endl;
   else
    cout<<"red"<<endl;
   return 0;
}


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

int main(){
    int n,k,d,num,ans = 0;
    cin >> n >> k;
    vector<set<int>> snuke(n);
    for(int i = 0; i < k;i++){
        cin >> d;
        for(int j = 0;j < d;j++){
            cin >> num;
            snuke[num - 1].insert(i + 1);
        }
    }
    for(int i = 0; i < n;i++){
        if(snuke[i].size() == 0)ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3968
#include <iostream>
#include <algorithm>
#include <string>
#include "bits/stdc++.h"
using namespace std;

int main() 
{
    int n, count=0;
    cin >> n;
    for(int i=1; i<n+1; i++) {
        stringstream st_i;
        st_i << i;
        if(st_i.str().length()%2 == 1) {
            count++;
        }
    }
    cout << count << endl; 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define mod 1e9+7
#define ll long long int
#define epsilon 1e-7

int compare_int(const void *a, const void *b){
	int *A = (int *)a;
	int *B = (int *)b;
    return *A - *B;
}

int main(void){
    int n;
    scanf("%d", &n);
    int a[n];
    for(int i = 0;i < n;i++)scanf("%d", &a[i]);
    qsort(a, n, sizeof(int), compare_int);
    int small = a[0];
    int big = a[n-1];
    if(big - small > 1)printf("No\n");
    else if(big - small == 0){
        if(small == n-1 || n/2 >= small)printf("Yes\n");
        else printf("No\n");
    }else{
        int count = 0;
        while(1){
            count++;
            if(a[count] != small){
                break;
            }
        }
        if(count > small || (n-count)/2 + count < big)printf("No\n");
        else printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 892
d = gets.to_i
cs = gets.split.map(&:to_i)
ss = []
d.times do
  ss << gets.split.map(&:to_i)
end
ts = []
score = 0
scored = Array.new(26, 0)
d.times do |i|
  t = gets.to_i
  score += ss[i][t-1]
  scored[t-1] = i + 1
  cs.each_with_index do |c, j|
    score -= c * (i+1 - scored[j])
  end
  puts score 
end

Measured memory_bytes: 14328
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
#define itn int
bool dbg = false;
int N;
string S;
void solve() {
    bool ans = true;
    if (N % 2 == 0) {
        int n = N / 2;
        FOR(i, 0, n) {
            if (S[i] != S[i + n])
                ans = false;
        }
    } else {
        ans = false;
    }
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N >> S;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define mt make_tuple
#define fi first
#define se second
#define endl "\n"

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

const int INF = 987654321;
const int MAX = 1000000;
ll A, B;

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

	cin >> A >> B;
	if (A + B - 1 > MAX) {
		for (int i = B - A + 1; i <= MAX; i++) cout << i << " ";
	}

	else if (B - A + 1 < -MAX) {
		for (int i = B + A - 1; i >= -MAX; i--) cout << i << " ";
	}

	else {
		for (int i = B - A + 1; i <= B + A - 1; i++) cout << i << " ";
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    ans = 0
    for i in range(1, n + 1):
        ans += i & 1
    print(ans/n)
    return

#B
def B():
    n, k = LI()
    h = LI()
    ans = 0
    for i in h:
        ans += i >= k
    print(ans)
    return

#C
def C():
    n = II()
    a = LI()
    d = defaultdict(int)
    for i in range(n):
        d[a[i] + 1] = i + 1
    for _, v in sorted(d.items()):
        print(v, end=" ")
    print()
    return

def primes(n):
    """ Input n>=6, Returns a list of primes, 2 <= p < n """
    """ 6以上の数であれば p (素数) <= n のlistを返す """
    n, correction = n-n%6+6, 2-(n%6>1)
    sieve = [True] * (n//3)
    for i in range(1,int(n**0.5)//3+1):
        if sieve[i]:
            k=3*i+1|1
            sieve[      k*k//3      ::2*k] = [False] * ((n//6-k*k//6-1)//k+1)
            sieve[k*(k-2*(i&1)+4)//3::2*k] = [False] * ((n//6-k*(k-2*(i&1)+4)//6-1)//k+1)
    return [2,3] + [3*i+1|1 for i in range(1,n//3-correction) if sieve[i]]

#D
def D():
    a, b = LI()
    da = defaultdict(int)
    db = defaultdict(int)
    for i in range(2, int(math.sqrt(a)) + 1):
        while a % i == 0:
            a = a // i
            da[i] = 1
        while b % i == 0:
            b = b // i
            db[i] = 1
    da[a] = 1
    db[b] = 1
    da[1] = 1
    db[1] = 1
    print(len(set(da.keys()) & set(db.keys())))
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()


Measured memory_bytes: 40176
main = do
    line1 <- getLine
    let (n,m) = (nums!!0, nums!!1)
                   where nums = map (\x -> read x :: Int) $ words line1
    ss <- getContents
    let ls = lines ss
    let as = map (map (\x -> read x :: Int)) $ map words $ take n ls
    let ms = map (\x -> read x :: Int) $ drop n ls
    let ans = map (calcC ms) as
    mapM_ putStrLn $ map show ans

calcC ms am = sum $ map (\(x,y) -> x*y) $ zip ms am


Measured memory_bytes: 7548
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int main(){
	vector<int> BMI;
	for(;;){
		int num;
		double m,l;
		if(scanf("%d,%lf,%lf",&num,&m,&l) == EOF){break;}
		if(m/(l*l) > 24.999999){BMI.push_back(num);}
	}
	for(int i=0; i<BMI.size(); i++){
		cout <<BMI[i]<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    string o, b;
    cin >> o >> b;
    int n = min(o.size(), b.size());
    repi(i, n, 0)
    {
        cout << o[i] << b[i];
    }
    if (o.size() - n)
    {
        cout << o[n];
    }
    else if (b.size() - n)
    {
        cout << b[n];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (void){
	int  x1=1,x2=1,count,kotae;
	for(count = 0;count<81;count++){
		if(x2 == 10){
			x2 = 1;
			x1 = x1 + 1;
		}
		kotae = x1 * x2;
		printf("%dx%d=%d\n",x1,x2,kotae);
		x2 = x2 + 1;
	}
	return(0);
}

Measured memory_bytes: 924
MOD = 10**9+7
n = int(input())
s = input()
p = input()
ans = 1
i = 0
num = 0
while i < n:
    if s[i] == p[i]:
        if num == 0: ans = 3
        if num == 1: ans *= 2
        if num == 2: ans *= 1
        num = 1
        i += 1
    else:
        if num == 0: ans = 6
        if num == 1: ans *= 2
        if num == 2: ans *= 3
        num = 2
        i += 2
    ans %= MOD
print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

int main() {
    int n, m, x; cin >> n >> m >> x;
    vi vc(n+1, 0);
    for (int i = 0; i < m; ++i) {
        int j; cin >> j;
        ++vc[j];
    }

    int l = 0, r = 0;
    for (int i = x; i <= n; ++i) r += vc[i];
    for (int i = x; i >= 0; --i) l += vc[i];

    cout << min(l, r) << endl;

    return 0;
}


Measured memory_bytes: 632
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

int N;

int main(){
	cin >> N;
	if (N % 1000 == 0){
		cout << 0 << endl;
	}
	else{
		cout << 1000 - N % 1000 << endl;
	}

	return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

void chmax(ll& a,ll b) {
    a = max(a,b);
}

int main() {
    ll const INF = 1e18;
    int n;
    cin >> n;
    vector<int> a(n);
    vector<array<ll,4>> dp(n+2,{-INF,-INF,-INF,-INF});
    dp[0][0] = 0;
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < n;++i) {
        if (i%2) {
            chmax(dp[i+1][0],dp[i][1]);
            chmax(dp[i+1][0],dp[i][0]);
            chmax(dp[i+1][2],dp[i][3]);
            chmax(dp[i+1][2],dp[i][2]);
            chmax(dp[i+1][1],dp[i][2]+a[i]);
        } else {
            chmax(dp[i+1][1],dp[i][0]+a[i]);
            chmax(dp[i+1][2],dp[i][0]);
            chmax(dp[i+1][2],dp[i][1]);
            chmax(dp[i+1][3],dp[i][2]+a[i]);
        }
    }
    // for (int i = 0;i < n+1;++i) p_ary(dp[i],0,4);
    cout << max(dp[n][(n&1)*2],dp[n][(n&1)*2+1]) << endl;
}

Measured memory_bytes: 10312
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
	int N = 0;
	int M = 0;
	int money = 0;
	int maxMoney = 0;
	char blueDeck[100][100];
	char redDeck[100][100];
	char temp[100];

	fgets(temp, sizeof(temp), stdin);
	N = atoi(temp);
	for(int i=0; i<N; i++){
		fgets(blueDeck[i], sizeof(blueDeck), stdin);
	}

	fgets(temp, sizeof(temp), stdin);
	M = atoi(temp);
	for(int i=0; i<M; i++){
		fgets(redDeck[i], sizeof(redDeck), stdin);
	}

	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			if(strcmp(blueDeck[i], blueDeck[j]) == 0){
				money++;
			}
		}
		for(int j=0; j<M; j++){
			if(strcmp(blueDeck[i], redDeck[j]) == 0){
				money--;
			}
		}
		if(maxMoney < money){
			maxMoney = money;
		}
		money = 0;
	}
	printf("%d", maxMoney);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define mod             1000000007
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
int main() {
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	int *arr = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	int sum = 0;
	for (int i = 0; i < k; i++)
		sum = sum + arr[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3600
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 
 
	public static void main(String[] args) { 
		Scanner input = new Scanner(System.in);
		int A = input.nextInt();
		int B = input.nextInt();
		int K = input.nextInt();
		if (B-A>=2*K) {
			for (int cur = A; cur < A+K; cur++) {
				System.out.println(cur);
			}
			int START = B-K+1;
			for (int cur = START; cur <= B; cur++) {
				System.out.println(cur);
			}
		}else {
			for (int cur = A; cur <= B; cur++) {
				System.out.println(cur);
			}
		}
	}	
}

Measured memory_bytes: 23764
# include<bits/stdc++.h>
# define LL long long
using namespace std;
const int MAX=2e5+5;
int n;
char s[MAX];
int main()
{
	scanf("%s",s+1),n=strlen(s+1);
	LL ans=0;
	for(int i=1,L=1;i<=n;++i)
	  if(s[n-i+1]=='B') ans+=i-L,++L;
	return printf("%lld",ans),0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] ans = new int[N];
		for(int i = 1; i <= 100; i++)
			for(int j = 1; j <= 100; j++)
				for(int k = 1; k <= 100; k++)
					if(i*i+j*j+k*k+i*j+j*k+k*i <= N)
						ans[i*i+j*j+k*k+i*j+j*k+k*i-1]++;
		for(int i = 0; i < N; i++)
			System.out.println(ans[i]);
	}

}


Measured memory_bytes: 38784
#include<bits/stdc++.h>
using namespace std;
#define int long long
int f[105000],k;
signed main(){
	int cnt=0;
	for (int i=1;i<=9;++i)
		f[++cnt]=i;
	for (int i=1;i<=9;++i)
		f[++cnt]=i*10+9;
	for (int i=1;i<=9;++i)
		f[++cnt]=i*100+99;
	int x=10;
	for (int t=1;t<=9;++t){
		x*=10;
		for (int i=10;i<=t*10+9;++i)
			f[++cnt]=(i+1)*x-1;
		int y=t+1;
		while(y<=9) f[++cnt]=(y+1)*x*10-1,y++;	
	}
	x*=10;
	for (int i=10;i<=99;++i)
		f[++cnt]=(i+1)*x-1;
	x*=10;
	for (int i=10;i<=99;++i)
		f[++cnt]=(i+1)*x-1;
	for (int t=10;t<=11;++t){
		for (int i=100;i<=t*10+9;++i)
			f[++cnt]=(i+1)*x-1;
		int y=t+1;
		while(y<=99) f[++cnt]=(y+1)*x*10-1,y++;	
		x*=10;
	}
	scanf("%lld",&k);
	for (int i=1;i<=k;++i)
		printf("%lld\n",f[i]);
}

Measured memory_bytes: 3836
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,m,Vans=0;scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int inp;scanf("%d",&inp);
		if(inp>=m) Vans++;
	}
	printf("%d\n",Vans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;


int main(){
    int k,s;
    cin >> k >>s;
    llong ans=0;

    REP(x,k+1) REP(y,k+1) if(0<=s - x - y and s-x-y <=k) ans +=1;
    cout << ans << endl;
}

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

int main() {
    int mat[4][4];
    int a[3], b[3];
    bool OK = true;
    int pos1 = -1, pos2 = -1;
    for (int i  = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            scanf("%d", &mat[i][j]);
        }
    }
    
    a[0] = 0;
    b[0] = mat[0][0] - a[0];
    b[1] = mat[0][1] - a[0];
    b[2] = mat[0][2] - a[0];
    a[1] = mat[1][0] - b[0];
    a[2] = mat[2][0] - b[0];
    /*for (int i = 0; i < 3; i++) {
        if (a[i] < 0 || b[i] < 0) {
            OK = false; 
            break;
        }
    }*/
    if (OK) {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (a[i] + b[j] != mat[i][j]) {
                    OK = false;
                    break;
                }
            }
            if (!OK) break;
        }
    }
    if (OK) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

using namespace std;

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

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

	for(int i = 1; i * 2 <= m; ++i) {
		cout << i << ' ' << m - i + 1 << '\n';
	}

	for(int i = 1; i * 2 <= m + 1; ++i) {
		cout << m + i << ' ' << m * 2 - i + 2 << '\n';
	}

	return 0;
}


Measured memory_bytes: 3636
program main
  implicit none
  
  integer :: n,i,j,a(10) = 0,t,s=0
  
  read(*,*)n
  read(*,*)(a(i), i = 1, n)
  do i=1,N-1
     do j=i+1,N
        if(a(i) .gt. a(j))then
           t=a(i)
           a(i)=a(j)
           a(j)=t
        end if
     end do
  end do
  
  do i = 1, n-1
    s = s + a(i)
  end do
  
  if (a(n) < s) then
    write(*,*)'Yes'
  else
    write(*,*)'No'
  end if
end program main

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int i=0;
for(;;){
int a=sc.nextInt();
int b=sc.nextInt();
if(a==0 && b==0)break;
if(a>b){i=a;a=b;b=i;}
System.out.println(a+" "+b);}}}

Measured memory_bytes: 35996
<?php
  $n = fgets(STDIN);
  $a = explode(' ',fgets(STDIN));
  $min = 30;
  for($i = 0; $i < $n; $i++) {
    for($j = 0; $a[$i] % 2 == 0; $j++) {
      $a[$i] /= 2;
    }
    $min = min($j, $min);
  }
  echo $min;
?>

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

using namespace std;

int main(){
  string s;
  char c;
  int64_t ans=0;
  cin >> s;
  vector<int> a(s.size()+1);
  vector<int> b(s.size()+1);
  a.front() = 0;
  b.back() = 0;

  for(int i=0;i<s.size();i++){
    if(s.at(i) == '<'){
      a.at(i+1) = a.at(i)+1;
    }
    else{
      a.at(i+1) = 0;
    }
  }

  for(int i=s.size()-1;i>=0;i--){
    if(s.at(i) == '>'){
      b.at(i) = b.at(i+1)+1;
    }
    else{
      b.at(i) = 0;
    }
  }

  for(int i=0;i<s.size()+1;i++){
    //cout << a.at(i) << "  " << b.at(i) << endl;
    ans = ans + max(a.at(i),b.at(i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4740
#include<bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
int n;
cin>>n;
vector<ll> v(n);
for(int i=0;i<n;i++){
cin>>	v[i];
}
ll ans=0;
sort(v.begin(), v.end());
for(int i=0;i<n;i++){
	for(int j=i+1;j<n;j++){
		for(int k=j+1;k<n;k++){
			if(v[i]+v[j]>v[k]&&v[i]!=v[j]&&v[j]!=v[k])
			ans++;
		}
	}
}
cout<<ans;
}

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

int main() {

    int K, A, B;
    cin >> K >> A >> B;
    
    string ans = "NG";
    for (int i = A; i <= B; i++) {
        if(i%K==0) ans = "OK";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#!usr/bin/env python3
from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

class UnionFind:
    __slots__ = ["N", "group_count", "root", "rank"]
    def __init__(self, N): self.N, self.group_count, self.root, self.rank = N, N, [-1] * N, [0] * N
    def __repr__(self): return str(self.all_groups())

    def find(self, x):
        while self.root[x] >= 0: x = self.root[x]
        return x

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return
        if self.rank[x] > self.rank[y]: x, y = y, x
        self.root[y] += self.root[x]
        self.root[x] = y
        if self.rank[x] == self.rank[y]: self.rank[y] += 1
        self.group_count -= 1

    def same(self, x, y): return self.find(x) == self.find(y)
    def count(self, x): return -self.root[self.find(x)]
    def members(self, x): return [i for i in range(self.N) if self.same(x, i)]
    def roots(self): return [i for i, x in enumerate(self.root) if x < 0]
    def all_groups(self):
        d = defaultdict(lambda: [])
        for i in range(self.N): d[self.find(i)].append(i)
        return dict(d)


def main():
    N, Q = LI()
    TUV = LIR(Q)

    uf = UnionFind(N)

    for t, u, v in TUV:
        if t == 0:
            uf.union(u, v)
        else:
            print(int(uf.same(u, v)))

if __name__ == '__main__':
    main()

Measured memory_bytes: 111252
import java.util.*;

public class Main {
  public static void main(String args[]) {
  	Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    if (a <= c) {
      if (c <= b) {
      	System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
    int a,b;
    
    scanf("%d %d", &a, &b);

    int i;
    if(a < b){
        for(i=0;i<b; i++) printf("%d",a);
    } else {
        for(i=0;i<a; i++) printf("%d",b);
    }

    return 0;
}

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

int main(){
  int n,m;
  int a[100][100], b[100];
  int sum;

  cin>>n>>m;

  for(int i=0; i<100; i++){
    for(int j=0; j<100; j++){
      a[i][j]=0;
    }
  }
  for(int i=0; i<100; i++){
    b[i]=0;
  }

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

  for(int i=0; i<n; i++){
    sum=0;
    for(int j=0; j<m; j++){
      sum=sum+a[i][j]*b[j];
    }
    cout<<sum<<endl;
  }

  return 0;
}

Measured memory_bytes: 3128
S = gets.chomp

if S[0] != 'A'
  puts 'WA'
elsif S[2..-2].count('C') != 1
  puts 'WA'
elsif S.delete('AC').chars.any? { |c| ('A'..'Z').include?(c) }
  puts 'WA'
else
  puts 'AC'
end


Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  int a[n+1]={};
  int x;

  for(int i=1;i<=n;i++){
    cin>>x;
    a[x]++;
  }

  int flag=0;
  ll ans=1;
  if(n%2==0){
    for(int i=1;i<n;i+=2){
      if(a[i]!=2){
        flag=1;
        break;
      }
      ans=ans*2%MOD;
    }
  }else{
    if(a[0]!=1) flag=1;
    for(int i=2;i<=n;i+=2){
      if(a[i]!=2){
        flag=1;
        break;
      }
      ans=ans*2%MOD;
    }
  }
  if(flag){
    cout<<0<<endl;
    return 0;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main() {
  int v[100010];
  int n;
  cin >> n;

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

  bool result = true;
  for(int i=1; i < n; i++) {
    if(v[i-1] <= v[i]-1) v[i]--;
    if(v[i] > v[i+1]) {result = false; break;}
  }

  cout << (result ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] p = new int[N];
    int[] px = new int[N];
    int count =0, ans =0;
    for (int i =0; i<N; i++) {
      p[i] = sc.nextInt();
    }
    System.arraycopy(p,0,px,0,p.length);
    Arrays.sort(px); //昇順にした配列
    for (int i =0; i<N; i++) {
      for (int j =i; j<N; j++) {
        int tmp =0; tmp = p[i]; p[i] = p[j]; p[j] = tmp;
        for (int l =0; l<N; l++) {
          if(p[l] == px[l]) count++;
        }
        if(count == N) {
          ans++;
        }
        tmp = p[j]; p[j] = p[i]; p[i] = tmp;
        count =0;
      }
    }
    if (ans != 0) {
      System.out.println("YES");
    } else {
      System.out.println("NO");
    }
  }
}

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

using namespace std;

#define ll long long

class RMQ {
	int n;
	vector<int>dat;
public:
	RMQ(int n_) {
		n = 1;
		while (n < n_)n *= 2;
		dat.resize(2 * n - 1);
		for (int i = 0; i < 2 * n - 1; i++)dat[i] = INT_MAX;
	}
	void update(int k, int a) {
		k += n - 1;
		dat[k] = a;
		while (k > 0) {
			k = (k - 1) / 2;
			dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
		}
	}
	int query(int a, int b, int k = 0, int l = 0, int r = 0) {
		if (r <= l)r = n;
		if (r <= a || b <= l)return INT_MAX;
		if (a <= l && r <= b)return dat[k];
		int vl = query(a, b, k * 2 + 1, l, (r + l) / 2);
		int vr = query(a, b, k * 2 + 2, (r + l) / 2, r);
		return min(vl, vr);
	}
};

signed main() {
	int n, m; cin >> n >> m;
	string s; cin >> s;
	RMQ dp(n + 1);
	dp.update(0, 0);
	for (int i = 1; i <= n; ++i)
		if (s[i] == '0')
			dp.update(i, dp.query(max(0, i - m), i) == INT_MAX ? INT_MAX : dp.query(max(0, i - m), i) + 1);
	//for (int i = 0; i <= n; ++i)
	//	cout << dp.query(i, i + 1) << " ";
	//cout << endl;
	if (dp.query(n, n + 1) == INT_MAX) {
		cout << -1 << endl;
	}
	else {
		vector<int> ans;
		int ptr = n;
		while (ptr) {
			int moved = dp.query(ptr, ptr + 1);
			for (int prv = max(0, ptr - m); prv < ptr; ++prv) {
				if (dp.query(prv, prv + 1) == moved - 1) {
					ans.push_back(ptr - prv);
					ptr = prv;
					break;
				}
			}
		}
		reverse(ans.begin(), ans.end());
		for (auto d : ans) cout << d << " ";
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2168
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

    ll n;
    cin>>n;
    vl as(n);
    cin>>as;

    mint acc = 0;
    mint ans = 0;
    mint d = 1;
    rep(i, n - 1) {
        d *= i + 1;
    }
    rep(i, n - 1) {
        mint m = i + 1;
        acc += d * m.inv();
        ans += acc * (as[i + 1] - as[i]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
using ll = int64_t;

ll MOD = static_cast<ll>(1e9+7);
ll ADD(ll x, ll y) { return (x+y)%MOD; }

vector<ll> DP;
ll dp(ll S) {
  if(S==0) { return 1LL; }
  if(DP[S]>=0) { return DP[S]; }
  ll ans = 0;
  for(ll x=3; x<=S; x++) {
    ans = ADD(ans, dp(S-x));
  }
  DP[S] = ans;
  return ans;
}

int main() {
  ll S;
  cin >> S;
  DP = vector<ll>(S+1, -1);
  ll ans = dp(S);
  cout << ans << endl;
}


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

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

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))
#define Rrep(i, n) for(int i = (n - 1); i >= 0; i--)
#define Itr(i, c) for(typeof(c.begin()) i = c.begin(); i != c.end(); i++)
#define pb push_back

const int inf = 999999999;
const int mod = 1000000007;

typedef struct{
	int y, x, num;
}data;

typedef struct{
	int a, b, c, d;
}answer;

int main(){
	int h, w; cin >> h >> w; int m = h * w;
	data d[m];
	int s = 0;
	Rep(i, h){
		Rep(j, w){
			int t; cin >> t;
			if(i % 2 == 0){
				s = i * w + j;
			}else{
				s = (i+1) * w - 1 - j;
			}
			d[s].y = i+1;
			d[s].x = j+1;
			d[s].num = t;
			s += 1;
		}
	}
	bool flag = true;
	vector<answer> ans;
	Rep(i, m-1){
		if(flag && d[i].num % 2 == 1){
			flag = false;
			ans.pb((answer){d[i].y, d[i].x, d[i+1].y, d[i+1].x});
			d[i].num -= 1; d[i+1].num += 1;
		}else if(!flag){
			if(d[i].num % 2 == 0){
				flag = true;
			}else{
				ans.pb((answer){d[i].y, d[i].x, d[i+1].y, d[i+1].x});
				d[i].num -= 1; d[i+1].num += 1;
			}
		}
	}
	cout << ans.size() << endl;
	Rep(i, ans.size()){
		cout << ans[i].a << " " << ans[i].b << " " << ans[i].c << " " << ans[i].d << endl;
	}
	return 0;
}

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

int main() {
    int a, b;
    string str;
    cin >> a >> b >> str;

    if (str.at(b - 1) == 'A'){
        str.at(b - 1) = 'a';
    } else if (str.at(b - 1) == 'B') {
        str.at(b - 1) = 'b';
    } else {
        str.at(b - 1) = 'c';
    }
    // str.at(0) = 'M'; // char型の'M'

    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
n,w=map(int,input().split())
weight=[]
money=[]
weight.append(0)
money.append(0)
for i in range(n):
    s,v=map(int,input().split())
    weight.append(s)
    money.append(v)
dp= [[0 for i in range(w+1)] for j in range(n+1)]
for i in range(w+1):
    dp[0][i]=0

for i in range(1,n+1):
    for j in range(1,w+1):
        if j<weight[i]:
            dp[i][j]=dp[i-1][j]
        else:
            dp[i][j]=max(dp[i-1][j-weight[i]] + money[i],dp[i-1][j])
print(dp[-1][-1])

Measured memory_bytes: 172040
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
 int a,b,c,d[6];
 cin>>a>>b>>c;
 d[1-1] = (10*a+b)+c;
 d[2-1] = (10*a+c)+b;
 d[3-1] = (10*b+a)+c;
 d[4-1] = (10*b+c)+a;
 d[5-1] = (10*c+a)+b;
 d[6-1] = (10*c+b)+a;
 int result = max({d[0],d[1],d[2],d[3],d[4],d[5]});
 cout<<result;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
vector<string> r{"dream", "dreamer", "erase", "eraser"};
/* function */
/* main */
int main(){
    string S;
    cin >> S;
    reverse(S.begin(), S.end());
    for (int i = 0; i < r.size(); i++) reverse(r[i].begin(), r[i].end());

    bool can;

    for (int i = 0;;) {
        can = false;
        for (string s : r) {
            if (i + s.size() > S.size()) continue;
            if (S.substr(i, s.size()) == s) {
                can = true;
                i += s.size();
                break;
            }
        }
        if (can == false) {
            cout << "NO" << '\n';
            return 0;
        }
        else if (i == S.size()) {
            cout << "YES" << '\n';
            return 0;
        }
    }
}

Measured memory_bytes: 512
#include <stdio.h>

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

    if (a == b) {
        printf("Draw\n");
    } else if ((a > 1 && a > b && a < 13) || a == 1) {
        printf("Alice\n");
    } else {
        printf("Bob\n");
    }

    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
    int N;
    cin >> N;

    vector<int> arr;
    int cur;
    for (int i = 0; i < N; i++) {
        cin >> cur;
        arr.push_back(cur);
    }

    sort(arr.begin(), arr.end());

    int other = 0;
    int max = arr[N - 1];
    for (int j = 0; j < N - 1; j++) {
        other += arr[j];
    }

    if (max < other) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

 char to_char(int n)
 {   if(n==0)
     return 'z';
     char res=n+96;
     return char(res);
 }

void solve()
{
    long long int n;
    cin>>n;
    string s;
    while(n>0)
    {
        char temp=to_char(n%26);
        s=temp+s;
        if(n%26==0)
        n=n/26 - 1;
        else
        n=n/26;
    }
    cout<<s<<endl;
    
}


int main()
 {  fast();
   solve();
	return 0;
}

Measured memory_bytes: 3600
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 998244353
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
ll dp[305][305*305];
ll dp2[305][305*305];
void solve()
{
    ll n;
    cin>>n;
    vl v;
    v.pb(0);
    ll sum=0;
    rep(i,n)
    {
        ll c;
        cin>>c;
        v.pb(c);
        sum+=c;
    }
    dp[0][0]=1;
    dp2[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        ll c=v[i];
        for(int j=0;j<302*302;j++)
        {
            dp[i][j]+=(dp[i-1][j]*2);
            if(j>=c)
                dp[i][j]+=dp[i-1][j-c];
            dp[i][j]%=mod;
        }
    }
    for(int i=1;i<=n;i++)
    {
        ll c=v[i];
        for(int j=0;j<302*302;j++)
        {
            dp2[i][j]+=(dp2[i-1][j]);
            if(j>=c)
                dp2[i][j]+=dp2[i-1][j-c];
            dp2[i][j]%=mod;
        }
    }
    ll anti=0;
    if(sum%2==1)
    {
        ll start=(sum+1)/2;
        for(int i=start;i<302*302;i++)
        {
            anti+=dp[n][i];
            anti%=mod;
        }
        ll total=power(3,n);
        anti*=3;
        anti%=mod;
        total+=(mod-anti);
        total%=mod;
        cout<<total<<'\n';
    }
    else
    {
        ll start=(sum)/2;
        start++;
        for(int i=start;i<302*302;i++)
        {
            anti+=dp[n][i];
            anti%=mod;
        }
        anti+=dp[n][sum/2];
        ll total=power(3,n);
        anti*=3;
        anti%=mod;
        total+=(mod-anti);
        total%=mod;
        total+=3*dp2[n][sum/2];
        total%=mod;
        cout<<total<<'\n';
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 445364
from collections import deque


def main():
    k = int(input())
    queue = deque([i for i in range(1, 10)])
    pop_time = 0
    now = 1
    while pop_time < k:
        now = queue.popleft()
        if now % 10 != 0:
            queue.append(10 * now + now % 10 - 1)
        queue.append(10 * now + now % 10)
        if now % 10 != 9:
            queue.append(10 * now + now % 10 + 1)
        pop_time += 1
    print(now)


if __name__ == '__main__':
    main()



Measured memory_bytes: 11912
import java.util.Scanner;

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

		int n = scan.nextInt();
		int r = scan.nextInt();

		if(n >= 10) {
			System.out.println(r);
		}else {
			System.out.println(r + (10 - n) * 100);
		}


	}
}

Measured memory_bytes: 23252
#include <iostream> // {{{
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <cstdio> // }}}

#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,s,n) for(int i=s; i<n; i++)

using ll = long long;

using namespace std;

const int N = 101;

int move(int x, int y, int n) {
    int d = (x<y) ? 1 : -1;
    if (x+d==0 || x+d==y || x+d==n+1) {
        if (x-d==0 || x-d==y || x-d==n+1) {
            return -1;
        } else {
            x-=d;
        }
    } else {
        x+=d;
    }

    return x;
}

int main() {
    int n,a,b;
    cin >> n >> a >> b;
    while(1){
        if((a=move(a,b,n))==-1) {
            cout << "Borys" << endl;
            return 0;
        }
        if((b=move(b,a,n))==-1) {
            cout << "Alice" << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256