akhauriyash/Code-Regression huggingface dataset:
/** 
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

#include <bits/stdc++.h>
using namespace std;

/* see https://github.com/pllk/cphb/
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
    tree_order_statistics_node_update> indexed_set;
 **/

typedef long long ll;
#define endl "\n"
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }

//typedef __int128 lll;
typedef pair<int, int> pii;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

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

    int ans=0;
    for(int i=1; i<=m; i++) {
        for(int j=10; j<=d; j++) {
            if(j%10>=2 && j/10>=2 && (j%10)*(j/10)==i)
                ans++;
        }
    }
    cout<<ans<<endl;
    
}



Measured memory_bytes: 256
n,k=map(int,input().split())
if k==0:
  print(n*n)
else:
  ct=0
  for i in range(1,n-k+1):
    ct+=i
  for j in range(k+1,n):
    ct+=((n-j)//j)*(j-k)
    ct+=max(0,(n-j)%j-k+1)
  print(ct)

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

int main(){
  string N;
  bool b = 1;
  cin >> N;
  int K = N.size();
  int c = N.at(0)-'0';
  for(int i=1;i<N.size();++i){
    if(N.at(i)!='9'){
      b=0;
      break;
    }
  }
  if(b){
    cout << c + 9*(K-1) << endl;
  }else{
    cout << c + 9*(K-1)-1 << endl;
  }
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

void solve(){
  ll n;cin>>n;
  ll num=0;
  ll ans=0;
  rep(i,n){
    ll a=0;cin>>a;
    ans+=max(a-num,(ll)0);
    num=a;
  }
  cout<<ans<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007
const int N=200005;

 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    /*#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif*/
    cout<<fixed<<setprecision(15);
    
    int n,k;
    cin>>n>>k;
    int cnt=0;
    int a[n];
    for(int i=0;i<n;i++) {
        cin>>a[i];
        if(a[i]>=k) cnt++;
    }
    cout<<cnt;
    
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int 
#define ull unsigned long long int 
#define ld long long double 
#define endl '\n'
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define print(v) for(auto x:v) cout<<x<<" ";
#define printf(v) for(auto x:v) cout<<x.first<<" "<<x.second<<endl;
using namespace std;
int main(){
fastio;
int a;
cin>>a;
vector<int>v;
for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
        v.pb(i*j);
    }
}
bool flag=false;
for(int x=0;x<v.size();x++){
    if(v[x]==a){
        flag=true;
        break;
}
}
if(flag) cout<<"Yes";
else cout<<"No";
return 0;
}
        
        

Measured memory_bytes: 256
x, n = map(int, input().split())
p = list(map(int, input().split()))
l = sorted(p)
new = []
t = x in l

if t == False:
    re = x #n = 0でよかった。ここでは、listの中にxがなかったときにreにxを入れている。
else:
    for i in range(len(l)):
        TorF_1 = x + i + 1 in l
        TorF_2 = x - i - 1 in l
        if TorF_2 == False:
            re = x - i - 1
            break

        elif TorF_1 == False:
            re = x + i + 1
            break
    
print(re)


Measured memory_bytes: 61716
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<string,int> &a, 
              const pair<string,int> &b) 
{ 
	bool x = false;
	if( a.second > b.second  && a.first < b.first ) {
		x = true;
	}
    return x;
}
int main(){
	
	int n;
	cin>>n;
	int ans = (n-2)*180;
	cout<<ans<<"\n";
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in);) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int k = sc.nextInt();

			for (int i = a; i <= b; i++) {
				if (i < (a + k) || (b - k) < i) {
					System.out.println(i);
				}
			}
		}
	}
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

void func(long long X)
{
    cout << (X / 500) * 1000 + (X % 500) / 5 * 5 << endl;
}

