akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
 
int main(void){
 
  int count = 0,i;
  char day[3][2];
  
  scanf("%c%c%c\n",&day[0][0],&day[1][0],&day[2][0]);
  scanf("%c%c%c\n",&day[0][1],&day[1][1],&day[2][1]);
 
  for(i=0;i<3;i++){
  	if(day[i][0] == day[i][1]) count++;
  }
  
  printf("%d\n",count);	
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
 
int main(void){
 
  char card[201];
  char copy[201];
  int m,h;
  register int i;
 
  while(scanf("%s",card)){
    if(card[0] == '-'){
      break;
    }
    scanf("%d",&m);
    for(i = 0;i < m;i ++){
      scanf("%d",&h);
      strcpy(copy,card);
      strcpy(card,copy + h);
      copy[h] = '\0';
      strcat(card,copy);
    }
    printf("%s\n",card);
  }
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,char> P;
int main(){
  int n;
  while(cin>>n,n){
    char c[100];
    int cc[256]={},f=1;
    for(int i=1;i<=n;i++){
      cin>>c[i];
      cc[c[i]]++;
      P tmp[256]={};
      for(int j='A';j<='Z';j++)tmp[j]=P(-cc[j],j);
      sort(tmp,tmp+256);
      if(f&&tmp[1].first-tmp[0].first>n-i)
	cout<<tmp[0].second<<" "<<i<<endl,f=0;
    }
    if(f)cout<<"TIE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define INF (1<<29)
int dp[1001][1001];
int main()
{
	fill(dp[0], dp[1000], INF);
	string s1, s2; cin >> s1 >> s2;
	int s1sz = s1.size()+1, s2sz = s2.size()+1;
	for (int i = 0; i < s1sz; ++i) {
		dp[i][0] = i;
	}
	for (int j = 0; j < s2sz; ++j) {
		dp[0][j] = j;
	}
	for (int i = 1; i < s1sz; ++i) {
		for (int j = 1; j < s2sz; ++j) {
			dp[i][j] = min(dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1]), min(dp[i - 1][j] + 1, dp[i][j - 1] + 1));
		}
	}
	cout << dp[s1sz-1][s2sz-1] << endl;
}

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

int n;
int h[105];
int main(){
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> h[i];
	}
	int tot = 0;
	bool put = 0;
	for (int w = 1; w <= 100; w++){
		for (int i = 1; i <= n; i++){
			if (h[i]){
				put = 1;
				--h[i];
			} else {
				if (put) tot++;
				put = 0;
			}
		}
		if (put) tot++;
		put = 0;
	}
	cout << tot << '\n';
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
    int n;cin>>n;
    vl a(n);
    map<ll,ll>c;
    set<ll>b;
    bool d=true,e=true,f=true;
    rep(i,n){
        cin>>a[i];
        ll m=a[i];
        if(m==1)e=false;
        else{
        for(int j=2;j*j<=m;++j){
            if(m%j==0){
                b.insert(j);
                if(c[j]>=1){
                    d=false;
                    break;
                }
                c[j]++;
                while(m%j==0)m/=j;
            }
        }
        if(m>1){
            b.insert(m);
            if(c[m]>=1){
                    d=false;
                    break;
            }
            c[m]++;
        }}
    }
    if(d){cout<<"pairwise coprime"<<endl;return 0;}
    else{
        ll GCD=a[0];
        rep(i,n){
            GCD=gcd(GCD,a[i]);
        }
        if(GCD==1)cout<<"setwise coprime"<<endl;
        else cout<<"not coprime"<<endl;
    }
}


Measured memory_bytes: 12484
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,a,b;

     cin>>n>>a>>b;

       long long int x = n/(a+b);

       x = a*x;
      long long int rem =n%(a+b);

       if(rem >= a)
        x+=a;

      else
      x+=rem;

      cout<<x;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,x,c[12],a[12][12],mi=100001*12,ba;
    cin>>n>>m>>x;
    int i;
    for(int t=0;t<n;t++)
    {
    	cin>>c[t];
    	for(int i=0;i<m;i++)
    	{
    		cin>>a[t][i];
		}
	}
	for(int t=0;t<(1<<n);t++)
	{
        long long ba=0,b[12]={0},y=1;
        for(i=0;i<n;i++)
        {
        	if((t>>i)&1)
        	{
        		ba+=c[i];
        		for(int j=0;j<m;j++)
        		{
        			b[j]+=a[i][j];
                }
			}
		}
        for(i=0;i<m;i++)
        {
        	if(b[i]<x)
        	{
        		y=0;
        		break;
			}
		}
	//-	cout<<ba<<" ";
	//	for(int j=0;j<m;j++)
	//	{
			//cout<<b[i]<<" ";
	//	}
	//	cout<<endl;
        if(y==1)
        {
        	//cout<<"HI ";
        	mi=min(mi,ba);
		}
	}
	if(mi==100001*12)
	{
		cout<<"-1";
	}
	else
	{
		cout<<mi;
	}
    return 0;
}
//※ at most 512 KiB
//※ Your source code will be saved as Main.extension.

