akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N = 1e6+50;
const int oo = 1e9;

int main(){
	string s;
	cin>>s;
	if(s[0]==s[1]&&s[0]==s[2]){
		puts("Yes");
	}else if(s[1]==s[2]&&s[2]==s[3]){
		puts("Yes");
	}else{
		puts("No");
	}
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!int;
  auto k = readln.chomp.to!int;

  auto ans = int.max;
  foreach (i; 0..1<<n) {
    auto r = 1;
    foreach (j; 0..n)
      if (i.bitTest(j)) r *= 2;
      else              r += k;
    ans = min(ans, r);
  }

  writeln(ans);
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        int H,W;
        cin>>H>>W;
        if(H==0 && W==0)break;
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(i==0 || i==H-1 || j==0 || j==W-1)cout<<"#";
                else cout<<".";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 2996
x1,y1,x2,y2 = [int(i) for i in input().split(' ')]
diff_x = x2-x1
diff_y = y2-y1
x3 = x2-diff_y
y3 = y2+diff_x
x4 = x3-diff_x
y4 = y3-diff_y
print(x3, y3, x4, y4)

Measured memory_bytes: 3060
n=int(input())
s=input()
ss=set(s)
ls={}
csp=0
for j in ss:
  ls[j]=csp
  csp+=1

iis=[]
for i in s:
  iis.append(ls[i])

mod=10**9+7
d=[0 for i in range(csp)]
for i in iis:
  d[i]+=1
c=1
for i in d:
  c=(c*(i+1))%mod

print((c+mod-1)%mod)

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

int main() {
    int n;
    char s[1000];
    char t[1000];
    cin >> n >> s >> t;
    string ans = "";
    rep(i, n){
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
from collections import Counter

def solve():
    MOD = 10**9 + 7
    maxA = 10**6

    N = int(input())
    As = list(map(int, input().split()))

    def getMinPFs(n):
        isPrimes = [False]*2 + [True]*(n-1)
        minPFs = [1] + list(range(1, n+1))
        for d in range(2, int(n**0.5)+1):
            if isPrimes[d]:
                minPFs[d] = d
                for x in range(d*d, n+1, d):
                    isPrimes[x] = False
                    if minPFs[x] == x:
                        minPFs[x] = d
        return minPFs

    minPFs = getMinPFs(maxA)

    def getPrimeFactors(x, minPFs):
        anss = []
        while minPFs[x] > 1:
            anss.append(minPFs[x])
            x //= minPFs[x]
        return anss

    cntP = Counter()
    for A in As:
        PFs = getPrimeFactors(A, minPFs)
        for key, num in Counter(PFs).items():
            cntP[key] = max(cntP[key], num)

    lcmA = 1
    for key, num in cntP.items():
        lcmA *= pow(key, num, MOD)
        lcmA %= MOD

    def getInvs(n, MOD):
        invs = [1] * (n+1)
        for x in range(2, n+1):
            invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
        return invs

    invs = getInvs(maxA, MOD)

    ans = 0
    for A in As:
        ans += lcmA * invs[A]
        ans %= MOD

    print(ans)

solve()


Measured memory_bytes: 59752
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <time.h>
#include <queue>
#include <list>
#include <map>
#include <string.h>
#define sf scanf
#define pf printf
#define lf double
#define ll long long
#define p123 printf("123\n");
#define pn printf("\n");
#define pk printf(" ");
#define p(n) printf("%d",n);
#define pln(n) printf("%d\n",n);
#define s(n) scanf("%d",&n);
#define ss(n) scanf("%s",n);
#define ps(n) printf("%s",n);
#define sld(n) scanf("%lld",&n);
#define pld(n) printf("%lld",n);
#define slf(n) scanf("%lf",&n);
#define plf(n) printf("%lf",n);
#define sc(n) scanf("%c",&n);
#define pc(n) printf("%c",n);
#define gc getchar();
#define re(n,a) memset(n,a,sizeof(n));
#define len(a) strlen(a)
#define LL long long
#define eps 1e-6
using namespace std;
const double pi = 3.1415926535;
/*
https://codeforces.com/contest/1106/problems
https://codeforces.com/contest/1106/submit
*/

    int a,b,c;

int num[450][450];
int vis[450][450];
int temp[450][450];
int temp_vis[450][450];
int main() {
    int n;
    s(n)
    int ma ,mb;
    s(ma) s(mb)
    re(num,0);
    re(vis,0);
    re(temp,0);
    re(temp_vis,0);
    s(a) s(b) s(c)
    vis[a][b] = 1;
    num[a][b] = c;
    //遍历输入所有的药瓶
    for(int i = 1; i < n; i ++){
        s(a) s(b) s(c)
        //遍历所有可能的满足ma和mb的情况
        for(int j = 0; j < 450; j ++){
            for(int k = 0; k < 450; k ++){
                //如果这个被读取过
                if(vis[j][k] == 1){
                    int na = a+j,nb = b+k;
                    temp_vis[na][nb] = 1;
                    temp[na][nb] = num[j][k] + c;
                }
            }
        }
        for(int j = 0; j < 450; j ++){
            for(int k = 0; k < 450; k ++){
                //如果这个被读取过
                if(temp_vis[j][k] == 1){
                    if(vis[j][k] == 1){
                        if(num[j][k] > temp[j][k]){
                            num[j][k] = temp[j][k];
                        }
                    }else{
                        num[j][k] = temp[j][k];
                        vis[j][k] = 1;
                    }
                }
            }
        }
        re(temp,0);
        re(temp_vis,0);
        if(vis[a][b] == 0){
            vis[a][b] = 1;
            num[a][b] = c;
        }else{
            if(num[a][b] > c){
                num[a][b] =c;
            }
        }
    }
    int mini = 100000000;
    for(int j = 0; j < 450; j ++){
        for(int k = 0; k < 450; k ++){
            if(vis[j][k] == 1){
                //p(j) pk p(k) pk p(num[j][k]) pn
                if((ma == j/__gcd(j,k)) && (mb == k/__gcd(j,k))){
                    if(mini > num[j][k]){
                        mini = num[j][k];
                    }
                }
            }
        }
    }
    if(mini == 100000000){
        p(-1) pn
    }else{
        p(mini) pn
    }
    return 0;
}



 //1 1 1 1 2 2 2 3 3 5 6 6 8 8 11


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int main()
{
    using ll = long long;
    ll n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        while(v[i] % 2 == 0)
        {
            ans++;
            v[i] /= 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
    int n;
    cin >> n;
    ll pow10=1, pow9=1, pow8=1; //答えは10^n-2*9^n+8^n
    ll waru = 1000000007;
    for (int i=0; i<n; i++) {
        pow10 = (pow10*10)%waru;
        pow9 = (pow9*9)%waru;
        pow8 = (pow8*8)%waru;
    }
    ll result = (pow10-2*pow9+pow8)%waru;
    while (result < 0) {
        result += waru;
    }
    cout << result << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,int> T;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef multiset<int>::iterator msi;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int N;
int A;
int x[55];
ll dp[55][55][2550];
int main(){
	cin >> N;
	cin >> A;
	for(int i=0;i<N;i++){
		cin >> x[i];
	}
	memset(dp,0,sizeof(dp));
	dp[0][0][0]=1;
	for(int i=0;i<N;i++){
		for(int j=0;j<=i;j++){
			for(int k=0;k<=50*(i+1);k++){
				dp[i+1][j][k]+=dp[i][j][k];
				dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
				//cout << dp[i][j][k] << ' ';
			}
		}
	}
	ll ans = 0ll;
	for(int i=1;i<=N;i++){
		ans += dp[N][i][i*A];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 60544
#include <iostream>
#include<algorithm>
#include<string>
using namespace std;

int main() {
    string S;
    long long K;
    int n = 1;
    cin >> S >> K;
    for ( int i = 0; i < K; i++ ) {
        if (S[i] - '0' != 1 ) {
            n = S[i] - '0';
            break;
        }
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int x,y;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    if(x<y)swap(x,y);
    int i=0;
    while(y){
      x=x%y;
      swap(x,y);
      i++;
    }
    cout<<x<<" "<<i<<endl;
  }
}

Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    cin  >> N;
    int Ntmp = N;
    int x = 0;

    while(Ntmp != 0) {
        x += Ntmp % 10;
        Ntmp /= 10;
    }

    cout << (N % x == 0 ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "cmath"
#include "random"

using namespace std;

const long long int MOD = 1000000007;

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

list<int> Prime(int num) {
	list<int>P;
	for (int i = 5; i <= num; i += 6) {
		bool flag = true;
		for (auto j : P) {
			if (j*j > i) {
				break;
			}
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i);
		flag = true;
		for (auto j : P) {
			if (j*j > i + 2) {
				break;
			}
			if ((i + 2) % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag)P.push_back(i + 2);
	}
	P.push_front(3);
	P.push_front(2);
	return P;
}

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

	auto P = Prime(100000);
	vector<int>sum(100001);
	vector<bool>flag(100001);
	for (auto i : P) {
		flag[i] = true;
	}
	for (int i = 3; i <= 99999; i += 2) {
		if (flag[i] && flag[(i + 1) / 2]) {
			sum[i]++;
		}
	}
	for (int i = 3; i <= 99999; i ++) {
		sum[i] += sum[i - 1];
	}
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> L >> R;
		cout << sum[R] - sum[L - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1408
#37 ABC128D
n,k=map(int,input().split())
v=list(map(int,input().split()))

res=[]
for x in range(min(n,k)+1):
	for a in range(x+1):
		b=x-a
		l=v[:a]
		r=v[n-b:]
		z=[]
		for t in l:
			if t<0:
				z.append(-t)
		for t in r:
			if t<0:
				z.append(-t)
		z.sort()
		z=z[::-1]
		res.append(sum(l)+sum(r)+sum(z[:k-x]))
		#print(l,r,z)
print(max(res))

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

using namespace std;
#define int long long
#define br cout<<"\n"
#define all(V) V.begin(),V.end()
#define rall(V) V.rbegin(),V.rend()
#define umap unordered_map
#define uset unordered_set

typedef vector<int> vi;
typedef vector<vi> vvi;

bool isPwrOf2(int x) { return x && (!(x&(x-1))); }
/*------------------------------------------------*/

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

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    // #ifndef ONLINE_JUDGE
    //     freopen("./input.txt", "r", stdin);
    //     freopen("./output.txt", "w", stdout);
    // #endif
    /*------------------------------------------------*/
    int n,k; cin>>n>>k;
    int cnt=1;
    int arr[n]; for(int i=0;i<n;i++){cin>>arr[i];}
    int rem = n-k;
    if(rem%(k-1)==0){
        cnt+= rem/(k-1);
    }
    else{
        cnt+= 1+ rem/(k-1);
    }
    cout<<cnt;
    /*------------------------------------------------*/
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){
    char s[11];
    scanf("%s",s);
    if((s[5]-'0') == 0 && (s[6] - '0') <= 4){
        printf("Heisei\n");
    }else{
        printf("TBD\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int n,m,x;
  cin >> n>>m>>x;
  int a[n][m];
  int c[n];
  rep(i,n+1){
    cin >> c[i];
    rep(j,m){
      cin >> a[i][j];
    }
  }
      
  int ans=1e9;
  for(int bit=0;bit<(1<<n);bit++){
    vector<int> is(m,0);
    int mini=0;
    rep(i,n){
      if(bit>>i&1){
        mini+=c[i];
        rep(j,m){
          is.at(j)+=a[i][j];
        }
      }
    }
    bool isno=true;
    rep(i,m){
      if(x>is.at(i)){
        isno=false;
      }
    }
    if(isno){
      ans=min(ans,mini);
    }
  }
  if(ans==1e9){
    ans=-1;
  }
  cout <<ans;
}
          

Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    map<string, int> m;
    for (int i = 0; i < N ; i++) {
        cin >> S.at(i);
        m[S.at(i)] += 1;
    }
    int max = 0;
    for(auto i : m)
    {
        if (i.second>max)
        {
            max = i.second;
        }
    }
    for (auto i:m)
    {
        if (i.second == max)
        {
            cout << i.first << endl;
        }
    }
}

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

int main() {
    int N;
    int F = 0;
    cin >> N;
    int N2 = N;
    while (N > 0) {
        F += N % 10;
        N /= 10;
    }
    if (N2 % F == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }



int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));

  printf("%d ",a[n-1]);

  double mx=1e9;
  int k=-1;
  rep(i,n-1){
    if(abs(a[n-1]/2.0-a[i])<mx){
      mx=a[n-1]/2.0-a[i];
      k=a[i];
    }
  }
  printf("%d\n",k );
  return 0;
}


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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T1,typename ...T2>
void dbg(const T1& p1, const T2&...pr){ cerr << p1 << ": "; dbg(pr...);}


int main(){
	string s;
	cin >> s;
	
	int z=s.find("AC");
	cout <<(z==-1? "No":"Yes") <<"\n";
	
	return 0;
}


Measured memory_bytes: 256
using System;

public class Program{
  public static void Main(string[] args){
    var s = Console.ReadLine();
    if(s.Length == 1){
      Console.WriteLine(1);
      return;
    }
    var count = 1;
    string preTemp = s[0].ToString();
    string currentTemp = "";
    for(int i = 1; i < s.Length; i++)
    {
      currentTemp += s[i].ToString();
      if(preTemp != currentTemp)
      {
        preTemp = currentTemp;
        currentTemp = "";
        count++;
      }
    }
    
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 15836
#include <stdio.h>
#include <stdlib.h>

int min(int a[],int n){
  int i,min;
  min = a[0];
  for(i = 1; i < n; i++){
    if(a[i] < min){
      min = a[i];
    }
  }
  return min;
}

int main(){
  
  int A1,A2,A3,ans;
  scanf("%d%d%d",&A1,&A2,&A3);
  
  int a[6];
  a[0] = abs(A2 - A1) + abs(A3 - A2);
  a[1] = abs(A3 - A1) + abs(A2 - A3);
  a[2] = abs(A1 - A2) + abs(A3 - A1);
  a[3] = abs(A3 - A2) + abs(A1 - A3);
  a[4] = abs(A1 - A3) + abs(A2 - A3);
  a[5] = abs(A2 - A3) + abs(A1 - A2);
  
  ans = min(a,6);
  
  printf("%d",ans);
  
  return 0;

}

Measured memory_bytes: 128
void main() {
	auto arr = generate_prime_list(100000);
	auto c = new int[](100001);
	foreach(i; iota(3, 100000, 2)) {
		if(!arr[i] && !arr[(i+1)/2]) c[i]++;
	}
	foreach(i; 3..100001) c[i] += c[i-1];
	auto Q = ri;
	foreach(_; 0..Q) {
		auto ip = readAs!(int[]), l = ip[0], r = ip[1];
		writeln(c[r]-c[l-1]);
	}
}
bool[] generate_prime_list(T)(T N) if(isIntegral!T) {
	bool[] res = new bool[](N+1);
	foreach(i; 2..N+1) {
		if(!res[i]) for(T j = i + i; j <= N; j += i) {
			res[j] = true;
		}
	}
	return res;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 2172
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a=0;int b=0;
    int d[114]={};
    int x=0;
    for(int i=0;i<n;i++){
        if(s[i]=='('){
            a++;
        }else{
            b++;
        }
        d[i]=a-b;
        x=min(x,d[i]);
    }
    for(int i=0;i<-x;i++){
        cout<<"(";
    }
    cout<<s;
    for(int i=0;i<d[n-1]-x;i++){
        cout<<")";
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())

int main() {
	int K, S;
	cin >> K >> S;
	int ans = 0;
	for (int x = 0;x <= K;++x) {
		for (int y = 0;y <= K;++y) {
			int z = S - x - y;
			if (0 <= z && z <= K) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
manzoku = 0

for i in range(len(A)):
  manzoku += B[A[i] - 1]
  if i != 0:
    j = i - 1
    if A[j] + 1 == A[i]:
      manzoku += C[A[j] - 1]
      
print(manzoku)

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll c[3][3];
    ll sum=0;
    rep(i,3)rep(j,3){
        cin>>c[i][j];
        sum+=c[i][j];
    }
    ll dia=0;
    rep(i,3) dia+=c[i][i];
    if(sum==3*dia) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3604
use whiteread::parse_line;

fn calc(n: usize, dp: &mut Vec<bool>, price: &[usize; 6]) -> bool {
    if !dp[n] && n > 105 {
        dp[n] |= match n % 5 {
            x @ 1..=4 => calc(n - price[x], dp, price),
            _ => calc(n - price[0], dp, price) | calc(n - price[5], dp, price),
        };
    }
    dp[n]
}

fn main() {
    let x: usize = parse_line().unwrap();
    let price: [usize; 6] = [100, 101, 102, 103, 104, 105];
    let mut dp: Vec<bool> = vec![false; x + 1];

    dp[0] = true;
    for &p in &price {
        let mut idx = 0;
        while idx <= x {
            dp[idx] = true;
            idx += p;
        }
    }

    calc(x, &mut dp, &price);
    if dp[x] {
        println!("1");
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2188
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	
	
	public static void main(String[] args) {
		StringBuffer str = new StringBuffer(sc.next());
	boolean a=true;
	int ans=0;
	int aaa[]=new int[2];
	for(int i=0;i<str.length();i++) {
		aaa[str.charAt(i)-48]++;
	}
	if(aaa[0]>=aaa[1]) {
		ans=aaa[1]*2;
	}else {
		ans=aaa[0]*2;
	}
	p(ans);
 }
}


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

using namespace std;

using ll = long long;
using ld = long double;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int a, b;
    cin >> a >> b;
    if (a + b == 15) cout << "+\n";
    else if (a * b == 15) cout << "*\n";
    else cout << "x\n";

    return 0;
}


Measured memory_bytes: 256
#AT2084
s = list(input())

r = 'No'
a = []
for i in s:
    if i == 'C' or i == 'F':
        a.append(i)
for i in range(len(a)-1):
    if a[i] == 'C' and a[i+1] == 'F':
        r = 'Yes'
        break
print(r)


Measured memory_bytes: 2940
<?php
  $n = intval(fgets(STDIN));

  $data = explode(" ", trim(fgets(STDIN)));
  sort($data);

  $max = $data[$n-1];
  $flags = [];
  for($i=0; $i<$n; $i++){
    if($i>0 && $data[$i-1]==$data[$i]){
      //同じ数字2回目なので、自身もフラグオン
      $flags[$data[$i]] = true;
    }else{
      $j = 2;  //自身を含まないように2倍からスタート
      while($data[$i]*$j<=$max){
        $idx = $data[$i]*$j;
        
        $flags[$idx] = true;
        //echo $idx." is true\n";
        /*
        if(isset($flags[$idx])){
          //チェック済みなのでブレーク
          break;
        }else{
          $flags[$idx] = true;
          echo $idx." is true\n";
        }
        */

        $j++;
      }
    }
  }
  
  $count = 0;
  for($i=0; $i<$n; $i++){
    if(!isset($flags[$data[$i]])){
      $count++;
    }
  }
  echo $count."\n";


Measured memory_bytes: 66480
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

#define MOD 1000000007

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; ++i)
		cin >> a[i];

	ll ans = 1;
	int l=0;
	for(int i=0; i<n; ++i)
	{
		int maxk = (a[i])/2;
		int need_remove = l + max(0,i-maxk-l);
		need_remove = max(need_remove, l);
		l = need_remove;
		int k = (i+1-l);
		if(a[i]%2==0 && i-maxk-l == 0)
			++l;
		//print3(k, l, i-maxk)
		ans = (ans * k) % MOD;
	}
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>   
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(ll i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
//nCr mod m
#define MOD 1000000007
#define M 4000010
vector<ll> fact,inv;
bool h=false;
ll A,B;
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
	inv=vector<ll>(M);
	rep(i,M)inv[i]=powmod(fact[i],MOD-2,MOD);
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 0;//??????
	ll out=fact[n]*inv[r]%m*inv[n-r]%m;
	return out;
}
void f(ll n,ll r,ll m=MOD){
	if(n<0||r<0||n<r){
		A=0;
		return;
	}
	(A*=fact[n])%=MOD;
	(B*=fact[r]*fact[n-r]%MOD)%=MOD;
	return;
}
int main(){
	ll a,b,c,d,e;
	while(cin>>a>>b>>c>>d>>e,a+b+c+d+e){
		ll out=0;
		ll aa=nCr(a+b+c,a),bb=nCr(b+c,b);
		rep(s,d+1){
			A=B=1;
			ll t=e-d+s;
			if(t<0||t>e)continue;
			ll w=1;
			if(s||a){
				f(s-1,a-1);
				(A*=aa)%=MOD;
			}
			if(t||b){
				f(t-1,b-1);
				(A*=bb)%=MOD;
			}
			f(d-s+a+b+c-1,a+b+c-1);
			(out+=A*powmod(B,MOD-2,MOD))%=MOD;
		}
		cout<<out<<endl;
	}
}








Measured memory_bytes: 65312
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

class Main{

    static int dfs(int v,int pare){
        int res = 0;
        int zero=0;
        for(int u:G[v]){
            if(u==pare)continue;
            int k = dfs(u,v);
            if(k==0)++zero;
            else res+=k;
        }
        if(zero>0)--zero;
        return res+zero;
    }

    static List<Integer>[] G;
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        G = new ArrayList[N];
        for(int i=0;i<N;++i)G[i] = new ArrayList<>();
        for(int i=0;i<N-1;++i){
            int a = scan.nextInt();
            int b = scan.nextInt();
            G[a].add(b);
            G[b].add(a);
        }
        int root=0;
        for(int i=0;i<N;++i){
            if(G[root].size()<G[i].size())root = i;
        }
        System.out.println(Math.max(1,dfs(root,-1)));

    }
}

Measured memory_bytes: 104444
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n;
		int na;
		int cnt = 0;
		n = sc.nextInt();
		for(int i = 0; i < n; i++){
			na = sc.nextInt();
			while(na%2==0){
				na/=2;
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

#define D  double
typedef pair<D,int>T;
int N;
int X[1111],Y[1111],R[1111];
D dist[1111];
D INF=1e15;
D EPS=1e-12;

int table2[1111][1111];
D table[1111][1111];

signed main(){

    cin>>X[0]>>Y[0]>>X[1]>>Y[1];
    cin>>N;
    rep(i,N)cin>>X[i+2]>>Y[i+2]>>R[i+2];
    N+=2;

    rep(i,N)rep(j,N){
        table2[i][j]=(X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]);
        table[i][j]=sqrt(1.0*table2[i][j]);
    }

    fill_n(dist,1111,INF);
    dist[0]=0;
    priority_queue<T,vector<T>,greater<T>>que;
    que.push(make_pair(0,0));
    while(que.size()){
        D d;
        int idx;
        tie(d,idx)=que.top();
        que.pop();
        if(dist[idx]<d)continue;
        rep(i,N){
            int foo=table2[i][idx];
            int bar=R[i]+R[idx];
            D cost;
            if(foo<=bar*bar)cost=0.0;
            else cost=table[i][idx]-bar;
            if(dist[i]>cost+dist[idx]){
                dist[i]=cost+dist[idx];
                que.push(T(dist[i],i));
            }
        }
    }
    printf("%.20f\n",dist[1]);
    return 0;
}


Measured memory_bytes: 21872
ss=raw_input().split()
w=int(ss[0])
h=int(ss[1])

a=[]
b=[]

for i in xrange(w):
    p=input()
    a.append(p)
for i in range(h):
    p=input()
    b.append(p)

a.sort()
b.sort()

h1=0
h2=0
res=0

while h1 < w and h2 < h:
    if a[h1]<b[h2]:
        res += a[h1] * (h - h2 + 1)
        h1 += 1
    else:
        res += b[h2] * (w - h1 + 1)
        h2 += 1
while (h1<w):
    res += a[h1]
    h1 += 1
while (h2<h):
    res += b[h2]
    h2 += 1
print res

Measured memory_bytes: 12292
//#pragma GCC optimize(3)
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<utility>
#include<iterator>
#include<iomanip>
using namespace std;
#define lowbit(x) x&(-x)
typedef long long ll;
typedef long double lb;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const int maxn = 1000;
int read();
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m,day,reward;
    cin>>n>>m;
    vector<vector<int>> v(m+1);
    for(int i = 0; i < n; i++ )
    {
        cin>>day>>reward;
        if(day<=m)
        {
            v[day].push_back(reward);
        }
    }
    priority_queue<int> pq;
    ll ans = 0;
    for(int i = 1; i <= m; i++ )
    {
        for(int j = 0; j < (int)(v[i].size()); j++)
        {
            int k = v[i][j];
            pq.push(k);
        }
        if(!pq.empty())
        {
            ans+=(int)pq.top();
            pq.pop();
        }
    }
    cout<<ans<<endl;

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


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  int k, x;
  std::cin >> k >> x;
  for (int i = x - k + 1; i < x + k; i++)
    print(i, 2);
}


Measured memory_bytes: 256
// Author : ps41

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll M = 1e9 + 7, N = 1e6 + 5;
ll f[N];

ll binexpmod(ll a, ll b, ll m)
{
    a %= m;
    ll res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll h, w, a, b;
    cin >> h >> w >> a >> b;    
    f[0] = 1;
    for (ll i = 1; i < N; i++) f[i] = (i * f[i - 1]) % M;
    ll total = (f[h + w - 2] * binexpmod((f[h - 1] * f[w - 1]) % M, M - 2, M)) % M; 
    ll extra = 0;
    vector<ll> l1, l2;
    for (ll i = 1; i <= b; i++)
    {
        ll down = h - a;
        ll right = i - 1;
        ll tmp1 = (f[down + right] * binexpmod((f[down] * f[right]) % M, M - 2, M)) % M;
        ll down1 = a - 1;
        ll right1 = w - i;
        ll tmp2 = (f[down1 + right1] * binexpmod((f[down1] * f[right1]) % M, M - 2, M)) % M;
        extra = (extra + tmp1 * tmp2) % M;
        l1.push_back(tmp1);
        l2.push_back(tmp2);
    }
    ll ans = (total - extra + M) % M;
    for (ll i = 0; i < l1.size() - 1; i++) ans = (ans + l1[i] * l2[i + 1]) % M;
    cout << ans;
}

Measured memory_bytes: 12760
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
typedef long long ll;
typedef long double ld;
int main(){
    ll h,w,n;cin>>h>>w>>n;
    vector<ll> a(n);
    REP(i,n){
        cin>>a[i];
    }
    vector<ll> v1;
    vector<vector<ll>> v2(h,vector<ll>(w));
    REP(i,n){
        ll num=a[i];
        REP(j,num){
            v1.push_back(i+1);
        }
    }
    ll size=SIZE(v1), b=0;
    
        REP(i,h){
            REP(j,w){
                v2[i][j]=v1[b];
                b++;
            }
            if(i%2==1){
                sort(ALL(v2[i]),greater<>());
            }
        }
    
    REP(i,h){
        REP(j,w){
            cout<<v2[i][j];
            if(j==w-1){
                cout<<endl;
            }else{
                cout<<" ";
            }
        }
    }
    return 0;
}


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

namespace abc127
{
    class B
    {
        static void Main(string[] args)
        {
            var input = Input.IntArray();
            int r = input[0];
            int D = input[1];
            int x2000 = input[2];

            int before = x2000;
            int after;
            for (int i = 0; i < 10; i++)
            {
                after = r * before - D;
                Console.WriteLine(after);
                before = after;
            }

        }

        /** Input Class */
        internal static class Input
        {
            /** input int */
            public static int Int() => int.Parse(Console.ReadLine());

            /** input str */
            public static string Str() => Console.ReadLine();

            /** input array of int */
            public static int[] IntArray() => Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            /** input array of string */
            public static string[] StrArray() => Input.Str().Split(' ');

            /** input array of char */
            public static char[] charArray() => Input.Str().ToCharArray();
        }
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include<queue>
#include<algorithm>

using namespace std;

void sink(int i, int j,int w,int h, int** field);

int main() {
	int w, h;
	int** field;
	while (1) {
		cin >> w >> h;
		if (w == 0)break;
		field = new int* [h];
		for (int i = 0;i < h;i++) {
			field[i] = new int[w];
			for (int j = 0;j < w;j++) {
				cin >> field[i][j];
			}
		}
		int cnt = 0;
		for (int i = 0;i < h;i++) {
			for (int j = 0;j < w;j++) {
				if (field[i][j]) {
					cnt++;
					sink(i, j,w,h, field);
				}
			}
		}
		cout << cnt << endl;
	}
}

void sink(int i, int j,int w,int h, int** field) {
	field[i][j] = 0;
	if (i > 0) {
		if (field[i - 1][j])sink(i - 1, j, w, h, field);
	}
	if (i < h-1) {
		if (field[i + 1][j])sink(i + 1, j, w, h, field);
	}
	if (j > 0) {
		if (field[i][j-1])sink(i , j-1, w, h, field);
	}
	if (j < w-1) {
		if (field[i][j+1])sink(i , j+1, w, h, field);
	}
	if (i > 0 && j > 0) {
		if (field[i - 1][j - 1])sink(i - 1, j - 1, w, h, field);
	}
	if (i > 0 && j < w - 1) {
		if (field[i - 1][j + 1])sink(i - 1, j + 1, w, h, field);
	}
	if (i < h-1 && j > 0) {
		if (field[i + 1][j - 1])sink(i + 1, j - 1, w, h, field);
	}
	if (i < h-1 && j < w-1) {
		if (field[i + 1][j + 1])sink(i + 1, j + 1, w, h, field);
	}
}


Measured memory_bytes: 3392
N,M,C=map(int, input().split())
# N:Aのソースコード(配列)数
# M:AとBの配列の中身の数
# C:計算で利用

B=list(map(int,input().split()))
A=[]
for i in range(N):
  a=list(map(int,input().split()))
  A.append(a)
    
x=0
for i in range(N):
  ans=0
  for j in range(M):
     ans+=A[i][j]*B[j]
  if ans+C>0:
     x+=1


print(x)


Measured memory_bytes: 3064
n=int(input())
x=[]
l=[]
for i in range(n):
    a,b=map(int,input().split())
    x.append(a)
    l.append(b)

ans = [[0 for i in range(2)] for j in range(n)]
for i in range(n):
    ans[i][1]=(x[i]+l[i])
    ans[i][0]=max(0,x[i]-l[i])
ans.sort()
count=1
j=0
for i in range(n-1):
    
    if ans[j][1]<=ans[i+1][0] :
        count+=1
        j=i+1
    else:
        if ans[j][1]>ans[i+1][1]:
           j=i+1  
print(count)


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

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

K = get_int

half = K / 2
odd = K % 2

puts (half + odd) * half


Measured memory_bytes: 14340
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)

using namespace std;
using p = pair<long long, int>;
#define INF 100000000
using Graph = vector<vector<int> >;

int main(){
	int k;
	int a,b;
	cin >> k >> a >> b;
	bool can = false;
	for(int i = a; i <= b; i++){
		if(i % k == 0){
			can = true;
			break;
		}	
	}
	if(can) cout << "OK" << endl;
	else cout << "NG" << endl;
}
	
	


Measured memory_bytes: 3584
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")

Measured memory_bytes: 7604
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    a = [0] + list(map(int, input().split()))
    # visited[i]:町iにvisited[i]回目の遷移で到達
    visited = [0]*(n+1)
    step = 0
    i = 1

    while k:
        i = a[i]
        step += 1
        k -= 1
        if visited[i] != 0:
            k = k % (step - visited[i])
            for _ in range(k):
                i = a[i]
            print(i)
            break
        visited[i] = step
    else:
        print(i)

if __name__ == '__main__':
    main()

Measured memory_bytes: 90172
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val s = br.readLine()!!
    val t = br.readLine()!!

    val sSet = s.toSet()
    if (sSet.union(t.toSet()).size > sSet.size) {
        out.println(-1)
        return
    }

    val charOccurenceList = Array('z' - 'a' + 1) { mutableListOf<Int>() }
    for ((i, c) in s.withIndex()) {
        charOccurenceList[c - 'a'].add(i + 1)
    }

    var ans = 0L
    var preIndex = 0
    for (c in t) {
        var left = -1
        var right = charOccurenceList[c - 'a'].size
        while (right - left > 1) {
            val mid = (left + right) / 2
            if (preIndex < charOccurenceList[c - 'a'][mid]) {
                right = mid
            } else {
                left = mid
            }
        }

        if (right !in charOccurenceList[c - 'a'].indices) {
            val nextIndex = charOccurenceList[c - 'a'][0]
            ans += s.length - preIndex + nextIndex
            preIndex = nextIndex
        } else {
            val nextIndex = charOccurenceList[c - 'a'][right]
            ans += nextIndex - preIndex
            preIndex = nextIndex
        }
    }

    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 46088
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(readline())
ans = []
cnt = 0
for i in range(1, n + 2):
    cnt += i
    ans.append(i)
    if cnt > n:
        ans.remove(cnt - n)
        break
print('\n'.join(map(str, ans)))


Measured memory_bytes: 3444
N = int(input())
a = [int(i) for i in input().split(' ')]
numbers = []
numbers.append(a[0])
for i in a:
    if i != numbers[0] and len(numbers) == 1:
        numbers.append(i)
    if i != numbers[0] and i != numbers[1]:
        numbers.append(i)
        break

if len(numbers) == 1:
    if numbers[0] == 0:
        print('Yes')
        exit(0)
    else:
        print('No')
        exit(0)

if len(numbers) == 3:
    if a.count(numbers[0]) != a.count(numbers[1]):
        print('No')
        exit(0)
    if a.count(numbers[0]) != a.count(numbers[2]):
        print('No')
        exit(0)
    if len(a) != a.count(numbers[0])+a.count(numbers[1])+a.count(numbers[2]):
        print('No')
        exit(0)

    if numbers[0]^numbers[1] == numbers[2]:
        print('Yes')
        exit(0)
    elif numbers[0]^numbers[2] == numbers[1]:
        print('Yes')
        exit(0)
    elif numbers[1]^numbers[2] == numbers[0]:
        print('Yes')
        exit(0)
    else:
        print('No')
else:
    if len(a) != a.count(numbers[0])+a.count(numbers[1]):
        print('No')
        exit(0)
    if numbers[0] == 0 or numbers[1] == 0:
        if numbers[0] == 0:
            if a.count(numbers[1]) != 2*a.count(numbers[0]):
                print('No')
                exit(0)
        elif a.count(numbers[0]) != 2*a.count(numbers[1]):
            print('No')
            exit(0)
        print('Yes')
        exit(0)
    else:
        print('No')
        exit(0)   

Measured memory_bytes: 14228
n, m = map(int, input().split())
lst = []
for i in range(m):
    ai, bi = map(int, input().split())
    ai, bi = ai-1, bi-1
    lst.append([ai, bi])

lst.sort(key=lambda x: x[1])

ans = 1
kiru = lst[0][1]
for i in range(1, m):
    if lst[i][0] >= kiru:
        ans += 1
        kiru = lst[i][1]

print(ans)

Measured memory_bytes: 63520
n = int(input())
shogen = []
for i in range(n):
    shogen.append({})
for i in range(n):
    for k in range(int(input())):
      x,y = map(int,input().split())
      shogen[i][x] = y 
MaxHonest = 0
for i in range(2**n):
    num = format(i,'b').zfill(n)
    lst = list(map(int,list(num)))
    flag = True
    for k in range(n):
        if lst[k] == 1:
            for l in shogen[k]:
                if shogen[k][l] != lst[l-1]:
                    flag = False
    if flag:
        MaxHonest = max(MaxHonest,sum(lst))
print(MaxHonest)


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <cmath>

using namespace std;

const int M = 1e9 + 7;

long long fp(int a, int p){
    if(p==0)
        return 1LL;
     long long h = fp(a, p/2);
     h *= h;
     h %= M;

     if(p % 2){
        h = h * a % M;
     }

     return h;
}


int main(){
    int x, y;
    cin >>x >> y;

    if(2*x - y >= 0 && (x*2-y)%3==0 && 2*y - x >= 0 && (y*2-x)%3==0){
        int a = (2*y - x) / 3;
        int b = (2*x - y) / 3;

        if(a>b){
            int tmp = a;
            a = b;
            b = tmp;
        }

        long long ans = 1;
        for(int i=b+1;i<=a+b;i++){
            ans *= i;
            ans %= M;
        }

        for(int i=2;i<=a;i++){
            ans = ans * fp(i, M-2) % M;
        }

        cout << ans<<endl;

    }
    else{
        cout << 0<<endl;
    }
}




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

#define SIZE 105

int N;
char S[SIZE];
int max=0;

int main(){
#ifdef DEBUG
	printf("DEBUGGING ON\n");
#endif
	scanf("%d", &N);
	scanf("%s", S);
	/* check how many letters are common in two parts if we divide it after i */
	for (int i=0;i<N-1;++i){
		int coincidence['z'-'a'+1]={0};
		for (int j=0;j<=i;++j){
			for(int k=i+1;k<N;++k){
				if (S[j]==S[k]){
					coincidence[S[j]-'a']=1;
					break;
				}
			}
		}
		int a=0;
		for (int l='a'-'a';l<='z'-'a';++l){
			a+=coincidence[l];
		}
		max=max<a?a:max;
	}
	printf("%d\n",max);
	return (0);
}

Measured memory_bytes: 128