akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int, int>;

//dijkstraっぽい
vector<int> dijkstra(vector<vector<P>> G) {
    const int INF = 1e9;
    int N = G.size();
    vector<int> dist(N, INF);
    dist[1] = 0;
    priority_queue<P, vector<P>, greater<P>> pq;
    pq.emplace(P(dist[1], 1));
    while(pq.size()) {
        P p = pq.top();
        pq.pop();
        int d = p.first;
        int v = p.second;
        if (dist[v] < d) continue;

        for (int i = 0; i < G[v].size(); i++) {
            P e = G[v][i];
            int cost = d + e.second;
            int nv = e.first;
            if (cost < dist[nv]) {
                dist[nv] = cost;
                pq.emplace(P(dist[nv], nv));
            }
        }
    }
    return dist;
}

int main() {
    int H, W; cin >> H >> W;
    vector<vector<P>> G(10);
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            int c; cin >> c;
            G[j].push_back(P(i, c));
        }
    }
    vector<int> vec = dijkstra(G);
    ll ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            int a; cin >> a;
            if (a == -1) continue;
            else ans += vec[a];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N = int(input())
        st = []
        for _ in range(N):
            tmp = list(input().split())
            st.append((tmp[0].rstrip(), int(tmp[1])))
        X = input().rstrip()

        f = False
        ans = 0
        for i in range(N):
            name, time = st[i]
            if f:
                ans += time
            if name == X:
                f = True

        print(ans)


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


Measured memory_bytes: 38256
x = input()
x = '000'+x
z = x[:-2]
y = x[-2:]
s = 0
z = int(z)
y = int(y)
L = []
y1 =y//5
if z>=20 or z>=(y1+(y%5!=0)):
    print(1)
    exit()
print(0)

Measured memory_bytes: 3060
#include <stdio.h>
#define N_MAX 1299709

char isprime[N_MAX + 1];

int main(void)
{
    int i, j;

    /* sieve */
    for(i = 1; i <= N_MAX; i++)
        isprime[i] = 1;
    for(i = 2; i <= N_MAX; i++)
        if(isprime[i])
            for(j = 2 * i; j <= N_MAX; j += i)
                isprime[j] = 0;

    while(scanf("%d", &i), i)
    {
        if(isprime[i])
            printf("%d\n", 0);
        else
        {
            int count = 2;
            for(j = i + 1; j <= N_MAX && !isprime[j]; j++)
                count++;
            for(j = i - 1; j <= N_MAX && !isprime[j]; j--)
                count++;
            printf("%d\n", count);
        }
    }

    return 0;
}

Measured memory_bytes: 1868
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b)
    {
        printf("a < b\n");
    }
    else if(a>b)
    {
        printf("a > b\n");
    }
   else 
    {
        printf("a == b\n");
    }
  }