Measured memory_bytes: 3604
s = input()
rev = s[::-1]
n = len(s)
for i in range(1, n):
  l = s[i:]
  r = rev[i:]

  if l[:(n-i)//2] == l[(n-i)//2:] or r[:(n-i)//2] == r[(n-i)//2:]:
    print(n-i)
    break

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
typedef long long ll;
ll K, Q;
ll diff[5005];
ll diffNew[5005];
int main() {
    cin >> K >> Q;
    for (int i=0; i<K; i++){
        scanf("%lld", &diff[i]);
    }
    ll n, m, x;
    for (int q=0; q<Q; q++){
        scanf("%lld %lld %lld", &n, &x, &m);
        ll sub = 0;
        ll sumRem = x%m;
        ll sumTot = 0;
        for (ll i=0; i<K; i++){
            diffNew[i] = diff[i] % m;
            if (diffNew[i] == 0) {
                sub += (n-1)/K;
                if (i < n-1-(n-1)/K*K) sub++;
            }
            else {
                sumRem += (n-1)/K * diffNew[i];
                if (i < n-1-(n-1)/K*K) sumRem += diffNew[i];
                sumTot += sumRem/m;
                sumRem %= m;
            }
            //cout << i << " " << diffNew[i] << " " << sub << " " << sumTot << endl;
        }
        sub += sumTot;
        printf("%lld\n", n-1-sub);
    }
    return 0;
}


Measured memory_bytes: 384
using namespace std;
#include <bits/stdc++.h>
#define frr(i, r, l) for(int i = r; i >= l; --i)
#define fr(i, l, r) for(int i = l; i < r; ++i)
#define forit(it, type, var) for(type::iterator it = var.begin(); it != var.end(); it++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define MEMS(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define m_p make_pair
#define pb push_back
#define ll long long
#define ld long double
typedef pair<ll, ll> iPair; 
priority_queue< ll, vector <ll> , greater<ll>>pq1,pq2;
#define maxN 1000000000000000000
ll power(ll a,ll b){ll res=1;while(b>0){res*=a;b--;}return res;}
int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string str;
    ll sum=0;
    cin>>str;
    ll l=str.length();
    fr(i,0,l)
    {
        sum+=str[i]-'0';
    }
    if(sum%9==0)
    cout<<"Yes"<<endl;
    else   
     cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3764
using System;

namespace ITP1_8_A
{
	class Program
	{
		static void Main(string[] args)
		{
			string txt = Console.ReadLine();

			char[] cs = txt.ToCharArray();
			for(int i = 0; i < cs.Length; i++) {
				if(char.IsUpper(cs[i])) {
					cs[i] = char.ToLower(cs[i]);
				}
				else if(char.IsLower(cs[i])) {
					cs[i] = char.ToUpper(cs[i]);
				}
			}

			string ans = new string(cs);

			Console.WriteLine(ans);
		}
	}
}



Measured memory_bytes: 15852
#include<bits/stdc++.h>
using namespace std;
#define MAXN 100005
#define ll long long int
#define int long long
int n,x,y,k=0;
int a[MAXN];
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>x>>y;

    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            a[min(abs(j-i),abs(x-i)+1+abs(j-y))]++;
        }
    }

    for(int i=1;i<n;i++){
        cout<<a[i]<<"\n";
    }
    return 0;

    

}

Measured memory_bytes: 256
from collections import defaultdict
N,K=map(int,input().split())
A=list(map(int,input().split()))
ct=defaultdict(int)
for a in A:
    ct[a]+=1
