akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(){

  int N; cin >> N;

  vector <int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());

  cout << A[N - 1] - A[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, i, j;
    vector <int> v;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        v.push_back(x);
    }
    
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    
    for (i = 0; i < n; i++) {
        if (i == n - 1 || v[i + 1] <= i + 1) break;
    }
    
    for (j = i; j < n; j++) {
        if (v[j] <= i) break;
    }
    
    if ((v[i] - i) % 2 == 0 || (j - i) % 2 == 0) {
        puts("First");
    } else {
        puts("Second");
    }
    
    return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <stack>
#define endl    '\n'
using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    vector<ll> v(n);
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    ll ans = 1000;
    ll i = 0;
    for (i = 0; i + 1 < n; ++i)
    {
        if(v[i] < v[i+1])
        {
            ll m = ans / v[i];
            ans -= m * v[i];
            ans += m * v[i+1];
        }
    }
    cout << ans;

    return 0;
}


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

int main(){
    string S;
    cin >> S;
    
    int count = 0;
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == 'o')count++;
    }
    if(count + 15 - S.size() >= 8){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;

    }
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  int a;
  string s;
  cin>>a>>s;

  if(a>=3200) cout<<s<<endl;
  else cout<<"red"<<endl;
}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a,T b){a=min(a,b);}
template<class T> void umax(T &a,T b){a=max(a,b);}

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 1e3+4;

int h,w;
char c[N][N];
int used[N][N];
pii A,B;

void solve(){
	cin>>h>>w;
	cin>>A.F>>A.S>>B.F>>B.S;
	for(int i=1;i<=h;++i){
		for(int j=1;j<=w;++j){
			cin>>c[i][j];
		}
	}
	queue<pii>q;
	used[A.F][A.S]=1;
	q.push(A);
	int cnt=-1;
	auto check = [&](int x,int y){
		return x>=1 && x<=h && y>=1 && y<=w && c[x][y]=='.' && !used[x][y];
	};
	while(!q.empty()){
		cnt++;
		vector<pii>vec;	
		while(!q.empty()){
			pii v=q.front();
			vec.pb(v);
			if(v==B){
				cout<<cnt;
				return;
			}
			q.pop();
			for(int i=0;i<4;++i){
				int x=v.F+dx[i],y=v.S+dy[i];
				if(check(x,y)){
					used[x][y]=1;
					q.push({x,y});
				}
			}
		}
		for(auto num:vec){
			for(int i=-2;i<=2;i++){
				for(int j=-2;j<=2;++j){
					if(check(num.F+i,num.S+j)){
						used[num.F+i][num.S+j]=1;
						q.push({num.F+i,num.S+j});
					}
				}
			}
		}
	}
	cout<<-1;


}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 8520
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  	int n,a[110];
  	cin>>n ;
  	for(int i=0; i<n; i++)
      cin>>a[i];
  	sort(a,a+n);
  	cout<<a[n-1]-a[0]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string t = "";
string n;

int ans = 0;

void dfs(int num, string sum) {
	if (sum != "") {
		//cout << sum << endl;
		if(sum.find("3") != string::npos && sum.find("5") != string::npos && sum.find("7") != string::npos){
			int cnt=0;
			int res=0;
			for (int i = 0; i < sum.size(); i++) {
				cnt = cnt * 10 + (int)(sum[i] - '0');
			}
			//cout << t << endl;
			for (int i = 0; i < t.size(); i++) {
				res = res * 10 + (int)(t[i] - '0');
			}
			//cout << cnt << " " << res << endl;
			if (cnt <= res) ans++;
		}
		if(num == t.size()) {
			return ;
		}
	}
	dfs(num+1,sum+'3');
	dfs(num+1,sum+'5');
	dfs(num+1,sum+'7');
}

int main() {
	cin >> n;
	t = n;
	dfs(0, "");
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int A[2], K;
    cin >> A[0] >> A[1] >> K;

    for (int i = 0; i < K; ++i) {
        if (A[i % 2] % 2) --A[i % 2];
        A[i % 2] /= 2;
        A[(i + 1) % 2] += A[i % 2];
    }

    cout << A[0] << " " << A[1] << endl;
    return 0;
}


Measured memory_bytes: 256
local N = io.read("*n")

local max_7 = math.modf(N / 7)

local isYes = false
for i = 0, max_7 do
	local without_7 = N - 7 * i
	if without_7 % 4 == 0 then
		isYes = true
		break
	end
end

print(isYes and "Yes" or "No")

Measured memory_bytes: 256
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
#define out(args...){vector<string> a_r_g_s=s_p_l_i_t(#args, ','); e_r_r(a_r_g_s.begin(), args); }
vector<string> s_p_l_i_t(const string &s, char c){vector<string> v;int d=0,f=0;string t;for(char c:s){if(!d&&c==',')v.pb(t),t="";else t+=c;if(c=='\"'||c=='\'')f^=1;if(!f&&c=='(')++d;if(!f&&c==')')--d;}v.pb(t);return move(v);}
void e_r_r(vector<string>::iterator it) {}
template<typename T, typename... Args> void e_r_r(vector<string>::iterator it, T a, Args... args){ if(*it==" 1"||*it=="1") cerr<<endl; else cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; e_r_r(++it, args...);}
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
	string s;
	cin>>s;
  int n=s.size();
	vector<int> a(n+1);
	rep(i,n) a[i+1]=1<<(s[i]-'a');
	rep(i,n) a[i+1]^=a[i];
	vector<int> mn(1<<26,MOD);
	mn[0]=0;
	vector<int> dp(n+1,MOD);
	dp[0]=0;
	rep(i,n){
		int st=a[i+1];
		MN(dp[i+1],mn[st]+1);
		rep(j,26) MN(dp[i+1],mn[st^(1<<j)]+1);
		MN(mn[st],dp[i+1]);
	}
	cout<<dp[n]<<endl;
  return 0;
}


