akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 

#define endl '\n'

 
typedef long long int ll;
 

const ll mod =1e9+7;
const ll maxn=1e5+7;
#define int ll
ll t[800400];
ll lazy[800400];

 
void push(ll id,ll l,ll r){
  if(lazy[id]){
    t[id]+=lazy[id];
    if(l!=r){
      lazy[id<<1]+=lazy[id];
      lazy[id<<1|1]+=lazy[id];
    }
    lazy[id]=0;
  }
}
 

 
void update(ll id,ll l,ll r,ll lq,ll rq,int val){
  push(id,l,r);
  if(l>r||lq>r||l>rq)return;
  if(lq<=l&&r<=rq){
    lazy[id]+=val;
    push(id,l,r);
    return;
  }
  ll mid=(l+r)>>1;
  update(id<<1,l,mid,lq,rq,val);
  update(id<<1|1,mid+1,r,lq,rq,val);
  t[id]=t[id<<1]+t[id<<1|1];
}
 
ll count(ll id,ll l,ll r,ll lq,ll rq){
  push(id,l,r);
  if(l>r||lq>r||l>rq)return 0;
  if(lq<=l&&r<=rq){
    return t[id];
  }
  ll mid=(l+r)>>1;
  return count(id<<1,l,mid,lq,rq)+count(id<<1|1,mid+1,r,lq,rq);
}
int32_t main()
{ 

   IOS
   ll n,d,a;
   cin>>n>>d>>a;
   vector<pair<int,int>> v;
   for(int i=0;i<n;++i)
   {
      int x,y;
      cin>>x>>y;
      v.push_back({x,y});
   }
   sort(v.begin(),v.end());
   set<pair<int,int>> s;
   for(int i=0;i<v.size();++i)
   {
    s.insert({v[i].first,i+1});
    update(1,1,n,i+1,i+1,v[i].second);
   }
   int ans=0;
   for(int i=0;i<n;++i)
   {
      int f=count(1,1,n,i+1,i+1);
      
      if(f<=0)
        continue;
      else
      {
        int pla=v[i].first+2*d;
        int in=n;
        auto it=s.lower_bound({pla,1e9});
        it--;
        pair<int,int> p=*it;
        in=p.second;
        int req=(f+a-1)/(a);
        ans+=req;
        req*=a;
        
        update(1,1,n,i+1,in,-req);


      }
   }
   cout<<ans<<endl;

   
}

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