Measured memory_bytes: 2096
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;
	auto S = RD!string;
	bool ans = true;
	foreach (i, c; S)
	{
		debug writeln(i == A ? c : c - '0');
		if (i == A)
		{
			if (c != '-')
				ans = false;
			debug writeln("a");
		}
		else if (c - '0' < 0 || c - '0' > 9)
		{
			ans = false;
			debug writeln("b");
		}
	}

	writeln(ans ? "Yes" : "No");
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int a,b,c,d,p,x,y;
	cin >> a >> b >> c >> d >> p;
	x=a*p;
	if(p<c){
		y=b;
	}else if(p>c){
		y=b+(p-c)*d;
	}
	if(x>y){
		cout << y << endl;
	}else if(x<y){
		cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if (a == b && b != c) ||
		(b == c && c != a) ||
		(c == a && b != c) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define min(p,q)((p)<(q)?(p):(q))
#define INF ((1LL<<62)-(1LL<<31))

//dinicここから
#define dinicVmax 110
#define resflow(a,b)(capa[a][b]-flow[a][b])
ll vcnt;//頂点数
ll capa[dinicVmax][dinicVmax];//容量
ll flow[dinicVmax][dinicVmax];//実際の流量
ll dist[dinicVmax];//ソースからの距離
ll checked[dinicVmax];//dfsの行き止まりフラグ
void dinicbfs(ll s){
	rep(i,0,vcnt)dist[i]=-1;
	dist[s]=0;
	//まだ流せる辺だけを使ってbfs
	ll que[dinicVmax*dinicVmax];
	ll qcnt=0,qptr=0;
	que[qcnt++]=s;
	while(qcnt!=qptr){
		ll a=que[qptr++];
		rep(b,0,vcnt)if(resflow(a,b)>0&&dist[b]==-1){
			dist[b]=dist[a]+1;
			que[qcnt++]=b;
		}
	}
}
ll dinicdfs(ll a,ll t,ll m){
	//aはm受け取ってる(⇔aから最大m流せる)
	//いくら流せるかを返す
	if(a==t)return m;
	if(checked[a])return 0;
	ll ans=0;
	checked[a]=1;
	rep(b,0,vcnt)if(dist[b]>dist[a]&&resflow(a,b)>0){
		ll addedflow=dinicdfs(b,t,min(m,resflow(a,b)));
		if(addedflow){
			flow[a][b]+=addedflow;
			flow[b][a]-=addedflow;
			checked[a]=0;
			ans+=addedflow;
			m-=addedflow;
			if(m<=0)break;
		}
	}
	return ans;
}
//ソース,シンク
ll dinic(ll s,ll t){
	ll ans=0;
	ll flag=1;
	while(flag){
		flag=0;//更新フラグ
		dinicbfs(s);
		while(!checked[s]){
			ll addedflow=dinicdfs(s,t,INF);
			ans+=addedflow;
			if(addedflow)flag=1;
		}
		rep(i,0,vcnt)checked[i]=0;
	}
	return ans;
}
//dinicここまで

int main(){
	//ソースを0、シンクをN+1として、破壊する側をソース、しない側をシンクに集める
	//以下の条件で与えられるペナルティーを最小化する
	//・a[i]<0のとき、a[i]を破壊しないと|a[i]|のペナルティー→ソースからiを|a[i]|で結ぶ
	//・a[i]>=0のとき、a[i]を破壊しないのを基礎点として、破壊するとa[i]のペナルティー→iからシンクをa[i]で結ぶ
	//・a[i]が破壊されていてかつa[k*i]が破壊されていないとき、∞点のペナルティー→iからk*iを∞で結ぶ
	//基礎点としてもらえる(Σ_{i\in\{j|a[j]>=0\}}a[i])点からペナルティーを引いたものが答え
	ll n;
	scanf("%lld",&n);
	ll base=0;
	rep(i,1,n+1){
		ll t;
		scanf("%lld",&t);
		if(t<0){
			capa[0][i]=-t;
		}else{
			capa[i][n+1]=t;
			base+=t;
		}
	}
	rep(i,1,n+1)repp(j,i*2,n+1,i)capa[i][j]=INF;
	vcnt=n+2;
	printf("%lld\n",base-dinic(0,n+1));
	return 0;
}

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

#define rep(i,n)        for (i = 0; i < n; ++i) 
#define REP(i,k,n)      for (i = k; i <= n; ++i) 
#define REPR(i,k,n)     for (i = k; i >= n; --i) 
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)

const int SIZE = 1e5;
int arr[SIZE];

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	#ifndef ONLINE_JUDGE
	    freopen("in.txt", "r", stdin);
	    freopen("out.txt", "w", stdout);
	#endif
}


int main() { 

	c_p_c();
	
	int w, s;
	cin >> s >> w;
	if (w >= s){
		cout << "unsafe" << endl;
	}
	else{
		cout << "safe" << endl;
	}
	return 0; 
} 


Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<set>
#include<iomanip>
#include<string>
#include<random>
#include<algorithm>
#include<queue>
#include<functional>

using namespace std;

#define X first
#define Y second

mt19937 rnd((size_t)time(nullptr));

const long long MAXM = 63, INF = 10000000, M = 1000000007;
const int MAXN = 410;

int h, w;
int a[MAXN][MAXN], dp[MAXN][MAXN];

int my_min(int a, int b) {
	if (a == -1) {
		return b;
	}
	else if (b == -1){
		return a;
	}
	else {
		return min(a, b);
	}
}

int main()
{
#if _DEBUG
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0);
	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			dp[i][j] = -1;
			char h;
			cin >> h;
			if (h == '.') {
				a[i][j] = 0;
			}
			else{
				a[i][j] = 1;
			}
			if (i == 1 && j == 1) {
				dp[i][j] = a[i][j];
			}
			else {
				if (i > 1) {
					if(a[i - 1][j] == 1) {
						dp[i][j] = my_min(dp[i][j], dp[i - 1][j]);
					}
					else {
						dp[i][j] = my_min(dp[i][j], dp[i - 1][j] + a[i][j]);
					}
				}
				if (j > 1) {
					if (a[i][j - 1] == 1) {
						dp[i][j] = my_min(dp[i][j], dp[i][j - 1]);
					}
					else {
						dp[i][j] = my_min(dp[i][j], dp[i][j - 1] + a[i][j]);
					}
				}
			}
		}
	}
	cout << dp[h][w];
	return 0;
}

