akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
using namespace std;
static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[N][N];
int color[N], d[N], f[N], tt;
int nt[N];

int next(int u) {
  for (int v = nt[u]; v < n; ++v){
    nt[u] = v + 1;
    if (M[u][v]) return v;
  }
  return -1;
}

void dfs_visit(int r) {
  for (int i = 0; i < n; ++i) nt[i] = 0;

  stack<int> S;
  S.push(r);
  color[r] = GRAY;
  d[r] = ++tt;

  while( !S.empty()) {
    int u = S.top();
    int v = next(u);
    if (v != -1) {
      if (color[v] == WHITE) {
        color[v] = GRAY;
        d[v] = ++tt;
        S.push(v);
      }
    }
    else {
      S.pop();
      color[u] = BLACK;
      f[u] = ++tt;
    }
  }
}

void dfs() {
  for (int i = 0; i < n; ++i) {
    color[i] = WHITE;
    nt[i] = 0;
  }
  tt = 0;

  for (int u = 0; u < n; u++) {
    if (color[u] == WHITE) dfs_visit(u);
  }
  for (int i = 0; i < n; ++i) {
    cout << i + 1 << " " << d[i] << " " << f[i] << endl;
  }
}

int main() {
  int u, k, v;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      M[i][j] = 0;
    }
  }

  for (int i = 0; i < n; ++i) {
    cin >> u >> k; u--;
    for (int j = 0; j < k; ++j) {
      cin >> v; v--;
      M[u][v] = 1;
    }
  }
  dfs();
  return 0;
}



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

int main() {
  ll X; cin>>X;
  ll p=100;
  int res=0;
  for (int i=1; i<10000; i++) {
    ll add=p/100;
    p+=add;
    if (p>=X) {
      res=i;
      break;
    }
  }
  cout<<res<<endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 101010 
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
struct hh{int t,nxt;}edge[sz<<1];
int head[sz],ecnt;
void make_edge(int f,int t)
{
	edge[++ecnt]=(hh){t,head[f]};
	head[f]=ecnt;
	edge[++ecnt]=(hh){f,head[t]};
	head[t]=ecnt;
}

int vis[sz][25];
int ans;
void dfs(int x,int fa)
{
	#define v edge[i].t
	go(x) if (v!=fa)
	{
		dfs(v,x);
		rep(j,0,20) vis[x][j]+=vis[v][j];
	}
	#undef v
	int k=0;
	rep(i,0,20) if (vis[x][i]>=2) k=i+1;
	while (vis[x][k]) ++k;
	++vis[x][k];
	rep(i,0,k-1) vis[x][i]=0;
	chkmax(ans,k);
}

int main()
{
	file();
	read(n);
	int x,y;
	rep(i,1,n-1) read(x,y),make_edge(x,y);
	dfs(1,0);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 18176
N,M = map(int,input().split())

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import bellman_ford

ABC = [[int(x) for x in input().split()] for _ in range(M)]
row,col,val = zip(*ABC)

# -1倍しておいて最短路問題にする
val = [-x for x in val]

# 求めたい経路の外の閉路にはまるとまずい
#graph = csr_matrix((val,(row,col)),(N+1,N+1))
#try:
#  dist = bellman_ford(graph,indices = [1])[0].astype(int)
#  answer = -dist[N]
#except:
#  answer = 'inf'
import numpy as np
from scipy.sparse.csgraph import connected_components

graph = csr_matrix((val,(row,col)),(N+1,N+1))

find_component_graph = csr_matrix(([1]*(M+1),(row+(N,),col+(1,))),(N+1,N+1))
_,labels = connected_components(find_component_graph,connection = 'strong')
idx = (labels == labels[1])

graph = graph[idx,:][:,idx]

try:
  dist = bellman_ford(graph,indices = [0])[0].astype(int)
  answer = -dist[-1]
except:
  answer = 'inf'

print(answer)

Measured memory_bytes: 14316
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int L, K;
    scanf("%d%d", &L, &K);
    lint dp[L+1][2];
    rep(i, L+1)rep(j, 2) dp[i][j] = 0;
    dp[0][0] = 1;
    rep(i, L)rep(j, 2)if(dp[i][j]){
        dp[i+1][j^1] += dp[i][j];
        if(j==0 && i+K<=L) dp[i+K][1] += dp[i][j];
    }
    lint ans = 0;
    rep(i, L+1) ans += dp[i][1];
    printf("%lld\n", ans);
}


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

int main(){
  int n;
  cin>>n;
  bool can = 0;
  for(int i = 1; i < 10 && i*i <= n; i++)if(n%i == 0 && n/i <= 9){can  =1; break;}
  if(can)cout<<"Yes\n";
  else cout<<"No\n";
}

Measured memory_bytes: 256
#include<stdio.h>
  
struct Node { int p, l, r; };
struct Node T[100000000];
int n;
  
void preParse(int u) {
    if (u==-1) return 1;
    printf(" %d",u);
    preParse(T[u].l);
    preParse(T[u].r);
}
  
void inParse(int u) {
    if (u==-1) return 1;
    inParse(T[u].l);
    printf(" %d",u);
    inParse(T[u].r);
}
  
void postParse(int u) {
    if(u==-1) return 1;
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d",u);
}
  
int main(void)
{
    int i, v, l, r, root;
  
    scanf("%d", &n);
    for(i=0;i<n;i++) {
        T[i].p=-1;
    }
    for (i=0;i<n;i++){
        scanf("%d %d %d",&v,&l,&r);
        T[v].l=l;
        T[v].r=r;
        if(l!=-1) T[l].p=v;
        if(r!=-1) T[r].p=v;
    }
      
    for(i=0;i<n;i++) 
if(T[i].p==-1)
 root = i;
  
    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");
  
    return 0;
}

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

public class Main {
    public static void printSet(Set<Integer> s){
    	for(int e:s){
    		System.out.print(" "+e);
    	}
    	System.out.println();
    }
    
    public static void make(int N,int K){
    	Set<Integer>[] S = new Set[K];
    	for(int k=0;k<K;k++) S[k] = new HashSet<>();
    	int edgeNum = 1;
    	for(int i=0;i<K;i++) for(int j=i+1;j<K;j++){
    		S[i].add(edgeNum);
    		S[j].add(edgeNum);
    		edgeNum++;
    	}
    	System.out.println(K);
    	for(int k=0;k<K;k++){
    		System.out.print(K-1);
    		printSet(S[k]);
    	}
    }
    
    
    
    public static void solve(int N){
    	for(int k=1; k<100000; k++){
    		if(N == k *(k-1)/2){
    			System.out.println("Yes");
    			make(N,k);
    			return;
    		}
    		else if (N < k*(k-1)/2){
    			System.out.println("No");
    			return;
    		}
    	}
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        solve(N);
    }
}

Measured memory_bytes: 57512
score :: [Int] -> [Int] -> Int
score c a = snd $ foldl step (-1, 0) a
    where step (y, a) x = (x, a + if x == y+1 then (c!!(y-1)) else 0)

main = do
  n <- readLn :: IO Int
  a <- map read . words <$> getLine :: IO [Int]
  b <- map read . words <$> getLine :: IO [Int]
  c <- map read . words <$> getLine :: IO [Int]
  putStrLn . show $ score c a + foldl (+) 0 b


Measured memory_bytes: 764
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);