svalues=sorted(ct.items(),key=lambda x:x[1])
num=len(ct)
count=0
for k,v in svalues:
    if num<=K:
        break
    else:
        count+=v
        num-=1
print(count)

Measured memory_bytes: 39320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
char s[N];
int n, cnt;
int t1, t2;

ll binpow(ll a, ll b, ll p) {
	a %= p;
	ll ret = 1;
	while (b) {
		if (b & 1) ret = ret * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return ret % p;
}

int calc(int x) {
	int sum;
	if (s[x] == '1') {
		if (cnt == 1) return 0;
		sum = (t1-binpow(2, n-x, cnt-1) + cnt-1) % (cnt-1);
	} else {
		sum = (t2+binpow(2, n-x, cnt+1)) % (cnt+1);
	}
	int ret = 1;
	while (sum) {
		sum = sum % __builtin_popcount(sum);
		ret++;
	}
	return ret;
}

int main()
{
	scanf("%d%s", &n, s+1);
	for (int i = 1; i <= n; i++) {
		if (s[i] == '1') cnt++;
	}
	for (int i = 1; i <= n; i++) {
		if (s[i] == '1') {
			if (cnt > 1) t1 = (t1 + binpow(2, n-i, cnt-1)) % (cnt-1);
			t2 = (t2 + binpow(2, n-i, cnt+1)) % (cnt+1);
		}
	}
	for (int i = 1; i <= n; i++) {
		printf("%d\n", calc(i));
	}
	return 0;
}

Measured memory_bytes: 3960
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const arr = input.split(' ').map(Number);
const x = Math.pow((arr[0] - arr[2]),2) + Math.pow((arr[1] - arr[3]),2);
const dist = Math.sqrt(x).toFixed(4);
console.log(dist);


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
/**最小公倍数**/
int gcd( int m, int n )
{
	// 引数に0がある場合は0を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
        else n = n - m;
	}
	return m;
}//g
/**最大公約数**/
int lcm( int m, int n )
{
	// 引数に0がある場合は0を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    int ma=lcm(n,m);
    int na=ma/n;
    int mma=ma/m;
    mma+=na;
    //cout << mma << " " << ma << endl;
    double ans=(double)ma/(double)mma;
    printf("%.10f\n",ans);
    return 0;
}


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

using namespace std;

struct dish_t {
  int a;
  int b;
};

int64_t solve(const std::vector<dish_t>& dishes) {
  int const n = dishes.size();
  int64_t ret = 0;
  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      ret += dishes[i].a;
    } else {
      ret -= dishes[i].b;
    }
  }
  return ret;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n;
  std::cin >> n;
  std::vector<dish_t> dishes(n);
  for (auto& d : dishes) {
    std::cin >> d.a;
    std::cin >> d.b;
  }
  std::sort(dishes.begin(), dishes.end(), [](const auto& lhs, const auto& rhs) {
    return lhs.a + lhs.b > rhs.a + rhs.b;
  });
  std::cout << solve(dishes) << std::endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
using namespace std;

int N,A[200020],P[200020],C[200020],par[200020],lf[200020],rt[200020];

int find(int x)
{
	if (par[x] != x) par[x] = find(par[x]);
	return par[x];
}

void uni(int x, int y)
{
	x = find(x); y = find(y);
	par[y] = x;
	lf[x] = min(lf[x],lf[y]);
	rt[x] = max(rt[x],rt[y]);
}

