akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <string>
using namespace std;
int main(){
    int n;
    cin>>n;
    long long sum = 0;
    for(int i=1; i<=n; i++){
        if((i%3==0) || (i%5==0) ) continue;
        else{
            sum += i;
        }
    }
    cout<<sum<<endl;
    return 0;
}




Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StackControler readDataArr = new StackControler(in.readLine()
				.split(" "));
		System.out.println(readDataArr.calcData());
	}
}

class Stack {
	private int[] stack;
	private static int pointer = 0, popData, remover = 0;

	Stack(int[] stack) {
		this.stack = stack;
	}

	public void push(int data) {
		stack[pointer] = data;
		pointer++;
	}

	public int pop() {
		pointer--;
		popData = stack[pointer];
		stack[pointer] = remover;// pop????????????data?????????
		return popData;
	}

}

class StackControler {
	private Stack stack;
	private String[] readData;
	private int operand2, operand1, result, strToIntData;

	StackControler(String[] readData) {
		this.readData = readData;
	}

	public int calcData() {
		String tempStrData;
		stack = new Stack(new int[readData.length / 2 + 1]);
		for (int i = 0; i < readData.length; i++) {
			tempStrData = readData[i];

			switch (tempStrData) {
			case "+":
				operand1 = stack.pop();
				operand2 = stack.pop();
				result = operand2 + operand1;
				stack.push(result);
				break;
			case "-":
				operand1 = stack.pop();
				operand2 = stack.pop();
				result = operand2 - operand1;
				stack.push(result);
				break;
			case "*":
				operand1 = stack.pop();
				operand2 = stack.pop();
				result = operand2 * operand1;
				stack.push(result);
				break;
			default:
				strToIntData = Integer.parseInt(readData[i]);
				stack.push(strToIntData);
			}
		}
		result = stack.pop();
		return result;
	}
}

Measured memory_bytes: 24452
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] a = new int[m];
        int[] b = new int[m];
        int[] result = new int[n];
        for (int i = 0; i < m; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            result[i] = 0;
        }

        for (int i = 0; i < m; i++) {
            result[a[i] - 1]++;
            result[b[i] - 1]++;
        }

        for (int i = 0; i < n; i++) {
            System.out.println(result[i]);
        }
    }

}


Measured memory_bytes: 21844
#include <stdio.h>

int main(void){

  char s[4];
  char t[4];
  scanf("%s", s);
  scanf("%s", t);

  int count = 0;
  for (int i = 0; i < 3; i++) {
    if (s[i] == t[i]) {
      count++;
    }
  }
  printf("%d\n", count);

  return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

#define PI (2*acos(0.0))
#define eps 1e-9
#define pb push_back
#define endl "\n"
#define watch(x) cout << (#x) << " is " << (x) << endl;
#define show(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi] << " "; cout << endl;
#define showpair(v) for(int fi = 0; fi < v.size(); fi++) cout << v[fi].first << " " << v[fi].second << endl;
#define mp make_pair
#define ff first
#define ss second
#define fu cout << "lol" << endl;
#define precision(n) cout << fixed << setprecision(n);
#define lb lower_bound
#define up upper_bound
#define vscan for(i = 0;i<n;i++){cin>>in; v.pb(in);}
#define all(a) a.begin(), a.end()
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define mem(a,val) memset(a,val,sizeof(a))
#define loop(i,n) for(i = 0; i < n; i++)
#define TC() ull T; cin>>T; while(T--)
#define IN(x) {scanf("%d",&x);}
#define LL(x) {scanf("%lld",&x);}
#define CC(x) {scanf("%c",&x);}
#define pfl(x) printf("%d\n",x)
#define pfll(x) printf("%lld\n",x)
#define newl puts("")
#define space printf(" ")
#define MOD 1000000007
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL);


