akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define N 1010
#define pb push_back
#define fi first
#define se second
#define si size()
#define ll long long
#define mp make_pair
#define iter ::iterator
#define all(v) v.begin(), v.end()
#define READ(f) freopen (f, "r", stdin)
#define WRITE(f) freopen (f, "w", stdout)
#define pp pop_back
#define mapiter map<int, int>::iterator
#define forn(i, n) for(int i = 0; i < n; ++i)
#define forn1(i, n) for(ll i = 1; i <= n; ++i)
#define forr(i, n) for(int i = n - 1; i >= 0; --i)
#define forr1(i, n)	for(int i = n; i >= 1; --i)
#define barnarnar ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define elif else if
#define lld long double
#define r0 return 0
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define db(x) cerr << #x << ": " << x << endl;

const int inf = 2e9; 
const ll infl = 2e17;
const ll modw = 998244353ll;
 
const ll mods[2] = {1000000009ll, 1000000007ll};
const ll pp[2] = {31, 53};
const int K = 355;

using namespace std;
using namespace __gnu_pbds;

int main()
{
	barnarnar
	ll n;
	cin >> n;
	ll ans = 0;
	forn1(i, n)
	{
		forn1(j, n / i)
		{
			if(i * j <= n - 1)	ans++;
		}
	}
	cout << ans;
	r0;
}
// #_# ok



Measured memory_bytes: 3648
def LCS(str1,str2):
    A = [0 for _ in range(len(str2)+1)]
    for i in range(len(str1)):
        A_copy = A[:]
        for j in range(len(str2)):
            if(str1[i]==str2[j]):
                A[j+1] = A_copy[j]+1
            elif(A[j] > A[j+1]):
                A[j+1] = A[j]
    print(A[-1])


m = int(input())
for i in range(m):
    str1 = input()
    str2 = input()
    LCS(str1,str2)


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

typedef long long ll;


int main() {

    ios_base::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);

    int a = 0, b = 0;
    cin >> a >> b; 

    int min = 1;
    int max = 101 * 10;
    int ans = -1;
    for(int i = 0; i <= max; i++) {
        if(floor(i * 0.08) == a && floor(i * 0.1) == b) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 384
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
int A,B,Q;
ll As[100000];
ll Bs[100000];
ll INF=(ll)1000*1000*1000*1000;
int main() {

  scanf("%d%d%d", &A, &B, &Q);
  REP(i,A)
    scanf("%lld", As+i);
  REP(i,B)
    scanf("%lld", Bs+i);
  REP(i,Q) {
    ll x;
    scanf("%lld", &x);
    ll* ita=lower_bound(As, As+A, x);
    ll* itb=lower_bound(Bs, Bs+B, x);
    ll ans=INF;
    ll alis[2],blis[2];
    alis[0]=ita!=As+A?*ita:INF;
    blis[0]=itb!=Bs+B?*itb:INF;
    alis[1]=ita!=As?ita[-1]:-INF;
    blis[1]=itb!=Bs?itb[-1]:-INF;
    for(ll a:alis)
      for(ll b:blis) {
        ans = min(ans,abs(a-x)+abs(b-a));
        ans = min(ans,abs(b-x)+abs(b-a));
      }
    printf("%lld\n",ans);
  }


  return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n;
  cin >> n;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  ll ans = 0;
  ll l = 0;
  ll r = 0;
  ll sum = 0;
  REP(l, n){
    while(r < n && (sum+a[r]) == (sum^a[r])){
      sum += a[r];
      r++;
    }

    ans += r-l;
    if(l==r)
      r++;
    sum -= a[l];

  }

  cout << ans << endl;
}


Measured memory_bytes: 1792
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
dif = []

for i in range(1, M):
	dif.append(abs(X[i] - X[i-1]))

dif.sort()
difLen = len(dif)
# M - N = (M-1) - (N-1)
e = M - N
if e < 0:
	print(0)
	exit()
ans = sum(dif[0:e])

print(ans)

Measured memory_bytes: 90716
import java.util.Scanner;

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

    String S = sc.next();
    String T = "";
    if ("Sunny".equals(S)) {
      T = "Cloudy";
    } else if ("Cloudy".equals(S)) {
      T = "Rainy";
    } else if ("Rainy".equals(S)) {
      T = "Sunny";
    }
    System.out.println(T);
  }
}


Measured memory_bytes: 20948
// test

import java.util.*;
class Main {
    public static final int mod = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        long ans = 0;

