akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const int maxm = 1e6 + 5;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x <= 1) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
int n,m;
int main(){
 	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	if(m == n) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}
//do smt instead of nothing! never give up!
//take care of long long!
//take care of upper or lower case e.g "yes" or "YES"?
//boundary condition! e.g. n = 0?
//brute force is always the first choice!
// print the ans to look for patterns in the data!

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    string s;
    cin>>s;
    bool ans=false;
    rep(i,3){
        if(s[i]=='7'){
            ans=true;
        }
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3620
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    string s = "";
    cin >> s;
    int pre = 0, suf = 0;
    int cnt = 0;
    for (auto iter=s.begin(); iter!=s.end(); iter++) {
        char c = *iter;
        if (c == '(') {
            cnt++;
        } else if (c == ')') {
            cnt--;
            if (cnt < 0) {
                pre++; cnt++;
            }
        }
    }
    cnt = 0;
    for (auto iter=s.rbegin(); iter!=s.rend(); iter++) {
        char c = *iter;
        if (c == ')') {
            cnt++;
        } else if (c == '(') {
            cnt--;
            if (cnt < 0) {
                suf++; cnt++;
            }
        }
    }
    string ans = "";
    for (int i=0; i<pre; i++) {
        ans += '(';
    }
    ans += s;
    for (int i=0; i<suf; i++) {
        ans += ')';
    }
    cout << ans << endl;
    return 0;
}
 

Measured memory_bytes: 256
#23:16

while True:
    candidate,max_stones = map(int,input().split())
    if candidate == 0 and max_stones ==0 :
        break
    # 候補者がもっている石の数
    have_stones = [0] * candidate
    i = 0
    stones = max_stones
    while True:
        if not stones == 0 :
            stones = stones -1
            have_stones[i] = have_stones[i] + 1
        else :
            stones = stones + have_stones[i]
            have_stones[i] = 0
        
        if stones == 0 and have_stones[i]  == max_stones:
            print(i)
            break
        i = i+1 
        i = i % candidate

            



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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

//bool dfs(const vvi& g1,const vvi& g2,int u,int c,vi& color)
//{
//	if(color[u]!=-1) return color[u]!=c;
//	color[u]=c;
//	for(int v:g1[u]) if(!dfs(g1,g2,v,!c,color)) return false;
//	for(int v:g2[u]) if(!dfs(g1,g2,v,!c,color)) return false;
//	return true;
//}
int dist(const vvi& g1,const vvi& g2,int u,int v)
{
	vi vis(g1.size());
	queue<pii> q; q.emplace(u,0);
	while(q.size()){
		int x,d; tie(x,d)=q.front(); q.pop();
		if(vis[x]) continue;
		vis[x]=1;
		if(x==v) return d;
		for(int y:g1[x]) q.emplace(y,d+1);
		for(int y:g2[x]) q.emplace(y,d+1);
	}
	return INF;
}

int main()
{
	for(int n;cin>>n && n;){
		cin.ignore();
		
		map<string,int> f;
		vector<pii> es;
		rep(i,n){
			string s;
			getline(cin,s,'-');
			f.insert(mp(s,f.size()));
			int u=f[s];
			getline(cin,s);
			f.insert(mp(s,f.size()));
			int v=f[s];
			es.emplace_back(u,v);
		}
		
		n=f.size();
		vvi g1(n,vi(n));
		for(auto e:es){
			int u,v; tie(u,v)=e;
			g1[u][v]=1;
		}
		
		vvi g(n,vi(n,INF));
		rep(i,n) rep(j,n){
			rep(k,n) if((g1[i][k]||g1[k][i])&&(g1[j][k]||g1[k][j]))
				g[i][j]=0;
			rep(k,n) if((g1[i][k]&&g1[k][j])||(g1[j][k]&&g1[k][i]))
				g[i][j]=INF;
		}
		rep(i,n) rep(j,n) if(g1[i][j]) g[i][j]=1;
		rep(k,n) rep(i,n) rep(j,n)
			g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
		
		cout<<n<<endl;
		
		int m; cin>>m;
		cin.ignore();
		rep(i,m){
			string s;
			getline(cin,s,'-');
			int u=f.count(s)?f[s]:-1;
			getline(cin,s);
			int v=f.count(s)?f[s]:-1;
			
			if(u==-1 || v==-1)
				cout<<"NO"<<endl;
			else
				cout<<(g[u][v]%2?"YES":"NO")<<endl;
		}
	}
}

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

