akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
// https://snuke.hatenablog.com/entry/2019/01/15/211812
vector<int> edge[5000];
int a[5000];
long long dp[5000][5001][2]; // true -> A_i > 0
int dfs(int par, int ver) {
  int cnt = 1;
  if (a[ver] > 0) dp[ver][1][true] = a[ver];
  dp[ver][1][false] = a[ver];
  for (int e : edge[ver]) if (e != par) {
    int kosu = dfs(ver, e);
    vector<vector<long long> > tmp(cnt+kosu+1, vector<long long>(2, LINF));
    FOR(i, 1, cnt+1) FOR(j, 1, kosu+1) {
      if (a[ver] > 0) {
        if (dp[e][j][true] != LINF || dp[e][j][false] < 0) tmp[i+j][true] = min(tmp[i+j][true], dp[ver][i][true]);
        if (a[e] > 0) tmp[i+j-1][true] = min(tmp[i+j-1][true], dp[ver][i][true]+dp[e][j][true]);
      }
      if (dp[e][j][true] != LINF || dp[e][j][false] < 0) tmp[i+j][false] = min(tmp[i+j][false], dp[ver][i][false]);
      tmp[i+j-1][false] = min(tmp[i+j-1][false], dp[ver][i][false]+dp[e][j][false]);
    }
    cnt += kosu;
    FOR(j, 1, cnt+1) {
      dp[ver][j][true] = tmp[j][true];
      dp[ver][j][false] = tmp[j][false];
    }
  }
  return cnt;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  REP(i, n) cin >> a[i];
  REP(i, n - 1) {
    int u, v; cin >> u >> v; --u; --v;
    edge[u].emplace_back(v);
    edge[v].emplace_back(u);
  }
  REP(i, n) FOR(j, 1, n+1) {
    dp[i][j][true] = dp[i][j][false] = LINF;
  }
  dfs(-1, 0);
  // REP(i, n) {
  //   cout << i << ": ";
  //   FOR(j, 1, n+1) {
  //     cout << "(";
  //     if (dp[i][j][true] == LINF) cout << "x";
  //     else cout << dp[i][j][true];
  //     cout << ",";
  //     if (dp[i][j][false] == LINF) cout << "x";
  //     else cout << dp[i][j][false];
  //     cout << ") ";
  //   }
  //   cout << '\n';
  // }
  FOR(j, 1, n+1) {
    if (dp[0][j][true] != LINF) {
      cout << j - 1 << '\n';
      return 0;
    }
    if (dp[0][j][false] < 0) {
      cout << j - 1 << '\n';
      return 0;
    }
  }
}


Measured memory_bytes: 392272
n,m,k=map(int,input().split())
# 解説動画を見た
mod=998244353
ans=0

#-------------------------------------------------------------------
MAX_N = 10**6

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
  fact.append(fact[-1]*(i+1)%mod)

fact_inv[-1] = pow(fact[-1],mod-2,mod)
for i in range(MAX_N+2,-1,-1):
  fact_inv[i] = fact_inv[i+1]*(i+1)%mod

def mod_comb_k(n,k,mod):
  return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod 
#-------------------------------------------------------------------

for x in range(0,k+1):
  ans+=m*pow(m-1,n-1-x,mod)*mod_comb_k(n-1,x,mod)
  ans%=mod
if ans<0:
  ans+=mod
print(ans)

Measured memory_bytes: 151296
#include <cstdio>
#include <cstdlib>
#define N 100000
#define Q 50000

using namespace std;
int *a,*b;
int n,q;

bool binst(int key, int s, int e){
	if(e - s <= 1){
		if( ((e >= 0) && a[e]==key) || a[s]==key) return true;
		else return false;
	}
	int mid = (s+e)/2;
	if(a[mid] == key) return true;
	if(a[mid] < key){
		return binst(key, mid+1, e);
	} else {
		return binst(key, s, mid-1);
	}
}

int main(){
	
	a = new int[N];
	b = new int[Q];
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf(" %d", &a[i]);
	}
	scanf("%d",&q);
	for(int i=0;i<q;i++){
		scanf(" %d", &b[i]);

	}
	int ans = 0;
	for(int i=0;i<q;i++){
		if( binst(b[i], 0, n-1)) ans++;
	}
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int X;
  cin >> X;
  int ans = 1;
  for (int b = 2; b <= sqrt(X); b++) {
    for (int p = 2; ; p++) {
      int x = pow(b, p);
      if (X < x) break;
      ans = max(ans, x);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG //FOR THE DEBUG! COMMENT OUT THIS WHEN SUBMITTING!
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 10010010010010;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

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

    long long N;cin >> N;
    vector<char> ans;
    long long minus = 26;
    for(int i = 99;i>=0;i--){
        if(N <= 0) break;
        N -= 1;
        ans.push_back('a'+N%26);
        N /= 26;
    }
    reverse(ans.begin(),ans.end());
    for(char V : ans) cout << V;
    cout << endl;
}


Measured memory_bytes: 3572
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N;
	string s;
	map<string, int>mp;
	for (int i = 0; i < N; i++) {
		cin >> s;
		mp[s]++;
	}
	vector<pair<int, string>>v;
	for (auto i : mp) {
		v.push_back({ i.second,i.first });
	}
	sort(v.begin(), v.end());
	for (auto i : v)if(i.first==v.back().first)cout << i.second << endl;
	return 0;
}


