akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int tac;
int n;
int k[200010],l[200010],r[200010];
vector<PII> v[3];
int a[200010];
set<int> st;
int main()
{
	scanf("%d",&tac);
	while (tac--)
	{
		scanf("%d",&n);
		for (int i=0;i<3;i++) v[i].clear();
		for (int i=0;i<n;i++)
		{
			scanf("%d%d%d",&k[i],&l[i],&r[i]);
			if (l[i]>r[i]) v[0].push_back(MP(r[i]-l[i],i));
			else if (l[i]<r[i]) v[1].push_back(MP(l[i]-r[i],i));
			else v[2].push_back(MP(0,i));
		}
		sort(v[0].begin(),v[0].end());
		sort(v[1].begin(),v[1].end());
		vector<int> vr;
		st.clear();
		for (int i=0;i<n;i++) a[i]=-1,st.insert(i);
		int ta=n-1;
		for (int i=0;i<v[0].size();i++)
		{
			int t=v[0][i].Snd;
			set<int>::iterator it=st.upper_bound(k[t]-1);
			if (it!=st.begin()) it--,a[*it]=t,st.erase(it);
			else
			{
				while (a[ta]!=-1 && ta>=0) ta--;
				a[ta]=t,st.erase(ta);
				while (a[ta]!=-1 && ta>=0) ta--;
			}
		} 
		for (int i=0;i<n;i++) if (a[i]!=-1) vr.push_back(a[i]);
		//cout <<v[0].size()<<" "<<vr.size()<<" ##\n";
		for (int i=0;i<v[2].size();i++) vr.push_back(v[2][i].Snd);
		for (int i=0;i<n;i++) a[i]=-1,st.insert(i);
		ta=0;
		for (int i=0;i<v[1].size();i++)
		{
			int t=v[1][i].Snd;
			set<int>::iterator it=st.lower_bound(k[t]);
			//cout <<*it<<" ##\n";
			if (it!=st.end()) a[*it]=t,st.erase(it);
			else
			{
				while (a[ta]!=-1 && ta<n) ta++;
				a[ta]=t,st.erase(ta);
				while (a[ta]!=-1 && ta<n) ta++;
			}
		}
		for (int i=0;i<n;i++) if (a[i]!=-1) vr.push_back(a[i]);
		//cout <<v[1].size()<<" "<<vr.size()<<" ##\n";
		ll res=0;
		for (int i=0;i<n;i++)
		{
			int t=vr[i];
			//cout <<vr[i]<<" ##\n";
			if (i<k[t]) res+=l[t];
			else res+=r[t];
		}
		printf("%lld\n",res);
	}
	return 0;
} 

Measured memory_bytes: 18992
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll D, N;
    cin >> D >> N;

    ll ans = 0;
    ll count = 1;
    if(D == 0){
        ans = 1;
        while(count < N){
            if(ans % 100 != 99){
                count++;
            }
            ans++;
        }
    }else if(D == 1){
        ans = 100;
        while(count < N){
            if(ans % 10000 != 9900){
                count++;
            }
            ans += 100;
        }
    }else{
        ans = 10000;
        while(count < N){
            if(ans % 1000000 != 990000){
                count++;
            }
            ans += 10000;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3600
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] b = new int[n];
        Arrays.fill(b, 1);
        boolean[] r = new boolean[n];
        r[0] = true;
        int ans = 1;
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt() -1;
            int y = sc.nextInt() -1;
            b[x]--;
            b[y]++;
            if(r[x]){
                if(!r[y]){
                    ans++;
                    r[y] = true;
                }
                if(b[x] == 0){
                    ans--;
                    r[x] = false;
                }
            }
        }

        System.out.println(ans);
        sc.close();
    }

}


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

#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

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

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }


const int nax = 3003;
ll dp[nax][nax][3];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll n;cin>>n;
	std::vector<ll> a(n);
	ll sum =0;
	REP(i,n){
		cin>>a[i];
		sum+=a[i];
	}

	REP(i,n){
		dp[i][i][0] = a[i];
		dp[i][i][1] = 0;
	}
	for(ll ad = 1 ; ad<n;ad++){
		for(ll i =0;i<n-ad;i++)
		{
			ll j = i+ad;
			dp[i][j][0] = max(dp[i+1][j][1] + a[i] , dp[i][j-1][1] + a[j]);


			dp[i][j][1] = min(dp[i+1][j][0] , dp[i][j-1][0] );

		}
	}

	//REP(i,n){REP(j,n){cout<<dp[i][j][0]<<" ";}cout << "\n";}

	std::cout << (2*dp[0][n-1][0]) - sum << "\n";
		return 0;
}


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