int main()
{
    // cout << fixed << setprecision(5);

    long long X;
    scanf("%lld", &X);
    func(X);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
using namespace std;
typedef long long ll;

int vs[300];

int main(void) {
  int n;
  cin >> n;
  REP(i, 2*n) {
    cin >> vs[i];
  }
  sort(vs, vs + 2*n);
  int res = 0;
  REP(i, n) {
    res += min(vs[2*i], vs[2*i+1]);
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 764
N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

dp_v = [0] * (W+1)

for i in range(N):
    for j in (reversed(range(W+1))):
        if (j == 0 or dp_v[j] != 0) and j+w[i] <= W and dp_v[j+w[i]] < dp_v[j] + v[i]:
            dp_v[j+w[i]] = dp_v[j] + v[i]
            
max = 0        
for i in range(W+1):
    if max < dp_v[i]:
        max = dp_v[i]

print(max)

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

using namespace std;

int main()
{
    int N,ans=0;
    int L[105];
    cin>>N;
    for(int l=1; l<=N; l++)
    {
        cin>>L[l];
    }
    for(int i=1; i<=N-2; i++)
    {
        for(int j=i+1; j<=N-1; j++)
        {

            for(int k=j+1; k<=N; k++)
            {
                if((L[i]!=L[j])&&( L[i]!=L[k]) && (L[j]!=L[k])&& (L[i]+L[j]>L[k] )&& (L[i]+L[k]>L[j] )&&( L[j]+L[k]>L[i] ))
                {
                    ans++;
                }
            }

        }
    }

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


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

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

    vector<char> c(n + 1);
    int r = 0;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        if (a == 1) {
            if (c[b]) {
                r = 1;
                break;
            }
            c[b] = 1;
        }
        if (b == n) {
            if (c[a]) {
                r = 1;
                break;
            }
            c[a] = 1;
        }
    }

    cout << (r ? "POSSIBLE" : "IMPOSSIBLE") << endl;

    return 0;
}

Measured memory_bytes: 512
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# Ciの値でsortする、Tを0000で固定した後、最後に2**N倍
N = ir()
C = np.array(lr())
MOD = 10 ** 9 + 7
C.sort()
# N-2がマイナスになる時に注意、一番右は2**(N-1)
two_power = np.array([(1+N-i) * pow(2, (N-2), MOD) % MOD if i < N-1 else pow(2, i, MOD) for i in range(N)])
answer = (C * two_power % MOD).sum() % MOD * pow(2, N, MOD)
print(answer%MOD)


Measured memory_bytes: 34488
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=1e9+7;
const int inf=1<<30;

int n;
vector<vector<int> > to;
vector<int> point;
priority_queue<int> q;
void dfs(int v,int p=-1){
  point[v]=q.top();
  q.pop();
  rep(i,to[v].size()){
    int nv=to[v][i];
    if(nv==p) continue;
    dfs(nv,v);
  }
}
int main(){
  cin >> n;
  to.resize(n,vector<int>(0));
  point.resize(n);
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ll score=0;
  rep(i,n){
    int c; cin >> c;
    q.push(c);
    score+=c;
  }
  score-=q.top();
  cout << score << endl;
  dfs(0);
  rep(i,n){
    cout << point[i] << " ";
  }cout << endl;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	int hit,blow;
	char num[11];
};

vector<Info> info;
int Keta,num_candidate;
ll POW[12] = {1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000,100000000000};
ll ans;

int calc_hit(char left[11],char right[11]){

	int hit = 0;

	for(int i = 0; i < Keta; i++){
		if(left[i] == right[i])hit++;
	}
	return hit;
}

int calc_blow(char left[11],char right[11],int right_num){

	int blow = 0;

	int check_left[10];
	for(int i = 0; i < 10; i++)check_left[i] = -1;
	for(int i = 0; i < Keta; i++){
		check_left[left[i]-'0'] = i;
	}

	for(int i = 0; i < right_num;i++){
		if(check_left[right[i]-'0'] != -1 && check_left[right[i]-'0'] != i)blow++;
	}
	return blow;
}



void recursive(char buf[11],bool used[10],int count){
	if(num_candidate > 1)return;

	bool FLG;

	if(count == Keta){

		FLG = true;
		for(int i = 0; i < info.size(); i++){
			if(calc_blow(info[i].num,buf,count) != info[i].blow || calc_hit(info[i].num,buf) != info[i].hit){
				FLG = false;
				break;
			}
		}

		if(FLG){
			num_candidate++;
			if(num_candidate >= 2){
				return;
			}
			ans = 0;
			for(int i = 0; i < count; i++){
				ans = 10*ans + buf[i] - '0';
			}
		}

		return;
	}

	//blow???????¨????:?°?????????¨???1??¶,blow?????£?§£???????????§???????????§????????°???return
	FLG = true;
	int blow;
	for(int i = 0; i < info.size(); i++){
		if((blow = calc_blow(info[i].num,buf,count)) > info[i].blow || blow+(Keta-count) < info[i].blow){
			FLG = false;
			break;
		}
	}
	if(!FLG)return;

	for(int i = 0; i < 10; i++){
		if(!used[i]){
			char next_buf[11];
			bool next_used[10];
			for(int k = 0; k < Keta; k++)next_buf[k] = buf[k];
			next_buf[count] = '0' + i;
			for(int k = 0; k < 10; k++)next_used[k] = used[k];
			next_used[i] = true;
			recursive(next_buf,next_used,count+1);
		}
	}
}

void func(int H){

	info.clear();

	num_candidate = 0;

	for(int loop = 0; loop < H; loop++){
		Info data;
		scanf("%s %d %d",data.num,&data.hit,&data.blow);
		info.push_back(data);
	}

	char buf[11];
	bool used[10];
	for(int i = 0; i < 10; i++)used[i] = false;
	recursive(buf,used,0);

	if(num_candidate == 1){
		ll tmp = POW[Keta-1];
		if(tmp > ans){
			printf("0");
		}
		printf("%lld\n",ans);
	}else{
		printf("NO\n");
	}
}


int main(){

	int H;

	while(true){
		scanf("%d %d",&Keta,&H);
		if(Keta == 0 && H == 0)break;

		func(H);
	}
	return 0;
}

Measured memory_bytes: 3140
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int gcd(int a, int b) {
  // assert(a >= b);
  if (a % b == 0) {
    return b;
  }
  return gcd(b, a % b);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, X;
  cin >> N >> X;
  vector<int> xs;
  for (int i = 0; i < N; ++i) {
    int xi;
    cin >> xi;
    xs.push_back(xi);
  }

  vector<int> diffs;
  for (auto &e : xs) {
    diffs.push_back(abs(X - e));
  }
  sort(diffs.rbegin(), diffs.rend());

  int ans = INT_MAX;
  int first = diffs[0];
  for (int i = 0; i < N; i++) {
    ans = min(ans, gcd(first, diffs[i]));
  }

  cout << ans << "\n";
  return 0;
}

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

public class Main {
public static void main(String[] args)throws IOException{

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String str = reader.readLine();
String[]abc =str.split(" ");
int a =Integer.parseInt(abc[0]);
int b =Integer.parseInt(abc[1]);
int c = Integer.parseInt(abc[2]);

Arrays.sort(abc);

System.out.println(abc[0]+" "+abc[1]+" "+abc[2]);
}
}

Measured memory_bytes: 24452
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back 
const int N = 1e5;
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n; 
	cin>>n; 
	ll x,y;
	cin>>x>>y;
	for(int i=1;i<n;i++){
		ll a,b; 
		cin>>a>>b; 
		ll nx = (x+a-1)/a;
		ll ny = (y+b-1)/b;
		ll d = max(nx,ny);
		x = d*a;
		y = d*b;
	}
	cout<<x+y<<endl;
	return 0;
}


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

int main(void){
    string s,t;
    cin >> s >> t;
    int count = 0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]) count++;

    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		sc.close();

		System.out.println(n * (n - 1) / 2 + m * (m - 1) / 2);
	}
}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;
const long long inf = 1e12;