Measured memory_bytes: 27504
#include<bits/stdc++.h>
using namespace std;
int a[200005],n,i,maxn=-2000000001,minn;
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	scanf("%d",&a[i]);
	minn=a[1];
	for(i=2;i<=n;i++)
	{
		maxn=max(maxn,a[i]-minn);
		minn=min(minn,a[i]);
	}
	printf("%d\n",maxn);
	return 0;
}


Measured memory_bytes: 4004
N=int(input())
a=list (map(int,input().split()))
abs_list=[]
c=0
for i in range(N):
	c=(a[i]-(i+1))
	abs_list.append(c)
abs_list.sort()
b=abs_list[int(N/2)]	
d=0
for i in range(N):
	d=abs(abs_list[i]-b)+d		
print(d)	

Measured memory_bytes: 26836
from subprocess import*
call(('pypy3','-c',"""
h,*s=open(0)
h,w=map(int,h.split())
r=range
a,b,c,d=[[[0]*w for _ in r(h)]for i in r(4)]
for i in r(h*w):
    i,j=i//w,i%w
    a[i][j]=-~a[i][j-1]*(s[i][j]=='.')
    b[i][~j]=-~b[i][-j]*(s[i][-j-2]=='.')
    c[i][j]=-~c[i-1][j]*(s[i][j]=='.')
    d[~i][j]=-~d[-i][j]*(s[~i][j]=='.')
print(max(a[i][j]+b[i][j]+c[i][j]+d[i][j]-3for i in r(h)for j in r(w)))
"""))

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


bool isvowel(char x){
    return x=='a' || x=='i' || x=='u' || x=='e' || x=='o';
}
int main(){
    int n;
    while(cin>>n,n){
        vector<string> s(n);
        for(int i=0;i<n;i++) cin>> s[i];
        int res=-1;
        const int size=50;
        for(int k=1;k<=size;k++){
            set<string> code;
            for(int i=0;i<n;i++){
                string coding="";
                coding+=s[i][0];
                for(int j=0;j<s[i].size()-1;j++){
                    if(isvowel(s[i][j])){
                        coding+=s[i][j+1];
                    }
                }
                if(coding.size()>k){
                    coding=coding.substr(0,k);
                }
                code.insert(coding);
            }
            if(code.size()==n){
                res=k;
                break;
            }
        }
        cout<<res<<endl;

    }

}

Measured memory_bytes: 3068
class node(object):
    def __init__(self):
        self.value = None
        self.left = None
        self.right = None
        self.parent = None

def preorder(nodes,root):
    stacked = [nodes[root]]
    visited = []
    while(len(stacked)>0):
        node = stacked.pop()
        value = node.value
        left = node.left
        right = node.right
        visited.append(value)
        
        if (right not in visited) and (right != None):
            stacked.append(nodes[right])
        if (left not in visited) and (left != None):
            stacked.append(nodes[left])
    out = ""
    for i in visited:
        out += " "+str(i)
    return out

def inorder_search(cur,nodes,out_list):
    value,left,right = nodes[cur].value,nodes[cur].left,nodes[cur].right
    if left != None:
        inorder_search(left,nodes,out_list)
    out_list.append(value)
    if right != None:
        inorder_search(right,nodes,out_list)

def inorder(nodes,root):
    out_list = []
    cur = root
    inorder_search(cur,nodes,out_list)
    out = ""
    for i in out_list:
        out += " "+str(i)
    return out

def postorder_search(cur,nodes,out_list):
    value,left,right = nodes[cur].value,nodes[cur].left,nodes[cur].right

    if left != None:
        postorder_search(left,nodes,out_list)
    if right != None:
        postorder_search(right,nodes,out_list)
    out_list.append(value)

def postorder(nodes,root):
    out_list = []
    cur = root

    postorder_search(cur,nodes,out_list)
    out = ""
    for i in out_list:
        out += " "+str(i)
    return out

if __name__ == "__main__":
    n = int(input())
    nodes = [node() for _ in range(n)]
    for i in range(n):
        value,left,right = map(int,input().split())
        nodes[value].value = value
        if right != -1:
            nodes[value].right = right
            nodes[right].parent = value
        if left != -1:
            nodes[value].left = left
            nodes[left].parent = value
    root = 0
    for i in range(n):
        if nodes[i].parent is None:
            root = i

    print("Preorder")
    print(preorder(nodes,root))
    print("Inorder")
    print(inorder(nodes,root))
    print("Postorder")
    print(postorder(nodes,root))


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }


