akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int n, a[1000], i, j, m, g, b;
    
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&a[i]);
    
    for(i=0;i<n;i++){
        m=a[i];
        for(j=i;j<n;j++){
            if(a[j]>m){
                m=a[j];
                a[j]=a[i];
                a[i]=m;
            }
        }
    }
    g=b=0;
    for(i=0;i<n;i++){
        if(i%2==0) g+=a[i];
        else       b+=a[i];
    }
    printf("%d\n",g-b);
    return 0;
}

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

bool nine = true;
int ans;

int main() {
  string n;
  cin >> n;
  rep (i, n.size()) {
    if (n[i] != '9') nine = false;
  }
  if (nine) {
    ans = n[0] - '0' + (n.size()-1) * 9;
  } else {
    ans = n[0] - '1' + 9 * (n.size()-1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n)
    cin >> a[i];
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        b[a[i] - 1] = i + 1;
    }

    for (int i = 0; i < b.size() - 1; i++)
    {
        cout << b.at(i) << " ";
    }
    cout << b.at(b.size() - 1) << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n;
    cin >> n;
    set<int> as, bs, isec;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as.insert(a);
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        bs.insert(a);
    }

    set_intersection(as.begin(), as.end(), bs.begin(), bs.end(), inserter(isec, isec.end()));
    vi vs;
    for (int i: isec) {
        vs.push_back(i);
    }
    sort(vs.begin(), vs.end());
    for (int v: vs) {
        cout << v << endl;
    }
}


Measured memory_bytes: 24044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
int n,a[200005],sum=1,ans,fff;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);	
		if(a[i]==1)fff=1;
	}
	if(!fff)puts("-1");
	else
	{	
		for(int i=1;i<=n;i++)
		{
			if(a[i]==sum)
			{
				sum++;
			}
		}
		cout<<n-sum+1<<endl;	
	}
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
    int n;
    int i;

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }

        for (i = 0; n != 1; i++){
            if (n % 2 == 0){
                n /= 2;
            }
            else {
                n = n * 3 + 1;
            }
        }
        printf("%d\n", i);
    }

    return (0);
}

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

int top[200000];
int bottom[200000];
bool live[200000];

int main(){
  int N, M, Q;
  scanf("%d %d %d", &N, &M, &Q);

  for(int i = 0; i < N; i++){
    top[i] = (i + N - 1) % N;
    bottom[i] = (i + 1) % N;
  }
  int batton = 0;
  while(M--){
    int a;
    scanf("%d", &a);
    if(a & 1){
      while(a--) batton = top[batton];
    } else {
      while(a--) batton = bottom[batton];
    }
    bottom[top[batton]] = bottom[batton];
    top[bottom[batton]] = top[batton];
    batton = bottom[batton];
  }
 
  while(!live[batton]++) batton = bottom[batton];

  while(Q--){
    int q;
    scanf("%d", &q);
    printf("%d\n", live[q]);
  }
}

Measured memory_bytes: 2760
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class UnionFindTree
{
private:
    int n;
    int groupNum;       // グループの数
    vector<int> parent; // 親ノード
    vector<int> rank;   // 木の高さの上限
    vector<int> num;    // グループの要素数
    int find(int i){
        if(parent[i] == i)
            return i;
        else
            return parent[i] = find(parent[i]);
    }
public:
    UnionFindTree(int n){ // コンストラクタ
        this->n = n;
        groupNum = n;
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
        num.assign(n, 1);
    }
    void unite(int a, int b){ // aとbのグループを併合
        if((a = find(a)) != (b = find(b))){
            if(rank[a] < rank[b]){
                parent[a] = b;
                num[b] += num[a];
            }
            else{
                parent[b] = a;
                if(rank[a] == rank[b])
                    ++ rank[a];
                num[a] += num[b];
            }
            -- groupNum;
        }
    }
    bool same(int a, int b){ // aとbのグループが同じかを調べる
        return find(a) == find(b);
    }
    int getNum(){ // グループの数を返す
        return groupNum;
    }
    int getNum(int a){ // aのグループの要素数を返す
        return num[find(a)];
    }
};

vector<vector<int> > edges;
vector<bool> isEven;
vector<pair<int, int> > ans;

bool solve(int curr, int prev)
{
    for(int next : edges[curr]){
        if(next == prev)
            continue;
        if(solve(next, curr)){
            isEven[curr] = !isEven[curr];
            ans.push_back(make_pair(curr, next));
        }
        else{
            isEven[next] = !isEven[next];
            ans.push_back(make_pair(next, curr));
        }
    }
    return isEven[curr];
}