//#define int long long
struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;
using intpair = pair<int, int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) ((int)((a) + (b) - 1)/(int)(b))

signed main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    rep(i,200){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n+1];
    a[0] = INT_MAX;
    a[n] = INT_MAX;
    for(int i = 1; i < n; i++){
        cin >> a[i];
    }
    int ans[n];
    for(int i = n-1; i >= 0; i--){
        ans[i] = min(a[i], a[i+1]);
    }
    long long int temp = 0;
    ans[0] = min(a[0], a[1]);
    for(int i = 0; i < n; i++){
        temp += min(a[i], min(a[i+1], ans[i]));
    }
    cout << temp;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

#define rep(i,n) for(ll i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;

	bool ans = true;
	rep(i, s.size()) {
		if (s[i] != t[i]) ans = false;
	}
	puts(ans ? "Yes" : "No");

	return 0;
}

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

using namespace std;

#define pb push_back
#define ll long long
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)

const ll INF = 1e9 + 5, N = 205;

int main(){
	int n;
	cin >> n;
	int a[n + 1];
	int ans = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j < i; j++){
			for(int k = 1; k < j; k++){
				if(a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) continue;
				if(a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i]){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
/*  Writen by : AS7
 *  "JUST KEEP GOING..."
 */
#define endl			'\n'
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define allr(v)			((v).rbegin()), ((v).rend())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define For(i,s)        for(auto i:s)
#define Forr(i,s)        for(auto &i:s)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define ii				pair <int,int>
#define vii				vector <ii>
#define vll				vector <pair<ll,ll>>
#define PI				double PPPPPP = 3.14159265358979323846;
#define bit(mask,i) ((mask>>i)&1)
const int N = 2e5+5;
map<int ,bool> vis;
int ans;
void solve(){
   string s,t;
   cin>>s>>t;
   rep(i,s){
       ans+=(s[i]!=t[i]);
   }
   cout<<ans<<endl;
}
int main() {
    int t = 1;
   //cin>>t;
    while (t--)solve();
}

Measured memory_bytes: 3908
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;	

ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c,d;
	cin >> a >> b >> c >> d;
	ll l1 = ceil(ld(a)/ld(c));
	ll l2 = ceil(ld(a)/ld(d));
	ll l3 = ceil(ld(a)/ld(c*d/__gcd(c,d)));
	ll r1 = (b/c);
	ll r2 = (b/d);
	ll r3 = (b/(c*d/__gcd(c,d)));
	ll temp = 0;
	if (l1 <= r1) temp += r1-l1+1;
	if (l2 <= r2) temp += r2-l2+1;
	if (l3 <= r3) temp -= r3-l3+1;
	cout << b-a+1-temp << endl;
	cin >> a;
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define EPS 1.0e-8
#define MAX_N 100

int num[10];

int main(){
	rep(i,10) cin >> num[i];
	sort(num,num+10,greater<int>());
	printf("%d\n%d\n%d\n",num[0], num[1], num[2]);
}

Measured memory_bytes: 1152
#include <stdio.h>
#define inf 10e15
typedef long long ll;

int main(void) {
  ll i, j, k, n, w;
  scanf("%lld%lld", &n, &w);
  ll dp[12000], v[n], we[n];
  for(i = 0; i < 12000; ++i) dp[i] = inf;
  dp[0] = 0;
  for(i = 0; i < n; ++i) scanf("%lld%lld", &v[i], &we[i]);
  for(i = 0; i < n; ++i) for(j = 10000; j >= 0; --j) if(dp[j + v[i]] > dp[j] + we[i]) dp[j + v[i]] = dp[j] + we[i];
  int ans = 0;
  for(i = 0; i < 12000; ++i) if(dp[i] <= w) ans = (int)i;
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2836
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>
#include <set>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef double ld;
const int N = 200001;

vector<int> g[N];
int bamb[N];
int minused[N];
int dfs(int v, int pr)
{
    int ans = 0;
    bool ok = false;
    int tau = 0;
    bamb[v] = 1;
    bool memes = false;
    for (int u : g[v])
        if (u != pr)
        {
            tau++;
            int t = dfs(u, v);
            if (!bamb[u])
                bamb[v] = 0;
            else
                ok = true;
            if (minused[u])
                memes = true;
            ans += t;
        }
    if (tau > 1)
        bamb[v] = 0;
    if (bamb[v])
        return 1;
    if (ok)
    {
        ans--;
        minused[v] = 1;
        if (memes && tau == 2 && pr == -1)
            ans++;
    }
    return ans;
    if (ans == 1 && tau == 2 && ok)
    {
        bool ok = true;
        for (int u : g[v])
            if (u != pr && !bamb[u])
                ok = false;
        if (!ok)
            return 2;
    }
    return ans;
}

int main()
{
   // freopen("in.txt", "r", stdin);
    int n;
    cin >> n;
    if (n == 2)
    {
        cout << 1;
        return 0;
    }
    for (int i = 1; i < n; i++)
    {
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    int maxx = 0;
    for (int i = 0; i < n; i++)
        maxx = max(maxx, (int)g[i].size());
    if (maxx == 2)
    {
        cout << 1;
        return 0;
    }
    int i = 0;
    while (g[i].size() == 1)
        i++;
    cout << dfs(i, -1);
    return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
bool ans=false;
void dfs(string str){
  if(ans)return;
  //cout<<str<<endl;
  if(str.size()<3)return;
  if(str.compare("ABC")==0){
    ans=true;
    return;
  }
  int cnta=0,cntb=0,cntc=0;
  string sa="",sb="",sc="";
  bool flag2=true;
  int i=0;
  for(int i=0;i<str.size();i++){
    if(str[i]=='A')cnta++;
    else if(str[i]=='B')cntb++;
    else cntc++;
  }
  int cnt=0;
  if(cnta<=cntb&&cnta<=cntc)cnt++;
  if(cntb<=cnta&&cntb<=cntc)cnt++;
  if(cntc<=cntb&&cntc<=cnta)cnt++;
  if(cnt>1)return;
  for(i=0;i<str.size()-2;i++){
    if(str.substr(i,3).compare("ABC")==0){
      sa+='A';sb+='B';sc+='C';
      flag2=false;
      i+=2;
    }else{
      sa+=str[i];sb+=str[i];sc+=str[i];
    }
  }
  sa+=str.substr(i,str.size()-i);
  sb+=str.substr(i,str.size()-i);
  sc+=str.substr(i,str.size()-i);
  if(flag2)return;
  dfs(sa);
  dfs(sb);
  dfs(sc);
}

int main(){
  string str;
  cin>>str;
  dfs(str);
  if(ans)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 46608
/*
ID: jerrywcy
TASK: AtCoder ABC 104 Problem B
LINK: https://abc104.contest.atcoder.jp/tasks/abc104_b
LANG: C++
*/
#include <bits/stdc++.h>

using namespace std;

string s;

bool up(char ch){
	return ('A'<=ch && ch<='Z');
}

int main()
{
	cin>>s;
	if (s[0]!='A'){
		cout<<"WA"<<endl;
		return 0;
	}
	int C=0,cntc=0;
	int i,j;
	if (up(s[1]) || up(s[s.size()-1])){
		cout<<"WA"<<endl;
		return 0;
	}
	for (i=2;i<s.size()-1;i++){
		if (s[i]=='C'){
			if (cntc){
				cout<<"WA"<<endl;
				return 0;
			}
			cntc++;
			C=i;
		}
		else if (up(s[i])){
			cout<<"WA"<<endl;
			return 0;
		}
	}
	if (C)cout<<"AC"<<endl;
	else cout<<"WA"<<endl;

	return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (H, W) = readLine()!!.split(" ").map{it.toInt()}

    val a = Array(H) { readLine()!! }.filter { it.any{it == '#'} }
    val b = (0 until W).filter { j -> a.any {it[j] == '#'} }

    a.forEach {s -> run {
        b.forEach { print(s[it]) }
        println()
    }}
}


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

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

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
template<typename T> class segtree {
private:
    int n,sz;
    vector<pair<T, int> > node;
public:
    segtree(vector<T>& v) : sz((int)v.size()){
        n = 1;
        while(n < sz){
            n *= 2;
        }
        node.resize(2*n, make_pair(numeric_limits<T>::max(), sz));
        for(int i = 0; i < sz; i++){
            node[i+n] = make_pair(v[i], i);
        }
        for(int i=n-1; i>=1; i--){
            node[i] = min(node[2*i], node[2*i+1]);
        }
    }
    void update(int k, T a)
    {
        node[k+n] = make_pair(a, k);
        k += n;
        while(k>>=1){
            node[k] = min(node[2*k], node[2*k+1]);
        }
    }
    pair<T, int> query(int a,int b,int k=0,int l=0,int r=-1)
    {
        pair<T, int> res1 = make_pair(numeric_limits<T>::max(), sz);
        pair<T, int> res2 = make_pair(numeric_limits<T>::max(), sz);
        a += n, b += n;
        while(a != b){
            if(a % 2) res1 = min(res1, node[a++]);
            if(b % 2) res2  = min(res2, node[--b]);
            a >>= 1, b>>= 1;
        }
        return min(res1, res2);
    }
    void print()
    {
        for(int i = 0; i < sz; i++){
            pair<T, int> p;
            p = query(i,i+1);
            cout << "st[" << i << "]: " << p.first << " " << p.second << endl;
        }
    }
};
struct dat{
    int l, r;
    int v;
    bool operator < (const dat &y) const{
        return v > y.v;
    }
};
int main(){
    int n;
    cin >> n;
    vector<int>a(n,INT_MAX/2);
    vector<int>b(n,INT_MAX/2);
    rep(i,n){
        if(i%2)cin >> a[i];
        else cin >> b[i];
    }
    segtree<int>seg1(a),seg2(b);
    vector<int>ans;
    priority_queue<dat>pq;
    pq.push({0,n-1,seg2.query(0,n-1).first});
    rep(_,n/2){
        auto x = pq.top();
        pq.pop();
        ans.push_back(x.v);
        int hoge = (x.l%2 ? seg1 :seg2).query(x.l,x.r+1).second;
//        (x.l%2 ? seg1 :seg2).update(hoge,INT_MAX/2);
        auto p = (x.l%2 ? seg2 : seg1).query(hoge,x.r+1);
        ans.push_back(p.first);
        int fuga = p.second;
//        (x.l%2 ? seg2 : seg1).update(fuga,INT_MAX/2);
        //x.l,hoge,fuga,x.r
        if(x.l<=hoge-1){
            pq.push({x.l,hoge-1, (x.l%2 ? seg1:seg2).query(x.l,hoge).first});
        }
        if(hoge+1<=fuga-1){
            pq.push({hoge+1,fuga-1,((hoge+1)%2 ? seg1:seg2).query(hoge+1,fuga).first});
        }
        if(fuga+1<=x.r){
            pq.push({fuga+1,x.r,((fuga+1)%2 ? seg1:seg2).query(fuga+1,x.r+1).first});
        }
    }
    rep(i,n){
        cout << ans[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 12712
#include<cstdio>
#include<algorithm>
#include<queue>
#include<map>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<set>
#include<unordered_map>
#include<vector>
typedef long long ll;
using namespace std;
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
struct triple{
	int sum;
	int last;
	int r;
}; 
queue<triple>Q;
int mn[100005];
int main(){
	int k;
	memset(mn,0x3f,sizeof(mn));
	scanf("%d",&k);
	Q.push((triple){1,1,1});
	while(!Q.empty()){
		triple tr=Q.front();Q.pop();
		int sum=tr.sum,last=tr.last,r=tr.r;
		if(mn[r]<=sum)continue;
		mn[r]=sum;
		Q.push((triple){sum,0,r*10%k});
		if(last!=9)Q.push((triple){sum+1,last+1,(r+1)%k});
	}
	printf("%d",mn[0]);
	return 0;
}


Measured memory_bytes: 1664
time = []
iti = 10
idx = -1
for i in range(5):
    x = int(input())
    y = x % 10
    if y != 0:
        if y < iti:
            iti = y
            idx = i
    time.append(x)

sum = 0


for i in range(5):

    if i != idx and time[i] % 10 != 0:
        sum += time[i] + (10 - time[i]%10)
    else:
        sum += time[i]

print(sum)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-


if __name__ == '__main__':
    C = [[-1 for i in range(3)] for j in range(3)]
    minv = 101
    min_a_i = -1  # 最小のときのaの添字
    min_b_i = -1
    for a_i in range(3):
        lists = list(map(int, input().split()))
        for b_i in range(3):
            C[a_i][b_i] = lists[b_i]
            if lists[b_i] < minv:
                minv = lists[b_i]
                min_a_i = a_i
                min_b_i = b_i

    # 最小の値から、aとbの取りうる範囲を全探索する
    for v in range(0, minv+1):
        A = [-1]*3
        B = [-1]*3
        A[min_a_i] = v
        for b_i in range(3):
            B[b_i] = C[min_a_i][b_i] - v
        a_i = min_a_i
        for _ in range(2):
            a_i += 1
            if a_i == 3: a_i = 0
            A[a_i] = C[a_i][a_i] - B[a_i]
        # ansCを作って元のCと比較する
        ans = [[-1 for i in range(3)] for j in range(3)]
        for a_i in range(3):
            for b_i in range(3):
                ans[a_i][b_i] = A[a_i] + B[b_i]
        if ans == C:
            print("Yes")
            exit()
    print("No")


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=2147483647;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
const int maxn=3e3+5;
ll x,a[maxn];
int main(){
	x=read();
	for(int i=1;i<=3000;i++) a[i]=(ll)i*i*i*i*i;
	for(int i=0;i<=3000;i++)
		for(int j=0;j<=3000;j++){
			if(a[i]+a[j]==x){
				printf("%d %d\n",i,-j);
				return 0;
			}
			if(a[i]-a[j]==x){
				printf("%d %d\n",i,j);
				return 0;
			}
		}
	return 0;
}

Measured memory_bytes: 3732
import java.io.*;
 
class Main{
    public static void main(String[] args) throws Exception{
        int x, ans;
     
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        x = Integer.parseInt(br.readLine());
         
        ans = x*x*x;
        System.out.println(ans);
    }
}

Measured memory_bytes: 24372
using System;

public class hello
{
    public static void Main()
    {
        var seiseki = "";
        while (true)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var m = int.Parse(line[0]);
            var r = int.Parse(line[1]);
            var f = int.Parse(line[2]);
            if ((m==-1) && (r== -1) &&(f ==-1) )goto readend;

            if ( (m == -1) | (r == -1))
            {
                seiseki = "F";
                goto nextread;
            }
            if ( m+r >= 80)
            {
                seiseki = "A";
                goto nextread;
            }
            if   (  (m+r < 80) &&(m + r >= 65))
            {
                seiseki = "B";
                goto nextread;
            }
            if ((m + r < 65) && (m + r >= 50))
            {
                seiseki = "C";
                goto nextread;
            }
            if ((m + r < 50) && (m + r >= 30) &&(f >=50))
            {
                seiseki = "C";
                goto nextread;
            }
            if ((m + r < 50) && (m + r >= 30) && (f < 50))
            {
                seiseki = "D";
                goto nextread;
            }
            if ((m + r < 30) )
            {
                seiseki = "F";
                goto nextread;
            }
            nextread:;
            Console.WriteLine(seiseki);
       }
       readend:;
    }
}

Measured memory_bytes: 8868
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(int i = a;i < b; i++)

int main() {

	int n, d;
	cin >> n >> d;

	vector<vector<int>> x(n, vector<int>(d));
	rep(i, 0, n) {
		rep(j, 0, d) {
			cin >> x[i][j];
		}
	}

	int ans = 0, count = 0, diff = 0;

	rep(i, 0, n - 1) {
		rep(j, i + 1, n) {
			rep(k, 0, d) {
				diff = (x[i][k] - x[j][k]);
				diff *= diff;
				ans += diff;
			}
			for(int l = 0; l <= ans; l++) {
				if (l * l == ans) count++;
			}
			ans = 0;
		}
	}

	cout << count << endl;

	return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<bool> fl(40005);
    for (int bit = 0; bit < (1 << N); ++bit) {
        int sum = 0;
        rep(i, N) {
            if (bit & (1 << i))
                sum += A[i];
        }

        fl[sum] = true;
    }

    int q;
    cin >> q;
    rep(i, q) {
        int m;
        cin >> m;
        fl[m] ? cout << "yes" : cout << "no";
        cout << endl;
    }

    return 0;
}


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

int main(int argc, char const *argv[]) {
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int m, f, r;
  while (1) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) break;
    if (m == -1 || f == -1) cout << "F" << endl;
    else if (m+f >= 80) cout << "A" << endl;
    else if (m+f >= 65) cout << "B" << endl;
    else if (m+f >= 50 || r >= 50) cout << "C" << endl;
    else if (m+f >= 30) cout << "D" << endl;
    else cout << "F" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


class V:
    def __init__(self, f, v=None):
        self.f = f
        self.v = v
 
    def __str__(self):
        return str(self.v)
 
    def ud(self, n):
        if n is None:
            return

        if self.v is None:
            self.v = n
            return
        self.v = self.f(self.v, n) 


def print_ans(B):
    for b in B:
        b.sort(key=lambda l: int(l))
        print(" ".join(b))



def main():
    N, K = read_values()
    A = list(read_index())

    P = [-1] * N

    k = 0
    n = 0
    while P[n] == -1: 
        P[n] = k
        n = A[n]
        k += 1

    if k > K:
        print(P.index(K) + 1)
        return

    a = (K - P[n]) % (k - P[n]) + P[n]
    print(P.index(a) + 1)

if __name__ == "__main__":
    main()



Measured memory_bytes: 32340
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  k, n = map(int, input().split())
  la = list(map(lambda x:int(x)%k, input().split()))
  la.sort()
  diff = [(la[i] - la[i-1])%k for i in range(len(la))]
  print(k - max(diff))
  

if __name__=='__main__':
  main()



Measured memory_bytes: 25580
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		// scanner.nextLine();
		String line = scanner.nextLine();

		long H = Long.parseLong(line.split("\\s+")[0]);

		HashMap<Long, Long> mem = new HashMap<>();

		long res = dfs(H, mem);
		System.out.println(res);

		return;
	}

	public long dfs(long x, Map<Long, Long> mem) {
		if (x == 1) return 1;

		long key = x;
		if (mem.containsKey(key)) return mem.get(key);

		long res = 2 * dfs(x/2, mem) + 1;
		mem.put(key, res);

		return res;
	}

	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}
}

// f(x) = 2 * f( floor(x/2) ) + 1;
// f(1) = 1;


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

int a[5001]={0};

int main(){
    int n;
    while(cin >> n, n != 0){
        for(int i=0;i<n;++i)cin >> a[i];
        int maxi = INT_MIN;
        for(int i=0;i<n;++i){
            int sum = a[i];
            if(sum > maxi)maxi = sum;
            for(int j=1;i+j<n;++j){
                sum += a[i+j];
                if(sum > maxi)maxi = sum;
            }
        }
        cout << maxi << endl;
    }

    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
#define popcount __builtin_popcount
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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;
}



int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long T;
    scanf("%lld",&T);
    ll r = (N+X-1)/X;
    cout << r*T << endl;
    return 0;
}


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

using namespace std;
int main()

{
    int a,b,c;
    cin>>a>>b>>c;

    if(a==b){
        cout<<c<<endl;
    }
    else if(a==c){
        cout<<b<<endl;
    }
    else if(b==c){
        cout<<a<<endl;
    }



return 0;

}

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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c;
    if (a>b){
        k=a;
        a=b;
        b=k;
    }
    if (b>c){
        k=c;
        c=b;
        b=k;
    }
    if (a>b){
        k=a;
        a=b;
        b=k;
    }
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3088
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
      h:usize,
      w:usize,
      board: [chars; h],
    }
    let mut iroha:Vec<String> = Vec::new();

    for s in board{
      iroha.push(s.into_iter().collect());
    }

    iroha.sort();

    for s in iroha{
      print!("{}", s);
    }
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 1e9 + 7;

ll N,a[5],b[6];

ll cul(ll N, ll al) {
	ll ans = 0;
	if (N%al != 0)ans++;
	ans += (N / al);
	return ans;
}

int main() {

	cin >> N>>a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	
	ll ans = cul(N, a[0]);
	FOR(i, 1, 5) {
		if (a[i] >= a[i-1]) {
			a[i] = a[i - 1];
			ans++;
		}
		else {
			ans = i + cul(N, a[i]);
		}
	}
	cout << ans << endl;



	return 0;
}

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

using namespace std;

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

  int h, w;
  cin >> h >> w;

  for (int i = 0; i < h; ++i) {
    string s;
    cin >> s;
    cout << s << '\n';
    cout << s << '\n';
  }

  return 0;
}


Measured memory_bytes: 3624
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N;
pair<ll,ll> p[300010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N)cin>>p[i].sec>>p[i].fir;
	sort(p,p+N);
	reverse(p,p+N);
	ll lo=-1,hi=N+1;
	while(lo+1<hi){
		ll M=(lo+hi)/2;
		multiset<ll> S;
		ll sum=0;
		rep(i,M){
			S.insert(p[i].sec);
			sum+=p[i].sec;
		}
		int ok=0;
		rep(i,N-M+1){
			if(sum<=p[i+M-1].fir*M){
				ok=1;break;
			}
			if(i==N-M)break;
			S.insert(p[i+M].sec);
			sum+=p[i+M].sec;
			multiset<ll>::ite it=S.lower_bound(*S.rbegin());
			sum-=*it;
			S.erase(it);
		}
		if(ok)lo=M;
		else hi=M;
	}
	cout<<lo<<endl;
}

Measured memory_bytes: 19852
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF (ll)1e18
#define INF (int)1e9
using namespace std;

int main(){
  ll s;
  cin >> s;

  ll y3 = (s-1) / INF + 1,x3 = y3*INF - s;

  cout << 0 << " " << 0 << " " << INF << " " << 1 << " " << x3 << " " << y3 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> D1(N), D2(N);
	for (int i = 0; i < N; ++i) {
		cin >> D1[i] >> D2[i];
	}

	bool ans = false;

	int cnt = 0;
	for (int i = 0; i < N; ++i) {
		if (D1[i] == D2[i]) {
			++cnt;
		}
		else {
			cnt = 0;
		}
		if (cnt >= 3) {
			ans = true;
		}
	}

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3604
N = int(input())
d = {}
for i in range(N):
    s = str(input())
    if not s in d:
        d[s] = 1
    else:
        d[s] = d[s] + 1
max = 0
res = []
for key in d:
    num = d[key]
    if num < max:
        continue
    elif num == max:
        res.append(key)
    else:
        max = num
        res = [key]
res.sort()
for r in res:
    print(r)


Measured memory_bytes: 92376
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}

long long gcd(long long a, long long b) {return b ? gcd(b, a % b) : a;}
long long lcm(long long m, long long n ){if((0 == m )||( 0 == n ))return 0;
    return ((m / gcd(m, n)) * n);
}

signed main(){
    int n;
    cin >> n;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    sort(all(v));
    int res = v.front();
    for(int i = 1; i < v.size();i++){
        res = gcd(res, v[i]);
    }
    cout << res << endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int N, T;
  cin >> N >> T;
  int ans = 1e9;
  rep(i, 0, N) {
    int c, t;
    cin >> c >> t;
    if (t <= T)
      chmin(ans, c);
  }
  if (ans == 1e9)
    cout << "TLE" << endl;
  else
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sca = new Scanner(System.in);
		int x = sca.nextInt();
		final int onigiri = 100;
		final int sandich = 101;
		final int cooky = 102;
		final int cake = 103;
		final int ame = 104;
		final int pc = 105;
		int max = 100000;
		for(int i = 0; i <= x/pc; i++) {
			for(int j = 0; j <= (x-pc*i)/ame; j++) {
				for(int k = 0; k <= (x-pc*i-ame*j)/cake; k++) {
					for(int l = 0; l <= (x-pc*i-ame*j-cake*k)/cooky; l++) {
						for(int m = 0; m <= (x-pc*i-ame*j-cake*k-cooky*l)/sandich; m++) {
							for(int n = 0; n <= (x-pc*i-ame*j-cake*k-cooky*l-sandich*m)/onigiri; n++) {
								if(x == n*onigiri + m*sandich + l*cooky + k*cake + j*ame + i*pc) {
									System.out.println(1);
									return;
								}
							}
						}
					}
				}
			}
		}
		System.out.println(0);
	}
}