int main()
{
    string S;
    cin >> S;
    int ret = 0, tmp = 0;
    for (auto c : S)
    {
        if (c == 'R') tmp++;
        else
        {
            tmp = 0;
        }
        chmax(ret, tmp);
    }
    cout << ret << '\n';
}


Measured memory_bytes: 3624
using System;
using static System.Console;

namespace dp
{
    class Program
    {
        private static int keyNum = (int)1e9 + 7;
        static void Main(string[] args)
        {
            var hw = ReadLine().Split(' ');
            var h = int.Parse(hw[0]);
            var w = int.Parse(hw[1]);
            var grid = new string[h];
            for (var i = 0; i < h; ++i)
            {
                grid[i] = ReadLine();
            }

            var dp = new int[h,w];
            dp[0, 0] = 1;
            for (var l = 0; l < h + w - 1; ++l)
            {
                for (var tmph = Math.Max(0, l - w + 1); tmph <= l && tmph < h; ++tmph)
                {
                    var tmpw = l - tmph;
                    if (grid[tmph][tmpw] == '.')
                    {
                        if (tmph > 0)
                        {
                            dp[tmph, tmpw] = (int)(((long)dp[tmph, tmpw] + dp[tmph - 1, tmpw]) % keyNum);
                        }
                        if (tmpw > 0)
                        {
                            dp[tmph, tmpw] = (int)(((long)dp[tmph, tmpw] + dp[tmph, tmpw - 1]) % keyNum);
                        }
                    }
                }
            }
            Console.WriteLine(dp[h - 1, w - 1]);
        }
    }
}


Measured memory_bytes: 33876
#include <bits/stdc++.h>
using namespace std;
int main () {
    #define int long long
    string S;
    cin >> S;
    vector<pair<char, int>> v;
    char c = S[0];
    int N = S.size()+1;
    int a = 1;
    for (int i = 1; i <= N-1; i++) {
        if (i == N-1 || c != S[i]) {
            v.push_back(make_pair(c, a));
            a = 1;
            c = S[i];
        }
        else {
            a++;
        }
    }
    int vl = v.size();
    vector<int> A(vl+1);
    A[0] = 0;
    for (int i = 0; i < vl; i++) {
        if (v[i].first == '<') {
            A[i+1] = A[i]+v[i].second;
        }
        else {
            A[i+1] = A[i]-v[i].second;
            if (A[i+1] < 0) {
                A[i] = v[i].second;
            }
            A[i+1] = 0;
        }
    }
    long long ans = 0;
    for (int i = 0; i <= vl; i++) ans += A[i];
    for (int i = 0; i < vl; i++) {
        if (v[i].first == '<') {
            ans += A[i]*(v[i].second-1);
        }
        else {
            ans += A[i+1]*(v[i].second-1);
        }
        ans += v[i].second*(v[i].second-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7032
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long k,num=1,i;
	int n,curr;
	cin>>n>>k;
	int a[n+1];
	int st[n+1];
	memset(st,0,sizeof(st));
	for(int i=1;i<=n;++i)
		cin>>a[i];
	curr=a[1];
	st[1]++;
	vector<int> v;
	v.push_back(1);
	/*4 5
3 2 4 1*/
	for(i=2;i<=k;i++)
	{
		num++;
	//	cout<<curr<<" "<<st[curr]<<endl;
		if(st[curr])
			break;
		v.push_back(curr);
		st[curr]=num;
//		cout<<"num"<<num<<" curr"<<curr<<" a[curr]"<<a[curr]<<" "<<endl	; 
		curr=a[curr];
	}
	if(i>=k)
	{
		cout<<curr<<endl;
		return 0;
	}
	long long l=st[curr]-1,t=num-st[curr];
//	cout<<l<<" "<<t<<endl;
//	vector<int>::iterator it;
/*	for(it=v.begin();it!=v.end();it++)
		cout<<*it<<" ";*/
	cout<<v[(k-l)%t+l]<<endl;	
	return 0;
}	

Measured memory_bytes: 5896
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; i++) cin >> s[i];
  vector<char> c;
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) c.push_back(s[i][j]);
  sort(c.begin(), c.end());
  int a1 = 0, a2 = 0, a4 = 0;
  map<char, int> mp;
  for(int i = 0; i < c.size(); i++) mp[c[i]]++;
  for(auto it = mp.begin(); it != mp.end(); it++) {
    a4 += it->second / 4;
    it->second %= 4;
    if(it->second > 1) {
      a2++;
      it->second -= 2;
    }
    if(it->second > 0) {
      a1++;
      it->second = 0;
    }
  }
  bool b = false;
  if(h % 2 == 1 && w % 2 == 1) {
    if(a4 >= (h - 1) * (w - 1) / 4) {
      a4 -= (h - 1) * (w - 1) / 4;
      a2 += a4 * 2;
      if(a2 >= (h + w - 2) / 2) {
        a2 -= (h + w - 2) / 2;
        a1 += a2 * 2;
        if(a1 >= 1) {
          b = true;
        }
      }
    }
  } else if(h % 2 == 0 && w % 2 == 0) {
    if(a4 >= h * w / 4) {
      b = true;
    }
  } else {
    if(h % 2 == 1) swap(h, w);
    // w % 2 == 1
    if(a4 >= (w - 1) * h / 4) {
      a4 -= (w - 1) * h / 4;
      a2 += a4 * 2;
      if(a2 >= h / 2) {
        b = true;
      }
    }
  }
  if(b) cout << "Yes" << endl;
  else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll N;
    cin>>N;
    set<ll>primelist;
    ll K=N;
    for(ll i=1;i<=sqrt(N);i++){
        if(K%i==0){
            primelist.insert(i);
        }
    }
    ll A=*rbegin(primelist);
    string S=to_string(A);
    string T=to_string(N/A);
    cout<<max(S.size(),T.size())<<endl;
}

