akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	int A[22][22] = {}; 
	for(int i = 0; i < N; i++){
		for(int j = 0; j < N; j++){
			cin >> A[i][j]; 
		}
	}
	long long int dp[2100000] = {}; // dp[i] := 男が1番目から順に相手を決めるとき，途中経過で確定済の女の集合がiになる場合の数
	long long int P = 1e9 + 7; 
	dp[0] = 1;
	for(int i = 0; i < (1 << N) - 1; i++){
		int cnt = 0; 
		for(int k = 0; k < N; k++){
			if((i >> k) & 1) cnt ++; 
		}
		for(int j = 0; j < N; j++){
			if(!((i >> j) & 1) && A[cnt][j] == 1){
				dp[i + (1 << j)] += dp[i]; 
				if(dp[i + (1 << j)] >= P){
					dp[i + (1 << j)] -= P; 
				}
			}
		}
	}
	cout << dp[(1 << N) - 1] << endl; 	
}

Measured memory_bytes: 16640
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.nextInt()

    println(abc131a(s))
}

private fun abc131a(s: Int): String {
    var ans = "Good"
    var a = s / 1000
    var b = s % 1000 / 100
    var c = s % 100 / 10
    var d = s % 10

    if (a == b || b == c || c == d ) {
        ans = "Bad"
    }

    return ans
}

Measured memory_bytes: 31392
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int n;
    cin >> n;
 
    vector<ll> a(n);
    int p[19][19] = {};//2^t 5^fで割り切れるものの個数
                       // ただしt, f > 18のときはt, f = 18として扱う
                    //:= 素因数分解したときに2の個数がi個、5の個数がj個であるBの個数
    string s;
    ll r = 0;
 
    for (int i = 0; i < n; i++) {
        ll t = 0;
        int f = 0, k = 9;
 
        cin >> s;
        for (char c : s) {
            if (c == '.') {
                f = 1;
                continue;
            }
            if (f) {
                k--;
            }
            t *= 10;
            t += c - '0';//t += atoll(&c);
        }
        for (int j = 0; j < k; j++) {
            t *= 10;
        }
        a[i] = t;
 #if 1
        int x = 0, y = 0;
        while (t % 2 == 0) t /= 2, x++;
        x = min(x, 18);
        while (t % 5 == 0) t /= 5, y++;
        y = min(y, 18);
 
 //例えば、x = 2, y = 5ならば、x' >= 16, y' >= 13となる相棒が見つかればOK!
 //p[i][j](where i : 16~18, j : 13~18)だけ答え(=r)に加算する。
        for (int x1 = 18 - x; x1 < 19; x1++) {
            for (int y1 = 18 - y; y1 < 19; y1++) {
                r += p[x1][y1];
            }
        }
        p[x][y]++;
        //cout << x << "/" << y << "/" << p[x][y] << endl;
 #endif
        //a[i] = t;
        //cout << a[i] << endl;
    }
    // for (int i = 0; i < n; i++) {
    //     cout << a[i] << endl;
    // }
 
    cout << r << endl;

 
    return 0;
}

Measured memory_bytes: 4768
n,m = map(int,input().split())
sc = [[i for i in map(int,input().split())] for j in range(m)]
start = 0
goal = 0
if n==1:
  start = 0
  goal = 9
elif n==2:
  start = 10
  goal = 99
elif n==3:
  start = 100
  goal = 999

flag = 1
ans = -1
for num in range(start,goal+1):
  flag = 1
  for i in range(m):
    if str(num)[sc[i][0]-1] != str(sc[i][1]): #両辺ともちゃんとstrで変換
      flag = 0
  if flag == 1:
    ans = num
    break
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

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

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

  int k, x;
  cin >> k >> x;

  string buf;
  for (int i = x - k + 1; i < x + k; i++) {
    buf += to_string(i) + " ";
  }

  cout << buf << endl;

  return 0;
}


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

int main(void)
{
    long long n;
    cin >> n;

    long long ans = 0;
    for (long long i = 1; i <= n; i++)
    {
        long long tmpN = n / i;
        ans += (tmpN + 1)*tmpN / 2 * i;
    }

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

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


#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, deque<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }



int main() {
    long long X;
    cin >> X;
    for (long long A = -200; A <= 200; ++A) {
        for (long long B = -200; B <= 200; ++B) {
            if (A*A*A*A*A - B*B*B*B*B == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3628
using System;
using System.Linq;

namespace EDPC
{
    class E
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int W = int.Parse(input[1]);

            const int MAX_N = 110;
            const int MAX_V = 100100;

            long[,] wv = new long[MAX_N, MAX_V];
            for (int i = 0; i < N; i++)
            {
                input = Console.ReadLine().Split(' ');
                wv[i, 0] = long.Parse(input[0]);
                wv[i, 1] = long.Parse(input[1]);
            }

            long[,] dp = new long[MAX_N, MAX_V];
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < MAX_V; j++)
                {
                    dp[i, j] = int.MaxValue;
                }
            }

            dp[0, 0] = 0;

            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < MAX_V; j++)
                {
                    if (0 <= j - wv[i, 1])
                    {
                        dp[i + 1, j] = Math.Min(dp[i, j], dp[i, j - wv[i, 1]] + wv[i, 0]);
                    }
                    else
                    {
                        dp[i + 1, j] = Math.Min(dp[i + 1, j], dp[i, j]);
                    }
                }
            }

            long res = 0;

            for (int j = 0; j < MAX_V; j++)
            {
                if (dp[N, j] <= W) res = j;
            }
            Console.WriteLine(res);
        }
    }
}


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

