akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int f[4010][4010],a[200010],b[200010],fac[8010],inv[8010];
inline int qpow(int a,int b) {
	int ans=1;
	while(b) {
		if(b&1)ans=1ll*ans*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return ans;
}
inline int C(int n,int m) {
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}
int main() {
	fac[0]=1;
	for(int i=1;i<=8000;i++)fac[i]=1ll*fac[i-1]*i%mod;
	inv[8000]=qpow(fac[8000],mod-2);
	for(int i=8000-1;i>=0;i--)inv[i]=1ll*inv[i+1]*(i+1)%mod;
	int n,ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) {
		scanf("%d%d",a+i,b+i);
		f[2000-a[i]][2000-b[i]]++;
	}
	for(int i=0;i<=4000;i++)
		for(int j=0;j<=4000;j++) {
			f[i][j+1]=(f[i][j+1]+f[i][j])%mod;
			f[i+1][j]=(f[i+1][j]+f[i][j])%mod;
		}
	for(int i=1;i<=n;i++)ans=(ans+f[2000+a[i]][2000+b[i]]-C((a[i]+b[i])<<1,a[i]<<1))%mod;
	ans=(mod+ans)%mod;
	printf("%lld\n",1ll*ans*inv[2]%mod);
	return 0;
}

Measured memory_bytes: 64640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,l,d=0,ans=1;cin>>n>>x;
  for(int i=0;i<n;i++){
    cin>>l;
    d+=l;
    if(d<=x) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define vpii            vector<pair<int,int> >
#define umii            unordered_map<int,int>
#define lli             list<int>             
#define gcd(m,n)        __gcd(m,n)   
#define mib             map<int,bool>
 
void fast()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//#endif
}
 
//////////////////////////////code//////////////////////////////

int32_t main()
{
  fast();
  int n,k;
  cin>>n>>k;
  int arr[n];
  
  for(int i=0;i<n;i++)
  cin>>arr[i];
  
  int dp[n];
  
  dp[0]=0;
  dp[1]=abs(arr[1]-arr[0]);
  
  for(int i=2;i<n;i++)
  {  dp[i]=INT_MAX;
    for(int j=1;j<=k && i-j>=0 ;j++)
      dp[i]=min(dp[i-j]+abs(arr[i-j]-arr[i]),dp[i]);
  }
  
  cout<<dp[n-1];


}

Measured memory_bytes: 1792
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    AB=[tuple(map(int, input().split())) for _ in range(N)]
    scoresA = [(a+b,a,i) for i,(a,b) in enumerate(AB)]
    scoresB = [(b+a,b,i) for i,(a,b) in enumerate(AB)]
    scoresA.sort(reverse=True)
    scoresB.sort(reverse=True)
    ans=0
    used=[False]*N
    ai=bi=0
    for i in range(N):
        if i&1:
            while used[scoresB[bi][2]]: bi+=1
            ans-=scoresB[bi][1]
            used[scoresB[bi][2]]=True
        else:
            while used[scoresA[ai][2]]: ai+=1
            ans+=scoresA[ai][1]
            used[scoresA[ai][2]]=True
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 80732
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

int main()
{
    int n;
    std::cin >> n;
    std::vector<int> vs(n);
    for (auto i = 0; i < n; ++i)
    {
        int num;
        std::cin >> num;
        vs[i] = num;
    }
    std::cin >> n;
    std::vector<int> vt(n);
    for (auto i = 0; i < n; ++i)
    {
        int num;
        std::cin >> num;
        vt[i] = num;
    }
    std::sort(vs.begin(), vs.end());
    std::sort(vt.begin(), vt.end());
    std::vector<int> common;
    std::set_intersection(vs.begin(), vs.end(), vt.begin(), vt.end(), std::back_inserter(common));
    std::cout << common.size() << std::endl;
    return 0;
}



Measured memory_bytes: 3156
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def lcm(a, b):
  return a*b/gcd(a, b)

try :
  while True :
    (a,b) = map(int, raw_input().split())

    print gcd(a,b), lcm(a,b)
except EOFError :
  pass

Measured memory_bytes: 4220
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
using namespace std;

#define ll long long