Measured memory_bytes: 256
n, m = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i).sort

y = Array.new(m - 1, 0)
(m - 1).times do |i|
  y[i] = x[i + 1] - x[i]
end

y.sort!

xmax = x.last
xmin =  x.first
ymaxs = y.last(n - 1)

if ymaxs.empty?
  ysum = 0
else
  ysum = ymaxs.inject(:+)
end

puts xmax - xmin - ysum

Measured memory_bytes: 11120
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    long long ans = 0;
    string s;
    cin >> s;
    vector <char> v;
    
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == 'B' && s[i+1] == 'C' && i + 1 < (int)s.size()){
            v.push_back('D');
            i++;
            continue;
        }
        v.push_back(s[i]);
        
    }
    int cnt = 0;
    for(int i = (int)v.size(); i >= 0; i--){
        if(v[i]=='A'){
            ans+=cnt;
        }
        else if(v[i]=='D'){
            cnt++;
        }
        else{
            cnt=0;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 772
def preParse(u):
    if u == None:
        return
    print(' {}'.format(u), end='')
    preParse(nodes[u][1])
    preParse(nodes[u][2])

def inParse(u):
    if u == None:
        return
    inParse(nodes[u][1])
    print(' {}'.format(u), end='')
    inParse(nodes[u][2])

def insert(nodes,z,root):
    x = root
    y = None
    while x != None:
        y = x
        if z < x:
            x = nodes[x][1]
        else:
            x = nodes[x][2]
    nodes[z][0] = y

    if y == None:
        root = z
    elif z < y:
        nodes[y][1] = z
    else:
        nodes[y][2] = z
    return root

def find(nodes,z,root):
    x = root
    while x != None and z != x:
        if z < x:
            x = nodes[x][1]
        else:
            x = nodes[x][2]
    return x

nodes = {}

# {key:[parent,left,right]}

N = int(input())

root = None

for i in range(N):
    order = input().split()
    if order[0] == 'print':
        inParse(root)
        print()
        preParse(root)
        print()
        continue

    z = int(order[1])
    if order[0] == 'insert':
        nodes[z] = [None,None,None]
        root = insert(nodes,z,root)
        continue

    if order[0] == 'find':
        k = find(nodes,z,root)
        if k == z:
            print('yes')
        else:
            print('no')



Measured memory_bytes: 77968
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

string N;
int K;

ll dp[110][2][4][2];

// i 桁目で合計sk個 maxかどうか
ll dfs(int i, int lz, int sk, int mx) {
	if (i == -1) {
		return !lz && sk == K;
	}
	if (sk > K) return 0;
	// cout << i << " " << lz << " " << sk <<" " <<  mx << endl;
	
	ll &res = dp[i][lz][sk][mx];
	if (~res) return res;
	res = 0;
	
	REP(k, 10) {
		if (mx && k > N[i] - '0') break;
		res += dfs(i - 1, lz && k == 0, sk + (k != 0), mx && k == (N[i] - '0'));
	}
	// cout << i << " " << lz << " " << sk << mx << endl;
	return res;
}

int main() {
	cin >> N >> K;
	while (N.size() < 105) N.insert(N.begin(), '0');
	reverse(ALL(N));
	ll ans = 0;
	
	memset(dp, -1, sizeof(dp));
	cout << dfs(104, true, 0, true);
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
      public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int num1 = sc.nextInt();
            int num2 = sc.nextInt();
            int num3 = sc.nextInt();
            if(num1 > num2 && num1 > num3){
              System.out.println(num2 + num3);
            } else if(num2 > num3 && num2 >num1){
              System.out.println(num1 + num3);
            } else {
              System.out.println(num2 + num1);
            }
          }
}


Measured memory_bytes: 21844
// In the Name of God
#include<bits/stdc++.h>

#define test(t) int t; cin>>t; while(t--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORE(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long int
#define em emplace_back
#define pb push_back
#define INF 1e7+5
#define MOD int(1e9+7)
#define print printf
#define in scanf
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

template<class type>
void displaySingle(type &arr)
{
	for(auto i:arr)
		cout<<i<<" ";
	cout<<endl;
}

template<class type>
void displayDouble(type &arr)
{
	for(auto &&i : arr) 
	{
		for(auto &&j : i) 
			cout << j << " ";
		cout << std::endl;
	}
}

int main()
{
	fast
	int n,m;
	cin>>m>>n;
	vector <string> str(m);
	REP(i,m)
		cin>>str[i];
	vector <vector <ll>> dp(m,vector <ll>(n));
	REP(i,m)
	{
		if(str[i][0] == '#')
			break;
		dp[i][0] = 1;
	}
	REP(i,n)
	{
		if(str[0][i] == '#')
			break;
		dp[0][i] = 1;
	}
	FOR(i,1,m)
	{
		FOR(j,1,n)
		{
			if(str[i][j] == '#')
				continue;
			dp[i][j] = (dp[i-1][j]%MOD + dp[i][j-1]%MOD)%MOD;
		}
	}
	cout<<dp[m-1][n-1]<<endl;
}

Measured memory_bytes: 12132
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
struct state{
  int x,y;
  int c;
  state(){}
  state(int x,int y,int c):x(x),y(y),c(c){}
};
int h,w;
long long l;
char g[111][111];
state next[111][111][5];
bool used[111][111][5];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
char D[256];
char DD[4];
int main(void)
{
  D['N']=0; DD[0]='N';
  D['E']=1; DD[1]='E';
  D['S']=2; DD[2]='S';
  D['W']=3; DD[3]='W';
  for(;;){
    scanf("%d%d%lld",&h,&w,&l); if(!h) break;
    memset(used,0,sizeof(used));
    int d,x,y;
    memset(g,'#',sizeof(g));
    for(int i=1;i<=h;i++){
      for(int j=1;j<=w;j++){
        scanf(" %c",g[i]+j);
        if(g[i][j]!='#' && g[i][j]!='.'){
          x=j;
          y=i;
          d=D[int(g[i][j])];
        }
      }
    }
    vector<state> v;
    for(;;){
      int nx,ny,nd=d;
      if(!l){
        printf("%d %d %c\n",y,x,DD[d]);
        goto NEXT;
      }
      if(used[y][x][d]){
        v.push_back(state(x,y,d));
        nx=x; ny=y; nd=d;
        x=next[ny][nx][nd].x;
        y=next[ny][nx][nd].y;
        d=next[ny][nx][nd].c;
        while(x!=nx || y!=ny || d!=nd){
          int mx,my,md;
          v.push_back(state(x,y,d));
          mx=x; my=y; md=d;
          x=next[my][mx][md].x;
          y=next[my][mx][md].y;
          d=next[my][mx][md].c;
        }
        l%=v.size();
        printf("%d %d %c\n",v[l].y,v[l].x,DD[v[l].c]);
        goto NEXT;
      }
      while(g[y+dy[nd]][x+dx[nd]]=='#'){
        nd=(nd+1)%4;
      }
      nx=x+dx[nd];
      ny=y+dy[nd];
      used[y][x][d]=true;
      next[y][x][d]=state(nx,ny,nd);
      x=nx; y=ny; d=nd;
      l--;
    }
  NEXT:;
  }
  return 0;
}

Measured memory_bytes: 0
n = int(input())
L=[]
st=0
sh=0
for i in range(n):
    x,y=input().split()
    L.append([x,y])




for i in L:
    j=sorted(i)
    if i[0] == i[1]:
        st+=1
        sh+=1
    else:
        if i[0] ==j[0]:
            sh += 3
        else:
            st+=3


print (st,sh)

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

#define      pai              acos(-1)
#define      ff               first
#define      ss               second
#define      ll               long long
#define      pb               push_back
#define      mp               make_pair
#define      pll              pair<ll,ll>
#define      sz(a)            (ll)a.size()
#define      endl             "\n"
#define      gcd(a, b)        __gcd(a, b)
#define      lcm(a, b)        ((a)*((b)/gcd(a,b))
#define      all(vec)         vec.begin(),vec.end()
#define      ms(a, b)         memset(a,b,sizeof(a))
#define      TEST_CASE(t)     for(int zz=1;zz<=t;zz++)
#define      PRINT_CASE       printf("Case %d: ",zz)
#define      fii              freopen("input.txt","r",stdin);
#define      foo              freopen("output.txt","w",stdout);
#define      FAST             ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);

const ll M   = 1e9+7;
const ll mxn = 1e5+7;

int  main()
{
    ll i,j,k,a,b,c,d,n,m,t,h,u,v,x,y,z;
    cin>>n;
    ll cnt  =0;
    ll prv  =0;
    for(i=1;i<=n;i++)
    {
        cin>>m;
        if(m<prv)
        {
            cnt+=(prv-m);
        }
        prv=max(prv,m);
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3528
S=input()
N=len(S)
ans="Yes"
for i in range(N):
    if S[i]!=S[-i-1]:
        ans="No"

c=S[:(N-1)//2]
for i in range(len(c)):
    if c[i]!=c[-i-1]:
        ans="No"

d=S[(N-1)//2+1:]
for i in range(len(d)):
    if d[i]!=d[-i-1]:
        ans="No"

print(ans)

Measured memory_bytes: 3064
N = int(input())
num = [0 for _ in range(5)]
for _ in range(N):
    s = input()[0]
    if s == "M":
        num[0] += 1
    elif s == "A":
        num[1] += 1
    elif s == "R":
        num[2] += 1
    elif s == "C":
        num[3] += 1
    elif s == "H":
        num[4] += 1
ans = 0
for i in range(0, 3):
    for j in range(i + 1, 4):
        for k in range(j + 1, 5):
            ans += num[i] * num[j] * num[k]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin>>n;
  vector<int>hiro(n);
  int flag=0;
  for(int i=0;i<n;i++){
    cin>>hiro.at(i);
    if(hiro.at(i)%2==0){
      if(hiro.at(i)%5==0 | hiro.at(i)%3==0){
        flag+=0;
      }
      else{
        flag+=1;
      }
    }
    else{
      flag+=0;
    }
  }
  if(flag==0){
    cout<<"APPROVED"<<endl;
  }
  else{
    cout<<"DENIED"<<endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int[][][] room = new int[4][3][10];

		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);

		for(int i = 0;i<4;i++) {
			for(int j = 0;j<3;j++) {
				for(int k = 0;k<10;k++) {
					room[i][j][k] = 0;
				}
			}
		}

		int n = sc.nextInt();
		for(int i = 0;i<n;i++) {
			int d = sc.nextInt();
			int f = sc.nextInt();
			int r = sc.nextInt();
			int v = sc.nextInt();
			room[d-1][f-1][r-1] += v;
		}

		for(int i = 0;i<4;i++) {
			for(int j = 0;j<3;j++) {
				for(int k = 0;k<10;k++) {
					System.out.print(" "+room[i][j][k]);
				}
				System.out.println();
			}
			if(i != 3) System.out.println("####################");
		}
	}
}



Measured memory_bytes: 29576
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;


typedef long long ll;
//typedef pair<string, int> pii;
//typedef pair<ll, ll> pll;
typedef vector<int> vi;
//typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef pair <int,int> pii;
typedef pair <int,pii> pi;
#define fi first
#define se second
#define pb push_back
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sv(v) sort(v.begin(),v.end())
#define floop(a,n) for(int i=a; i<n; i++)
#define max3(a,b,c) max(a, max(b,c))
#define max4(a,b,c,d) max(a, max(b,max(c,d)))
#define min3(a,b,c) min(a, min(b,c))
#define min4(a,b,c,d) min(a, min(b,min(c,d)))
vector <int> v;
string int_to_string(int a){return to_string(a);}
int string_to_int(string s){stringstream x(s);int a=0; x>>a; return a;}
//long long int gcd(long long int a, long long int b){if(a%b==0)return b;return gcd(b, a%b);}
//long long int lcm(long long int a, long long int b){return (a*b)/gcd(a, b);}

//long long int factorial(int a){if(a==0)return 1;elsereturn a*factorial(a-1);}



int main()
{
    map <string,int>mp;
    
    int a,b,c,max=0;
    string s,p;
    
    cin >> a;
    while(a--)
    {
        cin >> s;
        mp[s]++;
    }
    
    cin >> a;
    while(a--)
    {
        cin >> s;
        mp[s]--;
    }
    
    for(auto it = mp.cbegin(); it!=mp.cend(); ++it)
    {
        if(it -> second > max)
            max = it -> second;
    }
    
    cout << max << endl;
    
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <string>
typedef long long ll;

using namespace std;

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int len = Z;
    int res = 0;
    while (len+Y+Z <= X){
	res++;
	len += Y+Z;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>      // std::setprecision
using namespace std;
#define what_is(x) cerr << #x << " is " << x << endl;
#define bit(x,i) (x&(1<<i))  //select the bit of position i of x
#define lowbit(x) ((x)&((x)^((x)-1))) //get the lowest bit of x
#define hBit(msb,n) asm("bsrl %1,%0" : "=r"(msb) : "r"(n)) //get the highest bit of x, maybe the fastest
#define IN(i,l,r) (l<i&&i<r) //the next for are for checking bound
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define F(i,L,R) for (int i = L; i < R; i++) //next four are for "for loops"
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define FF(i,L,R) for (int i = L; i > R; i--)
#define FFE(i,L,R) for (int i = L; i >= R; i--)
#define char2Int(c) (c-'0')
#define lastEle(vec) vec[vec.size()-1] 
#define SZ(x) ((int)((x).size()))
#define REMAX(a,b) (a)=max((a),(b)) // set a to the maximum of a and b
#define REMIN(a,b) (a)=min((a),(b));
#define FENWICK(k) (k&-k)
#define FOREACH(i,t) for (auto i=t.begin(); i!=t.end(); i++) // traverse an STL data structure
#define ALL(c) (c).begin(),(c).end() //handy for function like "sort()"
#define PRESENT(c,x) ((c).find(x) != (c).end()) 
#define CPRESENT(c,x) (find(ALL(c),x) != (c).end()) 
#define LL long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF 1001001001
#define PI 3.1415926535897932384626
//for map, pair
#define mp make_pair
#define fi first
#define se second
//for vectors
#define pb push_back
typedef int elem_t;
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
// directions
const int fx[4][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}};
const int fxx[8][2] = {{0,1}, {0,-1}, {1,0}, {-1,0}, {1,1}, {1,-1}, {-1,1}, {-1,-1}};
const int rogi[4][2] = { {1,1}, {1,-1}, {-1,1}, {-1,-1} };

int n,x;

void dane() {
	cin>>n>>x;
	int ans = 0;
	int d = -1;
	F(i,0,n) {
		int l;
		cin>>l;
		ans+=l;
		if(ans > x && d==-1) {
			d = i+1;
		}
	}
	cout<<(d==-1?(n+1):d)<<endl;
}   


int main() {
	IOS
	// int t;
	// cin>>t;
	// F(i,0,t)
	    dane();
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

a.sort()

u,d,z = 0,0,0
uu,dd = [],[]
for i in range(n):
    if a[i] > 0:
        u += 1
        uu.append(a[i])
    elif a[i] < 0:
        d += 1
        dd.append(a[i])
    else:
        z += 1
        
dd = dd[::-1]
        
ans = []
if u == 0 and d == 0:
    for i in range(z-1):
        ans.append((0,0))
    cur = 0
    
elif d == 0:
    if z != 0:
        for i in range(z-1):
            ans.append((0,0))
        cur = 0
        for i in range(u-1):
            ans.append((cur,uu[i]))
            cur -= uu[i]
        ans.append((uu[u-1],cur))
        cur = uu[u-1] - cur
    else:
        cur = uu[0]
        for i in range(u-2):
            ans.append((cur,uu[i+1]))
            cur -= uu[i+1]
        ans.append((uu[u-1],cur))
        cur = uu[u-1] - cur
        
elif u == 0:
    if z != 0:
        for i in range(z-1):
            ans.append((0,0))
        cur = 0
        for i in range(d):
            ans.append((cur,dd[i]))
            cur -= dd[i]
    
    else:
        cur = dd[0]
        for i in range(d-1):
            ans.append((cur,dd[i+1]))
            cur -= dd[i+1]
            
else:
    for i in range(z):
        ans.append((uu[0],0))
    cur1 = uu[0]
    cur2 = dd[0]
    for i in range(d-1):
        ans.append((cur1,dd[i+1]))
        cur1 -= dd[i+1]
    for i in range(u-1):
        ans.append((cur2,uu[i+1]))
        cur2 -= uu[i+1]
        
    ans.append((cur1,cur2))
    cur = cur1 - cur2
    
print(cur)
for i in ans:
    print(*i)

Measured memory_bytes: 90572
from collections import deque
s=input()
Q=deque()
for i in range(len(s)):
    if s[i]=="0":
        Q.append("0")
    elif s[i]=="1":
        Q.append("1")
    else:
        if len(Q)==0:
            pass
        else:
            Q.pop()
ans="".join(list(Q))
print(ans)

Measured memory_bytes: 3316
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        mut k: u64,
    }
    let mut ans = "".to_string();
    for i in 0..s.len() - 1 {
        let acc = (s[i] as u8 - 'a' as u8) as u64;
        if k / (26u64 - acc) > 0 && acc != 0 {
            ans += &'a'.to_string();
            k -= (26 - acc);
        } else {
            ans += &((acc as u8 + b'a') as char).to_string();
        }
    }
    k %= 26;
    let mut acc = ((s[s.len() - 1] as u8 - b'a') + k as u8) % 26;
    ans += &((acc + b'a') as char).to_string();

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int co[1010] = { 0 };
int main(){
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		int n1 = i;
		for (int j = 2; j <= i; j++) {
			while (n1 % j == 0) {
				co[j]++;
				n1 /= j;
			}
		}
	}
	long long ans = 1;
	for (int i = 0; i < 1010; i++) {
		ans = ans * (co[i] + 1) % 1000000007;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int x, y;
int i;
int gcd, A;

while(1){
  scanf("%d %d",&x, &y);
  if(x>=1 && y<=1000000000)break;
}
if(x>y){
  while(1){
  A=x%y;
  if(A==0){gcd=y; break;}
  else{x=y; y=A;}
  }
}else if(x<y){
  while(1){
  A=y%x;
  if(A==0){gcd=x; break;}
  else{y=x; x=A;}
  }
}else gcd=x;
printf("%d\n",gcd);
return 0;
}



Measured memory_bytes: 2140
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    string s[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string k;
    cin >> k;
    rep(i,7)if(k == s[i]){
        cout << 7 - i << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin>>s;
  int mat[s][2];
  bool f = false;
  for(int i = 0;i<s;i++){
  	cin>>mat[i][0]>>mat[i][1];    
  }
  for(int i = 0;i<s-2;i++){
  	if(mat[i][0]==mat[i][1]){
    	if(mat[i+1][0]==mat[i+1][1]){
        	if(mat[i+2][0]==mat[i+2][1]) {f = true;break;}
        }
    }
  }
  if(f) cout<<"Yes";
  else cout<<"No";
  return 0;
  
}

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

namespace Atc_0045
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());

            if (N % 500 <= A)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }

        }
    }
}


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