#define int long long
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define yn(x) ((x) ? "YES" : "NO")

typedef pair <int, int> ii;
typedef pair <int, ii> iii;

const int siz = 3e2 + 10;
const int SIZ = 1e6 + 10;
const int mod = 1e9 + 7;
const int maxx = 2e9;
const int MAXX = 1e18;
const string file = "2";

int n, k;
int a[siz];
int f[siz][siz][siz];

int dp(int pos, int cnt, int prv) {
    if (pos == n + 1) {
        if (cnt == k) {
            return 0;
        }
        return MAXX;
    }

    int &res = f[pos][cnt][prv];
    if (res != -1) {
        return res;
    }

    res = dp(pos + 1, cnt, pos) + max(a[pos] - a[prv], 0LL);

    if (cnt < k) {
        res = min(res, dp(pos + 1, cnt + 1, prv));
    }

    return res;
}

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

//    freopen ((file + ".inp").c_str(), "r", stdin);
//    freopen ((file + ".out").c_str(), "w", stdout);

    cin >> n >> k;

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

    memset(f, -1, sizeof(f));

    cout << dp(1, 0, 0) << "\n";

//    cerr << "Time: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";

    return 0;
}


Measured memory_bytes: 236432
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		final long MOD = (long)1000000007;
		int n = in.nextInt();
		long[] ints = new long[n];
		for(int i = 0; i < n; i++) ints[i] = in.nextLong();
		int[][] solve = new int[n][61];
		for(int i = n - 1; i > 0; i--) {
			for(int j = 0; j < 61; j++) {
				if(((1L << j) & ints[i]) != 0) {
					solve[i][j] += 1;
					solve[i - 1][j] = solve[i][j];
				}else {
					solve[i - 1][j] = solve[i][j];
				}
			}
		}
		long ans = 0L;
		for(int i = 0; i < n - 1; i++) {
			for(int j = 0; j < 61; j++) {
				if(((1L << j) & ints[i]) != 0) { 
					long save = ((long)(((1L << j) % MOD) * (((n - 1) - i - solve[i + 1][j]) % MOD))) % MOD;
					ans = ((ans % MOD) + (save % MOD)) % MOD;
				}else {
					long save = ((long)(((1L << j) % MOD) * ((solve[i + 1][j]) % MOD))) % MOD;
					ans = ((ans % MOD) + (save % MOD)) % MOD;
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 126064
#include<bits/stdc++.h>
using namespace std;
int main () {
  int dp[128][1001];
  for (int n = 1; n < 1001; n ++) {
    for (int j = 0; j < 128; j ++) {
      if (n == 1) dp[j][n] = j;
      else {
        dp[j][n] = -1;
        for (int i = 0; i < 128; i ++) {
          int kj = j ^ i;
          int ku = max(dp[kj][n - 1] + i, dp[i][n - 1] + kj);
          if (dp[j][n] < ku) dp[j][n] = ku;
        }
      }
    }
  }
  int T;
  cin >> T;
  for (int i = 0; i < T; i ++) {
    int N, D;
    cin >> N >> D;
    cout << dp[D][N] << endl;
  }
}

Measured memory_bytes: 768
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
minrem = 10
minnum = 0
tens = 0
impts = [a,b,c,d,e]
for i in impts:
  if i%10>0:
    if min(minrem,i%10)==i%10:
      minrem = i%10
      minnum = i
  else:
    tens+=1
if tens==5:
  print(a+b+c+d+e)
else:  
  print((a//10+b//10+c//10+d//10+e//10)*10+(5-tens-1)*10-minnum//10*10+minnum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  cin >> n;

  string s, t;
  cin >> s >> t;

  string ans = "";
  for (int i = 0; i < n; i++) {
    ans += s[i];
    ans += t[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N = int(input())
list_anagram = [''.join(sorted(str(input()))) for i in range(N)]
 
list_anagram.sort()
ans = 0
 
x = 1
 
for i in range(1, N):
    if i != N - 1 and list_anagram[i] == list_anagram[i - 1]:
        x += 1
    elif i != N - 1 and list_anagram[i] != list_anagram[i - 1]:
        ans = ans + x * (x - 1) // 2
        x = 1
    elif i == N - 1 and list_anagram[i] == list_anagram[i - 1]:
        x += 1
        ans = ans + x * (x - 1) //2
    else:
        ans = ans + x * (x - 1) // 2
 
print(ans)

Measured memory_bytes: 10640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){//popcount%2
	return __builtin_parity(x);
}



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

const ll INF=1e15;

const ll mod=1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}

struct Sieve{
    int n;
    vector<int> f, primes;
    //コンストラクタを定義
    Sieve(int n=1):n(n), f(n+1){//メンバ変数の初期化
        f[0]=f[1]=-1;
        for(ll i=2;i<=n;i++){
            if(f[i]) continue;
            primes.push_back(i);
            f[i]=i;
            for(ll j=i*i;j<=n;j+=i){
                if(!f[j]) f[j]=i;
            }
        }
    }
    bool isPrime(int x) { return f[x]==x;} //xが素数かどうかを判定
    vector<int> factorList(int x){//xの素因数を重複ありで小さい順に列挙
        vector<int> res;
        while(x!=1){
            res.push_back(f[x]);
            x/=f[x];
        }
        return res;
    }
    vector<pair<int,int>> factor(int x){//xの素因数と、その出現回数
        vector<int> fl=factorList(x);
        if(fl.size()==0) return {};
        vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
        for(int p : fl){
            if(res.back().first==p){
                res.back().second++;
            }else{
                res.emplace_back(p,1);
            }
        }
        return res;
    }
};
int main(){
    ios;
   ll n;
   cin >> n;
   vector<ll> a(n);
   ll g;
   Sieve sieve=Sieve(1000000);
   vector<ll> pr(1000000);
   rep(i,n){
       cin >> a[i];
       if(i==0) g=a[i];
       else g=gcd(g,a[i]);
       for(auto x:sieve.factor(a[i])){
           ll s=x.first;
           ll t=x.second;
           pr[s]+=t;
       }
   }
   if(g!=1){
       cout << "not coprime" << endl;
       return 0;
   }
   bool ok=true;
   rep(i,n){
       for(auto x:sieve.factor(a[i])){
           ll s=x.first;
           ll t=x.second;
           if(pr[s]>t){
               ok=false;
               cout << "setwise coprime" << endl;
               return 0;
           }
       }
       
   }
   cout << "pairwise coprime" << endl;
   return 0;
}

Measured memory_bytes: 23112
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

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

	vector<int> data(n);
	rep(i, n)
		cin >> data[i];

	int XOR = 0;

	rep(i, n)
		XOR ^= data[i];

	rep(i, n) {
		cout << (XOR ^ data[i])<<" ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 4036
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))

n, k = MI()
a = LI()
cover = 0
ans = 0
while True:
    if cover == 0:
        cover += k
    else:
        cover += k-1
    ans += 1
    if n <= cover:
        break
print(ans)






Measured memory_bytes: 16508
/// Template by Zayed ///

///************************************************************///
/// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>

#include <string>
#include <cstring>
#include <sstream>

#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
//#include<unordered_map>
#include <set>
//#include<unordered_set>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
///************************************************************///
using namespace std;
int caseno = 1;
///************************************************************///
#define NL '\n'
#define SF scanf
#define PF printf
#define PC() printf("Case %d: ", caseno++)//NOTES:printf
//#define PC cout << "Case "//NOTES:cout
//#define CN cout << caseno++ << ": "//NOTES:cout
#define CLR(ar) memset(ar, 0, sizeof(ar))
#define SET(ar) memset(ar, -1, sizeof(ar))
#define READ() freopen("input.txt", "r", stdin)
#define WRITE() freopen("output.txt", "w", stdout)
#define BOOST std::ios_base::sync_with_stdio(0);
///************************************************************///
typedef long long LL;//NOTES:"%lld"
typedef unsigned long long ULL;//NOTES:"%llu"
///************************************************************///
#define INF (1 << 31) - 1
#define MOD 1000000007
#define PRIME 999998727899999 			// (largest prime below 10^16)
#define PB push_back
#define pii pair<int, int>
#define pic pair<int, char>
#define pci pair<char, int>
#define pLL pair<LL, LL>
#define pis pair<int, string>
#define psi pair<string, int>
#define pss pair<string, string>
#define PI 2 * acos(0.0)
#define EPS 1e-11
///************************************************************///
// Numeric Functions
template < class T > inline void SWAP(T &a, T &b) { T t = a; a = b; b = t; }
inline LL POW(LL base, LL power){
	LL res = base; if (power == 0) return 1;
	for (int I = 0; I < power - 1; I++) res *= base; return res;
}
// Translator Functions
int ToInt(string s) { int r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToInt(
double ToDouble(string s) { double r = 0; istringstream sin(s); sin >> r; return r; }//NOTES:ToDouble(
string ToString(int n) { string s; stringstream convert; convert << n; s = convert.str(); return s; }//NOTES:ToString(
///************************************************************///

/*
*******4 Direction Array*******
int dx[] = {0, 0, - 1, 1}, dy[] = {-1, 1, 0, 0};
*******8 Direction Array*******
int dx[] = {0, 0, -1, +1, -1, -1, +1, +1}, dy[] = {-1, +1, 0, 0, -1, +1, -1, +1};
********Knight Moves********
int dx[] = {-2, -2, -1, -1, +1, +1, +2, +2}, dy[] = {-1, +1, -2, +2, -2, +2, -1, +1};
*/

const int SIZE = 50 + 10;
int ar[SIZE];



int main()
{
	BOOST
	///READ();
	///WRITE();
	int T, I, J, K, N, n, m, cnt = 0, len, k;

	cin >> n >> k;

	for(I = 0; I < n; I++)
		cin >> ar[I];

	sort(ar, ar + n);

	int sum = 0;
	for(I = n - 1; I >= 0; I--)
	{
		if(cnt >= k)
			break;

		sum += ar[I];
		cnt++;
	}

	cout << sum << NL;


	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  string sa, sb, sc;
  cin >> sa >> sb >> sc;

  char turn;
  turn = 'a';
  int apos = 0, bpos = 0, cpos = 0;

  while(1){
    //a
    if(turn == 'a'){
      if(apos == sa.size()){
        cout << 'A' << endl;
        return 0;
      }
      turn = sa[apos];
      apos++;
    }
    //b
    if(turn == 'b'){
      if(bpos == sb.size()){
        cout << 'B' << endl;
        return 0;
      }
      turn = sb[bpos];
      bpos++;
    }
    //a
    if(turn == 'c'){
      if(cpos == sc.size()){
        cout << 'C' << endl;
        return 0;
      }
      turn = sc[cpos];
      cpos++;
    }

  }


  return 0;
}

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

#define ll long long

int main()
{
    int N, K;
    std::cin >> N >> K;

    std::map<int, int> data;

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

    int count = 0;
    for(int i=1; i <= N; i++) {
        if(data[i] == 0) {
            count++;
        }
    }

    std::cout << count << std::endl;
}

Measured memory_bytes: 3572
#include <stdio.h>

int main() {
  int n, x=0, max=0, i;
  scanf("%d", &n);
  char s[n+1];
  scanf("%s", s);

  for (i=0; i<n; i++) {
    if (s[i]=='I') {
      x++;
      if (max<x) max=x;
    } else if (s[i]=='D') {
      x--;
    }
  }

  printf("%d\n", max);
  return 0;
}

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


int main() {
  int N;
  cin>>N;
 
  for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
      int a=i*j;
      if(N==a){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  
  cout<<"No"<<endl;

    
  
}

Measured memory_bytes: 256
//15:53-17:33
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	deque<int>a;
	int n; cin >> n;
	rep(i,n){
		int x; cin >> x;
		if((n-1-i)%2 == 0) a.push_front(x);
		else a.push_back(x);
	}
	rep(i,n) cout << a[i] << (i==n-1?'\n':' ') ;
}

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

int main(){
  string s;
  cin >> s;
  if(s=="RRR"){
    cout << 3 << endl;
  }else if(s=="RRS"||s=="SRR"){
    cout << 2 << endl;
  }else if(s=="SSS"){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 3620
x,y=map(int,input().split())

r=0

if x==3:
  r+=100000
elif x==2:
  r+=200000
elif x==1:
  r+=300000
  
if y==3:
  r+=100000
elif y==2:
  r+=200000
elif y==1:
  r+=300000
  
if x==1 and y==1:
  r+= 400000

print(r)
 


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

using namespace std;

int main(){
  int n,r;

  while(cin>>n>>r,n){
    int p,c;
    vector<int> cards;
    
    for(int i=n;i>0;--i){
      cards.push_back(i);
    }
    
    for(int i=0;i<r;++i){
      cin>>p>>c;
      vector<int> temp;
      for(int j=0;j<c;++j){
	temp.push_back(cards[p-1]);
	cards.erase(cards.begin()+p-1);
      }
      
      int j=0;
      for(auto i:temp){
	cards.insert(cards.begin()+j,i);
	j++;
      }
    }
    cout<<cards[0]<<endl;
  }
}

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

using namespace std;

int n, t;
vector<pair<int, int> > v(100);
int main(){
    cin >> n >> t;
    for (int i = 0; i < n; i++){
        cin >> v[i].first >> v[i].second;
    }
    int mini = 10000;
    for (int i = 0; i < n; i++){
        if (t >= v[i].second){
            mini = min(mini, v[i].first);
        }
    }

    if (mini == 10000){
        cout << "TLE" << endl;
    } else {
        cout << mini << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

ll imos[2005][2005];
bool f[100005];

int main(){
    ll n,k; cin >> n >> k;
	vl x(n),y(n);
	vc c(n);
	rep(i,n){
		cin >> x[i] >> y[i] >> c[i];
		x[i] %= 2*k; y[i] %= 2*k;
		if(c[i]=='B') f[i] = !f[i];
		if(x[i]>=k){
			if(y[i]>=k) x[i] -= k, y[i] -= k;
			else x[i] -= k, f[i] = !f[i];
		}else{
			if(y[i]>=k) f[i] = !f[i], y[i] -= k;
		}
	}
	rep(i,n){
		if(f[i]){
			imos[0][0]++;
			imos[0][x[i]+1]--;
			imos[y[i]+1][0]--;
			imos[y[i]+1][x[i]+1]++;
			imos[y[i]+1][x[i]+1]++;
			imos[y[i]+1][x[i]+k+1]--;
			imos[y[i]+k+1][x[i]+1]--;
			imos[y[i]+k+1][x[i]+k+1]++;
			imos[y[i]+k+1][x[i]+k+1]++;
			imos[y[i]+k+1][2*k]--;
			imos[2*k][x[i]+k+1]--;
			imos[2*k][2*k]++;
			imos[0][x[i]+k+1]++;
			imos[y[i]+1][x[i]+k+1]--;
			imos[0][2*k]--;
			imos[y[i]+1][2*k]++;
			imos[y[i]+k+1][0]++;
			imos[y[i]+k+1][x[i]+1]--;
			imos[2*k][0]--;
			imos[2*k][x[i]+1]++;
		}else{
			imos[0][x[i]+1]++;
			imos[y[i]+1][x[i]+1]--;
			imos[0][x[i]+k+1]--;
			imos[y[i]+1][x[i]+k+1]++;
			imos[y[i]+1][0]++;
			imos[y[i]+1][x[i]+1]--;
			imos[y[i]+k+1][0]--;
			imos[y[i]+k+1][x[i]+1]++;
			imos[y[i]+1][x[i]+k+1]++;
			imos[y[i]+1][2*k]--;
			imos[y[i]+k+1][x[i]+k+1]--;
			imos[y[i]+k+1][2*k]++;
			imos[y[i]+k+1][x[i]+1]++;
			imos[y[i]+k+1][x[i]+k+1]--;
			imos[2*k][x[i]+1]--;
			imos[2*k][x[i]+k+1]++;
		}
	}
	rep(i,2*k) rep(j,2*k) imos[i+1][j] += imos[i][j];
	rep(j,2*k) rep(i,2*k) imos[i][j+1] += imos[i][j];
	ll ans = 0;
	rep(i,2*k) rep(j,2*k) chmax(ans,imos[i][j]);
	cout << ans << endl;
}

Measured memory_bytes: 33408
N = int(input())
W = []
for _ in range(N):
    W.append(input())

ans = True
for i in range(N):
    for j in range(N):
        if i != j and W[i] == W[j]:
            ans = False

for i in range(N - 1):
    if W[i][-1] != W[i + 1][0]:
        ans = False

if ans == True:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = a * b / 2;
    cout << ans << endl;
}

Measured memory_bytes: 3624
n = int(input())
a = list(map(int, input().split()))
count = {}
for i in range(len(a)):#番号と身長を引く
    minus = (i+1) - a[i]
    if minus in count:
        count[minus] += 1
    else:
        count[minus] = 1
total = 0
for i in range(len(a)):
    plus = a[i] + (i+1)
    if plus in count:
        total += count[plus]
print(total)


Measured memory_bytes: 40368
#include <iostream>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define AL 26
int main(){
  int d,i,j,sc=0;
  ll c[26],s[365][26],t[365];
  ll interval[26]={0};
  cin >> d;
  rep(i,AL) cin >> c[i];
  rep(i,d){
    rep(j,AL) cin >> s[i][j];
  }
  rep(i,d){
    cin >> t[i];
    t[i]--;
  }
  rep(i,d){
    rep(j,AL){
      interval[j]++;
      if(j==t[i]){
        sc += s[i][j];
        interval[j]=0;
      }
      sc -= interval[j]*c[j];
    }
    cout << sc << endl;
  }
  return 0;
}

Measured memory_bytes: 3696
import sys
readline = sys.stdin.readline
from math import log2
from itertools import accumulate
N, M = map(int, readline().split())
A = [list(map(int, readline().split())) for i in range(N)]
B = max(max(Ai) for Ai in A)
if M == 1:
    if N == 1 or all(A[i][0] < A[i+1][0] for i in range(N-1)):
        print("0")
    else:
        print("-1")
    exit(0)
logB = log2(B)
logBi = int(logB)
INF = 10**18
INFL = [INF]*(M - logBi-2)
def gen(P, t, L = min(logBi+2, M)):
    if t <= logB:
        # O(M log B)
        for k in range(t):
            P[:] = accumulate(P)
    else:
        # O(log^2 B)
        V = [1]*L # V[k] = C(i-j+t-1, i-j)
        for k in range(1, L):
            V[k] = V[k-1] * (t + k - 1)//k

        for i in range(L-1, 0, -1):
            P[i] += sum(P[j] * V[i-j] for j in range(i))
        if logBi+2 < M:
            P[logBi+2:] = INFL
T = [0]*N
ans = 0
P = [0]*M
for i in range(N-1):
    a0, a1 = A[i][:2]
    b0, b1 = A[i+1][:2]
    if a0 < b0:
        continue
    if a0 > b0:
        ans = -1
        break
    # a1 + a0*t0 = b1 + b0*t1 となる正の整数 t1 が存在するか
    t0 = T[i]
    v = max(t0*a0 + a1 - b1, 0)
    if v % b0 > 0:
        T[i+1] = t1 = (v + b0-1) // b0
        ans += t1
        continue

    # そのような t1 が存在するならばチェック

    t1 = v // b0
    if t0 <= t1:
        # A_i < f(A_{i+1}, t1-t0) となるか
        P[:] = A[i+1]
        gen(P, t1 - t0)
        if P <= A[i]:
            t1 += 1
    else:
        # f(A_i, t0-t1) < A_{i+1} となるか
        P[:] = A[i]
        gen(P, t0 - t1)
        if A[i+1] <= P:
            t1 += 1
    T[i+1] = t1
    ans += t1
print(ans)

Measured memory_bytes: 43252
N, a, b = map(int, input().split())
count = 0
for i in range(1, N + 1):
   str_i = str(i)
   sum_i = 0
   for part in str_i:
      sum_i += int(part)
   if (sum_i >= a) and (sum_i <=b):
      count += i
print(count)

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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,x,y,z;
    cin >> n >> x >> y >> z;
    int good=(1<<(x+y+z-1))+(1<<(y+z-1))+(1<<(z-1));
    int sz=(1<<(x+y+z));
    const ll mod=1000000007;
    vector<ll> now(sz,0);
    now[0]=1;
    for(int i=1;i<=n;i++)
    {
        vector<ll> nxt(sz,0);
        for(int j=1;j<=10;j++)
        {
            for(int m=0;m<sz;m++)
            {
                int a=((m<<j)+(1<<(j-1)))&(sz-1);
                if((a&good)!=good) nxt[a]=(nxt[a]+now[m])%mod;
            }
        }
        now=nxt;
    }
    ll res=1;
    for(int i=1;i<=n;i++) res=(10*res)%mod;
    for(int i=0;i<sz;i++) res=(res-now[i]+mod)%mod;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 2304
from itertools import groupby
s=input()
k=int(input())
l=len(s)
g=groupby(s)
a=[]
for i,j in g:
  a.append(len(list(j)))
if len(a)==1:
  x=len(s)*k
  if x%2==0:
    print(x//2)
  else:
    print((x-1)//2)
else:
  c=0
  for i in a:
    if i%2==0:
      t=i//2
    else:
      t=(i-1)//2
    c+=t
  if s[0]==s[l-1] and k!=1:
    a[0]=a[0]+a[len(a)-1]
    a=a[:len(a)-1]
    z=0
    for i in a:
      if i%2==0:
        t=i//2
      else:
        t=(i-1)//2
      z+=t
    print(z*(k-1)+c)
  else:
    print(c*k)  

Measured memory_bytes: 3064
import java.io.File
import java.io.FileInputStream
import java.io.InputStreamReader

fun main() {
    val k = readInt()
    var summation = 0L

    fun gcd(a: Long, b: Long): Long {
        if (b == 0L) return a
        return gcd(b, a % b)
    }

    for (i in 1..k) {
        for (j in 1..k) {
            for(l in 1..k) {
                summation += gcd(gcd(i.toLong(), j.toLong()), l.toLong())
            }
        }
    }

    println(summation)
}

// Input Reader
private fun readLn() = readLine()!!
// Read from file
//private val inputReader = InputStreamReader(FileInputStream(File("input.txt")))
//private val lines = inputReader.readLines()
//private var currLine = -1
//private fun readLn(): String {
//    currLine++
//    return lines[currLine]
//}

private fun readStrings() = readLn().trim().split(" ")
private fun readInt() = readLn().toInt()
private fun readInts() = readStrings().map { it.toInt() }


Measured memory_bytes: 34668
input_line = input().split()

num_array = int(input_line[0])
num_equal = int(input_line[1])

input_line = input() # 無視

equalized = 1
i = 0
while equalized < num_array:
    equalized += (num_equal - 1)
    # print(i, equalized)
    i += 1

print(str(i))


Measured memory_bytes: 4724
def main():
  n = int(input())
  vs = list(map(int, input().split()))
  avs = [abs(v) for v in vs]
  mvs = [v for v in vs if v < 0]
  
  mvs_len = len(mvs)
  avs_sum = sum(avs)
  avs_min = min(avs)
  if mvs_len % 2 == 0:
    return avs_sum
  else:
    return avs_sum - avs_min * 2
    
  
print(main())

Measured memory_bytes: 14412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
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() {
  string s;
  cin >> s;
  int n = s.length();
  vector<vector<mint>> dp(100010, vector<mint>(2));
  mint ans = 1;
  dp[0][0] = 1;
  rep(i, n) {
    rep(j, 2) {
      int ni = i + 1, nj = j;
      
      if(nj == 0) {
        if(s[i] == '0') dp[ni][nj] += dp[i][j];
        else {
          dp[ni][nj] += dp[i][j] * 2;
          dp[ni][1] +=  dp[i][j];
        }

      } else {
        dp[ni][nj] += dp[i][j] * 3;
      }
    }
  }
  cout << dp[n][0] + dp[n][1] << endl;
}

Measured memory_bytes: 5760
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

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

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	a := scanInts(n)

	sum := make([]int, n+1)
	for i := 0; i < n; i++ {
		sum[i+1] = sum[i]+a[i]
	}

	cnt := make(map[int]int)

	ans := 0
	for i := 0; i < len(sum); i++ {
		ans += cnt[sum[i]]
		cnt[sum[i]]++
	}

	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 13824
fun main() {
    val a = nextInt()
    println(a+(a*a)+(a*a*a))
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(' ')
fun nextIntList() = nextList().map { it.toInt() }
fun nextLongList() = nextList().map { it.toLong() }
fun nextDoubleList() = nextList().map { it.toDouble() }


Measured memory_bytes: 34520
#include<iostream>
#include<string>
#include<cctype>
#include<algorithm>
#include<functional>
using namespace std;
bool C(char c){return isupper(c);}
int main()
{
	string s;
	string::iterator i;
	char c;
	int x;
	while(cin>>s>>c,c-'X')
	{
		s[0]=toupper(s[0]);
		while(x=s.find('_'),x!=string::npos)
			s.erase(x,1),s[x]=toupper(s[x]);
		if(c-'U')s[0]=tolower(s[0]);
		if(c=='D')
			for(i=s.begin();(i=find_if(i,s.end(),ptr_fun(C)))!=s.end();++i)
				*i=tolower(*i),i=s.insert(i,'_');
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>

#define BASE (1000000)
typedef long long lint;

int main()
{
    int n, m, r;
    int head, tail;
    int i, j;
    static lint ans[20000], temp[20000];
    lint carry;
    
    tail = sizeof(ans) / sizeof(lint) - 1;
    
    scanf("%d%d%d", &n, &m, &r);
    
    if (r - m * n < 0 || n + r - m * n - 1 < 0){
        printf("0\n");
    }
    else {
        head = tail;
        ans[tail] = 1;
        
        //nCkを求める. n!
        for (i = 1; i <= n + r - m * n - 1; i++){
            carry = 0;
            for (j = tail; j >= head; j--){
                carry += i * ans[j];
                ans[j] = carry % BASE;
                carry /= BASE;
            }
            while (carry != 0){
                ans[--head] = carry % BASE;
                carry /= BASE;
            }
        }
        
        
        //k!
        for (i = r - m * n; i >= 2; i--){
            memcpy(temp, ans, sizeof(ans));
            carry = 0;
            for (j = head; j <= tail; j++){
                carry = carry * BASE + temp[j];
                ans[j] = carry / i;
                carry %= i;
            }
        }
        
        //(n - k)!
        for (i = n - 1; i >= 2; i--){
            memcpy(temp, ans, sizeof(ans));
            carry = 0;
            for (j = head; j <= tail; j++){
                carry = carry * BASE + temp[j];
                ans[j] = carry / i;
                carry %= i;
            }
        }
        
        while (ans[head] == 0){
            head++;
        }
        
        
        for (i = head; i <= tail; i++){
            if (i != head){
                printf("%06lld", ans[i]);
            }
            else {
                printf("%lld", ans[i]);
            }
        }
        printf("\n");
    }
    
    return (0);
}

Measured memory_bytes: 1316
#include <stdio.h>

int main(void)
{
	char x;
	int i;
	int a = 0, b = 0, c = 0;

	for(int i = 0; i < 3; i++) {
		x = getchar();
		if(x == 'a') { a++; }
		if(x == 'b') { b++; }
		if(x == 'c') { c++; }
	}

	if(a && b && c) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const int MOD=998244353;
int main(){
    ll n,m;
    cin>>n>>m;
    cout<<abs((n-2)*(m-2))<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using s64 = int64_t;
using u64 = uint64_t;

int main() {
	string S;
	cin >> S;
	
	if(S[2] != S[3]) {
		cout << "No";
	} else if(S[4] != S[5]) {
		cout << "No";
	} else {
		cout << "Yes";
	}
	
	return 0;
}

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

int main(){
  int n;cin>>n;
  vector<int>h(n);
  for(int i=0;i<n;i++)
    cin>>h.at(i);
  vector<int>dp(n,-1);
  dp.at(0)=0;
  dp.at(1)=abs(h.at(0)-h.at(1));
  for(int i=2;i<n;i++)
    dp.at(i)=min(dp.at(i-1)+abs(h.at(i)-h.at(i-1)),dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
  cout <<dp.at(n-1)<<endl;
}

Measured memory_bytes: 1024
n = int(input())
x = sorted(list(map(int,input().split())))

z = sum(x)//n
z2 = z + 1
ans1 = 0
ans2 = 0
for i in range(n):
	ans1 += (x[i] - z)**2
for i in range(n):
	ans2 += (x[i] - z2)**2
	
print(min(ans1,ans2))


Measured memory_bytes: 3060
s = input()
N = 2**(len(s) - 1)
ans = 0
for n in range(N):
    li, ci = 0, 0
    while n > 0:
        if n & 1 == 1:
            ans += int(s[li:ci + 1])
            li = ci + 1
        n = n >> 1
        ci += 1
    ans += int(s[ci:])

print(ans)

Measured memory_bytes: 39280
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] A = Console.ReadLine().Split();
            int x0 = int.Parse(A[0]);
            int x1 = int.Parse(A[1]);
            int x2 = int.Parse(A[2]);
            if(x0+x1+x2<22)
            {
                Console.WriteLine("win");
            }
            else
            {
                Console.WriteLine("bust");
            }
        }
    }
}


Measured memory_bytes: 27180
n,h,w=map(int,input().split())
x=list(map(int,input().split()))
wide_total=n*w
wide_cover=[False]*wide_total

for i in range(n):
    if (i+1)%2==1:
        for j in range(i*w+x[i],i*w+x[i]+w):
            wide_cover[j]=True
    else:
        for j in range(i*w-x[i],i*w-x[i]+w):
            wide_cover[j]=True
cnt=0
for c in wide_cover:
    if c==False:
        cnt+=1

print(cnt*h)



Measured memory_bytes: 5648
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <cstdlib>

using namespace std;

int main(){

	string o,e;
	cin >> o >> e;

	string a;
	int n;
	n = o.size();

	if(o.size() == e.size()){
		for(int i = 0; i < n; i++){
		a = a + o.front() + e.front();
		o.erase(o.begin());
		e.erase(e.begin());
		}
	}
	else{
		for(int i = 0; i < n-1; i++){
		a = a + o.front() + e.front();
		o.erase(o.begin());
		e.erase(e.begin());
		}
		a += o.front();
	}
	cout << a <<endl;

	return 0;
}

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

void deleteFirst(int**);
void deleteLast(int**);
void insertOne(int**, int**, int, int);
int deleteOne(int**, int**, int);

int main(void){
    int xs[2000001] = {};
    int* default_ptr = xs + 2000000;
    int* fp = default_ptr;
    int* lp = default_ptr;
    int len = 0;
    int n;
    char str[20];
    scanf("%d\n", &n);
    for(int i=0; i < n; ++i){
        fgets(str, sizeof(str), stdin);
        if(str[6] == 'F'){
            deleteFirst(&fp);
            --len;
        }else if(str[6] == 'L'){
            deleteLast(&lp);
            --len;
        }else{
            char *tp;
            int m;
            tp = strtok(str, " " );
            tp = strtok(NULL," ");
            sscanf(tp, "%d", &m);
            if(str[0] == 'i'){
                insertOne(&fp, &lp, m, len);
                ++len;
            }else if(deleteOne(&fp, &lp, m)){
                --len;
            }
        }
        
        if(len == 0){
            fp = default_ptr;
            lp = default_ptr;
        }
    }
    
    for(int i = 0; i < lp - fp; ++i){
        if(*(fp + i) != -1){
            printf("%d ", *(fp + i));
        }
    }
    printf("%d\n", *lp);
}

void deleteFirst(int** fp){
    **fp = -1;
    while(**fp == -1) ++*fp;
}

void deleteLast(int** lp){
    **lp = -1;
    while(**lp == -1) --*lp;
}

void insertOne(int** fp, int** lp, int m, int len){
    if(len == 0){
        **fp = m;
    }else{
        --*fp;
        **fp = m;
    }
}

int deleteOne(int** fp, int** lp, int m){
    for(int j = 0; j <= *lp - *fp; ++j){
        if(*(*fp + j) == m){
            *(*fp + j) = -1;
            if(j == 0){
                while(**fp == -1) ++*fp;
            }else if((*fp + j) == *lp){
                while(**lp == -1) --*lp;
            }
            return 1;
        }
    }
    return 0;
}

Measured memory_bytes: 9568
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#define ll long long
//vector<int> g1;
//g1.push_back(i);

using namespace std;

int main()
{
	int a,b;
	cin >> a >> b;
	if (a+b==1+2) cout << 3;
	if (a+b==1+3) cout << 2;
	if (a+b==2+3) cout << 1;
	return 0;
}



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

void chmax(ll &a, ll b)
{
    if (b > a)
        a = b;
    return;
}

int main()
{
    // 入力
    int n, w;
    cin >> n >> w;
    vector<ll> value(n), weight(n);
    rep(i, n) cin >> value[i] >> weight[i];
    vector<vector<ll>> dp(110, vector<ll>(100100));

    rep(i, n) for (int j = 0; j <= w; j++)
    {
        if (j >= weight[i])
            chmax(dp[i + 1][j], dp[i][j - weight[i]] + value[i]);

        chmax(dp[i + 1][j], dp[i][j]);
    }

    cout << dp[n][w] << endl;

    return 0;
}


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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;


signed main(){
    int a, b, c, d, n, m, x, y, h, w;
    string s, t;


    auto Yes = [&](bool t){
        cout << (t ? "Yes" : "No") << endl;
    };
    auto YES = [&](bool t){
        cout << (t ? "YES" : "NO") << endl;
    };
    auto tri = [&](bool t, string a, string b){
        cout << (t ? a : b) << endl;
    };

    cin >> n >> m;
    int ans = 1;
    for(int i = 0; i < n; ++i)
        ans *= (i ? m - 1 : m);
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>


using namespace std;


int K, A, B;

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

	bool ans = (A % K == 0 || B % K == 0) || (A / K != B / K);

	cout << (ans ? "OK" : "NG") << endl;

	return 0;
}


Measured memory_bytes: 3632
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
 
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}
//}}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c;
	cin >> a >> b >> c;
	reps(i,a*b){
		if(i * a % b == c){
			cout << "YES\n";
			return 0;
		}
	}
	cout << "NO\n";
	return 0;
}


Measured memory_bytes: 256
from collections import deque

k = int(input())
seen = [False]*k
dq = deque()
dq.append((1, 1))
ans = 0
while dq:
  v, s = dq.popleft()
  if seen[v]:
    continue
  seen[v] = True
  if v == 0:
    ans = s
    break
  nv1, nv2 = (v*10)%k, (v+1)%k
  dq.appendleft((nv1, s))
  dq.append((nv2, s+1))
print(ans)

Measured memory_bytes: 14444
import itertools
N = int(input())
L = list(map(int, input().split()))

list1 = list(itertools.combinations(L, 3))
count=0
for i in list1:
    if i[0] != i[1] and i[1] != i[2] and i[2] != i[0]:
        if i[0] + i[1] <= i[2]:
            continue
        
        if i[0] + i[2] <= i[1]:
            continue
        
        if i[2] + i[1] <= i[0]:
            continue
    
        count+=1
    else:
        continue
print(count)

Measured memory_bytes: 20616