        long aPct = div(a, a+b);
        long bPct = div(b, a+b);
        long comb = 1;
        for(int m = 0; m<n; m++) {
            ans += pow(aPct, n)*pow(bPct, m)%mod*comb%mod*(n+m)%mod;
            ans %= mod;
            ans += pow(bPct, n)*pow(aPct, m)%mod*comb%mod*(n+m)%mod;
            ans %= mod;
            comb = div(comb*(n+m)%mod, m+1);
        }
        long l = div(a+b, 100);
        System.out.println(div(ans, l));

    }
    static long pow (long x, long y) {
        if (y == 0) {
            return 1;
        } else if (y % 2 == 0) {
            long a = pow(x, y/2);
            return a*a%mod;
        } else {
            long a = pow(x, y/2);
                return(a*a%mod)*x%mod;
        }
    }

    static long div (long x, long y) {
        return (x*pow(y, mod-2))%mod;
    }

}

Measured memory_bytes: 21844
N = int(input())
a = sorted(list(map(int,input().split())))

count = 0
ans = []
for i in range(N-2):
  for s in range(1,N-1):
    for k in range(2,N):
      if a[k]<a[i]+a[s] and a[s]<a[i]+a[k] and a[i]<a[k]+a[s]:
        if i<s<k:
          if a[k]!=a[i] and a[k]!=a[s] and a[i]!=a[s] :
       
            count+=1
      
print(count)
      

Measured memory_bytes: 68416
M,D = map(int,input().split())
cnt = 0
if D > 21 and M > 3:
  for m in range(4,M+1):
    for d in range(22,D+1):
      a,b = divmod(d,10)
      if a > 1 and b > 1:
        if m == a*b:
          cnt += 1
      
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	for(ll i = 2; i *i <= n; i++)
	{
		if(n % i)
			continue;
		ll count = 0;
		while(n % i == 0)
		{
			n /= i;
			count++;
		}
		ll itr = 1;
		while(itr <= count)
		{
			ans++;
			count -= itr;
			itr++;
		}
	}
	if(n > 1)
		ans++;
	cout << ans;
	return 0;
}

Measured memory_bytes: 3504
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
int H,W;
char M[52][52];
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

bool solve(int x,int y){
    for(int i=0;i<4;i++){
        int rx=x+dx[i];
        int ry=y+dy[i];
        if(M[rx][ry]=='#')return true;
    }
    return false;
}
int main(){
    std::cin>>H>>W;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            std::cin>>M[i][j];
        }
    }
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            if(M[i][j]=='#'){
                if(!solve(i,j)){
                    std::cout<<"No"<<std::endl;
                    return 0;
                }
            }
        }
    }
    std::cout<<"Yes"<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 200010;
const int INF = INT_MAX/4;

int a,b,v1,v2,t;

int32_t main() {
	FAST
	cin >> a >> v1;
	cin >> b >> v2;
	cin >> t;
	
	if (a == b) {
		cout << "YES";
		return 0;
	}
	
	int diff = (v1 - v2);
	if (diff <= 0) {
		cout << "NO";
		return 0;
	}
	
	double timetaken = (double) abs(a-b) / (double) diff;
	if (timetaken <= t) {
		cout << "YES";
	}else {
		cout << "NO";
	}
	
	
	
}









Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char a[100];
    scanf("%s",a);
    int h=strlen(a);
    int flag=0;
    for(int i=0;i<h;i++)
    {
        if(a[i]=='7')
            flag=1;
    }
    if(flag)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 3764
#include<stdio.h>

int a[10];
int len,i;

int lsb(int num){
  return num%10;
}

int mix(){

  if(len==1)
    return 0;
  
  for(i=0;i<len-1;i++)
    a[i]=lsb(a[i]+a[i+1]);
  
  len--;
  return 1;
}

int main(){
  int c,f;
  
  for(;;){
    for(i=0;i<10;i++){
      for(;;){
	c=getchar();
	if(c==EOF)
	  return 0;
	else if(c>='0'&&c<='9')
	  break;
      }
      a[i]=c-'0';
    }
    
    len=10;
    f=1;
    while(f)
      f=mix();
    
    printf("%d\n",a[0]);
  }
}

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

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

    static class BIMissYou {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.nextLine();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < s.length(); i++) {
                sb.append("x");
            }
            out.println(sb.toString());
        }

    }
}



Measured memory_bytes: 23124
#include<iostream>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;

  // K-1ずつ変更する
  if((N-1)%(K-1)>0){
    cout << (N-1)/(K-1) + 1 << endl;
  }else{
    cout << (N-1)/(K-1) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]