int main() {
	int H, W, N; cin >> H >> W >> N;
	int r, c; cin >> r >> c;
	string S, T; cin >> S >> T;
	bool flag=true;
	int now;
	now=r;
	for(int i=0; i<N; ++i){
	    if(S[i]=='U') --now;
	    if(now==0){
	        flag=false;
	        break;
	    }
	    if(T[i]=='D' && now<H) ++now;
	}
	now=r;
	for(int i=0; i<N; ++i){
	    if(S[i]=='D') ++now;
	    if(now>H){
	        flag=false;
	        break;
	    }
	    if(T[i]=='U' && now>1) --now;
	}
	now=c;
	for(int i=0; i<N; ++i){
	    if(S[i]=='L') --now;
	    if(now==0){
	        flag=false;
	        break;
	    }
	    if(T[i]=='R' && now<W) ++now;
	}
	now=c;
	for(int i=0; i<N; ++i){
	    if(S[i]=='R') ++now;
	    if(now>W){
	        flag=false;
	        break;
	    }
	    if(T[i]=='L' && now>1) --now;
	}
	cout << (flag ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 1020
#include "bits/stdc++.h"
#define rep(i, j) for (int i = 0; i < j; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using ull = unsigned long long;

int gcd(int x, int y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    vector<int> sinn(n);
    sinn = x;
    sort(sinn.begin(), sinn.end());

    int num1 = sinn[(n / 2) - 1];
    int num2 = sinn[(n / 2)];

    rep(i, n) {
        if (x[i] > num1)
            cout << num1 << endl;
        else
            cout << num2 << endl;
    }
    return 0;
}

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 4852
use proconio::input;
const MAX: usize = 1_000_000 + 10;
fn main() {
    input!(n: usize);
    input!(mut a: [usize; n]);
    a.sort();
    let v = split_same_element(&a);
    let mut dp = vec![false; MAX];

    for &(e, c) in &v {
        if c > 1 {
            dp[e] = true;
        }
        let mut idx = 2 * e;
        while idx < MAX {
            dp[idx] = true;
            idx += e;
        }
    }

    let mut ans = 0;
    for &e in &a {
        if dp[e] == false {
            ans += 1;
        }
    }

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

fn split_same_element<T: Eq + Copy>(v: &Vec<T>) -> Vec<(T, usize)> {
    let mut res: Vec<(T, usize)> = Vec::new();
    if v.is_empty() {
        return res;
    }

    let mut now: T = v[0];
    let mut count: usize = 0;
    for &e in v {
        if e == now {
            count += 1;
        } else {
            res.push((now, count));
            count = 1;
            now = e;
        }
    }
    res.push((now, count));

    res
}


Measured memory_bytes: 9340
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<functional>
#include<cmath>

using namespace std;

typedef long long ll;

int main()
{
	string str;

	while (cin>>str) {
		int jcou = 0, icou = 0;
		for (int i = 0; i < str.length()-2; i++) {
			if (str[i] == 'J') {
				if (str[i + 1] == 'O'&&str[i + 2] == 'I')jcou++;
			}
			if (str[i] == 'I') {
				if (str[i + 1] == 'O'&&str[i + 2] == 'I')icou++;
			}
		}
		cout << jcou << endl;
		cout << icou << endl;
	}

	return 0;
}

Measured memory_bytes: 3040
#include <map>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define For(i, a, b) for (i = a; i <= b; i++)
#define Step(i, a, b, x) for (i = a; i <= b; i += x)
using namespace std;
const int mod = 998244353;
map<string, int> f, g;
int F(string); int G(string);
int G(string s) {
    if (g[s]) return g[s]; int i, n = s.size(); if (n == 1) return g[s] = s[0] - '0' + 1;
    int j, k, res = 0; For (i, 1, n - 1) if (n % i == 0) {
        string t = ""; For (j, 1, i) {
            int r = 1; Step (k, j - 1, n - 1, i) r &= s[k] - '0';
            t += (char) (r + '0');
        }
        res = (res + F(t)) % mod;
    }
    return g[s] = res;
}
int F(string s) {
    if (f[s]) return f[s]; int i, n = s.size(); if (!n) return f[s] = 1;
    int res = 0; For (i, 1, n)
        res = (res + 1ll * G(s.substr(0, i)) * F(s.substr(i, n)) % mod) % mod;
    return f[s] = res;
}
int main() {
    string s; cin >> s; cout << F(s) << endl;
    return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main() {
    int N, M;
    int a;  // 偶数+偶数
    int b;  // 奇数+奇数
    int ans;
    cin >> N >> M;

    a = ( N * (N-1) ) / 2;
    b = ( M * (M-1)) / 2;
    ans = a + b;

    cout << ans << endl;


}


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

#define ll long long
#define ull unsigned long long

bool isPalindrome(string s) {
    string t(s.rbegin(), s.rend());
    return s == t;
}

int main(void) {
    string S, T;
    ll count = 0;
    cin >> S >> T;
    if(S[0] == T[0]) count++;
    if(S[1] == T[1]) count++;
    if(S[2] == T[2]) count++;
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
// 2011/08/02 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prm[], int n)
{
	if(n>=1)
		prm[0] = false;
	if(n>=2)
		prm[1] = false;

	for(int i=2; i<n; i++)
		prm[i] = true;

	for(int i=2; i<n; i++)
		if(prm[i])
			for(int j=i+i; j<n; j+=i)
				prm[j] = false;
}

int main()
{
	bool prm[1000001];		// for AOJ
	eratos(prm, 1000001);

	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int cnt = 0;
		for(int p=2; p<=n-p; p++)
			if(prm[p]&&prm[n-p])
				cnt++;

		cout << cnt << endl;
	}

	return 0;
}

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

#include <sstream>
#include <fstream>
#include <cmath>
#include <vector>


using namespace std;


void check( int val ){
	
	cout << val << endl;
}

int main( int argc , char ** argv ){
	
	string s;
	cin >> s;

	bool C_check = true;
	bool F_check = true;
	// check(TEST_NUM);
	
	int C_point = s.find('C');

	if(C_point == string::npos){
		cout << "No" << endl;
		C_check = false;
	}
	else{

		string new_s = s.substr(C_point);

		int F_point = new_s.find('F');

		if(F_point == string::npos){
			cout << "No" << endl;
			F_check = false;
		}
	}
	if(C_check && F_check)
		cout << "Yes" << endl;

}



Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  int n = readNum!int;
  writeln(180 * (n - 2));
}


Measured memory_bytes: 256
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br= new
				BufferedReader(new InputStreamReader(System.in));
		while(true){
			String str1 = br.readLine();
			if(str1==null)break;
			int total=0;
			int num1 = Integer.parseInt(str1);
			for(int i=0;i<600;i+=num1){
				total+=(i*i*num1);
			}
			System.out.println(total);
		}

	}

}

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define sz(x) int(x.size())
const ll mod = 1000000007;
const ll INF = 1001001001001001000;

int main() {
    int r; cin >> r;
    cout << r*r << endl;
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n;i++)cin >> h.at(i);
	vector<int> count(n, 0);
	int p = 0;
	for (int i = 0; i < n - 1; i++) {
		if (h.at(i) >= h.at(i + 1))count.at(p)++;
		else p++;
	}
	sort(count.begin(), count.end());
	cout << count.at(n - 1) << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>

#define REP(i,n) for(int i=0; i<n; i++)
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define SIZE 722	// 1260-540
#define MAXM 10000

using namespace std;
typedef long long ll;

int data[MAXM][SIZE];

int main(){
	while(1){
		int n, m, r, q, tt, nn, mm, ss, ts, te, ans;
		
		cin >> n >> m >> r;
		if (n==0 && m==0) break;
		REP(i, MAXM){
			REP(k, SIZE){
				data[i][k] = 0;
			}
		}
		
		REP(i,r){
			scanf("%d %d %d %d", &tt, &nn, &mm, &ss);
			mm--;
			if (ss==1) data[mm][tt-540] += 1;
			else data[mm][tt-540] += -1;
		}
		
		/*/
		REP(i, SIZE){
			if (data[0][i]!=0) printf("data[%d]=%d\n", i, data[0][i]);
		}
		/*/
		
		REP(i, m){
			for (int k=1; k<SIZE; k++){
				data[i][k] += data[i][k-1];
			}
		}
		
		/*/
		REP(i, SIZE){
			if (data[0][i]>0) printf("data[%d]=%d\n", i, data[0][i]);
		}
		/*/
		
		cin >> q;
		
		REP(i,q){
			ans = 0;
			scanf("%d %d %d", &ts, &te, &mm);
			mm--;
			for (int i=ts; i<te; i++){
				if (data[mm][i-540]>0) ans++;
			}
			cout << ans << endl;
		}
		
	}
	return 0;
}



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

using P = pair<int64_t,int64_t>;
struct edge{
  int64_t to, yen, snuke;
};

const int MAX_N = 1e5;
int64_t N;


int64_t INF = 1e18;
vector<int64_t> dist1(MAX_N,INF);
vector<int64_t> dist2(MAX_N,INF);
vector<edge> G[MAX_N];


void dijkstra1(int s){
  priority_queue<P,vector<P>,greater<P>> PQ;
  dist1[s] = 0;
  PQ.push(P(0,s));
  
  while(PQ.size()){
    P p = PQ.top();
    PQ.pop();
    int v = p.second; //from
    if(dist1[v] < p.first){ //現在わかっている距離が更新できない
      continue;
    }
    for(int i=0; i<G[v].size(); i++){
      edge e = G[v][i];
      if(dist1[e.to] > dist1[v] + e.yen){
        dist1[e.to] = dist1[v] + e.yen;
        PQ.push(P(dist1[e.to], e.to));
      }
    }
  }
}

void dijkstra2(int s){
  priority_queue<P,vector<P>,greater<P>> PQ;
  dist2[s] = 0;
  PQ.push(P(0,s));
  
  while(PQ.size()){
    P p = PQ.top();
    PQ.pop();
    int v = p.second; //from
    if(dist2[v] < p.first){ //現在わかっている距離が更新できない
      continue;
    }
    for(int i=0; i<G[v].size(); i++){
      edge e = G[v][i];
      if(dist2[e.to] > dist2[v] + e.snuke){
        dist2[e.to] = dist2[v] + e.snuke;
        PQ.push(P(dist2[e.to], e.to));
      }
    }
  }
}

int main(){
  int64_t M, S, T;
  cin >> N >> M >> S >> T;
  S--; T--;
  for(int i=0; i<M; i++){
    int64_t a, b, c, d;
    cin >> a >> b >> c >> d;
    a--; b--;
    edge e = {b,c,d};
    G[a].push_back(e);
    e = {a,c,d};
    G[b].push_back(e);
  }
  dijkstra1(S);
  dijkstra2(T);
  vector<int64_t> use(N);
  for(int i=0; i<N; i++){
    use.at(i) = dist1[i] + dist2[i];
  }
  int64_t MIN = 1e18;
  vector<int64_t> ans(N);
  for(int i=N-1; i>=0; i--){
    MIN = min(MIN,use.at(i));
    ans.at(i) = 1e15 - MIN;
  }
  
  for(int i=0; i<N; i++){
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 15360
from collections import deque

A = deque(input())
B = deque(input())
C = deque(input())

current = "a"

while True:
    if current == "a":
        current = A.popleft()
    elif current == "b":
        current = B.popleft()
    elif current == "c":
        current = C.popleft()
    if current == "a" and len(A) == 0:
        print("A")
        break
    elif current == "b" and len(B) == 0:
        print("B")
        break
    elif current == "c" and len(C) == 0:
        print("C")
        break

Measured memory_bytes: 3316
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}
macro_rules! tern {
    ($condition: expr, $_true: expr, $_false: expr) => {
        if $condition {
            $_true
        } else {
            $_false
        }
    };
}
fn main() {
    let N = get!(usize);
    for i in 1..50000 {
        if ((i as f64) * 1.08f64).floor() as usize == N {
            println!("{}", i);
            return;
        }
    }
    println!(":(");
}


Measured memory_bytes: 4352
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int gcd(int a, int b) {
    int t;    // 補助変数
    while ( b != 0 ) {          // 他方が0になるまで
        t = a%b; a = b; b = t;    // 一方を剰余に置き換える
    }
    return a;                   // 他方が0になったときの一方がGCD
}
signed main(){
    int t,a,b,c,d;cin>>t;
    rep(i,0,t){
        cin>>a>>b>>c>>d;
        if(b>d||a<b){
            cout<<"No"<<endl;
            continue;
        }
        if(c>=b){
            cout<<"Yes"<<endl;
            continue;
        }
        int g=gcd(d,b);
        int h=b-g+(a%g);
        if(c<h)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
    }
    return 0;
}

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

#define ll long long
#define pb push_back
#define debug1(x) cerr << #x << " = " << x << '\n';
#define debug2(x, y) cerr << #x << " = " << x << "   " << #y << " = " << y << "\n";
#define _ ios_base::sync_with_stdio(0);cin.tie(NULL);

void solve() {
    int n;
    cin >> n;
    map<string, int> mp;
    for(int i = 0; i<n; i++) {
        string s;
        cin >> s;
        mp[s] ++;
    }
    cout << "AC"  << " x " << mp["AC"] << '\n';
    cout << "WA"  << " x " << mp["WA"] << '\n';
    cout << "TLE"  << " x " << mp["TLE"] << '\n';
    cout << "RE"  << " x " << mp["RE"] << '\n';
}

int main() {_
    int t = 1;
    //cin >> t;
    //Please remember to uncomment for taking test cases
    for(int i = 1; i<=t; i++) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

ll dp[401][401];
ll vis[401][401];
ll sum[401];

ll solve(int L, int R) {
    if (vis[L][R])
        return dp[L][R];
    vis[L][R] = 1;
    if (L == R)
        return dp[L][R] = 0;

    ll ret = 1LL << 60;
    for (int i = L; i <= R; ++i) {
        chmin(ret, solve(L, i) + solve(i + 1, R) + sum[R] - sum[L - 1]);
    }
    return dp[L][R] = ret;
}

int main() {
    int n;
    cin >> n;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sum[0] = a[0];
    for (int i = 1; i < n; ++i) {
        sum[i] += sum[i - 1] + a[i];
    }
    cout << solve(0, n - 1) << "\n";

    return 0;
}

Measured memory_bytes: 2816
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

M = i()
print(48-M)


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

int main()
{
	int n, x;
	string com;
	list<int> lis;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> com;
		if (com == "insert") {
			cin >> x;
			lis.push_front(x);
		}
		else if (com == "delete") {
			cin >> x;
			for (auto ite = lis.begin(); ite != lis.end(); ite++) {
				if (*ite == x) {
					lis.erase(ite);
					break;
				}
			}
		}
		else if (com == "deleteFirst") {
			lis.pop_front();
		}
		else if (com == "deleteLast") {
			lis.pop_back();
		}
	}
	for (auto ite = lis.begin(); ite != lis.end(); ite++) {
		if (ite == lis.begin())
			cout << *ite;
		else
			cout << ' ' << *ite;
	}
		cout << endl;
	return 0;
}

Measured memory_bytes: 34320
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (N, T) = read!(usize, usize);
    let mut A = vec![];
    let mut B = vec![];

    for (a, b) in read![usize, i64; N] {
        A.push(a);
        B.push(b);
    }

    let mut dp = vec![vec![0; T]; N + 1];
    dp[0][0] = 0;

    let mut prev = vec![vec![None; T]; N + 1];

    for i in 0..N {
        for t in 0..T {
            if dp[i + 1][t] < dp[i][t] {
                dp[i + 1][t] = dp[i][t];
                prev[i + 1][t] = prev[i][t];
            }

            if t + A[i] < T && dp[i + 1][t + A[i]] < dp[i][t] + B[i] {
                dp[i + 1][t + A[i]] = dp[i][t] + B[i];
                prev[i + 1][t + A[i]] = Some((i, t));
            }
        }
    }

    for t in 0..T - 1 {
        if dp[N][t + 1] < dp[N][t] {
            dp[N][t + 1] = dp[N][t];
            prev[N][t + 1] = prev[N][t];
        }
    }

    let mut dishes = BTreeSet::new();
    {
        let mut i = N;
        let mut t = T - 1;
        while let Some((j, u)) = prev[i][t] {
            dishes.insert(j);
            i = j;
            t = u;
        }
    }

    let mut max_b = 0;
    for i in 0..N {
        if !dishes.contains(&i) && max_b < B[i] {
            max_b = B[i];
        }
    }

    println!("{}", dp[N][T - 1] + max_b)
}


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

ll dp[1023][100001];
int w[1000000];
int v[1000000];

int main() {
  int n, q;
  cin >> n;
  rep(i, n) {
    cin >> v[i] >> w[i];
  }

  cin >> q;
  vector<P> query(q);
  int lmax = 0;
  rep(i, q) {
    cin >> query[i].first >> query[i].second;
    lmax = max( lmax, query[i].second);
  }
  lmax++;

  rep(i, lmax) {
    dp[0][i] = (i < w[0] ? 0 : v[0]);
  }

  for (int i=1; i<min(n, 1023); i++) {
    rep(j, lmax) {
      dp[i][j] = max( dp[(i-1)/2][j], (j < w[i] ? 0 : dp[(i-1)/2][j-w[i]] + v[i]) );
    }
  }

  rep(i, q) {
    int vid, l;
    vid = query[i].first - 1; l = query[i].second;

    if (vid < 1023) {
      cout << dp[vid][l] << endl;
    }

    else {
      vector<int> wt;
      int tsize = 0, tpow = 1;
      int vidt = vid;
      while (vidt >= 1023) {
        vidt = (vidt - 1) / 2;
        tsize++; tpow *= 2;
      }

      ll ans = 0;
      rep(j, tpow) {
        vidt = vid;
        ll vt = 0; int wt = 0;
        rep(k, tsize) {
          if ((j>>k) & 1) {
            vt += v[vidt]; wt += w[vidt];
          }
          vidt = (vidt - 1) / 2;
        }
        if (wt <= l) {
          ans = max( ans, vt + dp[vidt][l-wt] );
        }
      }
      cout << ans << endl;
    }
  }

/*  rep(i, min(n, 511)) {
    rep(j, 7) cout << dp[i][j] << " ";
    cout << endl;
  }*/

  return 0;
}

/*
*/


Measured memory_bytes: 805268
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int n;
ll ans=0;
cin >> n;
for(int i=0;i<n;i++){
    int z;
    cin >> z;
    ans+=z;
}
ans-=n;
cout << ans << endl;
}
 


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