Measured memory_bytes: 640
#include<iostream>

#include<algorithm>
#include<vector>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
const int INF = 1e9;
typedef long long ll;

int main(){
  ll n,q;
  cin >> n >> q;
  ll test = 1 << 31;

  ll a[n];
  REP(i,n){
    a[i] = test*(-1)-1;
  }
  ll com[q],x[q],y[q];
  REP(i,q){

    cin >> com[i] >> x[i] >> y[i];

  }
  REP(i,q){
    if(com[i] == 0){
      a[x[i]] = y[i];
    }
    else{
      ll c = a[x[i]];
      for(int j = x[i]+1;j < y[i]+1;j++){
	c = min(c,a[j]);
      }
      cout << c << endl;
    }
  }
  
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi a(n);
  rep(i, n) cin >> a[i];
  map<int, int> mp;
  rep(i, n) {
    if (mp[a[i]]) {
      cout << "NO" << endl;
      return;
    }
    mp[a[i]]++;
  }
  cout << "YES" << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 10368
n=list(map(int,input()))
a=len(n)
if n[a-1]==2 or n[a-1]==4 or n[a-1]==5 or n[a-1]==7 or n[a-1]==9:
  print("hon")
elif n[a-1]==0 or n[a-1]==1 or n[a-1]==6 or n[a-1]==8:
  print("pon")
else:
  print("bon")

Measured memory_bytes: 61652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
    ll color[9];
    for (ll i = 0; i < 9; i++) color[i] = 0;
    for (ll i = 0; i < n; i++) {
        ll t;
        cin >> t;
        for (ll i = 0; i < 8; i++) {
            if (i * 400 <= t and t < (i + 1) * 400) color[i]++;
        }
        if (t >= 3200) color[8]++;
    }
    ll max = 0;
    for (ll i = 0; i < 8;i++)
        if (color[i]) max++;
    max += color[8];
    ll min = 0;
    if (color[8] == n) min = 1;
    else
        min = max - color[8];
    cout << min << " " << max << endl;
}

Measured memory_bytes: 3596
import numpy as np
N, K, Q = map(int, input().split())
S = []
for _ in range(Q):
    S.append(int(input())) 
P=[K]*N
for i in range(Q):
  P[S[i]-1]+=1
P = np.array(P)
P -= Q
for i in range(N):
  if P[i] <= 0:
    print("No")
  else:
    print("Yes")

Measured memory_bytes: 19640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//(a+b-1)/b

