akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10, mod = 1e9 + 7;

int dp[maxn][15];
//dp[i][j]到第i位，当前余数是j的数量，枚举第i - 1位的余数和第i位的选择转移
int main()
{
    ios::sync_with_stdio(0); cin.tie(0);

    string s;
    cin >> s;
    if (s[0] == '?'){
        for (int i = 0; i <= 9; ++i) dp[0][i] = 1;
    }else dp[0][s[0] - '0'] = 1;

    for (int i = 1; i < s.size(); ++i){
        if (s[i] == '?'){
            for (int j = 0; j < 13; ++j){
                for (int k = 0; k <= 9; ++k){
                    dp[i][(j * 10 + k) % 13] += dp[i - 1][j];
                    dp[i][(j * 10 + k) % 13] %= mod;
                }
            }
        }else{
            for (int j = 0; j < 13; ++j){
                dp[i][(j * 10 + s[i] - '0') % 13] += dp[i - 1][j];
                dp[i][(j * 10 + s[i] - '0') % 13] %= mod;
            }
        }
    }

    cout << dp[s.size() - 1][5] << endl;
    return 0;
}


Measured memory_bytes: 6352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        //コード
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();

    	int[] member = new int[N];


    	for(int i=0;i<N;i++) {
    		member[i] = 0;
    	}

    	for(int i=0;i<N-1;i++) {
    		int joshiNumber = sc.nextInt();
    		member[joshiNumber-1] = member[joshiNumber-1] + 1;
    	}
    	for(int i=0;i<N;i++) {
    		System.out.println(member[i]);
    	}

    }
}

Measured memory_bytes: 57836
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
const int maxn=5e5+10;
int n;
map<int,int>a;
void res(){
    int ans=0;
    int up=sqrt(n);
    for(int i=1;i<=up;++i)
    for(int j=1;j<=up;++j)
    for(int k=1;k<=up;++k)
    a[i*i+j*j+k*k+i*j+j*k+k*i]++;

}
main(){
    cin>>n;
    res();
    for(int i=1;i<=n;++i)cout<<a[i]<<endl;
}


Measured memory_bytes: 5972
import sys
# N = int(input())
X, Y = [int(i) for i in input().split()]
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a_3 = 2 * Y - X
b_3 = 2 * X - Y
if a_3 % 3 != 0 or b_3 % 3 != 0 or a_3 < 0 or b_3 < 0:
    print(0)
    sys.exit(0)
a = a_3//3
b = b_3//3
print(cmb(a+b,a,mod))


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

int main(){
  string S;
  cin >> S;
  sort(S.begin(),S.end());
  if(S.at(0) !=S.at(1)){
    cout << "No" << endl;
    return 0;
  }else if(S.at(2) !=S.at(3)){
    cout << "No" << endl;
    return 0;
  }else if(S.at(1) == S.at(2)){
    cout << "No" << endl;
    return 0;
  }else{
    cout << "Yes" << endl;
    return 0;
  }
}

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