public class Program
{
    static void Main()
    {
        char[] w = Console.ReadLine().ToCharArray();
        char[] counts = w.Distinct().ToArray();
        for (int i = 0; i < counts.Length; i++)
        {
            int count = 0;
            for (int j = 0; j < w.Length; j++)
            {
                if (counts[i] == w[j])
                    count++;
            }
            if (count % 2 == 1)
            {
                Console.WriteLine("No");
                return;
            }
        }
        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 13268
#include <iostream>
#define llint long long
#define mod 998244353

using namespace std;

llint modpow(llint a, llint n)
{
	if(n == 0) return 1;
	if(n % 2){
		return ((a%mod) * (modpow(a, n-1)%mod)) % mod;
	}
	else{
		return modpow((a*a)%mod, n/2) % mod;
	}
}

llint n, s;
llint val[1005];

llint calc(llint x)
{
	llint ret = 0;
	for(int i = 1; i <= n+1; i++){
		llint tmp = val[i];
		for(int j = 1; j <= n+1; j++){
			if(i == j) continue;
			tmp *= (x-j+mod)%mod, tmp %= mod;
			tmp *= modpow((i-j+mod)%mod, mod-2), tmp %= mod;
		}
		ret += tmp, ret %= mod;
	}
	return ret;
}

int main(void)
{
	cin >> n >> s;
	
	llint sum = 0;
	for(int i = 1; i <= n+1; i++){
		sum += modpow(i, n-1), sum %= mod;
		val[i] = sum;
	}
	
	llint ans = (s+1)*s/2%mod;
	ans *= modpow(s+1, n-2), ans %= mod;
	
	llint tmp = modpow(2, n-1) * calc(s/2) % mod;
	tmp = calc(s) - 2*tmp%mod + mod, tmp %= mod;
	if(s % 2 == 0) tmp *= mod-1, tmp %= mod;
	
	ans += tmp, ans %= mod;
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3120
import itertools
n = int(raw_input())
p = map(int, raw_input().split())
q = map(int, raw_input().split())

ls = range(1, n+1)
seq = list(itertools.permutations(ls))
p_idx = seq.index(tuple(p)) + 1
q_idx =  seq.index(tuple(q)) + 1
print abs(p_idx - q_idx)

Measured memory_bytes: 7940
#include <iostream>
#include <set>
#include <stack>
#include <vector>
#include <map>
#include <string>
#include <string.h>
#include <cstring>
#include <queue>
#include <algorithm>
#include <math.h>

using namespace std;

typedef long long ll;

int N, K;
int stonez[100001];
int DP[100001];

int calculate(int index) 
{
	if (index == N - 1)
		return DP[index] = 0;

	if (DP[index] != -1)
		return DP[index];

	int ans = abs(stonez[index] - stonez[index+1]) + calculate(index+1);
	for (int i = 1; i <= K; i++) 
	{
		if(index + i < N)
			ans = min(ans, abs(stonez[index] - stonez[index + i]) + calculate(index + i));
	}
	return DP[index] = ans;
}

int main()
{
	cin >> N >> K;
	for (int i = 0; i < N; i++) 
	{
		cin >> stonez[i];
	}
	memset(DP,-1,sizeof DP);
	cout << calculate(0);
}

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

int main() {
  int N, K;
  cin >> N >> K;
  
  cout << (int)(log(N) / log(K)) + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

class Main{

	public static void main(String[] args) {

		List<Integer> time=new ArrayList<Integer>();		//キューの処理にかかる時間
		List<String> cue_nm=new ArrayList<String>();
		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String moto="";
		StringTokenizer stk;
		int cue_su=0;		//もともと与えられたキュー数
		int jikan=0;		//現在の経過時間
		int quantum=0;		//キューの処理時間制限
		int que_zanryo=0;	//キューの残数

		String name="";				//変数保管用
		int suuji=0;
		boolean end=false;

		try {
			moto=bfr.readLine();
			stk=new StringTokenizer(moto, " ");
			cue_su=Integer.parseInt(stk.nextToken());
			quantum=Integer.parseInt(stk.nextToken());

			que_zanryo=cue_su;

			for(int i=0; i<cue_su; i++) {
				moto=bfr.readLine();
				stk=new StringTokenizer(moto," ");
				name=stk.nextToken();
				suuji=Integer.parseInt(stk.nextToken());

				if(suuji>quantum) {
					time.add(suuji-quantum);
					cue_nm.add(name);
					jikan+=quantum;
				}
				else {
					//リストにはついかしない
					jikan+=suuji;
					System.out.println(name+" "+jikan);
				}
			}

			while(true) {
				name=cue_nm.get(0);
				suuji=time.get(0);

				if(suuji>quantum) {
					jikan+=quantum;
					suuji=suuji-quantum;
					cue_nm.remove(0);
					time.remove(0);
					cue_nm.add(name);
					time.add(suuji);
				}
				else {
					jikan+=suuji;
					cue_nm.remove(0);
					time.remove(0);
					System.out.println(name+" "+jikan);
				}

				if(cue_nm.size()<=0) {
					System.exit(0);
				}

				else {
					end=false;
				}
			}

		}catch(IOException e) {
			System.exit(0);
		}
		catch(IndexOutOfBoundsException e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 55880
import itertools

N = int(input())

towns = []
for i in range(N):
    town = list(map(lambda x: int(x), input().split(" ")))
    towns.append(town)

p = list(itertools.permutations(towns))
result = 0
for nums in p:
    pre = None
    for num in nums:
        if pre is None:
            pre = num
            continue
        x = pow(pre[0] - num[0], 2)
        y = pow(pre[1] - num[1], 2)
        result += pow(x+y, 0.5)
        pre = num

result /= len(p)
print(result)


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

struct dish{
  long long a;
  long long b;
  bool operator<( const dish& right ) const {
    return a+b < right.a+right.b;
  }
};

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

  vector<dish> d;

  for(int i = 0;i < n;i++){
    dish di;
    cin >> di.a >> di.b;
    d.push_back(di);
  }
  sort(d.begin(),d.end());
  long long ret = 0;
  for(int i = n-1;i>=0;i--){
    ret += d[i].a;
    i--;
    if(i>=0){
      ret -= d[i].b;
    }
  }
  cout << ret << endl;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=1<<18;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=2000000000;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int n;
int a[maxn];

int main()
{
	IOS;
    cin>>n;
    cout<<2*n-1<<'\n';
    REP(i,n) cin>>a[i];
    int idx=0;
    REP(i,n) if(abs(a[idx])<abs(a[i])) idx=i;
    REP(i,n) cout<<idx+1<<' '<<i+1<<'\n';
    REP(i,n) a[i]+=a[idx];
    if(a[0]<=0)
        REP(i,n-1) cout<<n-i<<' '<<n-i-1<<'\n';
    else REP(i,n-1) cout<<i+1<<' '<<i+2<<'\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define qmax(x,y) (x=max(x,y));
using namespace std;

typedef long long ll;
const int Maxn=210000;
const ll mod=1000000007;

int n,h[Maxn],x;
ll t[Maxn];

void add(int x,ll y) {
	for(;x<=n;x+=x&-x) qmax(t[x],y);
}

ll query(int x,ll ans=0) {
	for(;x;x&=x-1) qmax(ans,t[x]); return ans;
}

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&h[i]);
	for(int i=1;i<=n;i++) {
		scanf("%d",&x);
		add(h[i],query(h[i])+x);
	}
	printf("%lld\n",query(n));
	return 0;
}


Measured memory_bytes: 2560
import itertools
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        P = tuple(map(int, input().split()))
        Q = tuple(map(int, input().split()))
        perm = list(itertools.permutations(range(1, N + 1)))

        a, b = 0, 0
        for i, p in enumerate(perm):
            if p == P:
                a = i
            if Q == p:
                b = i

        print(abs(a - b))


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 45040
#include <cstdio>
#include <iostream>

using namespace std;

int gcd(int a, int b) {
  while (b) {
    int r = a % b;
    a = b;
    b = r;
  }
  return a;
}

int a[100'009];

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int x = 1;
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    x /= gcd(a[i] / 2, x);
    if ((long long)x * (a[i] / 2) > m) {
      puts("0");
      return 0;
    }
    x *= a[i] / 2;
  }
  for (int i = 0; i < n; ++i) {
    if ((x / (a[i] / 2)) % 2 != (x / (a[0] / 2)) % 2) {
      puts("0");
      return 0;
    }
  }
  int ans = m / x;
  if ((x / (a[0] / 2)) % 2 == 1) {
    ++ans;
  }
  ans /= 2;
  printf("%d\n", ans);
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
    }
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        ans += max(0LL, a.at(i) - x);
        a.at(i) = min(a.at(i), x);
    }
    for(int i = 1; i < n; ++i){
        if(a.at(i - 1) + a.at(i) <= x){
            continue;
        }
        ll rmv = min(a.at(i), a.at(i - 1) + a.at(i) - x);
        a.at(i) -= rmv;
        ans += rmv;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define pii pair<ll,ll>
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
  FAST/**/
   
   string s;
   cin>>s;
   
   if(s.back() == 's')
        s+="es";
   else s+="s";
   cout<<s;
   
   
   return 0;        
}  

  
          
   

Measured memory_bytes: 3648
#include<stdio.h>
#define max(a,b) a>b ?a : b;
#define min(a,b) a<b ?a : b;
#define abs(a) a>0 ?a : -a;
int main(void){
  int n,i,j,k,sum=0;
  int l[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      for(k=j+1;k<n;k++){
        if(l[i]+l[j]>l[k]&&l[i]+l[k]>l[j]
        &&l[j]+l[k]>l[i]){
          if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]){
            //printf("%d-%d-%d\n",i+1,j+1,k+1);

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


Measured memory_bytes: 1736
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	int N,Z,W;
	int a[2010]={};
	
	cin >> N >> Z >> W;
	for(int i=0;i<N;i++)
		cin >> a[i];
	
	if(N==1)
		cout << abs(a[N-1]-W) << endl;
	else
		cout << max(abs(a[N-2]-a[N-1]),abs(a[N-1]-W)) << endl;
	return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=LI()
for i in range(n):
    if lis[i]==1:
        one=i+1
#print(one)
ans=ceil((n-1)/(k-1))
print(ans)
    

Measured memory_bytes: 52880
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) { return std::vector<T>(n, std::forward<T>(val)); }
template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}
template<class Cond> struct chain {
  Cond cond; chain(Cond cond) : cond(cond) {}
  template<class T> bool operator()(T& a, const T& b) const { if(cond(a, b)) { a = b; return true; } return false; }
};
template<class Cond> chain<Cond> make_chain(Cond cond) { return chain<Cond>(cond); }

int main() {
  i64 N;
  cin >> N;
  i64 now = 1;
  i64 INF = i64(1e18) + 1;
  vector<i64> A(N);
  rep(i,0,N) {
    cin >> A[i];
    if(A[i] == 0) {
      cout << 0 << endl;;
      return 0;
    }
  }
  rep(i,0,N) {
    i64 a = A[i];
    if(now > INF / a) {
      cout << -1 << endl;
      return 0;
    }
    now *= a;
  }
  if(now >= INF) {
    cout << -1 << endl;

  }
  else {
    cout << now << endl;
  }
}


Measured memory_bytes: 4048
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# (a,b,c,d) -> (ab,bc,cd,da) と変換
# xor x で不変量になる

N = int(readline())

A = list(map(int,readline().split()))
B = list(map(int,readline().split()))

def convert(A):
    return [x ^ y for x,y in zip(A,A[1:])] + [A[-1] ^ A[0]]

C = convert(A); D = convert(B)

def Z_algorithm(S):
    # 共通接頭辞の長さを返す
    N=len(S)
    arr = [0]*N
    arr[0] = N
    i,j = 1,0
    while i<N:
        while i+j<N and S[j]==S[i+j]:
            j += 1
        arr[i]=j
        if not j:
            i += 1
            continue
        k = 1
        while i+k<N and k+arr[k]<j:
            arr[i+k] = arr[k]
            k += 1
        i += k; j -= k
    return arr

Z = Z_algorithm(D + [-1] + C + C)[N+1:N+N+1]

K = [i for i,x in enumerate(Z) if x == N]
X = [A[k] ^ B[0] for k in K]

print('\n'.join('{} {}'.format(k,x) for k,x in zip(K,X)))

Measured memory_bytes: 67028
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "No"; return;}

void solve() {
    int a, b;
    cin >> a >> b;
    if (b == 1)
        cout << 0;
    else
        for (int i = 1;;++i)
            if (a + (i - 1) * (a - 1) >= b) {
                cout << i; return;
            }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
//template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
signed main(){
  string s,t;
  cin>>s>>t;
  int counter=0;
  if(s[0]==t[0]) ++counter;
  if(s[1]==t[1]) ++counter;
  if(s[2]==t[2]) ++counter;
  cout<<counter<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,m,i,sum=0,j;
    cin>>n>>m;
    int a[m];
    for(i=0;i<m;i++)
    {
        cin>>a[i];
    }
    for(j=0;j<m;j++)
    {
        sum=sum+a[j];
    }
    if(n>=sum)
        cout<<n-sum;
    else
        cout<<-1;

}


Measured memory_bytes: 3640
fn get_line() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line
}

fn read_and_add(mat: &mut Vec<Vec<i64>>, n: &usize) {
    for _ in 0..*n {
        let nums: Vec<i64> = get_line().trim()
            .split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect();
        mat.push(nums);
    }
}

fn main() {
    let nums: Vec<usize> = get_line().trim()
        .split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();
    let (n, m, l) = (nums[0], nums[1], nums[2]);

    let mut n_by_m: Vec<Vec<i64>> = Vec::new();
    let mut m_by_l: Vec<Vec<i64>> = Vec::new();
    let mut result: Vec<Vec<i64>> = vec![vec![0; l]; n];

    read_and_add(&mut n_by_m, &n);
    read_and_add(&mut m_by_l, &m);

    for i in 0..n {
        for j in 0..m {
            for k in 0..l {
                result[i][k] += n_by_m[i][j] * m_by_l[j][k];
            }
        }
    }
    
    for i in 0..n {
        for j in 0..l {
            print!("{}{}", result[i][j], if j == l - 1 { "\n" } else { " " });
        }
    }
}



Measured memory_bytes: 5048
#include<iostream>
#include<vector>
using namespace std;
int n,a,b,c,min_c=-1;
vector<int> l;
void dfs(int n,int ra,int rb,int rc,int ma,int mb,int mc){
  if(l.size()==n){
    if(ra==0||rb==0||rc==0) return;
    int tmp = abs(ra-a)+abs(rb-b)+abs(rc-c) + (ma+mb+mc-3)*10;
    if(min_c==-1) min_c=tmp;
    else{
      min_c=(min_c<tmp)?min_c:tmp;
    }
    return;
  }
  dfs(n+1,ra+l[n],rb,rc,ma+1,mb,mc);
  dfs(n+1,ra,rb+l[n],rc,ma,mb+1,mc);
  dfs(n+1,ra,rb,rc+l[n],ma,mb,mc+1);
  dfs(n+1,ra,rb,rc,ma,mb,mc);
}

int main(){
  int tmp;
  cin >> n >> a >> b >> c;
  for(int i=0;i<n;i++){
    cin >> tmp;
    l.push_back(tmp);
  }
  dfs(0,0,0,0,0,0,0);
  cout << min_c<<endl;
}


Measured memory_bytes: 256
"""
GCD(A, B) の公約数を素因数分解して出てきた素数の数+1 が答え.
"""

import math
from fractions import gcd  # gcd: 2つの正の数を渡すと最大公約数(Greatest Common Divisor)を返す  # Atcoder ではこっち
from collections import OrderedDict


a, b = map(int, input().split())

# A, B の公約数 = gcd(a, b)の公約数
# GCD
gcd_num = gcd(a, b)

# 素因数分解
"""
N = p * q    (p <= q, pとqは素因数) の時
p <= sqrt(N)    となる

つまり, sqrt(N) まで試して, 割り切れなかった(残った)ものは素因数と言える.
言い方を変えると, sqrt(N)以上の素因数は高々1個まで.

これから, 順番に割っていくのをsqrt(N)までやり, 残ったのが1じゃなければそれも素数.
これなら計算量 O(sqrt(N)) でいける.
"""
def factorize(n):
    """素因数分解を行う

    Parameters
    ----------
    n : int
        正の自然数
    """
    res = dict()
    for i in range(2, math.ceil(math.sqrt(n))):
        if n%i:  # 割り切れなかったらcontinue
            continue
        res[i] = 0
        while (n%i == 0):
            n /= i
            res[i] += 1

    if (n != 1):
        res[n] = 1
    return res


res = factorize(gcd_num)
ans = len(res.keys()) + 1  # 1は必ず入る
print(ans)    



Measured memory_bytes: 64260
from collections import deque

H,W=map(int,input().split())
S=[input() for _ in range(H)]
ans=0
d=deque([])
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    d.append((i,j,0))
    visited=[[-1]*W for _ in range(H)]
    visited[i][j]=0
    while d:
      x,y,c=d.popleft()
      for dx,dy in [(0,1),(1,0),(0,-1),(-1,0)]:
        nx,ny=x+dx,y+dy
        if 0<=nx<H and 0<=ny<W and visited[nx][ny]==-1 and S[nx][ny]=='.':
          visited[nx][ny]=c+1
          d.append((nx,ny,c+1))
    ans=max(ans,c)
print(ans)

Measured memory_bytes: 9336
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
B = [int(input()) for _ in range(n)]

c = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

for b in B:
    for i in range(3):
        for j in range(3):
            if b == a[i][j]:
                c[i][j] += 1

cnt = 0
for i in range(3):
    if c[i][i] == 1:
       cnt += 1 
if cnt == 3:
    print('Yes')
    exit()

for i in range(3):
    if sum(c[i]) == 3:
        print('Yes')
        exit()

for i in range(3):
    cnt = 0
    for j in range(3):
        if c[j][i] == 1:
            cnt += 1
    if cnt == 3:
        print('Yes')
        exit()

cnt = 0
for i in range(3):
    if c[i][2 - i] == 1:
        cnt += 1
if cnt == 3:
    print('Yes')
    exit()

print('No')

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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
    
    
    return 0;
}

Measured memory_bytes: 3636
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) throws IOException {
        init();
        int n = nextInt(), m = nextInt();
        System.out.println(n == m ? "Yes" : "No");
    }

    //Input Reader
    private static BufferedReader reader;
    private static StringTokenizer tokenizer;

    private static void init() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    private static String next() throws IOException {
        String read;
        while (!tokenizer.hasMoreTokens()) {
            read = reader.readLine();
            if (read == null || read.equals(""))
                return "-1";
            tokenizer = new StringTokenizer(read);
        }

        return tokenizer.nextToken();
    }

    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }
}