void solve()
{
	int n;
	string s;
	cin >> n >> s;
	if(s.substr(0, sz(s) / 2) == s.substr(sz(s) / 2)){
		cout << "Yes";
	}
	else cout << "No";
}
 
int main()
{
    Red;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;

    ll ans = 0;
    for(int i = 0; i < n; i++) {
        ll a;
        cin >> a;        
        ans += a-1;
    }

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

Measured memory_bytes: 256
#!python
# -*- coding: utf-8 -*-


def main():
    n, m, d = map(int, input().split())
    if d:
        print(((n - d) * 2 / (n * n)) * (m - 1))
    else:
        print(((n - d) / (n * n)) * (m - 1))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>

int N, K;
int x[100010];

int main()
{
    std::cin >> N >> K;

    for (int i = 0; i < N; ++i)
        std::cin >> x[i];

    int ans = 1000000000;
    for (int i = 0; i < N - K + 1; ++i)
        ans = std::min({ans, std::abs(x[i]) + std::abs(x[i + K - 1] - x[i]),
                        std::abs(x[i + K - 1]) + std::abs(x[i] - x[i + K - 1])});

    std::cout << ans << '\n';

    return 0;
}

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

int n;
string s;

void input() {
    cin >> n >> s;
}

void solve() {
    string result;
    for(auto itr = s.begin(); itr != s.end(); itr++) {
        //result.push_back(*itr - '0' + n);
        cout << static_cast<unsigned char>((((*itr + n) - 'A' )% ('Z' - 'A' + 1) ) + 'A') ;
    }

}
int main() {
    input();
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

void Add(int &a, int b) {
  a += b;
  while (a >= MOD) a -= MOD;
  while (a < 0) a += MOD;
}
 
void Mul(int &a, int b) {
  a = 1LL * a * b % MOD;
}
 
int Pow(int b, int e) {
  if (e < 0) e += MOD - 1;
  int ret = 1;
  while (e) {
    if (e & 1) ret = 1LL * ret * b % MOD;
    b = 1LL * b * b % MOD;
    e >>= 1;
  }
  return ret;
}
 
namespace Math {
  const int NMAX = (int)1e5;
  int pow2[1 + NMAX];
  int fact[1 + NMAX], tcaf[1 + NMAX];
  void Precalc() {
    fact[0] = pow2[0] = 1;
    for (int i = 1; i <= NMAX; ++i) {
      pow2[i] = pow2[i - 1];
      Add(pow2[i], pow2[i]);
 
      fact[i] = fact[i - 1];
      Mul(fact[i], i);
    }
    tcaf[NMAX] = Pow(fact[NMAX], -1);
    for (int i = NMAX - 1; i >= 0; --i) {
      tcaf[i] = tcaf[i + 1];
      Mul(tcaf[i], i + 1);
      assert(1LL * fact[i] * tcaf[i] % MOD == 1);
    }
  }
  int Choose(int n, int k) {
    if (k > n || n < 0) return 0;
    return 1LL * fact[n] * tcaf[n - k] % MOD * tcaf[k] % MOD;
  }
};

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];
  map<ll,ll> m;
  rep(i,n){
    ll u=a[i],b=2;
    while(true){
      if (b*b>a[i]) break;
      ll c=0;
      while(true){
        if (u%b==0){
          u/=b;
          c++;
          m[b]=max(m[b],c);
        }
        else break;
      }
      b++;
    }
    m[u]=max(m[u],1ll);
  }
  ll r=1;
  for (auto it=m.begin();it!=m.end();it++){
    // cout << it->first << " " << it->second << endl;
    (r*=Pow(it->first,it->second))%=MOD;
  }
  ll ans=0;
  rep(i,n){
    (ans+=r*Pow(a[i],MOD-2))%=MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,N;
    cin >>A>>B>>N;
    ll ans;
    if(N>=B-1){
        ans = A*(B-1)/B;
    }else{
        ans = A*(N)/B;
    }

    cout << ans << endl;


    return 0;
    

}

Measured memory_bytes: 3632
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
    double L, a;

    cin >> L;

    a = L/3;

    cout << fixed << setprecision(6) << a*a*a;

    return 0;

}