Measured memory_bytes: 264340
#include <bits/stdc++.h>
 #include <string> 
 #include <math.h>
 #include <bitset>
 using namespace std;

 int main(){
    string S, T;;
    string tmp_div;
    bool result;
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    
    cin >> S;
    
    reverse(S.begin(), S.end());
    for (int i=0; i<4; i++)
        reverse(divide[i].begin(), divide[i].end());

    for (int i=0; i < S.size();){
        result = false;
        for (int j=0; j<4; j++){
            tmp_div = divide[j];
            if (tmp_div == S.substr(i, tmp_div.size())){
                result = true;
                i = i + tmp_div.size();
            }
        }
        if (result == false)
            break;
            
    }

    if (result == true)
        cout << "YES" <<endl;
    else
        cout << "NO" <<endl;
        
    return 0;
 }



Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        char[] s = sc.next().toCharArray();
        for (int i = 0 ; i < 3 ; i++) {
            System.out.print(s[i]);
        }
        System.out.print("\n");
    }

}


Measured memory_bytes: 35540
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cstdio>
 
using namespace std;
 
typedef complex<long double> P;
 
const long double EPS = 1e-10;
 
namespace std 
{
	bool operator <(const P &p1, const P &p2) 
	{
		if (p1.real() != p2.real()) return p1.real() < p2.real();
		return p1.imag() < p2.imag();
	}
};
 
// 按照y坐标排序
bool cmp(const P &p1, const P &p2) 
{
	return p1.imag() < p2.imag();
}
 
// 在pa和pb这两点决定的线上，横坐标为x的点的y坐标
long double calc_y_when_x_equals(const P &pa, const P &pb, long double x) 
{
	P d = pb - pa;
	if (abs(d.real()) < EPS) 
	{
		if (arg(d) < 0) return -EPS;
		else return EPS;
	}
	return pa.imag() + d.imag() * ((x - pa.real()) / d.real());
}
 
bool solve() 
{
	int W, H, N;
	cin >> W >> H >> N;
	if (!W && !H && !N) return false;
	N *= 2;
 
	vector<P> ps(N);
	for (int i = 0; i < N; ++i) 
	{
		int x, y;
		cin >> x >> y;
		ps[i] = P(x, y);
	}
	// 将四个顶点算在内的任意两点组成直线在y轴上的截距，它们相邻构成区间
	vector<P> events;
	for (int i = 0; i < N; ++i) 
	{
		for (int j = i + 1; j < N; ++j) 
		{
			events.push_back(P(0, calc_y_when_x_equals(ps[i], ps[j], 0)));
		}
		events.push_back(P(0, calc_y_when_x_equals(ps[i], P(W, 0), 0)));
		events.push_back(P(0, calc_y_when_x_equals(ps[i], P(W, H), 0)));
	}
	events.push_back(P(0, 0));
	events.push_back(P(0, H));
	sort(events.begin(), events.end(), cmp);
	// 区间收集完毕
	const int M = events.size();
	long double ans = 0;
	for (int i = 0; i < M - 1; ++i) 
	{
		const P &pa = events[i];
		const P &pb = events[i + 1];
		if (pa.imag() < 0) continue;
		if (pb.imag() > H) break;
		if (pb.imag() - pa.imag() < EPS) continue;
		const P m = (pa + pb) / (long double)2.0;
		long double upper = 0, lower = 0;
		vector<pair<long double, P>> v;
		for (const P &p : ps) 
		{
			const P d = p - m;
			v.push_back(make_pair(arg(d), p));	// 极角
		}
		sort(v.begin(), v.end());
		lower = min<long double>(H, max<long double>(0, calc_y_when_x_equals(m, v[N / 2 - 1].second, W)));	// 在右边的长度下界
		upper = min<long double>(H, max<long double>(0, calc_y_when_x_equals(m, v[N / 2].second, W)));		// 在右边的长度上界
		long double add = (pb.imag() - pa.imag()) * (upper - lower);	// 左边的长度乘以右边的长度，积分的思想
		ans += abs(add);
	}
	printf("%.10Lf\n", ans / H / H);
	return true;
}
 
///////////////////////////SubMain//////////////////////////////////
int main(int argc, char *argv[])
{
	cin.tie(0);
	ios::sync_with_stdio(0);
 
	while (solve());
	return 0;
}