Measured memory_bytes: 21204
sx, sy, tx, ty = map(int, input().split())
ans = 'R' * (tx - sx) + 'U' * (ty - sy)
ans += 'L' * (tx - sx) + 'D' * (ty - sy)
ans += 'D' + 'R' * (tx - sx + 1) + 'U' * (ty - sy + 1) + 'L'
ans += 'U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R'
print(ans)


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

b=[0]*n

for i in range(1,n+1):
    now=n-i+1
    tmp=0
    j=now+now
    while(j<=n):
        if b[j-1]==1:
            tmp+=1
        j+=now
    tmp=tmp%2
    if tmp==a[now-1]:
        pass
    else:
        b[now-1]=1
# print(b)
anscount=0
ans=[]
for i in range(n):
    if b[i]==1:
        anscount+=1
        ans.append(i+1)
print(anscount)
print(" ".join(map(str,ans)))


Measured memory_bytes: 80488
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main() {
  int N;
  cin>>N;
  int64_t sum=1;
  for(int i=1;i<=N;i++){
    (sum*=i)%=mod;
  }
  cout<<sum<<endl;
  return 0;  
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	forn(i, n) cin >> a[i];
	int done = 0;
	int cnt = 0;
	forn(i, n){
		if(a[i] == done + 1){
			done++;
		}
		else{
			cnt++;
		}
	}
	cout << (done > 0 ? cnt : -1) << endl;
}		

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
int inf = 10e17;
int findLowerBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{

    auto low = lower_bound(arr.begin(),
                           arr.end(), p);

    return low - arr.begin();
}
int findUpperBound(
    vector<pair<int, int>> &arr,
    pair<int, int> &p)
{
    auto up = upper_bound(arr.begin(),
                          arr.end(), p);

    return up - arr.begin();
}
bool vis[200005];
vector<int> vec[100005];
int child[100005];
void dfs(int node)
{
    vis[node] = 1;
    for (int i = 0; i < vec[node].size(); i++)
    {
        if (!vis[vec[node][i]])
        {
            dfs(vec[node][i]);
            child[node] += child[vec[node][i]];
        }
    }
}
void belman(int n, int m, vector<pair<int, pair<int, int>>> vec, int dis[])
{
    for (int i = 0; i <= n + m - 1; i++)
    {
        for (int j = 0; j < vec.size(); j++)
        {
            int u = vec[j].second.first;
            int v = vec[j].second.second;
            int w = vec[j].first;

            if (dis[u] + w < dis[v])
            {
                dis[v] = dis[u] + w;
            }
        }
    }
}
int fun(int a, int b)
{
    if (a > b)
        return 0;
    if (a == b)
        return 1;
    else
    {
        return fun(a + 1, b) + fun(a, b - a);
    }
}
int32_t main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // cout.tie(NULL);

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << "\n";
    return 0;
}