const long long mod = 1e9 + 7;
vvi g;
int n, k;
long long dfs(int now, int from)
{
	int colors = 0;
	if (from == -1)
		colors = k - 1;
	else
		colors = k - 2;
	long long res = 1;
	if (k < sz(g[now]))
		return 0;
	for (int i = 0; i < sz(g[now]); i++)
	{
		int v = g[now][i];
		if (v == from)
			continue;
		res = res * colors % mod;
		colors--;
	}
	for (int i = 0; i < sz(g[now]); i++)
	{
		int v = g[now][i];
		if (v == from)
			continue;
		res = res * dfs(v, now) % mod;
	}
	return res;
}

int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); cout << setprecision(18) << fixed;
	
	cin >> n >> k;
	g.resize(n);
	for (int i = 0; i < n - 1; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);

	}
	long long res = 1LL * k * dfs(0, -1) % mod;
	cout << res;
	return 0;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
int A[101];
int memo[1010101];

int win(int K) {
	if(K<=0) return 0;
	if(memo[K]>=0) return memo[K];
	int i;
	FOR(i,N) if(A[i]<=K && win(K-A[i])==0) return memo[K]=1;
	return memo[K]=0;
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	MINUS(memo);
	cin>>N>>K;
	FOR(i,N) cin>>A[i];
	
	if(win(K)) cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 7296
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <time.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,string> pip;
typedef vector<pip> vip;
const int inf=2*1e9+1;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

class Trie{
	private:
	const int MAX=400005;
	int ID=1;
	vvi date;
	vi u,v;
	public:
	Trie(){
		date=vvi(MAX,vi(26,-1));
		u=v=vi(MAX);
	}
	void Update(string s){
		int S=s.size(),I=0;
		for(int i=0;i<S;i++){
			int c=s[i]-'a';
			if(date[I][c]==-1) date[I][c]=ID++;
			I=date[I][c];
			u[I]++;
		}
		v[I]++;
	}
	int Find(string s){
		int S=s.size(),I=0,res=-1;
		for(int i=0;i<S;i++){
			I=date[I][s[i]-'a'];
			res+=v[I];
		}
		return res;
	}
	vvi solve(string s){
		vvi a(26,vi(26));
		int S=s.size(),I=0;
		for(int i=0;i<S;i++){
			int c=s[i]-'a';
			for(int j=0;j<26;j++) if(j!=c&&date[I][j]!=-1) a[j][c]+=u[date[I][j]];
			I=date[I][c];
		}
		return a;
	}
};

int n,q;
vs a,t;

int main(){
	cin>>n;
	a=vs(n);
	vi b(n);
	vvi c(26);
	Trie trie;
	for(int i=0;i<n;i++){
		cin>>a[i];
		trie.Update(a[i]);
	}
	for(int i=0;i<n;i++) b[i]=trie.Find(a[i]);
	cin>>q;
	t=vs(q);
	vp d(q);
	vi res(q);
	for(int i=0;i<q;i++){
		int k;
		cin>>k>>t[i];
		d[i]={k-1,i};
	}
	sort(d.begin(),d.end());
	for(int i=0;i<q;i++){
		int k=d[i].first,I=d[i].second;
		string s=t[I];
		if(!i||k!=d[i-1].first) c=trie.solve(a[k]);
		res[I]=b[k];
		for(int j=0;j<26;j++) for(int l=0;l<j;l++) res[I]+=c[s[l]-'a'][s[j]-'a'];
	}
	for(int i=0;i<q;i++) cout<<res[i]+1<<endl;
}

Measured memory_bytes: 72704
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long inf = 4523372036854775807;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int x, y, z;
	cin >> x >> y >> z;
	x -= z;
	cout << floor(x*1.0 / (y + z)) << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	string s;
	cin>>s;
	int ans=0,cnt=0;
	f(i,s.size()){
		if(s[i]=='A'){
			cnt++;
		}
		if(cnt&&s[i]=='C'&&s[i-1]=='B')ans+=cnt;
		if(cnt&&s[i]=='C'&&s[i-1]!='B')cnt=0;
		if(cnt&&s[i]=='B'&&s[i-1]=='B')cnt=0;
		if(cnt&&s[i]=='A'&&s[i-1]=='B')cnt=1;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
from collections import deque
N, M = map(int, input().split())
F_C_of_S = [{} for i in range(N)]
#Companies of Station
C_of_S = {}

#def Union-find
parent = [-1]*M
def root(x):
	if (parent[x] < 0): return x
	else:
		parent[x] = y = root(parent[x])
		return y

def unite(x, y):
	px = root(x)
	py = root(y)
	if (px == py): return False
	if (parent[px] > parent[py]):
		px = root(y)
		py = root(x)
	parent[px] += parent[py]
	parent[py] = px
	return True


#Union-find
pqcs = []
for i in range(M):
	p, q, c = map(int, input().split())
	p -= 1; q -= 1;
	pqcs += [(p, q, c)]
	
	#The first
	if not c in F_C_of_S[p]: F_C_of_S[p][c] = i
	#else
	else: unite(F_C_of_S[p][c], i)
	C_of_S.setdefault(p, set()).add(c)
	
	#The first
	if not (c in F_C_of_S[q]):F_C_of_S[q][c] = i
	#else
	else: unite(F_C_of_S[q][c], i)
	C_of_S.setdefault(q, set()).add(c)

#stations of company
S_of_C = {}
for i in range(M):
	p, q, c = pqcs[i]
	c_set = S_of_C.setdefault(root(i), set())
	c_set.add(p)
	c_set.add(q)


Q = deque([(0, 0, 0)])
#cost to go to the stations from station_0
dist = [float('inf')]*N
dist[0] = 0

gdist = [float('inf')]*M

while Q:
	cost, v, flag = Q.popleft()
	
	if not (flag):#(flag == 0) then gdist_update
		if (dist[v] < cost) or (v not in C_of_S):
			continue
		for l in F_C_of_S[v].values():
			l = root(l)
			if (cost < gdist[l]):
				gdist[l] = cost
				Q.appendleft((cost, l, 1))
	
	else:#(flag == 1) then dist_update
		if (gdist[v] < cost) or (v not in S_of_C):
			continue
		for s in S_of_C[v]:
			if (cost+1 < dist[s]):
				dist[s] = cost+1
				Q.append((cost+1, s, 0))

print(dist[N - 1] if dist[N - 1] < float('inf') else -1)

Measured memory_bytes: 196920
A = list(map(str,input().split()))
Stack = []
for e in A:
    if e.isdigit():
        Stack.append(int(e))
    else:
        right = Stack.pop()
        left = Stack.pop()
        if e == "+":
            Stack.append(left+right)
        elif e == "-":
            Stack.append(left-right)
        elif e == "*":
            Stack.append(left*right)
        else:
            if right != 0:
                Stack.append(left//right)
            else:
                print("0?????????")
                exit()

print(Stack.pop())

Measured memory_bytes: 7724
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <chrono>
#include <random>
#include <iomanip>
#include <ctime>
#include <chrono>
#include <cstdlib>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pb push_back
#define sz(x) (int)(x).size()
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define per(i, a, b) for (int i = a; i >= b; i--)
#define au(i, x) for (auto&i : x)
typedef long double ld;
typedef long long ll;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int  a, b, c;
	cin >> a >> b >> c;
	cout << c << ' ' << a << ' ' << b;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

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

import queue

def main():
    N=I()
    adj=[[] for _ in range(N)]
    mod1=range(1,N+1,3)
    n1=0
    mod2=range(2,N+1,3)
    n2=0
    mod12=list(mod1)+list(mod2)
    n12=0
    mod3=range(3,N+1,3)
    n3=0
    
    p=[0]*N
    
    for i in range(N-1):
        a,b=MI()
        a-=1
        b-=1
        adj[a].append(b)
        adj[b].append(a)
     
    
    q=queue.Queue()
    q.put((0,-1,0))#node,par,depth
    d=[0]*N#深さをメモ
            
        
    while not q.empty():
        v,par,depth=q.get()
        d[v]=depth%2
                
        for i in range(len(adj[v])):
            nxt=adj[v][i]
            if nxt!=par:
                q.put((nxt,v,depth+1))
                
    dmod=[0,0]
    for i in range(N):
        dmod[d[i]]+=1
        
    if dmod[0]<=(N//3):
        for i in range(N):
            if d[i]==0:
                p[i]=mod3[n3]
                n3+=1
            else:
                if n12<len(mod12):
                    p[i]=mod12[n12]
                    n12+=1
                else:
                    p[i]=mod3[n3]
                    n3+=1
    elif dmod[1]<=(N//3):
        for i in range(N):
            if d[i]==1:
                p[i]=mod3[n3]
                n3+=1
            else:
                if n12<len(mod12):
                    p[i]=mod12[n12]
                    n12+=1
                else:
                    p[i]=mod3[n3]
                    n3+=1         
    
    else:
        for i in range(N):
            if d[i]==1:
                if n1<len(mod1):
                    p[i]=mod1[n1]
                    n1+=1
                else:
                    p[i]=mod3[n3]
                    n3+=1
            else:
                if n2<len(mod2):
                    p[i]=mod2[n2]
                    n2+=1
                else:
                    p[i]=mod3[n3]
                    n3+=1     
    
                
    print(' '.join(map(str, p)))
        
        
    
    
        
                
            
        
        
    

main()


Measured memory_bytes: 126576
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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



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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef unsigned long long ul;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> Pair;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18;

int island[14][14];
bool went[14][14];
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

int main() {
    while(1) {
        string temp[12];
        REP(i, 12) if(!(cin >> temp[i])) return 0;
        FOR(i, 1, 13) {
            FOR(j, 1, 13) {
                if(temp[i - 1][j - 1] == '1') island[i][j] = 1;
            }
        }
        queue<Pair> q;
        ll ans = 0;
        FOR(i, 1, 13) FOR(j, 1, 13) {
            if(island[i][j]) {
                q.push({i, j});
                island[i][j] = 0;
                while(!q.empty()) {
                    Pair now = q.front();
                    q.pop();
                    REP(i, 4) {
                        if(island[now.first + dx[i]][now.second + dy[i]]) {
                            q.push({now.first + dx[i], now.second + dy[i]});
                            island[now.first + dx[i]][now.second + dy[i]] = 0;
                        }
                    }
                }
                ans++;
            }
        }
        cout << ans << "\n";
    }
}



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

int main(){

  long long ans=1, num[100002];
  long long N,M;
  cin >> N >> M;
  long long a[M];
  for(long long i=0; i<M; i++){
    cin >> a[i];
    if(i>0 && (a[i] == a[i-1]+1) || a[i]==a[i-1]){
      cout << "0" << endl;
      return 0;
    }
  }

  num[0]=1;
  num[1]=1;
  num[2]=1;
  for(long long i=3; i<100002; i++){
    num[i] = num[i-1] + num[i-2];
    num[i] %= 1000000007;
  }

  if(M==0){
    cout << num[N+1] << endl;
    return 0;
  }

  ans *= num[a[0]];
  ans %= 1000000007;
  ans *= num[N-a[M-1]];
  ans %= 1000000007;

  for(long long i=1; i<M; i++){
    ans *= num[a[i]-a[i-1]-1];
    ans %= 1000000007;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	string temp;
    char c1,c2,c3;
    cin>>temp;
    for(int i=0;i<temp.size()-1;i++)
    {
        if(temp[i]==temp[i+1])
        {
            cout<<i+1<<' '<<i+2;
            return 0;
        }
        if(i+3<=temp.size()&&temp[i]==temp[i+2])
        {
            cout<<i+1<<' '<<i+3;
            return 0;
        }
        
    }
    cout<<-1<<' '<<-1;
	return 0;
}

Measured memory_bytes: 3240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,i;
    cin>>n;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    if(n%2!=0)
    {
        cout<<0;
    }
    else
    {
        sort(a,a+n);
        cout<<a[n/2]-a[n/2-1];
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cstring> 
using namespace std;
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mpp make_pair
#define int long long int
#define F first
#define mem(a,b) memset(a,b,sizeof(a))
#define F first
#define S second
#define MOD 998244353
#define in_range(x, y, r, c) (x < r && y < c && x >= 0 && y >= 0)
#define MAXN 2000000
#define MAXI 10000000000007


signed main(){
 
    fast;
    
    #ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int n, sum=0, i, j;
    cin>>n;
    int r[n+1], g[n+1], b[n+1];
    r[n]=0;
    b[n]=0;
    g[n]=0;
    string s;
    cin>>s;
    for(i=n-1;i>=0;i--){
    	r[i]=r[i+1];
    	g[i]=g[i+1];
    	b[i]=b[i+1];
    	if(s[i]=='R')
    		r[i]++;
    	if(s[i]=='G')
    		g[i]++;
    	if(s[i]=='B')
    		b[i]++;
    }
    for(i=0;i<n-2;i++){
    	for(j=i+1;j<n-1;j++){
    		char ch;
    		if(s[i]==s[j])
    			continue;
    		if(s[i]=='R'&&s[j]=='G'){
    			ch = 'B';
    		}
    		if(s[i]=='R'&&s[j]=='B'){
    			ch = 'G';
    		}
    		if(s[i]=='G'&&s[j]=='R'){
    			ch = 'B';
    		}
    		if(s[i]=='G'&&s[j]=='B'){
    			ch = 'R';
    		}
    		if(s[i]=='B'&&s[j]=='R'){
    			ch = 'G';
    		}
    		if(s[i]=='B'&&s[j]=='G'){
    			ch = 'R';
    		}
    		if(2*j-i<n&&s[2*j-i]==ch){
    			if(ch=='R')
    				sum+=r[j+1]-1;
    			if(ch=='G')
    				sum+=g[j+1]-1;
    			if(ch=='B')
    				sum+=b[j+1]-1;
    		}
    		else{
    			if(ch=='R')
    				sum+=r[j+1];
    			if(ch=='G')
    				sum+=g[j+1];
    			if(ch=='B')
    				sum+=b[j+1];
    		}
    	}
    }
    cout<<sum<<endl;	
}

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

int main(){
    int n,i = 0,ans=200000,cb[200000],cw[200000];
    string s;
    cin >> n >> s;
    for(int i = 0;i < n;i ++){
        int x=0,y=0;
        if(s[i]=='.') x=1;
        else y=1;
        cb[i] = i?cb[i-1]+x:x;
        cw[i] = i?cw[i-1]+y:y;
    }
    for(int i = 0;i < n;i ++){
        ans = min(ans,i?cb[n-1]-cb[i-1]+cw[i-1]:cb[n-1]);
    }
    ans = min(ans,cw[n-1]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
#include<cstdio>
#include<algorithm>
#pragma warning(disable:4996)
using namespace std;
int n, k[99999999];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) { scanf("%d", &k[i]); }
	sort(k, k + n);
	for (int i = 0; i < n; i++) {if (i) { printf(" "); }printf("%d", k[i]); }
	printf("\n");
	return 0;
}

Measured memory_bytes: 9220
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    ll n;cin>>n;
    cout<<(n-1)*n/2<<endl;
    
}

Measured memory_bytes: 256
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
#define dcml(n) fixed<<setprecision(n)
//CONST
//------------------------------------------
const ll INF=1010000000000000017LL;
const ll MOD=1000000007LL;
const ld EPS=1e-12;
const ld PI=3.14159265358979323846;
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define  FORS(i,m,n) for(ll (i)=(m);   (i)<=(n); (i)++)
#define  RFOR(i,m,n) for(ll (i)=(n)-1; (i)>=(n); (i)--)
#define RFORS(i,m,n) for(ll (i)=(n);   (i)>(n);  (i)--)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define WREPS(i,in,j,jn) REPS(i,in)REPS(j,jn)
//-----------------------------------------
//namespace
using namespace std;
//ライブラリはここに
//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

//-----------------------------------------
struct Edge{
    ll to;
};
vector<Edge> G[100];
ll N,d[100];
typedef pair<ll,ll> P;
void bfs(ll i){
    REP(i,N)d[i]=-1;
    queue<P> que;
    que.push(make_pair(0ll,0ll));
    d[0]=0;
    while(!que.empty()){
        P q=que.front();que.pop();
        //cout<<q.first+1<<":";
        for(auto r:G[q.first]){
            if(d[r.to]!=-1){
                //cout<<"continue";
                continue;
            }
            d[r.to]=q.second+1;
            //cout<<r.to+1<<" ";
            que.push(make_pair(r.to,q.second+1));
        }//cout<<"\n";
    }
}
int main(void){
    cin>>N;
    REP(i,N){
        ll idx,k;cin>>idx>>k;
        REP(j,k){
            ll to;cin>>to;to--;
            G[i].push_back({to});
        }
    }
    bfs(0);
    REP(i,N){
        cout<<i+1<<" "<<d[i]<<"\n";
    }
}


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

int main() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(N + 1);
  for (int i = 0; i < M; ++i) {
    int ai, bi;
    cin >> ai >> bi;
    A[ai].push_back(bi);
  }
  bool flg = false;
  for (int i = 0; i < A[1].size(); ++i) {
    int dist = A[1][i];
    for (int j = 0; j < A[dist].size(); ++j) {
      if (A[dist][j] == N) {
        flg = true;
        break;
      }
    }
    if (flg) {
      break;
    }
  }
  
  if (flg) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long a,b,c,d,e;
  cin>>a>>b>>c;
  if((c-a-b)<0){
    cout<<"No"<<endl;
  }
  else{
  d=4*a*b;
  e=(c-a-b)*(c-a-b);
    if(d<e){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <numeric>
#include <iomanip>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10
#define MAX_N 20000
#define MAX_M 16

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int q, c, a, n;

int main(){
	cin >> q;
	REP(i, q){
		int co = 0;
		cin >> c >> a >> n;
		while (c > 0 && a > 0 && n > 0){
			co++;
			c--;
			a--;
			n--;
		}
		while (c > 1 && a > 0){
			co++;
			c -= 2;
			a--;
		}
		while (c > 2){
			co++;
			c -= 3;
		}
		cout << co << endl;
	}

}

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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  
  int maximum = max(max(A, B), C);
  
  if (maximum == A)
    cout << A * 10 + B + C << endl;
  else if (maximum == B)
    cout << B * 10 + A + C << endl;
  else
    cout << C * 10 + A + B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec[i];
  }
  sort(vec.begin(),vec.end());
  
  cout<<vec[N-1]-vec[0]<<endl;
}

Measured memory_bytes: 3524
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;



signed main(){
  int n,a,b;
  cin>>n>>a>>b;
  int dif=b-a-1;
  cout<<(dif%2==1?"Alice":"Borys")<<endl;
  return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  int ans = 0;
  if(n == 1){
    cout << m << endl;
    return 0;
  }
  for(int i=1;i*i <= m;i++){
    if(m%i) continue;
    int div1 = i;
    int div2 = m/i;
    if(m/div1 >= n) ans = max(ans,div1);
    if(m/div2 >= n) ans = max(ans,div2);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        if (n%k == 0) {
            System.out.println(0);
        }else{
            System.out.println(1);
        }
    }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
typedef     unsigned long long  ull;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define yes cout << "YES\n"
#define no cout<<"NO\n"
//#define sort(x) sort(x.begin(), x.end())
//sort(a,a+n,greater<ll>())
//for (auto it = mp.begin(); it != mp.end(); ++it){}
#define MAX 1000005
#define mod 1000000007



int main()
{
 //O_O ;
 ll c=100;
   ll t;
   cin>>t;
 for(ll i=1;;i++)
 {
     ll temp=c/100;
     c+=temp;
     if(c>=t)
     {
         cout<<i<<nn;
         break;
     }

 }


    return 0;
}


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

int main() {
  int N;
  cin >> N;
  long ans = 0;
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      for (int k = 1; k <= N; k++) ans += gcd(gcd(i, j), k);
  cout << ans << "\n";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define SORT(v) sort(v.begin(),v.end())
#define fori(i,a,b) for(ll i=a;i<b;i++)
#define M 1000000007
#define deb(x) cout<< #x << " " << x << endl;

double pi=3.14159265358979323846;

typedef pair<int,int> pii;
typedef pair<long long int, long long int>pll;
typedef vector<int>vi;
typedef vector<long long int>vl;
#define M 1000000007



int main ()
{
    ll T;
   T=1;
   //cin>>T;
    while(T--)
    {	
   ll n,wtl;
   cin>>n>>wtl;
   vl v(n+1),w(n+1);
   fori(i,1,n+1){cin>>w[i]>>v[i];}
   ll x=0;
   fori(i,1,n+1){x+=v[i];}
   vl dp(x+1,INT_MAX);
   dp[0]=0;
   for(ll item=1;item<=n;item++){
   	for(ll val=x;val>=0;val--){
   		if(val<v[item]){continue;}
   		else{
   			dp[val]=min(dp[val],dp[val-v[item]]+w[item]);
   		}
   	}
   }
   ll ans=-1;
   for(ll i=0;i<=x;i++){
   	if(dp[i]<=wtl)ans=i;
   }
   cout<<ans<<endl;
   
    
    }
    return 0;
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
int main(){
	int q,c,a,n;
	cin>>q;
	while(q--){
		int ans=0;
		cin>>c>>a>>n;
		int cnt=min(c,min(a,n));
		ans+=cnt;
		c-=cnt;a-=cnt;n-=cnt;
		cnt=min(c/2,a);
		ans+=cnt;
		c-=cnt*2;a-=cnt;
		ans+=c/3;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1160