Measured memory_bytes: 4636
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		int cnt_r = 0;
		int cnt_b = 0;
		for (int i=0;i<N;i++) {
			if (s.charAt(i)=='R') {
				cnt_r++;
			} else {
				cnt_b++;
			}
		}

		if (cnt_r>cnt_b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
from sys import stdin, setrecursionlimit
#input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

N = int(input())
S = input()

R_cnt = S.count("R")
W_cnt = S.count("W")

if W_cnt == 0:
    print(0)
    exit()

answer = 0
for s in S:
    if R_cnt == 0:
        print(answer)
        exit()
    if s == "W":
        answer += 1
    R_cnt -= 1


Measured memory_bytes: 68300
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<set>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
typedef long long ll;

signed main(){
    //B
    /*
    int k,a,b;
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
    */
   //B
   ll x;
   cin>>x;
   ll p=100;
   int c=0;
   while(p<x){
       p=ll(p+p*0.01);
       c++;
   }
   cout<<c<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int a,b,c,x,s=0;
int main()
{
	cin>>a>>b>>c>>x;
	for(int i=0;i<a+1;i++)
	{
		for(int j=0;j<b+1;j++)
		{
			if(x-i*500-j*100>=0 && x-i*500-j*100<=c*50)
			{
				s++;
			}
		}
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>

#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))

using namespace std;
using LL=long long;

int main(){
    int n,m,a,b,cur,ans=0;
    pair<int,int> P[100005];
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        P[i]=make_pair(a,b);
    }
    sort(P,P+m,[](const pair<int,int>& fir,const pair<int,int>& sec){return fir.second<sec.second;});
    cur=P[0].second-1;ans++;
    for(int i=1;i<m;i++){
        if(cur<P[i].first){
            cur=P[i].second-1;ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
def main113():
    import numpy as np
    N = int(input())
    T, A = (int(x) for x in input().split())
    H = list(map(int,input().split()))

    T_list = [T] * N
    A_list = [A] * N

    def temperature(T, A, x):
        return abs(A - (T - x * 0.006))

    answer = list(map(temperature, T_list, A_list, H))

    print(np.argmin(np.array(answer)) + 1)



main113()

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

int H, W, dist[59][59], sum;
string S[59];

int main()
{

    cin >> H >> W;
    for (int i = 0; i < H; i++)// nyuuryoku
    {
        cin >> S[i];
        for (int j = 0; j < W; j++)
        {
            if (S[i][j] == '.')
                sum++; // . no kazu
        }
    }

    for (int i = 0; i < 59; i++)
    {
        for (int j = 0; j < 59; j++)
            dist[i][j] = (1 << 30); // INF de syokika
    }

    queue<pair<int, int>> Q;
    Q.push(make_pair(0, 0)); // junnbi
    dist[0][0] = 1;

    while (!Q.empty())
    {
        int a1 = Q.front().first, a2 = Q.front().second; Q.pop(); // get
        int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; // houkou bekutoru
        for (int i = 0; i < 4; i++)
        {
            int cx = a1 + dx[i], cy = a2 + dy[i]; // tugi no basyo
            if (cx < 0 || cy < 0 || cx >= H || cy >= W || dist[cx][cy] <= dist[a1][a2] + 1 || S[cx][cy] == '#') continue;
            Q.push(make_pair(cx, cy));
            dist[cx][cy] = dist[a1][a2] + 1;
        }
    }

    if (dist[H - 1][W - 1] == (1 << 30)) // muri
        cout << "-1" << endl;
    else // sum - saitann kyori
        cout << sum - dist[H - 1][W - 1] << endl;
}


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

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int k, x;
  cin >> k >> x;
  if (500 * k >= x) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math

vectors = list()

n, d = (int(x) for x in input().split())
for c in range(n):
    vectors.append([int(x) for x in input().split()])

counter = 0

for i in range(n-1):
    for j in range(i+1, n):
        distance = math.sqrt(sum([
            (vectors[i][k] - vectors[j][k]) ** 2 for k in range(d)
            ]))
            
        if float(distance).is_integer():
            counter += 1

print(counter)

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();    
        int N = r.i();
        String[] S = new String[N];
        int[] P = new int[N];
        SortedMap<String, ArrayList<Integer>> map = new TreeMap<>();
        for(int i = 0; i < N; i++){
            String[] temp = r.ss();
            if(!map.containsKey(temp[0]))
                map.put(temp[0], new ArrayList<>());
            map.get(temp[0]).add(i);
            P[i] = Int(temp[1]);
        }
        for(String key : map.keySet()){
            ArrayList<Integer> array = map.get(key);
            ArrayList<int[]> array1 = new ArrayList<>();
            for(int idx : array){
                array1.add(new int[]{idx, P[idx]});
            }
            array1.sort((x, y)->-x[1]+y[1]);
            for(int[] temp : array1)
                println(temp[0]+1);
        }
    }

    static void print(Object o){
        System.out.print(o.toString());
    }

    static void println(Object o){
        System.out.println(o.toString());
    }

    static int Int(String s){
        return Integer.parseInt(s);
    }

    static long Long(String s){
        return Long.parseLong(s);
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }

        String s() throws IOException{
            return readLine();
        }

        String[] ss() throws IOException{
            return s().split(" ");
        }

        int i() throws IOException{
            return Int(s());
        }

        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }

        long l() throws IOException{
            return Long(s());
        }

        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long(ss[j]);            
            return ll;
        }
    }
}


Measured memory_bytes: 27860
import sys
sys.setrecursionlimit(100000)

N, M = map(int, input().split())
LRD = [list(map(int, input().split())) for _ in range(M)]

graph = [{} for _ in range(N)]
for l, r, d in LRD:
	l, r = l - 1, r - 1
	graph[l][r] = d
	graph[r][l] = -d

visited = [False] * N
depths = [0] * N
def dfs(v):
	q = [v]
	while q:
		cu = q.pop()
		for nx, d in graph[cu].items():
			if visited[nx]:
				if depths[nx] != depths[cu] + d:
					return False
			else:
				visited[nx] = True
				depths[nx] = depths[cu] + d
				q += [nx]
	return True

for n in range(N):
	if not visited[n]:
		if not dfs(n):
			print("No")
			break
else:
	print("Yes")


Measured memory_bytes: 113164
#include <stdio.h>
#include <string.h>

int main(){
	int a,b;
	char buff[10];

	//入力終了までループ
	while(scanf("%d %d", &a, &b) != EOF){
		//intからcharに変換
		sprintf(buff,"%d",a + b);
		//文字列の長さを出力
		printf("%d\n", strlen(buff));
	}

    return 0;
}

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

class Dice1 {
    public:
    int f1[6];
    Dice1() {}
    void roll_z() { roll(1, 2, 4, 3);}
    void roll_W() { roll(0, 2, 5, 3);}
    void roll_N() { roll(0, 1, 5, 4);}
    void roll_S() { roll(0, 4, 5, 1);}
    void roll_E() { roll(0, 3, 5, 2);}
    void roll (int i, int j, int k, int l) {
        int t = f1[i];
        f1[i] = f1[j];
        f1[j] = f1[k];
        f1[k] = f1[l];
        f1[l] = t;
    }
    int top1() {
        return f1[0];
    }
    int front1() {
        return f1[1];
    }
    int left1() {
        return f1[3];
    }
    int right1() {
        return f1[2];
    }
};

class Dice2 {
    public:
    int f2[6];
    Dice2() {}
    int top2() {
        return f2[0];
    }
    int front2() {
        return f2[1];
    }
    int left2() {
        return f2[3];
    }
    int right2() {
        return f2[2];
    }
};

int main() {
    Dice1 d1;
    Dice2 d2;
    
    for (int i = 0; i < 6; i++) cin >> d1.f1[i];
    for (int i = 0; i < 6; i++) cin >> d2.f2[i];
    
    
    if(d1.left1() == d2.top2()) d1.roll_E();
    if(d1.right1() == d2.top2()) d1.roll_W();
    for (int i = 0; i < 6; i++) {
        if(d1.top1() != d2.top2() ) d1.roll_N();
        if(d1.top1() == d2.top2() ) break;
    }
    for (int i = 0; i < 6; i++) {
        if(d1.front1() != d2.front2()) d1.roll_z();
        if(d1.front1() == d2.front2() ) break;
    }
    
    if (d1.right1() == d2.right2()) {cout << "Yes" << endl;}
    else {cout << "No" << endl;}
    
    return 0;
}





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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N, K; cin >> N >> K;
    i64 cnt = (N * (N - 1)) / 2 - (N - 1);
    if (K > cnt) {
        cout << -1 << endl;
        return 0;
    }

    cout << N - 1 + (cnt - K) << endl;
    for (i64 i = 2; i <= N; i++) {
        cout << 1 << " " << i << endl;
    }

    for (i64 i = 2; i < N; i++) {
        for (i64 j = i + 1; j <= N; j++) {
            if (cnt == K) break;
            cout << i << " " << j << endl;
            cnt--;
        }
    }

    return 0;
}

