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

int main() {
    int N; int64_t K; cin >> N >> K;
    vector<int> A(N);
    for(auto &e : A) cin >> e, e--;
    vector<int> n(N, -1);
    int cur = 0, cnt = 0;
    while(n[cur] == -1) {
        n[cur] = cnt;
        cnt++;
        cur = A[cur];
        if(cnt == K) {
            cout << cur + 1 << '\n';
            return 0;
        }
    }
    int d = cnt - n[cur];

    K -= cnt;
    K %= d;

    int t = n[cur];
    for(int i = 0; i < N; ++i) {
        n[i] -= t;
    }

    for(int i = 0; i < N; ++i) {
        if(n[i] == K) {
            cout << i + 1 << '\n';
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 4844
use proconio::input;

fn main() {
    input! {
        r: isize,
        g: isize,
        b: isize,
        n: isize,
    }

    let mut ans = 0;

    for i in 0..=n {
        for j in 0..=n {
            let rem = n - i * r - j * g;
            if rem >= 0 && rem % b == 0 {
                ans += 1;
            }
        }
    }

    println!("{}", ans);
}


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

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int main() {
    char b;
    cin >> b;

    if (b == 'A') cout << 'T' << endl;
    else if (b == 'T') cout << 'A' << endl;
    else if (b == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100005;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,c = 0,a;
    cin >> n >> m;
    rep(i,m){
        cin >> a;
        c += a;
    }
    if (c > n) PRINT(-1);
    else PRINT(n-c);
}


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

using namespace std;

int main(void) {
  long long N;
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }

  long long count = 0;
  for (int i = 0; i < N; i++) {
    string::size_type pos = s[i].find("AB");
    while (pos != string::npos) {
      count++;
      pos = s[i].find("AB", pos + 2);
    }
  }

  long long countB = 0;
  long long countA = 0;
  long long countAB = 0;
  for (int i = 0; i < N; i++) {
    if (s[i][0] == 'B' && s[i][s[i].length() - 1] == 'A') {
      countAB++;
    } else if (s[i][s[i].length() - 1] == 'A') {
      countA++;
    } else if (s[i][0] == 'B') {
      countB++;
    }
  }

  if (countAB == 0) {
    cout << count + min(countA, countB) << endl;
  } else if (countA + countB > 0) {
    cout << count + countAB + min(countA, countB) << endl;
  } else {
    cout << count + countAB - 1 << endl;
  }
}


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

int main(){
  int N,i;
  float A[110] ;
  float sum=0;

  cin >> N ;

  for(i=0;i<N;i++){
    cin >> A[i] ;
  }

  for(i=0;i<N;i++){
	sum = sum + 1/A[i] ;
  }

  cout << 1/sum << endl;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define inputv(arr,n) for(ll i=0;i<n;i++){ll value;cin>>value;arr.pb(value);}
#define sz(a) ((ll)(a).size())
#define len(a) ((ll)(a).length())
#define precise cout<<fixed<<setprecision(0); 
#define F first
#define S second
#define vi vector <int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define YES cout<<"Yes\n"
#define NO cout<<"No\n"
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
#define nl cout<<"\n"
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
// hashing for pairs
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
//sort in reverse order
bool compare(ll x, ll y){
    return x>y;
}
void solve()
{
  string n;
  cin>>n;
  ll sum=0;
  rep(i,len(n))
  {
    sum+=(n[i]-'0');
  }  
  if(sum%9)
  {
    cout<<"No";nl;
  }
  else
  {
    cout<<"Yes";nl;
  }
  
  return;
}
int main()
{
    IOS;
    int T=1;
  //  cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3988
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    
    let s: Vec<u32> = s.trim().split(" ").map(|c|c.parse::<u32>().unwrap()).collect();
    if s[0] + s[1] > s[2] + s[3] {
        println!("Left");
    } else if s[0] + s[1] < s[2] + s[3] {
        println!("Right");
    } else if s[0] + s[1] == s[2] + s[3] {
        println!("Balanced");
    }
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {
    private class City {
        Boolean flg = null;
        List<Integer> dsts = new ArrayList<>();
    }

    public void main(Scanner sc) {
        int n = sc.nextInt();
        City city[] = new City[n];
        for (int i = 0; i < n; i++) {
            city[i] = new City();
        }

        int m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int src = sc.nextInt() - 1;
            int dst = sc.nextInt() - 1;
            city[src].dsts.add(dst);
            city[dst].dsts.add(src);
        }

        city[0].flg = true;
        Queue<City> queue = new ArrayDeque<>();
        queue.add(city[0]);

        boolean is2bunki = true;
        while (is2bunki && !queue.isEmpty()) {
            City c = queue.poll();
            for (Integer dst : c.dsts) {
                if (city[dst].flg == null) {
                    city[dst].flg = !c.flg;
                    queue.add(city[dst]);
                } else if (city[dst].flg == c.flg) {
                    is2bunki = false;
                    break;
                }
            }
        }

        if (is2bunki) {
            long r = 0;
            long b = 0;
            for (int i = 0; i < n; i++) {
                if (city[i].flg) {
                    r++;
                } else {
                    b++;
                }
            }
            System.out.println(r * b - m);
        } else {
            long nn = n;
            System.out.println(nn * (nn - 1) / 2 - m);
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


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

int main(){

    int N,M;
    cin >> N;
    string s[N];
    for(int i = 0;i<N;i++) cin >> s[i];
    cin >> M;
    string t[M];
    for(int i = 0;i<M;i++) cin >> t[i];

    struct MOJI{
        string moji;
        int num;
    };

    MOJI X[N];
    for(int i = 0;i<N;i++){
        X[i].moji = "";
        X[i].num = 0;
    }

    int j = 0;
    bool flag = false;

    for(int i = 0;i<N;i++){
        for(int k = 0;k<N;k++){
            if(X[k].moji == s[i]) {
                X[k].num ++;
                flag = true;
                j --;
                break;
            }
        }
        if(flag) flag = false;
        else{
            X[j].moji = s[i];
            X[j].num ++;
        }
        j ++;
    }

    for(int i = 0;i<M;i++){
        for(int k = 0;k < N;k++){
            if(X[k].moji == t[i]){
                X[k].num --;
                break;
            }
        }
    }

    int MAX = 0;
    for(int i = 0;i<N;i++){
        MAX = max(MAX,X[i].num);
    }
    cout << MAX << endl;

    /*
    for(int i = 0;i<N;i++){
        cout << "文字 " << X[i].moji << " 数字 " << X[i].num << endl;
    }
    */

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char b;
	scanf("%c", &b);
	if (b == 'A')
	{
		printf("T");
	}
	else if (b == 'T')
	{
		printf("A");
	}
	else if (b == 'G')
	{
		printf("C");
	}
	else if (b == 'C')
	{
		printf("G");
	}
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
using namespace std;
int main(){
	int x,y,z;
	cin>>x>>y>>z;
	x-=z,y+=z;
	cout<<x/y<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
#define INF (1 << 30)
using namespace std;

const int kn = 105;
int atl[kn][kn];

int findMinPath(int n, vector<int> &v, bool isVisited[kn]){
    int mp, md = INF;
    rep(i,v.size()){
        rep(j,n){
            if(isVisited[j] == 0){
                if(md > atl[v[i]][j]){
                    md = atl[v[i]][j];
                    mp = j;
                }
            }
        }
    }
    isVisited[mp] = 1;
    v.push_back(mp);
    return md;
}

int PrimAlgorithm(int n){
    int sum = 0;
    bool isVisited[kn] = {0};
    vector<int> v;
    v.push_back(0);
    isVisited[0] = 1;

    while(not (v.size() == n)){
        sum += findMinPath(n, v, isVisited);
    }

    return sum;
}

int main(){
    int n, m;
    while(cin >> n >> m, n){
        rep(i,kn) rep(j,kn) atl[i][j] = INF;
        rep(i,m){
            int a, b, c;
            scanf("%d%*c%d%*c%d", &a, &b, &c);
            atl[a][b] = atl[b][a] = c;
        }
        cout << (PrimAlgorithm(n) / 100) - n + 1 << endl;
    }
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=5e3+7,mod=1e9+7;
int n,nxt[N<<1],to[N<<1],ha[N],tot,f[N][N],g[N],fac[N],fa[N],siz[N];
void add(int x,int y){nxt[++tot]=ha[x];ha[x]=tot;to[tot]=y;}
void dfs(int x){
	f[x][siz[x]=1]=1;
	for(int i=ha[x],y;i;i=nxt[i])if((y=to[i])!=fa[x]){
		fa[y]=x;dfs(y);
		for(int j=1;j<=siz[x]+siz[y];++j) g[j]=0;
		for(int s=1;s<=siz[x];++s)
			for(int t=0;t<=siz[y];++t) g[s+t]=1ll*(1ll*g[s+t]+1ll*f[x][s]*f[y][t]%mod)%mod;
		for(int j=1;j<=siz[x]+siz[y];++j) f[x][j]=g[j];
		siz[x]+=siz[y];
	}
	for(int i=2;i<=siz[x];i+=2) 
		f[x][0]=1ll*(1ll*f[x][0]-1ll*fac[i]*f[x][i]%mod+mod)%mod;
}
signed main(){
	cin>>n;
	for(int i=1;i<n;++i){int x,y;cin>>x>>y;add(x,y);add(y,x);}
	fac[0]=1;  for(ll i=2;i<=n;i+=2) fac[i]=1ll*fac[i-2]*(i-1)%mod;
	dfs(1);
	cout<<(mod-f[1][0])%mod;
	return 0;
} 

Measured memory_bytes: 97280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b==0) return a;
    else{
    	return gcd(b,a%b);
    }
}
 
int main() {
	vector<ll> v(3);
  	cin >> v[0] >> v[1] >> v[2];
  	sort(v.begin(), v.end());
  	cout << v[0]+v[1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;


int main()
{
	int nA, nB;
	char c;
	while (1)
	{
		cin >> nA >> c >> nB;
		if ('?' == c)
		{
			break;
		}
		int nTemp;
		switch (c)
		{
		case '+':
			nTemp = nA + nB;
			break;
		case '-':
			nTemp = nA - nB;
			break;
		case '*':
			nTemp = nA*nB;
			break;
		case '/':
			nTemp = nA / nB;
			break;
		}
		cout << nTemp << endl;
	}

	//system("pause");
	return 0;
}

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

int main() {
  
  int N;
  cin >> N;

  int r = N%10;
  if(r == 3) cout << "bon" << endl;
  else if(r == 0 || r == 1 || r == 6 || r == 8) cout << "pon" << endl;
  else cout << "hon" << endl;

}


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

int main(){

    int A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;

    int water = 0, sugar = 0;
    double conce = 0.;
    for(int a = 0; a <= F; a += 100 * A){
        for(int b = 0; (a + b) <= F; b += 100 * B){
            for(int c = 0; (a + b + c) <= F && (100 * c) <= (E * (a + b)); c += C){
                for(int d = 0; (a + b + c + d) <= F && (100 * (c + d)) <= (E * (a + b)); d += D){
                    if(conce <= ((100. * (c + d)) / (a + b + c + d))){
                        conce = ((100. * (c + d)) / (a + b + c + d));
                        water = (a + b);
                        sugar = (c + d);
                    }
                }
            }
        }
    }

    cout << water + sugar << " " << sugar << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
// バッファを経ずstdinから数値を得る
#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
    int n = 0, c = gc();
    do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
    return n;
}
 
int  tr['T'+1];
char f[33554432];
 
int main()
{
    int n, k, c;
 
    tr['A'] = 0, tr['C'] = 1, tr['G'] = 2, tr['T'] = 3;
    n = in();
    while (n--) {
        if (gc() == 'i') {
            k = 7; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            f[k] = 1;
        } else {
            k = 5; while (--k) gc();
            k++; while ((c = gc()) >= ' ') k <<= 2, k |= tr[c];
            if (f[k]) pc('y'), pc('e'), pc('s');
            else      pc('n'), pc('o');
            pc('\n');
        }
    }
    return 0;
}



Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n, k;
    cin>>n>>k;
    vector <ll> a(n);
    vector <ll> dp(n, INT_MAX);
    for(auto &it : a){
        cin>>it;
    }
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j <= i + k; j++){
            if(j < n){
                dp[j] = min(dp[j], dp[i] + abs(a[i] - a[j]));
            }
        }
    }
    cout<<dp[n - 1]<<endl;
    return 0;
}


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

int main(){
  int n,x;
  cin>>n>>x;
  vector<int> L(n);
  rep(i,n) cin>>L[i];
  int s=0;
  int t=1;
  rep(i,n){
    s+=L[i];
    if(s>x){
      cout<<t<<endl;
      return 0;
    }
    t++;
  }
  cout<<t<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 #define int long long
 #define pa pair<int,int>
  #define  mp make_pair
  #define  pb push_back
 using namespace std;



struct bi_match{
	private:
	public:
	int V;
	vector<vector<int>> Graph;
	vector<int> used,match;
	bi_match(int V){
		this->V=V;
		Graph.resize(V);
		match.resize(V,-1);
		used.resize(V,-1);
	}
	
	void add_edge(int u,int v){
		Graph[u].pb(v),Graph[v].pb(u);		
	}
	
	bool dfs_bi(int v,int num){
		used[v] = num;
  		for(int u:Graph[v]){
    		int w=match[u];
    		if(w<0 || used[w]<num && dfs_bi(w,num)){
      			match[v]=u,match[u]=v;
      			return true;
    		}
  		}
  		return false;
	}
	
	int solve(){
 		int res=0;
  		for(int v=0;v<V;v++)if(match[v]<0)if(dfs_bi(v,v))res++;
 		return res;
	}
};

struct unionfind{
	private:
	public:
	
vector<int> par,ranks;
	
	void shoki(int N){
		par.resize(N+1,0);
		ranks.resize(N+1,0);
		for(int i=0;i<=N;i++){
			par[i]=i;
		}
	}
	int root(int x){
		return par[x]==x ? x : par[x]=root(par[x]);
	}
	void unite(int x,int y){
 		x=root(x),y=root(y);
	 	if(x==y) return;
		if(ranks[x]<ranks[y]){
			par[x]=y;
		}
	 	else {
			par[y]=x;
			if(ranks[x]==ranks[y]) ranks[x]=ranks[x]+1;
	 	}
		return;
	}
};

 signed main(){
 	
 
    cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,m;
 	cin>>n>>m;
 	vector<pa> ve;
 	bi_match bi(2*n);
 	for(int i=0;i<m;i++){
 		int y,yy;
 		cin>>y>>yy;
 		y--,yy--;
 		ve.pb(mp(y,yy));
 		bi.add_edge(y,n+yy);
 	}
 	
 	int mi=m-bi.solve();
 	
 	unionfind uf;
 	uf.shoki(m);
 	for(int i=0;i<m;i++)for(int j=i+1;j<m;j++){
 		if(ve[i].first==ve[j].first || ve[i].second==ve[j].second) uf.unite(i,j);
 	}
 	int ma=m;
 	for(int i=0;i<m;i++)if(uf.root(i)==i)ma--;
 	cout<<mi<<" "<<ma<<endl;
 	
return 0;

 }


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

int main() {
 int n,k;
  cin>>n>>k;
  vector<int> p(n),r(n+1,0);
  for(int i=0;i<n;i++) {
    int x;
    cin>>x;
    p[i]=x;
    r[i+1]=r[i]+p[i];
  }
  int sum=0;
  for(int i=0;i<=n-k;i++) sum=max(sum,r[k+i]-r[i]);
  double x=sum+k;
  x/=2;
  printf("%.1f\n",x);
}

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

int main() {
  int A,B,C;
  cin >>A >>B >>C;
  
  if(175 == A*B*C){
    if(17 == A+B+C){
     cout << "YES" << endl;
   }
  }
  
  else{
  cout <<"NO" << endl;  
 }
  
  
}


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

#define ll long long

ll n, w, wt[100005], val[100005], dp[102][100005];

ll solve (ll i, ll wgt) {
	if (i == -1 || wgt == 0) {
		return 0;
	}

	if (dp[i][wgt] != -1) {
		return dp[i][wgt];
	}

	dp[i][wgt] = solve(i - 1, wgt);

	if (wgt - wt[i] >= 0)
		dp[i][wgt] = max (dp[i][wgt], val[i] + solve (i - 1, wgt - wt[i]));

	return dp[i][wgt];
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	cin >> n >> w;
	for (ll i = 0; i < n; i++) {
		cin >> wt[i] >> val[i];
	}
	memset (dp, -1, sizeof dp);
	cout << solve (n - 1, w) << "\n";
	return 0;
}

Measured memory_bytes: 80128
s = input()
s = list(s)
ans = 0
for i in range(len(s)-1):
    if s[i]==s[i+1]:
        if s[i+1]=="0":
            s[i+1] = "1"
        elif s[i+1]=="1":
            s[i+1] = "0"
        ans += 1
print(ans)


Measured memory_bytes: 9804
#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
#include<functional>
#include<set>
using namespace std ;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;

int main(){
    int n , m , k ;
    cin >> n >> m >> k ;
    set<int> A ;
    rep(i,k) if(n + i <= m ) A.insert(n + i);
    rep(i,k) if(m - i >= n ) A.insert(m - i);
    for(auto p : A) cout << p << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int main(){
    int n;
    cin >> n;

    for(int i = 1; i <= sqrt(n); i++){
        if(n % i == 0 && 1 <= i && 9 >= i && 1 <= n/i && 9 >= n/i){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
len_N = len(str(N))
str_N = str(N)
N_a = int(str_N[0])
N_b = int(str_N[-1])
ans = 0
if len_N == 1:
    print(N)
    exit()
if len_N == 2:
    ans += 9
    for i in range(11, N+1):
        str_i = str(i)
        if str_i[1] == '0':
            continue
        i_tmp = int(str(i)[1] + str(i)[0])
        if i_tmp <= N:
            ans += 1
    tmp = N // 11
    ans += tmp * 2
    print(ans)
    exit()

for i in range(1, N+1):
    tmp = str(i)
    tmp_a = int(tmp[0])
    tmp_b = int(tmp[-1])
    if tmp_b == 0:
        continue
    if tmp_a == tmp_b:
        ans += 1
 
    if tmp_b > N_a:
        ans += int('1' * (len_N - 2))

    elif tmp_b == N_a and tmp_a <= N_b:
        ans += int('1' * (len_N - 2))
        naka = str_N[1:-1]
        if naka == "":
            continue
        ans += int(naka) + 1

    elif tmp_b == N_a and tmp_a > N_b:
        ans += int('1' * (len_N - 2))
        naka = str_N[1:-1]
        if naka == "":
            continue
        ans += int(naka)

    else:
        ans += int('1' * (len_N - 1))

print(ans)


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

int main(){
    ll n;
    cin >> n;
    ll a[n];
  ll dp[n+10][2];
  for(int i = 0; i < n; i++){
    dp[i][0] = 0;
    dp[i][1] = 0;
  }
  dp[0][0] = 0;
  dp[0][1] = -MOD;
    for(int i = 0; i < n; i++){
      ll temp;
        cin >> temp;
      a[i] = temp;
    }
    for(int i = 1; i < n; i++){
        dp[i][0] = max(dp[i-1][0]+a[i-1],dp[i-1][1]-a[i-1]);
        dp[i][1] = max(dp[i-1][0]-a[i-1],dp[i-1][1]+a[i-1]);
    }
    dp[n][0] = max(dp[n-1][0]+a[n-1],dp[n-1][1]-a[n-1]);
    cout << dp[n][0] << endl;

}

Measured memory_bytes: 2560
n = int(input())
a, b = [int(i) for i in input().split()]
numlist = [int(i) for i in input().split()]

cntx = 0
cnty = 0
cntz = 0

for i in range(n):
  if numlist[i]<=a:
    cntx += 1
  elif numlist[i]<=b:
    cnty += 1
  else:
    cntz += 1
 
print(min([cntx, cnty, cntz]))

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {
	int n, m, l, a, b;
	cin >> n >> m >> l;
	int A[n][m];
	int B[m][l];
	long C[n][l] = {};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a;
			A[i][j] = a;
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> b;
			B[i][j] = b;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				C[i][j] += A[i][k] * B[k][j];
			}
			if (j > 0) cout << " ";
			cout << C[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

int n;
string S = "ACGT";
const int MOD = 1e9+7;

bool contain(string s) {
	if (s.substr(0, 3) == "AGC") return true;
	if (s.substr(1, 3) == "AGC") return true;
	return false;
}

string add(string s, char c){
    string res = s + c;
    if(contain(res)) return "";
    
    rep(i, 3){
        string tes = res;
        swap(tes[i], tes[i+1]);
        if(contain(tes)) return "";
    }
    
    return res.substr(1);
}

void Main(){
    cin >> n;
    map<string, int> dp;
    dp["###"] = 1;
    
    rep(i, n){
        map<string, int> pd;
        for(auto [ps, pi] : dp){
            for(char c : S){
                string nxt = add(ps, c);
                if(nxt.size() != 0) pd[nxt] = (pd[nxt] + pi) % MOD;
            }
        }
        swap(dp, pd);
    }
    
    int ans = 0;
    for(auto [ps, pi] : dp){
        ans = (ans + pi) % MOD;
        // cout << ps << " " << pi << endl;
    }
    cout << ans << endl;
    return;
}

int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3668
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll d[2][MAXn], p[2][MAXn];
vector<pair<ll,ii> > dt;

int main()
{
    IOS();
    ll n;
    cin>>n;
    REP(i,n)REP(j,2)cin>>d[j][i];
    ll mn = INF;
    {
        ll tt = 0;
        REP(i,n)tt += d[0][i];
        mn = min(tt, mn);
    }
    {
        ll tt = 0;
        REP(i,n)tt += d[1][i];
        mn = min(tt, mn);
    }
    REP(i,n)REP(j,2)dt.pb({d[j][i],{j,i}});
    sort(ALL(dt));
    ll tmp = 0;
    REP(i,n)tmp += dt[i].X;
    REP(i,SZ(dt))p[dt[i].Y.X][dt[i].Y.Y] = i;
    REP(i,n)REP(j,2)debug(i,j,d[j][i],p[j][i]);
    debug(mn);
    REP(i,n)
    {
        debug(i, mn);
        if((p[0][i] >= n && p[1][i] >= n) || (p[0][i] < n && p[1][i] < n))mn = min(mn, tmp);
        else if(p[0][i] < n)
        {
            debug(i, "a");
            if(p[0][i] != n-1)mn = min(mn, tmp - dt[n-1].X + d[1][i]);
            else mn = min(mn, tmp - dt[n-2].X + d[1][i]);
        }
        else
        {
            debug(i, "b");
            if(p[1][i] != n-1)mn = min(mn, tmp - dt[n-1].X + d[0][i]);
            else mn = min(mn, tmp - dt[n-2].X + d[0][i]);
        }
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 9840
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000000000

//ぴったり割り切れる時と、そうでない時とで対応が分かれる。


int main(){
  char buf[1024];
  long N;
  long *a=(long *)malloc(sizeof(long)*5);

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%ld", &N);
  rep(i,5){
    fgets(buf,sizeof(buf),stdin);
    sscanf(buf, "%ld", &a[i]);
  }

  long min=INF;
  rep(i,5){
    if(a[i]<min){
      min=a[i];
    }
  }

  long ans=0;
  if(N%min==0){
    ans+=N/min;
  }
  else{
    ans+=N/min+1;
  }
  ans+=4;

  printf("%ld\n", ans);

  return 0;

}


Measured memory_bytes: 128
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    string s; cin>>s;
    ll k; cin>>k;
    rep(i,s.size()){
        if(k==i+1){
            cout<<s[i]<<endl;
            break;
        }
        if(s[i]!='1'){
            cout<<s[i]<<endl;
            break;
        }
    }
}

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

int main() {
  int N;
  long long ans=0;
  cin>>N;
  for(int i=1;i<=N;i++){
    if((i%3)!=0 and (i%5)!=0){
      ans+=i;
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3636
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int a = 0;
      int b = 0;
      int[] socres = new int[n];
      for(int i = 0 ; i < n ; i++) {
        	socres[i] = sc.nextInt();
      }
      Arrays.sort(socres);
      int i = n - 1;
      while(i >= 0) {
        a += socres[i--];
        if(i >= 0)
         	b += socres[i--];
      }
      System.out.println(a - b);
  }
}

Measured memory_bytes: 20948
program C
    implicit none
    integer::N,M,i,j, max, min, l, r
    read(*,*) N, M
    do i = 1, M
        read(*,*) l, r
        if(i == 1) then
            max = r
            min = l
        else
            if(l > min) then
                min = l
            end if
            if(r < max) then
                max = r
            end if
        end if
    end do
    if(max >= min)then
        write(*,*) max - min + 1
    else
        write(*,*) 0
    end if

    stop
end program

Measured memory_bytes: 2800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll MOD = ll(1e9 + 7);

int main() {
    ll n;
    string s;
    cin >> s;
    n = s.size();
    vector<vector<ll> > dp(n+1, vector<ll>(13,0));
    dp[0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++){
            if(s[i] != '?'){
                int r = (10*j + (s[i]-'0')) % 13;
                dp[i+1][r] += dp[i][j];
                dp[i+1][r] %= MOD;
            }
            else{
                for(int k=0;k<=9;k++){
                    int r = (10*j + k) % 13;
                    dp[i+1][r] += dp[i][j];
                    dp[i+1][r] %= MOD;
                }
            }
        }
    }
    cout << dp[n][5] << endl;
    return 0;
}


Measured memory_bytes: 13696
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    int H, W;
    while(true){
        scanf("%d %d",&H,&W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < W; i++) printf("#");
        printf("\n");

        for(int i = 1; i < H-1; i++){
            printf("#");
            for(int j = 1; j < W-1; j++) printf(".");
            printf("#\n");
        }

        if(H > 1){
            for(int i = 0; i < W; i++) printf("#");
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}



Measured memory_bytes: 2612
#include <iostream>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;
using std::lower_bound;
using std::upper_bound;
using std::find_if;
using std::copy;
using std::copy_if;

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

    sort(a.begin(),a.end());

    long v=0,h=0;
    for(int i=a.size()-1;i>0;i--){
        if(a[i]==a[i-1]){
            if(v==0){
                v=a[i];
                i--;
            }
            else if(h==0){
                h=a[i];
                break;
            }
        }
    }

    cout << (v*h) << endl;
    return 0;
}



Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BStringRotation solver = new BStringRotation();
        solver.solve(1, in, out);
        out.close();
    }

    static class BStringRotation {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next(), t = in.next();
            for (int i = 0; i < s.length(); i++) {
                String u = s.substring(i, s.length()) + s.substring(0, i);
                if (t.equals(u)) {
                    out.println("Yes");
                    return;
                }
            }
            out.println("No");
        }

    }
}



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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,m;
  while(cin>>n>>m,n){
    int d[101]={};
  for(int i=0;i<n;i++){
    int d1,v;cin>>d1>>v;
    d[d1]=max(d[d1],v);
  }
  int cnt=0;
  for(int i=1;i<=m;i++){
    cnt+=d[i];
  }
  cout<<cnt<<endl;
}
  return 0;
}



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

using namespace std;

int main(){
    int H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> vec;
    for (int h = 0; h < H;h++){
        vector<int> v;
        string s;
        cin >> s;
        for (int i = 0; i < s.length();i++){
            if(s[i]=='.'){
                v.push_back(0);
            }else{
                v.push_back(1);
            }
        }
        vec.push_back(v);
    }

    int ans = 0;
    for (int bith = 0; bith < (1 << H); bith++)
    {
        for (int bitw = 0; bitw < (1 << W); bitw++)
        {
            int res = 0;
            for (int h = 0; h < H;h++){
                if(!(bith & (1<<h))){
                    for (int w = 0; w < W;w++){
                        if(!(bitw & (1<<w))){
                            if(vec.at(h).at(w)){
                                res++;
                            }
                        }
                    }
                }
            }
            if (res == K)
            {
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
// Problem : B - Judge Status Summary
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define ll long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frr(i,a,b) for(int i=a;i>=b;i--)
//vector
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define pp pop_back
//pair
#define pi pair<int ,int >
#define mk make_pair
#define ff first
#define ss second
//set
#define si set<int>
#define sit set<int>::iterator 
using namespace std;
int main()
{
fast;
int tc;cin>>tc;
int a=0,b=0,c=0,d=0;
while(tc--)
{
	string s;cin>>s;
	if(s=="AC") a++;
	else if(s=="TLE") c++;
	else if(s=="WA") b++;
	else d++;
	
}
cout<<"AC x "<<a<<endl;
cout<<"WA x "<<b<<endl;
cout<<"TLE x "<<c<<endl;
cout<<"RE x "<<d<<endl;
return 0;
}

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

using namespace std;
using ll = long long;
const int D = 61;

int main()
{
    int n; ll k; cin >> n >> k;
    vector<vector<int>> d(D+1, vector<int>(n));
    for(int i = 0; i < n; i++) {
        cin >> d[0][i]; d[0][i]--;
    }
    for(int i = 0; i < D; i++) {
        for(int j = 0; j < n; j++) {
            d[i + 1][j] = d[i][d[i][j]];
        }
    }

    int cur = 0;
    for(int i = 0; i <= D; i++) {
        if(k & 1LL << i) {
            cur = d[i][cur];
        }
    }
    cout << cur + 1 << endl;
}

Measured memory_bytes: 52624
#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(){
	int a,b;
	cin>>a>>b;
	cout<<(a*3+b)/2<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int want = sc.nextInt();
		int count = 0;
		for(int i = 0; i <= k; i++) {
			for(int m = 0; m <= k; m++) {
				if(want - i - m <= k && want - i - m >= 0) {
					count++;
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int a,b; cin >> a >> b;
    if ((a+b)%3==0 || a%3==0 || b%3==0) cout << "Possible\n";
    else cout << "Impossible\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string S;
    while(cin >> S){
        int cnt[128] = {};
        for(char c: S){
            ++cnt[c];
        }
        bool ans =
            (cnt['N'] != 0) == (cnt['S'] != 0) &&
            (cnt['E'] != 0) == (cnt['W'] != 0);
        puts(ans ? "Yes" : "No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int h, w;
int c_x, c_y;
int d_x, d_y;
vector<string> field;
vector<vector<int>> dist;
vector<pair<int, int>> directions = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int main() {
    cin >> h >> w;
    cin >> c_x >> c_y;
    cin >> d_x >> d_y;
    c_x--, c_y--, d_x--, d_y--;
    field.resize(h);
    for (int i = 0; i < h; i++) cin >> field[i];
    dist.assign(h, vector<int>(w, INF));
    dist[c_x][c_y] = 0;
    deque<pair<int, int>> dq;
    dq.emplace_back(c_x, c_y);
    while (!dq.empty()) {
        int x = dq.front().first;
        int y = dq.front().second;
        int d = dist[x][y];
        dq.pop_front();
        for (auto dir: directions) {
            int nx = x + dir.first, ny = y + dir.second;
            if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
            if (field[nx][ny] == '#') continue;
            if (dist[nx][ny] <= d) continue;
            dist[nx][ny] = d;
            dq.emplace_front(nx, ny);
        }
        for (int i = -2; i <= 2; i++) {
            for (int j = -2; j <= 2; j++) {
                int nx = x + i, ny = y + j;
                if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue;
                if (field[nx][ny] == '#') continue;
                if (dist[nx][ny] <= d + 1) continue;
                dist[nx][ny] = d + 1;
                dq.emplace_back(nx, ny);
            }
        }
    }
    // for (int i = 0; i < h; i++) {
    //     for (int j = 0; j < w; j++) {
    //         cout << dist[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    if (dist[d_x][d_y] == INF) cout << -1 << endl;
    else cout << dist[d_x][d_y] << endl;
    return 0;
}


Measured memory_bytes: 9548
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n,t=get_i
table=array(t+1,1,0)
n.times do|i|
  l,r=get_i
  table[l]+=1
  table[r]-=1
end
imos=array(t+2,1)
imos[0]=0
max=0
(t+1).times do|i|
  imos[i+1]=imos[i]+table[i]
  max=imos[i+1] if max<imos[i+1]
end
puts max


Measured memory_bytes: 8452
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
ll M=1e9+7;
//string s,p;
//vector<int>v;
//map<int,int>mp;
ll a[N],d[N];
int main()
{
    ft
    ll t,i,j,n,m,k,l,r;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        d[i]=a[i];
    }
    for(i=1;i<=n;i++)
    {
        d[i]+=d[i-1];
    }
    ll s=0;
    for(i=1;i<n;i++)
    {
        a[i]%=M;
        s+=a[i]*((d[n]-d[i])%M);
        s%=M;
    }
    cout<<s<<"\n";
    return 0;
}



Measured memory_bytes: 6736
#include<iostream>
#include<cstdio>
#include<vector>

int main(void){
	std::int64_t N;
	std::cin >> N;
	std::int64_t a[N];

	std::int64_t c[16] = {0};

	for(auto i = decltype(N)(1); i <= N; i++){
		std::cin >> a[i];
	}


	std::int8_t big = 0;
	for(auto i = decltype(N)(1); i <= N; i++){
		std::uint8_t c_ = a[i] / 400;
		c[c_] = 1;
		if(c_ >= 8){
			big++;
		}
	}

	std::int32_t min_=0;
	for(auto i = 0; i <= 7; i++){
		min_ += c[i];
	}
	std::int32_t max_ = min_ + big;
	if(min_ == 0){
		min_ = 1;
	}

	std::cout << min_ << " " << max_ << std::endl;
	return 0;
	
}


Measured memory_bytes: 256
z = input().split()
l = {
  'A': 1
  , 'B': 2
  , 'C': 3
  , 'D': 4
  , 'E': 5
  , 'F': 6
}
x = l[z[0]]
y = l[z[1]]
if x > y:
  print('>')
elif x < y:
  print('<')
else:
  print('=')

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

int main(){
	int K,N;
	cin >> K >> N;
	int A[N];
	int D[N];
	for(int i=0;i<N;i++){
		cin >> A[i];
	}
	for(int i=0;i<N-1;i++){
		D[i]=A[i+1]-A[i];
	}
	D[N-1]=A[0]+K-A[N-1];
	int minDist=K;
	for(int i=0;i<N;i++){
		int d;
		d=K-D[(i-1+N)%N];
		if(d<minDist){
			minDist=d;
		}
		d=K-D[i];
		if(d<minDist){
			minDist=d;
		}
	}
	cout << minDist;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>

using namespace std;
typedef long long ll;

ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}


//for(int i = ; i < ; i++){}

int main(){
  int n,k;
  cin>>n>>k;
  ll mod = 1e9 + 7;
  ll **c;
  c = (ll**)malloc(sizeof(ll*)*2005);
  
  for(int i = 0; i < 2005; i++){
      c[i] = (ll*)malloc(sizeof(ll)*2005);
  }
  int red = n-k;
  for(int i = 0; i <= 2000; i++){
    for(int j = 0; j <= i; j++){
      if(j == 0||j == i) c[i][j] = 1;
      else c[i][j] = (c[i-1][j-1]+c[i-1][j])%mod;
    }
  }
  for(int i = 1; i <= k; i++){
    cout<<(c[red+1][i]*c[k-1][k-i])%mod<<endl;
  }
  return 0;
}




Measured memory_bytes: 22912
/*
 
 
*/
 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    int arr[n];
    vector<int> dp(k+1,0);
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    	dp[arr[i]]=1;
    }
 
    //vector<int> dp(k+1,0);
    dp[0]=1;
 	for(int i=1;i<=k;i++)
 	{
 		for(int j=0;j<n;j++)
 		{
 			if(i==arr[j])
 			{
 				dp[i]=1;
 				break;
 			}
 			
 			if(i>arr[j]&&dp[i]!=1)
 			{
 				if(dp[i-arr[j]]==1)
 					dp[i]=0;
 				else
 					dp[i]=1;
 			}

 		}
 	}

 	//for(auto x:dp)
 		//cout<<x<<" ";
 	
 	if(dp[k]==1)
 		cout<<"First";
 	else
 		cout<<"Second";
  
    return 0;
}

Measured memory_bytes: 640
h,n=map(int,input().split())
a=[0]
b=[0]
width=2*10**4+7
dp=[[10**10 for i in range(width)] for j in range(n+1)]
dp[0][0]=0
dp[1][0]=0
for i in range(n):
    x,y=map(int,input().split())
    a.append(x)
    b.append(y)
for i in range(1,n+1):
    for j in range(width):
        dp[i][j]=min(dp[i][j],dp[i-1][j])
        if(j+a[i]<width):
            dp[i][j+a[i]]=min(dp[i][j+a[i]],dp[i][j]+b[i])
print(min(dp[n][h:]))

Measured memory_bytes: 299244
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

#define int ll

//get vector of prime numbers which is lower than or equal n
vector<int> get_primes(int n)
{
    vector<bool> is_prime(n + 1, true);
    vector<int> res;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; i++)
    {
        if (is_prime[i])
        {
            res.push_back(i);
            for (int j = 2 * i; j < is_prime.size(); j = j + i)
            {
                is_prime[j] = false;
            }
        }
    }
    return res;
}

vector<pair<int, int>> factorize(int n)
{
    vector<pair<int, int>> res;
    for (int i = 2; i * i <= n; i++)
    {
        int tmp = 0;
        while (n % i == 0)
        {
            tmp++;
            n /= i;
        }
        res.push_back(make_pair(i, tmp));
    }
    if (n != 1)
    {
        res.push_back(make_pair(n, 1));
    }
    return res;
}

int mpow(int x, int n)
{
    int res = 1;
    while (n != 0)
    {
        if (n & 1)
            res = res * x % INF;
        x = x * x % INF;
        n = n >> 1;
    }
    return res;
}

//mod frac
vector<int> mfrac;
void set_mfrac(int n)
{
    if (mfrac.size() == 0)
    {
        mfrac.push_back(1);
    }
    for (int i = mfrac.size(); i <= n; i++)
    {
        mfrac.push_back((i * mfrac[i - 1]) % INF);
    }
}

//get nCm mod INF
int mcomb(int n, int m)
{
    if (mfrac.size() <= n)
    {
        set_mfrac(n);
    }
    int res = mfrac[n];
    res = res * mpow(mfrac[m], INF - 2) % INF;
    res = res * mpow(mfrac[n - m], INF - 2) % INF;
    return res;
}

vector<int> get_gcd(int n){
    vector<int> res;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            if(i*i==n)
            {res.push_back(i);}
            else
            {res.push_back(i);
            res.push_back(n/i);}
        }
    }
    return res;
}

signed main()
{
    int A, B;
    cin >> A >> B;
    if (A-2*B>0){
        cout << A-2*B<<endl;
    }else{
        cout << 0 <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
from itertools import accumulate
w=[[] for _ in range(4)]
N,W=map(int,input().split())
w1,v1=map(int,input().split())
w[0].append(v1)
for _ in range(N-1):
    wi,vi=map(int,input().split())
    w[wi-w1].append(vi)
for i in range(4):
    w[i].sort(reverse=True)
    w[i]=list(accumulate(w[i]))
ans=0
for i in range(len(w[0])+1):
    for j in range(len(w[1])+1):
        for k in range(len(w[2])+1):
            for l in range(len(w[3])+1):
                if w1*i+(w1+1)*j+(w1+2)*k+(w1+3)*l<=W:
                    su=0
                    if i>0:
                        su+=w[0][i-1]
                    if j>0:
                        su+=w[1][j-1]
                    if k>0:
                        su+=w[2][k-1]
                    if l>0:
                        su+=w[3][l-1]
                    ans=max(ans,su)
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int S;
    cin >> S;
    int h = S / 3600, m = S % 3600 / 60, s = S % 60;
    printf("%d:%d:%d\n", h, m, s);
    return 0;
        
}


Measured memory_bytes: 3200