bool isprime(long long a){
    if(a<=1) return false;
    for(long long i=2;i*i<=a;i++){
        if(a%i==0LL) return false;
    }
    return true;
}

map<long long,long long> cnt;

void fact(long long a){
    for(long long i=2;i<=a;i++){
        while(a%i==0LL){
            cnt[i]++;
            a/=i;
            cerr<<i<<endl;
        }
    }
}

const long long MAX = 510000;
const long long mod = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    long long n,m;
    cin>>n>>m;

    long long ans=1;

    if(isprime(m)){
        cout<<n<<endl;
        return 0;
    }

    fact(m);
    COMinit();

    for(auto i:cnt){
        ans*=COM(i.second+n-1,i.second);
        ans%=mod;
        cerr<<i.second<<endl;
    }
    cout<<ans<<endl;

    

}

Measured memory_bytes: 12288
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int h,w,k,a[10][1005]={0},ans=4e18,cnt[10],x,cur;
string str[10];
bool ok;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> h >> w >> k;
	rep(h) cin >> str[i];
	rep(h) rep1(j,w) a[i][j]=(int)(str[i][j]-'0');
	rep(pow2(h-1)){
		cur=__builtin_popcountll(i);
		rep1(j,h) cnt[j]=0;
		rep1(j,w){
			cnt[0]+=a[0][j];
			x=0;
			ok=true;
			rep1(l,h-1){
				if(i&pow2(l)) x++;
				cnt[x]+=a[l+1][j];
			}
			rep1(l,h) if(cnt[l]>k) ok=false;
			if(!ok){
				debug(j);
				debug("cut");
				rep1(l,h) cnt[l]=0;
				cur++;
				cnt[0]+=a[0][j];
				x=0;
				ok=true;
				rep1(l,h-1){
					if(i&pow2(l)) x++;
					cnt[x]+=a[l+1][j];
				}
				rep1(l,h) if(cnt[l]>k) ok=false;
				if(!ok){
					cur=4e18;
					break;
				}
			}
			debug(cnt[0]);
		}
		ans=min(ans,cur);
		debug(cur);
	}
	print1(ans);
	return 0;
}

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

typedef unsigned long long ll;
#define mod 1000000007
#define all(x) (x).begin(),(x).end()

void solve(){
  string s,t;
  cin>>s>>t;
  int cnt=t.size();
  for(int i=0;i<=s.size()-t.size();i++){
  	int diff=0;
  	for(int j=0;j<t.size();j++){
  		if(t[j] != s[j+i])
  			diff++;
	  }
	  cnt = min(cnt,diff);
  }
  cout<<cnt<<endl;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
  return 0;
}


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

const int M = 1e6 + 5;
int arr[M];

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

    int ans = 0, val = n;

    for(int i = 1; i <= n; i++){
        for(int j = i; j <= n; j += i){
            arr[j]++;
        }
    }

    for(int i = 1; i <= n; i++){
        val = n - i;

        ans += arr[val];
    }

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

int main()
{
    int tc = 1;
    //cin >> tc;

    while(tc--) solve();

    return 0;
}


Measured memory_bytes: 7520
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char c;
	cin>>c;
	if(c=='A')
		cout<<'T'<<endl;
	if(c=='C')
		cout<<'G'<<endl;
	if(c=='G')
		cout<<'C'<<endl;
	if(c=='T')
		cout<<'A'<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define arrprint(v,n) rep(i,0,n-1)cout << v[i] << " ";cout << endl;
#define matprint(v,n,m) rep(i,0,n-1){rep(j,0,m-1){cout << v[i][j] << " ";}cout << endl;}
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,0,n-1)cin >> h[i];
    sort(h.begin(),h.end(),greater<int>());
    ll ans = 0;
    rep(i,k,n-1)ans += h[i];

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 1024
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

insertList :: (Ord a) => [a] -> a -> [a]
insertList [] a = [a]
insertList xxs@(x:xs) a
  | a < x = a : xxs
  | otherwise = x : insertList xs a

f :: [Int] -> [[Int]]
f xs = tail $ zipWith (++) (scanl insertList [] xs) (scanr (:) [] xs)

main :: IO ()
main =
  getLine >> -- n を捨てる
    map (read :: String -> Int) . words <$> getLine >>=
      putStr
      . unlines
      . map (unwords . map show) . f



Measured memory_bytes: 4024
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int, int> pi;
typedef pair<int, pi> pii;

struct edge {
	int to, cost;
	edge(int to, int cost) : to(to), cost(cost) {}
};
const int INF = (int)(1e+9);
int N, M;
vector<vector<edge> > G;
vector<int> d;
vector<int> mark;