Measured memory_bytes: 256
def main():
    n, a, b = map(int, input().split())
    mod = 10**9+7
    s = pow(2, n, mod)-1
    x = 1
    y = 1
    for i in range(1, b+1):
        x = x*(n-i+1)%mod
        y = y*i%mod
        if i==a or i==b:
            s -= x*pow(y, mod-2, mod)

    print(s%mod)

main()

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
typedef int sign;
typedef long long ll;
#define For(i,a,b) for(register sign i=(sign)(a);i<=(sign)(b);++i)
#define Fordown(i,a,b) for(register sign i=(sign)(a);i>=(sign)(b);--i)
const int N=2e6+5;
template<typename T>bool cmax(T &a,T b){return (a<b)?a=b,1:0;}
template<typename T>bool cmin(T &a,T b){return (a>b)?a=b,1:0;}
template<typename T>T read()
{
	T ans=0,f=1;
	char ch=getchar();
	while(!isdigit(ch)&&ch!='-')ch=getchar();
	if(ch=='-')f=-1,ch=getchar();
	while(isdigit(ch))ans=(ans<<3)+(ans<<1)+(ch-'0'),ch=getchar();
	return ans*f;
}
template<typename T>void write(T x,char y)
{
	if(x==0)
	{
		putchar('0'),putchar(y);
		return;
	}
	if(x<0)
	{
		putchar('-');
		x=-x;
	}
	static char wr[20];
	int top=0;
	for(;x;x/=10)wr[++top]=x%10+'0';
	while(top)putchar(wr[top--]);
	putchar(y);
}
void file()
{
#ifndef ONLINE_JUDGE
	freopen("E.in","r",stdin);
	freopen("E.out","w",stdout);
#endif
}
int X[7],Y[7];
void input()
{
	For(i,1,6)X[i]=read<int>();
	For(i,1,6)Y[i]=read<int>();
}
const int mo=1e9+7;
ll power(ll x,int y)
{
	ll res=1;
	for(;y;x=x*x%mo,y>>=1)if(y&1)res=res*x%mo;
	return res;
}
int mc[N],inv[N];
void init()
{
	int d=max(X[6],Y[6])*2;
	mc[0]=inv[0]=1;
	For(i,1,d)mc[i]=1ll*mc[i-1]*i%mo;
	inv[d]=power(mc[d],mo-2);
	Fordown(i,d-1,1)inv[i]=1ll*inv[i+1]*(i+1)%mo;
}
ll C(int n,int m){return n>=m?1ll*mc[n]*inv[m]%mo*inv[n-m]%mo:0;}
ll path0(int x,int y)
{
	ll res=C(x-X[1]+y-Y[1]+2,x-X[1]+1)-C(x-X[2]+y-Y[1]+1,x-X[2])-C(x-X[1]+y-Y[2]+1,x-X[1]+1)+C(x-X[2]+y-Y[2],x-X[2]);
	res=(res%mo+mo)%mo;
//	cout<<"1"<<' '<<res<<endl;
	return res;
}
ll path1(int x,int y)
{
	ll res=C(X[6]-x+Y[6]-y+2,X[6]-x+1)-C(X[5]-x+Y[6]-y+1,X[5]-x)-C(X[6]-x+Y[5]-y+1,X[6]-x+1)+C(X[5]-x+Y[5]-y,X[5]-x);
	res=(res%mo+mo)%mo;
//	cout<<"2"<<' '<<res<<endl;
	return res;
}
void work()
{
	int ans=0;
	For(i,X[3],X[4])
	{
		ans=(ans+mo-1ll*(i+Y[3])*path0(i,Y[3]-1)%mo*path1(i,Y[3])%mo)%mo;
		ans=(ans+1ll*(i+Y[4]+1)*path0(i,Y[4])%mo*path1(i,Y[4]+1)%mo)%mo;
	}
//	cout<<ans<<endl;
	For(j,Y[3],Y[4])
	{
		ans=(ans+mo-1ll*(X[3]+j)*path0(X[3]-1,j)%mo*path1(X[3],j)%mo)%mo;
		ans=(ans+1ll*(X[4]+j+1)*path0(X[4],j)%mo*path1(X[4]+1,j)%mo)%mo;
	}
	write(ans,'\n');
	/*
	int ans=0;
	int x=read<int>(),y=read<int>();
	For(i,X[1],X[2])For(j,Y[1],Y[2])
	{
		ans=(ans+C(n-i+m-j,n-i))%mo;
	}*/
	/*For(i,X[1],X[2])
	{
		ans=(ans+C(x-i+y-Y[1]+1,x-i+1))%mo;
		ans=(ans-C(x-i+y-Y[2],x-i+1)+mo)%mo;
	}
	//cerr<<ans<<endl;
	cout<<path0(x,y)<<' '<<ans<<endl;
	For(i,X[5],X[6])
	{
		ans=(ans+C(i-x+Y[6]-y+1,i-x+1))%mo;
		ans=(ans-C(i-x+Y[5]-y,i-x+1)+mo)%mo;
	}
	cout<<ans<<' '<<path1(x,y)<<endl;*/
}
int main()
{
//	file();
	input();
	init();
	work();
	return 0;
}