Measured memory_bytes: 24020
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int k;
main() {
  file("threesum");
  ios;
  cin >> k;
  ll ans = 0;
  fo(a, 1, k, 1) fo(b, 1, k, 1) fo(c, 1, k, 1) ans += 0ll + __gcd(a, __gcd(b, c));
  cout << ans;
  return 0;
}
/**

*/


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>

#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;

typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int,int> P;

const int MOD = 1000000007;

ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

ll mod_factrial_up(ll start, ll end){
  ll sum=1;
  for(ll i=start;i>=end; i--){
    sum = (sum * i) % MOD;
  }
  return sum;
}

// mod_factrial(N,k+1): nCkの分母：(n-k)^p-2 * (n-k-1)^p-2 * ... * 1^p-2 を計算
ll mod_factrial_down(ll start, ll end){
  ll sum=1;
  for(ll i=start; i>=end;i--){
    sum = (sum * i) % MOD;
    // sum = (sum * modpow(i,MOD-2) ) % MOD;
  }
  sum = modpow(sum,MOD-2);
  return sum;
}


int main(int argc, const char * argv[]) {
  ll N,a,b; cin >> N >> a >> b;
  ll sum = (modpow(2,N)-1 - (mod_factrial_up(N,N-a+1) * mod_factrial_down(a,1))%MOD - (mod_factrial_up(N,N-b+1) * mod_factrial_down(b,1))%MOD ) %MOD;
  if (sum<0) sum += MOD;
   cout << sum << endl;
  //  cout << -1 % MOD << endl;
}