int main()
{
	scanf ("%d",&N);
	for (int i=1;i<=N;i++){
		scanf ("%d",&A[i]);
		P[A[i]] = i;
		par[i] = lf[i] = rt[i] = i;
	}

	long long ans = 0;
	for (int i=N;i>=1;i--){
		C[P[i]] = 1;
		int u = find(P[i]);
		int v = find(lf[u]-1);
		int k = 1;
		if (C[v]){
			uni(u,v);
			k = rt[v] - lf[v] + 2;
		}
		u = find(u);
		v = find(rt[u]+1);
		int l = 1;
		if (C[v]){
			uni(u,v);
			l = rt[v] - lf[v] + 2;
		}
		u = find(u);

		ans += (long long) i * k * l;
	}
	printf ("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 4864
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define INF 1200000000



int main(){
    
    long long A,B,K;
    cin>>A>>B>>K;
    
    if(K<=A){
        cout<<A-K<<" "<<B<<endl;
        return 0;
    }
    else if(K<=A+B){
        cout<<0<<" "<<B-(K-A)<<endl;
        return 0;
    }
    else{
        cout<<0<<" "<<0<<endl;
    }
    
}




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

int main(){
  string str;
  vector <char> ch;
  vector <char> ch2;
  
  cin >> str;
  int i;
  int len = str.size();
  int flag = 1;
  int cnt = 0;
  for( i = 0; i < len; i++ ){
    if( str[i] == 'A' || str[i] == 'Z' ) ch.push_back(str[i]);
  }

  int len2 = ch.size();

  for( i = 0; i < len2-1; i++ ){
    if( ch[i] == 'A' && ch[i+1] == 'Z' ){
      ch2.push_back(ch[i]);
      ch2.push_back(ch[i+1]);
    }
  }

  int len3 = ch2.size();

  if( ch2.empty() ) cout << "-1" << endl;
  else{
    for( i = 0; i < len3; i++ ){
      cout << ch2[i];
  }
  cout << endl;
  }
  
  return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int k, x;
  cin >> k >> x;
  cout << ((k * 500 >= x) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  long int n;
  scanf("%ld", &n);

  char ans[15];
  int amari;
  for(int i=0;i<15;i++){
    amari = n % 26;
    if(amari==0){
      if(n==0) ans[i] = ' ';
      else ans[i] = 'z';
    }
    else ans[i] = amari+96;
    n = (n-1) / 26;
  }

  char tmp;
  for(int j=0;j<14;j++){
    for(int k=j+1;k<15;k++){
      if(ans[k] != ' '){
        tmp = ans[j];
        ans[j] = ans[k];
        ans[k] = tmp;
      }
    }
  }

  printf("%s", ans);

  return 0;
}


Measured memory_bytes: 1704
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::string;

int main()
{
  string ss;
  cin >> ss;
  std::vector<int> s;
  for(size_t i = 0; i < ss.size(); ++i)
  {
    std::string tmp = ss.substr(i,1);
    s.emplace_back(std::stoi(tmp));
  }
  int count = 0;

  while(s.size() >= 2)
  {
    // std::for_each(s.begin(), s.end(), [](int x) { std::cout << x << ","; });
    // cout << "\n";
    int id = -1;
    for (size_t i = 0; i < s.size()-1; ++i)
    {
      if (s[i] != s[i+1])
      {
        id = i;
        // cout << "delete: " << id << ", " << s[i] << ", " << s[i+1] << "\n"; 
        break;
      }
    }

    if (id != -1)
    {
      s.erase(s.begin() + id, s.begin() + id+2);
      count += 2;
      continue;
    }
    else
    {
      break;
    }
  }

  std::cout << count << "\n";

  return 0;
}


Measured memory_bytes: 1020
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)    (x).begin(),(x).end()
#define UNIQ(c)   (c).erase(unique(ALL((c))), end((c)))
#define mp        make_pair
#define eb        emplace_back
#define REP(i, a) for (int i = 0; i < (a); i++)

int N, C;
int s[100000], t[100000], c[100000];
int sm[200002];
int tt[200002];
int main(){
	cin >> N >> C;
	for (int i = 0; i < N; i++)
		cin >> s[i] >> t[i] >> c[i];
	for (int i = 1; i <= C; i++){
		for (int j = 0; j <200002; j++) tt[j] = 0;
		for (int j = 0; j < N; j++) if (c[j] == i) tt[s[j] * 2 - 1]++, tt[t[j] * 2]--;
		for (int j = 1; j <200002; j++) tt[j] += tt[j - 1];
		for (int j = 0; j <200002; j++) if (tt[j] >0) sm[j]++;
	}
	int ans = 0;
	for (int j = 0; j <200002; j++) if (ans < sm[j]) ans = sm[j];
	cout << ans << endl;
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);

        // 高橋、青木モンスター設定
        int takaMHp = s.nextInt();
        final int TAKA_M_ATK = s.nextInt();
        int aokiMHp = s.nextInt();
        final int AOKI_M_ATK = s.nextInt();

        int x = 1;
        while (true) {
            if (x % 2 == 1) {
                // 高橋ターン
                aokiMHp -= TAKA_M_ATK;
            } else {
                // 青木ターン
                takaMHp -= AOKI_M_ATK;
            }

            if (aokiMHp <= 0 || takaMHp <= 0) {
                break;
            }
            x += 1;
        }

        if (takaMHp > 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
  }
}

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

int main(){
    int x1, y1, x2, y2, x3, y3, x4, y4;
    int sub_x, sub_y;

    cin >> x1 >> y1 >> x2 >> y2;

    sub_x = x2 - x1;
    sub_y = y2 - y1;

    x3 = x2 - sub_y;
    y3 = y2 + sub_x;
    x4 = x3 - sub_x;
    y4 = y3 - sub_y;

    cout << x3  << "  "<< y3 <<"  "<< x4 <<"  "<< y4 << endl;

    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::cmp::Ordering;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(Eq)]
struct Shop {
    index: usize,
    name: String,
    score: u64
}

impl PartialEq for Shop {
    fn eq(&self, other: &Shop) -> bool {
        self.name == other.name && self.score == other.score
    }
}

impl PartialOrd for Shop {
    fn partial_cmp(&self, other: &Shop) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

impl Ord for Shop {
    fn cmp(&self, other: &Shop) -> Ordering {
        if self.name == other.name {
            other.score.cmp(&self.score)
        } else {
            self.name.cmp(&other.name)
        }
    }
}

fn main() {
    let n: usize = read();
    let mut s: Vec<Shop>  = Vec::with_capacity(n);
    for i in 0..n {
        let e = Shop {
            index: i + 1,
            name: read(),
            score: read(),
        };
        s.push(e);
    }
    s.sort();
    for e in &s {
        println!("{}", e.index);
    }
}


Measured memory_bytes: 4352
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int h = fs.nextInt(), n = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		long sum = 0;
		for(int i=0;i<n;i++) {
			sum += a[i];
		}
		if(sum>=h)System.out.println("Yes");
		else System.out.println("No");
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}


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

int main() {
  int L;
  cin >> L;
  double l = (double)L/3;
  cout << fixed;
  cout << setprecision(12) << l*l*l << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<(k) ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=(k) ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define X first
#define Y second
#ifdef tmd
#define TIME(i) Timer i(#i)
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
class Timer {
private:
    string scope_name;
    chrono::high_resolution_clock::time_point start_time;
public:
    Timer (string name) : scope_name(name) {
        start_time = chrono::high_resolution_clock::now();
    }
    ~Timer () {
        auto stop_time = chrono::high_resolution_clock::now();
        auto length = chrono::duration_cast<chrono::microseconds>(stop_time - start_time).count();
        double mlength = double(length) * 0.001;
        debug(scope_name, mlength);
    }
};
#else
#define TIME(i)
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

int n;
string str;
/********** Good Luck :) **********/
int main () {
    TIME(main);
    IOS();

    cin >> n;
    cin >> str;

    for (auto &c : str) {
        int idx = c - 'A';
        idx = (idx + n) % 26;
        c = 'A' + idx;
    }

    cout << str << endl;

    return 0;

}


Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
  	var ans int64
  	ans = 1
	for i := 2; i < n+1; i++ {
      	ans += int64(i)
		for j := i; j < n+1; j += i {
			ans += int64(j)
		}
	}
	fmt.Fprintln(writer, ans)
}


Measured memory_bytes: 1852
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	string S; cin >> S;
	int N = sz(S);
	F0R(i, N) {
		if (i % 2 == 0 && S[i] == 'L') {
			cout << "No" << endl; return 0;
		}
		if (i % 2 == 1 && S[i] == 'R') {
			cout << "No" << endl; return 0;
		}
	}
	
	cout << "Yes" << endl;
	
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 256
// import java.util.Scanner

object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val a = sc.nextInt //最初の整数が読み込まれる
    
    var b: Long = 0
    
    (1 to a).foreach{j =>
      j match{
      	case j if j%15 == 0 => b = b
        case j if j%3 == 0 => b = b
        case j if j%5 == 0 => b = b
        case _ => b = b + j.toLong
      }
    }
     println(b)
  }
}