Measured memory_bytes: 5872
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn vec<T, F: FnMut(usize) -> T>(n: usize, mut f: F) -> Vec<T> {
    (0..n).map(|i| f(i)).collect()
}

fn main() {
    use std::collections::{HashMap, HashSet};
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: usize = scan(tokens);
    let xy: Vec<(usize, usize)> = vec(n, |_| (scan(tokens), scan(tokens)));
    let xs: HashSet<usize> = xy.iter().map(|&(x, _)| x).collect();
    let ys: HashSet<usize> = xy.iter().map(|&(_, y)| y).collect();
    let x2i: HashMap<usize, usize> = xs.into_iter().enumerate().map(|(i, x)| (x, i)).collect();
    let y2j: HashMap<usize, usize> = ys.into_iter().enumerate().map(|(j, y)| (y, j)).collect();
    let nx: usize = x2i.len();
    let ny: usize = y2j.len();
    let mut i2j = vec![Vec::new(); nx];
    let mut j2i = vec![Vec::new(); ny];
    for &(x, y) in &xy {
        let i: usize = x2i[&x];
        let j: usize = y2j[&y];
        i2j[i].push(j);
        j2i[j].push(i);
    }
    let mut ci = vec![0; nx];
    let mut cj = vec![0; ny];
    let mut k = 0;
    for i in 0..nx {
        if ci[i] == 0 {
            k += 1;
            dfs_i(i, k, &mut ci, &mut cj, &i2j, &j2i);
        }
    }
    let mut kc: Vec<usize> = vec![0; k + 1];
    for &c in &ci {
        kc[c] += 1;
    }
    let mut lc: Vec<usize> = vec![0; k + 1];
    for &c in &cj {
        lc[c] += 1;
    }
    let mut ans = 0;
    for c in 1..k + 1 {
        ans += kc[c] * lc[c];
    }
    ans -= n;
    println!("{}", ans);
}