int main(void)
{

    int amounts[3];
    
    cin >> amounts[0] >> amounts[1];
    amounts[2] = amounts[0] - amounts[1];
    
    if(amounts[2] <= 0){
        cout << 0 << endl;
    }
    else{
        cout << amounts[2] << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define hello777 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#include <string>
#define pie 3.14159265358979323846
constexpr int MOD = 1e9+7;
const int MAX= 1e5+5;
using namespace std;


//ll gcd(int a, int b)
//{ 
//    if (a == 0) 
//        return b;  
//    return gcd(b % a, a);  
// } 
// 
//ll lcm(int a, int b)  
// {  
//    return a/gcd(a, b) *b;  
// }
//  
//int prime(int n)
//{
//	rep(i,2,n+1)
//	{
//		if(n%i==0)return i;
//	}
//	
//vector<unordered_set<int> > prime_factors(MAX,unordered_set<int>());
//int primes[MAX];
//int prefix[MAX][6];
//void sieve(){
//    //primes i stores the largest prime factor of a number....
//    for(int i=2;i<MAX;++i){
//        if(primes[i]!=0){
//            continue;
//        }
//        primes[i] = i;
//        for(int j=2*i;j<MAX;j+=i){
//            primes[j] = i;
//        }
//    }
//    
//    for(int i=2;i<MAX;++i){
//        int current = i;
//        
//        while(current!=1){
//            prime_factors[i].insert(primes[current]);
//            current = current/primes[current];
//        }
//    }
//    
//    for(int i=1;i<MAX;++i){
//        for(int k=1;k<=5;++k){
//            prefix[i][k] = prefix[i-1][k] + (prime_factors[i].size()==k);
//        }
//    }
//    
//}
void solve() 
{
	int n;
	cin>>n;
	int t=0;
	while(t<n)
	{
		t+=1000;
	}
	int ans=t-n;
	cout<<ans<<endl;
}



int main()
{
	hello777;

	int q=1;
	
//    cin>>q;
    while(q--)
    {   
      solve();
    }
}

 

Measured memory_bytes: 3640
#include <stdio.h>

int prime(int);

int main()
{
  int num,in,t=0,i,j,judg;
  
  scanf("%d",&num);
  
  for(i = 0;i < num;i++)
    {
      scanf("%d",&in);
      judg = prime(in);
      if(judg == 1) t++;
    }

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

int prime(int num)
{
  int i;

  if(num <= 3 && num > 1) return 1;
  else if(num % 2 ==0 || num % 3 == 0) return 0;
  else for(i = 5;i * i <= num;i+=6)
	 {
	   if(num % i == 0 || num % (i + 2) == 0)
	     {
	       return 0;
	     }
	 }
  return 1;
}

  



Measured memory_bytes: 2144
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		if(n <= k) {
			System.out.println(x * n);
		} else {
			System.out.println(x * k + (n - k) * y);
		}

	}

}


Measured memory_bytes: 21844
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        s: chars
    }
    let mut ans = 0;
    for sub in s.windows(3) {
        if sub == &['A', 'B', 'C'] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


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

int main()
{
    int count = 0;
    string str1, str2;
    cin >> str1>>str2;
    for (int i = 0; i < 3; i++)
    {
        if (str1.at(i) == str2.at(i))
        {
            count++;
        }
    }
    
        cout << count << endl;

}

Measured memory_bytes: 256
h, n = [int(s) for s in input().strip().split()]
A, B = [], []
for _ in range(n):
    a, b = [int(s) for s in input().strip().split()]
    A.append(a)
    B.append(b)

dp = [0] + [float("inf")] * h
for a, b in zip(A, B):
    for i in range(1, h + 1):
        dp[i] = min(dp[i], b + dp[max(i - a, 0)])
print(dp[-1])

Measured memory_bytes: 48988
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := newIo()
	defer io.flush()

	n := io.nextInt()
	var fmHf, ltHf []int

	for i := 0; i < n; i++ {
		a := io.nextInt()
		if n%2 != i%2 {
			fmHf = append(fmHf, a)
		} else {
			ltHf = append(ltHf, a)
		}
	}

	for i := len(fmHf) - 1; i >= 0; i-- {
		io.print(fmHf[i], " ")
	}
	for i, v := range ltHf {
		if i != 0 {
			io.print(" ")
		}
		io.print(v)
	}
	io.println()
}