Measured memory_bytes: 256
from collections import deque

S = str(input())
Q = int(input())

tmp = deque(S)
houkou = 1 #1:foward 2:reverse

for i in range(Q):
    inp = input().split()
    if inp[0] == '1':
        if houkou == 1:
            houkou = 2
        else:
            houkou = 1
    else:
        if houkou == 1 and inp[1] == '1':
            tmp.appendleft(inp[2])
        elif houkou == 1 and inp[1] == '2':
            tmp.append(inp[2])
        elif houkou == 2 and inp[1] == '1':
            tmp.append(inp[2])
        else:
            tmp.appendleft(inp[2])
    
#    print(houkou, tmp)

output = ''.join(list(tmp))
if houkou == 2:
    output = output[::-1]

print(output)


Measured memory_bytes: 8820
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define for(i,a,b) for(int i=a;i<b;i++)
#define all(a) a.begin(),a.end()
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//sort 降順
//reverse 逆順
 
int main() {
  ll a,b;
  ci(a>>b);
  string s;
  ci(s);
  vec c(b),d(b);
  //OK
  //co(s.size());
  vec e(a);
  ll f=0;
  for(i,0,a){
    if(s[i-1]=='A'&&s[i]=='C')
      f++;
    e[i]=f;
  }
  
  for(i,0,b){
    ll n,m;
    ci(n>>m);
    co(e[m-1]-e[n-1]);
  }
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(){
  int w,h,n;
  cin>>n>>w>>h;
  int x,y,B=2*(w+h),ans=n;
  char c;
  vector<P> m;
  for(int i=0;i<n;i++){
    cin>>x>>y>>c;
    P A;
    if(c=='S')A=P(x+y,(x-y+B)%B);
    if(c=='E')A=P(w+y+(w-x),w+y-(w-x));
    if(c=='N')A=P(w+h+(w-x)+(h-y),w+h+(w-x)-(h-y));
    if(c=='W')A=P((w*2+h+(h-y)+x)%B,w*2+h+(h-y)-x);
    m.push_back(A);
  }
  sort(m.begin(),m.end());
  for(int i=0;i<n;i++){
    int tp=1,p=m[i].first;
    for(int j=0;j<n;j++){
      int s=m[(i+j)%n].second,g=m[(i+j)%n].first;
      if(!(s>g&&!(g<p&&p<s))&&!(s<g&&s<=p&&p<=g))tp++,p=g;
    }
    ans=min(tp,ans);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3104
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>

typedef unsigned long long ULONG;
typedef long long LONG;
using namespace std;

#define PI 3.1415926535897932384626433
#define _DBG_

#define BIG 10000000000 //10

#define LAST 10000000 //10^7


LONG D;
vector<LONG> cost(26);
//vector<vector<ULONG>> sati(D + 1, vector<ULONG>(27));
vector<vector<LONG>> sati;
vector<LONG> answer;
vector<int> lastDate(26, -1);
LONG satVal = 0;


LONG calcSabunScore(int eventType, LONG date) {

	LONG sabun = sati[date][eventType];
	// costsum
	LONG costSum = 0;
	for (int i = 0; i < 26; i++) {
		if (i != eventType) {
			costSum += cost[i] * (date - lastDate[i]);
		}
	}

	sabun -= costSum;
	

	return sabun;

}


int main(void) {
	// for A

	cin >> D;

	vector<LONG> tmpans(D);
	answer = tmpans;


	for (int i = 0; i < 26; i++) {
		cin >> cost[i];
	}



	for (int d = 0; d < D; d++) {
		vector<LONG> tmpsati(26);
		for (int i = 0; i < 26; i++) {
			cin >> tmpsati[i];
		}
		sati.push_back(tmpsati);
	}
	// finish data input


	// answerを決める
	LONG totalScore = 0;
	for (int d = 0; d < D; d++) {
		int maxI = 0;
		LONG maxsabun = -1000000;
		for (int i = 0; i < 26; i++) {
			LONG sabun = calcSabunScore(i, d);
			if (sabun > maxsabun) {
				maxsabun = sabun;
				maxI = i;
			}
		}
		answer[d] = maxI;
		lastDate[maxI] = d;

		totalScore += maxsabun;

	}

	//randomchange
	int changeAtOnce = 2;
	int numChange = 200000;

	changeAtOnce = rand() % 3;
  
	for (int c = 0; c < numChange; c++) {
		vector<LONG> answer2(D);

		for (int d = 0; d < D; d++)answer2[d] = answer[d];

		for (int cao = 0; cao < changeAtOnce; cao++) {
			int date = rand() % D;
			int newEvent = rand() % 26;

			answer2[date] = newEvent;
		}

			LONG totalScore2 = 0;

			// calc score
			for (int i = 0; i < 26; i++)lastDate[i] = -1;
			for (int d = 0; d < D; d++) {
				LONG sabun = calcSabunScore(answer2[d], d);
				totalScore2 += sabun;
				lastDate[answer2[d]] = d;
			}

			// これがよさそうならこれにする
			if (totalScore2 > totalScore) {
				totalScore = totalScore2;
				for (int d = 0; d < D; d++)answer[d] = answer2[d];
			}

		
	}


	// output
	for (int d = 0; d < D; d++) {
		cout << answer[d] + 1 << endl;
	}

	return 0;
}



Measured memory_bytes: 3728
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;

#define inf int(0x3f3f3f3f)
#define mod int(1e9+7)
#define pi acos(-1.0)


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
}



Measured memory_bytes: 256
n = int(input())
ans = 10000
for i in range(1,n):
    a = str(i)
    b = str(n - i)
    a_tmp = 0
    b_tmp = 0
    for j in a:
        a_tmp += int(j)
    for k in b:
        b_tmp += int(k)
    if a_tmp + b_tmp < ans:
        ans = a_tmp + b_tmp
print(ans)
    


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

int main(){
    int n, r;
    cin >> n >> r;
    if (n >= 10) cout << r << endl;
    else cout << r + 100 * (10 - n) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int cnt[26]={0},i,f=1;
	char w[101];
	scanf("%s",w);
	for(i=0;w[i]!='\0';i++){
		cnt[w[i]-'a']++;
	}
	for(i=0;i<26;i++){
		if(cnt[i]%2){
			f=0;
			break;
		}
	}
	if(f) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

int main()
{
   FAST/**/
   
   string s;
   cin>>s;
   
   ll n = s.length();
   
   if(n == 1)
   {
       cout<<1;
       return 0;
   }
   
   ll dp[n][2];
   memset(dp, 0, sizeof(dp));
   
   dp[0][0] = 1;
   dp[1][1] = 1;
   if(s[1]!=s[0])
        dp[1][0] = 2;
   
   for(ll i=2;i<n;i++)
   {
       string s1 = string(1,s[i-1]) + string(1,s[i]);
       string s2 = string(1,s[i]);
       string s5 = string(1,s[i-1]);
       string s3;
       if(i>=3)
            s3 = string(1,s[i-3]) + string(1,s[i-2]);
       
       if(dp[i-1][0]!=0 && s2!=s5)
            dp[i][0] = max(dp[i][0], dp[i-1][0] + 1);
       if(dp[i-1][1]!=0)
            dp[i][0] = max(dp[i][0], dp[i-1][1] + 1);
       if(dp[i-2][0]!=0)
            dp[i][1] = max(dp[i][1], dp[i-2][0] + 1);
       if(dp[i-2][1]!=0 && s3.length() == 2 && s1!=s3)
            dp[i][1] = max(dp[i][1], dp[i-2][1] + 1);
   }
   
   ll ans = max(dp[n-1][0], dp[n-1][1]);
   cout<<ans;
   
   return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

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

    int A, B, C, D, E, K;
    std::cin >> A >> B >> C >> D >> E >> K;

    if(E - A > K){
        std::cout << ":(" << std::endl;
    }else{
        std::cout << "Yay!" << std::endl;
    }
}


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

#define fo1(i, n) for (int i = 0; i < n; i++)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int((x).size())
using ll = long long; using vi = vector<int>; using ii = pair<int,int>;
const int oo = 0x3f3f3f3f; const ll OO = ll(oo)*oo;
#ifndef DEBUG
#define endl '\n'
#define debugf(...)
#define debug(...)
#else
#define debugf(...) printf(__VA_ARGS__)
#define debug(...) __VA_ARGS__
#endif
const int N = 10;

struct Point {
    int x, y;
    Point() {}
    Point(int x, int y) : x(x), y(y) {}

    long double dist(const Point& p) const {
        int dx = x - p.x;
        int dy = y - p.y;
        return hypot(dx, dy);
    }
};

Point p[N];

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

    int n; cin >> n;
    vi idx(n);
    fo1(i, n) {
        cin >> p[i].x >> p[i].y;
        idx[i] = i;
    }

    long double ans = 0;
    int k = 0;
    do {
        rep(i, 1, n) {
            ans += p[idx[i-1]].dist(p[idx[i]]);
        }

        k++;
    } while (next_permutation(all(idx)));

    cout << fixed << setprecision(8) << ans / (long double)k << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int A = scanner.nextInt();
		int B = scanner.nextInt();

		double x8 = (double)A * (100.0 / 8.0);
		double x10 = (double)B * 10.0;

		int floor8 = (int)(Math.floor(x8));
		int floor10 = (int)(Math.floor(x10));

		int num = 0;
		for (int i = (int)Math.ceil(x8); true; i++) {
			int floorZei8 = (int)(Math.floor((double)i * 0.08));
			int floorZei10 = (int)(Math.floor((double)i * 0.1));

			if (floorZei8 == A && floorZei10 == B) {
				num = i;
				break;
			}
			else {
				if (floorZei8 != A && floorZei10 != B) {
					num = -1;
					break;
				}
				else {
					continue;
				}
			}
		}

		System.out.println(num);
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define oo 100000000000000000
using namespace std;



void _sol(){
    int d,t,s; cin >> d >> t >> s;
    if(d<=t*s) cout << "Yes";
    else cout << "No";
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    _sol();
}


Measured memory_bytes: 3648
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let s = get!(String).chars().collect::<Vec<_>>();
    let mut p = 0;
    for c in s.iter() {
        if *c == 'p' {
            p += 1;
        }
    }
    println!("{}", s.len() / 2 - p);
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <set>
#define MAX 100000
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;
typedef long long int lli;

int main(void)
{
	int N; cin >> N;
	set<int> S; S.insert(1);

	rep(i,2,sqrt(1000)) {
		int j = i * i;
		while (j <= 1000) {
			S.insert(j);
			j *= i;
		}
	}
	set<int>::iterator s = --S.end();
	while (*s > N)s--;

	cout << *s << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve(){
	int n; cin >> n;
	vector<int> c(n - 1), s(n - 1), f(n - 1);
	rep(i, n - 1) {
		cin >> c[i] >> s[i] >> f[i];
	}
	rep(i, n) {
		ll cur = 0;
		Rep(j, i, n - 1) {
			ll nex = f[j] * ((cur + f[j] - 1) / f[j]);
			if (nex < s[j])nex = s[j];
			cur = nex + c[j];
		}
		cout << cur << endl;
	}
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(6);
	//init();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
using namespace std;
int  n,m,a[10],b[10];
int s,c;
 
 
int main(){
	while(cin>>n>>m){
		for(int i=1;i <= 5;i++) a[i]=-1;
		if(n==1&&m==0){cout<<0<<endl;return 0;}
		for(int i=1;i <= m;i++){
			cin>>s>>c;
			if(s == 1 && c == 0 && n!=1 ) n=-1;
			if(a[s]!=-1&&a[s]!=c) n=-1;
			a[s]=c;
		}	
		if(n == -1){cout<<-1<<endl;return 0;}
 
		if(a[1] == -1) a[1]=1;
 
		for(int i=1;i <= n;i++){
			if(a[i]==-1)a[i]=0;
			cout<<a[i];
		}
		cout<<endl;
	}
 
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
 
int main(void) {
  int a, b;
  string s;
  cin >> a >> b >> s;
  bool ans=false;
  
  char c = s.at(a);
  	if (c == '-') {
      for (int i=0; i<s.size(); ++i) {
        if (i == a) {
          ans = true;
        } else if (s.at(i) != '-') { 
          ans = true;
        } else {
          ans = false;
          break;
        }
      }
    }
 
    if (ans == true) cout << "Yes" << endl;
      else cout << "No" << endl;
}
   

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SZ = 2009, INF = 1e9 * 1e9 + 10;

char grid[SZ][SZ];

vector<pair<ll, ll>> dir = { {-1, 0}, {1, 0}, {0, 1}, {0, -1}};
bool used[SZ][SZ];
ll dist[SZ][SZ];

int main()
{
    fastInp;

    ll h, w;
    cin >> h >> w;


    queue<pair<ll, ll>> q;

    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
            
            if (grid[i][j] == '#') {
                used[i][j] = 1;
                dist[i][j] = 0;
                q.push({i, j});
            }
        }
    }

    while (!q.empty()) {
        pair<ll, ll> v=  q.front();
        q.pop();

        for (auto cur : dir) {
            if (cur.first + v.first >= 0 && cur.second + v.second >= 0 && cur.first + v.first < h && cur.second + v.second < w) {
                if (!used[cur.first + v.first][cur.second + v.second]) {
                    used[cur.first + v.first][cur.second + v.second] = 1;
                    dist[cur.first + v.first][cur.second + v.second] = dist[v.first][v.second] + 1;
                    q.push({cur.first + v.first, cur.second + v.second});
                }
            }
        }
    }

    ll ans = 0;
    for (int i= 0; i < h; i++) {
        for (int j= 0; j < w; j++) {
            ans = max(ans, dist[i][j]);
        }
    }

    cout << ans;
    
    return 0;
}

Measured memory_bytes: 35156
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

char c1[maxn],c2[maxn],p;
int n,a,b,c,f;
vector <char> ans;

int main()
{
	n=read(); a=read(); b=read(); c=read();
	rep(i,1,n) scanf("%c%c%c",&c1[i],&c2[i],&p);
	rep(i,1,n)
	{
		if(c1[i]=='A'&&c2[i]=='B'||c1[i]=='B'&&c2[i]=='A')
		{
			if(a==0&&b==0) {f=1; break;}
			if(a>b) a--,b++,ans.pb('b'); else if(a<b) a++,b--,ans.pb('a');
			else
			{
				if(c1[i+1]=='A'||c2[i+1]=='A') a++,b--,ans.pb('a');
				else a--,b++,ans.pb('b');
			}
		}
		
		else if(c1[i]=='A'&&c2[i]=='C'||c1[i]=='C'&&c2[i]=='A')
		{
			if(a==0&&c==0) {f=1; break;}
			if(a>c) a--,c++,ans.pb('c'); else if(a<c) a++,c--,ans.pb('a');
			else
			{
				if(c1[i+1]=='A'||c2[i+1]=='A') a++,c--,ans.pb('a');
				else a--,c++,ans.pb('c');
			}
		}
		
		else if(c1[i]=='B'&&c2[i]=='C'||c1[i]=='C'&&c2[i]=='B')
		{
			if(c==0&&b==0) {f=1; break;}
			if(b>c) b--,c++,ans.pb('c'); else if(b<c) b++,c--,ans.pb('b');
			else
			{
				if(c1[i+1]=='B'||c2[i+1]=='B') b++,c--,ans.pb('b');
				else b--,c++,ans.pb('c');
			}
		}
	}
	
	if(f==1) puts("No");
	else
	{
		puts("Yes");
		for(int i=0;i<ans.size();i++) printf("%c\n",ans[i]-'a'+'A');
	}
	return 0;
}

Measured memory_bytes: 4156
h,w = map(int,input().split())
vec = [(1,0),(0,1),(-1,0),(0,-1),(-1,-1),(1,1),(-1,1),(1,-1)]
ans = []
s = [input()for _ in range(h)]
def check(x,y):
    if x>=0 and y >=0 and x <=h-1 and y <= w-1:
        return s[x][y] == '#'
    else:return 0

for x in range(h):
    next = []
    for y in range(w):
        
        if s[x][y] == '#':
            next.append('#')
            continue
        res = 0
        for tx,ty in vec:
            nx = x+tx
            ny = y + ty
            res +=check(nx,ny)
        next.append(str(res))
    ans.append(next)
for i in range(h):
    print("".join(ans[i]))
        
    
        

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main()
{
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='2'){
            cnt++;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod=1000000007;
//head
const int nax = 2001;
ll bit[nax];

void update(int i, int v) {
    while(i < nax) {
        bit[i] += v;
        i += i & -i;
    }
}

ll sum(int i) {
    ll s = 0;
    while(i > 0) {
        s += bit[i];
        i -= i & -i;
    }
    return s;
}
int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    ll ans = 0;
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) { 
        cin >> a[i];
        update(a[i],1);
        ll val = (sum(nax) - sum(a[i])) * k;
        val %= mod;
        if(val < 0) val += mod;
        ans += val;
        ans %= mod;
    }
    ll val = k*(k-1);
    val %= mod;
    val *= (mod + 1) / 2;
    val %= mod;
    for(int i = 0; i < n; i++) {
        ll p1 = val*(sum(nax)-sum(a[i]));
        p1 %= mod;
        if(p1 < 0) p1 += mod;
        ans += p1;
        ans %= mod;
    }
    cout << ans % mod << endl;

    return 0;
}


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


bool sosuu(int l){
    if(l<=1)return false;
    else if (l==2) return true;
    else if (l%2==0) return false;
    for (int i=3;i<sqrt(l)+1; i+=2) {
        if (l%i==0) {
            return false;
            break;
        }
    }
    return true;
}
int main() {
    // insert code here...
    int k,p,a=0;
    cin>>k;
    for (int y=0; y<k; y++) {
        cin>>p;
        if (sosuu(p)) {
            a++;
        }
    }
    cout<<a<<endl;
    return 0;
}


Measured memory_bytes: 3080
let () =
  let n = read_int () in
  let tbl = Hashtbl.create ~random:true n in
  let doit (op, x) =
    if op = "insert" then Hashtbl.add tbl x true
    else if op = "find" then print_endline (if Hashtbl.mem tbl x then "yes" else "no")
    else exit 1
  in
  let rec read i =
    if i >= n then ()
    else begin
      match Str.split (Str.regexp_string " ") (read_line ()) with
      | [] | [_] -> exit 1
      | op :: x :: _ -> (doit (op, x); read (i + 1))
    end
  in
  read 0

Measured memory_bytes: 44048
#include <stdio.h>

int main(void)
{
    int a, b, c, d, e, f;
    int det;
    double x, y;

    while (scanf("%d %d %d %d %d %d",
           &a, &b, &c, &d, &e, &f) != EOF) {
        det = a * e - b * d;
        x = (double)(e * c + -b * f) / det;
        y = (double)(-d * c + a * f) / det;
        printf("%.3f %.3f\n", x + 0, y + 0);
    }

    return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define REP(i,n) for(int64_t i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REV(c) reverse((c).begin(),(c).end())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define COUTDOUBLE(d,i) cout << setprecision((i)) << (d) << endl;
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}
#define MREP(i,m) for(auto i=(m).begin(); i != (m).end(); ++i) // auto key = i->first;auto value = i->second;

using namespace std;
typedef int64_t I;
typedef pair<I,I> P;
typedef vector<I> V;

I MOD = pow(10,9)+7;
I MAX = LONG_MAX;
I MIN = LONG_MIN;

// 最大公約数
I gcd(I a, I b) {
  return b != 0 ? gcd(b, a % b) : a;
}

// 最小公倍数
I lcm(I a, I b) {
  return a * b / gcd(a, b);
}

int ctoi(char c){
  return c - '0';
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  I m1,d1,m2,d2;
  cin >> m1 >> d1 >> m2 >> d2;
  if (m1 != m2 && m1 < m2){
    cout << 1 << endl;
  }else{
    cout << 0 << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	int A[N];
	for(int &i : A){
		cin >> i;
	}
	int min = A[0];
	int max = A[0];
	for(int i=1; i<N; ++i){
		if( min > A[i] ){
			min = A[i];
		}
		if( max < A[i] ){
			max = A[i];
		}
	}
	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int ans=-1;
    int p[101][101]={};
    int m[101];
    for(int i=0;i<n;++i){
      cin>>m[i];
      for(int j=0;j<m[i];++j) cin>>p[i][j];
    }
    int k, l[101]={};
    bool flag=false, th=false;
    cin>>k;
    for(int i=0;i<k;++i) cin>>l[i];
    for(int i=0;i<n;++i){
      int cnt=0;
      for(int o=0;o<k;++o){
        for(int j=0;j<m[i];++j){
          if(l[o]==p[i][j]) cnt++;
        }
      }
      if(cnt==k){
        if(flag) th=true;
        ans=i+1;
        flag=true;
      }
    }
    if(th) cout<<-1<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3124
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll MOD;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[5000001], invf[5000001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
//ll dp[6060][2020];
ll p2[6060], p3[6060];
int main()
{
	int n;
    cin>>n>>MOD;
    fac(3*n);
	for(int i=0; i<=3*n; i++){
		p2[i]=inv(powmod(2, i)), p3[i]=inv(powmod(3, i));
	}
    ll ans=0;
    for(int i=0; i<=n; i++){
        for(int j=2*i; j<=3*i; j++){
            (ans+=comb(j, 3*(j-2*i))*f[3*(j-2*i)]%MOD*p3[j-2*i]%MOD*invf[j-2*i]%MOD*f[2*(3*i-j)]%MOD*p2[3*i-j]%MOD*invf[3*i-j]%MOD*comb(3*n, j))%=MOD;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2432
#include<iostream>
using namespace std;
static const int MAX_N=100;
int A[MAX_N];
int main(void){
	int N;
		cin >> N;
	for(int i=0;i<N;i++)
		cin >> A[i];
	
	int ans=0;
	bool c;
	while(1){
		int cou=0;
		c=false;
		for(int i=0;i<N;i++){
			if(A[i]>0){
				A[i]--;
				cou++;
				if(!c){
					c=true;
					ans++;
				}
			}else if(c)
				c=false;
		}
		if(cou==0)
			break;
	}
	cout << ans << endl;
	return 0;
}

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

#define ll long long
#define in ({ll x=0;int o=0,c=getchar();for(;!isdigit(c);c=getchar()) o=c=='-';for(;isdigit(c);c=getchar()) x=x*10+c-'0';o?-x:x;})
#define inchar ({char c=getchar();while(c==' '||c=='\n') c=getchar();c;})
#define instring ({string s;char c=getchar();while(c==' '||c=='\n') c=getchar();while(c!=' '&&c!='\n') s+=c,c=getchar();s;})

#define FOR(i,a,b) for(auto i=a;i<=b;i++)
#define ROF(i,a,b) for(auto i=b;a<=i;i--)
#define rr(x) " "<<#x<<'='<<x<<" "

#define bitnum(x) __builtin_popcountll(x)
#define bit(x,i) ((x>>(i-1))&1ll)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1ll<<(i-1)))
#define pow2(x) (1ll<<x)

#define mt make_tuple
#define pi pair<int,int>
#define x first
#define y second

#define VEC(i,a) for(auto&i:a)
#define pb push_back
#define allv(a) a.begin(),a.end()
#define endv(a) (int)a.size()-1

#define ifnot(x) if(!(x))
#define middle(a,b) (a+(b-(a))/2)
#define bp(x) ((x)*(x))
////////////////////////////////////////// HUX
const ll E8=1e8;
main()
{
    ll n=in;
    ll X=sqrt(n);
    ll Y=X;
    if(X*X<n) X++,Y++;

    ll x=1;
    ll y=X*Y-n;
   //cout<<rr(X) rr(Y) rr(x) rr(y) "\n";
    cout<<"0 0 "<<X<<" "<<y<<" "<<x<<" "<<Y;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG

 // 深さ優先探索
vector<bool> seen;
int dfs(const Graph &G, ll v) {
    seen[v] = true; // v を訪問済にする
    int score = 0; 

    // v から行ける各頂点 next_v について
    for (auto next_v : G[v]) { 
        if (seen[next_v]) continue; // next_v が探索済だったらスルー

        // 負荷さ優先探索中の処理



        dfs(G, next_v); // 再帰的に探索, 毎回mat渡してええの？
    }
    return score;
} 

/*
//桁数の計算
ll keta(ll num){
  ll ans= 0 ;
  ll rem;

  for (ll i = 4; i >= 0 ; i--){
    rem = pow(10,i);
    ans += (num / rem); 
    num = num % rem;
  }
  return ans;
}
*/


int main() {
    ll A, B , C, D;
    cin >> A >> B >> C >> D;
    //vector<vector<char>> s(H, vector<char>(W));


    if (B <= C || D <= A) cout << 0 << endl;
    else if (A <= C && D <= B) cout << D-C << endl;
    else if (C <= A && B <= D) cout << B-A << endl;
    else if (C <= A && D <= B) cout << D-A << endl;
    else if (A <= C && B <= D) cout << B-C << endl;


    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		int[][] boxN;
		int[] boxM;
		int[] InputList = new int[2];

		int anser = 0;

		Scanner sc = null;

		try {
			sc = new Scanner(System.in);

			for (int i = 0; i < InputList.length; i++) {
				InputList[i] = sc.nextInt();
			}

			//??????N?????????
			boxN = new int[InputList[0]][InputList[1]];

			for (int i = 0; i < InputList[0]; i++) {

				//N??????????????????
				for (int j = 0; j < InputList[1]; j++) {

					boxN[i][j] = sc.nextInt();
				}
			}

			//??????M?????????
			boxM = new int[InputList[1]];

			for (int i = 0; i < InputList[1]; i++) {
				boxM[i] = sc.nextInt();
			}

			//?¨????
			for (int i = 0; i < InputList[0]; i++) {
				for (int j = 0; j < InputList[1]; j++) {

					anser += boxN[i][j] * boxM[j];
				}
				//???????????????
				System.out.println(anser);
				//????????????
				anser = 0;
			}
		} finally {
			sc.close();
		}

	}

}

Measured memory_bytes: 40276
#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a,long long b){
  if(b==0)return a;
  return gcd(b,a%b);
}
long long lcm(long long a,long long b){
  return a*(b/gcd(a,b));
}
int main(){
  long long a,b;cin>>a>>b;
  string s,t;cin>>s>>t;
  long long c=lcm(a,b);
  long long f=gcd(a,b);
  long long d=0,e=0;
  for(int i=0;i<gcd(a,b);i++){
    if(s.at(d)!=t.at(e)){
      puts("-1");
      return 0;
    }
    d+=a/f;
    e+=b/f;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define int  long long
#define tc(t)  int t; cin>>t; while(t--)
#define f(n)    for(int i=0;i<n;i++)
#define endl   "\n"
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     int a,b;
     cin>>a>>b;
     if(a>8||b>8) cout<<":("<<endl;
     else cout<<"Yay!"<<endl;


}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

int main(){
    ll n;cin>>n;
    string s;
    ll ans=0;
    rep(i,1,n){
        s=to_string(i);
        if(s.size()%2==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H)cout << "Yes\n";
	else cout << "No\n";
		return 0;
}



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

int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,x;
    map<int,int> mp;
    while(cin >> n)
    {
        mp.clear();
        for(int i = 0; i < n; i++)
        {
            cin >> x;
            mp[x] = mp[x-1] + 1;
        }
        int ans = n;
        for(auto it : mp)
            ans = min(ans, n - it.second);
        cout << ans << '\n';
    }    
    return 0;
}

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

int main()
{
    int h, w;
    
    while(1) {
        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%2)) {
                    if(!(j%2)) {
                        cout << '#';
                    }else {
                        cout << '.';
                    }
                }else {
                    if(!(j%2)) {
                        cout << '.';
                    }else {
                        cout << '#';
                    }
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 3076
package main

import "fmt"

func main() {
	maxGram := 5000
	// store := map[int]int{
	// 	1500: 2244, // 500 * 3
	// 	1200: 1870, // 300 * 4
	// 	1000: 1520, // 200 * 5
	// 	500:  850,
	// 	300:  550,
	// 	200:  380,
	// }

	for {
		var gram int
		fmt.Scanf("%d", &gram)

		if gram == 0 {
			return
		}

		var minPrice int

		// (x * 200) + (y * 300) + (z * 500) == gram
		for x := 0; (x * 200) <= maxGram; x++ {
			for y := 0; (y * 300) <= maxGram; y++ {
				for z := 0; (z * 500) <= maxGram; z++ {
					if (x*200)+(y*300)+(z*500) == gram {
						price := 0
						price += (z / 3) * 2244
						price += (z % 3) * 850
						price += (y / 4) * 1870
						price += (y % 4) * 550
						price += (x / 5) * 1520
						price += (x % 5) * 380

						if price < minPrice || minPrice == 0 {
							minPrice = price
						}
					}
				}
			}
		}

		fmt.Println(minPrice)
	}
}

// 1 袋あたりの量			200g	300g	500g
// 1 袋の単価(定価)		380円	550円	850円
// 割引が適用される単位		5袋毎	4袋毎	3袋毎
// 割引率							20%引き	15%引き	12%引き



Measured memory_bytes: 1088