Measured memory_bytes: 15872
from collections import defaultdict
from copy import deepcopy

n = int(input())
dd = defaultdict(int)
for i in range(n):
    s = input()
    d = defaultdict(int)
    for j in s:
        d[j] += 1
    if i == 0:
        dd = deepcopy(d)
    else:
        for j in dd.keys():
            dd[j] = min(dd[j], d[j])

print("".join(
    sorted(
        [(i * dd[i] if dd[i] != 0 else "") for i in dd.keys()]
        )
))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
const int N=100005;
ll n,dp[N];
vector<pii> v;
bool cs(pii a,pii b){
    return a.y<b.y;
}
int main(){
cin>>n;
for(int k=1;k<=n;k++){
    int x,l;
    cin>>x>>l;
    v.push_back({x-l,x+l});
}
sort(v.begin(),v.end(),cs);
dp[0]=1;
for(int k=1;k<n;k++){
    if(v[k].x>=v[k-1].y){
        dp[k]=dp[k-1]+1;
    }
    else{
        dp[k]=dp[k-1];
        if(v[0].y>v[k].x)
            continue;
        int l=0,r=k-1;
        while(r-l>1){
            int mid=(l+r)/2;
            if(v[mid].y<=v[k].x)
                l=mid;
            else r=mid;
        }
        int p=l;
        if(v[r].y<v[k].x)
            p=r;
        dp[k]=max(dp[k],dp[p]+1);
    }
}
cout<<dp[n-1];
return 0;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    cin >> A;
    int sum = accumulate(A.begin(), A.end(), 0LL);
    vector<int> divisor;
    for (int i = 1; i <= sqrt(sum); i++) {
        if (sum % i == 0) {
            divisor.push_back(i);
            divisor.push_back(sum / i);
        }
    }
    sort(divisor.rbegin(), divisor.rend());
    for (int temp : divisor) {
        int count = 0;
        vector<int> move(N);
        for (int i = 0; i < N; i++) {
            count += A[i] % temp;
            move[i] = temp - A[i]% temp;
        }
        sort(move.begin(), move.end());
        if (count % temp != 0) continue;
        int sumK = 0;
        for (int i = 0; i < count / temp; i++) {
            sumK += move[i];
        }
        if (sumK > K) continue;
        cout << temp << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int cmp(const void* p, const void* q) {
	return *(int*)q - *(int*)p;
}

int main(void) {
	int n;
	int l[2000];

	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &l[i]);

	qsort(l, n, sizeof(int), cmp);

	int count = 0;
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++) {
			for (int k = j + 1; k < n; k++)
				if (l[i] - l[j] < l[k])
					count++;
		}
	}

	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int N; cin >> N ;
	for(int i=0;i<N;i++)
	{
		string str,ptr,temp,ans; cin >> str >> ptr ;
		int lens,lenp,len;
		lens=str.size(); lenp=ptr.size();
		bool flag=false; len=max(lens,lenp);
		temp=str; for(int i=0;i<lens;i++) str[i]=temp[lens-i-1];
		temp=ptr; for(int i=0;i<lenp;i++) ptr[i]=temp[lenp-i-1];
		for(int i=0;i<len;i++)
		{
			int temp;
			if(i>=lens && i<lenp) temp=ptr[i]-'0';
			else if(i<lens && i>=lenp) temp=str[i]-'0';
			else temp=(str[i]-'0')+(ptr[i]-'0'); 
			if(flag==true) temp++,flag=false;
			if(temp>=10) flag=true,temp%=10;
			char ch='0'+temp;
			if(!i) ans=ch;
			else ans+=ch;
		}
		if(flag==true) ans+='1';
		temp=ans; int LEN=ans.size();
		for(int i=0;i<LEN;i++) ans[i]=temp[LEN-i-1];
		if(LEN>80) ans="overflow";
		cout << ans << '\n' ;
	}
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#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);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
 
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
 
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 22;
 