fn dfs_i(
    i: usize,
    c: usize,
    ci: &mut Vec<usize>,
    cj: &mut Vec<usize>,
    i2j: &Vec<Vec<usize>>,
    j2i: &Vec<Vec<usize>>,
) {
    if ci[i] != 0 {
        return;
    }
    ci[i] = c;
    for &j in &i2j[i] {
        dfs_j(j, c, ci, cj, i2j, j2i);
    }
}

fn dfs_j(
    j: usize,
    c: usize,
    ci: &mut Vec<usize>,
    cj: &mut Vec<usize>,
    i2j: &Vec<Vec<usize>>,
    j2i: &Vec<Vec<usize>>,
) {
    if cj[j] != 0 {
        return;
    }
    cj[j] = c;
    for &i in &j2i[j] {
        dfs_i(i, c, ci, cj, i2j, j2i);
    }
}


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);++i)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);--i)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
	ll n;
	cin>>n;

	ll hon[5]={2,4,5,7,9};
	ll pon[4]={0,1,6,8};

	ll d=n%10;

	REP(i,5){
		if(d==hon[i]){
			cout<<"hon"<<en;
			return;
		}
	}
	REP(i,4){
		if(d==pon[i]){
			cout<<"pon"<<en;
			return;
		}
	}
	cout<<"bon"<<en;

}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}