Measured memory_bytes: 55372
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;

ll powMod(ll x, ll n) {
  if (n == 0) return 1;
  ll r = powMod(x, n / 2);
  if (n % 2 == 0) return (r * r) % MOD;
  return (r * r % MOD) * x % MOD;
}


int main(void) {

  int n, k;
  cin >> n >> k;
  ll a[100010];
  rep(i, n) cin >> a[i];
  sort(a, a + n);

  int d = 0, cnt = 0;
  ll b[100010][2] = {};
  while (d < n) {
    int i = d;
    while (a[d] == a[i]) i++;
    b[cnt][0] = a[d];
    b[cnt][1] = i - d;
    cnt++;
    d = i;
  }
  
  int x = 0, i = 0;
  while (x < k) {
    x += b[i][1];
    i++;
  }

  ll fac[100010]; fac[1] = 1; fac[0] = 1;
  for (ll i = 2; i <= (ll)n; i++) {
    fac[i] = i * fac[i - 1] % MOD;
  }

  ll sb[100010] = {};
  sb[cnt - 1] = b[cnt - 1][1];
  for (int i = cnt - 2; i >= 0; i--) {
    sb[i] = sb[i + 1] + b[i][1];
  }

  ll sf[100010] = {};
  sf[0] = b[0][1];
  for (int i = 1; i < cnt; i++) {
    sf[i] = sf[i - 1] + b[i][1];
  }

  ll mi = 0, ma = 0;
  for (int i = cnt - 1; i >= 0; i--) {
    for (ll j = 1; j <= b[i][1]; j++) {
      if (sb[i + 1] < k - j) continue;
      //cout << "####" << endl;
      ll v = fac[sb[i + 1]]; 
      v *= powMod(fac[k - j], MOD - 2);
      v %= MOD;
      v *= powMod(fac[sb[i + 1] - k + j], MOD - 2);
      v %= MOD;
      ll u = fac[b[i][1]];
      u *= powMod(fac[b[i][1] - j], MOD - 2);
      u %= MOD;
      u *= powMod(fac[j], MOD - 2);
      u %= MOD;
      //cout << b[i][0] << " " << v << " " << endl;
      mi += (u * b[i][0] % MOD) * v % MOD;
      mi %= MOD;
    }
  }

  for (int i = 1; i < cnt; i++) {
    for (ll j = 1; j <= b[i][1]; j++) {
      if (sf[i - 1] < k - j) continue;
      
      ll v = fac[sf[i - 1]]; 
      v *= powMod(fac[k - j], MOD - 2);
      v %= MOD; 
      v *= powMod(fac[sf[i - 1] - k + j], MOD - 2);
      v %= MOD; 
      ll u = fac[b[i][1]];
      u *= powMod(fac[b[i][1] - j], MOD - 2);
      u %= MOD;
      u *= powMod(fac[j], MOD - 2);
      u %= MOD; 
      ma += (u * b[i][0] % MOD) * v % MOD;
      ma %= MOD;
    }
  }

  if (b[0][1] >= k) {
    ll u = fac[b[0][1]];
      u *= powMod(fac[b[0][1] - k], MOD - 2);
      u %= MOD;
      u *= powMod(fac[k], MOD - 2);
      u %= MOD;
      ma += u * b[0][0] % MOD;
      ma %= MOD;
  }




    
  

  ll ans = (ma - mi) % MOD;
  if (ans < 0) ans += MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4992
N = int(input())
S = input()
ans = [0] * N
ans[0] = S[1:].count('E')
num = ans[0]

for i in range(1, N):
    if S[i-1] == 'W':
        num += 1
    if S[i] == 'E':
        num -= 1
    ans[i] = num
    
print(min(ans))

Measured memory_bytes: 15436
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll ans=0;
string a,b;
int32_t main(){
CODE_START;
cin>>a>>b;
for(ll i=0;i<a.size();i++)
{
    if(a[i]!=b[i]){
        ans++;
    }
}
cout<<ans<<endl;
}


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

using namespace std;
using int64 = long long;
const int mod = 1e9 + 7;
//const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return (ret);
}