template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}
 
int main () {
  cin.tie(0);
  cout << setprecision(10);
 
  int n;cin >> n;
  vi a(n); REP(i, n) cin >> a[i];
 
  map<int, int> m;
  int fr = 0;
  REP(i, n) {
    if(a[i] / 400 > 7) fr++;
    else m[a[i]/400]++;
  }
 
  int k = m.size();
 
  cout << ((k==0) ? 1 : k) << " " << k + fr << endl;
}

Measured memory_bytes: 256
#include<iostream>

int main(){
    int x,y,i;

    for(i=1;;i++){
        std::cin >> x >> y;

        if(x==0&&y==0){
            break;
        }

        if(x>y){
            std::cout<<y<<" "<<x<<std::endl;
        }
        else{
            std::cout<<x<<" "<<y<<std::endl;
        }
        
    }
    return 0;
}


Measured memory_bytes: 3072
# -*- coding: utf-8 -*-
from fractions import Fraction
from collections import Counter, defaultdict, deque
import math

import sys
# sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def fract(a, b):
    if a == 0 and b == 0:
        return (0, 0)
    if b == 0:
        return (1, 0)
    f = Fraction(a, b)
    a = f.numerator
    b = f.denominator
    return a, b


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)


@mt
def slv(N, AB):
    adb = Counter()
    for a, b in AB:
        k = fract(a, b)
        adb[k] += 1
    M = Mod(1000000007)
    ans = 1
    done = {(0, 0)}
    for k, v in adb.items():
        if k in done:
            continue
        a, b = k
        kk = fract(-b, a)
        done.add(k)
        done.add(kk)

        n = adb[kk]
        t = M.sub(M.pow(2, v) + M.pow(2, n), 1)
        ans = M.mul(ans, t)
    ans = M.add(ans, adb[(0, 0)])
    return M.sub(ans, 1)


def main():
    N = read_int()
    AB = [read_int_n() for _ in range(N)]
    print(slv(N, AB))


if __name__ == '__main__':
    main()


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

using namespace std;
#define endl "\n"

const int MOD = 1000000007;
int main()
{
	int a, b;
	cin >> a >> b ;
	int s = max(a+b,max(a-b,a*b));
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
int k;
string s;
int l;
vector<string> v;
string vv[111111];

bool ch(string x){
  int p = 0;
  for(int i = 0; i < k+1; i++){

    if(p+l > (int)s.size()) return true;
    if(x >= s.substr(p,l)){
      p += l;
    }else{
      p += l-1;
    }
  }
  return p == (int)s.size();
}

bool u[111111];
bool uv[111111]; 
bool dfs(int x){
  if(x > (int)s.size()) return false;
  if(x == (int)s.size()) return true;
  if(uv[x]) return u[x];
  uv[x] = true;

  bool a = dfs(x+l);
  bool b = dfs(x+l-1);
  u[x] = b;

  return u[x] = a||b;
}

int main(void){
  cin >> k >> s;

  if(k == 0){
    cout << s << endl;
    return 0;
  }

  l = (s.size()+k)/(k+1);

  dfs(0);
  for(int i = 0; i+l-1 < (int)s.size(); i++){
    if(u[i])
      v.push_back(s.substr(i,l));
  }
  sort(v.begin(),v.end());

  /*
  cout << "vs " << v.size() << endl;
  for(int i = 0; i < (int)v.size(); i++)
    cout << v[i] << endl;
  */

  int lb = -1;
  int ub = v.size()-1;
  while(ub-lb > 1){
    int mid = (lb+ub)/2;
    /*
    cout << lb << " " << ub << endl;
    cout << "mid " << v[mid] << endl;
    //*/
    if(ch(v[mid])){
      ub = mid;
    }else{
      lb = mid;
    }
  }
  cout << v[ub] << endl;
}


Measured memory_bytes: 9972
import java.util.Scanner;

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

		if (x < a) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}
	}
}