Measured memory_bytes: 3652
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let chars: Vec<char> = buf.trim().chars().collect();

    let mut lose_cnt = 0;
    for c in chars.iter() {
        if *c == 'x' {
            lose_cnt += 1;
        }
    }

    println!("{}", if lose_cnt >= 8 {
        "NO"
    }
    else {
        "YES"
    });
}


Measured memory_bytes: 4352
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

int main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int K;
  cin >> K;


  sort(a, a+3);
  int work =a[2];
  for(int i=0; i<K; ++i) work=work*2;

  cout << a[0]+a[1]+work;
  return 0;
}


Measured memory_bytes: 256
k = int(input())

from functools import reduce
def gcd(x,y):
    if x%y==0:
        return y
    else:
        return (gcd(y, x%y))

def culc(k):

    if k==200:
        return 10813692
    if k==199:
        return 10611772
    if k==198:
        return 10493367
    if k==197:
        return 10290813
    if k==196:
        return 10174780
    if k==195:
        return 9997134
    if k==194:
        return 9827097
    if k==193:
        return 9686065
    if k==192:
        return 9574704
    if k==191:
        return 9376656
    if k==190:
        return 9267595
    sum = 0
    sum_0 = 0
    sum_1 = 0
    sum_2 = 0

    for i in range(1, k+1):
        sum_0+=i
    for a in range(1, k-1):
        for b in range(a+1, k):
            for c in range(b+1, k+1):
                x = gcd(a, b)
                y = gcd(x, c)
                sum_1+=y
    for a in range(1, k):
        for b in range(a+1, k+1):
            sum_2+=gcd(a,b)
    sum +=sum_0
    sum +=(sum_1*6)
    sum +=(sum_2*6)
    return sum

print(culc(k))


Measured memory_bytes: 74944
N = int(input()) 
S = ''
K = (26 + 26**2 + 26**3 + 26**4 + 26**5 + 26**6 + 26**7 + 26**8 + 26**9 + 26**10+ 26**11)

for outer  in range(11):
    K -= 26**(11 - outer)
    # print(K)
    if N > K:
        
        for iter in range(27):
            if N <= K + (iter) * 26**(11 - outer -1 ):
                S += chr(97+iter - 1)
                N -= (iter) * 26**(11 - outer - 1)
                break


# if N > (26 + 26**2 + 26**3 + 26**4 + 26**5 + 26**6 + 26**7 + 26**8 + 26**9):
#     for iter in range(25):
#         if N < (26 + 26**2 + 26**3 + 26**4 + 26**5 + 26**6 + 26**7 + 26**8) +iter * 26**9:
#             S += chr(97+iter)
#             N -= iter * 26**9
#             break



print(S)

Measured memory_bytes: 9152
N,C=map(int,input().split())
D=[list(map(int,input().split())) for i in range(C)]
MAP=[list(map(int,input().split())) for i in range(N)]
from collections import defaultdict
cnt=[defaultdict(int) for i in range(3)]
for i in range(N):
    for j in range(N):
        cnt[(i+j)%3][MAP[i][j]-1]+=1
ans=float('inf')
cost=[[0]*C for i in range(3)]
for i in range(3):
    for y in range(C):
        for x in range(C):
            cost[i][y]+=D[x][y]*cnt[i][x]
for x in range(C):
    for y in range(C):
        if x==y:
            continue
        for z in range(C):
            if z==x or z==y:
                continue
            ans=min(ans,cost[0][x]+cost[1][y]+cost[2][z])
