akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[1000][1000];
const int INF=1e9+7;

signed main(){
  int H,W;cin>>H>>W;
  std::vector<string> s(H);
  for(int i=0;i<H;i++)cin>>s[i];
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)dp[i][j]=0;
  dp[0][0]=1;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j>0&&s[i][j]=='.')dp[i][j]+=dp[i][j-1];
      if(i>0&&s[i][j]=='.')dp[i][j]+=dp[i-1][j];
      dp[i][j]%=INF;
    }
  }
  cout<<dp[H-1][W-1]<<endl;
}


Measured memory_bytes: 9088
'use strict'

function Main(input) {
  const N = Number(input.split('\n')[0]);
  let line = input.split('\n')[1].split(' ');
  let count = 0;

  for(let i=1; i<N; i++) {
    if(line[i] === line[i-1]) {
      line[i] = 'x';
      count++;
    } else if(line[i] === line[i+1]) {
      line[i+1] = 'x'
      count++;
    }
  }

  console.log(count);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
#include <stdio.h>

#define N 101
#define M 101

int calc(int a[][M], int b[], int n, int m);

int main(){
	
	int n, m;
	int a[N][M];
	int b[M];
	int c[N];
	int i, i1, i2;
	
	scanf("%d %d", &n, &m);
	for(i1 = 0; i1 < n; i1++){
		for(i2 = 0; i2 < m; i2++){
			scanf("%d", &a[i1][i2]);
		}
	}
	
	for(i = 0; i < m; i++){
		scanf("%d", &b[i]);
	}
	
	for(i = 0; i < n; i++){
		c[i] = calc(a, b, i, m);
		printf("%d\n", c[i]);
	}
	
	return 0;
	
}

int calc(int a[][M], int b[], int n, int m){
	
	int i;
	int ret = 0;
	
	for(i = 0; i < m; i++){
		
		ret += (a[n][i] * b[i]);
		
	}
	
	return ret;
	
}

Measured memory_bytes: 636
# https://atcoder.jp/contests/abc119/tasks/abc119_c

N, A, B, C = gets.split.map(&:to_i)
ls = Array.new(N) { gets.to_i }

ans = 10000

(4**N).times do |s|
  vss = Array.new(3) { Array.new }
  N.times do |i|
    s, r = s.divmod(4)
    vss[r] << ls[i] if r < 3
  end
  next if vss.any? { |vs| vs.empty? }
  mp = [A, B, C].zip(vss).reduce(0) do |memo, (x, vs)|
    memo + (vs.size - 1) * 10 + (x - vs.reduce(&:+)).abs
  end
  ans = [ans, mp].min
end

puts ans


Measured memory_bytes: 1916
'use strict';
const main = input => {
  const num = input[0].split(' ').map(val => parseInt(val));
  const k = num[0], x = num[1];
  console.log(k*500>=x?'Yes':'No');
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

int main() {
    int n;
    cin >> n;
    int f[n][10], p[n][11];
    rep(i, n) rep(j, 10) cin >> f[i][j];
    rep(i, n) rep(j, 11) cin >> p[i][j];

    int ans = -INF;

    REP(i, 1, 1 << 10) {
        bitset<10> bs(i);
        int profit = 0;

        rep(i, n) {
            int cnt = 0;

            rep(j, 10) {
                if (bs[j] && f[i][j]) cnt++;
            }
            profit += p[i][cnt];
        }
        ans = max(ans, profit);
    }

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



Measured memory_bytes: 256
s = raw_input()
x, y = map(int, raw_input().split())

offset = 0
continuousMovement = 0
verticalMovement = []
horizontalMovement = []
flag = "start"

for letter in s:
    if letter == "F":
        continuousMovement += 1
    else:
        if flag == "vert":
            flag = "hori"
            verticalMovement.append(continuousMovement)
        elif flag == "hori":
            flag = "vert"
            horizontalMovement.append(continuousMovement)
        else:
            offset = continuousMovement
            flag = "vert"
        continuousMovement = 0
else:
    if flag == "vert":
        verticalMovement.append(continuousMovement)
    elif flag == "hori":
        horizontalMovement.append(continuousMovement)
    else:
        offset = continuousMovement

distanceX = x - offset
distanceY = y

vertMovementVariation = {0, }
for x in verticalMovement:
    newVariation = set()
    for y in vertMovementVariation:
        newVariation.add(y + x)
        newVariation.add(y - x)
    vertMovementVariation = newVariation

horiMovementVariation = {0, }
for x in horizontalMovement:
    newVariation = set()
    for y in horiMovementVariation:
        newVariation.add(y + x)
        newVariation.add(y - x)
    horiMovementVariation = newVariation

if distanceX in horiMovementVariation and distanceY in vertMovementVariation:
    print "Yes"
else:
    print "No"

Measured memory_bytes: 3464
#include <iostream>

using namespace std;

int main() {
    int n;
    int A[210];
    cin >> n;

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

    int res = 0;
    while (true) {
        bool is_odd = false;
        for (int i = 0; i < n; i++) {
            if (A[i] %2 != 0) is_odd = true;
        }
        if (is_odd) break;

        for (int i = 0; i < n; ++i) {
            A[i] /= 2;
        }

        res++;
    }
    cout << res << endl;

    return 0;
}


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

int n, A[50];

int solve(int i, int m){
    if(m == 0) return true;
    if(i >= n) return false;
    int res = solve(i+1,m) || solve(i + 1, m - A[i]);
    return res;
}

int main(){
    int q,m;
    cin >> n;
    for(int i = 0; i < n; i++) cin >> A[i];
    cin >> q;
    
    for(int i = 0; i < q; i++){
        cin >> m;
        if(solve(0,m)) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 3080
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());



int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		ll a,b,d;
		cin>>a>>b>>c>>d;
		while(a>0 && c>0)
		{
			c-=b;
			if(c<=0) {cout<<"Yes\n";return 0;}
			a-=d;
		}
		// n=s.length();
		// ll a[n];
		cout<<"No";

		
		cout<<"\n";
	}
	return 0;
}

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


string T;

string fnc(int pos, string s)
{
    for (int i = pos, j = 0; j < (int)T.length(); i++, j++) {
        if (s[i] != '?' && s[i] != T[j]) return "0";

        s[i] = T[j];
    }

    for (int i = 0; i < (int)s.length(); i++) {
        if (s[i] == '?') s[i] = 'a';
    }

    return s;
}

int main()
{
    string s;
    string ans;
    cin >> s >> T;
    for (int i = 0; i < (int)s.length(); i++) {
        string tmp = fnc(i, s);
        if (tmp != "0") {
            if (ans.empty()) ans = tmp;
            else ans = min(ans, tmp);
        }
    }

    if (ans.empty()) cout << "UNRESTORABLE\n";
    else cout << ans << "\n";
}


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

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

    vector<int> water;
    vector<int> sugar;
    for(int i=0; i<=(F / (100*A)); ++i) {
        for(int j=0; j<=(F / (100*B)); ++j) {
            int x = 100 * A * i + 100 * B * j;
            if(x <= F) water.push_back(x);
        }
    }
    for(int i=0; i<=(F / C); ++i) {
        for(int j=0; j<=(F / D); ++j) {
            int x = C * i + D * j;
            if(x <= F) sugar.push_back(x);
        }
    }

    sort(water.begin(), water.end());
    sort(sugar.begin(), sugar.end());

    int wres = 100 * A;
    int sres = 0;
    for(int i=0; i<water.size(); ++i) {
        int w = water[i];
        for(int j=0; j<sugar.size(); ++j) {
            int s = sugar[j];
            if(w + s > F || s * 100 > E * w) continue;
            if(s * (wres+sres) > sres * (w+s)) {
                wres = w;
                sres = s;
            }
        }
    }
    cout << wres + sres << ' ' << sres << endl;
}

Measured memory_bytes: 1400
import itertools
import math

n = int(input())
point = [tuple(map(int, input().split())) for i in range(n)]

numbers = 1
for i in range(1,n+1):
    numbers *= i
#nの階乗

route = list(itertools.permutations(point))

d = 0

for pattern in route:
    for i in range(n-1):
        d += math.sqrt((pattern[i][0]-pattern[i+1][0])**2 + (pattern[i][1]-pattern[i+1][1])**2)
        

ans = d / numbers

print(ans)


Measured memory_bytes: 13840
#include<iostream>
using namespace std;
int main()
{
	int n[15],temp;
	for(int i=0;i<10;i++)cin>>n[i];
	for(int i=0;i<10;i++){
		for(int j=i+1;j<10;j++){
			if(n[i]<n[j]){
				temp=n[i];n[i]=n[j];n[j]=temp;
			}
		}	
	}
	cout<<n[0]<<endl;
	cout<<n[1]<<endl;
	cout<<n[2]<<endl;
	return 0;
}

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

int main()
{
    char a[1000];
    int n;
    while(cin>>n)
    {
        scanf("%s",a);
        if(n%2)
        cout<<"No"<<endl;
        else
        {
            char x[500]={'\0'};
            char y[500]={'\0'};
            for(int i=0;i<n;i++)
                if(i>=n/2)
                y[i-(n/2)]=a[i];
                else
                x[i]=a[i];
            if(strcmp(x,y)==0)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
    }
    return 0;
}


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

main() {
  int N,X;
  cin >> N >> X;
  
  vector<int> mount(N);
  for(int i=0; i<N; i++)
    cin >> mount.at(i);
  
  int msum=0,mmin;
  
  for(int i=0; i<N; i++)
    msum+= mount[i];
  
  sort(mount.begin(),mount.end());
  mmin =mount[0];
  
  cout << N+(X-msum)/mmin << endl;
  return 0;
}  

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
#define INF 1LL<<60

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

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

int main() {
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m2 == m1+1) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
template <typename T>
inline void readin(T &x) {
	x = 0;
	T fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
	x *= fh;
}
inline void d_read(double &x) {
	x = 0.0;
	int fh = 1;
	char ch = getchar();
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ 48);
	if (ch == '.') {
		double num = 1.0;
		ch = getchar();
		for (; isdigit(ch); ch = getchar()) x = x + (num /= 10) * (ch ^ 48);
	}
	x *= fh;
}

template <typename T>
inline void wt(T x) {
	if (x > 9) wt(x / 10);
	putchar(x % 10 + 48);
}
template <typename T>
inline void writeln(T x, char c) {
	if (x < 0) {
		putchar('-');
		x = -x;
	}
	wt(x);
	putchar(c);
}
bool m[1000005];
int main() {
	int n, res = 7, cnt = 1;
	readin(n);
	res %= n;
	while(res != 0) {
		res = (res * 10 + 7) % n;
		if (m[res]) {
			puts("-1");
			return 0;
		}
		m[res] = true;
		cnt ++;
	}
	writeln(cnt, '\n');
	return 0;
}




Measured memory_bytes: 4564
import numpy as np
n,k = map(int,input().split())
arr = list(map(int,input().split()))

base = 0
mod = 10**9 + 7
mul = (k*(k+1))//2
mul2 = (k*(k-1))//2

for i in range(n):
    for j in range(i):
        if arr[i] < arr[j]:
            base += 1
    # print(base)

pot = 0
for i in range(n):
    for j in range(i+1,n):
        if arr[i] < arr[j]:
            pot += 1


# print(pot)
# print(base)

print((base*mul+pot*mul2)%mod)



Measured memory_bytes: 20896
import sys
from operator import itemgetter
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=[(int(i)+1,int(a)) for i,a in enumerate(input().split())]
    A.sort(key=itemgetter(1))
    print(" ".join(map(str,list(zip(*A))[0])))
if __name__=='__main__':
    main()

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

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

int main() {
    int R, G, B, N;

    cin >> R >> G >> B >> N;

    int enumB[3001];
    for (int i = 0; i <= 3000; i++) {
        enumB[i] = i*B;
    }

    ll cnt = 0;
    for (int r = 0; R * r <= N; r++) {
        for (int g = 0; R * r + G * g <= N; g++) {
            if (binary_search(enumB, enumB + 3001, N - R*r - G*g)) cnt++;
        }
    }

    cout << cnt;

    return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    String ans = "NO";
    a:for(int i = 0; i <= s; i++){
      for(int j = i; j <= s; j++){
        String S1 = S.substring(0, i);
        String S2 = S.substring(j, s);
        if((S1+S2).equals("keyence")){
          ans = "YES";
          break a;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 25300
import java.awt.Point;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Queue;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        final int[] dx = {1, 0, -1, 0};
        final int[] dy = {0, 1, 0, -1};

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] in = br.readLine().split(" ");
        int h = Integer.parseInt(in[0]);
        int w = Integer.parseInt(in[1]);
        
        int ans = 0;
        int[][] dist = new int[h][w];
        Queue<Point> que = new ArrayDeque<>();
        for(int i = 0; i < h; i++) {
            char[] in2 = br.readLine().toCharArray();
            for(int j = 0; j < w; j++) {
                if(in2[j] == '#') {
                    que.add(new Point(i, j));
                    dist[i][j] = 0;
                }else {
                    dist[i][j] = -1;
                }
            }
        }

        while(!que.isEmpty()) {
            Point p = que.poll();
            int d = dist[p.x][p.y];

            for(int i = 0; i < 4; i++) {
                int nx = p.x + dx[i];
                int ny = p.y + dy[i];

                if(0 <= nx && nx < h && 0 <= ny && ny < w && dist[nx][ny] == -1) {
                    ans = Math.max(ans, d + 1);
                    dist[nx][ny] = d + 1;
                    que.add(new Point(nx, ny));
                }
            }
        }

        System.out.println(ans);

        br.close();
    }
}

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

#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; ++i)
#define FORD(i, a, b) for (int i = (int)a; i >= (int)b; --i)
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define Debug(x) cerr << #x << " = " << x << '\n';
#define HERE cerr << "HERE\n\n";
#define X first
#define Y second
#define pb push_back
#define FASTER { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); }

using namespace std;

typedef pair <int, int> ii;
typedef vector <int> vi;



int main(){
    FASTER
//    freopen("x.INP", "r", stdin);
//    freopen("x.OUT", "w", stdout);
    int a, b;
    cin >> a >> b;
    int mark[4] = {0};
    mark[a] = mark[b] = 1;
    FOR(i, 1, 3) if (!mark[i]){
        cout << i;
    }
}


Measured memory_bytes: 256
"use strict";

function main(input) {
  var lines = input.split('\n');
  var n = parseInt(lines.shift());
  var vs = splitNum(lines.shift()).slice(0, n);
  var map0 = new Array(1e5 + 1).fill(0).map(function (_, idx) {
    return {
      idx,
      count: 0
    };
  });
  var map1 = new Array(1e5 + 1).fill(0).map(function (_, idx) {
    return {
      idx,
      count: 0
    };
  });

  for (var i = 0; i < n; i += 2) {
    map0[vs[i]].count++;
    map1[vs[i + 1]].count++;
  }

  map0.sort(function (a, b) {
    return b.count - a.count;
  });
  map1.sort(function (a, b) {
    return b.count - a.count;
  });
  var result;

  if (map0[0].idx !== map1[0].idx) {
    // use different numbers.
    result = sumCount(map0.slice(1)) + sumCount(map1.slice(1));
  } else {
    // secondary
    var sum02 = sumCount(map0.slice(2));
    var sum12 = sumCount(map1.slice(2));
    var use0 = map0[1].count + sum02 + map1[0].count + sum12;
    var use1 = map0[0].count + sum02 + map1[1].count + sum12;
    result = Math.min(use0, use1);
  }

  console.log(result);
}

function sumCount(arr) {
  return arr.reduce(function (pv, _ref) {
    var count = _ref.count;
    return pv + count;
  }, 0);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function splitNum(line) {
  return line.split(/\s+/).map(function (n) {
    return parseInt(n);
  });
}


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

#define pb push_back
#define mk make_pair
#define lob lower_bound
#define upb upper_bound
#define fst first
#define scd second

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

inline int read(){
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
inline ll readll(){
	ll f=1,x=0;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

const int MAXN=505;
int n,p[MAXN*MAXN],cnt;
bool v[MAXN*MAXN];
void sieve(int n=500*500){
	for(int i=2;i<=n;++i){
		if(!v[i])p[++cnt]=i;
		for(int j=1;j<=cnt&&i*p[j]<=n;++j){
			v[i*p[j]]=1;
			if(i%p[j]==0)break;
		}
	}
}
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll a[MAXN][MAXN];
ll lcm(ll x,ll y){return x/__gcd(x,y)*y;}
int main() {
	n=read();if(n==2)return puts("4 7\n23 10\n"),0;
	sieve();
	int t=0;
	for(int s=2;s<=n+n;s+=2){
		++t;
		for(int i=1;i<=n;++i)if(s-i>=1&&s-i<=n&&(!((i+s-i)&1)))a[i][s-i]=p[t];
	}
	for(int d=((n&1)?1-n:2-n);d<=n;d+=2){
		++t;
		for(int i=1;i<=n;++i)if(i-d>=1&&i-d<=n&&(!((i+i-d)&1)))a[i][i-d]*=p[t];
	}
	for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)if((i+j)&1){
		ll l=1;
		for(int k=0;k<4;++k){
			int ii=i+dx[k],jj=j+dy[k];
			if(ii<1||ii>n||jj<1||jj>n)continue;
			assert(a[ii][jj]);
			l=lcm(l,a[ii][jj]);
		}
		a[i][j]=l+1;
	}
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j)cout<<a[i][j]<<" ";
		cout<<endl;
	}
	return 0;
}

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

using namespace std;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 2e5 + 9, M = 100 + 9, OO = (int) 1e9 + 1;
const long long MOD = 1e9 + 7;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(12);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void READ() {
	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
}

int main() {
//	READ();
	OUTPUT();
	int arr[3];
	cin >> arr[0] >> arr[1] >> arr[2];
	sort(arr, arr + 3);
	cout << arr[0] + arr[1];

	return 0;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        List<String> a = new ArrayList<>();
        List<String> b = new ArrayList<>();

        int i = 1;
        for (String str : sc.next().split("")) {
            if (i % 2 > 0) {
                a.add(str);
            } else {
                b.add(str);
            }
            i++;
        }

        if (!a.contains("L") && !b.contains("R")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23636
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arrD = new int[n];
		for (int i = 0; i < n; i++) {
			arrD[i] = sc.nextInt();
		}
		int m = sc.nextInt();
		int[] arrT = new int[m];
		for (int i = 0; i < m; i++) {
			arrT[i] = sc.nextInt();
		}
		Arrays.sort(arrD);
		Arrays.sort(arrT);
		int idx = 0;
		for (int i = 0; i < m; i++) {
			while (true) {
				if (idx >= n || arrD[idx] > arrT[i]) {
					System.out.println("NO");
					return;
				} else if (arrD[idx] == arrT[i]) {
					idx++;
					break;
				} else {
					idx++;
				}
			}
		}
		System.out.println("YES");
	}
}


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

ll ebob(ll a, ll b){
	if(a==0) return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (a*b)/ebob(a,b);
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n; cin>>n;
	string arr[n]; int arr2[n];
	int sum = -1;
	for(int i = 0; i < n; i++){
		cin>>arr[i]>>arr2[i];
	}
	string s; cin>>s;
	for(int i = 0; i < n; i++){
		if(s == arr[i] || sum >= 0){
			if(s == arr[i]) sum++;
			else sum += arr2[i];
		}
	}
	cout<<sum;
	return 0;
}


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

namespace Main
{
    class Program
    {

        static void Main(string[] arg)
        {

            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int Goukei = 0;
            int[] NumList = { };
            int MaxNum = 0;

            for (int i = 0; i < n; i++)
            {
                NumList = new int[NumList.Length + 1];
                NumList[NumList.Length - 1] = int.Parse(str[i]);
                Goukei += int.Parse(str[i]);
                if(int.Parse(str[i]) > MaxNum)
                {
                    MaxNum = int.Parse(str[i]);
                }
            }
            Goukei -= MaxNum;
            if (Goukei > MaxNum)
            {
                Console.WriteLine("Yes");

            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


Measured memory_bytes: 11220
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var N=Arr.shift()-0;
   if(N==0)break;
   if(N==1){console.log("1 1");continue;}
   var arr=[];
   arr[0]=[0,0];
   for(var i=0;i<N-1;i++){
      var nm=(Arr.shift()).split(" ").map(Number);
      var n=nm[0];
      var m=nm[1];
      var x=0;
      var y=0;
      if(m==0)x=-1;
      if(m==1)y=-1
      if(m==2)x=1;
      if(m==3)y=1;
      arr[i+1]=[arr[n][0]+x,arr[n][1]+y];
   }
   var xA=0;
   var xZ=0;
   var yA=0;
   var yZ=0;
   for(var i=0;i<arr.length;i++){
      xA=Math.min(xA,arr[i][0]);
      xZ=Math.max(xZ,arr[i][0]);
      yA=Math.min(yA,arr[i][1]);
      yZ=Math.max(yZ,arr[i][1]);
   }
   console.log((xZ-xA+1)+" "+(yZ-yA+1));
}

Measured memory_bytes: 11352
#include<iostream>
using namespace std;
int main()
{
    int k,a,b,i,c=0;
    cin>>k>>a>>b;
    for(i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            c++;
        }
    }
    if(c==0)
    {
        cout<<"NG"<<endl;
    }
    else
    {
        cout<<"OK"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
  int a,b[1009],ma,c;
  ma=c=0;
   cin >> a;
  rep(i,a){
    cin >> b[i];
    if(b[i]>=ma){
      ma=b[i];
      c++;
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    s = input()

    ans = 1
    for c in 'RGB':
        ans *= s.count(c)

    for j in range(N):
        for i in range(j):
            k = (j - i) + j
            if k >= N: continue
            if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]: continue
            ans -= 1

    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

int main(){

    char c; cin >> c;

    cout << (char)(c+1) << endl;

    return 0;
}

Measured memory_bytes: 256
/******************************************************************************
 
рассвет. 
 
*******************************************************************************/
#include <bits/stdc++.h>
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define rapgame ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define eb emplace_back
#define vi vector <int>
#define vlli vector <lli>
#define vulli vector <ulli>
#define vchar vector <char>
#define vstr vector <string>
#define vb vector <bool>
#define fst first
#define sec second
#define srt(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define vpii vector <pair <int,int> >
#define pii pair <int,int> 
#define vplli vector <pair <lli,lli> >
#define vpulli vector <pair <ulli,ulli> >
#define vvi vector <vector <int> >
#define vvlli vector <vector <lli> >
#define vvpii vector <vector <pair <int,int>> >
#define fr(i,n) for (int i = 0; i < (n); ++i)
#define frbig(i,n) for (lli i = 0; i < (n); ++i)
#define fra(i,a,n) for (lli i = a; i < (n); ++i)
#define run(c,s) for(auto c:s) 
#define read(n) int n; cin >> n;
#define readchar(n) char n; cin >> n;
#define readstr(n) string n; cin >> n;
#define readarr(a,n) fr(i,n) cin >> a[i];
#define read2(x,y) int x,y; cin >> x >> y;
#define read2ll(x,y) long long int x,y; cin >> x >> y;
#define readll(n) lli n; cin >> n;
#define watch(x) cout << (#x) << " is " << (x) << endl
#define print_array(x) fr(i,x.size()) cout << x[i] << " ";
using namespace std;
 
const lli MOD=1e9+7;
const lli MAXN=1e6+1;
const ld PI=acos(-1);
 
int main(){
    rapgame
    read2(a,b);read2(c,d);
    cout << (c/b+(c%b>0)<=a/d+(a%d>0) ? "Yes":"No");
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main(void){
  
  while(1){
    int n,x;
    int count = 0;
    cin >> n >> x;
    if(n == 0 && x == 0)
       break;

       for(int i=1; i<=n; i++){
           for(int j=i + 1; j<=n; j++){
               for(int k= j + 1; k<=n; k++){
                  if(i + j + k == x)
                    count++;
               }
           }
       }
    cout << count << endl;
  }


  return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, a[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	int sum = a[0];
	int ng = -1;
	REP(i, n) {
		if (sum * 2 < a[i]) {
			ng = i - 1;
		}
		sum += a[i];
	}
	cout << (n - 1) - ng << endl;
}

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

int ac,wa,tle,re, n;
int main(){
    cin>>n;
    string s;

    while((n--)){
        cin>>s;
        if(s=="AC")ac++;
        else if(s=="TLE")tle++;
        else  if(s=="WA")wa++;
        else re++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d",ac,wa,tle,re);

    return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    int n, k;
    cin >> n >> k;
    vint h(n);
    rep(i, n) cin >> h[i];

    vll cost(n, 0);
    for(int i = 1; i < n; i++){
        ll nextCost = 1e9;
        for(int j = 1; j <= k and j <= i; j++){
            ll tmp = abs(h[i] - h[i - j]) + cost[i - j];
            nextCost = min(tmp, nextCost);
        }
        cost[i] = nextCost;
    }
    // for(auto x : cost) cout << x << endl;

    cout << cost.back() << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

int main() {
    
    int N;
    cin >> N;
    cout << N/3 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF 1e9
int n;
int dp[100001];

int Min(int a, int b){
    return a<b?a:b;
}

int dfs(int m){
    if(dp[m]!=INF)return dp[m];
    int tmp=9;
    while(m-tmp>=0){
        dp[m]=Min(dp[m],dfs(m-tmp)+1);
        tmp*=9;
    }
    tmp=1;
    while(m-tmp>=0){
        dp[m]=Min(dp[m],dfs(m-tmp)+1);
        tmp*=6;
    }
    return dp[m];
}

int main(){
    scanf("%d",&n);
    int i;
    for(i=1;i<=n;i++){
        dp[i]=INF;
    }
    printf("%d\n",dfs(n));
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF 1e9+7
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll,ll>
const int maxn = 10000;
const int maxa =1000000;
ll mod = INF;

ll d[maxa+1];
ll n;
ll a[maxn];
vector<map<ll,ll>> m(maxn);
map<ll,ll> LCM;
ll ans=0;

void func(int i,ll k){
    if(k<2)return;
    m[i][d[k]]++;
    LCM[d[k]]=max(LCM[d[k]],m[i][d[k]]);
    //cout <<k<<" "<<d[k]<<endl;
    func(i,k/d[k]);
    return;
}

ll pow(ll x,ll y){
    if(y==0){
        return 1;
    }else if(y==1){
        return x;
    }else if(y%2==0){
        ll k=pow(x,y/2);
        return (k*k)%mod;
    }else{
        ll k=pow(x,(y-1)/2);
        return k*k%mod*x%mod;
    }
}

int main(){
    ll M=0;
    cin >> n;
    rep(i,n){
        cin >> a[i];
        M=max(M,a[i]);
    }

    fill(d,d+maxa+1,INF);
    d[0]=d[1]=1;


    for(int i=2;i<=M;i++){
        if(d[i]!=INF)continue;
        int div=INF;
        if(i%2==0){
            div=2;
        }else{
            for(int tmp=3;tmp*tmp<=i;tmp+=2){
                if(i%tmp==0){
                    div=tmp;
                    break;
                }
            }
            if(div==INF)div=i;
        }
        for(int j=div;j<=M;j+=div){
            if(d[j]==INF)d[j]=div;
        }
    }
    
    rep(i,n)func(i,a[i]);
    
    ll l=1;
    for(auto ite=LCM.begin();ite!=LCM.end();ite++){
        //l=l*pow(ite->first,ite->second)%mod;
        for(int i=0;i<ite->second;i++){
            l=l*ite->first%mod;
        }
    }
    
    rep(i,n){
        ans=(ans+l*pow(a[i],mod-2)%mod)%mod;
    }

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

Measured memory_bytes: 14724
i = list(map(int, input().split()))
A = i[0]
B = i[1]

if(A - B > 1 or B - A > 1):
  print(':(')

if((A - B) == 0 or (A - B) == 1 or (B - A) == 0 or (B - A) == 1):
  print('Yay!')



Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }


    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int[] T = cin.ArrayInt(N);
        int[] V = cin.ArrayInt(N);
        int sumT = T.Sum() * 2;
        double[] v = new double[sumT + 1];
        for (int i = 0; i < v.Length; i++)
        {
            v[i] = 1e30;
        }
        v[0] = 0;
        v[sumT] = 0;
        int cnt = 0;
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j < T[i] * 2; j++)
            {
                v[cnt] = Math.Min(v[cnt], V[i]);
                cnt++;
                v[cnt] = Math.Min(v[cnt], V[i]);
            }
        }

        for (int i = 1; i < v.Length - 1; i++)
        {
            v[i] = Math.Min(v[i], v[i - 1] + 0.5);
            v[i] = Math.Min(v[i], v[i + 1] + 0.5);
        }
        for (int i = v.Length - 2; i >= 1; i--)
        {
            v[i] = Math.Min(v[i], v[i - 1] + 0.5);
            v[i] = Math.Min(v[i], v[i + 1] + 0.5);
        }
        

        double ans = 0;
        for (int i = 0; i < sumT; i++)
        {
            ans += (v[i] + v[i + 1]) / 4;
        }
        Console.WriteLine("{0:0.000000000000000000}", ans);
    }


}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13372
n, yen = [int(s) for s in input().split()]
yen //= 1000
for x in range(n + 1):
    for y in range(n - x + 1):
        z = n - x - y
        p = 10 * x + 5 * y + z
        if p == yen:
            print(x, y, z)
            exit()
print(-1, -1, -1)

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

using namespace std;

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    int ret;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        if (a >= h && b >= w)ret++;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let s: Vec<u8> = s.trim().bytes().collect();
	println!("{}", s.iter().zip(s.iter().rev()).take(s.len() / 2).fold(0, |r, (a, b)| r + if a == b { 0 } else { 1 }));
}


Measured memory_bytes: 4352
H, W = map(int, input().split())
S = H * W
ans = S

for h in range(1,H):
    s1 = h * W
    s2 = W // 2 * (H-h)
    s3 = S-s1-s2
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))

    s2 = (H-h) // 2 * W
    s3 = S-s1-s2
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))

for w in range(1,W):
    s1 = H * w
    s2 = H // 2 * (W-w)
    s3 = S-s1-s2
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))

    s2 = (W-w) // 2 * H
    s3 = S-s1-s2
    ans = min(ans,max(s1,s2,s3)-min(s1,s2,s3))

print(ans)

Measured memory_bytes: 9256
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(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;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n = nxt(), m = nxt();
    VI digit(n, -1);
    REP(i, m){
        int s = nxt(), c = nxt();
        s--;
        if(digit[s] != -1 && digit[s] != c){
            printf("-1");
            return 0;
        }else digit[s] = c;
    }
    if(n != 1 && digit[0] == 0){
        printf("-1");
        return 0;
    }
    REP(i, n) {
        if(digit[i] == -1) {
            if(i || n == 1) digit[i] = 0;
            else digit[i] = 1;
        }
    }
    REP(i, n) printf("%d", digit[i]);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}
template<class A,size_t N,class T>void Fill(A(&a)[N],const T&v){fill((T*)a,(T*)(a+N),v);}

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

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m=MOD){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m=MOD){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>Fac,Rac;void setF(int n,int m=MOD){Fac=Rac=V<ll>(++n);Fac[0]=1;FOR(i,1,n)Fac[i]=Fac[i-1]*i%m;Rac[n-1]=modInv(Fac[n-1],m);FORR(i,n-1,1)Rac[i-1]=Rac[i]*i%m;}
//ll comb(int a,int b,int m=MOD){return a<b||b<0?0:Fac[a]*Rac[b]%m*Rac[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int N = 12;
int n, m, x, c[N];
int A[N][N];
int b[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m >> x;
  FOR(i, 0, n){
    cin >> c[i];
    FOR(j, 0, m) cin >> A[i][j];
  }
  int ans = IINF;
  FOR(i, 0, bit(n)){
    int s = 0;
    memset(b, 0, sizeof b);
    FOR(j, 0, n)if(i&bit(j)){
      s += c[j];
      FOR(k, 0, m) b[k] += A[j][k];
    }
    FOR(j, 0, m) if(b[j]<x) s = IINF;
    mins(ans, s);
  }
  cout << ((ans==IINF) ? -1 : ans) << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<utility>
#include<numeric>
#include<functional>
#include<algorithm>
#include<queue>
#include<map>
#include<string>

#define FOR(i, a, b) for(int i=a; i<b; i++)
#define COUT(a) cout << a << endl;

using namespace std;
using Int = long long;
using P = pair<Int, Int>;

int main() {
    Int a,b,c;
    Int max,y;
    Int x;

    cin >> a >> b >> c;

    if (a <= b) {
        if (b <= c){
            max = c;
            y   = a+b;

        }
        else {
            max = b;
            y   = a+c;
        }
    }
    else{
        if (a <= c){
            max = c;
            y   = a+b;
        }
        else {
            max = a;
            y   = b+c;
        }
    }

    x = (max*10)  + y;

    cout << x << endl;

    return 0;
}

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

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void io(){
		
		while(true){
			int n = ni();
			if(n==0)
				break;
			
			// 一番左の点から
			int left=0;
			double[][] map = new double[n][2];
			for(int i=0; i<n; ++i){
				map[i] = ndl();
				if(map[i][0] < map[left][0]){
					left = i;
				}
			}
			final int last = left;
			int now = left;
			int count = n;
			// 一番左なので、真上を指すベクトルから
			double[] v = new double[]{0., 1.};
			do{
				--count;
				double min = 360.1;
				int i_best = 0;
				double[] v_best = v;
				for(int i=0; i<n; ++i){
					// 自身以外の全探索
					if(i!=now){
						// 進行方向ベクトル, vに対する角度を求める
						
						// 内積から0~180度の角度を得る
						double[] v_ = new double[]{map[i][0]-map[now][0], map[i][1]-map[now][1]};
						double ab = v[0]*v_[0] + v[1]*v_[1];
						double a_ = Math.sqrt(v[0]*v[0] + v[1]*v[1]);
						double b_ = Math.sqrt(v_[0]*v_[0] + v_[1]*v_[1]);
						double cos_ = ab/(a_*b_);
						double ang_ = Math.toDegrees(Math.acos(cos_));
						
						// 外積で左向いていたら180度げたはかせる
						double axb = v[0]*v_[1] - v[1]*v_[0];
						if(axb > 0){
							ang_ = 360. - ang_;  //(180. - ang_) + 180.
						}
						
						//debug(map[now], map[i], ang_);
						// 方向ベクトルに対する一番時計回りに近い点を得る
						if(ang_ < min){
							min = ang_;
							i_best = i;
							v_best = v_;
						}
					}
				}
				
				// 点の移動
				now = i_best;
				v = v_best;
			}while(now!=last);
			
			// 残りのn(count)が中に入っている点の数
			System.out.println(count);
		}
	}
	
	double[] ndl(){
		String[] str = sc.next().split(",");
		double args[] = new double[2];
		for(int i=0; i<2; ++i){
			args[i] = Double.parseDouble(str[i]);
		}
		return args;
	}
	
	int ni(){
		return sc.nextInt();
	}
	
	public static void main(String[] args) {
		new Main().io();
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}
}

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

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

//b=2 素因数分解
int64_t fa(int64_t a) {
    if (a == 1)return 1;
    int64_t y = 1;
    int64_t o = 1;
    int64_t b = 2;
    while (1) {
        if (b * b > a) { if (a != y) o++; break; }
        if (a % b != 0) b++;
        if (a % b == 0) { if (b != y) o++; a = a / b; y = b; }
    }
    return o;
}

int main() {
    int64_t a, b;
    cin >> a >> b;
    cout << fa(gcd(min(a, b), max(a, b))) << endl;
}

Measured memory_bytes: 256
C = input()

a = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,w,v,x,y,z'

arr = a.split(",")

idx = 0
count = 0

for i in arr:
  if i == C:
    idx = count
  count += 1
  
print(arr[idx+1])

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <numeric> //accumulate for vector
#include <iomanip> //cout<<setprecision(1)<<fixed;
typedef long long ll;
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
int main()
{
	string s="";
	getline(cin,s);
	int f=1;
	for(int i=0;i<s.length();i++)
	{
		if(s.at(i)==' ')
		{
			if(s.at(i-1)!=s.at(i+1))
			{
				f=0;
				break;
			}
		}
	}
	if(f==1)
		cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
	int t;
	cin >> t;
	rep(aa,t){
		int x,y,p,dp[17][17]={};
		bool tate[16][16]={},yoko[16][16]={};
		cin >> x >> y >> p;
		rep(i,p){
			int a,b,c,d;
			cin >> a >> b >> c >> d;
			if(a==c) tate[a][min(b,d)]=true;
			else yoko[min(a,c)][b]=true;
		}
		dp[0][0]=1;
		rep(i,x+1) rep(j,y+1){
			if(!yoko[i][j]) dp[i+1][j]+=dp[i][j];
			if(!tate[i][j]) dp[i][j+1]+=dp[i][j];
		}
		if(dp[x][y]==0) cout << "Miserable Hokusai!" << endl;
		else cout << dp[x][y] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160