using namespace std;

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

  vector<int> va(n);
  map<int, int> cnts;
  for (int i = 0; i < n; i++) {
    cin >> va[i];
    cnts[va[i]]++;
  }

  if (n % 3 != 0) {
    cout << (cnts[0] == n ? "Yes" : "No") << '\n';
    return 0;
  }

  bool ans;
  switch (cnts.size()) {
    case 1: {
      ans = cnts[0] == n;
      break;
    }
    case 2: {
      ans = cnts[0] == n / 3;
      break;
    }
    case 3: {
      int xor_all = accumulate(cnts.begin(), cnts.end(), 0,
                               [](int a, auto b) { return a ^ b.first; });
      ans = xor_all == 0 && all_of(cnts.begin(), cnts.end(),
                                   [&](auto p) { return p.second == n / 3; });
      break;
    }
    default: { ans = false; }
  }

  cout << (ans ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var x = ReadInts().ToList();

            var x_min = x.Min();
            var x_max = x.Max();

            var anslist = new List<int>();
            for (int i = 1; i <= 2000; i++)
            {
                anslist.Add(Max(Abs(x_min - i), Abs(x_max - i)));
            }
            WriteLine(anslist.Min());
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 20336
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        c: i32,
        b: [i32;m],
        aa: [[i32;m];n]
    }
    let mut cnt = 0;
    for a in aa {
        let v = a.iter().zip(b.iter()).map(|(x,y)| x * y).sum::<i32>() + c;
        if v > 0 {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<bitset>
#include<math.h>
using namespace std;
#define ll long long

int main(){
    ll N,A,i;
    cin >> N;
    map<ll,bool> mp;
    ll ans=0;
    for(i=0;i<N;i++){
        cin >> A;
        if(mp.count(A)==0)mp[A]=0;
        mp[A]=(mp[A]+1)%2;
        ans+=-1+2*mp[A];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

int main()
{
  int N, K;
  string S;
  cin >> N >> K >> S;

  for (int i = 0; i < N; ++i)
  {
    if (i + 1 == K) S[i] = S[i] + 32;
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#  ABC 086 C - Traveling
N = int(input())

t = [0] * (N+1)
x = [0] * (N+1)
y = [0] * (N+1)

for i in range(1,N+1):
    t[i],x[i],y[i] = map(int,input().split())

boolian = True    
        
for i in range(N):
    delta_t = t[i+1] - t[i]
    delta_x = x[i+1] - x[i]
    delta_y = y[i+1] - y[i]
    
    delta_x = abs(delta_x)
    delta_y = abs(delta_y)
    
    delta_sum = delta_x + delta_y
    
    k = delta_sum % 2 
    j = delta_t % 2

    if -delta_t <= delta_sum and delta_sum <= delta_t:
        if k == 0 and j == 0:
            boolian = True
            continue
        if k == 1 and j == 1:
            boolian = True
            continue
        else:
            boolian = False
            print('No')
            break
    else:
        boolian = False
        print('No')
        break

if boolian == True:
    print('Yes')

Measured memory_bytes: 17356
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, R;
    scan(N, R);
    if (10 <= N)
    {
        writeln(R);
    }
    else
    {
        writeln(R + 100 * (10 - N));
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define PB push_back
#define SP << " " <<





int main(void){
	int N;
    cin >> N;
    string S;
    cin >> S;

    ll ans = 1;

    rep(i,N-1){
        if(S[i]!=S[i+1]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}



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

int main() {
  int a, b;
  char op;
  for (;;) {
    cin >> a >> op >> b;
    int ans = a;

    switch (op) {
    case '+':
      ans += b;
      break;
    case '-':
      ans -= b;
      break;
    case '*':
      ans *= b;
      break;
    case '/':
      ans /= b;
      break;
    default:
      return 0;
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 3100
def resolve():
    A,B=map(int,input().split())
    for i in range(1,20000):
        a=int(i*0.08)
        b=int(i*0.1)
        if a==A and b==B:
            print(i)
            return
    else:
        print(-1)


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
	IOS;
	int n; cin>>n;
	string s; cin>>s;
	char c[26];
	for(int i=0;i<26;i++){
		c[i]='A'+(n+i)%26;
	}
	for(int i=0;i<s.length();i++){
		s[i]=c[s[i]-'A'];
	}
	cout<<s<<endl;
}

Measured memory_bytes: 256