signed main(){
	string s; cin>>s;
	string memo;
	int ans=0;
	while(!s.empty()){
		int m=s.size();
		string t;
		if(m==1){
			if(s!=memo)ans++;
			s.pop_back();
		}
		else{
			t.push_back(s[m-1]);
			s.pop_back();
			if(memo==t){
				t.push_back(m-2);
				s.pop_back();
			}
			ans++;
			memo=t;
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

const ll mod = 1e9 + 7;

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

/*-------------------------------------------*/

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

    int n, k;
    cin >> n >> k;
    int ans=0;
    while(n){
        ans++;
        n/=k;
    }cout<<ans;
}

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

int main(int argc, char const *argv[]) {
  int n, i;
  vector<int> b;

  cin >> n;

  int a[n];

  for (i=0; i < n; i++) {
    cin >> a[i];
    b.push_back(a[i]);
  }
  sort(b.begin(), b.end());

  for (i=0; i < n; i++) {
    if (a[i] != b[n-1]) {
      cout << b[n-1] << endl;
      continue;
    } else {
      cout << b[n-2] << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3316
S=list(input())
ans=0
if S[0]=='+':
    ans+=1
else :
    ans-=1
if S[1]=='+':
    ans+=1
else :
    ans-=1
if S[2]=='+':
    ans+=1
else :
    ans-=1
if S[3]=='+':
    ans+=1
else :
    ans-=1    
print(ans)    
    



Measured memory_bytes: 3060
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define Rep(i, a, b) for (int (i) = (a) - 1; (i) < (b); (i)++)
#define REP(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define clr(a) memset(a, 0, sizeof(a))
#define Sort(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define lowbit(x) (x & -x)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define ENDL cout << endl
#define SZ(x) ((int)x.size())

typedef long long ll ;
typedef unsigned long long ull ;
typedef vector <int> Vi ;
typedef pair <int, int> Pii ;
typedef pair <ll, ll> Pll ;
typedef map <int, int> mii ;
typedef map <string, int> msi ;
typedef map <ll, ll> mll ;

const int N = 100010 ;
const double eps = 1e-8 ;
const int iinf = INT_MAX ;
const ll linf = 2e18 ;
const double dinf = 1e30 ;
const int MOD = 1000000007 ;

inline int read(){
    int X = 0,w = 0 ;
	char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}

void write(int x){
     if(x < 0) putchar('-'),x = -x;
     if(x > 9) write(x / 10);
     putchar(x%10 + '0');
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void PRINT(string x) {
	 cout << x << endl ;
	 exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

int a, b ;

signed main(){
	cin >> a >> b ;
	cout << a + b / 2 << endl ;
	return 0 ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.实数精度有没有处理？
	3.特殊情况处理好了么？
	4.做一些总比不做好。
思考提醒：
	1.最大值和最小值问题可不可以用二分答案？
	2.有没有贪心策略？否则能不能dp？
*/


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    N2=pow(2,N)
    
    """
    下位集合に対する高速ゼータ変換．
    (Kがi,jを包含している）
    ここでのgを適切なfの和として考えるのが基本だけど，
    今回は和ではなくて上位2つの要素を持つ
    """
    
    g=[[0,0]for _ in range(N2)]
    
    for i in range(N2):
        g[i][0]=A[i]
        
    for k in range(N):#このkはKと違う，kbit目に着目する
        for s in range(N2):#これが今回でいうK，
            if ((s>>k)&1):#sのkbit目が立っていれば
                #加法として，上位2つを選択する
                L=[0,0,0,0]
                L[0]=g[s][0]
                L[1]=g[s][1]
                L[2]=g[(s^(1<<k))][0]#sのkbit目をマスクしたgを持ってくる
                L[3]=g[(s^(1<<k))][1]
                L.sort()
                g[s][0]=L[-1]
                g[s][1]=L[-2]
                #print(bin(s),k,g[s],L)
                
    ans=0
    for k in range(1,N2):
        ans=max(ans,sum(g[k]))
        print(ans)
        
    
                    
                
            
        
    
    

main()


Measured memory_bytes: 124108
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

//#include "atcoder/all"
//using namespace atcoder;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a;
	string b;
	cin >> a >> b;
	int B = 0;
	rep(i,b.size()){
		if(b[i] == '.') continue;
		B = B * 10 + (b[i] - '0');
	}
	ll ans = a * B / 100;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define int long long 
#define pb push_back
#define ins insert
#define rs resize
#define br break;
#define cont continue;
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vector<int>>
#define si set<ll>
#define sll set<long long>
#define pii pair<ll,ll>
#define pll pair<long long, long long>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vec vector
#define cend cout<<endl;
#define sc second
#define fr first
#define retz return 0;
#define ll_MAX (ll)(1e9*1e9)
#define ll_MIN (ll)(-1e9*1e9)
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b)  for(int i=a; i<=b; i++)
#define repd(i,a,b) for(int i=a; i>=b; i--)
#define ps(arr, n) for(int i=1; i<n; i++)arr[i]+=arr[i-1];
#define inp(arr, n)for(int i=0; i<n; i++)cin>>arr[i];
#define out(arr, n)for(int i=0; i<n; i++)cout<<arr[i];
#define inp1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define out1(arr,n,m)for(int i=0; i<n; i++)for(int j=0;j<m;j++)cin>>arr[i][j];
#define loop(q) for(auto it:q)
#define loop1(q) for(auto&it:q)
#define db1 cout << "*" << endl
#define db2 cout << "YES" << endl
using namespace std;
using namespace __gnu_pbds; 
#define oset(X) tree<X,null_type,less<X>, rb_tree_tag, tree_order_statistics_node_update> 
#define roset(X) tree<X,null_type,greater<X>, rb_tree_tag, tree_order_statistics_node_update>  
#define okey order_of_key //lower_bound_set
#define ofind find_by_order
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl;
#define mod (long long)1000000007
#define mod2 (long long)998244353
#define INT_MAX1 900000000
#define MAXN 2000000
#define INF INT_MAX


string s;
int dp[100001][13];
bool v[100001][13];


int s1(int i, int j)
{
    if(i==s.size())
        return j == 5;
    if(v[i][j])
        return dp[i][j];
    v[i][j] = 1;
    if(s[i]>='0' and s[i]<='9')
        return dp[i][j] = s1(i+1, (j*10+s[i]-'0')%13);
    rep(k,'0','9')
        dp[i][j] += s1(i+1, (j*10+k-'0')%13);
    dp[i][j]%=mod;
    return dp[i][j];
}


void solve()
{
    cin >> s;
    cout << s1(0,0) << endl;
}



signed main()
{
    speed;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}

Measured memory_bytes: 18128
#include<cstdio>
#include<algorithm>

using namespace std;

int n;
int a[105][105];
int sum[105][105];

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)scanf("%d",&a[j][i]);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)sum[j][i]=sum[j-1][i]+a[j][i];
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++)sum[i][j]+=sum[i][j-1];
	}
	int res=-114514;
	for(int i=0;i<=n;i++){
		for(int j=i+1;j<=n;j++){
			for(int k=0;k<=n;k++){
				for(int l=k+1;l<=n;l++){
					res=max(res,sum[j][l]-sum[j][k]-sum[i][l]+sum[i][k]);
				}
			}
		}
	}
	printf("%d\n",res);
}

Measured memory_bytes: 1112
#include <iostream>
using namespace std;
int main(void){
    string S;
    cin >> S;
    
    if(S.at(0)==S.at(1)){
        if(S.at(2)==S.at(3)){
            if(S.at(0)==S.at(2)){
                cout << "No";
                return 0;
            }
        }
    }
    if(S.at(0)==S.at(1)){
        if(S.at(2)==S.at(3)){
            if(S.at(0)!=S.at(2)){
                cout << "Yes";
                return 0;
            }
        }
    }
    if(S.at(0)==S.at(3)){
        if(S.at(1)==S.at(2)){
            if(S.at(0)!=S.at(2)){
                cout << "Yes";
                return 0;
            }
        }
    }
    if(S.at(0)==S.at(2)){
        if(S.at(1)==S.at(3)){
            if(S.at(1)!=S.at(2)){
                cout << "Yes";
                return 0;
            }
        }
    }
    else cout << "No";
}


Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
q = int(input())
h = defaultdict(int)
s = sum(a)
for i in a:
    h[i] += 1
for _ in range(q):
    b, c = map(int, input().split())
    s += h[b] * (c - b)
    print(s)
    h[c] += h[b]
    h[b] = 0


Measured memory_bytes: 89012
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;
using qint = queue<int>;
using sint = stack<int>;
using pii = pair<int, int>;


int main(){
    vector<ll> numbers(1e5 + 5, 0);
    int n;
    cin >> n;
    ll ans = 0;
    rep(i, n){
        int tmp;
        cin >> tmp;
        numbers[tmp]++;
        ans += tmp;
    }
    int q;
    cin >> q;
    rep(i, q){
        int b, c;
        cin >> b >> c;
        numbers[c] += numbers[b];
        ans += (c - b) * numbers[b];
        numbers[b] = 0;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    if(n%2==1){out(0); return 0;}
    int ans = n/10;
    int now = 50;
    while(now<=n){
        ans += n/now;
        now*=5;
    }
    out(ans);

    return 0;
}

Measured memory_bytes: 256
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

#define MP make_pair
typedef long long ll;

ll h,w;
char g[405][405];
bool u[405][405];
ll dx[]={-1,0,1,0},dy[]={0,1,0,-1};
ll ans;

bool in(ll x,ll y){
	return (x>=1)&&(x<=h)&&(y>=1)&&(y<=w);
}

pair<ll,ll> dfs(ll x,ll y){
	u[x][y]=true;
	pair<ll,ll> res=MP(0,0),shit;
	for(ll d=0;d<4;d++){
		ll nx=dx[d]+x,ny=dy[d]+y;
		if(!u[nx][ny]&&g[nx][ny]!=g[x][y]&&in(nx,ny)){
			shit.first=0,shit.second=0;
			shit=dfs(nx,ny);
			res.first+=shit.first;
			res.second+=shit.second;
		}
	}
	if(g[x][y]=='#'){
		res.first++;
	}else{
		res.second++;
	}
	return res;
}

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>h>>w;
	for(ll i=1;i<=h;i++){
		for(ll j=1;j<=w;j++){
			cin>>g[i][j];
		}
	}
	for(ll i=1;i<=h;i++){
		for(ll j=1;j<=w;j++){
			if(!u[i][j]&&g[i][j]=='#'){
				pair<ll,ll> shit=dfs(i,j);
				//cout<<shit.first<<' '<<shit.second<<endl;
				ans+=shit.first*shit.second;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
#define LiangJiaJun main
#define INF 1999122700
using namespace std;
int n,k;
int a[100004];
int w33ha(){
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    int l=1,r=k,st=-1,ans=INF;
    for(int i=1;i<=n;i++)if(a[i]==1){st=i;break;}
    while(st>r){++l;++r;}
    while(l<=st&&st<=r&&r<=n){
        int L=l-1,R=n-r;
        ans=min(ans,L/(k-1)+R/(k-1)+1+(L%(k-1)!=0)+(R%(k-1)!=0));
        ++l;++r;
    }
    printf("%d\n",ans);
    return 0;
}

int LiangJiaJun (){
    while(scanf("%d%d",&n,&k)!=EOF)w33ha();
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;



void solve(){
    string s,t;
    cin >> s >> t;
    int ans = 100100100;
    
    int m = t.size();
    for(int i = 0; i < s.size()-m+1; i++){

        int need = 0;
        for(int j = 0; j < m; j++){
            if (s[j+i]!=t[j]) need++;
        }
        ans = min(ans,need);
    }
    cout << ans;
};



int main() {
    int T;
    //cin >> T;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}




Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        freopen("error.txt","w",stderr);
    #endif
}
int main()
{
    vok();
    int a;
    IN a;
    int ans=a+(a*a)+(a*a*a);
    OUT ans<<endl
    return 0;
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N+1];
		for(int i=1;i<=N;i++) {
			a[i]= sc.nextInt();
		}
		int count =0;
		for(int i=1;i<=N;i++) {
			if(a[a[i]]==i) {
				count ++;
			}
		}
		System.out.println(count/2);
	}
}

Measured memory_bytes: 59400
import sys
import math
input = sys.stdin.readline
##

n, p = input().rstrip().split()
n, p = int(n), int(p)
while n + p != 0:
    tegoma = [0] * n
    owan = p
    pivot = 0
    finish_flag = False
    while finish_flag is False:
        if owan != 0:
            owan = owan - 1
            tegoma[pivot] = tegoma[pivot] + 1
        else:
            if tegoma[pivot - 1] == p:
                finish_flag = True
            owan = tegoma[pivot]
            tegoma[pivot] = 0
        pivot = (pivot + 1) % n
    print((pivot - 2) % n)

    n, p = input().rstrip().split()
    n, p = int(n), int(p)



Measured memory_bytes: 5656
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int main() {
     int n, a, b;
     scanf("%d%d%d", &n, &a, &b);
     long long sum = 0;
     for (int i = 1; i <= n; i++) {
          int m = i, res = 0;
          while (m) {
               res += (m % 10);
               m /= 10;
          }
          if (res >= a && res <= b) sum += i;
     }
     printf("%lld\n", sum);
     return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

// RingoDivide 10^2でD回割り切れる中でN番目に小さな正の整数を返す
// D=0, 1, 2   1<=N<=100
// res = N * 10^(2*D)
func RingoDivide(D int, N int) int {
	if N == 100 {
		N++
	}
	res := N
	for i := 0; i < D; i++ {
		res *= 100
	}
	return res
}

func main() {
	var D int
	var N int
	var res int

	fmt.Scan(&D)
	fmt.Scan(&N)
	res = RingoDivide(D, N)
	fmt.Println(res)
}


Measured memory_bytes: 512
#include "bits/stdc++.h"

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int L,R,d;
  cin >> L >> R >> d;
  int c = 0;
  for (int i = L; i <= R; i++) {
    if (i % d == 0) c++;
  }
  cout << c;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の
string型配列と同じような感じ） map<int, string> mp; for (auto itr =mp.begin();
itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main()
{
	int k,p,n;
	cin >> n;
	for(int  i = 0; i < n; i++){
		cin >> k >> p;
		if( k < p ){
			cout <<  k << endl;
		}
		else{
			while( k > p ){
				k = k - p;
			}
			cout << k << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
public class Main {

  private static void solve() {
    int n = ni();
    long sum = 0;
    for (int i = 1; i <= n; i++) {
      if (i % 3 == 0 || i % 5 == 0)
        continue;

      sum += i;
    }
    System.out.println(sum);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



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

int main() {
  char n[200001];
  cin >> n;
  int l = strlen(n);
  int sum = 0;
  for (int i = 0; i < l; i++) {
    sum += n[i] - '0';
  }
  if (sum % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3740
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

constexpr int P = 1e9 + 7;

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

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

    int64_t r = 1;
    for (int i = 0; i < n; i++) {
        if (b[i] != 2) continue;
        r *= b[i];
        r %= P;
    }

    int c = -2, a = n - 1;
    for (int i = 0; i < n; i++) {
        b[a]--;
        a += c;
        if (a <= 0) {
            c *= -1;
            if (a < 0) a += c;
        }
    }
    for (int i = 0; i < n; i++) {
        if (b[i] != 0) {
            cout << 0 << endl;
            quick_exit(0);
        }
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>

using namespace std;

int main()
{
  int p, n, tp = 0, tn = 0, c = 0;
  char d;

  while ( cin >> p >> d >> n )
    {
      tp += p * n;
      tn += n;
      ++c;
    }

  cout << tp << endl;
  cout << round( (double)tn / (double)c) << endl;
  
  return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
int st[2003];
int main()
{
    int g,h,t,q,w,a,b,c,nn;
    scanf("%d %d %d",&t,&q,&w);
    for(g=1;g<t;g++){
        for(h=g+1;h<=t;h++){
            a=h-g;
            b=abs(q-g)+abs(w-h)+1;
            c=abs(q-h)+abs(w-g)+1;
            nn=min(a,min(b,c));
            st[nn]++;
        }
    }
    for(g=1;g<t;g++)
        printf("%d\n",st[g]);
    return 0;
}


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

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef long long ll;
typedef pair<ll, ll> P;

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

    vector<P> A;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        A.emplace_back(a, i);
    }

    sort(A.begin(), A.end());
    ll ans = 0;
    for(int i=0;i<N;i+=2){
        if (i % 2 != A[i].second % 2){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2420
#include <stdio.h>
#include <iostream>
using namespace std;	
int a[100005] = {0};
int b[100005] = {0};
int main(){
	int i,n;
	cin >> n;
	int tp = 0;
	for(i=0;i<n;i++){
		cin >> a[i];
		if(tp<a[i]){
			tp = a[i];
		}
		b[a[i]]++;
		b[a[i]-1]++;
		b[a[i]+1]++;
	}
	int max = 0;
	for(i=0;i<=tp;i++){
		if(max<b[i]){
			max = b[i];
		}
	}
	cout << max;
	return 0;
}

Measured memory_bytes: 4176
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int a, b, k; cin >> a >> b >> k;
    if(a > b) swap(a, b);
    vint ans;
    repi(i, 1, a + 1) {
        if(a % i == 0 && b % i == 0) ans.push_back(i);
    }
    sort(rall(ans));
    print(ans[k - 1]);

    return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	array<string, 100> grid;
	for (int i = 0; i < grid.size(); i++) {
		if (i < 50) {
			for (int j = 0; j < 100; j++) {
				grid[i] += "#";
			}
		} else {
			for (int j = 0; j < 100; j++) {
				grid[i] += ".";
			}
		}
	}

	for (int i = 0; i < 49; i += 2) {
		if (A <= 1) break;

		for (int j = 0; j < grid[i].size(); j += 2) {
			grid[i][j] = '.';
			A--;

			if (A <= 1) break;
		}
	}

	for (int i = 51; i < 100; i += 2) {
		if (B <= 1) break;

		for (int j = 0; j < grid[i].size(); j += 2) {
			grid[i][j] = '#';
			B--;

			if (B <= 1) break;
		}
	}

	cout << "100 100" << endl;
	for (int i = 0; i < grid.size(); i++) {
		for (int j = 0; j < grid[i].size(); j++) {
			cout << grid[i][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
def p(n):
    i = 2
    t = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            t.append(i)
        i += 1
    if n > 1:
        t.append(n)
    return t


def main():
    from fractions import gcd
    a, b = map(int, input().split())
    g = gcd(a, b)
    print(len(set(p(g))) + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5436
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
#include <complex>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef double D;
typedef complex<D> P;
typedef pair<P,P> L;
D inf=1e50,eps=1e-9;
bool eq(D a,D b){return abs(a-b)<eps;}
D cro(P a,P b){return imag(conj(a)*b);}
D dot(P a,P b){return real(conj(a)*b);}
int ccw(P a,P b,P c){
	if(cro(b-a,c-a)>eps) return 1;
	if(cro(b-a,c-a)<-eps) return -1;
	if(eq(abs(a-c)+abs(c-b),abs(a-b))) return 0;
	if(eq(abs(a-b)+abs(c-b),abs(a-c))) return -2;
	if(eq(abs(a-c)+abs(a-b),abs(c-b))) return 2;
}
P perp(L l,P p){
	D t=dot(p-l.fs,l.fs-l.sc)/norm(l.fs-l.sc);
	return l.fs+t*(l.fs-l.sc);
}
P refl(L l,P p){
	return p+2.0*(perp(l,p)-p);
}
bool iLS(L l,L s){
	return cro(l.sc-l.fs,s.fs-l.fs)*cro(l.sc-l.fs,s.sc-l.fs)<eps;
}
P intLL(L a,L b){
	D t=cro(a.sc-a.fs,a.sc-b.fs)/cro(a.sc-a.fs,b.sc-b.fs);
	return b.fs+t*(b.sc-b.fs);
}
P S,T;
int N;
L l[5];
D ans;
void calc(P ss,P tt,vector<int> ref){
	L a=L(tt,ss);
	reverse(all(ref));
	D d=0;
//	cout<<"ref  ";
//	rep(i,ref.size()) cout<<ref[i]<<" ";
//	cout<<endl;
	rep(i,ref.size()+1){
		P s=a.fs,t=a.sc;
//		show(s);
//		show(t);
		D mx=inf;
		P tmp;
		int tmpid;
		rep(j,N){
			if(i>0&&j==ref[i-1]) continue;
			if(iLS(a,l[j])){
				P p=intLL(l[j],a);
				if(ccw(a.fs,a.sc,p)!=2&&mx>abs(s-p)){
					mx=abs(s-p);
					tmp=p;
					tmpid=j;
				}
			}
		}
		if(i==ref.size()){
			int x=ccw(s,t,S);
			if(mx>abs(s-S)&&(x!=2)){
				ans=min(ans,d+abs(s-S));
			}
			return;
		}
		if(ref[i]!=tmpid) return;
		d+=mx;
		P dx=(l[tmpid].fs-l[tmpid].sc)*P(0,1);
		L lx=L(tmp,tmp+dx);
		a=L(tmp,refl(lx,s));
	}

}
void dfs(P s,P t,vector<int> ref){
	calc(s,t,ref);
	if(ref.size()==5) return;
	rep(i,N){
		if(ref.size()&&ref.back()==i) continue;
		vector<int> nr=ref;
		nr.pb(i);
		P ns=refl(l[i],s);
		dfs(ns,t,nr);
	}
}
int main(){
	while(true){
		cin>>N;
		if(N==0) break;
		ans=inf;
		rep(i,N){
			D a,b,c,d;
			cin>>a>>b>>c>>d;
			l[i]=L(P(a,b),P(c,d));
		}
		D aa,bb,cc,dd;
		cin>>aa>>bb>>cc>>dd;
		S=P(aa,bb),T=P(cc,dd);
		vector<int> be;
		dfs(S,T,be);
		printf("%.12f\n",ans);
	}
}

Measured memory_bytes: 1276
#ifdef CLION
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
//#define int long long

using namespace __gnu_pbds;
using namespace std;

using ll = long long;
#define int ll
template<typename T>
using oset = tree<
        T,
        null_type,
        less<T>,
        rb_tree_tag,
        tree_order_statistics_node_update>;


#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define chkmx(a, b) (a) = max((a), (b))
#define chkmn(a, b) (a) = min((a), (b))

constexpr int MAXN = 3e3;

vector<int> g[MAXN];

int cnt = 0;
int max_deg = 0;
int k;
void run() {
    string s;
    cin >> s;
    int cn, cs, ce,cw;
    cn = cs = ce =cw = 0;
    for (auto ch : s) {
        if (ch == 'N') cn=1;
        if (ch == 'S') cs=1;
        if (ch == 'E') ce=1;
        if (ch == 'W') cw=1;
    }
    if (!(cs ^ cn) && !(ce ^ cw)) {
        puts("Yes");
    } else {
        puts("No");
    }
}


signed main() {

#ifdef CLION
    freopen("input.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int t = 1;
    //cin >> t;
    while (t--)
        run();
    return 0;
}

Measured memory_bytes: 384