int main(int argc, char const *argv[])
{
  int a, b, c;
  cin >> a >> b >> c;
  if(a+b==c || b+c==a || c+a==b)
    cout << "Yes" << flush;
  else
    cout << "No" << flush;
  return 0;
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
/*
   typedef __int128_t Int;
   std::ostream &operator<<(std::ostream &dest, __int128_t value) {
   std::ostream::sentry s(dest);
   if (s) {
   __uint128_t tmp = value < 0 ? -value : value;
   char buffer[128];
   char *d = std::end(buffer);
   do {
   --d;
 *d = "0123456789"[tmp % 10];
 tmp /= 10;
 } while (tmp != 0);
 if (value < 0) {
 --d;
 *d = '-';
 }
 int len = std::end(buffer) - d;
 if (dest.rdbuf()->sputn(d, len) != len) {
 dest.setstate(std::ios_base::badbit);
 }
 }
 return dest;
 }

 __int128 parse(string &s) {
 __int128 ret = 0;
 for (int i = 0; i < s.length(); i++)
 if ('0' <= s[i] && s[i] <= '9')
 ret = 10 * ret + s[i] - '0';
 return ret;
 }
 */

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main(signed argc, char *argv[]) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N; cin >> N;
  vector<int> p(N); rep(i, 0, N){ cin >> p[i]; }
  sort(all(p));
  cout<<accumulate(all(p),0)-p.back()/2<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    string S;
    cin >> S;
    int c1=0;
    int c2=0;
    for(int i=0; i<S.length(); i++){
        if(S[i] == '0')
            c1++;
        else
            c2++;
    }
    cout << 2 * min(c1, c2) << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[15];
int x[15][15], y[15][15];

int main() {
	int i, j, k;
	
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		rep(j, a[i]) {
			cin >> x[i][j] >> y[i][j];
			x[i][j]--;
		}
	}
	
	int ans = 0;
	rep(i, (1 << n)) {
		bool isright[15];
		rep(j, n) {
			if ((i >> j) & 1) isright[j] = true;
			else isright[j] = false;
		}
		
		rep(j, n) {
			if (isright[j] == false) continue;
			rep(k, a[j]) {
				int id = x[j][k];
				if (y[j][k] == 0 && isright[id] == true) break;
				if (y[j][k] == 1 && isright[id] == false) break;
			}
			if (k < a[j]) break;
		}
		if (j < n) continue;
		
		int cnt = 0;
		rep(j, n) cnt += isright[j];
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  int sum = 0;
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      sum += d.at(i) * d.at(j);
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string s;
int k;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s >> k;
  int n = sz(s);
  FOR(i, 0, n){
    int r = ('{'-s[i])%26;
    if(k >= r){
      s[i] = 'a';
      k -= r;
    }
  }
  s[n-1] = char('a'+(s[n-1]-'a'+k%26)%26);
  cout << s << endl;
}

Measured memory_bytes: 592
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
    Mbak Seulgi Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
const int mod = 998244353;
ll dp[200200], arr[200200];
map<int,int> mp;
int main()
{
    int n,i,j,k,x,y,ans,curr,temp,m;
    int tc;
    ll a;
    cin >> a >> x >> m;
    ll seulgi = x;
    ll now = x;
    i = 1;
    mp[now] = i;
    dp[i] = now;
    a--;
    while(a--) {
        now *= now;
        now %= m;
        i++;
        dp[i] = now;
        seulgi += now;
        if(mp[now] > 0) {
            int last = mp[now] + 1;
            int cnt = 1;
            for(j=last;j<=i;j++) {
                arr[cnt] = arr[cnt-1] + dp[j];
                cnt++;
            }
            cnt--;
            ll bagi = a / cnt;
            seulgi += bagi * arr[cnt];
            a %= cnt;
            seulgi += arr[a];
            cout << seulgi << endl;
            return 0;
        }
        mp[now] = i;
    }
    cout << seulgi << endl;
    return 0;
}


Measured memory_bytes: 6724
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

using pii = pair<int, int>;

int main(){
    int N, M;
    cin >> N >> M;
    
    vector<pii> AB(N);
    for(int i = 0; i < N; ++i){
        cin >> AB[i].first >> AB[i].second;
    }

    sort(begin(AB), end(AB));

    priority_queue<pii, vector<pii>, function<bool(pii, pii)>> q(
        [](pair<int, int> a, pair<int, int> b){
            return (a.second == b.second) ? (a.first > b.first) : (a.second < b.second);
        }
    );

    int d = 1;
    int j = 0;
    for(int i = 0; i < N; ++i){
        if(AB[i].first != d){
            break;
        }else{
            q.emplace(AB[i]);
            ++j;
        }
    }

    int ans = 0;
    while(d <= M){
        if(!q.empty()){
            ans += q.top().second;
            q.pop();
        }
        
        ++d;
        for(int i = j; i < N; ++i){
            if(AB[i].first != d){
                break;
            }else{
                q.emplace(AB[i]);
                ++j;
            }
        }
    }

    cout << ans << endl;
}

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

class Program
{
    static void Main(string[] args)
    {

        // 文字列の入力
        string s = Console.ReadLine();
        int n = s.Length;
        string ans = "No";

        //回文判定
        if (s.Reverse().SequenceEqual(s))
        {
            string saisyo = s.Substring(0, (n - 1) / 2);
            string saigo = s.Substring(((n + 3) / 2) - 1);

            if(saigo.Reverse().SequenceEqual(saigo) && saisyo.Reverse().SequenceEqual(saisyo))
            {
                ans = "Yes";
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
	int i;
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size()) cout<<"GREATER";
	if(a.size()<b.size()) cout<<"LESS";
	if(a.size()==b.size()){
		for(i=0;i<a.size();i++){
			if(a[i]>b[i]){
				cout<<"GREATER";
				return 0;
			} 
			if(a[i]<b[i]){
				cout<<"LESS";
				return 0;
			} 
		}
		cout<<"EQUAL";
	}
	return 0;
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

n = int(input())
y = (n//15)*200
x = n*800
print(x-y)

Measured memory_bytes: 3316
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cctype>
#include <cstdio>
#include <vector>
using namespace std;

int main()
{
    int r, g, b;
    cin >> r >> g >> b;
    int tmp=g*10+b;
    if(tmp%4==0){
        cout << "YES";
    }else{
        cout << "NO";
    }
    
    return 0;
}

Measured memory_bytes: 256
import numpy as np

N, _W = map(int, input().split())

W, V = [0], [0]
for _ in range(N):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
# dp[i][sum_w] := i-1 番目までの品物から重さが sum_w を超えないように選んだときの、価値の総和の最大値
# dp[i + 1][sum_w], dp[i][sum_w - w[i]] + v[i]

dp = np.array([0] * (_W + 1))
for i in range(1, N + 1):
    w, v = W[i], V[i]
    np.maximum(dp[:-w] + v, dp[w:], out=dp[w:])
    # print(dp)

# print('dp')
print(dp.max())


Measured memory_bytes: 14028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N;
  cin>>N;
  vector<ll> F(N+1, 0);
  for(ll x=1; x<=100; x++){
    for(ll y=1; y<=100; y++){
      for(ll z=1; z<=100; z++){
        ll Sum=x*x+y*y+z*z+x*y+y*z+z*x;
        if(Sum<=N){
          F[Sum]++;
        }
      }
    }
  }
  for(ll i=1; i<=N; i++){
    cout<<F[i]<<endl;
  }
} 

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	int a[25],b[25],c[25];
	int count=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		cin>>b[i];
	}
	for(int i=1;i<=n-1;i++){
		cin>>c[i];
		c[n]=0;
	}

	for(int i=1;i<=n;i++){
			count+=b[a[i]];
			if(i!=1 && a[i-1]==(a[i]-1)){
				count+=c[a[i-1]];
			}

		}
	

	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
import collections


n, a, b = map(int, input().split())
s = collections.deque(input())
total = 0
oversea = 0
while s:
    x = s.popleft()
    if x == "c":
        print("No")
    elif x == "a":
        if total < a + b:
            total += 1
            print("Yes")
        else:
            print("No")
    elif x == "b":
        if total >= a + b:
            print("No")
        elif oversea >= b:
            print("No")
        else:
            total += 1
            oversea += 1
            print("Yes")


Measured memory_bytes: 5268
#include <stdio.h>
#include <iostream>

using namespace std;

int n;
int data[11];
int l,r;
bool fla;

void solve(){
    scanf("%d",&n);
    while(n--){

        for(int i = 1; i <= 10; i++){
            scanf("%d",&data[i]);
        }

        l = 0;
        r = 0;
        fla = true;

        for(int i = 1; i <= 10; i++){
            if(data[i] > l && data[i] > r){
                if(l > r){
                    l = data[i];
                }else{
                    r = data[i];
                }
            }else if(data[i] > l && data[i] < r){
                l = data[i];
            }else if(data[i] > r && data[i] < l){
                r = data[i];
            }else{
                fla = false;
                break;
            }
        }

        if(fla){
            cout << "YES" << endl;
        }else{
            cout << "NO" << endl;
        }

    }
}

int main(void){

    solve();

    return 0;
}


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

//N:1,W:2,E:3,S:4
void RotateDice(int *a, int n)
{
    int c = a[0];
    a[0] = a[n];
    a[n] = a[5];
    a[5] = a[5 - n];
    a[5 - n] = c;
}
int main()
{
    int a[6], b[6];
    for (int i = 0; i < 6; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < 6; i++)
    {
        cin >> b[i];
    }


    for (int j = 0; j < 4; j++)
    {
        if (a[1] == b[1])
        {
            break;
        }
        RotateDice(a, 1);
    }

    if (a[1] != b[1])
    {
        RotateDice(a, 3);
        for (int j = 0; j < 4; j++)
        {
            if (a[1] == b[1])
            {
                break;
            }
            RotateDice(a, 1);
        }
    }

    for (int j = 0; j < 4; j++)
    {
        if (a[0] == b[0])
        {
            break;
        }
        RotateDice(a, 3);
    }

    if (a[0] == b[0] && a[2] == b[2] && a[3] == b[3] && a[4] == b[4])
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}



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

    #define ll long long

    void solve()
    {
        int n;
        cin >> n;
        string s;
        cin >> s;

        int i = 0, j = n - 1;
        int cnt = 0;

        while(i < j)
        {
            while(i < j && s[i] != 'W')
            {
                i++;
            }

            while(j > i && s[j] != 'R')
            {
                j--;
            }

            if(i < j)
            {
                cnt++;
                swap(s[i], s[j]);
            }

            //cout << i << " " << j << "\n";
        }

        cout << cnt;
    }

    int main()
    {
        ios::sync_with_stdio(0);
        cin.tie(0);
        
        // ll t;
        // cin >> t;
        
        // while(t--)
        // {
            solve();
        // }

        return 0;
    }


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

int main()
{
	string strInput;
	while (cin >> strInput, strInput != "0")
	{
		int nSum = 0;
		for (char c : strInput)	// A new way of for... in c++11
		{
			nSum += c - '0';
		}
		cout << nSum << endl;
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 3160
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
X = min(A, B, C, D, E)
if(N % X == 0):
  print(N//X + 4)
else:
  print(N//X + 5)

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

int main(){
	char c1,c2,in='A';
	while(scanf("%c,%c",&c1,&c2)!=EOF){
		//if(c1=='Z') break;
		if(c1==in) in=c2;
		else if(c2==in) in=c1;
	}
	cout<<in<<endl;
}

Measured memory_bytes: 1152
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[6100];
long long M1=mod;
long long M2=mod+2;
pair<pair<long long,long long> ,int >p[6100];
long long key=114514;
long long sum[2][5100];
long long ks[2][5100];

int main(){
	int n;scanf("%d",&n);
	scanf("%s",in);
	for(int i=0;i<5100;i++){
		ks[0][i]=pw_mod(key,100000-i,M1);
		ks[1][i]=pw_mod(key,100000-i,M2);
	}
	for(int i=0;i<n;i++){
		sum[0][i+1]=in[i]*pw_mod(key,i,M1)%M1;
		sum[1][i+1]=in[i]*pw_mod(key,i,M2)%M2;
	}
	for(int i=0;i<=n;i++){
		sum[0][i+1]=(sum[0][i+1]+sum[0][i])%M1;
		sum[1][i+1]=(sum[1][i+1]+sum[1][i])%M2;
	}
	int ret=0;
	for(int i=n;i>0;i--){
		bool ok=false;
		for(int j=0;j<=n-i;j++){
			long long tmp1=(sum[0][j+i]-sum[0][j]+M1)%M1;
			tmp1=tmp1*ks[0][j]%M1;
			long long tmp2=(sum[1][j+i]-sum[1][j]+M2)%M2;
			tmp2=tmp2*ks[1][j]%M2;
			p[j]=make_pair(make_pair(tmp1,tmp2),j);
		}
		std::sort(p,p+n-i+1);
		int las=0;
		for(int j=0;j<n-i+1;j++){
			if(j==0||p[j].first!=p[j-1].first){
				las=p[j].second;
			}else if(p[j].second-las>=i){
				ok=true;
			}
		}
		if(ok){
			ret=i;break;
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 384
mycode = r'''
# distutils: language=c++
# cython: language_level=3
# cython: boundscheck=False
# cython: wraparound=False
# cython: infer_types=True
# cython: cdivision=True
# False:Cython はCの型に対する除算・剰余演算子に関する仕様を、(被演算子間の符号が異なる場合の振る舞いが異なる)Pythonのintの仕様に合わせ、除算する数が0の場合にZeroDivisionErrorを送出します。この処理を行わせると、速度に 35% ぐらいのペナルティが生じます。 True:チェックを行いません。



# define 
ctypedef long long LL

# 読み込みはpython側で行う
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.readline #文字列読み込む時はこっち

cdef LL a_int(): return int(readline())

cdef LL i,j,k,_


A=a_int()
B=a_int()
C=a_int()
X=a_int() #あえて型をつけない(→実装が早くなる)

# 愚直にシミュレーション
cdef LL a,b,c,ans #他の定数はぶっちゃけ型を付ける必要がないですが、ループにはしっかりつけないと速度が低下する
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            ans += (500*a + 100*b + 50*c == X)
print(ans)


'''

import sys
if sys.argv[-1] == 'ONLINE_JUDGE':  # コンパイル時
    import os
    with open('mycode.pyx', 'w') as f:
        f.write(mycode)
    os.system('cythonize -i -3 -b mycode.pyx')

import mycode


Measured memory_bytes: 9192
/*
Author : Xinyuan
*/
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int n = nxt(), m = nxt();
    set<int> ac;
    multiset<int> wa;
    int w = 0;
    REP(i, m){
        int q = nxt();
        string s;
        cin >> s;
        if(s == "AC"){
            if(ac.count(q) == 0) w += wa.count(q);
            ac.insert(q);
        }else{
            if(ac.count(q) == 0) wa.insert(q);
        }
    }
    printf("%d %d\n", ac.size(), w);
    return 0;
}



Measured memory_bytes: 4992
nhw = list(map(int, input().split()))
ab = [list(map(int, input().split())) for _ in range(nhw[0])]
ab.sort(reverse=True)
aba = [i for i in ab if i[0] >= nhw[1]]
abab = [i for i in aba if i[1] >= nhw[2]]
print(len(abab))


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

bool f[100][10];
int p[100][11];
int main() {
  int n;
  cin >> n;
  rep(i,n)rep(j,10) cin >> f[i][j];
  rep(i,n)rep(j,11) cin >> p[i][j];
  int ans = -1e9;
  rep(b,1<<10){
    if(b==0) continue;
    int s = 0;
    rep(i,n){
      int c = 0;
      rep(j,10) if(b>>j&1 && f[i][j]) ++c;
      s += p[i][c];
    }
    ans = max(ans,s);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    char str[4] ;
    scanf("%s",&str);
    int count = 0  , i , j;
    for(i = 0 ; i < 3 ; i++){
        for(j = i+1 ; j<4 ; j++){
            if(str[i]==str[j]){
                count++ ;
                break ;
            }
        }
    }
    if(count==2){
        printf("Yes");
    }else{
        printf("No");
    }

}


Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef set<int> si;
typedef map<int, int> mii;
#define INF (1<<29)

set<int> s[200000];

int main(){
    int n,m,i;
    scanf("%d %d", &n, &m);

    for(i=0; i<m; i++){
        int x,y;
        scanf("%d %d", &x, &y);

        x--;
        y--;

        s[x].insert(y);
        s[y].insert(x);
    }

    for(i=1; i<n-1; i++){
        if(s[i].count(0)&&s[i].count(n-1)){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}



Measured memory_bytes: 28416
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define fs first
#define sc second
#define N 100010
#define M 200010
#define ll long long
using namespace std;
const int mod=1000000007;
int n,m,S,T,dl[20000010],u[M],v[M],w[M]; 
bool vis[N];
ll diss[N],dist[N],g[N],h[N],ans;
pair<ll,int> os[N],ot[N];
int read()
{
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x*f;
}
struct edge
{
	int t;ll w;
	edge *next;
}*con[N];
void ins(int x,int y,int w)
{
	edge *p=new edge;
	p->t=y;
	p->w=w;
	p->next=con[x];
	con[x]=p;
}
void spfa(ll *dis,int s)
{
	dis[s]=0;dl[1]=s;//a[s]=1;
	for(int hd=1,tl=1,v=s;hd<=tl;vis[v]=0,v=dl[++hd])
		for(edge *p=con[v];p;p=p->next)
			if(dis[p->t]>dis[v]+p->w)
			{
				dis[p->t]=dis[v]+p->w;
				if(!vis[p->t]) dl[++tl]=p->t,vis[p->t]=1;
			}
			//else if(dis[p->t]==dis[v]+p->w) a[p->t]+=a[v];
}
void work(pair<ll,int> *o,ll *dis,ll *a)
{
	for(int i=1;i<=n;i++)
	{
		int v=o[i].sc;
		//cout<<v<<endl;
		for(edge *p=con[v];p;p=p->next)
			if(dis[v]+p->w==dis[p->t]) a[p->t]=(a[p->t]+a[v])%mod;
	}
}
int main()
{
	n=read();m=read();S=read();T=read();
	for(int i=1;i<=m;i++)
	{
		u[i]=read(),v[i]=read(),w[i]=read();
		ins(u[i],v[i],w[i]);
		ins(v[i],u[i],w[i]);
	}
	memset(diss,0x3f,sizeof(diss));
	memset(dist,0x3f,sizeof(dist));
	memset(vis,0,sizeof(vis));
	spfa(diss,S);
	
	for(int i=1;i<=n;i++)
		os[i]=make_pair(diss[i],i);
	memset(vis,0,sizeof(vis));
	spfa(dist,T);
	for(int i=1;i<=n;i++)
		ot[i]=make_pair(dist[i],i);
	sort(os+1,os+n+1);
	sort(ot+1,ot+n+1);
	g[S]=1;h[T]=1;
//	cout<<"S:"<<endl;
	work(os,diss,g);
//	cout<<"T:"<<endl;
	work(ot,dist,h);
//	puts("diss:");
//	for(int i=1;i<=n;i++)
//		cout<<diss[i]<<' ';
//	puts("");
//	puts("dist:");
//	for(int i=1;i<=n;i++)
//		cout<<dist[i]<<' ';
//	puts("");	
//	puts("g:");
//	for(int i=1;i<=n;i++)
//		cout<<g[i]<<' ';
//	puts("");
//	puts("h:");
//	for(int i=1;i<=n;i++)
//		cout<<h[i]<<' ';
//	puts("");
	for(int i=1;i<=n;i++)
	{
		for(edge *p=con[i];p;p=p->next)
			if(diss[i]+dist[p->t]+p->w==diss[T]&&abs(diss[i]-dist[p->t])<p->w) ans=(ans+g[i]*g[i]%mod*h[p->t]%mod*h[p->t]%mod)%mod;
		if(diss[i]==dist[i]) ans=(ans+g[i]*g[i]%mod*h[i]%mod*h[i]%mod)%mod;
	}
	//cout<<g[T]*h[S]<<' '<<ans<<endl;
	ans=(g[T]*h[S]%mod-ans+mod)%mod;
	printf("%lld",ans);		
	return 0;
}
/*4 5
1 4 
1 2 1
2 3 1
3 4 1
1 3 2
2 4 2*/

Measured memory_bytes: 29184
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define vi vector <int>
#define vp vector <pair<int,int>>
#define f(x,y,z) for(x=y;x<z;x++)
#define pb push_back
#define mp make_pair
#define ld long double
#define fb(x,y,z) for(x=y;x>z;x--)
#define pqf priority_queue <int,vector <int>> 
#define pqb priority_queue <int,vector <int>,greater<int>> 
#define ps(x,y) fixed << setprecision(y) << x
#define PI 3.1415926535
#define mod 1000000007 
#define mods 998244353 
#define setbits(x) __builtin_popcountll(x)
#define all(x) (x).begin(), (x).end()
#define fill(a,b) memset(a,b,sizeof(a))


// AUTHOR ALOK KUMAR
int lcm(int a,int b)
{
    return (a*b)/(__gcd(a,b));
}
int power(int a,int b)
{
    int c=1;
    while(b)
    {
        if(b&1)
        c*=a;
        a*=a;
        b>>=1;
    }
    return c;
}
void solve()
{
    string s="";
    int k;
    cin>>k;
    while(k--)
    {
        s+="ACL";
    }
    cout<<s<<"\n";
    
    
    
    
}



int32_t main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--)
    solve();
    return 0;
}



































Measured memory_bytes: 3612
import math

HORIZONTAL = 0
VERTICAL = 1
ELSE = 2
mode = ELSE

x_p1, y_p1, x_p2, y_p2 = [int(i) for i in input().split()]
if x_p2-x_p1 == 0:
    mode = VERTICAL
elif y_p2-y_p1 == 0:
    mode = HORIZONTAL
else:
    a = (y_p2-y_p1)/(x_p2-x_p1)
    b = y_p1 - a * x_p1

q = int(input())
for _ in range(q):
    x_p0, y_p0 = [int(i) for i in input().split()]
    u = x_p0-x_p1
    v = y_p0-y_p1
    if mode == VERTICAL:
        print(x_p1, y_p0)
    elif mode == HORIZONTAL:
        print(x_p0, y_p1)
    else:
        x = (x_p0/a+y_p0-b)/(a+1/a)
        y = a* x + b
        print(x, y)


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

typedef long long int ll;

using namespace std;

typedef vector< vector<bool> > Graph;

int main()
{
    ios_base::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    int maxK = ((n - 2) * (n - 1)) / 2;
    if (k > maxK)
    {
        cout << "-1\n";
        return 0;
    }
    
    Graph graph(n + 1, vector<bool>(n + 1, false));
    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            if (i == j)
                continue;
            
            graph[i][j] = true;
        }
    }
    
    int currNode = 2;
    while (k > 0)
    {
        bool found = false;
        
        // skip center node
        for (; currNode <= n; ++currNode)
        {
            for (int i = 2; i <= n; ++i)
            {
                if (graph[currNode][i])
                {
                    found = true;
                    graph[currNode][i] = false;
                    graph[i][currNode] = false;
                    break;
                }
            }
            
            if (found)
                break;
        }
        
        --k;
    }
    
    int m = 0;
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; ++j)
            m += graph[i][j];
    }
    
    cout << m << "\n";
    for (int i = 1; i <= n; ++i)
    {
        for (int j = i + 1; j <= n; ++j)
        {
            if (graph[i][j])
                cout << i << " " << j << "\n";
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ri register int
#define N 2010
using namespace std;

int n,a[N];
bitset <4000003> f;
int sum;


int gi(){
	char ch;
	while(ch=getchar(),ch<'0'||ch>'9');
	int res=ch^48;
	while(ch=getchar(),ch>='0'&&ch<='9')
		res=(res<<3)+(res<<1)+(ch^48);
	return res;
}


int main(){
	//freopen("mid.in","r",stdin);
	//freopen("mid.out","w",stdout);
	f.reset();
	scanf("%d",&n);
	for(ri i=1;i<=n;++i){
		a[i]=gi();
		sum+=a[i];
		f|=f<<a[i];
		f.set(a[i]); 
	}
	for(ri j=(sum+1)/2;j<=sum;++j){
		if(f[j]){
			printf("%d",j);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int H,W,A=0,I = 0;
 cin >> H >> W;
 A = H * W;
 vector<char> vec(A);
 for(int j = 0; j < W+2; j++){
   cout << '#';
 }
 cout << endl;
 for(int i = 0; i < H; i++){
   cout << '#';
   for(int j = 0; j < W; j++){
     I = i * W + j;
     cin >> vec.at(I);
     cout << vec.at(I);
   }
  cout <<'#' <<endl;
 }
 for(int j = 0; j < W+2; j++){
   cout <<'#';
 }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chMin(T& a,T b){if(a>b){a=b;return true;}else{return false;}};
const int inf=1e9;
  
int main(){
    int N,K;
    cin >>N >>K;
    vector<int> h(N);
    for (int i=0;i<N;i++)cin >>h[i];
    vector<int> mem(100200); 
  	for(int i=0;i<N;i++)mem[i]=inf;
    mem[0]=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<K;j++){
            chMin(mem[i+j+1],mem[i]+abs(h[i+j+1]-h[i]));
        }
    }
    cout <<mem[N-1]<<endl;
}

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

int main() {

  int n, m;
  cin >> n >> m;

  vector<vector<int>> A(n,vector<int>(m));
  vector<int> B(m);

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> A[i][j];
    }
  }

  for (int i = 0; i < m; i++) {
    cin >> B[i];
  }
  
  for (int i = 0; i < n; i++) {
    int result = 0;
    for (int j = 0; j < m; j++) {
      result += A[i][j] * B[j];
    }
    cout << result << endl;
  }

  return 0;

}


Measured memory_bytes: 3204
from collections import deque
N, C, K = map(int, input().split())
T = [int(input()) for _ in range(N)]
D = deque(sorted(T))
cnt = 1
ans = 1
pre = D.popleft()
flag = False
while D:
    d = D.popleft()
    cnt += 1
    if cnt > C or d - pre > K:
        cnt = 1
        pre = d
        ans += 1
print(ans)


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void ans(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=INF,res2=-INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  vector<ll>h(10);
  for(i=0;i<k;i++){
    cin>>buf;
    h[buf]=1;
  }
  for(i=n;;i++){
    judge=true;
    buf=i;
    for(;buf!=0;buf/=10){
      if(h[buf%10])judge=false;
    }
    if(judge){
      cout<<i<<endl;
      break;
    }
  }
  return 0;
}

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

using namespace std;

int main(){
    int M1 = 0, D1 = 0;
    int M2 = 0, D2 = 0;
    cin >> M1 >> D1;
    cin >> M2 >> D2;
    if(M1+1 == M2 || (M1==12 && M2==1)){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var k = int.Parse(Console.ReadLine());
			var x = int.Parse(Console.ReadLine());
			var y = int.Parse(Console.ReadLine());

			var diff = n - k;
			if(diff <= 0)
			{
				diff = 0;
				k = n;
			}

			Console.WriteLine(x * k + y * diff);
		}
	}
}


Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 100000007
typedef long long ll;
using namespace std;

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


Measured memory_bytes: 256
r;main(a,b,n,i){
for(;~scanf("%d%d%d",&a,&b,&n);printf("%d\n",r)){
	for(r=i=0,a*=10;i<n;i++){
		r+=a/b%10;
		a=a%b*10;
	}
}exit(0);}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;
    cin >> n;
    ll a[n], b[n];
    for (ll i = 0; i < n;i++){
        cin >> a[i] >> b[i];
    }
    ll cnt = 0;
    for (ll i = n - 1; i > 0; i--) {
        ll tmp = 0;
        tmp -= a[i];
        tmp += ((a[i] + b[i] - 1) / b[i]) * b[i];
        cnt += tmp;
        a[i - 1] += cnt;
    }
        ll tmp = 0;
        tmp -= a[0];
        tmp += ((a[0] + b[0] - 1) / b[0]) * b[0];
        cnt += tmp;
    cout << cnt << endl;
}

Measured memory_bytes: 5136
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

constexpr int MAX_N = 100;

int N;
int a[MAX_N], sum, diff[MAX_N], mi = 1<<30;

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", a+i ), sum += a[i];
  
  rep( i, N )
    diff[i] = abs(a[i]*N-sum), mi = std::min( mi, diff[i] );

  rep( i, N ) if( diff[i] == mi )
  {
    printf( "%d\n", i );

    return 0;
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  int X, Y;
  cin >> X >> Y;
  if(Y % 2 == 0 && 2 * X <= Y && Y <= 4 * X)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>

#define bigone t.size() + 1
#define bangone b.size() + 1
#define big t.size()
#define bang b.size()
#define USA 1000000007

using namespace std;

int main() {
	string t, b;
	cin >> t >> b;
	//P=プロフェッショナル
	int P[bigone][bangone] = {};

	for (int i = 0; i < bang + 1; i++) {
		P[0][i] = 0;
	}

	for (int i = 0; i < big + 1; i++) {
		P[i][0] = 1;
	}

	for (int i = 1; i < big + 1; i++) {
		char ti = t.at(i - 1);
		for (int j = 1; j < bang + 1; j++) {
			char bj = b.at(j - 1);
			if (j <= i) {
				if (ti == bj) {
					P[i][j] = (P[i - 1][j - 1] + P[i - 1][j]) % USA;
				}
				else {
					P[i][j] = P[i - 1][j];
				}
			}
			else {
				P[i][j] = 0;
			}
		}
	}
	cout << P[big][bang] << endl;
}


Measured memory_bytes: 7072
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(M);
  for (int i = 0; i < N; i++){
    int K;
    cin >> K;
    for (int j = 0; j < K; j++){
      int L;
      cin >> L;
      L--;
      A[L].push_back(i);
    }
  }
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int cnt = A[i].size();
    for (int j = 0; j < cnt - 1; j++){
      E[A[i][j]].push_back(A[i][j + 1]);
      E[A[i][j + 1]].push_back(A[i][j]);
    }
  }
  vector<bool> used(N, false);
  queue<int> Q;
  Q.push(0);
  used[0] = true;
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (int w : E[v]){
      if (!used[w]){
        used[w] = true;
        Q.push(w);
      }
    }
  }
  bool ok = true;
  for (int i = 0; i < N; i++){
    if (!used[i]){
      ok = false;
    }
  }
  if (ok){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

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

int main(){
    int h,w,i,j;
    while(cin >> h >> w){
        if(h == 0 && w == 0) break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(i % 2 == 0){
                    if(j % 2 == 0){
                        cout << "#";
                    }else{
                        cout << ".";
                    }
                }else{
                    if(j % 2 == 0){
                        cout << ".";
                    }else{
                        cout << "#";
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<string>

#define oct2dec( b ) ( \
 ((b & 1 <<  0) >>  0) + ((b & 1 <<  3) >>  2) + ((b & 1 <<  6) >>  4) + \
 ((b & 1 <<  9) >>  6) + ((b & 1 << 12) >>  8) + ((b & 1 << 15) >> 10) + \
 ((b & 1 << 18) >> 12) + ((b & 1 << 21) >> 14))

#define B( x ) oct2dec( 0 ## x )

const int en[10] = { B( 0111111 ), B( 0000110 ), B( 1011011 ), B( 1001111 ), B( 1100110 ), 
					B( 1101101 ), B( 1111101 ), B( 0100111 ), B( 1111111 ), B( 1101111 ) };

void showBin( int x )
{
	std::string s;

	while( x > 0 )
	{
		s += ( x & 1 ) + '0';
		x >>= 1;
	}

	std::reverse( s.begin(), s.end() );

	std::cout << std::setw( 7 ) << std::setfill( '0' ) << s << std::endl;

	return;
}

int main()
{
	int n;
	while( std::cin >> n, n != -1 )
	{
		int prv = 0;
		for( int i = 0; i != n; ++i )
		{
			int a;
			std::cin >> a;
			showBin( en[a] ^ prv );
			prv = en[a];
		}
	}

	return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,W,v[100],w[100];
  cin>>N>>W;
  for(int i=0;i<N;i++)cin>>v[i]>>w[i];
  int dp[101][10001]={};
  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      dp[i+1][j]=max(dp[i][j],dp[i+1][j]);
      if(j>=w[i])dp[i+1][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
    }
  }
  int ans=0;
  for(int i=0;i<=W;i++)ans=max(ans,dp[N][i]);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 7052
#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
using namespace std;

ll MOD = 1000000007;
int ans = INT_MAX;
int fd = -1;
int n,m,x;
void back(int cost, int ind, vector<vector<int>> &mp, vector<int> &c, vector<int> vals){
    int f = 1;
    for(int i=0;i<m;i++){
        if(vals[i] < x){
            f=0;
            break;
        }
    }
    //cout<<ind<<" "<<f<<endl;
    if(f == 1){
        ans = min(ans, cost);
        fd =1;
    }
    if(ind == n) return;
    cost += c[ind];

    for(int i=0;i<m;i++){
        vals[i]+=mp[ind][i];
    }
    back(cost, ind+1, mp, c,vals);
    cost -= c[ind];
    for(int i=0;i<m;i++){
        vals[i]-=mp[ind][i];
    }
    back(cost, ind+1,mp,c,vals);

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>m>>x;
    vector<int> c(n,0);
    vector<int> t(m, 0);
    vector<vector<int>> mp(n, t);
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++) cin>>mp[i][j];
    }
    vector<int> vals(m,0);
    back(0,0,mp,c,vals);
    if(fd ==-1) ans = -1;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
int main(){
  int n,i,j;
  char s[100001];
  scanf("%d",&n);
  while(n--){
    scanf("%s",s);
    if(s[0]!='>'){
      printf("NA\n");
      continue;
    }
    if(s[1]=='\''){
      for(i=2;s[i]=='=';i++);//printf("%c\n",s[i]);
      for(j=1;s[i-j]=='='&&s[i+j]=='=';j++);
      if(i-j==1&&s[i+j]=='~'&&s[i+j+1]==0&&s[i]=='#'&&i-2)printf("A\n");
      else                                                printf("NA\n");
    }
    else if(s[1]=='^'){
      for(i=2;s[i]=='Q'&&s[i+1]=='=';i+=2);
      if(s[i]=='~'&&s[i+1]=='~'&&s[i+2]==0&&i-2)printf("B\n");
      else                                      printf("NA\n");
    }
    else printf("NA\n");
  }
  return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define int long long
using namespace std;
using ll = long long;

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

  int n, a, b;
  cin >> n >> a >> b;

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

  int now = x[0], ans = 0;
  for (int i = 0; i < n; ++i) {
    int next_town = x[i];

    ans += min((next_town - now) * a, b);
    now = next_town;
  }

  cout << ans << '\n';

  return (0);
}


Measured memory_bytes: 4340
import bisect
a,b,c,d,e,f = map(int,input().split())
lw = []
ls = []
for i in range((f//100)//b+1):
    for j in range(100):
        if b*i*100+a*j*100 > f:
            break
        lw.append(b*i*100+a*j*100)
for i in range((f//2)//d+1):
    for j in range(3000):
        if (d*i+c*j) > (f*e)/(100+e):
            break
        ls.append(d*i+c*j)
ls.sort()
lw.sort()
n = len(lw)
ans = 0
ansl = [0,0]

for i in range(n):
    w = lw[i]
    t = min(f-w,w/100*e)
    s = ls[bisect.bisect_right(ls,t)-1]
    if (s+w)==0:
        continue
    if 100*s/(s+w) >= ans:
        ans = 100*s/(s+w)
        ansl = [s+w,s]
print(*ansl)

Measured memory_bytes: 71104
/**
*    author:  souzai32
*    created: 11.08.2020 20:19:26
**/

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

int main() {

    int n,m;
    cin >> n >> m;
    vector<int> k(m),p(m);
    vector<vector<int>> s(m,vector<int>(n));
    rep(i,m){
        cin >> k.at(i);
        rep(j,k.at(i)){
            cin >> s.at(i).at(j);
        }
    }
    rep(i,m) cin >> p.at(i);

    vector<bool> sw(n);
    int count=0,check,num;
    bool light;
    for(int i=0; i<pow(2,n); i++){
        num=i;
        light=true;
        rep(j,n){
            if(num%2==1) sw.at(j)=true;
            else sw.at(j)=false; 
            num/=2;
        }
        rep(j,m){
            check=p.at(j);
            rep(l,k.at(j)){
                if(sw.at(s.at(j).at(l)-1)) check++;
            }
            if(check%2) light=false;
        }
        if(light) count++;
        /*for(int j=0; j<n; j++){
            cout << sw.at(j) << ' ';
        }   
        cout << endl;
        cout << count << endl;*/
    }
    
    cout << count << endl;

    return 0;
}

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


int N, M, Q;


vector<vector<int>> hozo;

void dfs(vector<int> A, int last) {
    int sz;
    sz = A.size();
    if (sz == N) {
        hozo.push_back(A);
        return;
    }

    for (int i = last; i <= M; i++) {

        vector<int> tmp;
        tmp = A;
        tmp.push_back(i);
        dfs(tmp,i);
    }
}


int main(){
 
    cin >> N >> M >> Q;
    vector<int> a(Q), b(Q), c(Q), d(Q);
    for(int i = 0; i < Q; i++) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
    
    }
    
    vector<int> empty;

    long long ans;
    ans = 0;

    dfs(empty, 1);

    for (vector<int> A : hozo){
        long long score = 0;
        for (int i = 0; i < Q; i++){

            if (A[b[i]] - A[a[i]] == c[i]){
                score += d[i];
            }
        }

        

        ans = max(ans,score);
    }
    
    cout << ans << endl;

}

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

int main() {
  int n;
  cin >> n;
  vector<long double> a(n);
  long double sum = 0;
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
    a.at(i) = 1 / a.at(i);
    sum += a.at(i);
  }
  cout << fixed << setprecision(6) << 1 / sum << endl;
  
}


Measured memory_bytes: 256