void input_init(void) {
	cin >> N >> M;
	G.resize(N + 1);
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		edge ea = edge(b, 1);
		edge eb = edge(a, 1);
		G[a].push_back(ea);
		G[b].push_back(eb);
	}
}

void dijkstra(int s) {
	priority_queue<pii, vector<pii>, greater<pii> > que;
	d.resize(N + 1, INF);
	d[s] = 0;
	mark.resize(N + 1, -1);
	que.push(make_pair(0, make_pair(s, 0)));
	
	while (!que.empty()) {
		pii p = que.top();
		que.pop();
		int v = p.second.first;
		if (d[v] < p.first)
			continue;
		for (int i = 0; i < (int)G[v].size(); ++i) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				mark[v] = p.second.second;
				que.push(make_pair(d[e.to], make_pair(e.to, v)));
			}
			else
				mark[v] = p.second.second;
		}
	}
}

void print_ans(void) {
	bool res = true;
	for (int i = 2; i <= N; ++i) {
		if (d[i] == INF) {
			res = false;
			break;
		}
	}
	if (!res)
		cout << "No" << '\n';
	else {
		cout << "Yes" << '\n';
		for (int i = 2; i <= N; ++i)
			cout << mark[i] << '\n';
	}
}

int main(void) {
	input_init();
	dijkstra(1);
	print_ans();
	return 0;
}


Measured memory_bytes: 14512
import sys
stdin = sys.stdin

     
ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
N,M=nm()
A=nl()

h_sum=sum(A)
print(N-h_sum if N-h_sum>=0 else -1)

Measured memory_bytes: 9992
n,k = gets.split.map(&:to_i)
m = []
i = 1
for i in 1..k
    d = gets.split[0].to_i
    dnum = gets.split.map(&:to_i)
    j = 0
    for j in 0..d-1 
        m.push(dnum[j])
    end
end
puts n - m.uniq.size

Measured memory_bytes: 14332
import sys
import heapq

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    cost = dict()
    for i in range(2 ** N): cost[i] = -1
    cost[0] = 0
    for i in range(M):
        a, b = map(int, input().split())
        c = [int(c) for c in input().split()]
        bit = 0
        for j in c: bit += 2 ** (j - 1)
        for i in range(2 ** N):
            if cost[i] > -1:
                if cost[i | bit] > -1:
                    cost[i | bit] = min(cost[i | bit], cost[i] + a)
                else: cost[i | bit] = cost[i] + a

    #print(cost)

    print(cost[2 ** N - 1])
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    long long int a,c;
    float b;
    cin>>a>>b;
    c= round(100*b);
    cout<<(a*c)/100<<endl;
    return 0;
}


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

using namespace std;
using ll = long long;