int main()
{
    int i = 0, j = 0, in;
    int n; cin>>n;
    vi v; vscan;
    int ans = INT_MAX;
    for(i = 1; i <= 100; i++){
        int cnt = 0;
        for(auto j : v){
            cnt += (j - i)*(j-i);
        }
        ans = min(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func nextString() string {
    sc.Scan()
    return sc.Text()
}

func main() {
    buf := make([]byte, 0)
    sc.Buffer(buf, 4000000)
    sc.Split(bufio.ScanWords)
    s := nextString()
    var answer string
    if (s == "Sunny") {
       answer = "Cloudy" 
    }
    if (s == "Cloudy") {
       answer = "Rainy" 
    }
    if (s == "Rainy") {
       answer = "Sunny" 
    }
    
    fmt.Println(answer)
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int A, B, C; cin>>A>>B>>C;
  int tmp = min(A, B+C);
  int ans = C -	(tmp - B);
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 888
n = int(input())
a = list(map(int,input().split()))
if a[-1] == 0:
    print(-1)
    exit()

if a[0] == 1 and n == 0:
    print(1)
    exit()
elif a[0] >= 1:
    print(-1)
    exit()

par = [0]*(n+1)
par[0] = 1
for i in range(1,n+1):
    par[i] = par[i-1]*2-a[i]
    if par[i] < 0:
        print(-1)
        exit()

ret = a[-1]
suc = a[-1]
for i_ in range(n):
    i = n-1-i_
    ret += min(suc,par[i]) + a[i]
    suc = min(suc,par[i]) + a[i]

print(ret)

Measured memory_bytes: 700052
# coding: utf-8
# Your code here!

import itertools 
from collections import defaultdict

H, W, K = map(int, input().rstrip().split(' '))


w = [[0] * 3 for _ in range(W)]
patterns = itertools.product([0, 1], repeat=W-1)

if W > 1:
    for i in range(W):
        for k, j in enumerate([-1, 0, 1]):
            if i - j < 0 or i - j > W - 1:
                continue
            
            num_use_pattern = 0
            for pattern in itertools.product([0, 1], repeat=W-1):
                if j == -1:
                    if i - 1 < 0: 
                        if pattern[i] == 0:
                            continue
                    else:
                        if not (pattern[i-1] == 0 and pattern[i] == 1):
                            continue
                elif j == 1:
                    if i >= W - 1:
                        if pattern[i-1] == 0:
                             continue
                    else:
                        if not (pattern[i-1] == 1 and pattern[i] == 0):
                            continue
                else:
                    if i - 1 < 0: 
                        if pattern[i] == 1:
                            continue
                    elif i >= W - 1:
                        if pattern[i-1] == 1:
                             continue
                    else:
                        if pattern[i] == 1 or pattern[i-1] == 1:
                            continue
                   
                if sum([pattern[l] * pattern[l-1] for l in range(1, W-1)]) > 0:
                    continue
                
                num_use_pattern += 1
                
            w[i][k] += num_use_pattern
     
    memo = defaultdict(lambda: defaultdict(lambda: -1))
    def recursive(h, k, num_p):
        if 0 > k or k >= W:
            return 0
        if memo[h][k] != -1:
            return memo[h][k] * num_p
        if h == H:
            if k == K - 1:
                return num_p
            else:
                return 0
             
        temp1 = 0
        temp2 = 0
        temp3 = 0
        temp1 = recursive(h + 1, k, w[k][1])
        if k > 0:
            temp2 = recursive(h + 1, k - 1, w[k][2])
        if k <= W - 1:
            temp3 = recursive(h + 1, k + 1, w[k][0])
            
        temp = temp1 + temp2 + temp3
        memo[h][k] = temp
        
        return temp * num_p
     
    print(recursive(0, 0, 1) % 1000000007)
else:
    print(1)


Measured memory_bytes: 3436
#include <iostream>
#include <fstream>
#include <string> 
#include <cstring>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>

#define BIT(a) (1 << (a))

using namespace std;

long long MOD = 1000000007;

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

int main(void){
    int A, B, X;
    cin >> A >> B >> X;
    
    if (A <= X && X <= A+B){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e6+5;
const int INF = 0x3f3f3f3f;
typedef long long LL;

int cnt[maxn];

int main(void)
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        for(int j=1;1ll*j*i<=n;j++)
            cnt[i*j]++;
    LL ans = 0;
    for(int i=1;i<n;i++){
        // printf("%d\n",cnt[i]);
        ans += cnt[i];
    }
    printf("%lld\n",ans);
}



Measured memory_bytes: 7624
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int N = 0;
    int V[50];
    int C[50];

    //数
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> V[i];
    }
    for(int i = 0; i < N; i++){
        cin >> C[i];
    }

    int sum = 0;
    for(int i = 0; i < N; i++){
        int tmp = V[i] - C[i];
        sum += tmp > 0 ? tmp : 0;
    }


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

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <deque>
#include <string>
using namespace std;
typedef deque <string> sdeque;


int sdeque_out(sdeque &A){
    int n=A.size();
    for (int i=0; i<n; i++){
        cout << A[i];
        if (i!= n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}

int main(void){
	int n;
	string text = "";
	sdeque que;
	sdeque::iterator pos;
	
	cin >> n;
	getline(cin, text);

	for (int i=0; i<n; i++){
		getline(cin, text);

		if (text[0]== 'i')
			que.push_front(text.substr(7));
		else switch(text[6]){
			case ' ':
				pos = find( que.begin(), que.end(), text.substr(7) );
				if (pos != que.end()) que.erase(pos);
				break;
			case 'F':
				que.pop_front();
				break;
			case 'L':
				que.pop_back();
				break;
		}
	}

	sdeque_out(que);
	return 0;
}

Measured memory_bytes: 56184
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

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

    int a, b;
    cin >> a >> b;
    cout << max(0, a - (b << 1)) << endl;

    cout << flush;

    return 0;
}

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

using namespace std;

using ll =int64_t;

int main()
{
    ll n;
    cin>>n;
    vector<ll>d(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>d[i];
    }
    ll even_sum=0,odd_sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%2==0)
            even_sum+=d[i];
        else
            odd_sum+=d[i];
    }
    vector<ll>m(n+1);
    m[1]=abs(odd_sum-even_sum);
    for(int i=2;i<=n;i++)
    {
        m[i]=2*d[i-1]-m[i-1];
    }
    for(int i=1;i<=n;i++)
    {
        cout<<m[i]<<' ';
    }
}


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

#define ll     long long
#define fr     first
#define sec    second
#define rep(i,n)  for(i=0;i<n;i++)
#define vi     vector <int>
#define vc     vector <char>
#define vl     vector <ll>
#define vb     vector <bool>
#define pb     push_back
#define M      1000000007
#define ios    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define open   freopen("input.txt","r",stdin);
#define close  freopen("output.txt","w",stdout);
#define M_PI   3.14159265358979323846
#define pp     pair<int,int>
#define nn 100003
#define MM 1000000000
#define MN 1000000000000000000

int main()
{
    ios;
    ll n;
    cin>>n;
    if(n%1000==0)
        cout<<"0";
    else
    {
        ll ans=1000-n%1000;
        cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define all(c) (c).begin(), (c).end()

int main(){
    int N; cin >> N;
    vector<string> S,ans;
    for (int i = 0; i < N; i++) {
        string s; cin >> s;
        S.push_back(s);
    }
    sort(all(S));
    int c = 0,max = 0;
    for (int i = 0; i < N; i++) {
        while (i < N-1 && S[i].compare(S[i+1]) == 0) {
            i++; c++;
        }
        if(c > max) {
            max = c;
            ans.clear();
            ans.push_back(S[i]);
        }else if(max == c) {
            ans.push_back(S[i]);
        }
        c = 0;
    }
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i] << "\n";   
    }
}

Measured memory_bytes: 15984
package main

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

func solve() {
	n := scanInt()
	k := scanInt()
	ans := n % k
	if ans > k-ans {
		ans = k - ans
	}
	fmt.Println(ans)

}

var sc = bufio.NewScanner(os.Stdin)

func read() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func main() {
	sc.Split(bufio.ScanWords)
	solve()
}


Measured memory_bytes: 640
fun main(args: Array<String>) {
    a47(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

fun a47(args: Array<String>) {
    if (args.size != 1) {
        throw IllegalArgumentException()
    }
    val sizeList = args[0].split(" ").map { it.toInt() }.sortedDescending()
    print(if (sizeList[0] == sizeList[1] + sizeList[2]) "Yes" else "No")
}


Measured memory_bytes: 38164
//17.05.2020 15:41:42

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

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


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, a, b, c, d;
  	cin >> N;
  	a = N / 1000;
    b = (N - 1000 * a) / 100;
    c = (N - 1000 * a - 100 * b) / 10;
    d = N - 1000 * a - 100 * b - 10 * c;
	
  	if ( (a == b && b == c) || (b == c && c == d) ) {
      cout << "Yes" << endl;
    }
  	else {
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      int x = sc.nextInt();
 
      int[] a;
      a = new int[m];
      for (int i = 0; i < m ; i++) {
         int s = sc.nextInt();
         a[i] = s;
      }
 
      int costl = 0;
      int i = 0;
 
      while (a[i] < x) {
         costl ++;
         i ++;
      }
 
      int costr = m - i;
 
      if (costl <= costr) {
          System.out.println(costl);
      }
      else {
          System.out.println(costr);
      }
   }
}

Measured memory_bytes: 21972
import sys
input=sys.stdin.readline
def knapsack(N,W,weight,value):
  dp=[[float('inf') for i in range(W+1)] for j in range(N+1)]
  for i in range(W+1):
    dp[0][i]=0
 
  for i in range(N):
    for w in range(W+1):
      if weight[i]<=w:
        if dp[i][w-weight[i]]+value[i]>dp[i][w]:
          dp[i+1][w]=dp[i][w-weight[i]]+value[i]
        else:
          dp[i+1][w]=dp[i][w]
      else:
        dp[i+1][w]=dp[i][w]
  return dp
 
n,t=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
l.sort()
a=[];b=[]
for i in range(n):
  a.append(l[i][0])
  b.append(l[i][1])
dp=knapsack(n,t-1,a,b)
ans=[]
for i in range(n):
  if i!=n:
    ans.append(dp[i][t-1]+b[i])
  else:
    ans.append(dp[n][t])
print(max(ans))

Measured memory_bytes: 268552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

static const int MAX = 1e+7;

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    for(int j = 1; j <= n; j++){
        ll y = n / j;
        sum += j * y * (y+1) / 2;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int a,b; cin >> a >> b;
	if(a*b%2) cout << "Odd" << endl;
	else cout << "Even" <<  endl;
}


Measured memory_bytes: 384
from collections import Counter

N = int(input())
A = [int(i) for i in input().split()]

C = Counter(A)
ret = len(C)

cnt = []
for v in C.values() :
    if v >= 2 :
        cnt.append(v - 1)

s = sum(cnt)
for c in cnt :
    if c > s // 2 :
        ret -= (2 * c - s) % 2
        break
else :
    ret -= s % 2
        
print(ret)

Measured memory_bytes: 62124
def modelAnswer(s:list) -> int:
   white = "1"
   ans_w = 0
   black = "0"
   ans_b = 0
   for i in s:
      if(i != white):
         ans_w +=1
      else:
         ans_b += 1
      white = "0" if(white == "1") else "1"
      black = "0" if(black == "1") else "1"
   return min(ans_b,ans_w)

def main():
   s = list(input())
   print(modelAnswer(s))

if __name__ == '__main__':
   main()

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

int main() {
  long N, X, M;
  cin >> N >> X >> M;
  
  long ans = 0;
  vector<pair<long, long>> pre(M);

  for (long i = 0; i < N; i++) {
    auto [p_i, p_ans] = pre.at(X);
    if (!p_i) {
      pre.at(X) = {i, ans};
    } else {
      long len = i - p_i;
      long cnt = (N - i - 1) / len;
      ans += (ans - p_ans) * cnt;
      i += len * cnt;
    }
    ans += X;
    X = X * X % M;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4844
def main():
    n = int(input())
    d = {'AC':0,'WA':0,'TLE':0,'RE':0}
    for _ in range(n):
        d[input()] += 1
    print("AC x {}".format(d['AC']))
    print("WA x {}".format(d['WA']))
    print("TLE x {}".format(d['TLE']))
    print("RE x {}".format(d['RE']))

main()

Measured memory_bytes: 9192
import sys
def input():
	return sys.stdin.readline()[:-1]

n, k = map(int, input().split())
d = 31
z = [list(map(int, input().split())) for _ in range(n)]
used = [True for _ in range(n)]
dp = [[0 for _ in range(2)] for _ in range(d)]
dp[d-1][1] = sum([x[1] for x in z])
for i in range(d-2, -1, -1):
	if (k>>i) % 2 == 1:
		dp[i][1] = dp[i+1][1]
		tmp = 0
		for j in range(n):
			if used[j] == True and (z[j][0]>>i) % 2 == 0:
				tmp += z[j][1]
		if tmp == dp[i+1][1]:
			dp[i][1] = 0
			used = [False] * n
		dp[i][0] = max(tmp, dp[i+1][0])
	else:
		dp[i][1] = dp[i+1][1]
		for j in range(n):
			if used[j] == True and (z[j][0]>>i) % 2 == 1:
				used[j] = False
				dp[i][1] -= z[j][1]
		dp[i][0] = dp[i+1][0]
print(max(dp[0]))

Measured memory_bytes: 30316
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <map>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

ll Pow(ll n) {
	ll ans = 1, a = n, k = 5;
	while (k > 0) {
		if (k & 1) {
			ans *= a;
		}
		a *= a;
		k >>= 1;
	}
	return ans;
}

void Ini(map<ll, ll> &mp) {
	ll i;
	for (i = -1000; i <= 1000; i++) {
		mp[i] = Pow(i);
	}
	return;
}

int main(void) {
	int num, i;
	ll a, b, x;
	cin >> x;
	for (a = -1000; a <= 1000; a++) {
		for (b = -1000; b <= 1000; b++) {
			if (Pow(a) - Pow(b) == x) {
				cout << a << " " << b << "\n";
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>

int main() {
	int w, n, i, p, *num, *a, *b;
	scanf("%d",&w);
	num = (int *)malloc( sizeof(int) * w );
	for(i=0;i<w;i++) {
		num[i] = i+1;
	}
	
	scanf("%d",&n);
	a = (int *)malloc( sizeof(int) * n );
	b = (int *)malloc( sizeof(int) * n );
	for(i=0;i<n;i++) {
		scanf("%d,%d",&a[i] ,&b[i] );
	}
	for(i=0;i<n;i++) {
		p = num[ a[i]-1 ];
		num[ a[i]-1 ] = num[ b[i]-1 ];
		num[ b[i]-1 ] = p;
	}
	for(i=0;i<w;i++) {
		printf("%d\n",num[i]);
	}
	free(num);
	free(a);
	free(b);
	return 0;
}

Measured memory_bytes: 0
a, b = map(int, input().split())
al = []
b_lis = []

for _ in range(a):
    g = list(map(int, input().split()))
    g.append(sum(g))
    al.append(g)
for i in range(b+1):
    p = 0
    for j in range(a):
        p += al[j][i]
    b_lis.append(p)
al.append((b_lis))
for i in al:
    print(' '.join([str(v) for v in i]))


Measured memory_bytes: 5700
N, A, B = map(int, input().split())
result = 0

for num in range(1, N+1):
    num_10000 = num // 10000
    num_1000 = (num - 10000*num_10000) // 1000
    num_100 = (num - 10000*num_10000 - 1000*num_1000) // 100
    num_10 = (num - 10000*num_10000 - 1000*num_1000 - 100*num_100) // 10
    num_1 = num - 10000*num_10000 - 1000*num_1000 - 100*num_100 - 10*num_10
    sum = num_1 + num_10 + num_100 + num_1000 + num_10000
    if A <= sum <= B:
        result += num
        
print(result)


Measured memory_bytes: 3060
s = input()
t = input()

ans = 100000
for start in range(len(s)-len(t)+1):
    substr = s[start:start+len(t)]

    cnt = len(t)
    for i in range(len(substr)):
        if t[i] == substr[i]:
            cnt -= 1
    ans = min(ans, cnt)

print(ans)


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

#define IOS		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ld 		    long double
#define ll 		    long long int
#define ull 	   	unsigned long long int
#define pb		    push_back
#define mp		    make_pair
#define F		    first
#define S		    second
#define lb		    lower_bound
#define ub		    upper_bound
#define deb(x)      cout<<"#x "<<x<<"\n";
#define trace(x,y)  cout<<"#x "<<x<<" #y "<<y<<"\n";


const int mod = 1e9;
int n, m;

int main(){
    IOS;
    cin >> n>> m;
    ll h[n+1];
    for(int i = 1; i<= n ;i++)cin >> h[i];
    vector <int> g(n+1);
    int p[n+1];
    memset(p,0,sizeof(p));
    for(int i = 0; i < m ;i++){
        int u, v;
        cin >> u >> v;
        if(h[u] < h[v]){
            p[u] = -1;
        }
        else if(h[v] < h[u]){
            p[v]=-1;
        }
        else if(h[u] == h[v]){
            p[v] = p[u] = -1;
        }
        
    }
    long long ans =0;
    for(int i = 1; i<=n ;i++){
        if(p[i] == 0)ans++;
    }
    cout<<ans<<"\n";

return 0;
}


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

int main() {
    int N, n, fn = 0;
    cin >> N;
    n = N;
    while(true) {
        fn += n % 10;
        if (n < 10) break;
        n /= 10;
    }
    if (N % fn == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N,D;
signed main() {
    cin>>N>>D;
    cout<<N/(D*2+1)+(N%(D*2+1)==0?0:1)<<endl;
}


Measured memory_bytes: 256
class PERM_COMB_MOD():
    # http://drken1215.hatenablog.com/entry/2018/06/08/210000
    def __init__(self, max_n=510000, mod=10**9+7):
        self.fac = [0]*max_n
        self.finv = [0]*max_n
        self.inv = [0]*max_n
        self.fac[0] = self.fac[1] = 1
        self.finv[0] = self.finv[1] = 1
        self.inv[1] = 1
        self.max = max_n
        self.mod = mod
        self._maesyori()

    def _maesyori(self):
        for i in range(2,self.max):
            self.fac[i] = self.fac[i-1] * i % self.mod
            self.inv[i] = self.mod - self.inv[self.mod % i] * (self.mod // i) % self.mod
            self.finv[i] = self.finv[i-1] * self.inv[i] % self.mod

    def comb(self, n, k):
        if n < k : return 0
        if n < 0 or k < 0:return 0
        return self.fac[n] * (self.finv[k] * self.finv[n-k] % self.mod) % self.mod

mod = 10**9+7

n = int(input())
p = PERM_COMB_MOD(n+10)
a = list(map(int, input().split()))
d = {}
l=r=None

for i, ai in enumerate(a):
    if ai in d:
        l = d[ai]
        r = i
        break
    else:
        d[ai] = i

s = l+n-r

for k in range(n+1):
    ans = p.comb(n+1, k+1) - p.comb(s, k)
    print(ans%mod)

Measured memory_bytes: 32588
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N;
string S[100005];

int k[100005];
string rules[100005];

//               ch1 < ch2 なら　小さくなる
int memo[100005][26][26];

struct node {
	node *next[26] = {};
	int num[26];
	int fin;
};
node *root = new node();
 
void add(string s) {
	node *curr = root;
	for (char c : s) {
		if (curr->next[c - 'a'] == NULL) {
			curr->next[c - 'a'] = new node();
			for(int i = 0; i < 26; i++){
				curr->next[c-'a']->num[i] = 0;
			}
			curr->next[c-'a']->fin = 0;
		}
		curr->num[c-'a']++;
		curr = curr->next[c - 'a'];
	}
	curr->fin++;
}

long long count(int kdx, string rule){
	long long ret = 0;
	for(int i = 0; i < 26; i++){
		for(int j = i + 1; j < 26; j++){
			int ch1 = rule[i] - 'a';
			int ch2 = rule[j] - 'a';
			ret += memo[kdx][ch1][ch2];
		}
	}
	return ret + memo[kdx][0][0] + 1;

}


void create_table(int idx){
	node *curr = root;

	for (char c : S[idx] ) {
		long long tmp = 0;
		for(int i = 0; i < 26; i++){
			if(i != c - 'a'){
				memo[idx][i][c-'a'] += curr->num[i];
			}
		}
		memo[idx][0][0] += curr->fin;
		curr = curr->next[c - 'a'];
	}


}



int main(){
	cin >> N;

	//400000
	for(int i = 0; i < N; i++){
		cin >> S[i];
		add(S[i]);
	}

	for(int i = 0; i < N; i++){
		create_table(i);
	}


	long long Q;
	cin >> Q;
	for(int i = 0; i < Q; i++){
		cin >> k[i] >> rules[i];
		k[i]--;
	}

	/*
	for(int i = 0; i < N; i++){
		cout << "i=" << i  << endl;
		for(int j = 0; j < 26; j++){
			for(int k = 0; k < 26; k++){
				cout << "memo[" << i << "][" << (char)('a' + j) << "][" << (char)('a' + k) << "]=" << memo[i][j][k] << endl;
			}
		}
	}
	*/

	//1e5
	for(int i = 0; i < Q; i++){
		cout << count(k[i], rules[i]) << endl;
	}
}

Measured memory_bytes: 318080
import java.util.*;

public class Main {
	static int h;
	static int w;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		h = sc.nextInt();
		w = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
			if (check(sc.nextInt(), sc.nextInt())) {
				count++;
			}
        }
		System.out.println(count);
	}
	
	static boolean check(int hh, int ww) {
		if (hh >= h && ww >= w) {
			return true;
		}
		return false;
	}
}


Measured memory_bytes: 24244
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;

int N;
vvi eg;

void dfs(vi& vis, int t, int x, int px=-1) {
  vis[x] = t;

  for(int nx : eg[x]) {
    if (nx == px) continue;

    dfs(vis, t+1, nx, x);
  }
}

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


  int V,U; cin>>N>>U>>V;
  U--;V--;
  eg = vvi(N);
  REP(i,N-1) {
    int A,B;cin>>A>>B;
    A--;B--;
    eg[A].push_back(B);
    eg[B].push_back(A);
  }

  vi vt = vi(N, INF);
  dfs(vt, 0, U);
  vi va = vi(N, INF);
  dfs(va, 0, V);

  int ans = 0;
  REP(i,N) {
    if (vt[i] < va[i]) {
      ans = max(ans, va[i]);
    }
  }
  ans--;

  cout << ans << endl;


  return 0;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i, n){
        cin >> x[i];
        x[i] -= a;
    }
    lint dp[55][2505] = {0};
    dp[0][1250] = 1;
    REP(i, 1, n + 1){
        rep(j, 2501){
            if(0 <= j - x[i - 1] && j - x[i - 1] <= 2500){
                dp[i][j] = dp[i - 1][j] + dp[i - 1][j - x[i - 1]];
            }else{
                dp[i][j] = dp[i - 1][j];
            }
        }
    }
    cout << dp[n][1250] - 1LL << endl;
    return 0;
}

Measured memory_bytes: 1280
function main(input) {
    const args = input.split(' ');
    const a = parseInt(args[0], 10);
    const b = parseInt(args[1], 10);

    if ((a * b) % 2 === 0) {
        console.log('Even');
    } else {
        console.log('Odd');
    }
}

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

Measured memory_bytes: 22196
#include<bits/stdc++.h>
    using namespace std;
     
    int main() {
     int n;
      cin >> n;
      int a;
      cin >> a;
      int g = a;
      for(int i = 1;  i < n; ++i) {
        
        cin >> a;
        
        g = __gcd(a, g);
      }
      cout << g;
    }

Measured memory_bytes: 256
<?php
list($n) = ints();
$a = ints();
for ($i = 0; $i < $n; ++$i) {
    if (isset($cnt[$a[$i]])) $cnt[$a[$i]]++;
    else $cnt[$a[$i]] = 1;
}
$c = 0;
foreach ($cnt as $v) $c += $v - 1;
echo $c % 2 ? count($cnt) - 1 : count($cnt);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 18932
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

import Data.Int

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ n, k ] <- readInts
	vs <- readInts
	print $ solve k $ map fromIntegral vs

solve k vs' = runST $ do
	let
		n = length vs'
	vs <- newListArray ( 0, n - 1 ) vs' :: ST s ( STUArray s Int Int64 )
	dp <- newArray ( ( 0, -1, -1 ), ( k, n, n ) ) ( minBound `div` 2 :: Int64 ) :: ST s ( STUArray s ( Int, Int, Int ) Int64 )
	writeArray dp ( 0, 0, n - 1 ) 0
	forM_ [ 0 .. k - 1 ] $ \i -> do
		forM_ [ -1 .. n ] $ \j1 -> do
			forM_ [ -1 .. n ] $ \j2 -> do
				modifyArray dp ( i + 1, j1, j2 ) =<< max <$> readArray dp ( i, j1, j2 )
				when ( 0 <= j1 && j1 <= j2 && j2 < n ) $ do
					modifyArray dp ( i + 1, j1 + 1, j2 ) =<< max <$> ( (+)
						<$> readArray vs j1
						<*> readArray dp ( i, j1, j2 ) )
					modifyArray dp ( i + 1, j1, j2 - 1 ) =<< max <$> ( (+)
						<$> readArray vs j2
						<*> readArray dp ( i, j1, j2 ) )
					when ( i + 2 <= k ) $ do
						modifyArray dp ( i + 2, j1 + 1, j2 ) =<< max
							<$> readArray dp ( i, j1, j2 )
						modifyArray dp ( i + 2, j1, j2 - 1 ) =<< max
							<$> readArray dp ( i, j1, j2 )
	res <- newSTRef 0
	forM_ [ -1 .. n ] $ \j1 -> do
		forM_ [ -1 .. n ] $ \j2 -> do
			modifySTRef res =<< max <$> readArray dp ( k, j1, j2 )
	readSTRef res

Measured memory_bytes: 4092
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <iomanip>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
#define int ll

using namespace std;
using Graph = vector<vector<int> >;


signed main() {
  int N; cin >> N;
  string S; cin >> S;
  if (N < 3200) {
    cout << "red" << endl;
  } else {
    cout << S << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
using namespace std;

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 long long INF = 1LL << 60;

int main()
{
	int a,b,k;
	cin >> a >> b >> k;
	int res =0;
	int cnt = 0;
	for (int i = min(a,b);i>=1;i--) {
		if (a%i == 0 && b%i == 0) {
			res = i;
			cnt++;
		}
		if (cnt == k) {
			break;
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 256
import bisect

n = int(input())
l = [int(v) for v in input().split(' ')]
sum = 0
l.sort()
for i in range(n):
    for j in range(n):
        if i < j:
            ab = l[i] + l[j]
            index = bisect.bisect_left(l, ab)
            sum += index - j - 1
print(sum)


Measured memory_bytes: 3316
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int N=int.Parse(Console.ReadLine());
            string[] input=Console.ReadLine().Split();
            int []X=new int[N];
            for(int i=0;i<N;i++){
                X[i]=int.Parse(input[i]);
            }
            int ans=int.MaxValue;
            for(int i=0;i<100;i++){
                int temp=0;
                for(int j=0;j<N;j++){
                    temp+=(X[j]-i)*(X[j]-i);
                }
                ans=Math.Min(ans,temp);
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;  
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b){
    if (a < b){ a = b;return 1;}
    return 0;
}
template <class T, class U> //chmin(min,a)
bool chmin(T &a, U b){
    if (a > b){ a = b; return 1;}
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
   
// g++ -std=c++11 prac.cpp
        
int main(){
    ll b,c,n,x,y,m=-1,k,w,sum=1,ans=0,Max=-1e9,Min=1e9+1;
    string s,t,u;
    bool count=false,ok=true;
    VL a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(ALL(a));
    x = a[2] / 2;
    y = a[2] - x;
    cout << abs(a[0]*a[1]*x - a[0]*a[1]*y) << endl;
    return 0;
}

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

int main() {
  int64_t n, a = 0, b = 0, l = 0, r, s = 0, tmp1 = 0, tmp2, d = 0;
  cin >> n;
  vector<int64_t> v(n);
  rep(i, n){
    cin >> v[i];
    s += v[i];
  }
  rep(i, n){
    tmp1 += v[i];
    if(tmp1 > s / 2){
      tmp2 = tmp1;
      tmp1 -= v[i];
      r = i;
      break;
    }
  }
  rep(i, n){
    if(i < r) a += v[i]-1;
    else b += v[i]-1;
  }
  d = min(abs(tmp1 - (s - tmp1)), abs(tmp2 - (s - tmp2)));
  cout << d << endl;
  return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		String op = scan.next();
		int b = scan.nextInt();
		System.out.println((op.equals("+"))? a+b:a-b);
	}

}

Measured memory_bytes: 23764
#include <stdio.h>
#define MAX 250
int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

int main (){
  int i,n,A[MAX+1];

  scanf("%d",&n);
  for(i=1;i<=n;i++)
    scanf("%d",&A[i]);

  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i)>=1)
      printf("parent key = %d, ",A[parent(i)]);
    if(left(i)<=n)
      printf("left key = %d, ",A[left(i)]);
    if(right(i)<=n)
      printf("right key = %d, ",A[right(i)]);
  printf("\n");
  }
  return 0;
}






Measured memory_bytes: 2052
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  vector<vector<char>> vec(3,vector<char>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>vec[i][j];
    }
  }
  
  cout<<vec[0][0]<<vec[1][1]<<vec[2][2]<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
         
    int main() {
        string A;
        cin >> A;

        bool flag = false;
        if(A[0]=='7' || A[1]=='7' || A[2]=='7')
            flag = true;
        
        if(flag)    cout << "Yes" << endl;
        else        cout << "No" << endl;
        }

Measured memory_bytes: 3624
import sys
N = int(input())
A = [el for el in map(int,input().split())]
if 0 in A : 
    print(0)
    sys.exit(0)
res = 1
for el in A:
  res *= el
  if res - 10**18 > 0:
    print(-1)
    sys.exit(0)
print(res)


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

//keyence
int main(){
	string s; cin >> s;
	int n = 0;
	int l = s.length();
	if (l<7){
		cout << "NO";
		return 0;
	}
	if(s[0]=='k'){
		n++;
		if(s[1]=='e'){
			n++;
			if(s[2]=='y'){
				n++;
				if(s[3]=='e'){
					n++;
					if (s[4]=='n'){
						n++;
						if (s[5]=='c'){
							n++;
							if (s[6]=='e'){
								n++;
							}
						}
					}
				}
			}
		}
	}
	if (s[l-1]=='e'){
		n++;
		if(s[l-2]=='c'){
			n++;
			if(s[l-3]=='n'){
				n++;
				if(s[l-4]=='e'){
					n++;
					if(s[l-5]=='y'){
						n++;
						if(s[l-6]=='e'){
							n++;
							if (s[l-7]=='k'){
								n++;
							}
						}
					}
				}
			}
		}
	}
	if (n>=7)cout << "YES";
	else cout << "NO";
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    char S[5];
    cin >> S;
    char tmp ='A'; //char型はシングルクォーテーション
    string judge;
    judge = "Good";
    for(int i=0; i<4; i++){
        if (tmp ==S[i]){
            judge = "Bad";
        }
        tmp = S[i];
    }
    cout << judge;
}

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


int main(){
                                                                     

    int a, b;

    char op;


    cin >> a >> op >> b;


    if( op == '+' ) cout << a + b << endl;

    else cout << a - b << endl;


    return 0;

    }

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

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

    int s = 0, t = 0;
    for (int64_t x = n; x > 0;) {
        if (x < 10) {
            t += x % 10 - 1;
        } else {
            t += 9;
        }
        s += x % 10;
        x /= 10;
    }



    cout << max(s, t) << endl;

    return 0;
}

Measured memory_bytes: 256
while True:
	n = int(raw_input())
	if n == 0: break

	else:
		list = []
		for i in range(n):
			score = int(raw_input())
			list.append(score)
		list.sort();
		list.pop(0);
		list.pop();
		x = sum(list) / (n-2)
		print x

Measured memory_bytes: 6408
/************************************************
*Author        :  lrj124
*Created Time  :  2020.08.14.11:48
*Mail          :  1584634848@qq.com
*Problem       :  at1999
************************************************/
#include <algorithm>
#include <iostream>
#include <cstdio>
using namespace std;
const int maxn = 1e5 + 10;
int n,a[maxn];
int main() {
//	freopen("at1999.in","r",stdin);
//	freopen("at1999.out","w",stdout);
	scanf("%d",&n);
	for (int i = 1;i <= n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1,greater<int>());
	for (int i = 1;i <= n;i++)
		if (i >= a[i+1]) {
			int cnt = 0;
			for (int j = i+1;j <= n;j++) if (a[j] == i) cnt++; else break;
			return puts((a[i]-i)&1 || cnt&1 ? "First" : "Second"),0;
		}
	return 0;
}

Measured memory_bytes: 3504
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define BITTYPE LL
#define BITCNT  2
#define BITSIZE 512345
typedef long long LL;
int N;
int x[200001];
int y[200001];
map<int,int>m;
map<int,int>m2;
LL cnt[200001];
LL MOD=998244353;
typedef pair<LL,LL>P;
namespace _BIT{
    int i=0;
    BITTYPE t[2][BITSIZE];
    inline BITTYPE* get(){
        return t[i++];
    }
}

LL C[200011];
void init(){
	C[0]=1;
	REP(i,200005){
		C[i+1]=C[i]*2;
		C[i+1]%=MOD;
	}
}


struct BIT{
    using T=BITTYPE;
    T *t;
    int n;
    BIT(int N):t(_BIT::get()),n(N+1){
        REP(i,n+1)t[i]=0;
    }

    void add(int r,T v){//add v for [1,r]
        for(;r;r-=r&-r)t[r]+=v;
    }

    void add(int l,int r,T v){//add v for [l,r]
        add(r,v);
        add(l-1,-v);
    }

    T get(int i){//get sum[i]
        T res=0;
        for(;i<=n;i+=i&-i)res+=t[i];
        return res;
    }
};

void solve(vector<P>v){
	BIT b(200011);
	REP(i,v.size()){
		LL xx=v[i].second;
		LL a=x[xx]^y[xx]^v[i].first;
		b.add(a+2,200011,1);
		//if(a==0)continue;
		LL temp=b.get(a+1);
		LL p=v[i].second;
		cnt[p]+=C[temp];
		//cout<<C[temp]<<"aab"<< p<<endl;
		cnt[p]%=MOD;
		//cnt[p]-=temp*(temp-1);
		//cnt[p]%=MOD;
	}
	REP(i,v.size()){
		LL xx=v[i].second;
		LL a=x[xx]^y[xx]^v[i].first;
		b.add(a+2,200011,-1);
	}
	reverse(v.begin(),v.end());
	REP(i,v.size()){
		LL xx=v[i].second;
		LL a=x[xx]^y[xx]^v[i].first;
		if(a!=0){
			b.add(1,a,1);
		}
		//if(a==0)continue;
		LL temp=b.get(a+1);
		LL p=v[i].second;
		cnt[p]+=C[temp];
		//cout<<C[temp]<<"aaa "<<p<<endl;
		cnt[p]%=MOD;
		//cnt[p]-=temp*(temp-1);
		//cnt[p]%=MOD;
	}
	REP(i,v.size()){
		LL xx=v[i].second;
		LL a=x[xx]^y[xx]^v[i].first;
		b.add(1,a+1,-1);
	}
}
void debug(){
	/*cout<<"debug"<<endl;
	REP(i,N){
		cout<<cnt[i]<<endl;
	}
	cout<<"--------------"<<endl;*/
}

int main(){
	init();
	cin>>N;
	REP(i,N){
		cin>>x[i]>>y[i];
		m[x[i]]++;
		m2[y[i]]++;
	}
	int c=0;
	for(auto it:m){
		m[it.first]=c;
		c++;
	}
	c=0;
	for(auto it:m2){
		m2[it.first]=c;
		c++;
	}
	REP(i,N){
		cnt[i]=C[N]-1;
	}
	debug();
	
	REP(i,N){
		x[i]=m[x[i]];
		y[i]=m2[y[i]];
		cnt[i]-=C[x[i]];
		cnt[i]%=MOD;
		cnt[i]-=C[y[i]];
		cnt[i]%=MOD;
		cnt[i]-=C[N-1-x[i]];
		cnt[i]%=MOD;
		cnt[i]-=C[N-1-y[i]];
		cnt[i]%=MOD;
		/*if(x[i]!=0){
			cnt[i]+=
			(x[i]-1)*(x[i]-2);
		}
		if(y[i]!=0){
			cnt[i]+=(y[i]-1)*y[i-2];
		}
		if(x[i]!=N-1){
			cnt[i]+=(N-1-x[i])*(N-1-x[i]-1);
		}
		if(y[i]!=N-1){
			cnt[i]+=(N-1-y[i])*(N-1-y[i]-1);
		}
		cnt[i]%=MOD;*/
	}
	vector<P>v;
	REP(i,N){
		v.push_back(P(y[i],i));
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	solve(v);
	vector<P>w;
	REP(i,N){
		w.push_back(P(x[i],i));
	}
	sort(w.begin(),w.end());
	//reverse(w.begin(),w.end());
	solve(w);
	
	debug();
	LL ans=0;
	REP(i,N){
		ans+=cnt[i];
		ans%=MOD;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 43960