Measured memory_bytes: 764
#!/usr/bin/env python3
import sys


def euclid_gcd(a: int, b: int):
    if a < b:
        return euclid_gcd(b, a)
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return b


def solve(N: int, A: "List[int]"):
    lastGCD = A[0]
    for i in range(1, N):
        lastGCD = euclid_gcd(lastGCD, A[i])
    print(lastGCD)
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 15140
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    rep(i, n) cin >> p[i];

    sort(all(p));
    ll ans = 0;
    rep(i, k){
        ans += p[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N1 100100
#define N2 1000010
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int a[10010];

signed main()
{
    
    speed
    int n,m;cin>>n>>m;
    int su=0;
    rep(i,1,n){
        cin>>a[i];
        su+=a[i];
    }
    int f=0;
    sort(a+1,a+1+n);
    reverse(a+1,a+1+n);
    for(int i=1;i<=m;i++){
        if(a[i]*4*m<su){
            cout<<"No"<<endl;
            f=1;
            break;
        }
    }
    if(!f)
        cout<<"Yes"<<endl;

    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
int main()
{
	char m=getchar(),d=getchar();
	printf((((!(m-57))||(!(d-57)))?("Yes"):("No")));
	putchar(10);
	return 0;
}

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

#define jaldi ios_base::sync_with_stdio(false)
#define fr(i,j,n) for(i=j;i<n;i++)
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%ld",&x)
#define sll(x) scanf("%lld",&x)
#define sc(x) scanf("%c",&x)
#define ss(x) scanf("%s",x)
#define pi(x) printf("%d",x)
#define pl(x) printf("%ld",x)
#define pll(x) printf("%lld",x)
#define pc(x) printf("%c",x)
#define ps(x) printf("%s",x)
#define vi vector<int> 
#define vl vector<long> 
#define vll vector<long long>
#define vc vector<char>  
#define vs vector<string>
#define vvi vector<vector<int>> 
#define vvll vector<vector<long long>> 
#define F first
#define S second
#define ll long long
#define pb push_back
#define ppii pair<int,int> 
#define ppll pair<long long,long long>
#define ppcc pair<char,char>
#define ppss pair<string,string> 
#define vpll vector<pair<long long,long long>>
#define PI 3.1415926535897932384626
#define precision(x) cout<<fixed<<setprecision(x) 
#define mod 1000000007

int x_d[8] = {-1,1,0,0,-1,-1,1,1};
int y_d[8] = {0,0,-1,1,-1,1,-1,1};

ll power(ll b,ll e)
{
    if(b==0)
        return 0;
    
    ll r=1;
    while(e>0)
    {
        if(e%2)
            r=(r*b)%mod;
        b=(b*b)%mod;
        e/=2;
    }
    return r;
}

int main()
{
    jaldi;
    precision(20);
    ll i,j;

    ll x;
    cin>>x;
    ll f=0;
    for(i=-1000;i<=1000;i++)
    {
        ll a = i*i*i*i*i;
        for(j=-1000;j<=1000;j++)
        {
            ll b = j*j*j*j*j;
            // cout<<a<<" "<<b<<" ";
            // break;
            if(a-b==x)
            {
                f=1;
                break;
            }
        }
        if(f==1)
            break;
    }
    cout<<i<<" "<<j;

    return 0;
}

Measured memory_bytes: 3556