int main()
{
    string s;
    set<char> st;
    cin >> s;
    st.insert(s[0]);
    st.insert(s[1]);
    st.insert(s[2]);
    cout << (st.size() == 2 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define FOR(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";

//#include<boost/multiprecision/cpp_int.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//(Uncomment when needed and be sure it not give TLE bcoz it requires time)
//#pragma GCC optimize "trapv"//to check integer overflow and gives RE.
//typedef tree<pair<int,int>,null_type, 
//less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("O3")
//uncoment for large int requirement
//using boost::multiprecision::cpp_int;
//using namespace _gnu_pbds;

using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//use it with unordered_map<T,T,custom_hash> safe_map

int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main()
{fast_io

int t;
//cin>>t;
t = 1;
while(t--)
{
    int x;
    cin>>x;
    if(x>=30)
    cout<<"Yes\n";
    else 
    cout<<"No\n";
}
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define len(s) s.length()
#define forp(i,a,b) for( i=a;i<=b;i++)
#define rep(i,n)    for( i=0;i<n;i++)
#define ren(i,n)    for( i=n-1;i>=0;i--)
#define forn(i,a,b) for( i=a;i>=b;i--)
#define all(v) v.begin(),v.end()
#define b(v) v.begin()
#define e(v) v.end()
#define mem(n,m) memset(n,m,sizeof(n))
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define pll pair<long long,long long>
#define vii vector<int>
#define vll vector<long long>
#define gl(cin,s)  getline(cin,s);
#define bitc(n) __builtin_popcountll(n)
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define boost ios_base::sync_with_stdio(0)
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define SIZE 200010

typedef long long  ll;
typedef unsigned long long ull;
typedef long double  ldo;
typedef double  db ;
using namespace std;
int N;
int A[SIZE];
int B[SIZE];
long long tree[4*SIZE];
long long query(int node,int s,int e,int l,int r)
{
    if(e < l or s > r)
        return 0;
    if(s >= l and e <= r)
        return tree[node];
    int mid = (s+e)>>1;
    return max(query(2*node,s,mid,l,r),query(2*node+1,mid+1,e,l,r));
}
void upd(int node,int s,int e,int v,long long x)
{
    if(s == e){
        tree[node] = x;
        return ;
    }
    int mid = (s+e)>>1;
    if(v <= mid){
        upd(2*node,s,mid,v,x);
    }
    else{
        upd(2*node+1,mid+1,e,v,x);
    }
    tree[node] = max(tree[2*node],tree[2*node+1]);
}
int main()
{
    boost;
    int N;
    cin>>N;
    for(int i=1;i<=N;i++){
        cin>>A[i];
    }
    for(int i=1;i<=N;i++){
        cin>>B[i];
    }
    long long fans = 0;
    for(int i=1;i<=N;i++){
        long long currAns = B[i] + query(1,1,N,1,A[i]);
        upd(1,1,N,A[i],currAns);
        fans = max(fans,currAns);
    }
    cout<<fans<<endl;
    return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {

    int N;
    cin >> N;
    int t = 0, x = 0, y = 0;
    int tt, xx, yy;
    bool flag = true;
    REP(i, N){
        cin >> tt >> xx >> yy;
        if (!flag) continue;
        int tmp = tt - t - abs(yy - y) - abs(xx - x);
        if (tmp < 0 || tmp % 2 != 0) {flag = false;}
    }
    string s = "Yes";
    if(!flag) s = "No";
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
#define INF 1000000007
#define MOD 1000000007

#define ARRAY_MAX 15

int d[ARRAY_MAX][ARRAY_MAX];
int arr[ARRAY_MAX];

int main(){

    int n;
    while(cin >> n,n){
        REP(i,ARRAY_MAX){
            REP(j,ARRAY_MAX){
                d[i][j] = 0;
            }
        }
        REP(i,n){
            REP(j,5){
                cin >> d[i][j];
            }
        }

        int ans = 0;

        while(1){

            bool exist = false;//消せるものがあるかどうか
            int cnt = 1;

            for(int i = n-1;i >= 0;i--){
                for(int j = 0;j < 5;j++){
                    if(j != 4 && d[i][j] == d[i][j+1]){
                        cnt++;
                    }else{
                        if(cnt >= 3 && d[i][j] != 0){//0で埋めたやつを考慮
                            ans += cnt*d[i][j];
                            exist = true;
                            for(int k = 0;k < cnt;k++){
                                d[i][j-k] = 0;//消したら0で埋める
                            }
                        }
                        cnt = 1;
                    }
                }
            }

            REP(hoge,n){
                for(int i = n-1;i > 0;i--){
                    for(int j = 0;j < 5;j++){
                        if(d[i][j] == 0 && d[i-1][j] != 0){
                            d[i][j] = d[i-1][j];
                            d[i-1][j] = 0;
                        }
                    }
                }
            }

        
            if(!exist){
                break;
            }
        }
        cout << ans << endl;
    }


    return 0;
}



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

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

int main()
{
    int k, x;
    cin >> k >> x;

    if(k * 500 >= x)
        cout << "Yes";
    else
        cout << "No";

    return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF=2e18+10;

int main()
{
    ll n,m;

    while(cin>>n>>m)
    {
        vector<ll> v(n+1),w(n+1);
        for(int i=0;i<n;i++)
        {
            cin>>v[i]>>w[i];
        }
        vector<pair<ll,ll> > a;
        for(int i=0;i<(1<<(n/2));i++)
        {
            ll sv=0,sw=0;
            for(int j=0;j<n/2;j++)
            {
                if((i>>j)&1)
                {
                    sv+=v[j];
                    sw+=w[j];
                }
            }
            a.push_back(make_pair(sw,sv));
        }
        sort(a.begin(),a.end());
        ll Max=-INF;
        for(int i=0;i<a.size();i++)
        {
            a[i].second=max(a[i].second,Max);
            Max=a[i].second;
        }
        ll ans=0;
        for(int i=0;i<(1<<(n-n/2));i++)
        {
            ll sv=0,sw=0;
            for(int j=0;j<n-n/2;j++)
            {
                if((i>>j)&1)
                {
                    sv+=v[j+n/2];
                    sw+=w[j+n/2];
                }
            }
            if(sw<=m)
            {
                ll tv=(upper_bound(a.begin(),a.end(),make_pair(m-sw,INF))-1)->second;
                ans=max(ans,tv+sv);
            }

        }
        cout<<ans<<endl;
    }

    return 0;
}



Measured memory_bytes: 19480
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 1e9
#define Inf 1000000000000000000LL
using namespace std;
typedef pair<int,int>pii;
int n,k;
bool ok=1;
vector<int>G[100010];
int id[100010];
int L[100010],R[100010];
void solve(int v=0,int p=-1){
	L[v]=-INF-1,R[v]=INF+1;
	if(id[v]!=-1)L[v]=R[v]=id[v];
	for(auto to:G[v]){
		if(to!=p){
			solve(to,v);
			if(L[to]<-INF/2)continue;
			if(L[v]<-INF/2){
				L[v]=L[to]-1;
				R[v]=R[to]+1;
			}else{
				if(abs(L[to])%2==abs(L[v])%2){
					ok=0;
					return;
				}
				L[v]=max(L[v],L[to]-1);
				R[v]=min(R[v],R[to]+1);
			}
		}
	}
	if(L[v]>R[v])ok=0;
}
void make(int v=0,int p=-1){
	if(v==0&&id[v]==-1)id[v]=L[v];
	for(auto to:G[v]){
		if(to!=p){
			if(id[to]==-1){
				if(L[to]<=id[v]-1&&id[v]-1<=R[to])id[to]=id[v]-1;
				else id[to]=id[v]+1;
			}
			make(to,v);
		}
	}
}
int main(){
	memset(id,-1,sizeof(id));
	cin>>n;
	for(int i=0,x,y;i<n-1;i++){
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	cin>>k;
	for(int i=0,x,y;i<k;i++){
		cin>>x>>y;
		x--;
		id[x]=y;
	}
	solve();
	if(!ok){
		puts("No");
		return 0;
	}else{
		make();
		puts("Yes");
		for(int i=0;i<n;i++)cout<<id[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 13824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<ll> vec(N);
    for(int i = 0;i < N;i++) {
        int A;
        cin >> A;
        vec.at(A - 1) = i;
    }
    ll ret = 0;
    multiset<int> ms{-1,N};
    for(ll i = 0;i < N;i++) {
        auto itr = ms.upper_bound(vec.at(i));
        ll A = *itr;
        --itr;
        ll B = *itr;
        ret += (i + 1) * (A - vec.at(i)) * (vec.at(i) - B);
        ms.insert(vec.at(i));
    }
    cout << ret << endl;
}

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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
#define debug(x) cerr << #x << " = " << x << endl;

// template starts
typedef long long int ll;

// template ends here

// TO ADD: LCA, Dijkstra's

ll N; // no of vertices and no of edges
vector<vector<pair<int,int>>> adj;
vector<ll> dist;

void resizeAll(){	
	dist.resize(N);
	adj.resize(N);
	
	for(int i = 0; i < N; i++){
		dist[i] = 1e7;
	}
}

int N2, M2;
int startx,starty,endx,endy;
vector<string> g;
int ans = INT_MAX;

bool valid(int i, int j){
	if(i < 0 || j < 0 || i >= N2 || j >= M2) return false;
	return g[i][j] != '#';
}
// IMPORTANT: Everything here is 0 based index!!!!

int dij(){
	set<pair<int,int>> s;
	int start = startx*M2 + starty;
	
	dist[start] = 0;
	s.insert(mp(0,start));
	
	while(s.size() > 0){
		auto p  = *s.begin();
		s.erase(s.begin());
	
		
		int node = p.second;
		int d = p.first;
		
			//debug(node);
			
		for(int i = 0; i < (int)adj[node].size(); i++){
			int child = adj[node][i].first;
			int w = adj[node][i].second;
			
			if(dist[child] > w+d){
				dist[child] = w+d;
				s.insert(mp(dist[child],child));
			}
		}
	}
	
	if(dist[endx*M2+endy] >= 1e7) return -1;
	else return dist[endx*M2+endy];
}
void solve(){
	// code starts from here
	
	
	cin >> N2 >> M2 >> startx >> starty >> endx >> endy;
	
	startx--;starty--;
	endx--;endy--;
	g.resize(N2);
	
	input(g,N2);
	
	N = N2*M2;
	resizeAll();
	
	for(int i = 0; i < N2; i++){
		for(int j = 0; j < M2; j++){
			if(g[i][j] == '#') continue;
			for(int k = -2; k < 3; k++){
				for(int l = -2; l < 3; l++){
					if(k == 0 && l == 0) continue;
					if(!valid(i+k,j+l)) continue;
					
					int w = 1;
					if(k*l == 0 && (abs(k) == 1 || abs(l) == 1)) w= 0;
					adj[i*M2+j].pb(mp((i+k)*M2+j+l,w));
				}
			}
		}
	}
	
	cout << dij() << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 105824
#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;
    string S;
    cin >> N >> S;

    int now = 0;
    rep(i, N - 1) {
        if (S[i + 1] == 'E')
            now++;
    }

    int ans = now;
    for (int i = 1; i < N; i++) {
        if (S[i] == 'E')
            now--;
        if (S[i - 1] == 'W')
            now++;
        ans = min(ans, now);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 900
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }



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

	if (n == 2) {
		if (k == 0) {

			cout << 1 << endl;
			cout << 1 << " " << 2 << endl;
			return 0;
		}
		cout << -1 << endl;
		return 0;
	}
	if (k > (n-1) * (n-2) / 2) {
		cout << -1 << endl;
		return 0;
	}

	vector<pair<int,int>> ans;

	rep(i, n - 1) {
		ans.push_back(make_pair(0, i + 1));
	}

	int add = (n - 1) * (n - 2) / 2 - k;
	if (add == 0) {
		std::cout << ans.size() << endl;
		rep(i, ans.size()) {
			std::cout << ans[i].first + 1 << " "
				<< ans[i].second + 1 << endl;
		}
		return 0;
	}

	FOR(i, 1, n) {
		FOR(j, 1, n) {
			if (i >= j) {
				continue;
			}

			ans.push_back(make_pair(i, j));
			add--;
			if (add == 0) {
				std::cout << ans.size() << endl;
				rep(i, ans.size()) {
					std::cout << ans[i].first + 1 << " "
						<< ans[i].second + 1 << endl;
				}
				return 0;
			}
		}
	}
	std::cout << ans.size() << endl;
	rep(i, ans.size()) {
		std::cout << ans[i].first + 1 << " "
			<< ans[i].second + 1 << endl;
	}



	return 0;
}



Measured memory_bytes: 384
def isPalindrome(str):
  ret = True
  l = len(str)
  end = int(l/2)
  for i in range(end):
    if str[i] != str[-1-i]:
      ret = False
	
  return ret

ans = "Yes"
str = input()

str_l = len(str)
if isPalindrome(str) and isPalindrome(str[:int(str_l/2)]) and isPalindrome(str[-int(str_l/2):]):
  print("Yes")
else:
  print("No")

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

int main(){
  int N;
  int count = 0;
  cin >> N;
  for(int i=0;i<N;i++){
    int x;
    cin >> x;
    while(x % 2 == 0){
      x /= 2;
      count++;
    }
  }

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


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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; }

vector<long long> make_divisors(long long n){
    vector<long long> divisors;
    for(long long i=1; i*i<=n; i++){
        if(n%i == 0){
            divisors.push_back(i);
            if(i*i != n) divisors.push_back(n/i);
        }
    }
    // sort(divisors.begin(), divisors.end());
    return divisors;
}

void Main(){
    int N; cin >> N;
    int mx=0;
    VI A(N); REP(i,N){cin >> A[i]; chmax(mx,A[i]);}
    vector<bool> exist(mx+1,false);

    bool flag = false;
    REP(i,N){
        auto v = make_divisors(A[i]);
        for(int p : v){
            if(p == 1) continue;
            if(exist[p]){
                flag = true;
                break;
            }
            exist[p] = true;
        }
        if(flag) break;
    }

    if(!flag){
        cout << "pairwise coprime" << en;
        return;
    }

    int g = A[0]; REP(i,N-1) g = gcd(g,A[i+1]);
    string ans = g==1 ? "setwise coprime" : "not coprime";
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 7108
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e16;

int main(){
    ll n,m,q;
    cin >> n >> m >> q;
    vector<ll>a(q),b(q),c(q),d(q);
    rep(i,q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;b[i]--;
    }
    ll ans = 0;
    for(ll bit = 0;bit<(1<<(m+n));bit++){
        vector<ll>now;
        rep(i,m){
            if(bit>>i&1){
                now.push_back(i);
            }
        }
        for(ll i=m;i<m+n;i++){
            if(bit>>i&1){
                if((ll)now.size()<i-m+1)continue;
                ll nx = now[i-m];
                now.push_back(nx);
            }
        }
        sort(now.begin(),now.end());
        if((ll)now.size()!=n)continue;
        ll temp = 0;
        rep(i,q){
            if(now[b[i]]-now[a[i]]==c[i]){
                temp+=d[i];
            }
        }
        chmax(ans,temp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <ctime>

using namespace std;
#define RN cout << "\r\n";
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef long long int ll;
typedef pair<ll, ll> P;

// combination
const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// GCD, LCM
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;
}

int main() {
    ll n;
    cin >> n;
    ll ans = 1;
    vector<ll> numbers;
    REP(i, n) {
        ll a;
        cin >> a;
        ans = lcm(a, ans);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#define ll long long
#define ar array
using namespace std;
const int N = 1e5;
int arr[N];
int dp[N];

int main(){
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
        cin>>arr[i];

    dp[0] = 0;
    dp[1] = abs(arr[1]-arr[0]);
    for(int i=2; i<n; i++){
        dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n-1]<<endl;

}

Measured memory_bytes: 3952
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int n;
int t[102];
int main()
{
    scanf("%d",&n);
    int m;
    memset(t,0,sizeof(t));
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&m);
        t[m]++;
    }
    int min1=0x3f3f3f3f;
    for(int i=1;i<=100;i++)
    {
        int sum=0;
        for(int j=1;j<=100;j++)
        {
            for(int k=1;k<=t[j];k++)
                sum+=(i-j)*(i-j);
        }
        if(sum<min1)
        {
            min1=sum;
        }
    }
    printf("%d\n",min1);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);
		int total = 0;
		int n =0;
		int d =0;
		int x =0;
		int a =0;

		n = sc1.nextInt();
		d = sc1.nextInt();
		x = sc1.nextInt();

		for (int i = 0 ; i < n ; i++) {
			a = sc1.nextInt();

			for (int j = 0 ; a * j < d ; j++) {
				total++;
			}
		}

		total += x;

		System.out.println(total);

		sc1.close();

	}

}

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

int main() {
	
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int x,a,b;
	cin >> x >> a >> b;
	
	if(abs(a-x) > abs(b-x))
		cout << "B" << endl;
	else
		cout << "A" << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int[] A = ReadInts();
        int sum = 0;
        foreach (int a in A)
        {
            sum += a;
        }
        if (sum >= 22)
        {
            return "bust";
        }
        else
        {
            return "win";
        }
    }


    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


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

int main(){
  int n,k;
  string s;
  cin>> n >> k >> s;
  
  char c=s.at(k-1);
  if (c=='A') c='a';
  else if (c=='B') c='b';
  else c='c';
  s.at(k-1)=c;
  cout<< s << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){

	int A, B, C;
	int have = 0, ans = 0;
	cin >> A >> B >> C;
	for (int i = 1; i <= C; i++){
		have += A;
		if (i % 7 == 0) have += B;
		if (have >= C){
			ans = i;
			break;
		}
	}

	cout << ans << endl;

	return 0;
}


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

typedef long long ll;

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

	ll t=1;
	//cin >> t;

	for(ll i=1;i<=t;i++){
		ll n,d;
		cin >> n >> d;

		ll ans=0;

		for(ll j=1;j<=n;j++){
			ll x,y;
			cin >> x >> y;

			ll temp1=pow(x,2);
			ll temp2=pow(y,2);
			ll temp=temp1+temp2;
			long double temp3=sqrt(temp);
			if(temp3<=d)
				ans++;

			//cout << ans << endl;
		}

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

Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define FOR(i,a,b) for(register int i=(a);i<(b);++i)
#define ROF(i,a,b) for(register int i=(a);i>=(b);--i)
#define pi pair<int,int>
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 200005;
const int maxm = 100;
const int inf = 2147483647;
typedef long long ll;
const double eps = 1e-9;
const long long INF = 9223372036854775807ll;
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b>>=1;}return ans;}
char s[maxn];
int res1[maxn],res2[maxn],sm1,sm2;
int cal(int x){
	int u=x,cnt=0;
	while(u){
		if(u&1)cnt++;
		u>>=1;
	}
	return x%cnt;
}
int call(int x){
	int cnt=0;
	while(x){
		x=cal(x);
		cnt++;
	}
	return cnt;
}
int main(){
	int n;
	scanf("%d%s",&n,s);
	reverse(s,s+n);
	int t=0;
	FOR(i,0,n)if(s[i]=='1')t++;
	res1[0]=1%(t+1);
	FOR(i,1,n){
		res1[i]=res1[i-1]*2%(t+1);
	}
	if(t>1){
		res2[0]=1%(t-1);
		FOR(i,1,n)res2[i]=res2[i-1]*2%(t-1);
		sm1=sm2=0;
		ROF(i,n-1,0)sm1=(sm1*2+s[i]-'0')%(t+1),sm2=(sm2*2+s[i]-'0')%(t-1);
		vector<int>ans;
		FOR(i,0,n){
			if(s[i]=='0'){
				ans.push_back(call((sm1+res1[i])%(t+1))+1);
			}else ans.push_back(call(((sm2-res2[i])%(t-1)+(t-1))%(t-1))+1);
		}
		ROF(i,(int)ans.size()-1,0)printf("%d\n",ans[i]);
	}else if(!t){
		FOR(i,0,n)printf("1\n");
	}else{
		sm1=sm2=0;
		ROF(i,n-1,0)sm1=(sm1*2+s[i]-'0')%(t+1);
		vector<int>ans;
		FOR(i,0,n){
			if(s[i]=='0'){
				ans.push_back(call((sm1+res1[i])%(t+1))+1);
			}else ans.push_back(0);
		}
		ROF(i,(int)ans.size()-1,0)printf("%d\n",ans[i]);
	}
}

Measured memory_bytes: 6000
N = int(input())
A = [int(i) for i in input().split()]
sorted_A = sorted(A, reverse=True)

a_sum = 0
b_sum = 0

for i in range(N):
    if i % 2 == 0:
        a_sum += sorted_A[i]
    else:
        b_sum += sorted_A[i]

print(a_sum - b_sum)

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}


void solve(std::string s){
    if(s=="SUN") cout<<7<<endl;
    if(s=="MON") cout<<6<<endl;
    if(s=="TUE") cout<<5<<endl;
    if(s=="WED") cout<<4<<endl;
    if(s=="THU") cout<<3<<endl;
    if(s=="FRI") cout<<2<<endl;
    if(s=="SAT") cout<<1<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import collections
N=int(input())
A=sorted(list(map(int,input().split())))
p=collections.Counter(A)
B=list(set(A))
ans=0
l=len(B)
if l==1:
  ans = p[B[0]]
elif l==2:
  if B[1]-B[0] <= 2:
    ans = p[B[0]]+p[B[1]]
  else:
    ans = max(p[B[0]],p[B[1]])
else:  
  for i in range(l-2):
    sum_a = p[B[i]]+p[B[i+1]]+p[B[i+2]]
    if sum_a > ans:
      ans = sum_a
print(ans)


Measured memory_bytes: 15048
#include <bits/stdc++.h>
using namespace std;
#define oo 1000000000
#define mod 1000000007
const int N = 200010 ;
int n , u , v , arr[N] , all[N];
vector< int > g[N];
int cnt = 0;

void DFS(int node,int prnt){
    all[node] = arr[cnt++];
    for(int i = 0 ;i < (int)g[node].size();i++){
        if(g[node][i] == prnt) continue;
        DFS(g[node][i] , node);
    }
}

int main(){
    scanf("%d",&n);
    for(int i = 0 ;i < n - 1;i++){
        scanf("%d%d",&u,&v);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i = 1;i <= n;i++){
        scanf("%d",&arr[i-1]);
    }
    long long ans = 0;
    sort(arr,arr+n);
    reverse(arr,arr+n);
    for(int i = 1 ;i < n;i++){
        ans += arr[i];
    }
    DFS(1 , -1);
    cout << ans << endl;
    for(int i = 0 ;i < n;i++){
        if(i) putchar(' ');
        printf("%d",all[i + 1]);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 7424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll a[n];
    rep(i, 0, n){
        cin >> a[i];
    }

    deque<ll> dq;
    rep(i, 0, n){
        ll idx = lower_bound(dq.begin(), dq.end(), a[i]) - dq.begin();
        if(idx == 0){
            dq.push_front(a[i]);
        }else{
            dq[idx - 1] = a[i];
        }
    }

    cout << dq.size() << endl;
    return 0;
}


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

int main(void){
   int n, a[100] = {0};
   cin >> n;
   for(int i = 0; i < n; i++){
       cin >> a[i];
   }
   for(int i = 0; i < n; i++){
       int j = (n-1) - i;
       if( i ){
            cout << " " << a[j];
       }
       else{
            cout << a[j];
       }
   }
    cout << endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int a1,a3;
  a3 = max(a,max(b,c));
  a1 = min(a,min(b,c));
  cout << a3-a1<< endl;
}


Measured memory_bytes: 256
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S;
  cin >> S;
  const int64_t length = static_cast<int64_t>(S.length());
  const int64_t N = length + 1;
  vector<int64_t> A(N, 0);
  for (int64_t i = 0; i < length; ++i) {
    const int64_t n = i + 1;
    if (S.c_str()[i] == '<') {
      A[n] = max(A[n - 1] + 1, A[n]);
    }
  }
  for (int64_t i = length - 1; i >= 0; --i) {
    const int64_t n = i + 1;
    if (S.c_str()[i] == '>') {
      A[n - 1] = max(A[n - 1], A[n] + 1);
    }
  }
  int64_t sum = 0;
  for (int64_t i = 0; i < N; ++i) {
    sum += A[i];
  }
  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 4764