int main()
{
    int n, m;
    cin >> n >> m;
    edges.assign(n, vector<int>());
    isEven.assign(n, true);
    ans.clear();

    UnionFindTree uft(n);
    for(int i=0; i<m; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        if(!uft.same(a, b)){
            edges[a].push_back(b);
            edges[b].push_back(a);
            uft.unite(a, b);
        }
        else{
            ans.push_back(make_pair(a, b));
            isEven[a] = !isEven[a];
        }
    }

    if(solve(1, -1)){
        for(const auto& p : ans)
            cout << (p.first + 1) << ' ' << (p.second + 1) << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 18036
# -*- coding: utf-8 -*-
import math
import sys
import itertools
import numpy as np
import functools
import collections
mo = 1000000007
INF = 10**100
r = range

class infix(object):
    def __init__(self, function):
        self.function = function

    def __ror__(self, other):
        self.left = other
        return self

    def __or__(self, other):
        return self.function(self.left, other)

    def __call__(self, value1, value2):
        return self.function(value1, value2)

@infix
def c(f_t_u, f_u_r): return lambda t: f_u_r(f_t_u(t))

class _Ap(object):
    def __rlshift__(self, other):
        self.value = other
        return self

    def __rshift__(self, other):
        return other(self.value)
Ap = _Ap()
ap = Ap

#d = {1:2, 3:5, 6:10, 1000043:3814}
#zip(d.keys(), d.values())<<ap>>(list |c| sorted |c| reversed |c| list |c| print)

x=map(int,input().split())<<ap>>list<<ap>>sorted
print('Yes' if x[0]+x[1]==x[2] else 'No')


Measured memory_bytes: 12504
/*ex3_4
    takafumi_ueki*/
#include <stdio.h>
int main(void){
    int x;
    scanf("%d",&x);
    /*例えば,Nを2で割った余りが０（２で割り切れる）かつ
    ２で割った商が10未満だったら一桁の整数同士の掛け算で表せるということなので、それを3,4,5,,,,と調べる。*/
    if(((x%1 == 0)&&((x/1)<10))||((x%2 == 0)&&((x/2)<10))||((x%3 == 0)&&((x/3)<10))||((x%4 == 0)&&((x/4)<10))||((x%5 == 0)&&((x/5)<10))||((x%6 == 0)&&((x/6)<10))||((x%7 == 0)&&((x/7)<10))||((x%8 == 0)&&((x/8)<10))||((x%9 == 0)&&((x/9)<10))){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
#define MAX 36
typedef struct{
  char mark;
  int num;
}Card;

 // if(strlen(x,y)==0)return 0;//同じだったら０
int swap_s(Card *X,Card *Y){
  Card Z;
  Z=*X;
  *X=*Y;
  *Y=Z;
  return 1;//違ったら１
}
/*
//安定なら1　 ちがったら0
int isStable(Card *In,Card *Out,int n)
{
  int i,j,a,b;

  for (i = 0;i< n;i++){
    for (j = i+1 ;j<n;j++){
      for (a = 0;a <n;a++){
	for (b = a+1;b<n;b++){
	  if (In[i].num ==In[j].num&& In[i].num == Out[b].num && In[i].mark == Out[b].mark && In[j].num == Out[a].num && In[j].mark == Out[a].mark)
	    return 0;
	}
      }
    }
  }
  return 1;
}
*/
//n番目まで安定か？　bubleで確かめる安定なら1　 ちがったら0 
int isStable2(Card *buble,Card *select,int n){
  int i;
  
  for(i=0;i<n;i++){
    if(buble[i].mark!=select[i].mark)return 0;
  }
  return 1;
}



  
//Aの配列を/ n番目まで出力
void sarray_output(Card *A,int N){
  int i;
  for(i=0;i<N;i++){
    if(i)printf(" ");
    printf("%c%d",A[i].mark,A[i].num);
  }
  printf("\n");
}

int bubbleSort(Card *A, int n){
  int flag=1;
  int i,j;
  
  for (i=0;flag;i++){
    flag = 0;//一回も交換しない、 つまり既に並んんでいたら０

    for (j = n-1;j>=1;j--){
      if (A[j].num < A[j-1].num)
	{
	  swap_s(&A[j],&A[j-1]);
	  flag=1;
	}
    }
  }
  return 0;
}

int selectionSort(Card *A,int n){ // N個の要素を含む0-オリジンの配列A
  int i;
  int j;
  int minj;
    
  for (i=0;i<=n-1;i++){
    minj = i;
    for (j=i;j<=n-1;j++){
      if (A[j].num < A[minj].num) minj=j;
    }
    swap_s(&A[i],&A[minj]);
  }
  return 0;
}

int main(){
  Card A[MAX],B[MAX],In[MAX];//A bubule /B selection 
  
  int i;
  int n;

  scanf("%d",&n);
  for(i=0;i<n;i++){//Input
    scanf(" %c%d",&A[i].mark,&A[i].num);
    In[i]= B[i]=A[i];
  }
  
  bubbleSort(A,n);
  selectionSort(B,n);


  //print
  sarray_output(A,n);
  printf("Stable\n");
	    
  sarray_output(B,n);
  if(isStable2(A,B,n))printf("Stable\n");
  else  printf("Not stable\n");
  
  return 0;
}



//(In,B,n)
/*
  2
  H4 D1を昇順に

  出力
  D1 H4 
  Stable
  H4 D1
  Not Stable
 
  バブルソートは絶対安定
*/



Measured memory_bytes: 2112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

int main() {
    long long x;
    cin >> x;

    long long a = 100;
    long long ans = 0;
    while (a < x) {
        a += a / 100;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


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

template <int MOD>
struct ModInt {
    using lint = long long;
    using mint = ModInt<MOD>;

    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // assignment
    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->val = x.val; }
        return *this;
    }

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator~() const {
        // non-recursive extended euclidean algorithm
        int s = val, t = MOD;
        mint sx = 1, sy = 0, tx = 0, ty = 1;
        while (s % t != 0) {
            int div = s / t;
            s -= t * div;
            sx -= tx * div;
            sy -= ty * div;

            std::swap(s, t);
            std::swap(sx, tx);
            std::swap(sy, ty);
        }
        return mint(tx);
    }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= ~x; }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
};

constexpr int MOD = 1e9 + 7;
using mint = ModInt<MOD>;

template <int MOD>
class Combination {
    using mint = ModInt<MOD>;

private:
    int MAX_V;
    std::vector<mint> f, invf;

public:
    explicit Combination(int N)
        : MAX_V(N), f(MAX_V + 1), invf(MAX_V + 1) {
        f[0] = 1;
        for (int i = 1; i <= MAX_V; ++i) {
            f[i] = f[i - 1] * i;
        }

        invf[MAX_V] = ~f[MAX_V];
        for (int i = MAX_V - 1; i >= 0; --i) {
            invf[i] = invf[i + 1] * (i + 1);
        }
    }

    mint fact(int n) const { return f[n]; }
    mint invfact(int n) const { return invf[n]; }
    mint perm(int a, int b) const {
        return a < b ? mint(0) : f[a] * invf[a - b];
    }
    mint comb(int a, int b) const {
        return a < b ? mint(0) : f[a] * invf[a - b] * invf[b];
    }
};

const Combination<MOD> C(10000000);

void fail() {
    std::cout << 0 << std::endl;
    std::exit(0);
}

int main() {
    int x, y;
    std::cin >> x >> y;

    int s = x + y;
    if (s % 3 != 0) fail();

    x -= s / 3, y -= s / 3;
    if (x < 0 || y < 0) fail();

    std::cout << C.comb(x + y, x) << std::endl;
    return 0;
}


Measured memory_bytes: 78336
N = int(input())
cake = N // 4
donuts = N // 7
calcs = False
for i in range(cake + 1):
  for j in range(donuts + 1):
    if i * 4 + j * 7 == N:
      calcs = True
      break
print('Yes' if calcs is True else 'No')

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

char A[50][50], B[50][50];

bool loop(int x, int y, int m)
{
    for (int i = x; i < x + m; i++)
        for (int j = y; j < y + m; j++)
            if (A[i][j] != B[i - x][j - y])
                return false;
    return true;
}

int main()
{
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> A[i][j];
    for (int i = 0; i < m; i++)
        for (int j = 0; j < m; j++)
            cin >> B[i][j];
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
            if (A[i][j] == B[0][0])
            {
                if (loop(i, j, m))
                {
                    cout << "Yes" << endl;
                    return 0;
                }
            }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
n,u,v = map(int,input().split())
u -= 1
v -= 1
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
rank = [10**6 for _ in range(n)]
seen = [0 for _ in range(n)]
pre = [10**6 for _ in range(n)]
pst = [[] for _ in range(n)]
seen[v] = 1
rank[v] = 0
now = [v]
while now:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if seen[y] == 0:
        seen[y] += 1
        rank[y] = rank[x] + 1
        now.append(y)
        pre[y] = x
        pst[x].append(y)
#print(rank)
back = (rank[u]-1) // 2
tar = u
for _ in range(back):
  tar = pre[tar]
depth = -1
now = [tar]
while now:
  depth += 1
  last = now
  now = []
  for x in last:
    now += pst[x]
#print(tar,depth,last)
if rank[u] % 2 == 1:
  print(back + depth)
else:
  print(back + depth + 1)

Measured memory_bytes: 75040
def main():
    import collections

    S = input()

    mod_list = [0]

    for i in range(len(S)):
        index = len(S) - i - 1
        num = int(S[index])

        mod_list.append((mod_list[-1] + num * pow(10, i, 2019)) % 2019)

    CTR_mod_list = collections.Counter(mod_list).most_common()
    cnt = 0

    for i in range(len(CTR_mod_list)):
        n = CTR_mod_list[i][1]

        if (n == 1):
            break

        cnt += n * (n - 1) // 2

    print(cnt)

if __name__ == '__main__':
    main()

Measured memory_bytes: 16760
from bisect import bisect_right, bisect_left
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()
ans = 0
for j in range(N):
    b = B[j]
    i = bisect_left(A, b)
    k = bisect_right(C, b)
    ans += i * (N - k)
print(ans)


Measured memory_bytes: 92644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<utility>//swapでaとbの値を入れ替える
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
using namespace std;

int main() {
	int a,b,c,ans=0;
	cin >> a;
	string s[100],t[100];
	rep(i, a)cin >> s[i];
	cin >> b;
	rep(j, b)cin >> t[j];
	rep(i, a) {
		int x = 0;
		rep(j, a) {
			if (s[i] == s[j])x++;
		}
		rep(j, b) {
			if (s[i] == t[j])x--;
		}
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    while(1){
        int n, i, dice[6], sum = 1;
        for(i=0; i<6; i++)
            dice[i] = i+1;
        scanf("%d", &n);
        if (n == 0)
            return 0;
        for (i=0; i<n; i++){
            //char *str = NULL;
            char str[8];
            int tmp;
            scanf("%s", str);
            switch(str[0]){
                case 'N':
                    tmp = dice[0];
                    dice[0] = dice[1];
                    dice[1] = dice[5];
                    dice[5] = dice[4];
                    dice[4] = tmp;
                    break;
                case 'E':
                    tmp = dice[0];
                    dice[0] = dice[3];
                    dice[3] = dice[5];
                    dice[5] = dice[2];
                    dice[2] = tmp;
                    break;
                case 'W':
                    tmp = dice[0];
                    dice[0] = dice[2];
                    dice[2] = dice[5];
                    dice[5] = dice[3];
                    dice[3] = tmp;
                    break;
                case 'S':
                    tmp = dice[0];
                    dice[0] = dice[4];
                    dice[4] = dice[5];
                    dice[5] = dice[1];
                    dice[1] = tmp;
                    break;
                case 'R':
                    tmp = dice[1];
                    dice[1] = dice[2];
                    dice[2] = dice[4];
                    dice[4] = dice[3];
                    dice[3] = tmp;
                    break;
                case 'L':
                    tmp = dice[1];
                    dice[1] = dice[3];
                    dice[3] = dice[4];
                    dice[4] = dice[2];
                    dice[2] = tmp;
                    break;
            }
            sum += dice[0];
        }
        printf("%d\n", sum);
    }
}

Measured memory_bytes: 604
def render kq
  str = kq ? "Yes" : "No"
  puts str
end
n=gets.chomp.to_i
array=gets.chomp.split(' ').map(&:to_i)
min = max = array[0]
kq = true
if n == 1
  kq = true
else
  array.each_with_index do |value, index|
    next if index == n -1
    kq = false if value - array[index+1] > 1
    min = value < min ? value : min
    kq = false if min - array[index+1] > 1
    max = value > max ? value : max
    kq = false if max - array[index+1] > 1
  end
end
render kq


Measured memory_bytes: 10636
#include<bits/stdc++.h>
using namespace std;
int main()
{
int num;
float check_number, rest_num;

cin>>num;

check_number = num / 1000.00;


if(floor(check_number)==ceil(check_number)){
  rest_num = 0;
}
else if(check_number>1){
  check_number = ceil(check_number);
  rest_num = check_number*1000 - num;
}
else{
  rest_num = 1000 - num;
}
cout<<rest_num<<endl;
}


Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#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;

int main(void) {
	ll i, j, num, x, m, ans, a = 0, b = 0, k = 0;
	cin >> num >> x >> m;
	if (m == 1) {
		printf("0\n");
		return 0;
	}
	vector<ll> d(m, 0), s(m, 0);
	rep(i, num) {
		k++;
		a += x;
		if (d[x]) {
			k -= s[x];
			b = a - d[x];
			a = d[x];
			int c = (num - s[x]) % k;
			k = (num - s[x]) / k;
			rep(j, c) {
				x *= x;
				x %= m;
				a += x;
			}
			break;
		}
		d[x] = a;
		s[x] = k;
		x *= x;
		x %= m;
	}
	if (i == num)
		ans = a;
	else
		ans = a + b * k;
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 4824
function Main(input) {input=input.split("\n");var n=parseInt(input[0], 10);var d=[];d=input[1].split(" ").map(Number);tl=0;for(i=0;i<n;i++){for(j=i+1;j<n;j++){tl = tl+ d[i]*d[j];}}console.log(tl);}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
n,x=map(int,input().split())
li=list(map(int,input().split()))

count=0
d=0
d_l=[0]
for l in li:
  d=d+l
  d_l.append(d)

for di in d_l:
  #print(di)
  if di<=x:
    count+=1
print(count)

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

X,Y = map(int,input().split())

#print(X)
#print(Y)
#a+b=X
#2a+4b+Y
#2a+2b=2X
#a=(4X-Y)/2
#b=(Y-2X)/2

# if Y-2X=0; b=0; a=X; 2a=Y; print Yes
if (Y-2*X) == 0  :
  print("Yes")
  exit()

if (Y-2*X) < 0 or (4*X-Y) < 0 or Y%2!=0  :
  print("No")
  exit()



b=int((Y-2*X)/2)
a=int(X-b)

# if a>=0 and b>=0 -> Yes, else -> No
if a >= 0 and b >=0 :
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9152
#include<stdio.h>
long long int a, b, x, ans;
int main(){
  scanf("%lld%lld%lld", &a, &b, &x);
  if(a==0){
    printf("%lld\n", b/x+1);
  }else{
    printf("%lld\n", b/x-(a-1)/x);
  }
}


Measured memory_bytes: 128
import collections
n = int(input())
a = sorted(list(int(i) for i in input().split()))
ct = collections.Counter(a)
odd = []
even = []
mod =10**9+7



if n % 2 == 0:
  for i in range(n//2):
    even.append(i*2+1)
    even.append(i*2+1)
  if a == even:
    print(2**(n//2)%mod)
  else:
    print(0)
else:
  odd.append(0)
  for i in range(n//2):
    odd.append(2+i*2)
    odd.append(2+i*2)
  if a == odd:
    print(2**(n//2)%mod)
  else:
    print(0)

Measured memory_bytes: 15304
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  int A[N],B[N];
  for(int i=0;i<N;i++){
    cin >> A[i] >> B[i];
  }
  vector<pair<int,int>> AB(N);
  for(int i=0;i<N;i++){
    AB[i] = make_pair(A[i],B[i]);
  }
  sort(AB.begin(),AB.end());
  
  long long ans = 0;
  for(int i=0;i<N;i++){
    int buy = min(M,AB[i].second);
    ans += (long long)buy * AB[i].first;
    M -= buy;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cout<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define Error  1e-9
#define pi (2*acos(0))
const ll mod =1e9 +7;
const int N = 2e5 +5;
ll bigmod(ll a, ll b, ll m)
{
    if(b==0)
        return 1%m;
    ll x=bigmod(a,b/2,m);
    x=(x*x)%m;
    if(b%2==1)
        x=(x*a)%m;
    return x;
}
ll fact[N+5];
void init()
{
    fact[0]=1;
    for(ll i=1; i<N; i++)
    {
        fact[i]= fact[i-1]*i;
        fact[i]%=mod;
    }
}
ll get_ncr(ll n, ll r)
{
    ll down = fact[r];
    ll up= 1;
    for(ll i=n;i>=n-r+1;i--)
    {
        up*=i;
        up%=mod;
    }
    up*= bigmod(down,mod-2,mod);
    return up%mod;
}
void Solve(int cas)
{
    init();
    ll n,a,b;
    scanf("%lld %lld %lld",&n,&a,&b);
    ll ans= bigmod(2,n,mod);
    ans= (ans - get_ncr(n,a)- get_ncr(n,b) - 1)%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);




}



int main()
{
    //fastInput;
    //cout.tie(0);
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        Solve(++cas);
    }
    return 0;
}
/*

*/


//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 1920
//#include <bits/stdc++.h>
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#define FOR(N) for(int i=0;i<N;i++)
#define FOR2(N) for(int j=0;j<N;j++)
using namespace std;
typedef long long ll;


int main() {
	int N;
	int A[3][3] = { 0 };
	int C[3][3] = { 0 };
	FOR(3)FOR2(3)
		cin >> A[i][j];
	cin >> N;
	int b[N] = { 0 };
	FOR(N) {
		cin >> b[i];
		FOR2(3) {
			for (int k = 0; k < 3; k++) {
				if (b[i] == A[j][k]) {
					C[j][k] = 1;
					//cout << "a" << endl;
				}
			}
		}
	}
	//FOR(3)FOR2(3) { cout << C[i][j] << A[i][j] << endl; }
	FOR(3)
	if (C[i][0] == C[i][1] && C[i][1] == C[i][2]&&C[i][0]) {
		cout << "Yes" << endl;
		return 0;
	}
	FOR(3)
		if (C[0][i] == C[1][i] && C[0][i] == C[2][i]&&C[0][i]) {
			cout << "Yes" << endl;
			return 0;
		}
	if (C[0][0] == C[1][1] && C[0][0] == C[2][2]&&C[0][0]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (C[2][0] == C[1][1] && C[2][0] == C[0][2]&&C[2][0]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define mp make_pair
#define pll pair<ll,ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pqmin priority_queue<ll,vector<ll>,greater<ll>>
#define pqmax priority_queue<ll>
using namespace std;
ll power(ll a,ll n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return (power((a*a),n/2));
	else
	  return (a*(power((a*a),n/2)));    
}
int main()
{
  IOS;
   
 ll n,x;
 cin>>n>>x;
 if(n*500>=x)
 cout<<"Yes"<<endl;
 else
 cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <random>
#include <chrono>
using namespace std;
random_device seed;
mt19937_64 engine(seed());
uint_fast64_t rnd(){ return engine(); }
uint_fast64_t rnd(uint_fast64_t u){ return (u <= 1)?0:engine()%u; }
long long rnd(long long a, long long b){
    if(a > b) swap(a, b);
    return a + (engine()%(b-a+1));
}
const int alp = 26;
int D;
vector<long long> c(alp);
vector< vector< long long > > s;

long long sub(vector<int>& last, int x, int d){
    long long res = s[d][x];
    for(int j=0;j<alp;j++){
        if(j != x) res -= c[j] * (d-last[j]);
    }
    return res;
}

long long score(vector<int>& t){
    if(t.size() != D) return 0;
    vector< int > last(alp, -1);
    long long res = 0;
    for(int i=0;i<D;i++){
        res += s[i][t[i]];
        last[t[i]] = i;
        for(int j=0;j<alp;j++){
            res -= c[j] * (i-last[j]);
        }
    }
    return res;
}

void f(vector<int>& t){
    t.assign(D, 0);
    vector< int > last(alp, -1);
    for(int i=0;i<D;i++){
        int mxj = 0;
        long long mx = -1e9;
        for(int j=0;j<alp;j++){
            long long tmp = sub(last, j, i);
            if(tmp > mx){
                mxj = j;
                mx = tmp;
            }
        }
        t[i] = mxj;
        last[mxj] = i;
    }
}

bool print_t(vector<int>& t){
    if(t.size() != D) return false;
    for(int i=0;i<D;i++){
        cout << t[i]+1 << endl;
    }
    return true;
}

int main(void){
    chrono::system_clock::time_point clk_start = chrono::system_clock::now();
    chrono::system_clock::time_point clk_end;
    cin >> D;
    for(int i=0;i<alp;i++) cin >> c[i];
    s.assign(D, vector<long long>(alp, 0));
    for(int i=0;i<D;i++){
        for(int j=0;j<alp;j++) cin >> s[i][j];
    }

    vector<int> t;
    f(t);
    long long old_score = score(t);
    for(int l=1;;l++){
        int i = rnd(0, D-1);
        int od = t[i];
        t[i] = rnd(0, alp-1);
        long long new_score = score(t);
        if(new_score > old_score){
            old_score = new_score;
        }else{
            t[i] = od;
        }
        if(i%100000 == 0){
            clk_end = chrono::system_clock::now();
            int clk_time = static_cast<int>(chrono::duration_cast<chrono::microseconds>(clk_end - clk_start).count());
            if(clk_time > 1900000) break;
        }
    }

    print_t(t);
}


Measured memory_bytes: 3284
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

int main(){
	int N;
	cin >> N;
	vector<int> a(N+1);
	a[0] = -1;//
	for(int i=1; i<=N; i++) cin >> a[i];

	vector<int> ans(N+1, 0);
	ans[0] = -1;

	for(int i=N; i>0; i--){
		int sum = 0;
		for(int j=i+i; j<=N; j+=i){
			if(ans[j] == 1) sum++;
		}
		sum %= 2;
		if(a[i] == sum) ans[i] = 0;
		else ans[i] = 1;
	}



	// cout << " ans:"; print_vec(ans);
	int num = 0;
	for(int i=1; i<=N; i++) if(ans[i] == 1) num++;
	cout << num << endl;
	for(int i=1; i<=N; i++) if(ans[i] == 1) cout << i << " ";
	cout << endl;
}



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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

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

	int n;
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	ll ans = 1e18;
	for(int i=1;i<=100;i++){
		ll cur = 0;
		for(int j : a){
			cur += (j - i) * (j - i);
		}
		ans = min(ans, cur);
	}
	cout << ans << '\n';
}


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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if ((n | m) == 0)
				break;
			Integer[] ps = new Integer[n];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				ps[i] = sc.nextInt();
				sum += ps[i];
			}
			Arrays.sort(ps, new Comparator<Integer>() {
				public int compare(Integer a, Integer b) {
					return b - a;
				}
			});
			for (int i = 0; i < ps.length / m; i++) {
				sum -= ps[i*m+m-1];
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
char s[100];
int len;
ll f(int pos,int L){
    ll ret=0,ed=pos+L-1;
    for(int i=pos;i<=ed;i++){
        ret=ret*10+(s[i]-'0');
    }
    return ret;
}
int main()
{
    ll n;
    scanf("%s",s+1);
    len=strlen(s+1);
    sscanf(s+1,"%lld",&n);
    ll ans=0,tmp;
    for(int i=1;i<=len;i++){
        for(int j=1;j+i-1<=len;j++){
            int cur=len-i-1;
            if(1<j&&j<len-i+1){
                cur--;
            }
            cur=max(0,cur);
            tmp=f(j,i)*pow(2,cur);
            ans=ans+tmp;
            //printf("%d %d %lld\n",i,j,tmp);
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a = list(map(int,input().split()))
a.append(0)
s = 0
b = [0]*n
for i in range(n):
  x = abs(a[i]-a[i-1])
  y = abs(a[i+1]-a[i])
  z = abs(a[i+1]-a[i-1])
  s += x
  b[i] = x+y-z
s += abs(a[n-1])
for i in range(n):
  print(s-b[i])
  

Measured memory_bytes: 14048
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Main
{
    public static class Program
    {
        public static List<int> list = new List<int>();
 
        static void Main(string[] arg)
        {
            //int r = int.Parse(Console.ReadLine());
            var a = GetIntList(Console.ReadLine());
            var answer = a[2];

            for(int i = 0;i<10;i++){
                answer = a[0] * answer - a[1];
                Console.WriteLine(answer);
            }            


            //Console.WriteLine(answer);
            Console.ReadLine();
 
        }
        
        #region libraries
        private static int[] GetIntList(string line)
        {
            return line.Split(' ').Select(x => int.Parse(x)).ToArray();
 
        }
        private static double[] GetDoubleList(string line)
        {
            return line.Split(' ').Select(x => double.Parse(x)).ToArray();
 
        }
        private static ulong[] GetUlongList(string line)
        {
            return line.Split(' ').Select(x => ulong.Parse(x)).ToArray();
        }
        private static long[] GetLongList(string line)
        {
            return line.Split(' ').Select(x => long.Parse(x)).ToArray();
        }
        private static int SearchNearest(this IEnumerable<int> list, int target)
        {
            var min = list.Min(c => Math.Abs(c - target));
            return list.First(c => Math.Abs(c - target) == min);
        }
        public static bool IsOdd(int i)
        {
            return i % 2 == 1 ? true : false;
        }
        public static int Gcd(int a,int b)
        {
            if(a < b)
            {
                Gcd(b, a);
            }
            while (b != 0)
            {
                var rm = a % b;
                a = b;
                b = rm;
            }
            return a;
        }
        #endregion
    }
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  ll n, x;
  cin >> n >> x;
  vl a(n);
  re(i, n) cin >> a[i];

  sort(all(a));
  ll cnt = 0;
  re(i, n-1) {
    if(a[i] <= x) {
      x -= a[i];
      cnt++;
    } else {
      break;
    }
  }
  if(a[n-1] == x) cnt++;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize(2)
const int N = 222;
int f[2][N][N][N];
int n, m;
char mp[N][N];
int main(){
//	freopen("land.in", "r", stdin);
//	freopen("land.out", "w", stdout);
	cin>>n>>m;
	for(int i = 1;i <= n; i++){
		scanf("%s", mp[i] + 1);
	}
	for(int i = m;i >= 1; i--){
		for(int l = 1;l <= n; l++){
			for(int r = l;r <= n; r++){
				if(mp[l][i] != mp[r][i])break;
				f[0][l][r][i] = i;
				if(mp[l][i+1] == mp[l][i])f[0][l][r][i] = max(f[0][l][r][i+1], i);
			}
		}
	}
	int fl = 0;
	for(int ans = 0;ans <= 20; ans++){
		if(f[fl][1][n][1] == m){
			printf("%d\n", ans);
			return 0;
		}
		for(int i = 1;i <= m; i++){
			for(int l = 1;l <= n; l++){
//				printf("l=%d\n", l);
				int res = l;
				for(int r = l;r <= n; r++){
					if(f[fl][l][r][i] == m){
						f[fl^1][l][r][i] = m;
						continue;
					}
					int F = f[fl][l][r][i];
					F = max(F, f[fl][l][r][F+1]);
					while(1){
						if(res >= r - 1)break;
						int a = min(f[fl][l][res][i], f[fl][res+1][r][i]), b = min(f[fl][l][res+1][i], f[fl][res+2][r][i]);
						if(b >= a)res++;
						else break;
					}
					F = max(F, min(f[fl][l][res][i], f[fl][res+1][r][i]));
					f[fl^1][l][r][i] = F;
				}
			}
		}
		fl ^= 1;
	}
	return 0;
}

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

int main(void){
	int num;
	cin >> num;
        int lastNum = num % 10;
        int firstNum = num / 100;
        if (firstNum == lastNum) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  ll T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  if(A1 < B1) {
    swap(A1, B1);
    swap(A2, B2);
  }
  ll d = (A1-B1)*T1 + (A2-B2)*T2;
  if(d == 0) cout << "infinity" << endl;
  else if(d > 0) cout << 0 << endl;
  else {
    ll d1 = (A1-B1)*T1;
    d = abs(d);
    ll cnt = d1/d+1;
    if(d1%d) cout << cnt*2-1 << endl;
    else     cout << cnt*2-2 << endl;
  }
  return 0;
}


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

int main() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	int i;
	for(i=0; i<N; ++i) cin >> S[i];
	sort(S.begin(), S.end());
	for(i=0; i<N; ++i) cout << S[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace Problem_A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            Console.WriteLine($"{(input[0] - 1) * (input[1] - 1)}");
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[2000][2000]={0};
const ll N=1000000007;
int main()
{
    ll h,w;
    cin>>h>>w;

    char k1[h][w];
    for(ll i=0;i<h;i++)
        for(ll j=0;j<w;j++)
            cin>>k1[i][j];
            dp[h-1][w-1]=1;

    for(ll i=(h-1);i>=0;i--)
    {
        for(ll j=(w-1);j>=0;j--)
        {
            if(k1[i][j]=='.')
            {
                if(i+1<=(h-1)&&k1[i+1][j]!='#')
                    dp[i][j]=(dp[i][j]+dp[i+1][j])%N;
                if(j+1<=(w-1)&&k1[i][j+1]!='#')
                    dp[i][j]=(dp[i][j]+dp[i][j+1])%N;
            }
        }
    }
 cout<<dp[0][0]%N;

}


Measured memory_bytes: 17152
#include <cstdio>

int n;

int main(){
	while(scanf("%d", &n),n){
		int in, out, month = 0;
		bool ok = true;
		for(int i = 0; i < 12; i++){
			scanf("%d%d", &in, &out);
			n -= in-out;
			if(n <= 0 && month == 0) month = i+1;
		}
		if(n <= 0) printf("%d\n", month);
		else printf("NA\n");
	}
}

Measured memory_bytes: 1036
#include <stdio.h>
#define INF 999999999

int l[250002] = {};
int r[250002] = {};
int c ;

 int s[500000];

void merge(int left,int mid,int right){

  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;

  for(i = 0;i < n1;i++) l[i] = s[left + i];
  for(i = 0;i < n2;i++) r[i] = s[mid + i];

  l[n1] = INF;
  r[n2] = INF;

  i = j = 0;
  
  for(k = left;k < right;k++){
    c++;
    if(l[i] <= r[j]){
      s[k] = l[i];
      i++;
    }
    else{
      s[k] = r[j];
      j++;
    }
  }
}

void mergesort(int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right) / 2;
    mergesort(left,mid);
    mergesort(mid,right);
    merge(left,mid,right);
  }
}
    
int main(){
  
  int n,i,left,right;
 
  c = 0;
  
  scanf("%d",&n);
  for(i = 0;i < n;i++) scanf("%d",&s[i]);

  
  left = 0;right = n;

  mergesort(left,right);

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

Measured memory_bytes: 6464
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from math import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
X = I()
m500 = X//500
rest = X - 500 * m500
print(m500 * 1000 + 5 * (rest//5))


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

int main(){
  int num, a, b;
  string str;
  
  cin >> num;
  if(num ==1){
    cout << "Hello World" << endl;
  }else{
  	cin >> a;
    cin >> b;
    cout << a+b << endl;
  }
  
return 0;
}

Measured memory_bytes: 256
fn read_line_as_value<T: std::str::FromStr>() -> T {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().parse() {
        Ok(val) => val,
        _ => panic!("error while parsing input: {}", input)
    }
}

fn read_line_as_vector<T: std::str::FromStr>() -> Vec<T> {
    let mut input = String::new();
    let res = std::io::stdin().read_line(&mut input);
    if let Err(error) = res {
        panic!("io error at stdin.read_line: {}", error);
    };
    match input.trim().split_whitespace().map(|x| x.parse()).collect::<Result<Vec<T>, _>>() {
        Ok(vec) => vec,
        _ => panic!("error while parsing input: {}", input)
    }
}

fn main() {
    let input = read_line_as_vector::<usize>();
    let num = input[0]; let steps = input[1];
    // println!("{} {}", num, steps);
    let input = read_line_as_vector::<i32>();
    let r_score = input[0]; let s_score = input[1]; let p_score = input[2];
    // println!("{} {} {}", r_score, s_score, p_score);
    let hands = read_line_as_value::<String>();
    let char_hands: Vec<char> = hands.chars().collect();
    // println!("{}", hands);

    let mut ans = 0;
    for i in 0..steps {
        let mut prev = '\0';
        for j in (i..num).step_by(steps) {
            if prev == '\0' || prev != char_hands[j] {
                match char_hands[j] {
                    'r' => ans += p_score,
                    's' => ans += r_score,
                    'p' => ans += s_score,
                    x => panic!("unknown hand found: {}", x),
                }
                prev = char_hands[j]
            } else {
                prev = '\0'
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2556
#include<bits/stdc++.h>
#define fo(i,a,b) for(register int (i)=(a);(i)<=(b);++(i))
#define rd read()
#define maxn 200001
#define gc getchar()
#define mem(a,b) memset(a,b,sizeof(a))
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define pb push_back
#define db double
#define pu puts(" ")
using namespace std;
const int p=998244353;
int read()
{
	int x=0,f=1;
	char ch=gc;
	while(!isdigit(ch))
	{
		if(ch=='-')f=-1;
		ch=gc;
	}
	while(isdigit(ch))x=x*10+ch-48,ch=gc;
	return x*f;
}
void print(int x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>9)print(x/10);
	putchar(x%10+48);
}
int qp(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%p;a=(ll)a*a%p;
		
		b>>=1;
	}
	return ans%p;
}
string s;
int main()
{
    cin>>s;
    int l=s.size();
    if(l==3) reverse(s.begin(), s.end());
    cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#include <queue>//for queue and priority_queue
#include <fstream>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <set>
#include <map>
#include <list>
#define endl "\n"
typedef long long ll;
using namespace std;
void Lancer() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
bool isPrime(ll n){
	if (n == 2 || n == 3 || n == 5)
		return true;
	else if (n % 2 == 0 || n % 3 == 0 || n % 5 == 0 || n == 1)
		return false;
	else {
		for (int i = 5; i <= sqrt(n); i += 2){
			if (n%i == 0)
				return false;
		}
		return true;
	}
}

char img[57][57], temp[57][57];
int main(){
	Lancer();
	ll n, m;
	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> img[i][j];
	for (int i = 0; i < m; i++)
		for (int j = 0; j < m; j++)
			cin >> temp[i][j];

	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			if (temp[0][0] == img[i][j]){
				if (i + m <= n && j + m <= n){
					bool ch = true;
					for (int k = 0; k < m; k++){
						for (int c = 0; c < m; c++){
							if (temp[k][c] != img[i + k][j + c]){
								ch = false;
								break;
							}
						}
					}
					if (ch){
						cout << "Yes";
						return 0;
					}
				}
			}
		}
	}
	cout << "No";
	cout << endl;
	return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=155;
int n,k,mod;
int f[maxn][maxn][maxn];
map<pii,int>g[maxn][maxn][maxn];
void Add(int &a,int b){a+=b;if(a>=mod)a-=mod;}

int main(){
	scanf("%d%d%d",&n,&k,&mod);
	if(k%2==0){
		k/=2;
		f[0][0][0]=1;
		rep(i,n)rep(p,k+1)rep(q,k+1){
			int cur=f[i][p][q];
			if(!cur)continue;
			Add(f[i+1][q+1][p],cur);
			Add(f[i+1][0][p],cur);
		}
		int ans=0;
		rep(p,k+1)rep(q,k+1)Add(ans,f[n][p][q]);
		printf("%d\n",ans);
	}
	else{
		g[0][0][0][mp(n+1,n+1)]=1;
		rep(i,n)rep(p,i/2+2)rep(q,i/2+2){
			for(map<pii,int>::iterator it=g[i][p][q].begin();it!=g[i][p][q].end();it++){
				int fp=(it->fst).fst,fq=(it->fst).snd,cur=it->snd;
				if(!(i&1)){
					Add(g[i+1][0][q][mp(n+1,fq)],cur);
					if(i+1<fp){
						if(i+1-k>=i-2*(q-1))Add(g[i+1][p+1][q][mp(fp,min(fq,i+1-2*p+k))],cur);
						else Add(g[i+1][p+1][q][mp(fp,fq)],cur);
					}
				}
				else{
					Add(g[i+1][p][0][mp(fp,n+1)],cur);
					if(i+1<fq){
						if(i+1-k>=i-2*(p-1))Add(g[i+1][p][q+1][mp(min(fp,i+1-2*q+k),fq)],cur);
						else Add(g[i+1][p][q+1][mp(fp,fq)],cur);
					}
				}
			}
		}
		int ans=0;
		rep(p,n/2+2)rep(q,n/2+2)
			for(map<pii,int>::iterator it=g[n][p][q].begin();it!=g[n][p][q].end();it++)
				Add(ans,it->snd);
		printf("%d\n",ans);
	}
	return 0;
} 

Measured memory_bytes: 229888