n, a, b = ril()
if (a - b) % 2 == 0:
    print(abs(a - b) // 2)
else:
    print(min(a - 1, b - 1, n - a, n - b) + (abs(a - b) + 1) // 2)

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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    string s; cin >> s;
    ll n = s.length();
    ll res = n;
    char prev = s[0];
    for (ll i = 1; i < n; i++) {
        char cur = s[i];
        if (cur != prev) {
            res = min(res, max(i, n - i));
        }
        prev = cur;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e5 + 5, mod = 1e9 + 7;

int a[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, m, sum = 0;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    int cnt = 0, val = sum / (4 * m) ;
    if(sum % (4 * m)) val++;
    for(int i = 0; i < n; i++){
        if(a[i] >= val) cnt++;
    }
    if(cnt >= m) cout << "Yes";
    else cout << "No";


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
// scanf
#pragma warning(disable: 4996)
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値
#define _ceil(x) ceil(x)

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

	string temp;
	bool is_found = false;
	for (uint32_t i= 0; i < n; i++) {
		cin >> temp;
		if (temp != "Y") { continue; }
		is_found = true;
	}
	if (is_found) {
		printf("Four\n");
	}
	else {
		printf("Three\n");
	}

	return 0;
	//	std::cout << "Hello World!\n"; 
}


Measured memory_bytes: 256
import copy
n = int(input())
xarray = list(map(int,input().split()))
newArray = copy.copy(xarray)
newArray.sort()

left = newArray[n//2-1]
right = newArray[n//2]


for item in xarray:
    if item<=left:  #ここで if newArray.index(item)<=n//2-1 としたらTLEだったのでindexメソッド自体が結構時間かかるものなのかもしれない
        print(right)
    else:
        print(left)

Measured memory_bytes: 26068
//R<3S
#include <bits/stdc++.h>
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>


using namespace std;

void solve()
  {
	int n,w;
	cin>>n>>w;
	int wt[n],val[n];
	rep(i,n)cin>>wt[i]>>val[i];
	int dp[n+1][w+1];
	memset(dp,0,sizeof dp);
	dp[0][0]=0;
	
	
	repA(i,0,n)
	{
		repA(j,0,w)
		{
			if(i==0||j==0){dp[i][j]=0;continue;}
			if(j-wt[i-1]>=0)dp[i][j]=max(dp[i-1][j],dp[i-1][j-wt[i-1]]+val[i-1]);
			else dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][w];
	


  }



signed main()
{
   std::ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


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

using namespace std;

typedef long long int ll;

const int maxW = 1e5 + 1;
int N,W;
ll w[101];
ll v[101];
ll dp[101][maxW];


int main(){
	cin>>N>>W;
	fill(w, w + 101, 0);
	fill(v, v + 101, 0);
	fill(dp[0], dp[0] + 101 * maxW, 0);
	for(int i = 1; i <= N; ++i)
		cin>>w[i]>>v[i];
	for(int item = 0; item <= N; ++item){
		for(int weight = 0; weight <= W; ++weight){
			if(item==0||weight==0){
				dp[item][weight] = 0;
				continue;
			}
			if(w[item] <= weight){
				dp[item][weight] = max(
					v[item] + dp[item - 1][weight - w[item]],
					dp[item - 1][weight]
				);
			}
			else {
				dp[item][weight] = dp[item - 1][weight];
			}
		}
	}
	cout<<dp[N][W]<<endl;
	return 0;
}

Measured memory_bytes: 79104
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from heapq import heappush, heappop

def main():
    q = II()
    Q = []
    for _ in range(q):
        Q.append(LI())
    lows, highs = [], []
    slow, shigh = 0, 0
    bias = 0
    for q in Q:
        if q[0] == 2:
            odd = -lows[0] if len(highs) != len(lows) else 0
            ans = -lows[0], bias + shigh - slow + odd
            print(*ans)
        else:
            _, a, b = q
            bias += b
            if not lows:
                lows = [-a]
                slow = a
            else:
                if a <= -lows[0]:
                    heappush(lows, -a)
                    slow += a
                    if len(lows) > len(highs) + 1:
                        x = -heappop(lows)
                        heappush(highs, x)
                        slow -= x
                        shigh += x
                else:
                    heappush(highs, a)
                    shigh += a
                    if len(highs) > len(lows):
                        x = heappop(highs)
                        heappush(lows, -x)
                        shigh -= x
                        slow += x
    return

main()

Measured memory_bytes: 47420
#include "bits/stdc++.h"

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	LL d;
	while (cin >> d) {
		LL ans = 0;
		for (LL i = 1; i * d <= 600 - d; i++) {
			ans += i * d * i * d * d;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <cstdio>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>

#define MAXN 100009


std::vector < int > a[MAXN];
int t[MAXN], val[MAXN], v[MAXN];

int sef(int x) {
    if (t[x] == x) return x;
    else return t[x] = sef(t[x]);
}

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

    for (int i = 1; i <= n; i++) {
        t[i] = i;
        scanf("%d", &val[i]);
    }

    for (int i = 1; i <= m; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        x++;
        y++;

        t[sef(x)] = sef(y);
    }

    for (int i = 1; i <= n; i++)
        a[sef(i)].push_back(val[i]);

    long long sum = 0;
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (t[i] == i) {
            std::sort(a[i].begin(), a[i].end());
            sum += a[i][0];
            cnt++;
            for (int j = 1; j < (int)a[i].size(); j++)
                v[++v[0]] = a[i][j];
        }
    }

    bool ok = 1;
    if (cnt == 1)
        sum = 0;
    if (v[0] < cnt - 2)
        ok = 0;
    else {
        std::sort(v + 1, v + v[0] + 1);
        for (int i = 1; i <= cnt - 2; i++)
            sum += v[i];
    }

    if (ok == 0)
        printf("Impossible\n");
    else
        printf("%lld\n", sum);

    return 0;
}


Measured memory_bytes: 6528
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a,b;
  cin >> n >> a >> b;
  if(n%12==0) {
    cout << a << " " << b << endl;
  }
  else if(n%12==1) {
    cout << a-b << " " << b << endl;
  }
  else if(n%12==2) {
    cout << a-b << " " << a << endl;
  }
  else if(n%12==3) {
    cout << -b << " " << a << endl;
  }
  else if(n%12==4) {
    cout << -b << " " << a-b << endl;
  }
  else if(n%12==5) {
    cout << -a << " " << a-b << endl;
  }
  else if(n%12==6) {
    cout << -a << " " << -b << endl;
  }
  else if(n%12==7) {
    cout << -a+b << " " << -b << endl;
  }
  else if(n%12==8) {
    cout << -a+b << " " << -a << endl;
  }
  else if(n%12==9) {
    cout << b << " " << -a << endl;
  }
  else if(n%12==10) {
    cout << b << " " << -a+b << endl;
  }
  else if(n%12==11) {
    cout << a << " " << -a+b << endl;
  }
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    if (n - (n / 500) * 500 <= a)
        OP("Yes");
    else
        OP("No");

    return 0;
}

Measured memory_bytes: 256
using System;

class Class4
{
    static void Main(string[] args)
    {
    string[] _strinput = Console.ReadLine().Split();
    ulong ul0 = ulong.Parse(_strinput[0]), ul1 = ulong.Parse(_strinput[1]);
        if (ul0 == 1 || ul1 == 1) { 
            Console.WriteLine("1");
            return;
        }
        Console.WriteLine((ul0*ul1/2)+(ul1%2)*(ul0%2));
    }
}



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

int main() {
	int A, B;
	int c = 0;
	cin >> A >> B;
	for (int i = A;i < B + 1;i++) {
		if (i / 10000 == i % 10 && i/1000 - i/10000*10 == (i%100 -i%10)/10 ) {
			c++;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
N,A,B,C,D,=map(int,input().split())

if 1<=N<=1000 and 1<=A<=1000 and 1<=B<=1000 and 1<=C<=1000 and 1<=D<=1000:
    if N%A==0:
        X=(N//A)*B
    
    else:
        X=(N//A+1)*B
        
    if N%C==0:
        Y=(N//C)*D
    else:
        Y=(N//C+1)*D
    
    if X<=Y:
        print(int(X))
    if X>Y:
        print(int(Y))
        

else:
    pass


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

typedef pair<int, int> P;

int main(){
    int N;
    cin >> N;
    vector<int> L(N);

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

    sort(L.begin(), L.end());
    int cnt = 0; 
    for(int i = 0; i < N; ++i){
        for(int j = i + 1; j < N; ++j){
            for(int k = j + 1; k < N; ++k){
                if(L[i] + L[j] > L[k] && L[i] != L[j] && L[j] != L[k]){
                    cnt++;
                }
            }
        }
    }
    cout << cnt << endl;

    return 0;
}

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

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

    vector<pair<int, int>> key;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        int s = 0;
        rep(j, b){
            int c;
            cin >> c;
            c--;
            s |= 1 << c;
        }
        key.emplace_back(s, a);
    }

    vector<int> dp(1<<n, inf);
    dp[0] = 0;
    rep(s, 1<<n){
        rep(i, m){
            int t = s | key[i].first;
            int cost = dp[s] + key[i].second;
            dp[t] = min(dp[t], cost);
        }
    }
    int ans = dp.back();
    if(ans == inf){
        ans = -1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
 
 
int main()
{
      int n, i,j,k;
      int A[1000];
      int B;
 
      scanf("%d", &n);
 
      for (i = 0;i < n;i++) {
         scanf("%d", &A[i]);
                          }     
       for(j=0;j<n-1;j++){
                  printf("%d ",A[j]);
              }
             
              printf("%d\n",A[n-1]);   

      for (i = 1;i < n;i++) {
            for(int j=i;j!=0 && A[j]<A[j-1];--j){
              B = A[j-1];
              A[j-1]=A[j];
              A[j]= B;  
            }    
            for(k=0;k<n-1;k++){
                  printf("%d ",A[k]);
              }
              printf("%d\n",A[n-1]); 
                         
              
       }       

 
             
 
    return 0;
}


Measured memory_bytes: 1916
#include<iostream>
int main()
{
    int a, b, c, d;
    int sum = 0;
    std::cin >> a >> b >> c >> d;
    sum = a + b + c + d;  
    std::cin >> a >> b >> c >> d;
    if(sum < (a + b + c + d)){
        std::cout << (a + b + c + d)  << std::endl;
    }
    else{
        std::cout << sum << std::endl; 
    }
}

Measured memory_bytes: 1160
s = raw_input().strip()
t = raw_input().strip()

s_encode = [0]*26
t_encode = [0]*26

for i in s:
	s_encode[ord(i)-97]+=1

for i in t:
	t_encode[ord(i)-97]+=1

s_encode.sort()
t_encode.sort()
if s_encode==t_encode:
	print("Yes")
else:
	print("No")


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

def main():
    n, k, q = map(int, input().split())
    a = list(map(int, input().split()))

    b = [[v, i]for i, v in enumerate(a)]
    b.sort()
    index = [0]*n
    for i in range(n):
        index[i] = b[i][1]

    judge = [[] for i in range(n)]
    already = [-1, n]

    for i in range(n):
        
        for j in range(len(already)-1):
            key = a[already[j]+1:already[j+1]]
            if len(key) >= k:
                judge[i].append(key)
        already.append(index[i])
        already.sort()

    ans = 1e9
    for i in range(n):
        if not judge[i]:
            break
        m = b[i][0]
        sub = []
        for values in judge[i]:
            values.sort()
            for j in range(len(values)-k+1):
                sub.append(values[j])
        sub.sort()
        if len(sub) < q:
            break
        M = sub[q-1]
        ans = min(ans, M-m)

    print(ans)


    
if __name__ == "__main__":
    main()



Measured memory_bytes: 47644
#include<bits/stdc++.h>
    using namespace std;
    const int mod = 1e9 + 7;
    int main()
    {
        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int x, y; cin >> x >> y;
        if (abs(x - y) > 1) return cout << 0, 0;
        long long ans = 1;
        for (int i = 1; i <= x; ++i) {
            ans *= i;
            ans %= mod;
        }
        for (int i = 1; i <= y; ++i) {
            ans *= i;
            ans %= mod;
        }
        cout << (x == y ? (ans * 2) % mod : ans);
            return 0; 
    }  

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",c);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int a[114514],b[114514];
pair<int,int>l[114514];
signed main(){
	ic(n)
	rep(0,i,n){
		cin>>a[i];
		cin>>b[i];
	}
	rep(0,i,n){
		l[i].s=a[i]-b[i];
		l[i].f=a[i]+b[i];
	}
	sort(l,l+n);	
	int ans=0,t=-1145141919;
	rep(0,i,n){
		if(t<=l[i].s){
			ans++;
			t=l[i].f;
		}
	}
	c(ans)		
}	


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define SUBIF(a, b, x) ((x) ? (b) : (a))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


struct SEG {
	int aryN;
	vector<PII> seg;

	SEG(){}
	SEG(const VI &v){
		aryN = (int)pow(2, (int)ceil(log2(SIZE(v))));
		seg.resize(2*aryN-1, { -1, INF });
		rep(i, 0, SIZE(v)) seg[i+aryN-1] = { v[i], v[i] };
		reper(i, aryN-2, 0) seg[i].first = max(seg[2*i+1].first, seg[2*i+2].first), seg[i].second = min(seg[2*i+1].second, seg[2*i+2].second);
	}
	void update(int x, PII p){
		x += (aryN-1);
		seg[x] = p;
		while(x > 0){
			x = (x-1)/2;
			seg[x].first = max(seg[2*x+1].first, seg[2*x+2].first);
			seg[x].second = min(seg[2*x+1].second, seg[2*x+2].second);
		}
	}
	int getMax(int a, int b, int k = 0, int l = 0, int r = -1){
		if(r < 0) r = aryN;
		if(r <= a || b <= l) return -1;
		if(a <= l && r <= b) return seg[k].first;
		int vl = getMax(a, b, 2*k+1, l, (l+r)/2);
		int vr = getMax(a, b, 2*k+2, (l+r)/2, r);
		return max(vl, vr);
	}
	int getMin(int a, int b, int k = 0, int l = 0, int r = -1){
		if(r < 0) r = aryN;
		if(r <= a || b <= l) return INF;
		if(a <= l && r <= b) return seg[k].second;
		int vl = getMin(a, b, 2*k+1, l, (l+r)/2);
		int vr = getMin(a, b, 2*k+2, (l+r)/2, r);
		return min(vl, vr);
	}
};


int N, d;
vector<TIII> s;
int br[200010];
SEG X, Y;


template<int N>
VI tupleToVec(vector<TIII>& vt){
	VI ret;
	for(TIII t : vt) ret.pb(get<N>(t));
	return ret;
}


llint solve(){
	llint ans = 0;
	rep(i, 0, N) br[i] = get<0>(s[i]);
	X = SEG(tupleToVec<1>(s));
	Y = SEG(tupleToVec<2>(s));
	rep(i, 0, N){
		int p = upper_bound(RNG(br, N), br[i]+d)-&br[0];
		llint x1 = X.getMax(i, p), x2 = X.getMin(i, p);
		llint y1 = Y.getMax(i, p), y2 = Y.getMin(i, p);
		ans = max(ans, (x1-x2)*(y1-y2));
	}
	return ans;
}


int main(){
	cin >> N >> d;
	s = vector<TIII>(N);
	rep(i, 0, N) cin >> get<1>(s[i]) >> get<2>(s[i]) >> get<0>(s[i]);
	sort(ALL(s));

	cout << solve() << endl;

	return 0;
}


Measured memory_bytes: 16220
#include <cstdio>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <set>
using namespace std;
 
typedef long long ll;
 
int n, a, b;
const int maxn = 1e5+1;
ll h[maxn];
bool valid(ll mid)
{
    ll cnt = 0;
    for (int i = 0; i < n; ++i)
    {
        if (h[i] <= mid*b)
            continue;
        cnt += (h[i]-mid*b+a-1)/a;
    }
    return cnt <= mid;
}
int main()
{
    scanf("%d %d %d", &n, &a, &b);
    a -= b;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d", h+i);
    }
    int l = 0, r = 1e9, mid, ans;
    while (l <= r)
    {
        mid = (l+r)>>1;
        if (valid(mid))
        {
            ans = mid;
            r = mid-1;
        }
        else
        {
            l = mid+1;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<utility>
#include<algorithm>
#include<functional>
#include<deque>
#include<cctype>
#include<time.h>
#include<cstdlib>
#include<iomanip>
using namespace std;

int main(){
   int n;
   cin >> n;
   if (n <= 999) cout << "ABC" << endl;
   else cout << "ABD" << endl;
}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
dic = [0] * 128
for i in range(n):
    s = ns()
    dic[ord(s[0])] += 1

x = [
    ord("M"),
    ord("A"),
    ord("R"),
    ord("C"),
    ord("H"),
]

ans = 0
for i in range(5):
    for j in range(i+1, 5):
        for k in range(j+1, 5):
            ans += dic[x[i]] * dic[x[j]] * dic[x[k]]
print(ans)




Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define MAX 500000000

using namespace std;

int main()
{
    long long n,flag,i;
    while(cin >> n)
    {
        for(i=n; i>0; i--)
        {
            int r = sqrt(i);
            if(r == sqrt(i))
            {
                flag = i;
                break;
            }
        }
        cout << flag << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int W ,H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) { printf("Yes\n"); }
	else { printf("No\n"); }
	return 0;
}



Measured memory_bytes: 2696
#!/usr/bin/env python3
#ABC44 D

import sys
import math
import bisect
import time
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

#√n < bの場合はnをb進数表記すると2桁になることに着目
n = I()
s = I()
def f(b,n):
    if n < b:
        return n
    else:
        return f(b,n//b) + n % b

if n == s:
    print(n+1)
    quit()
for b in range(2,int(math.sqrt(n))+1):
    if f(b,n) == s:
        print(b)
        quit()
for p in range(1,int(math.sqrt(n))+1)[::-1]:
    b = (n-s)//p + 1
    if b <= 1:
        continue
    if f(b,n) == s:
        print(b)
        quit()
print(-1)


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

int main() {
  int A, B, C, D;
  cin >> A >>B >>C >>D;
  if(A+B > C+D){
    cout << "Left" << endl;
  }
  if(A+B < C+D){
    cout << "Right" << endl;
  }
  if(A+B==C+D){
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter
N=int(input())
A=list(map(int,input().split()))
A__=list(set(A))
A_=Counter(A)
S=0
for a in A__:
    k=a
    v=A_[a]
    if v<2:
        continue
    a=v*(v-1)//2
    S+=a

for a in A:
    x=A_[a]
    y=x*(x-1)//2
    S-=y
    z=(x-1)*(x-2)//2
    print(S+z)
    S+=y



Measured memory_bytes: 28032
//鉄道路線Ⅱ

#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>

using namespace std;

int N, M;
int st;//出発駅番号
int s[10009];//目的駅番号
int shortest;//最短ルート長
int d;//M+1 目的地の数(st含む)
//int _p1, _p2, t;//t 1:clock 0:unti-clock

int D(int a, int b) {//aからbへ順方向に回ったときの距離
	if (b < a) 
		return N + b - a;
	else return b - a;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i <= M; i++) {
		cin >> s[i];
		if (!i) 
			st = s[i];
	}
	sort(s, s + (M + 1));

	shortest = N;
	d = M + 1;

	for (int i = 0; i < d; i++) {//st->p1->st->p2
		//時計回り
		int P1 = s[i], P2 = s[(i - 1 + d) % d];
		int d1 = N - D(P2, P1) + D(P1, st);//一周-通らない区間+二回通る区間
		if (shortest > d1) {
			shortest = d1;
			//_p1 = P1; _p2 = P2; t = 1;
			//cout << _p1 << " " << _p2 << " " << t << " " << shortest * 100 << endl;
		}

		//反時計回り
		int p1 = s[i], p2 = s[(i + 1) % d];
		int d2 = N - D(p1, p2) + D(st, p1);//一周-通らない区間+二回通る区間
		if (shortest > d2) {
			shortest = d2;
			//_p1 = p1; _p2 = p2; t = 0;
			//cout << _p1 << " " << _p2 << " " << t << " " << shortest * 100 << endl;
		}
	}

	cout << shortest * 100 << endl;

	return 0;
}


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

int t[100005],x[100005],y[100005];
int main(){
    int N;cin>>N;
    int flag=0;
    for(int i=1;i<=N;i++)cin>>t[i]>>x[i]>>y[i];
    for(int i=1;i<=N;i++){
        if(abs(x[i]-x[i-1])+abs(y[i]-y[i-1])>t[i]-t[i-1] or (abs(x[i]-x[i-1])+abs(y[i]-y[i-1])-(t[i]-t[i-1]))%2!=0){
            flag++;
            break;
        }
    }
    if(flag)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long

using namespace std;

// input
ll a,b;

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

    cout << fixed << setprecision(0) << a*b << " " << 2*(a+b) << "\n";
}


Measured memory_bytes: 3168
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int jo,io;
    char str[10000];
    while(scanf("%s",str)!=EOF){
        jo=0;io=0;
        for(int i=0;;i++){
            if(str[i]=='\0')break;
            else if(str[i]=='J'&&str[i+1]=='O'&&str[i+2]=='I')jo++;
            else if (str[i]=='I'&&str[i+1]=='O'&&str[i+2]=='I')io++;
        }
        cout<<jo<<endl<<io<<endl;
    }
}

Measured memory_bytes: 1168
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 23/09/2017 13:01:03
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	string s1, s2 = "";
	cin>>s1;
	for(int i = 0; i < s1.size() && i < 4; i++){
		s2 += s1[i];
	}
	if(s2 == "YAKI") cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,x,N[100001];
  scanf("%d",&x);
  for(i=1; i<=x; i++)scanf("%d",&N[i]);
  for(i=1; i<=x; i++){
    printf("node %d: key = %d, ",i,N[i]);
    if(i/2>=1)printf("parent key = %d, ",N[i/2]);
    if(2*i<=x)printf("left key = %d, ",N[2*i]);
    if(2*i+1<=x)printf("right key = %d, ",N[2*i+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2112
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 500000
#define P 131
#define MO 1000000007
using namespace std;
char str[MAXN+5];
int n;
int Hash[MAXN+5],Pow[MAXN+5];
bool l[MAXN+5],r[MAXN+5];
void prepare()
{
	Pow[0]=1;
	for(int i=1;i<=MAXN;i++)
		Pow[i]=1LL*Pow[i-1]*P%MO; 
}
int main()
{
	prepare();
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=1;i<=n;i++)
		Hash[i]=(1LL*Hash[i-1]*P+1LL*str[i])%MO;
	for(int i=1;i<=n;i++)
	{
		int val=Hash[i];
		for(int totlen=i*2;totlen<=n;totlen+=i)
		{
			val=(1LL*val*Pow[i]%MO+1LL*Hash[i])%MO;
			if(Hash[totlen]==val)
				l[totlen]=true;
			else
				break;
		}
	}
	reverse(str+1,str+1+n);
	memset(Hash,0,sizeof(Hash));
	for(int i=1;i<=n;i++)
		Hash[i]=(1LL*Hash[i-1]*P+1LL*str[i])%MO;
	for(int i=1;i<=n;i++)
	{
		int val=Hash[i];
		for(int totlen=i*2;totlen<=n;totlen+=i)
		{
			val=(1LL*val*Pow[i]%MO+1LL*Hash[i])%MO;
			if(Hash[totlen]==val)
				r[totlen]=true;
			else
				break;
		}
	}
	
	if(l[n]==false)
	{
		printf("1\n1\n");
		return 0;
	}
	bool same=true;
	for(int i=1;i<n;i++)
		if(str[i]!=str[i+1])
		{
			same=false;
			break;
		}
	if(same==true)
	{
		printf("%d\n1\n",n);
		return 0;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		if(l[i]==false&&r[n-i]==false)
			ans++;
	printf("2\n%d\n",ans);
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,T;
    cin >> n >> T;

    VI a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];

    ll dp[n+10][T+10][2];

    rep(i,n+1) rep(j,T+1) rep(k,2) dp[i][j][k] = 0;

    rep(i,n){
      rep(j,T+1){
        if(j-a[i] >= 0){
          dp[i+1][j-a[i]][0] = max(b[i] + dp[i][j][0] , dp[i+1][j-a[i]][0]);
          dp[i+1][j-a[i]][1] = max(b[i] + dp[i][j][1] , dp[i+1][j-a[i]][1]);
        }
        if(j-1 >= 0) dp[i+1][j-1][1] =  max(b[i]+dp[i][j][0], dp[i+1][j-1][1]);
        rep(k,2) dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
      }
      
    }
    
    ll ans = 0;
    rep(i,T+1){
        ans = max(dp[n][i][0],ans);
        ans = max(dp[n][i][1],ans);
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 141440
#include<bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(),x.end()
#define ld long double
#define fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 2e5+1;
int n,k;
int a[N];
bool check(int mid){
	int cnt = 0;
	int cuts = 0;
	for(int i = 1;i<=n;i++){
		if(a[i]>mid){
			cuts += (a[i]/mid);
		}
		if(cuts>k) return false;
	}
	return true;
}
signed main(){
    fast;
   	cin>>n>>k;
   	for(int i = 1;i<=n;i++)
   		cin>>a[i];
   	sort(a+1,a+n+1);
   	int low = 1;
   	int high = a[n];
   	int ans;
   	while(low<=high){
   		int mid = (low + high)/2ll;
   		//cout<<mid<<" "<<check(mid)<<endl;
   		if(check(mid)){
   			ans = mid;
   			high = mid-1ll;
   		}
   		else low = mid+1ll;
   	}
   	cout<<ans;
}

Measured memory_bytes: 5084
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl;exit(0);}else return;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
void YN(bool flg) {cout << ((flg) ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << ((flg) ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << ((flg) ? "yes" : "no") << endl;}

int main() {
	int N,K; cin >> N >> K;
	V<ll> a(K); REP(i, N) cin >> a[i];
	V<int> dp(K + 1);
	dp[0] = 0;
	FOR(i, 1, K + 1) {
		int cnt = 0;
		REP(j,N){
			if (i - a[j] < 0) continue;
			cnt++;
			if (dp[i - a[j]] == 0) {
				dp[i] = 1;
				break;
			}
			dp[i] = 0;
		}
		if(cnt==0) dp[i] = 0;
	}
	cout << ((dp[K] == 1) ? "First" : "Second") << endl;
}



Measured memory_bytes: 1408