Measured memory_bytes: 23892
while True:
    n=int(input())
    if n==0:
        break 
    else:
        A=[0]*(n+48)
        A[0]=1
        A[1]=1
        A[2]=2
        if n==1:
            print(1)
        elif n==2:
            print(1)
        else:
            for i in range (3,(n+1)):
                A[i]=A[i-1]+A[i-2]+A[i-3]
            print((A[n])//3650+1)


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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a>=c){
    cout<<0<<endl;
  }else if(a+b>=c){
    cout<<c-a<<endl;
  }else{
    cout<<"NA"<<endl;
  }
  return 0;
}




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

int t[100005];
int main() {
	int n, c, k; scanf("%d%d%d", &n, &c, &k);
	rep(i, n)scanf("%d", &t[i]);
	sort(t, t + n);
	int a = 0;
	int cnt = 0;
	while (a < n) {
		cnt++;
		int u = a;
		while (u < n&&u - a + 1 <= c&&t[u] <= t[a] + k)u++;
		a = u;
	}
	cout << cnt << endl;
}

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

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

using namespace std;
using lint=long long;

int main(){
	lint n,W,w[100],v[100];
	cin>>n>>W;
	rep(i,n) cin>>w[i]>>v[i];

	vector<lint> V[4];
	rep(i,n) V[w[i]-w[0]].emplace_back(v[i]);

	vector<lint> Vsum[4];
	rep(i,4){
		sort(V[i].rbegin(),V[i].rend());
		Vsum[i].emplace_back(0);
		lint sum=0;
		for(lint a:V[i]) sum+=a, Vsum[i].emplace_back(sum);
	}

	lint ans=0;
	rep(i,V[0].size()+1) rep(j,V[1].size()+1) rep(k,V[2].size()+1) rep(l,V[3].size()+1) {
		if(i*w[0]+j*(w[0]+1)+k*(w[0]+2)+l*(w[0]+3)<=W){
			ans=max(ans,Vsum[0][i]+Vsum[1][j]+Vsum[2][k]+Vsum[3][l]);
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	
	static boolean search(String tar , String str){//２つの引数の文字列で看板が作れるかどうか判定するクラスメソッド
		boolean f = false;
		for(int j=0;j<str.length();j++){
			if(tar.equals(str))return true;
			if(tar.charAt(0)==str.charAt(j)){
				int cnt=0;
				for(int i=j+1;i<str.length();i++){
					cnt++;
					if(str.length()<j+cnt)continue;
					if(tar.charAt(1)==str.charAt(i)){
						if((j+tar.length()-1*cnt)>str.length())break;//
						for(int k=2;k<tar.length();k++){
							if(j+k*cnt>=str.length()){f=false;break;}//
							if(tar.charAt(k)==str.charAt(j+k*cnt))f = true;
							else {
								f = false;
								break;
							}
						}
						if(f==true) return f;
					}
				}
			}
		}		
		return f;
	}
	
	void doIt(){//クラス変数scに対しての操作を決めるメソッド
		int n = sc.nextInt();
		int ans = 0;
		String tar = sc.next();
		for(int i=0;i<n;++i){
			String s = sc.next();
			if(search(tar,s))ans++;
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new Main().doIt();
	}

}

Measured memory_bytes: 20604
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
//const long long MOD = 998244353;
const long long INF_LL = 1e18+11; const int INF_int = 1e9+11;
#define ll long long
#define mp std::make_pair
#define rep(i,n) for(int i = 0;i<n;i++)
#define lrep(i,n) for(long long i = 0;i<n;i++)
#define All(a) a.begin(),a.end()
#define Debug_Output_ALL(a) for(auto x:a) cout << x << " ";cout << endl;
int main(){
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    int sum = a+b+c+d+e;
    cout << 15 - sum << endl;
}

Measured memory_bytes: 3524
S = input()
if int(S[:2]) == 0 or int(S[:2]) >= 13:
    if int(S[2:]) == 0 or int(S[2:]) >= 13:
        print("NA")
    else:
        print("YYMM")
else:
    if int(S[2:]) == 0 or int(S[2:]) >= 13:
        print("MMYY")
    else:
        print("AMBIGUOUS")

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;

struct Circle{
	int x, y, r, c;
	// コンストラクタで初期化
	Circle(int x_, int y_, int r_, int c_){
		x = x_; y = y_; r = r_; c = c_;
	};
	// this と円 cir が重なるかどうか 
	bool is_intersect(const Circle& cir){
		int d = (x - cir.x) * (x - cir.x) + (y - cir.y) * (y - cir.y);
		return ( d < (r + cir.r) * (r + cir.r) );
	}
};

// 円の個数
int n;
// 円 : v.size() <= 24
vector<Circle> v;
// exist[i] := 円 i が存在するかどうか.
bool exist[24];
// メモ
// memo[bits] := 円の状態 bits のときのとり除ける枚数を返す. 
char memo[1<<24];
// 答え
int ans;

// 初期化
void init(){
	v.clear();
	for(int i=0 ; i < n ; i++ ) exist[i] = true;
	for(int i=0 ; i < (1<<n) ; i++ ) memo[i] = -1;
}

// 円 k が一番上にあるかどうか
// k > i となる すべての i の円と衝突していなければよい.
bool is_top(int k){
	for(int i = k-1 ; i >= 0 ; i-- ){
		if( exist[i] == false ) continue;
		
		if( v[k].is_intersect(v[i]) ){
			return false;
		}
	}
	return true;
}

// メモ化再帰
int dfs(int bits, int cnt){
	if( memo[bits] >= 0 ) return memo[bits];
	int result = cnt;
	
	for(int i=0 ; i < n ; i++ ){
		if( exist[i] == false || !is_top(i) ) continue;
		
		for(int j=i+1 ; j < n ; j++ ){
			if( exist[j] == false || !is_top(j) || i == j ) continue;
			
			// 円 i と 円 j が取り除けたら取り除いて再帰
			if( v[i].c == v[j].c ){
				exist[i] = false;
				exist[j] = false;
				int next_bits = (bits & (~(1<<i))) & (~(1<<j));
				result = dfs( next_bits , cnt+2 );
				exist[i] = true;
				exist[j] = true;
			}
		}
	}
	// メモ
	memo[bits] = result;
	// 答えの更新
	ans = max( ans , result );
	return result;
}

int main(){
	while( cin >> n , n ){
		init();
		
		// 入力
		for(int i=0 ; i < n ; i++ ){
			int x, y, r, c;
			cin >> x >> y >> r >> c;
			v.push_back( Circle( x , y , r , c ) );
		}
		
		// 探索
		ans = 0;
		dfs( ((1<<n)-1) , 0 );
		cout << ans << endl;
	}
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int K;
    cin >> K;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        cnt += (h >= K);
    }
    cout << cnt << "\n";
    return 0;
}

Measured memory_bytes: 256
while True:
    m,f,r=map(int,input().split())
    if m==-1 and f==-1 and r==-1:
        break
    
    if m==-1 or f==-1 or m+f<30:
        print("F")
    elif m+f>=80:
        print("A")
    elif m+f<80 and m+f>=65:
        print("B")
    elif m+f<65 and m+f>=50:
        print("C")
    elif m+f<50 and m+f>=30 and r<50:
        print("D")
    else:
        print("C")


Measured memory_bytes: 5592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);    
    
    int a,b;
    cin>>a>>b;
    cout<<a*b<<endl;
}

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