int main() {
  int64 N;
  cin >> N;
  auto d = prime_factor(N);
  int64 ret = 0;
  for(auto &p : d) {
    int now = 1;
    while(p.second - now >= 0) {
      p.second -= now;
      ++now;
      ++ret;
    }
  }
  cout << ret << "\n";
}




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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> s(M), c(M);
  for(int i = 0; i < M; i++) {
    cin >> s[i] >> c[i];
    s[i]--;
  }
  string S;
  int count;
  int ans = 10000000;
  for(int num = 0; num <= 999; num++) {
    count = 1;
    S = to_string(num);
    for(int i = 0; i < M; i++) {
      if(S[s[i]] - '0' != c[i]) { count = 0; } 
    }
    if(count == 1 && S.size() == N) { 
      if(ans > num) ans = num;
    }
  }
  if(ans == 10000000) cout << -1;
  else cout << ans; 
}

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

int main()
{
  int h, n; cin >> h >> n;
  int sum = 0;
  for (int i = 0, a; i < n; ++i)
  {
    cin >> a;
    sum += a;
  }
  
  if (sum >= h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(void)
{
    int a,b,c,x;
    scanf("%d%d%d",&a,&b,&c);
    if (a>b) {
        x = a;
        a = b;
        b = x;
    }
    if (b>c){
        x=b;
        b=c;
        c=x;
    }
    if (a>b) {
        x = a;
        a = b;
        b = x;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
//
struct poi{
  int X;int Y;int Z;
  bool operator<(const poi&R)const{
    return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
  }
};
//
//
int N;
int A[200000];
int main(){
	cin>>N;
	FOR(i,0,N){
		cin>>A[i];
	}
	int now=0;
	ll ans=N;
	while(now<N-1){
		ll S=A[now]+A[now+1];
		ll s=A[now]^A[now+1];
		if(S==s){
			int no=now;
			now+=2;
			int cnt=1;
			while(cnt>=1){
				while(now<N&&S==s){
					S+=A[now];
					s^=A[now];
					if(S==s){
						cnt++;
						now++;
					}else{
						S-=A[now];
						s^=A[now];
						break;
					}
				}
				ans+=cnt;
				S-=A[no];
				s^=A[no];
				no++;
				cnt--;
			}
			now--;
		}else{
			now++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
module Main where

import Data.List
import Data.Char (digitToInt)
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import qualified Data.Map.Strict as M


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las


main = do
    (n, r) <- readTuple2
    if n >= 10 then
        print r
    else
        print $ r + (100 * (10 - n))



Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n,a,b,c;
    cin>>n;
    a=n%10;
    if(a==2||a==5||a==7||a==9||a==4){
        cout<<"hon"<<endl;
    }
    if(a==0||a==1||a==6||a==8){
        cout<<"pon"<<endl;
    }
    if(a==3){
        cout<<"bon"<<endl;
    }
}


Measured memory_bytes: 3620
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#define rp(i,a,b) for(int (i)=(int)(a);i<(int)(b);++i)

using namespace std;

typedef long long ll;
typedef pair<int,int> P;



int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int bfs(P x,P y,vector<vector<int> > map){
    vector<vector<bool> > d(map.size(),vector<bool>(map[0].size()));
    queue<P> que;
    que.push(x);
    d[x.first][x.second]==true;
    while(que.size()){
        P p=que.front();que.pop();
        //cout<<"lll"<<p.first<<p.second<<endl;
        if(p.first == y.first and p.second==y.second) {break;}
        for(int i=0;i<4;i++){
            int nx=p.first+dx[i];
            int ny=p.second+dy[i];
            if(0<=nx && nx<map.size() && 0<=ny &&ny<map[0].size() && map[nx][ny]!=-1 && d[nx][ny]==false){
                d[nx][ny]=true;
                que.push(P(nx,ny));
                map[nx][ny]=map[p.first][p.second]+1;
                //cout<<nx<<ny<<map[nx][ny]<<endl;
                
            }
        }
    }
    return map[y.first][y.second];

}



int main(){
    int x,y,z;
    cin>>x>>y>>z;
    vector<vector<int> > map;
    vector<pair<int,int> > pl(z+1);

    int sx,sy;
    rp(i,0,x){
        vector<int> tmp;
        string s;
        cin>>s;
        rp(j,0,y){
            if(s[j]=='X') tmp.push_back(-1);
            else if(s[j]=='.') tmp.push_back(0);
            else if(s[j]=='S') sx=i,sy=j,tmp.push_back(0);
            else {pl[(int)(s[j] - '0')]=make_pair(i,j);tmp.push_back(0);}
        }
        map.push_back(tmp);
    }

    int ans=0;
    //cout<<sx<<sy<<pl[1].first<<pl[1].second<<endl;
    ans+=bfs(P(sx,sy),pl[1],map);
    for(int i=2;i<=z;i++){
        ans+=bfs(pl[i-1],pl[i],map);
    }
    cout<<ans<<endl;
    return 0;
};

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

int main() {
  int a,b,c,d=0;
  cin >> b;
  c=b;
  for(int i=0;i<8;i++){
    a=b%10;
    b=b/10;
    d+=a;
  }
  if(c%d==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}


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

int main()
{
  long long int N, K;
  cin >> N >> K;
  long long int R, S, P;
  cin >> R >> S >> P;
  string T;
  cin >> T;
  long long int ans = 0;
  vector<string> group(K);
  for (int i = 0; i < N; i++)
  {
    group[i % K] += T[i];
  }
  for (int i = 0; i < K; i++)
  {
    for (int j = 0; j < group[i].size(); j++)
    {
      if (j == 0)
      {
        if (group[i][j] == 'r')
        {
          ans += P;
        }
        else if (group[i][j] == 's')
        {
          ans += R;
        }
        else if (group[i][j] == 'p')
        {
          ans += S;
        }
      }
      else
      {
        if (group[i][j] == 'r' && group[i][j - 1] != 'r')
        {
          ans += P;
        }
        else if (group[i][j] == 's' && group[i][j - 1] != 's')
        {
          ans += R;
        }
        else if (group[i][j] == 'p' && group[i][j - 1] != 'p')
        {
          ans += S;
        }
        else
        {
          group[i][j] = 'x';
          continue;
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 5120
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;

void MAIN() {
    scanf("%d", &N);
    LL ans = 0;
    REP (i, N-1) {
	int x, y;
	scanf("%d%d", &x, &y);
	x--; y--;
	if (x > y) swap(x, y);

	LL tmp = 0;
	tmp -= LL(x+1) * (N-y);
	ans += tmp;
	//eprintf("%lld\n", tmp);
    }

    REP (i, N) {
	ans += LL(i+1) * (N-i);
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 3824
#include<iostream>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << ""; print(ts...); }

int main(){
  int k,a,b; cin >>k >>a >>b;
  print((b/k-(a-1)/k>=1)?"OK":"NG");
}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  string s;
  cin >> s;
  int n = s.size();

  vector<int> ans(n);
  int cnt = 0;
  rep(c, 2) {
    rep(i, n) {
      if (s[i] == 'R')
        ++cnt;
      else {
        ans[i] += cnt / 2;
        ans[i - 1] += (cnt + 1) / 2;
        cnt = 0;
      }
    }

    reverse(s.begin(), s.end());
    reverse(ans.begin(), ans.end());
    rep(i, n) {
      if (s[i] == 'L')
        s[i] = 'R';
      else
        s[i] = 'L';
    }
  }

  rep(i, n) printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************



int main(void) {

	int N, K;
	cin >> N >> K;

	if (N % K == 0) cout << 0 << endl;
	else cout << 1 << endl;


	/*ll N, M;
	cin >> N >> M;
	vll A(N);
	cin >> A;

	int l = 0, r = 0;
	ll sum = A[0];
	ll ans = 0;
	while (true) {
		cout << "l:" << l << " r:" << r << " sum:" << sum << endl;
		if (sum % M == 0) {
			ans++;
		}

		if (r == N && l == N) {
			cout << ans << endl;
			return 0;
		}
			
		if (r < N - 1 && (A[l] % 2 == 0 || l == r)) {
			r++;
			sum += A[r];
		}
		else if (l < r){
			sum -= A[l];
			l++;
		}
		else {
			cout << ans << endl;
			return 0;
		}
	}
	
*/
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
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];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        for(int i=1; i<n; i++) {
            if(a[i-1] == a[i]) {
                System.out.println("NO");
                return;
            }
        }

        System.out.println("YES");
    }



}


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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll n;
  string s;
  cin >> n >> s;

  ll ans = 0;
  for (ll i = 0; i < 1000; ++i) {
    ll s1 = i / 100;
    ll s2 = (i - s1*100) / 10;
    ll s3 = i - (s1*100 + s2*10);

    ll j = 0;
    for (; j < n; ++j) {
      if (s[j] == '0'+s1) break;
    }
    for ( j = j+1; j < n; ++j) {
      if (s[j] == '0'+s2) break;
    }
    for ( j = j+1; j < n; ++j) {
      if (s[j] == '0'+s3) break;
    }

    if (j >= n) continue;
    ++ans;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256