type io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func newIo() *io {
	return &io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *io) flush() {
	_ = io.writer.Flush()
}

func (io *io) nextLine() string {
	var buffer []byte
	for {
		line, isPrefix, _ := io.reader.ReadLine()
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *io) nextString() string {
	for io.nextToken >= len(io.tokens) {
		line := io.nextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *io) nextInt() int {
	i, _ := strconv.Atoi(io.nextString())
	return i
}

func (io *io) print(a ...interface{}) {
	fmt.Fprint(io.writer, a...)
}

func (io *io) println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *io) printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}


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

using namespace std;

typedef long long ll;

const int INF = (int) 1e9 + 1e6 + 123;
const ll LINF = (ll) 1e18 + 1e9 + 123;

#define rep(i, s, t) for (auto i = s; i < (t); ++i)
#define per(i, s, t) for (auto i = s; i >= (t); --i)
#define sz(x) ((int) (x).size())
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return 1;
    }
    return 0;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return 1;
    }
    return 0;
}

void run();

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    run();
    return 0;
}

const int N = (int) 1e5 + 123;

int n;
vector<int> g[N];
bool isb[N], need[N];
int dp[N];

void dfs(int v, int f = -1) {
    int deg = 0;
    int repr = -1;
    for (int u : g[v]) {
        if (u == f) continue;
        deg++;
        repr = u;
        dfs(u, v);
    }
    
    isb[v] = (deg == 0 || (deg == 1 && isb[repr]));
    if (isb[v]) {
        need[v] = 1;
        return;
    }
    
    int cnt = 0;
    int cnt2 = 0;
    
    for (int u : g[v]) {
        if (u == f) continue;
        if (isb[u]) {
            cnt++;
        } else {
            dp[v] += dp[u];
            cnt2++;
        }
    }
    
    need[v] = (cnt2 == 1 && cnt <= 1);
    dp[v] += max(0, cnt - 1);
}