void compute(){
  string num; cin >> num;
  vector<int> v;
  for ( int i = 0; i < num.size(); i++ ) v.push_back(num[i]-'0');
  
  int cnt = 0;
  while(1){
    if ( v.size() == 1 ) break;
    int a = v[0];
    int b = v[1];
    v.erase(v.begin());
    v.erase(v.begin());
    a += b;
    if ( a < 10 ) v.insert(v.begin(), a);
    else {
      v.insert(v.begin(), a%10);
      v.insert(v.begin(), 1);
    }
    cnt++;
  }
  if ( cnt%2 ) cout << "Fabre wins." << endl;
  else cout << "Audrey wins." << endl;
}

main(){
  int tcase; cin >> tcase;
  for ( int i = 0; i < tcase;i++ ) compute();
}

Measured memory_bytes: 0
#include <cstdio>
static const int MAXM = 3004;
static const int MAXN = 3004;
static const int MODULUS = 1e9 + 7;
#define _  %  MODULUS
#define __ %= MODULUS

int n, m;
// f[# of operations][# of red bricks in the box]
int f[MAXM][MAXN] = {{ 0 }}, g[MAXM][MAXN] = {{ 0 }};

int main()
{
    scanf("%d%d", &n, &m);

    g[0][0] = 1;
    for (int i = 1; i <= n; ++i) f[0][i] = 1;

    for (int i = 0; i < m; ++i) {
        for (int j = 0; j <= n; ++j) {
            if (j > 0) {
                // RR
                ((j == 1 ? g[i + 1][j - 1] : f[i + 1][j - 1]) += f[i][j])__;
                (g[i + 1][j - 1] += g[i][j])__;
                // RB
                ((j == 1 ? g[i + 1][j] : f[i + 1][j]) += f[i][j])__;
                (g[i + 1][j] += g[i][j])__;
            }
            if (j < n) {
                // BB
                ((j == 0 ? g[i + 1][j + 1] : f[i + 1][j + 1]) += f[i][j])__;
                (g[i + 1][j + 1] += g[i][j])__;
                // BR
                ((j == 0 ? g[i + 1][j] : f[i + 1][j]) += f[i][j])__;
                (g[i + 1][j] += g[i][j])__;
            }
        }
    }
    //for (int i = 0; i <= m; ++i)
    //    for (int j = 0; j <= n; ++j) printf("%d/%d%c", f[i][j], g[i][j], j == n ? '\n' : '\t');

    int ans = 0;
    for (int i = 0; i <= n; ++i) (ans += g[m][i])__;
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;
static const ll LOGN=55;


map<ll, ll> prime;
void factrization(ll n) {
  for(ll i=2; i*i<=n; i++) {
    while(n%i==0) {
      prime[i]++;
      n/=i;
    }
  }
  
  if(n>1) prime[n]++;
}


ll N;

int main(void) {
  cin >> N;
  ll i;
  ll cnt[111]={};
  for(i=2; i<=N; i++) factrization(i);
  
  for(auto it=prime.begin(); it!=prime.end(); it++) {
    cnt[it->second]++;
  }
  
  
  ll sc[111]={};
  for(i=99; i>=0; i--) {
    sc[i]=sc[i+1]+cnt[i];
  }
  
  ll ans=0;
  ans+=sc[74];
  ans+=sc[24]*(sc[2]-1);
  ans+=sc[14]*(sc[4]-1);
  ans+=sc[4]*(sc[4]-1)/2*(sc[2]-2);
  
  pt(ans);
}






Measured memory_bytes: 256