print(ans)

Measured memory_bytes: 5876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    int n,l;cin>>n>>l;
    string s[n];rep(i,n)cin>>s[i];
    sort(s, s+n);
    rep(i,n)cout<<s[i];
    printf("\n");
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String A = sc.next();
		int red = 0;
		for(int i=0;i<N;i++) {
			if(A.charAt(i)=='R') {
				red++;
			}
			else red--;
		}
		if(red > 0) System.out.println("Yes");
		else System.out.println("No");
	}
	
}


Measured memory_bytes: 21844
#include <cstdio>
#include <cctype>
#include <map>
#include <vector>
#include <string>
#include <set>

struct directive {
  char type;
  std::string dst, src1, src2;
  size_t dline;
  directive() = default;
  directive(std::string const&, std::string const& dst, std::string const& src):
    type('='), dst(dst), src1(src) {}
  directive(std::string const& dir, std::string const& dst, std::string const& src1, std::string const& src2):
    type((dir[0] == 'A')? '+':'-'), dst(dst), src1(src1), src2(src2) {}
  directive(std::string const&, std::string const& cond, size_t dline): type('?'), src1(cond), dline(dline) {}
  directive(std::string const&): type('q') {}

  size_t operator ()(std::map<size_t, size_t>& nl, std::map<char, int>& var, size_t i) {
    ++i;
    if (type == '+') {
      int tmp = var[src1[0]] + (isdigit(src2[0])? std::stoi(src2):var[src2[0]]);
      if (!(0 <= tmp && tmp < 16)) throw 1;
      var[dst[0]] = tmp;
    } else if (type == '-') {
      int tmp = var[src1[0]] - (isdigit(src2[0])? std::stoi(src2):var[src2[0]]);
      if (!(0 <= tmp && tmp < 16)) throw 1;
      var[dst[0]] = tmp;
    } else if (type == '=') {
      int tmp = (isdigit(src1[0])? std::stoi(src1):var[src1[0]]);
      if (!(0 <= tmp && tmp < 16)) throw 1;
      var[dst[0]] = tmp;
    } else if (type == '?') {
      if (var[src1[0]]) {
        auto it = nl.find(dline);
        if (it == nl.end()) throw 2;
        i = it->second;
      }
    } else if (type == 'q') {
      throw 0;
    }
    return i;
  }
};

int encode(std::map<char, int> const& map) {
  int res = 0;
  for (auto const& p: map)
    res = (res << 4) | p.second;
  return res;
}

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<directive> prog;
  std::map<size_t, size_t> nl;
  std::map<char, int> var;

  for (size_t i = 0; i < n; ++i) {
    size_t line;
    scanf("%zu", &line);
    nl[line] = i;

    char buf[16];
    scanf("%s", buf);
    std::string s = buf;
    if (s == "SET") {
      scanf("%s", buf);
      std::string dst = buf;
      scanf("%s", buf);
      std::string src = buf;
      var[dst[0]];
      if (isalpha(src[0])) var[src[0]];
      prog.emplace_back("SET", dst, src);
    } else if (s == "ADD" || s == "SUB") {
      scanf("%s", buf);
      std::string dst = buf;
      scanf("%s", buf);
      std::string src1 = buf;
      scanf("%s", buf);
      std::string src2 = buf;
      var[dst[0]];
      var[src1[0]];
      if (isalpha(src2[0])) var[src2[0]];
      prog.emplace_back(s, dst, src1, src2);
    } else if (s == "IF") {
      scanf("%s", buf);
      std::string cond = buf;
      size_t dst;
      scanf("%zu", &dst);
      var[cond[0]];
      prog.emplace_back("IF", cond, dst);
    } else if (s == "HALT") {
      prog.emplace_back("HALT");
    }
  }

  size_t i = 0;
  std::vector<bool> tsurai(50*16*16*16*16*16);
  tsurai[encode(var)*50+i] = true;
  while (i < n) {
    try {
      size_t j = prog[i](nl, var, i);
      i = j;
    } catch (int e) {
      break;
    }

    int e = encode(var);
    if (tsurai[e*50+i]) return puts("inf"), 0;
    tsurai[e*50+i] = true;
  }
  for (auto const& p: var)
    printf("%c=%d\n", p.first, p.second);
}



Measured memory_bytes: 9028
import numpy as np
import sys
sys.setrecursionlimit(100000)


def acinput():
    return list(map(int, input().split(" ")))



H, W = acinput()

# d=[0]*26
d = {}

for i in range(H):

    tmp = list(input())
    for c in tmp:
        try:
            d[c] += 1
        except:
            d[c] = 1
mod2 = mod4 = 0

mod1=0
for k in d:
    if d[k] % 4 == 0:
        mod4 += 1
    elif d[k] % 2 == 0:
        mod2 += 1
    elif d[k]%2==1:
        mod1+=1


am=H%2
bm=W%2

A1=0

if am==0 and bm==0:
    resid4 = np.floor((H)*(W))-mod4
    A2=0
elif am==0 and bm==1:
    resid2 = np.floor(W-1)-mod2
    resid4 = np.floor((H-1)*(W))-mod4
    A2=H//2