void run() {
    cin >> n;
    rep(i, 0, n - 1) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    dfs(0);
    cout << dp[0] + need[0] << "\n";
}


Measured memory_bytes: 15232
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
using namespace std;

int main() {
	int A=1,B=0,C=0;
	char z;
	string s1,s2,s3;
	cin>>s1>>s2>>s3;
	
	z=s1[0];
	
	for(;;){
		
		if(z=='a'){
			if(A==s1.size()){
				cout<<'A'<<endl;
				return 0;
			}
			z=s1[A];
			A=A+1;
		}else if(z=='b'){
			if(B==s2.size()){
				cout<<'B'<<endl;
				return 0;
			}
			z=s2[B];
			B=B+1;
		}else if(z=='c'){
			if(C==s3.size()){
				cout<<'C'<<endl;
				return 0;
			}
			z=s3[C];
			C=C+1;
		}
		
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int r;

int main() {
    cin >> r;
    cout << 3*r*r << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <string>
#include <deque>
#define inf (long long int)(1e19)
#define pb push_back
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,ll> pll;
ll h,w,a,b;
ll factx[222222];
ll factxx[222222];
ll xxcal(ll n, ll x){
  if(x==1) return n;
  if(x==0) return 1;
  return x%2==0?xxcal((n*n)%mod,x/2):(n*xxcal(n,x-1)%mod);
}
ll cal(ll n,ll r){

  ll a=factx[n];
  a*=factxx[r];   a%=mod;
  a*=factxx[n-r]; a%=mod;
  //cout<<"("<<n<<","<<r<<")["<<a<<"]"<<endl;
  return a;
}
int main(void){
  ll x,y;
  cin>>h>>w>>a>>b;
  ll r=0;
  factx[0]=1;
  factxx[0]=xxcal(factx[0],mod-2);
  for(ll i=1;i<=h+w;i++){
    factx[i]=i*factx[i-1]%mod;
    factxx[i]=xxcal(factx[i],mod-2);
  }

  for(ll i=1;i<=w-b;i++){
    ll t=1;
    t*=cal(b+h-a-2+i,h-a-1);
    t%-mod;
    t*=cal(a+w-b-2-i+1,a-1);
    t%=mod;
    r+=t;
    r%=mod;
  }

  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
LL A[100000];
int main() {
	LL N;
	cin >> N;
	LL sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	LL a = N*(N + 1) / 2;
	if (sum%a) {
		cout << "NO" << endl;
		return 0;
	}
	LL k = sum / a;
	for (int i = 0; i < N; i++) {
		LL d = A[(i + 1) % N] - A[i];
		if (d > k || (k - d) % N) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

Measured memory_bytes: 1024
#include<cmath>
#include<vector>
#include<iostream>
#include<algorithm>
#define debug(ARGS) cout << #ARGS << ": " << ARGS << endl;
using namespace std;
int main(){
  int num = 0;

  while(cin >> num)
    if(num % 10 == 9 || num - (num % 10) == 90) cout << "Yes" << endl;
    else cout << "No" << endl;
  
  return 0;
}


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

int main(void){
  int n, i;
  cin >> n;
  if (n <= 9){
    cout << "Yes";
    return 0;
  }
  for (i=1; i<=9; ++i){
    if (n % i == 0){
      if (n/i <= 9){
        cout << "Yes";
        return 0;
      }
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int n=s.length();
    int num=0,ans=0;
    for(int i=0;i<n;i++){
    	if(s[i]=='S')num++;
    	else{
    		if(num>0){
    			ans+=2;
    			num--;
    		}
    	}
    }
    cout << n-ans<<endl;
    return 0;
}


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

int main(void){
	long long n, k;
	cin >> n >> k;
	long long ans = 0;
	for(int i = k+1; i <= n; ++i){
		ans += n - (k!=0?((n/i)*k-1):0) - min(n-n/i*i+1, k);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

LL ans = 0;

void solve(){
	ans = N + N*N + N*N*N;
}

int main(){
	cin >> N;

    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
int main(){
    vector<vector<int> >dp(1010,vector<int> (1010));
    int w,h;cin>>w>>h;
    REP(i,1,w+1)REP(j,1,h+1){
        char c;cin>>c;
        if(c=='.')dp[i][j]=1;
        else dp[i][j]=0;
    }
    dp[w][h]=1;
    for(int i=w;i>0;i--){
        for(int j=h;j>0;j--){
            if(i+j==w+h)continue;
            if(dp[i][j])dp[i][j]=(dp[i+1][j]+dp[i][j+1])%inf;
        }
    }
    cout<<dp[1][1]<<endl;
}

Measured memory_bytes: 4224
import sys
from operator import itemgetter
def input():
    return sys.stdin.readline()[:-1]
n = int(input())
a = [list(map(int, input().split())) for i in range(n)]
a.sort(key=itemgetter(1))
ans = "Yes"
k = 0
for i in range(len(a)):
    k += a[i][0]
    if k > a[i][1]:
        ans = "No"
        break
print(ans)

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
	int r, d, x;
	cin >> r >> d >> x;

	rep(i, 0, 10){
		x = r*x - d;
		cout << x << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
void show(int arr[],int n)
{
    for(int i = 0;i< n;i++)
    {
        cout<<arr[i];
        if(i<n-1)
            cout<<" ";
    }
    cout<<endl;
}
int selectionSort(int arr[],int n)
{
    int times = 0;
    for(int i = 0;i<n;i++)
    {
        int key = i;
        bool flag = 0;
        for(int j = i+1;j<n;j++)
            if(arr[j]<arr[key])
            {
                key = j;
                flag = 1;
            }
        if(flag)
        {
            swap(arr[key],arr[i]);
            times++;
        }
    }
    return times;
}

int main()
{
    int n;
    cin>>n;
    int *arr = new int[n+1];
    for(int i = 0;i<n;i++)
        cin>>arr[i];
    int times = selectionSort(arr,n);
    show(arr,n);
    cout<<times<<endl;
    return 0;
}



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

long long gcd(long long a, long long b) {

   	if(a < b) {
       swap(a, b);
   	}

	long long r = a % b;
	while(r != 0) {
		a = b;
		b = r;
		r = a % b;
	}

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

    ll N, X;
    cin >> N >> X;

    ll x;
    cin >> x;
    x = abs(x - X);
    ll g = x;

    for(int i = 1; i < N; i++) {
        cin >> x;
        x = abs(x - X);
        g = gcd(g, x);
    }

    cout << g << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void point_sort(int point_data[])
{

	int i, j, temp;

	for(i = 0; i < 9; i++) {
		for(j = i + 1; j < 10; j++) {
			if(point_data[i] < point_data[j]) {
				temp = point_data[i];
				point_data[i] = point_data[j];
				point_data[j] = temp;
			}
		}
	}

}

int main(void)
{

	int i;
	int W_college[10], K_college[10];

	for(i = 0; i < 20; i++) {
		if(i <= 9) {
			scanf("%d", &W_college[i]);
		}
		else {
			scanf("%d", &K_college[i - 10]);
		}
	}

	point_sort(W_college);
	point_sort(K_college);

	printf("%d %d\n", W_college[0] + W_college[1] + W_college[2], K_college[0] + K_college[1] + K_college[2]);

	return 0;

}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int ans, n,a,b,c,d;
string s;
void solve(){
    reads(s);
    if(s == "AC")a++;
    else if(s == "WA")b++;
    else if(s == "TLE")c++;
    else if(s == "RE")d++;
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",a,b,c,d);
}

Measured memory_bytes: 3848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

  int n;
  cin >> n;

  ll ans = (n - 2) * 180;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
N,K,Q = map(int,input().split())
A = {i: 0 for i in range(1,N+1)}
for i in range(Q):
    a = int(input())
    A[a] += 1
for v in A.values():
    if K-Q+v > 0:
        print('Yes')
    else:
        print('No')


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i=0; i<N; i++) {cin >> A[i]; A[i] -= i;}
  sort(A.begin(), A.end());
  long long ans = 0;
  int b = A[N/2];
  for (int i=0; i<N; i++) ans += abs(A[i]-b);
  cout << ans << endl;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""

A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    if X > Y :
        if A < 2 * C:
            ans = Y * C * 2 + abs(X-Y) * A
        else:
            ans = X * C * 2
    else:
        if B < 2 * C:
            ans = X * C * 2 + abs(X-Y) * B
        else:
            ans = Y * C * 2
else:
    ans = X * A + Y * B 
print(ans)

Measured memory_bytes: 3060
s = str(input())
n = len(s)
MOD = 10**9 + 7

res_dic = {}
for i in range(13):
    if (i*10)%13 in res_dic:
        res_dic[(i*10)%13].append(i)
    else:
        res_dic[(i*10)%13] = [i]
        
caseq_list = [[0 for j in range(13)] for i in range(10)]
for num in range(10):
    for j in range(13):
        k = (j - num)%13
        if k in res_dic:
            for m in res_dic[k]:
                caseq_list[num][j] = m
        
dp = [[0 for j in range(13)] for i in range(n+1)]    # i番目までの文字を読み込んだ時に13で割った余りがjになる数の個数
if s[0] == '?':
    for i in range(10):
        dp[1][i] =  1
else:
    num = ord(s[0]) - ord('0')
    dp[1][num] = 1

for i in range(1,n):
    c = s[i]
    if c == '?':
        for num in range(10):
            for j in range(13):
                dp[i+1][j] = (dp[i+1][j] + dp[i][caseq_list[num][j]]) % MOD
    else:
        num = ord(c) - ord('0')
        for j in range(13):
            dp[i+1][j] = (dp[i+1][j] + dp[i][caseq_list[num][j]]) % MOD
print(dp[n][5])

Measured memory_bytes: 66012