akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define pii pair<int , int>
#define _FastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAXX 105

int n , m , c;
int b[MAXX];
int a[MAXX][MAXX];
int d[MAXX][MAXX];

int main()
{
    _FastIO;
    cin >> n >> m >> c;
    for(int i = 1; i <= m; i++){
        cin >> b[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
            d[i][j] = d[i][j - 1] + a[i][j] * b[j];
            if(j == m && ((d[i][m] + c) > 0))
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;
 
public class Main {
	public static long twoCount(long a){
		long count = 0;
		while(a%2 == 0){
			a = a/2;
			count++;
		}
		return count;
	}

	private static long calcGcd(long m, long n) {
        if (m <= 0 || n <= 0) {
            throw new IllegalArgumentException("Arguments must be 1 and over.");
        }
        if(m < n) {
            long tmp = m;
            m = n;
            n = tmp;
        }
        long remainder = 0;
        while ((remainder = m % n) != 0) {
            m = n;
            n = remainder;
        }
        return n;
    }

    private static long calcLcm(long m, long n) {
        return m * n / calcGcd(m, n);
    }
	
	public static void main(String[] args) {
	Scanner s = new Scanner(System.in);
	int X = s.nextInt();
	
	
	

	if(X >= 30){
		System.out.println("Yes");
	}else{
		System.out.println("No");
	}
    
  }
}

Measured memory_bytes: 35736
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007ll
#define mod1 998244353ll
#define endl "\n"
#define inf (ll)1e18+1
using namespace std::chrono;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll h,w,n;
    cin>>h>>w>>n;
    ll maxi=max(h,w);
    ll ans=ceil(1.0*n/maxi);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  long long ans=0,k,a,b;
  scanf("%lld%lld%lld",&k,&a,&b);

  if((b-a)<=2){
    ans=k+1;
  }else if((k-a+1)%2==0){
    ans=(k-a+1)/2*(b-a)+a;
      }else{
    ans=(k-a)*(b-a)/2+a+1;
  }

  printf("%lld",ans);
}


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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
//const int MOD = 1e9+7;

int main(){
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    
    int d=0;
    for(int i=0; i<=n; ++i){
        string ts = s.substr(n-i);
        string tt = t.substr(0, i);

        if(ts == tt){
            d = i;
        }
    }
    cout << n+n-d;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int n;
vector<int> vec;
set<int> ign;

void _0to01(int l,int r){
	if(r - l == 1){
		vec.pb(l);
		return;
	}
	_0to01(l,r - 1);
	vec.pb(r - 1);
	_0to01(l,r - 1);
}

void _0to10(int num,int l){
	if(l == n - 1){
		vec.pb(l);
		return;
	}
	_0to10(1,l + 1);
	vec.pb(l);
	if(num == 1){
		_0to10(1,l + 1);
		return;
	}
	vec.pb(l + 1);
	_0to01(l + 2,n);
	vec.pb(l + 1);
	ign.insert(vec.size());
	_0to10(num - 2,l + 2);
}

int flip(int x,int pos){
	if((x >> pos) & 1) x -= (1 << pos);
	else x += (1 << pos);
	return x;
}

signed main(){
	int a,b,cnt = 0;
	cin >> n >> a >> b;
	for(int i = 0;i < n;i++){
		if(((a >> i) & 1) != ((b >> i) & 1)) cnt++;
	}
	if(cnt % 2 == 0) NO();
	else{
		YES();
		_0to10(cnt,0);
		int x = 0,y = cnt,wari[20];
		for(int i = 0;i < n;i++){
			if(((a >> i) & 1) != ((b >> i) & 1)){
				wari[x++] = i;
			}else{
				wari[y++] = i;
			}
		}
		int tmp = a;
		cout << a;
		for(int i = 0;i < vec.size();i++){
			int v = vec[i];
			if(!ign.count(i)){
				tmp = flip(tmp,wari[v]);
				cout << " " << tmp;
				//cout << " " << v;
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 2420
#include <stdio.h>

int main(){
	char num[1000]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int K;
	
	scanf("%d",&K);
	int ans = num[K-1];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // ll K, X; cin >> K >> X;
  // cout << (K*500 >= X ? "Yes" : "No") << endl;

  int N;
  cin >> N;
  vector<int> P(N); rep(i, N) cin >> P[i];
  vector<int> Q(N); rep(i, N) cin >> Q[i];
  vector<int> R(N); rep(i, N) R[i] = i + 1;
  int x, y;
  int i = 0;
  do {
    if (R == P) x = i;
    if (R == Q) y = i;
    i++;
  } while (next_permutation(range(R)));
  cout << abs(x - y) << endl;
}


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

using namespace std;
 

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<long long,long long>> c(m);
    map<string,int> e;
    vector<pair<long long,long long>> d(m); //pとyを保持
    map<long long,int> r;
    map<long long,int> q;
    for(int i=0;i<m;i++){
        long long p,y;
        cin >> p >> y;
        string t=to_string(p);
        r[p]=t.length();
        d[i].second=p;
        d[i].first=y;
        c[i].second=p;
        c[i].first=y;
    }
    sort(d.begin(),d.end());
    for(int i=0;i<m;i++){
        int s=++q[d[i].second];
        string t=to_string(d[i].second);
        string u=to_string(d[i].first);
        e[t+u]=s;
    }
    for(int i=0;i<m;i++){
        for(int j=0;j<6-r[c[i].second];j++){
            cout << 0;
        }
        string t=to_string(c[i].second);
        string u=to_string(c[i].first);
        int s=e[t+u];
        cout << c[i].second*1000000+s<< endl;
    }
}

Measured memory_bytes: 28032
// G - Longest Path
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define rep(i,n) for(int i=0;i<(n);++i)
#define chmax(x,y) x=max(x,y)
int in(){int x;cin>>x;return x;}

vvi edges; // [parent vertex][children vertex]
vi dp; // [vertex]: longest path from this vertex (memo of dfs)

int dfs(int p){
	if(0 <= dp[p]) return dp[p]; // already visited
	dp[p] = 0;
	for(int c:edges[p]) chmax(dp[p], dfs(c)+1);
	return dp[p];
}

int main(){
	int N; // number of vertices
	int M; // number of edges
	cin>>N>>M;

	edges.resize(N);
	rep(i, M) edges[in()-1].push_back(in()-1);

	int ans = 0;
	dp.resize(N);
	rep(i, N) dp[i] = -1;
	rep(p, N) chmax(ans, dfs(p));
	cout<< ans <<endl;

	// // print ===================
	// cout<<"ans "<<ans<<"\n";//
	// rep(p,N){
	// 	cout<<"["<<dp[p]<<"] "<<p<<":";
	// 	for(int c:edges[p])cout<<" "<<c;
	// 	puts("");
	// }
	// // ===================

}


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

using namespace std;

#define sq(a) ((a) * (a))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define what_is(x) cerr << fixed << setprecision(2) << #x << " = " << x << endl
#define setbitj(n, j) (n |= (1 << (j)))
#define isbitjOn(n, j) (((n & (1 << (j))) > 0) ? 1 : 0)
#define safeMod(a, m) ((((a)%(m))+(m))%(m))/*handling negative sign of remainder*/

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vii;

const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int MAX = 100005;
const int MOD = 1000000007;

inline bool isEq(double a, double b){return abs(a - b) < EPS;}
inline double toRad(double deg){return deg*PI/180;}
inline double toDeg(double rad){return rad*180/PI;}

inline int geti(int &_int){return scanf("%d", &_int);}
inline int getii(int &_int, int &_int2){return scanf("%d %d", &_int, &_int2);}
inline int getiii(int &_int, int &_int2, int &_int3){return scanf("%d %d %d", &_int, &_int2, &_int3);}

inline int getl(ll &_ll){return scanf("%lld", &_ll);}
inline int getll(ll &_ll, ll &_ll2){return scanf("%lld %lld", &_ll, &_ll2);}
inline int getlll(ll &_ll, ll &_ll2, ll &_ll3){return scanf("%lld %lld %lld", &_ll, &_ll2, &_ll3);}

inline int getd(double &_double){return scanf("%lf", &_double);}
inline int getdd(double &_double, double &_double2){return scanf("%lf %lf", &_double, &_double2);}

inline int getstr(char *str){return scanf("%s", str);}

//#define isValid(a, b) (a >= 0 && a < b)
//int dr[]  =  {0, -1, -1, -1,  0,  1, 1, 1};
//int dc[]  =  {1,  1,  0, -1, -1, -1, 0, 1};

int main(int argc, char* argv[])
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    //ios_base::sync_with_stdio(false); cin.tie(NULL);
    int k, ara[MAX];
    geti(k);
    for(int i = 0; i < k; i++)
        geti(ara[i]);
    ll low, high;
    ll l = 0, h = 1e18, mid;
    while(l <= h){
        mid = (l+h)/2;
        ll n = mid;
        for(int i = 0; i < k; i++){n=(n/ara[i])*ara[i];}
        if(n >= 2){
            h = mid-1;
            low = mid;
        }
        else
            l = mid+1;
    }
    l = 0;
    h = 1e18;
    while(l <= h){
        mid = (l+h)/2;
        ll n = mid;
        for(int i = 0; i < k; i++){n=(n/ara[i])*ara[i];}
        if(n <= 2){
            l = mid+1;
            high = mid;
        }
        else
            h = mid-1;
    }
    if(low <= high)
        printf("%lld %lld\n", low, high);
    else
        printf("-1\n");
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int n, count=0;
  int a[100000];
  scanf("%d",&n);
  for(int i = 0; i < n; i++){
    scanf("%d",&(a[i]));
    a[i] = a[i]%2;
    if(a[i]==1){
      count += 1;
    }
  }

  if(count % 2 == 1){
    printf("NO\n");
  }else{
    printf("YES\n");
  }


  return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;
vector<int> nums;
int numofnum;
int mequal;
long long int memo[21][100];

int main() {

	cin >> numofnum;

	numofnum--;

	nums = vector<int>(numofnum);

	for (int i = 0; i < numofnum; i++) {
		cin >> nums[i];
	}
	cin >> mequal;

	for (int i = nums.size() - 1 ; i >= 0; i--) {
		for (int j = 0; j < 21; j++) {
			memo[j][i] = 0;
			if (i == nums.size() - 1) {
				if ((j - nums[i]) == mequal) memo[j][i]++;
				if ((j + nums[i]) == mequal) memo[j][i]++;
			}
			else {
				if (!((i == 0) && (nums[i] == 0))) {
					if ((j - nums[i]) >= 0) memo[j][i] += memo[j - nums[i]][i + 1];
					if ((j + nums[i]) <= 20) memo[j][i] += memo[j + nums[i]][i + 1];
				}
				else{
					memo[j][i] += memo[j - nums[i]][i + 1];
				}
			}
		}
	}

	cout << memo[0][0] << endl;
	return 0;
}


Measured memory_bytes: 3136
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
pin=a[0]
cnt=1
x=[]
for i in range(1,n):
  if a[i]==pin and i!=(n-1):
    cnt+=1
  elif a[i]!=pin:
    if cnt>=4:
      x+=[pin]
      x+=[pin]
    elif cnt>=2:
      x+=[pin]
    if len(x)>=2:
      break
    pin=a[i]
    cnt=1
  
  elif i==(n-1):
    if pin==a[i]:
      cnt+=1
    if cnt>=4:
      x+=[pin]
      x+=[pin]
    elif cnt>=2:
      x+=[pin]
    if len(x)>=2:
      break
    pin=a[i]
    cnt=1

    
if len(x)<=1:
  print(0)
else:
  print(x[0]*x[1])


Measured memory_bytes: 85288
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur =  nil->next;
  while (cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  if (t == nil)
    return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  deleteNode(nil->prev);
}

void delete(int key){
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32988
#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;

int main() {
    string s;
    cin >> s;
    string substr[10];
    int digit[10];
    for(int i = 0; i < s.length(); i++){
        substr[i] = s.substr(i,1);
        digit[i] = stoi(substr[i]);
    }
    int ans = -1;
    int sum;
    for(int i = 0; i < s.length() - 2; i++){
        sum = abs((digit[i]*100 + digit[i+1]*10 + digit[i+2]) - 753);
        if(ans == -1 || ans > sum)
            ans = sum;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;



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

	int N;
	ll T;
	cin >> N >> T;
	vector<ll> t(N);
	REP(i, N) cin >> t[i];
	ll res = T;
	REP(i, N - 1) res += min(t[i + 1] - t[i], T);
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

int main(int argc, char **argv)
{
    int A, B, C;
    std::cin >> A >> B >> C;

    for(int i = 1; i <= 100; i++){
        if(A * i % B == C){
            std::cout << "YES" << std::endl;
            return 0;
        }
    }
    std::cout << "NO" << std::endl;
}


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

using namespace std;

#define ll long long

ll gcd(ll a, ll b){
	return b==0?a:gcd(b,a%b);
}

ll lcm(ll a, ll b){
	return a*b/gcd(a,b);
}

int main(){
	int n;
	while(cin >> n && n){
		vector<pair<int,int> > v(n);
		vector<ll> cand;
		ll l=1;
		ll g;
		for(int i=0;i<n;i++){
			cin >> v[i].first >> v[i].second;
			l = lcm(l, v[i].first);
		}
		for(int i=0;i<n;i++){
			cand.push_back(l / v[i].first * v[i].second);
		}
		g = cand[0];
		for(int i=1;i<n;i++){
			g = gcd(g, cand[i]);
		}
		for(int i=0;i<n;i++){
			cout << cand[i] / g << endl;
		}
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(){
  long long A,B,C;
  scanf("%lld %lld %lld",&A,&B,&C);
  long long t = min(A,C);
  A-=t;
  C-=t;
  t = min(B,C);
  B-=t;
  printf("%lld %lld",A,B);
}

Measured memory_bytes: 128
s = int(input())

a = [s]
i = 0
tmp_fn = s
while True:
    if tmp_fn % 2 == 1:
        tmp_fn = a[i] * 3 + 1
        a.append(tmp_fn)
    else:
        tmp_fn = a[i] / 2
        a.append(tmp_fn)
    count = 0
    for j in range(len(a)):
        if a[j] == tmp_fn:
            count += 1
            if count == 2:
                print(j + 1)
                exit(0)
    i += 1


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,max=0,sum=0;
  cin>>n;
  vector<int> a(n,0);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    if(max<a[i]) max=a[i];
  }
  for(int i=0;i<n;i++){
    if(max==a[i]){
      a[i]=0;
      break;
    }
  }
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  if(sum>max) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    int n,m;
    cin >> n >> m;
    vector<int> a(n,0);
    double sum = 0;
    rep(i,n){
        cin >> a.at(i);
        sum += a.at(i);
    }
    sum = sum/(4*m);
    sort(a.begin(),a.end(),greater<int>());
    if(a[m-1] < sum)cout << "No\n";
    else cout << "Yes\n";
    
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const ll M=2e6+6;
ll a[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll k,n;
	cin>>k>>n;
	for(ll i=0;i<n;i++)
		cin>>a[i];
	std::vector<ll> v;
	for(ll i=0;i<n;i++)
	{
		if(i+1<n)
			v.pb(a[i+1]-a[i]);
		else
			v.pb(k-a[i]+a[0]);
	}
	ll s=0;
	ll mx=0;
	for(auto u:v)
	{
		s+=u;
		mx=max(mx,u);
	}
	cout<<s-mx<<"\n";
	return 0;
}

Measured memory_bytes: 3956
S=input()
if int(S[:4])<2019:
  print('Heisei')
elif int(S[:4])==2019 and int(S[5:7])<4:
  print('Heisei')
elif int(S[:4])==2019 and int(S[5:7])==4 and int(S[8:10])<=30:
  print('Heisei')
else:
  print('TBD')

Measured memory_bytes: 9136
package main

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

const INF = 1000000000000

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	s.Scan()
	k, _ := strconv.Atoi(s.Text())

	h := make([]int, n+1)
	for i := 0; i < n; i++ {
		s.Scan()
		h[i], _ = strconv.Atoi(s.Text())
	}

	dp := make([]int, n+1)
	for i := range dp {
		dp[i] = INF
	}

	dp[0] = 0
	for i := 0; i < n; i++ {
		for j := 1; j <= k && i+j < n; j++ {
			dp[i+j] = min(dp[i+j], abs(h[i+j]-h[i])+dp[i])
		}
	}

	fmt.Println(dp[n-1])
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
#define long long long
template<class T> inline signed size(const T& t) { return t.size(); }

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

    int N; cin >> N;
    vector<long> A(N); for(int l = 0; l < N; l++) cin >> A[l];
    vector<long> vs;
    unordered_map<long, int> vm;
    {
        set<long> s0 = {0};
        for(int l = 0, l_M = size(A); l < l_M; l++) s0.insert(A[l]);
        for(auto& sv0: s0) vs.push_back(sv0);
        for(int l = 0, l_M = size(s0); l < l_M; l++) vm[vs[l]] = l;
    }

    int s = size(vs);
    vector<int> g(s);
    for(int i = 0; i < N; i++) g[vm[A[i]]]++;
    for(int j = s-1-1; j >= 0; j--) g[j] += g[j+1];
    if(0) { //dbg
        for(int l = 0, l_M = size(vs); l < l_M; l++) cout << (l ? " " : "") << vs[l];
        cout << '\n';
        for(int l = 0, l_M = size(g); l < l_M; l++) cout << (l ? " " : "") << g[l];
        cout << '\n';
    }

    long now = 0;
    for(int i = 0; i < N; i++) {
        if(A[i] <= now) {
            cout << 0 << '\n';
        } else {
            long a = 0;
            for(int k = vm[now]+1; k <= vm[A[i]]; k++) {
                a += g[k] * (vs[k] - vs[k-1]);
                if(0) { //dbg
                    cout << k << ' ' << a << '\n';
                }
            }
            cout << a << '\n';
            now = A[i];
        }
    }
    return 0;
}


Measured memory_bytes: 11512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, x;
  cin >> a >> b >> x;
  ll ans = b/x+1;
  if (a)
    ans -= (a-1)/x+1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
 
using namespace std;
 
int main(){
    long long N,H;
    cin>>N>>H;
    vector <long long>a(N);
    vector <long long>b(N);
    for(int i=0 ; i<N ; i++){
        cin>>a[i];
        cin>>b[i];
    }
    long long ans=0;
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(long long i=N-1 ; i>=0 ; i--){
        if(a[N-1]<=b[i] && H>0){
           H-=b[i];
           ans+=1;
        }
    }
    if(H>0){
    	ans+=(long long)H/a[N-1];
        if(H%a[N-1]!=0)ans+=1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
d = 10 ** 9 + 7
n = int(input())

a = list(map(int,input().split()))


s = 0
for i in range(n):
    s += a[i]
    s %= d

ans = 0

b = 0
for i in range(n):
    b += a[i] ** 2
    b %= d

ans = s ** 2 - b
ans %= d

if ans % 2 == 0:
    ans //= 2
else:
    ans += d
    ans //= 2

print(ans)


Measured memory_bytes: 30824
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int MAXN = 100000+9;
int n;
int A[MAXN],B[MAXN],C[MAXN];
int b[MAXN*3];
int len;
long long ans;
int tmp;

class BIT{
	private:
		int tree[MAXN*3];
		int lowbit(int x){
			return x&(-x);
		}
	public:
		void add(int pos,int v){
			for(int i=pos;i<=len;i+=lowbit(i))
				tree[i]+=v;
		}

		int getsum(int pos){
			int re=0;
			for(int i=pos;i;i-=lowbit(i))
				re+=tree[i];
			return re;
		}
}bit1,bit2;

void solve(){
	sort(b+1,b+tmp+1);
	len=unique(b+n,b+tmp+1)-(b+1);
	for(int i=1;i<=n;i++){
		A[i]=lower_bound(b+1,b+len+1,A[i])-b;
		B[i]=lower_bound(b+1,b+len+1,B[i])-b;
		C[i]=lower_bound(b+1,b+len+1,C[i])-b;
	}
	for(int i=1;i<=n;i++){
		bit1.add(A[i],1);
		bit2.add(C[i],1);
	}
	for(int i=1;i<=n;i++){
		int val1=bit1.getsum(B[i]-1);
		int val2=(n-bit2.getsum(B[i]));
		ans+=1LL*val1*val2;
		//printf("%d %d\n",val1,val2);
	}
	printf("%lld\n",ans);
}

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&A[i]);
		b[++tmp]=A[i];
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&B[i]);
		b[++tmp]=B[i];
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&C[i]);
		b[++tmp]=C[i];
	}
	solve();
	return 0;
}


Measured memory_bytes: 4864
#include<cstdio>
#include<algorithm>
#include<set>
using namespace std;
int n, res;
multiset<int>Set;
int main() {
	int i, a;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		Set.insert(a);
	}
	while (!Set.empty()) {
		auto it = Set.end();
		it--;
		int x = *it;
		Set.erase(it);
		for (i = 1; i <= x; i *= 2);
		if (Set.find(i-x) != Set.end()) {
			Set.erase(Set.find(i - x));
			res++;
		}
	}
	printf("%d\n", res);
}

Measured memory_bytes: 9600
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int H, W;

		while (true) {
			H = sc.nextInt();
			W = sc.nextInt();
			if (H == 0 && W == 0) {
				break;
			}
			for (int i = 0; i < H; i++) {
				for (int j = 0; j < W; j++) {
					if ((i + j) % 2 == 0) {
						System.out.print("#");
					} else {
						System.out.print(".");
					}
				}
				System.out.println();
			}
			System.out.println();
		}

	}
}


Measured memory_bytes: 35312
# -*- coding: utf-8 -*-
"""
Created on Sat Aug 15 17:00:46 2020

@author: saito
"""

# %% import phase

# %% define phase

# %% input phase
x, k, d = list(map(int, input().split()))

# %% process phase
xabs = abs(x)
if k*d <= xabs:
    ans = xabs-k*d
else:
    innum = xabs // d
    if (k - innum)%2 == 0:
        ans = xabs%d
    else:
        ans = d - xabs%d


# %%output phase
print(ans)

Measured memory_bytes: 9184
while True:
    N = int(input())
    if N == 0:
        break
    air = [input() for _ in range(N)]
    codes = [''.join(x for i, x in enumerate(s) if i == 0 or s[i-1] in 'aiueo') for s in air]
    if len(set(codes)) != N:
        print(-1)
        continue
    max_len = max(len(x) for x in codes)
    for k in range(1, max_len + 1):
        if len(set(x[:k] for x in codes)) == N:
            print(k)
            break

Measured memory_bytes: 7644
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF=10**9

def dfs(cur, a, b, c):
	if cur == N:
		return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
	ret0 = dfs(cur + 1, a, b, c)
	ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
	ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
	ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
	return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
require 'time'

def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end

def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def yn(f) return (f)? "Yes": "No" end

def ynb(f) return (f)? "YES": "NO" end

def ap(a) a.each{|u| p u} end

def bit(n) n.to_s(2).split("").map(&:to_i) end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

a = inp[0]#k,f = inp
s = inps[0]
puts (a < 3200)? "red" : s
#puts ()? "Yes" : "No"
#puts ()? "YES" : "NO"
#puts ()? "yes" : "no"

Measured memory_bytes: 2168
import java.util.*;

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

		while (sc.hasNext()) {
			String data = sc.nextLine();

			List<Integer> list = new ArrayList<>();
	 		for (String s : data.split("\\s+")) {
				list.add(Integer.parseInt(s));
			}

			int sum = 0;
			for (int x : list) sum += x;

			if (sum >= 22)
	        	System.out.println("bust");
			else
				System.out.println("win");
		}
	}
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int q;
int main(){
	cin>>q;
	long long a ,b;
	long long tong;
	while(q--){
		cin>>a>>b;
		long long product=a*b;
		long long t=sqrt(product);
		if(t*(t+1)<product){
			cout<<2*t-1<<endl;
		}
	else if(t * t == product)
		{
			if(a != b)
				cout<< (t - 1) * 2-1<<endl;
			else
				cout<<(t - 1) * 2 <<endl;
		}
		else
		 cout<< (t-1)*2<<endl;
}
}


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

int main() {
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdint.h>

#define RBUF 10
#define MBUF (100000)
#define NBUF (205)
#define INF (1<<29)


int N, M, R;

int r[RBUF];

typedef struct
{
	int from;
	int to;
	int cost;
} SIDES;

SIDES sides[MBUF];

void input(void)
{
	scanf("%d %d %d", &N, &M, &R);	
	int i = 0;
	for(i=0;i<R;i++)scanf("%d",&r[i]);
	for (i = 0; i < M; i++)
	{
		scanf("%d %d %d", &sides[i].from, &sides[i].to, &sides[i].cost);
	}
}

int dp[NBUF][NBUF];

int min(int a, int b)
{
	if (a > b)
		return b;
	return a;
}

void dp_init(void)
{
	
	//init
	int i = 0,j;
	for(i=0;i<NBUF;i++){
		for(j=0;j<NBUF;j++){
			dp[i][j] = INF;
		}		
	}
		
	for (i = 0; i < M; i++)
	{
		dp[sides[i].from][sides[i].to] = sides[i].cost;
		dp[sides[i].to][sides[i].from] = sides[i].cost;
	}
	for (i = 0; i < NBUF; i++)
	{
		dp[i][i] = 0;
	}
}

void solve_wf(void)
{
#ifdef DEBUG
	printf("%d,%d,%d",N,R,M);
	printf("%d,%d,%d",r[0],r[1],r[2]);
	int l=0;
	for(l=0;l<NBUF;l++){
		printf("dp%d: %d\r\n",l ,dp[l][l]);
	}
#endif
	int i, j, k;
	//solve
	for (k = 1; k < N+1; k++)
	{
		for (i = 1; i < N+1; i++)
		{
			for (j = 1; j < N+1; j++)
			{
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
}
void show_dp(void)
{
	int i, j;
	//solve
	for (i = 0; i < N+1; i++)
	{
		for (j = 0; j < N+1; j++)
		{
			printf("dp %d,%d : %d\r\n",i,j,dp[i][j]);
		}
	}
}
bool used[RBUF];
int res;

void dfs(int c, int las, int dist){
	if(c==R+1){
		if(res>dist)res = dist;
		return;
	}

	for(int i=0;i<=R;i++){
		if(!used[i]){
			used[i]= true;
			if(las==-1)dfs(c+1,i,0);
			else dfs(c+1,i,dist+dp[r[las]][r[i]]);
			used[i] = false;
		}
	}
}

int main(void)
{
	input();
	dp_init();
	solve_wf();
#ifdef DEBUG
	show_dp();
#endif
	int i=0;
	for(i=0;i<RBUF;i++){
		used[i]=false;
	}
	res = INF;
	dfs(1,-1,0);	
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>

typedef unsigned long long ull;


bool check(ull middle, std::vector<ull>& A, std::vector<ull>& B, ull k, ull n, ull m)
{
	ull time = 4294967295;
	for (ull i = 0; i <= n; i++)
	{
		if (middle - i <= m)
			time = std::min(time, A[i] + B[middle - i]);
		if (time <= k)
			return true;
	}
	if (time > k)
		return false;
	return true;
}

int main()
{
	ull n, m, k;
	std::cin >> n >> m >> k;
	std::vector<ull> A(n + 1);
	std::vector<ull> B(m + 1);
	A[0] = 0;
	B[0] = 0;
	for (int i = 1; i < n + 1; i++)
	{
		ull a;
		std::cin >> a;
		A[i] = a + A[i - 1];
	}
	for (int i = 1; i < m + 1; i++)
	{
		ull b;
		std::cin >> b;
		B[i] = b + B[i - 1];
	}
	ull bottom = 0;
	ull top = m + n;
	while (bottom + 1 < top)
	{
		ull middle = (bottom + top) / 2;
		if (check(middle, A, B, k, n, m))
			bottom = middle;
		else
			top = middle; 
	}
	if (check(top, A, B, k, n, m))
		std::cout << top << '\n';
	else
		std::cout << bottom << '\n';
	return 0;
}

Measured memory_bytes: 6416
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vi a;

int f(int x){
	int res=x;
	vi b=a;
	b[0]=max(b[0]-x,0);
	for(int i=1;i<n;i++){
		res+=2*b[i-1];
		b[i]=max(b[i]-b[i-1],0);
	}
	return res+b[n-1];
}

int main(){
	cin>>n;
	a=vi(n);
	for(int i=0;i<n;i++) cin>>a[i];
	cout<<min({f(0),f(1),f(2),f(3)})<<endl;
}

Measured memory_bytes: 3184
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
      	int ans;
    
     if (a > 9) {
       ans = -1;
     } else if (b > 9) {
       ans = -1;
     } else {
       ans = a * b;
     }
     
      System.out.println(ans);
    }
}
       

Measured memory_bytes: 22740
package main

import "fmt"

func main() {
	// Code for B - Small and Large Integers
	var A, B, K int
	fmt.Scanf("%d %d %d", &A, &B, &K)

	for i := A; i <= B; i++ {
		if i < A+K || B-K < i {
			fmt.Println(i)
		}
	}
}


Measured memory_bytes: 1860
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

int gcd(int a,int b){
	if(a < b) swap(a,b);
	if(!b) return a;
	return gcd(b,a % b);
}

signed main(){
	int n,x,g;
	cin >> n >> x;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		if(!i) g = abs(a - x);
		else g = gcd(g,abs(a - x));
	}
	cout << g << endl;
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;

int main(){
    int n;
    cin >> n;
    vector<int> v(4);
    for (int i = 3; i >= 0; --i) {
        v[i] = n % 10;
        n /= 10;
    }

    for (int i = 0; i < (1<<3); ++i) {
        int tmp = v[0];
        for (int j = 0; j < 3; ++j) {
            if(i & (1<<j)){
                tmp += v[j+1];
            }
            else{
                tmp -= v[j+1];
            }
        }
        if(tmp == 7){
            cout << v[0];
            for (int j = 0; j < 3; ++j) {
                if(i & (1<<j)) cout << '+';
                else cout << '-';
                cout << v[j+1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const LL MAX = 1e9 + 1;

int main() {

    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    vector<pair<LL, LL>> v;
    for(int i = 0; i < N; i++){
        LL a, b;
        scanf("%lld %lld", &a, &b);
        v.push_back(make_pair(b, a));
    }
    
    // 2. 〆切の時刻で, 昇順sort.
    sort(v.begin(), v.end());
    
    // 3. 区間をマージしていく.
    // [入力例]
    // ※〆切の時刻で, 昇順sort済.
    // 5
    // 2 4
    // 1 8
    // 1 9
    // 4 9
    // 3 12
    // -> 具体的には, 以下のような処理を想定.
    // 仕事1 => [2, 4]  … 開始時刻: 2, 終了時刻: 4
    // 仕事2 => [1, 4]  … 開始時刻: 1, 終了時刻: 4
    // 仕事3 => [0, 4]  … 開始時刻: 0, 終了時刻: 4
    // 仕事4 => [0, 8]  … 開始時刻: 0, 終了時刻: 8
    // 仕事5 => [0, 11] … 開始時刻: 0, 終了時刻: 11
    bool ans = true;
    LL l = v[0].first - v[0].second, r = v[0].first;
    // printf("[%lld, %lld]\n", l, r);
    // sub1_07.txt, sub1_09.txt, sub1_27.txt, sub1_28.txt で, 
    // WA版となった理由 と 推定し, ロジック追加.
    if(l < 0) ans = false; 

    for(int i = 1; i < N; i++){
        // 以下の条件で, 区間更新.
        LL a = v[i].second, b = v[i].first;
        
        // 3-1. 最小時刻が, ゼロの場合.
        if(l == 0) r += a;
        
        // 3-2. 最小時刻 が 0より大きく, かつ, 仕事にかかる時間が, 最小時刻 より 大きい場合.
        if(l > 0 && l < a) r += (a - l), l = 0;
        
        // 3-3. 最小時刻 が, 仕事にかかる時間以上に大きい場合.
        if(l >= a) l -= a;
        
        // 3-4. 仕事が〆切までに終了しているかチェック.
        // printf("[%lld, %lld]\n", l, r);
        if(r > b){
            ans = false;
            break;
        }
    }
    
    // 4. 後処理.
    if(ans) printf("%s\n", "Yes");
    else    printf("%s\n",  "No");
    return 0;

}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) (find(all(v),x)!=v.end())
#define incls(s,c) (s.find(c)!=string::npos)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(all(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; cin >> x; return x;}
inline ll lin() { ll x; cin >> x; return x;}
inline char chin() { char x; cin >> x; return x;}
inline string stin() { string x; cin >> x; return x;}
inline double din() { double x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int t1 = h1*60 + m1;
  int t2 = h2*60 + m2;
  int dt = t2 - t1;
  cout << dt - k << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

typedef long long ll;

#define rep(i, a, n) for (ll i = a; i < (ll)n; ++i)
#define repd(i, n) for (ll i = (n)-1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

using namespace std;

int main(void)
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    int x, a;
    cin >> x >> a;
    if (x < a)
        cout << 0 << endl;
    else
        cout << 10 << endl;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
#define mod 1000000007
ll t,n,m,i,j,k,l,arr[sz],brr[sz],crr[sz];
vector<ll>v;
int main()
{
    scanf("%lld",&t);
    k=t;
    while(t--)
    {
      scanf("%lld",&n);
      v.push_back(n);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    t=2;
    for(i=1;i<v.size() && t<k;i++)
    {
        t++;
        m+=v[i];
        if(t<k)
        {
            m+=v[i];
            t++;
        }
    }
    printf("%lld\n",m+v[0]);
    return 0;
}



Measured memory_bytes: 5412
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

long  a[100005];
long  s[100005];

int main(int argc, char* argv[])
{
    long n,cc;
    scanf("%ld%ld", &n, &cc); 

    vector<vector<pair<long, long> > > x(cc);

    long i;
    for(i=0; i<n; i++) {
        long s,t,c;
        scanf("%ld%ld%ld", &s, &t, &c);
        x[c-1].push_back( make_pair(s,t) );
    }
    
    long j;
    for(i=0; i<cc; i++) {
        sort(x[i].begin(), x[i].end());
        long nSize=(long)x[i].size();
        for(j=1; j<nSize; j++) {
            if(x[i][j-1].second==x[i][j].first) {
                x[i][j].first ++;
            }
        }

        for(j=0; j<nSize; j++) {
            a[x[i][j].first]++;
            a[x[i][j].second+1]--;
        }
    }

    s[0]=0;
    long max=0;
    for(i=1; i<100004; i++) {
        s[i] = s[i-1] + a[i-1];
        if(s[i]>max)
            max=s[i];
    }
    printf("%ld\n", max);
 
    return 0;
}


Measured memory_bytes: 4224
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define nl "\n"
#define fout(x) fixed<<setprecision(x)
#define one(x) __builtin_popcount(x)
#define F first
#define S second

const int MOD=1e9+7;
const double EPS=1e-9;
const double PI=acos(-1.0);

ll qpow(ll n,ll k){ll ans=1;assert(k>=0);n%=MOD;while(k>0){if(k&1)ans=(ans*n)%MOD;n=(n*n)%MOD;k>>=1;}return ans%MOD;}

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << fout(10)<<x;}
void __print(double x) {cerr << fout(10)<<x;}
void __print(long double x) {cerr << fout(10)<<x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

// ****************************************************



int main()
{
    int n;
    cin>>n;
    vector<int>v(n, 0);
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        v[i]=x;
    }
    sort(v.begin(), v.end());
    int ans=0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            int t=v[i]+v[j];
            int p1=upper_bound(v.begin(), v.end(), t-1)-v.begin();
            p1--;
            int p2=upper_bound(v.begin(), v.end(), abs(v[i]-v[j]))-v.begin();
            p1=min(p1, n-1);
           // debug(p2, p1);
           // debug(i, j);
            if(i<p2)
            {
                p2=max(p2, j+1);
                if(p1-p2+1>0)
                    ans+=(p1-p2+1);
                //debug(p1-p2+1, "a");
            }
            else if(i>=p2 && i<=p1)
            {
               // ans+=(i-p2);
                int tt=(p1-j);
                //debug(tt, "b");
                if(tt>0) ans+=tt;
            }
            else
            {
                ans+=(p1-p2+1);
               // debug(p1-p2+1, "c");
            }
            //debug(ans);
        }
    }
    cout<<ans<<nl;
    return 0;
}


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;

  int c = 0;
  vector<int> sum(N);
  sum[0] = 0;
  for (int i = 1; i < N; i++)
  {
    if (S[i - 1] == 'A' && S[i] == 'C')
    {
      c++;
    }
    sum[i] = c;
  }

  rep(i, Q)
  {
    int l, r;
    cin >> l >> r;
    l--;
    r--;

    int c;
    if (l == 0)
      c = sum[r];
    else
    {
      c = sum[r] - sum[l];
    }
    cout << c << endl;
  }

  return 0;
}


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

int n;

int main()
{
    cin >> n;
    int lb = 0;
    cout << lb << "\n";
    string ls;
    cin >> ls;
    int ub = n;
    string s;
    int cnt = 0;
    while(ls != "Vacant" && cnt <= 100000)
    {
        int mid = (ub + lb) / 2;
        cout << mid << "\n";
        cin >> s;
        if((mid - lb) % 2 == 0)
        {
            if(s == ls)
            {
                lb = mid;
                ls = s;
            }
            else
            {
                ub = mid;
            }
        }
        else
        {
            if(s == ls)
            {
                ub = mid;
            }
            else
            {
                lb = mid;
                ls = s;
            }
        }
        //cout << lb << " " << ub << "\n";
        cnt++;
    }
    
    
    return 0;
}

Measured memory_bytes: 852
#include <iostream>
#include <vector>
#include <climits>

using namespace std;

const int p = 1000000007;
vector<int> fact;
vector<int> inv;
vector<int> factinv;

int combi(int a, int b){
    return (int)((long long)fact[a]*factinv[a-b]%p*factinv[b]%p);
}
int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    int size=h+w-2;
    fact = vector<int>(size);
    inv = vector<int>(size);
    factinv = vector<int>(size);
    fact[0]=1, factinv[0]=1;
    fact[1]=1, inv[1]=1, factinv[1]=1;
    for(int i=2;i<size;++i){
        fact[i] = (int)((long long)fact[i-1]*i % p);
        inv[i] = p - (int)((long long)inv[p%i] * (p/i) % p);
        factinv[i] = (int)((long long)factinv[i-1]*inv[i] % p);
    }
    long long ans=0;
    for(int i=b+1;i<=w;++i){
        ans = (ans + (long long)combi(h-a-1+i-1, i-1) * combi(a-1+w-i, w-i) % p) % p;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
int n,q;
int main()
{
	scanf("%d",&n);
	int ans=0;
	int pd=0;
	if(n<10)
	{
		printf("%d\n",n);
		return 0;
	}
	while(n)
	{
		if(n%10) pd++;
		ans+=n%10;
		n/=10;
	}
	if(pd<2&&ans==1) ans*=10;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long int D,c[26],i,j;
	scanf("%ld",&D);
	for(i=0;i<26;i++){
		scanf("%ld",&c[i]);
	}
	long int s[D][26];
	for(i=0;i<D;i++){
		for(j=0;j<26;j++){
			scanf("%ld",&s[i][j]);
		}
	}
	
	for(i=0;i<D;i++){
      printf("%d\n",i%26+1);
    }
  
	return 0;
}


Measured memory_bytes: 1804