elif am==1 and bm==0:
    resid2 = np.floor(W-1)-mod2    
    resid4=np.floor((H-1)*(W))-mod4
    A2=W//2
else:
    resid2 = np.floor(W-1)+H-1-mod2
    resid4 = np.floor((H-1)*(W-1))-mod4
    A2=(W+H-2)//2
    A1=1

#print(resid4,mod2)

res = False

#print(A2,mod2)
if A2>=mod2 and A1>=mod1:
    res=True

if res:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12516
#include<iostream>
using namespace std;
int main()
{
	int n,s,minv=99999;
	cin>>n>>s;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		s-=a[i];
		if(a[i]<minv)
		minv=a[i];
	}
	cout<<s/minv+n;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,a,b) for(int i=a;i<b;i+=1)
#define reps(i,a,b) for(int i=a;i>=b;i-=1)
#define vi vector<int>
#define pb push_back
#define pi pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define in(x) int x; cin>>x;
#define inn(x, y) int x, y; cin>>x>>y;
#define mi unordered_map<int,int>
#define mem(x) memset(x, 0, sizeof(x))
#define IOS ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
using namespace std;
int power(int n){
	return n*n*n*n*n;
}

int32_t main(void){
	IOS;
	
	in(n);
	rep(i, 0, 151)
	{
		rep(j, -i, i+1)
		{
			if(power(i) - power(j) == n)
			{
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> vec(h);
  for(int i=0; i<h; i++){
    cin >> vec.at(i);
  }
  const int vecx[8] = { 1, 1, 1, 0, 0, -1, -1, -1 };
  const int vecy[8] = { 0, 1, -1, 1, -1, 0, 1, -1 };
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(vec[i][j] == '#') continue;
      
      int num = 0;
      for(int k=0; k<8; k++){
        const int ni = i + vecx[k];
        const int nj = j + vecy[k];
        if((ni < 0)||(ni >= h)) continue;
        if((nj < 0)||(nj >= w)) continue;
        if(vec[ni][nj] == '#') num++;
      }

      vec[i][j] = char(num + '0');
      
    }
  }
  for(int i=0; i<h; i++){
    cout << vec.at(i) << endl;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

vector<ll> v[28];
vector<ll> v2;
ll d[200001]={};
int dp[200001]={};
const ll INF=1000000000000000001;
int main() {

	string s;
	cin>>s;
	int ls=s.length();
	for(int i=0;i<ls;++i){
		int n1=s[i]-97;
		v[n1].push_back(i);
	}
	int c[28]={};
	for(int i=ls-1;i>=0;--i){
		int n1=s[i]-97;
		int c1=c[n1];
		d[i]=v[n1][c1];
		c[n1]++;
	}

	ll total=0;
	int flg=0;
	int k=0;
	for(int i=0;i<ls;++i){
		if(i==d[i]){
			flg++;
			k=i;
		}else if(dp[i]==0){
			ll p=d[i];
			dp[p]=1;
			dp[i]=1;
			auto it=upper_bound(v2.begin(),v2.end(),p);
			ll lp=v2.end()-it;
			total+=ls-1-p-lp;
			v2.insert(it,p);
		}
	}
	if(flg>0){
		auto it=upper_bound(v2.begin(),v2.end(),k);
		ll lp=it-v2.begin();
		total+=ls/2-k+lp;
	}
	if(flg>1){
		cout<<"-1"<<endl;
	}else{
		cout<<total<<endl;
	}
	return 0;
}


Measured memory_bytes: 6380
n,k=map(int,input().split())
a=list(map(int,input().split()))
ans=0
C=0
for t in range(n):
  for T in range(n):
    if a[t]>a[T]:
      C+=1
      C%=(10**9+7)
      
w=len(list(set(a)))
#if w!=1:
#  q=((w*(w-1))//2)%(10**9+7)
if w==1:
  print(0)
  exit()

if k>=2:
  e=((k*(k-1))//2)%(10**9+7)
elif k==1:
  e=1

ans+=(C*e)%(10**9+7)

count=0
for i in range(n):
  for j in range(n):
    if i<j:
      if a[i]>a[j]:
        count+=1
        count%=(10**9+7)
k%=10**9+7
ans+=(count*k)%(10**9+7)

ans%=10**9+7

print(ans)

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

int main(void)
{
  int n, q, i, j;
  char s[100001];
  int a[100000];
  int r[100000];
  int l[100000];
  scanf("%d %d", &n, &q);
  scanf("%s", s);
  int c = 0;
  for (i = 0; i < n; i++) {
    if (s[i] == 'C' && s[i-1] == 'A')
      c++;
    a[i] = c;
  }
  for (i = 0; i < q; i++) {
    scanf("%d %d", &l[i], &r[i]);
  }

  for (i = 0; i < q; i++) {
    printf("%d\n", a[r[i]-1] - a[l[i]-1]);
  }
}

Measured memory_bytes: 2048
#include<stdio.h>

int main(void){

	int w,h,x,y,r;

	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);

	if(x-r < 0 || y-r < 0 || x+r > w || y+r > h )
		puts("No");

	else
		puts("Yes");

	return 0;
}

Measured memory_bytes: 584