akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

int main(){
    char ch;
    int cnt[26] = {};
    
    while(cin >> ch){
        ch = tolower(ch);
        if (isalpha(ch)){
            cnt[ch-'a']++;
            
        }
    }
    for ( int i = 0; i < 26; i++){
        printf("%c : %d\n", i+'a', cnt[i]);
        
    }
    return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9;
int main() {
	int N, K;
	cin >> N >> K;
	int a;
	vector<int>v(N);
	int flag[200001] = {};
	for (int i = 0; i < N; ++i) {
		cin >> a;
		v.at(i) = a;
		flag[a]++;
	}
	sort(v.begin(), v.end());
	sort(flag, flag + 200001);
	int sum = 1;
	int count = 0;
	for (int i = 0; i < N-1; ++i) {
		if (v[i] != v[i + 1])
			sum++;
	}
	if (sum <= K)
		cout << 0 << endl;
	else {
		for (int i = 0; i < 200001; ++i) {
			if (flag[i] > 0) {
				sum--;
				count += flag[i];
			}
			if (sum <= K) {
				break;
			}
		}
		cout << count << endl;
	}
	return 0;
}

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

#define ll long long int
#define MOD (ll)1e9 + 7

int main() {
  ll n, k;
  cin >> n >> k;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];

  vector< pair<ll, ll> > inversion(n);
  for(int i = 0; i < n; i++) {
    inversion[i].first = 0;
    inversion[i].second = 0;
    for(int j = 0; j < i; j++) {
      if(a[i] > a[j]) inversion[i].first++;
    }
    for(int j = i + 1; j < n; j++) {
      if(a[i] > a[j]) inversion[i].second++;
    }
  }

  ll ans = 0;
  ll sum1 = (k - 1) * k / 2;
  sum1 %= MOD;
  ll sum2 = k * (k + 1) / 2;
  sum2 %= MOD;
  for(int i = 0; i < n; i++) {
    ans += inversion[i].first * sum1 + inversion[i].second * sum2;
    ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main(){
  int N,i;
  cin >> N;
  string S;
  cin >> S;
  
  int ch=1;
  for(i=0;i<N-1;i++){
    if(S[i]!=S[i+1]){
      ch++;
    }
  }
  
  cout << ch << endl;
}

Measured memory_bytes: 512
N = int(input())
WList = []
wrongflag = False
lastword = ''

for _ in range(N):
    word = input()
    if word in WList:
        wrongflag = True
    if lastword != '' and lastword != word[0]:
        wrongflag = True

    WList.append(word)
    lastword = word[-1]

if wrongflag:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,q) for(int i = 0; q > i; i++)
#define repp(i,o,q) for(int i = o; q > i; i++)
#define MOD 1000000007
int main(){
  int H,W;cin>>H>>W;
  int dp[H][W];
  char mp[H][W];
  rep(i,H){
    rep(j,W){
      dp[i][j] = 0;
      cin >> mp[i][j];
    }
  }
  rep(i,H){
    rep(j,W){
      if(mp[i][j] == '#'){
        dp[i][j] = 0;
        continue;
      }
      if(i == 0 && j == 0)dp[i][j] = 1;
      else if(i == 0) dp[i][j] = dp[i][j-1];
      else if(j == 0) dp[i][j] = dp[i-1][j];
      else dp[i][j] = (dp[i-1][j]+dp[i][j-1])%MOD;
    }
  }
  cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 5120
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


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


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    D = I()
    c = LI()
    s = LLIN(D)
    lst = [0] * 26
    for i in range(D):
        l = s[i]
        for j in range(26):
            lst[j] += c[j]
            l[j] += lst[j]
        if i < D - 2:
            l1 = s[i + 1]
            for j in range(26):
                l[j] += l1[j]
        ind = l.index(max(l))
        print(ind + 1)
        lst[ind] = 0




if __name__ == '__main__':
    main()

Measured memory_bytes: 78848
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=200;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int k,n;
LL dp[NN][NN][NN]={};
int mod;
LL ksm(LL a,LL b){
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
void upd(LL &x,LL y){
	x=(x+y)%mod;
}
void solve1(){
	dp[0][0][0]=1;
	int lim=k/2;
	for(int i=1;i<=n;++i){
		for(int a=0;a<=lim;++a){
			for(int b=0;b<=lim;++b){
				if(i&1){
					upd(dp[i][a][0],dp[i-1][a][b]);
					upd(dp[i][a][b+1],dp[i-1][a][b]);
				}
				else{
					upd(dp[i][0][b],dp[i-1][a][b]);
					upd(dp[i][a+1][b],dp[i-1][a][b]);
				}
			}
		}
	}
	LL ans=0;
	for(int a=0;a<=lim;++a){
		for(int b=0;b<=lim;++b){
			upd(ans,dp[n][a][b]);
		}
	}
	printf("%lld\n",ans);
}
void empty(int now){
	for(int j=0;j<=k+2;++j){
		for(int l=0;l<=k+2;++l){
			dp[now][j][l]=0;
		}
	}
}
void cut(int now){
	for(int j=0;j<=k+2;++j){
		for(int l=k-j+2;l<=k+2;++l){
			dp[now][j][l]=0;
		}
	}
}
void pushodd(int now){
	for(int j=0;j<=k+1;++j){
		for(int l=0;l<=k+1;++l){
			upd(dp[now][j][0],dp[now^1][j][l]);
			upd(dp[now][j][l+1],dp[now^1][j][l]);
		}
	}
	upd(dp[now][0][k+1],dp[now^1][0][k+1]);
}
void pusheven(int now){
	for(int j=1;j<=k+2;++j){
		for(int l=0;l<=k+2;++l){
			upd(dp[now][j-1][l],dp[now^1][j][l]);
		}
	}
	upd(dp[now][k+1][0],dp[now^1][k+1][0]);
	for(int j=0;j<=k+1;++j){
		for(int l=0;l<=k+1;++l){
			upd(dp[now][j][l],dp[now^1][0][l]);
		}
	}
}
void solve2(){
	int t=(k+1)/2;
	int now=0;
	dp[0][0][0]=1;
	for(int i=1;i<=k;i+=2){//2 4 6 | 1 3 5
		now^=1;
		empty(now);
		pushodd(now);
		cut(now);
	}
	for(int i=k+2;i<=n;i+=2){
		now^=1;
		empty(now);
		pushodd(now);
		now^=1;
		empty(now);
		pusheven(now);
		cut(now);
	}
	int cur=(n+1)/2*2-1-k;
	int cnt=(n-cur)/2;
	LL ans=0;
	for(int j=0;j<=cnt;++j){
		for(int l=0;l<=k+1-j;++l){
			int rem=cnt-j;
			upd(ans,dp[now][j][l]*ksm(2,rem));
		}
	}
	for(int l=0;l<=k+1-cnt-1;++l){
		upd(ans,dp[now][cnt+1][l]);
	}
	/*for(int i=cur+2;i<=n;i+=2){
		now^=1;
		empty(now);
		pusheven(now);
		cut(now);
	}
	for(int i=0;i<=k+1;++i){
		upd(ans,dp[now][0][i]);
		if(i<=k)upd(ans,dp[now][1][i]);
	}*/
	printf("%lld\n",ans);
}
int main(){
	//open();
	n=read();
	k=read();
	mod=read();
	if(k%2==0){
		solve1();
	}
	else solve2();
	close();
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++)cin >> a[i];
  int next=0;
  int I;
  bool ans=false;
  for(int i=0;i<N;i++){
    if(next==1){
      ans=true;
      I=i;
      break;
    }
    else{
      next=a[next]-1;
    }
  }
  if(ans)cout << I;
  else cout << -1;
}



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

int main()
{
	double a, b, r, f;
	int A, B, d;
	std::cin >> a >> b;
	A = a;
	B = b;
	f = a / b;
	a *= 1.000000;
	b *= 1.000000;
	d = A / B;
	r = A % B;
	std::cout << d << " " << r << " " << std::fixed << f << std::endl;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define RFOR(i, a, b) for (int i = (int)(b - 1); i >= (int)(a); --i)
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(a) ((int)(a).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define SQ(x) ((x) * (x))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

bool sieve[1299709+1];

int main() {
    sieve[0] = sieve[1] = true;
    FOR(i, 2, 1299709+1) {
        if (sieve[i]) continue;
        for (int j = i+i; j < 1299709+1; j+= i) {
            sieve[j] = true;
        }
    }
    int k;
    while (cin >> k, k) {
        if (!sieve[k]) {
            cout << "0" << endl;
        } else {
            int a, b;
            FOR(i, k, 1299709+1) {
                if (!sieve[i]) {
                    b = i;
                    break;
                }
            }
            RREP(i, k) {
                if (!sieve[i]) {
                    a = i;
                    break;
                }
            }
            cout << b - a << endl;
        }
    }
}

Measured memory_bytes: 4328
N=int(input())
print(N-1)
s=input()
if s=="Vacant":
    exit()
elif s=="Male":
    flag=1
else:
    flag=0
print(0)
s=input()
if s=="Vacant":
    exit()
elif s=="Male":
    flag=1
else:
    flag=0
st=0
end=N-1

while s!="Vacant":
    a=(end+st)//2
    print(a)
    s=input()
    if (a+flag*1)%2:
        if s=="Male":
            st=a
        else:
            end=a
    else:
        if s=="Female":
            st=a
        else:
            end=a


Measured memory_bytes: 38852
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 = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        int D = sc.nextInt();
        int ans = 0;
        int numOfPen = 0;
        int x = 0, y = 0;
        // Xセット
        while(numOfPen < N){
            numOfPen += A;
            x += B;
        }
        numOfPen = 0;
        // Yセット
        while(numOfPen < N){
            numOfPen += C;
            y += D;
        }
        
        if(x < y){
            ans = x;
        }else{
            ans = y;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int N;
    cin>>N;
    vector<int>A(N);
    vector<int>B(N);
    ll ans=0;
    rep(i,N){
        cin>>A[i];
        cin>>B[i];
        ans+=B[i]-A[i]+1;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int b[(int)1e6+7]={},minfact[(int)1e6+7]={},Isprime[(int) 1e6+7]={},p[(int) 1e6+7]={};
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    int algcd = a[0];
    for(int i=0;i<n;i++) algcd = gcd(algcd,a[i]);
    rep(i,1e6+8) Isprime[i] = 1;
    Isprime[0] = 0; Isprime[1] = 0;
    for(int i=2;i<=1e6+7;i++){
        if(Isprime[i]){
            minfact[i] = i;
            for(int j=2*i;j<=1e6+7;j+=i){
                if(minfact[j]!=0) continue;
                    minfact[j] = i;
                    Isprime[j] = 0;
            }
        }
    }
    int flag = 1;
    rep(i,n){
        map<int,int> res;
        while(a[i]>1){
            res[minfact[a[i]]]++;
            a[i] /= minfact[a[i]];
        }
        for(auto j:res){
            if(p[j.first]) flag = 0;
            else p[j.first] = 1;
        }
    }
    if(flag) cout << "pairwise coprime" << endl;
    else{
        if(algcd==1) cout << "setwise coprime"<< endl; 
        else cout << "not coprime" << endl;
    }
}

Measured memory_bytes: 19068
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N,S = read().decode('utf-8').split()
count = 0
for i in range(1000):
  s = str(i).zfill(3)
  index_all = 0
  for j in range(3):
    index = S[index_all:].find(s[j])
    if index == -1:
      break
    index_all += index+1
    if j ==2:
      count += 1
print(count)

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

using namespace std;

int main() {
    int a,b,h,s;
    /*cin >> a >> b >> h;
    
    s=(a+b)*h/2;
    
    cout << s << endl;*/
    
    int N,A,B;
    cin >> N >> A;
    B=N*N-A;
    
    cout << B << endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 110;

int n, m, imam[300];

char s[MAXN][MAXN];

vector <int> v[MAXN * MAXN];

set <pii> st[MAXN][MAXN];

int main() {
  scanf("%d %d",&n,&m);
  REP(i, n) scanf("%s",s[i]);
  REP(i, n) REP(j, m) imam[s[i][j]]++;

  REP(i, 300) if (imam[i]) v[imam[i]].push_back(i);

  REP(i, n) {
    REP(j, m) {
      int x = i;
      int nx = n - i - 1;
      int y = j;
      int ny = m - j - 1;
      st[i][j].insert(mp(x, y));
      st[i][j].insert(mp(nx, y));
      st[i][j].insert(mp(x, ny));
      st[i][j].insert(mp(nx, ny));
    }
  }

  vector <int> ans;
  REP(i, n) {
    REP(j, m) {
      if (*st[i][j].begin() != mp(i, j)) continue;
      ans.push_back((int)st[i][j].size());
    }
  }

  sort(all(ans));
  reverse(all(ans));

  REP(i, (int)ans.size()) {
    vector <pii> kand;
    FOR(j, 'a', 'z' + 1) if (imam[j] >= ans[i]) kand.push_back(mp(imam[j], j));
    if (kand.empty()) {
      puts("No");
      return 0;
    }
    sort(all(kand));
    int t = kand[0].sec;
    imam[t] -= ans[i];
  }

  puts("Yes");
  return 0;
}


Measured memory_bytes: 2688
package main

import "fmt"

func main() {
	var N, a, j int
	fmt.Scan(&N)
	j = 1
	for i := 0; i < N; i++ {
		fmt.Scan(&a)
		if a == j {
			j++
		}
	}
	if j == 1 {
    	fmt.Println(-1)
    } else if N == j-1 {
		fmt.Println(0)
    } else {
      	fmt.Println(N-j+1)
    }
}


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

int main() {
  int K, A, B;
  cin >> K >> A >> B;
  //cout << K << A << B <<endl;
  int C=1;
  string ans ="NG";
  
  while (K*C <= B) {
    if (A <= K*C && K*C <= B) {
      ans = "OK";
      break;
    }
    C++;
  }
  
  cout << ans << endl;

}

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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;using vb=vector<bool>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template <typename T> T read() {T t; cin >> t; return t;}

struct UnionFind {
  const int V; // 頂点数
  vector<int> par, rank, cnt; // 親の番号, 木の大きさ, 同じ親の頂点数
  UnionFind(int V) : V(V), par(V), rank(V), cnt(V) { init(); }

  // 初期化する
  void init() {
    for (int i = 0; i < V; i++) par[i] = i;
    fill(rank.begin(), rank.end(), 0);
    fill(cnt.begin(), cnt.end(), 1);
  }

  // 木の根を求める
  int find(int x) {
    return par[x] == x ? x : par[x] = find(par[x]);
  }

  // x と y の属する集合を併合
  // 併合前は違う集合だったら true を返す
  bool unite(int x, int y) {
    if ((x = find(x)) == (y = find(y))) return false;
    cnt[y] = cnt[x] = cnt[x] + cnt[y];

    if (rank[x] < rank[y]) par[x] = y;
    else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
    return true;
  }

  // x と y が同じ集合に属するか否か
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // x と同じ集合にいる頂点数を返す
  int count(int x) {
    return cnt[find(x)];
  }
};

bool solve() {
  int n = read<int>();
  int m = read<int>();

  vvi lh(m);

  rep(i, n) {
    int k = read<int>();
    rep(j, k) {
      int l = read<int>() - 1;
      lh[l].push_back(i);
    }
  }

  UnionFind uf(n);
  rep(i, m) {
    vi &h = lh[i];
    if (sz(h)) {
      int x = h[0];
      forr(j, h) {
        uf.unite(x, j);
      }
    }
  }
  return uf.count(0) == n;
}

void Main() {
  cout << (solve() ? "YES" : "NO") << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


Measured memory_bytes: 4608
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) printf("%d\n",(x));
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;
template<class T> using V = vector<T>;
using I = int;
using VI = V<I>;
const int INF = 2e9;
const int64 MOD = 1e9 + 7;

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(){
    int n; cin >> n;
    bool f = false;
    int tmp = n;
    tmp %= 10;
    if (tmp == 7) f = true;
    n /= 10;
    tmp = n;
    tmp %= 10;
    if (tmp == 7) f = true;
    n /= 10;
    tmp = n;
    tmp %= 10;
    if( tmp == 7) f =true;
    cout <<( f ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3632
N, K = map(int, input().split())
S = input()
T = S[::-1] #文字列反転
U = S + T
D = []
for i in range(N):
  D.append(U[i:i+N])
D.sort()
B = D[0]
for i in range(N):
  if B[i] != B[0]:
    break
if i * 1 << (K - 1) > N:
  print(B[0] * N)
else:
  print((B[0] * (i * (1 << (K - 1))) + B[i:])[:N])

Measured memory_bytes: 256136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int x,y,z,a[N],b[N],c[N],tp[N];
typedef pair<int,int> pii;
set<pii> xy,xz,yz,yx,zx,zy;
void x_to_y(){
	int p=xy.begin()->second;
	xy.erase(pii(a[p]-b[p],p));
	xz.erase(pii(a[p]-c[p],p));
	yx.insert(pii(b[p]-a[p],p));
	yz.insert(pii(b[p]-c[p],p));
	tp[p]=1;
}
void x_to_z(){
	int p=xz.begin()->second;
	xy.erase(pii(a[p]-b[p],p));
	xz.erase(pii(a[p]-c[p],p));
	zy.insert(pii(c[p]-b[p],p));
	zx.insert(pii(c[p]-a[p],p));
	tp[p]=2;
}
void y_to_x(){
	int p=yx.begin()->second;
	yz.erase(pii(b[p]-c[p],p));
	yx.erase(pii(b[p]-a[p],p));
	xy.insert(pii(a[p]-b[p],p));
	xz.insert(pii(a[p]-c[p],p));
	tp[p]=0;
}
void y_to_z(){
	int p=yz.begin()->second;
	yz.erase(pii(b[p]-c[p],p));
	yx.erase(pii(b[p]-a[p],p));
	zx.insert(pii(c[p]-a[p],p));
	zy.insert(pii(c[p]-b[p],p));
	tp[p]=2;
}
void z_to_x(){
	int p=zx.begin()->second;
	zx.erase(pii(c[p]-a[p],p));
	zy.erase(pii(c[p]-b[p],p));
	xy.insert(pii(a[p]-b[p],p));
	xz.insert(pii(a[p]-c[p],p));
	tp[p]=0;
}
void z_to_y(){
	int p=zy.begin()->second;
	zx.erase(pii(c[p]-a[p],p));
	zy.erase(pii(c[p]-b[p],p));
	yx.insert(pii(b[p]-a[p],p));
	yz.insert(pii(b[p]-c[p],p));
	tp[p]=1;
}
int main()
{
	scanf("%d%d%d",&x,&y,&z);
	for (int i=1;i<=x+y+z;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]);
	ll ans=0;
	for (int i=1;i<=x;i++){
		ans+=a[i];
		xy.insert(pii(a[i]-b[i],i));
		xz.insert(pii(a[i]-c[i],i));
		tp[i]=0;
	}
	for (int i=x+1;i<=x+y;i++){
		ans+=b[i];
		yz.insert(pii(b[i]-c[i],i));
		yx.insert(pii(b[i]-a[i],i));
		tp[i]=1;
	}
	for (int i=x+y+1;i<=x+y+z;i++){
		ans+=c[i];
		zx.insert(pii(c[i]-a[i],i));
		zy.insert(pii(c[i]-b[i],i));
		tp[i]=2;
	}
	while (1){
		ll XY=-xy.begin()->first,XZ=-xz.begin()->first;
		ll YZ=-yz.begin()->first,YX=-yx.begin()->first;
		ll ZX=-zx.begin()->first,ZY=-zy.begin()->first;
		ll tp1=XY+YX,tp2=XZ+ZX,tp3=YZ+ZY,tp4=XY+YZ+ZX,tp5=XZ+ZY+YX;
		ll Max=max(max(tp1,tp2),max(tp3,max(tp4,tp5)));
		if (Max<=0) break;
		ans+=Max;
		if (tp1==Max) x_to_y(),y_to_x();else
		if (tp2==Max) x_to_z(),z_to_x();else
		if (tp3==Max) y_to_z(),z_to_y();else
		if (tp4==Max) x_to_y(),y_to_z(),z_to_x();else
		if (tp5==Max) x_to_z(),z_to_y(),y_to_x();
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n,m,h,w,a,b,c,d,x,y;
string str;

signed main(){
  cin >> h >> w;
  iFOR(i,1,h+1){
    iFOR(j,0,w){
      cin >> str;
      if(str=="snuke"){
        printf("%c%d\n",j+'A',i);
      }
    }
  }
  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static final int WHITE = 0;
    public static final int GRAY = 1;
    public static final int BLACK = 2;
    public static final int INF = Integer.MAX_VALUE;


    public Main() {

    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[][] G = new int[n][n];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                int w = sc.nextInt();
                G[i][j] = (w == -1) ? INF : w;
            }
        }
        int res = prim(n, G);
        System.out.println(res);


    }

    private static int prim(int n, int[][] G) {
        int u;
        int minv;
        int[] d = new int[n];
        int[] p = new int[n];
        int[] color = new int[n];

        for (int i = 0; i < n; i++) {
            d[i] = INF;
            p[i] = -1;
            color[i] = WHITE;
        }

        d[0] = 0;

        while (true) {
            minv = INF;
            u = -1;
            for (int i = 0; i < n; i++) {
                if (d[i] < minv && color[i] != BLACK) {
                    u = i;
                    minv = d[i];
                }
            }
            if(u==-1){
                break;
            }
            color[u]=BLACK;

            for(int v=0;v<n;v++){
                if(color[v] != BLACK && G[u][v] != INF){
                    if(d[v] > G[u][v]) {
                        d[v] = G[u][v];
                        p[v] = u;
                        color[v] = GRAY;
                    }
                }
            }
        }
        int sum = 0;
        for(int i = 0; i < n; i++){
            if(p[i] != -1){
                sum += G[i][p[i]];
            }
        }
        return sum;
    }
}



Measured memory_bytes: 41100
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	static int A[100000], B[100000], C[100000];
	long long ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A, A + N);
	for (int i = 0; i < N; i++) {
		cin >> B[i];
	}
	sort(B, B + N);
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	sort(C, C + N);
	for (int i = 0; i < N; i++) {
		long long L = -1, R = N, As, Cs;
		while (R - L > 1) {
			int mid = L + (R - L) / 2;
			if (A[mid] < B[i]) L = mid;
			else R = mid;
		}
		As = R;
		L = -1, R = N;
		while (R - L > 1) {
			int mid = L + (R - L) / 2;
			if (C[mid] > B[i]) R = mid;
			else L = mid;
		}
		Cs = (N - R);
		ans += As * Cs;
	}
	cout << ans;
}

Measured memory_bytes: 1536
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

const int N = 2e5 + 5;

int n;
int arr[N];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    cin>>n;
    REP(i,1,n)cin>>arr[i];
    sort(arr+1, arr+n+1);

    int now = n;
    int use = 1;
    ll ans = 0;
    REV(i,n-1,1){
        ans += arr[now];
        use--;
        if(use == 0){
            use = 2;
            now--;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4472
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int n;
int t[101];
int v[101];

double Abs(double x) { if (x > 0) return x; return -x; }

int main() {
	int i, j;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> t[i];
	for (i = 0; i < n; i++) cin >> v[i];
	
	//速度を下げきれない場合をなくす
	for (i = n; i > 0; i--) {
		int limitV = v[i];
		for (j = i - 1; j >= 0; j--) {
			limitV += t[j];
			v[j] = min(limitV, v[j]);
		}
	}
	
	//あとは各区間で独立に制限速度を守ればよい。
	double nowSpeed = 0;
	double ans = 0;
	
	for (i = 0; i < n; i++) {
		if (v[i] > v[i + 1]) {
			if (v[i] - nowSpeed + v[i] - v[i + 1] <= t[i]) {
				ans += (nowSpeed + v[i]) * 0.5 * (v[i] - nowSpeed);
				ans += v[i] * (t[i] - (v[i] - nowSpeed + v[i] - v[i + 1]));
				ans += (v[i] + v[i + 1]) * 0.5 * (v[i] - v[i + 1]);
				nowSpeed = v[i + 1];
			}
			else {
				double maxSpeed = v[i] + (t[i] - (v[i] - nowSpeed + v[i] - v[i + 1])) * 0.5;
				if (maxSpeed >= v[i + 1]) {
					ans += (nowSpeed + maxSpeed) * 0.5 * (maxSpeed - nowSpeed);
					ans += (maxSpeed + v[i + 1]) * 0.5 * (maxSpeed - v[i + 1]);
					nowSpeed = v[i + 1];
				}
				else {
					maxSpeed = nowSpeed + t[i];
					ans += (nowSpeed + maxSpeed) * 0.5 * (maxSpeed - nowSpeed);
					nowSpeed = maxSpeed;
				}
			}
		}
		else {
			if (v[i] - nowSpeed <= t[i]) {
				ans += (nowSpeed + v[i]) * 0.5 * (v[i] - nowSpeed);
				ans += v[i] * (t[i] - (v[i] - nowSpeed));
				nowSpeed = v[i];
			}
			else {
				double maxSpeed = nowSpeed + t[i];
				ans += (nowSpeed + maxSpeed) * 0.5 * t[i];
				nowSpeed = maxSpeed;
			}
		}
	}
	printf("%.14f\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	string S;
	cin >> S;
	if(S=="Sunny")
		cout << "Cloudy" << endl;
	else if(S=="Cloudy")
		cout << "Rainy" << endl;
	else
		cout << "Sunny" << endl;

	return 0;
}



Measured memory_bytes: 3612
// https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_a
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
// clang-format on
int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(A, B) << " " << ((A + B) > N ? (A + B) - N : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll> 
#define pll pair <ll,ll> 

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return -1;
    }
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        //res%=m9, a%=m9;
        b>>=1;
    }
    return res;
}



///target expert

int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll d, t, s;
    cin>>d>>t>>s;
    if(t*s<d){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>

int main() {
    int D;
    cin >> D;
    if(D==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
    if(D==23){
        cout << "Christmas Eve Eve" << endl;
    }
    if(D==24){
        cout << "Christmas Eve" << endl;
    }
    if(D==25){
        cout << "Christmas" << endl;
    }
} 



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, Q;
  cin >> N >> M >> Q;
  
  int left_end[N + 1] = {};
  int right_end[N + 1] = {};
  
  int count[N+1][N+1] = {};
  int cumulative[N+1][N+1] = {};
  
  for (int i = 0; i < M; i++) {
    int l, r;
    cin >> l >> r;
    count[l][r] ++;
  }
  
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) {
      cumulative[i][j] = cumulative [i][j-1] + cumulative[i-1][j] - cumulative[i-1][j-1] + count[i][j];
    }
  }
  
  for (int i = 0; i < Q; i++) {
    int k, l;
    cin >> k >> l;
    cout << cumulative[l][l] - cumulative[k-1][l] - cumulative[l][k-1] + cumulative[k-1][k-1] << endl;
  } 
}

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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int res=0;
  for(int i=0;i<a;i++){
    res++;
    k--;
    if(k==0) break;
  }
  if(k>0)
  for(int i=0;i<b;i++){
    k--;
    if(k==0) break;
  }
  
  if(k>0)
  rep(i,c){
    res--;
    k--;
    if(k==0) break;
  }
  cout << res;
  return 0;
}

Measured memory_bytes: 3596
#!/usr/bin/env ruby

while line = gets
  a = line.chomp!.split(" ").map(&:to_i)
  b = gets.chomp!.split(" ").map(&:to_i)

  hit, blow = 0, 0
  4.times do |n|
      hit += 1 if a[n] == b[n]
      blow += 1 if a.include?(b[n])
  end
  puts "#{hit} #{blow - hit}"
end

Measured memory_bytes: 8740
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, i;
    vector <pair <int, int>> v;
    vector <int> ans;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x, l;
        
        scanf("%d %d", &x, &l);
        
        v.push_back(make_pair(x, l));
    }
    
    sort(v.begin(), v.end());
    
    for (i = 0; i < v.size(); i++) {
        int x = v[i].first;
        int l = v[i].second;
        
        if (ans.size() == 0 || ans.back() <= x - l) {
            ans.push_back(x + l);
        } else if (ans.back() > x + l) {
            ans.back() = x + l;
        }
    }
    
    printf("%d\n", ans.size());
    
    return 0;
}


Measured memory_bytes: 1908
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int A,B;
  scanf("%d %d",&A,&B);
  if(B%A == 0)printf("%d",A+B);
  else printf("%d",B-A);
  return 0;
}


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

int main() {
  string s,t; cin >> s >> t;
  string ans = "Yes";
  rep(i,s.size()) {
    if (s[i]!=t[i]) {
      ans = "No";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int main()
{
	ios::sync_with_stdio(false);
	int n,m,a;
	n=read();
	m=read();
    a=n%500;
    if(a<=m) puts("Yes");
    else puts("No");
	return 0;
}


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



int main() {
    int N,M;
    vector< vector<int> > root(200001);
    int cnt[100001] = {0};
    int mark[100001] = {0};
    cin >> N >> M;
    rep(i,M) {
        int A,B;
        cin >> A >> B;
        root[A].push_back(B);
        cnt[A]++;
        root[B].push_back(A);
        cnt[B]++;
    }
    
    queue<int> que;
    que.push(1);
    while (!que.empty()) {
        int room = que.front(); // 先頭要素を参照する
        que.pop(); // 先頭要素を削除
        rep(j,cnt[room]){
            if(mark[root[room][j]] == 0){
                mark[root[room][j]] = room;
                que.push(root[room][j]);
            }
        }
    }

    for(int i=2;i<N+1;i++){
        if(mark[i] == 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(int i=2;i<N+1;i++){
        cout << mark[i] << endl;
    }
    
	return 0;
}

Measured memory_bytes: 12920
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }






        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);


            var nm = Reads();
            var n = nm[0];
            var m = nm[1];
            Console.WriteLine(2 * n >= m ? m / 2 : n + (m - 2 * n) / 4);
            
            Console.WriteLine();
         
            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 13396
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

const ll INF = 1LL << 50;

bool judge(const ll v, const dqll& dvs) {
  ll n = (ll)dvs.size();
  if (abs(v) > 8000) return false;
  vvll dp(n + 1, vll(18000, 0));
  dp[0][9000] = 1;
  for (ll i = 1; i <= n; i++) {
    for (ll j = 0; j < 18000; j++) {
      if (dp[i - 1][j] != 0) {
        dp[i][j + dvs[i - 1]] = 1;
        dp[i][j - dvs[i - 1]] = 1;
      }
    }  // j
  }    // i
  return (dp[n][v + 9000] == 1);
}

int main() {
  string s;
  ll x, y;
  cin >> s >> x >> y;

  dqll dxs;
  dqll dys;
  bool isX = true;
  ll cnt = 0;

  ll n = (ll)s.size();
  for (ll i = 0; i < n; i++) {
    if (s[i] == 'T') {
      if (cnt > 0) {
        if (isX)
          dxs.push_back(cnt);
        else
          dys.push_back(cnt);
        cnt = 0;
      }
      isX = !isX;
    } else {
      cnt++;
    }
  }
  if (cnt > 0) {
    if (isX)
      dxs.push_back(cnt);
    else
      dys.push_back(cnt);
  }
  if (s[0] != 'T') {
    x -= dxs[0];
    dxs.pop_front();
  }

  bool jx = judge(x, dxs);
  bool jy = judge(y, dys);

  if (jx && jy)
    puts("Yes");
  else
    puts("No");

  return 0;
}


Measured memory_bytes: 384512
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int ans = INF;
    for(int p = 0; p < 200; p++) {
        int tmp = 0;
        for(int i = 0; i < n; i++) {
            tmp += (x[i] - p) * (x[i] - p);
        }
        chmin(ans, tmp);
    }
    cout << ans << endl;
}

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

int a[200010];
int b[200010];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=2;i<=n;i++) scanf("%d",&a[i]);
    for(int i=2;i<=n;i++) b[a[i]]++;
    for(int i=1;i<=n;i++) printf("%d\n",b[i]);
}

Measured memory_bytes: 3264
#include<iostream>
#include<vector>
#include<iomanip>

int main() {
	int N;
	std::cin >> N;
	std::vector<double> A(N);
	double numerator = 1;
	double denominator = 0;
	for (int i = 0; i < N; i++) {
		std::cin >> A.at(i);
		numerator *= A.at(i);
	}
	for (int i = 0; i < N; i++) {
		denominator += numerator / A.at(i);
	}
	std::cout << std::fixed << std::setprecision(5) << numerator / denominator << std::endl;
	return 0;
}

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

using namespace std;

void solve()
{
  int h, w;
  cin >> h >> w;
  int c[10][10];
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      cin >> c[i][j];
    }
  }
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      for (int k = 0; k < 10; k++) {
        c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      int num;
      cin >> num;
      if (~num) {
        ans += c[num][1];
      }
    }
  }
  cout << ans << "\n";
}

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

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

int main(){
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> T(h);
  for(int i = 0; i < h; ++i)
    cin >> T[i];
  vector<vector<int>> A(h,vector<int>(w,-1));
  int t = 0;
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(T[i][j] != '#') continue;
      ++t;
      A[i][j] = t;
    }
  }
  for(int i = 0; i < h; ++i){
    for(int j = 1; j < w; ++j){
      if(T[i][j] == '#') continue;
      A[i][j] = A[i][j-1];
    }
  }
  for(int i = h-1; i >= 0; --i){
    for(int j = w-2; j >= 0; --j){
      if(A[i][j] >= 0) continue;
      A[i][j] = A[i][j+1];
    }
  }
  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      if(i+1 < h and A[i+1][j] < 0){
        A[i+1][j] = A[i][j];
      }
    }
  }
  for(int i = h-1; i >= 0; --i){
    for(int j = w-1; j >= 0; --j){
      if(i-1 >= 0 and A[i-1][j] < 0){
        A[i-1][j] = A[i][j];
      }
    }
  }
  for(int i = 0; i < h; ++i)
    for(int j = 0; j < w; ++j)
      cout << A[i][j] << (j+1 == w ? '\n' : ' ');
}


Measured memory_bytes: 4112