akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define double long double
using namespace std;
typedef pair<int, int>P;
void pyes() { cout << "Yay!" << endl; }
void pno() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int n;
signed main() {
	cin >> n;
	int q = 0, memo;
	for (int i = 1; i <= 10000000; i++) {
		q += i;
		if (q >= n) {
			memo = i; break;
		}
	}
	int p = n;
	for (int i = memo; i >= 1; i--) {
		if (p >= i) {
			cout << i << endl;
			p -= i;
		}
	}
	ggr
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<vector<int>> suki;
  for(int i=0; i<N; i++)
  {
    int K;
    cin >> K;
    vector<int> a(K);
    for(int j=0; j<K; j++)
    {
      cin >> a[j];
    }
    suki.push_back(a);
  }
  
  vector<int> top = suki[0];
  
//  cout << top.size() << endl;
  for(int i=1; i<N; i++)
  {
    for(int k=top.size()-1; k>=0; k--)
    {
//      cout << top[k] << " ";
      bool isFound = false;
      for(int j=0; j<suki[i].size(); j++)
      {
        if(suki[i][j] == top[k]) isFound = true;
      }
      
      if(!isFound) top.erase(top.begin() + k);
    }
//    cout << endl;
  }
  
  cout << top.size() << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

ll gcd(ll x,ll y){
  return y==0? x:gcd(y,x%y);
}
int main() {
  int T;cin >> T;
  repeat(i,T){
    ll A,B,C,D;
    cin >> A >> B >> C >> D;
    if(B>A||B>D){
      cout << "No" << endl;
      continue;
    }
    if(C+1>=B){
      cout << "Yes" << endl;
      continue;
    }
    ll r = A%B;
    if(r>=C+1){
      cout << "No" << endl;
      continue;
    }
    ll g = gcd(D,B);
    if(g<=B-C-1){
      cout << "No" << endl;
      continue;
    }
    if(g==B){
      cout << "Yes" << endl;
      continue;
    }
    if((B-1-r)/g > (C-r)/g){
      cout << "No" << endl;
      continue;
    }
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    for (int i=0;i<s.length();i++){
      if (s.find(s[i],i+1) < 100){
        cout << "no" << endl;
        return 0;
      }
    }
    cout << "yes" << endl;
    return 0;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define popb pop_back()
#define pf push_front
#define popf pop_front()
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define acc(v) accumulate(all(v), 0)
#define F first
#define S second
#define INF lli(1e19)

#define forz(i, n) for (lli i = 0; i < n; i++)
#define fore(i, m, n) for (lli i = m; i < n; i++)
#define rforz(i, n) for (lli i = n - 1; i >= 0; i--)
#define rfore(i, m, n) for (lli i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define highll(n) __builtin_popcountll(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define gcd __gcd
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define newline cout<<endl;
//#define endl "\n"



inline lli power(lli x, lli y, lli p = mod)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

inline lli modadd(lli a, lli b, lli m = mod)
{
    a += b;
    if (a >= m)
        a -= m;
    return a;
}

inline lli modmul(lli a, lli b, lli m = mod)
{
    return ((a % m) * (b % m)) % m;
}

inline lli modi(lli a, lli m = mod) { return power(a, m - 2, m); }
inline lli md(lli x) {if(x>=0)return x; return -x;}
///////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////
lli n,m,k;
//const lli mxN = 1e6;
//lli u, v;
//bool vis[mxN];
//vector<lli> adj[mxN];
//void init()
//{
//    forz(i,n) vis[i]=0, adj[i].clear();
//}


int32_t main()
{
    kira;

    lli T=1;
    //cin>>T;

    while(T--)
    {
        lli d, t, s;
        cin>>d>>t>>s;
        if(s*t>=d) cout<<"Yes\n";
        else cout<<"No\n";
    }

    return 0;

}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<random>
#include<stdio.h>
using namespace std;

typedef long long ll;

int main(){
    ll N;
    string S;
    ll Q;
    vector<ll> K(Q);
    cin>>N;
    cin>>S;
    cin>>Q;
    for (ll i=0;i<Q;i++){
        cin>>K[i];
    }
    for (ll j=0;j<Q;j++){
        ll k=K[j];
        ll d=0;
        ll m=0;
        ll dm=0;
        ll ans=0;
        for (ll i=0;i<N-1;i++){
            d+=(S[i]=='D');
            m+=(S[i]=='M');
            dm+=d*(S[i]=='M');
            if (i>k-2){
                d-=(S[i+1-k]=='D');
                dm-=m*(S[i+1-k]=='D');
                m-=(S[i+1-k]=='M');
            }
            ans+=dm*(S[i+1]=='C');
        }
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 34180
#include <bits/stdc++.h>
using namespace std;
 
#define int long long 
 
main()
{
  string s, r;
  int dp[1005][1005] = {};
  int mod = 1000000007;
   
  dp[0][0] = 1;
   
  cin >> s >> r;
   
  for(int i = 0; i < s.size(); i++) {
    for(int j = 0; j <= r.size(); j++) {
      (dp[i + 1][j] += dp[i][j]) %= mod;
      if(j != r.size() && s[i] == r[j]) (dp[i + 1][j + 1] += dp[i][j]) %= mod;
    }
  }
 
  cout << dp[s.size()][r.size()] << endl;
 
  return (0);
}

Measured memory_bytes: 11052
N= int(input())

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

#print(N,W)

S1=[]
for i in range(N):
  if i==0:
    S1.append(W[0])
  else:
    S1.append(S1[i-1]+W[i])
#print(S1)
    
S2=[]
for i in range(N):
  S2.append(S1[N-1]-S1[i])
#print(S2)

Df=[]
minD=100
for i in range(N):
  Df.append(abs(S1[i]-S2[i]))
#print(Df[i])
  if Df[i]<minD:
    minD=Df[i]
    
#print(Df)
print(minD)
  


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 10000000000000000
#define endl '\n'
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

//abc127
signed main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m; cin>>n>>m;
    vector<int> a(n+1);
    rep(i,m){
        int l,r; cin>>l>>r;
        a.at(l-1)++; a.at(r)--;
    }
    int sum=0;
    rep(i,n+1){
        sum+=a.at(i);
        a.at(i)=sum;
    }
    int ans=0;
    rep(i,n+1){
        if(a.at(i)==m)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
n,m=map(int,input().split())
L=list(map(int,input().split()))
day=0
flg=True

for i in range(m):
    day+=L[i]
    if day>n:
        flg=False
        break

if flg:
    print(n-day)
else:
    print("-1")
    
    

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

using namespace std;

int add(vector<int> &a){
    int sum = 0;
    for (int i = 0; i < (int) a.size(); i++){
        sum += a[i];
    }
    return sum;
}

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i <= n; i++){
        vector<int> b(a.begin(), a.begin() + i);
        for (int j = n - 1; j >= i - 1 && (int) b.size() <= k; j--){
            sort(b.begin(), b.end());
            int sum = add(b);
            ans = max(ans, sum);
            for (int l = 0; l < (int) b.size() && b[l] < 0 && l + 1 + (int) b.size() <= k; l++){
                sum -= b[l];
                ans = max(sum, ans);
            }
            b.push_back(a[j]);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	char a[n][n];
	char b[m][m];
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<m;i++){
		for(int j=0;j<m;j++){
			cin>>b[i][j];
		}
	}
	bool ans=false;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(i+m-1>=n||j+m-1>=n)continue;
			
			bool check=true;
			for(int k=0;k<m;k++){
				for(int l=0;l<m;l++){
					if(a[i+k][j+l]!=b[k][l])check=false;
				}
			}
			if(check==true){
				ans=true;
			}
		}
	}
	if(ans==true){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
}

Measured memory_bytes: 256
N=int(input())
K=int(input())

keta1=len(str(N))
maxN=int(str(N)[0])
secN=0
keta2=0
if keta1>1:
    keta2=len(str(int(str(N)[1:])))
    secN=int(str(int(str(N)[1:]))[0])
    if keta2>1:
        keta3=len(str(int(str(int(str(N)[1:]))[1:])))
        thiN=int(str(int(str(int(str(N)[1:]))[1:]))[0])
only1=0
only2=0
if secN==0:
    only1=1
if keta2>1:
    if str(int(str(int(str(N)[1:]))[0]))[0]==0:
        only2=1
import math

if keta1<K:
    print(0)
else:
    if K==1:
        print(maxN+9*(keta1-1))
    if K==2:
        if keta1-2!=0:
            if only1:
                print((maxN-1)*(keta1-1)*9+9**2*(keta1-2)*(keta1-1)//2)
            else:
                if keta2-1!=0:
                    print((maxN-1)*(keta1-1)*9+9**2*(keta1-2)*(keta1-1)//2+secN+(keta2-1)*9)
                else:
                    print((maxN-1)*(keta1-1)*9+9**2*(keta1-2)*(keta1-1)//2+secN)
        else:
            print((maxN-1)*(keta1-1)*9+secN)
    if K==3:
        if keta1-3!=0:
            if only1:
                print((maxN-1)*(keta1-1)*(keta1-2)//2*9**2+9**3*(keta1-3)*(keta1-2)*(keta1-1)//6)
            else:
                if keta2-2!=0:
                    print((maxN-1)*(keta1-1)*(keta1-2)//2*9**2+9**3*(keta1-3)*(keta1-2)*(keta1-1)//6+(secN-1)*9*(keta2-1)+9**2*(keta2-2)*(keta2-1)//2+thiN+(keta3-1)*9)
                else:
                    print((maxN-1)*(keta1-1)*(keta1-2)//2*9**2+9**3*(keta1-3)*(keta1-2)*(keta1-1)//6+(secN-1)*9*(keta2-1)+9**2*(keta2-2)*(keta2-1)//2+thiN)
        else:
            if only1:
                print((maxN-1)*(keta1-1)*9)
            else:
                print((maxN-1)*(keta1-1)*9+(secN-1)*9+thiN)




Measured memory_bytes: 38384
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# みんなのプロコン 2019：A - Anti-Adjacency


def main():
    N, K = [int(i) for i in raw_input().strip().split(' ')]

    if N >= K*2 - 1:
        print 'YES'
    else:
        print 'NO'


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main(){ 
  int a,b;
  cin >> a >> b;
  if (a == b){
    cout << "Draw\n";
    return 0;
  }
  if (a == 1){
    cout << "Alice\n";
    return 0;
  }
   if (b == 1){
      cout << "Bob\n";
      return 0;
  } 
  if (a < b){
    cout << "Bob\n";
  }
  else
  {
    cout << "Alice\n";
  }
  
  return 0;
}

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

int main(){
  int n, x, y, X_Y, I_J, mindis;
  cin >> n >> x >> y;
  vector<int> min_dist(n-1,0);
  for(int i = 1; i <= n-1; i++){
    for(int j = i+1; j <= n; j++){
      X_Y = abs(x-i) + abs(j-y) +1;
      I_J = j - i;
      mindis = min(X_Y,I_J);
      min_dist.at(mindis-1)++;
    }
  }
  for(int i = 0; i < n-1; i++)
    cout << min_dist.at(i) << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    ll a,b;
    cin >> a >> b;
    if(a*b <= 0) cout << "Zero" << endl;
    else if(a > 0 || (b-a)%2 == 1) cout << "Positive" << endl;
    else cout << "Negative" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] h = new int[n];
		TreeMap<Integer, Integer> yoi = new TreeMap<>();
		int total = 0;

		for(int i = 0; i < n; i++) {
			h[i]= sc.nextInt();
			yoi.put(i+1,1);
		}
		
		for(int i = 0; i < m; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();

			if(h[a-1] > h[b-1]) {
				yoi.put(b,0);
			} else if(h[a-1] == h[b-1]){
				yoi.put(a,0);
				yoi.put(b,0);
			} else {
				yoi.put(a,0);
			}
		}

		for (Integer key : yoi.keySet()) {
			total += yoi.get(key);
		}
		
		System.out.println(total);
	}
}


Measured memory_bytes: 67408
#include<stdio.h>
main()
{
    int a,b;
    while(scanf("%d %d",&a,&b)==2){
            if(a==b||b==1||a<b){
                printf("0\n");
            }
            else{
                a=a-b;
                printf("%d\n",a);
            }
    }
}


Measured memory_bytes: 128
n = int(input())
h = list(map(int,input().split()))
h = h[::-1]
h.append(10**10)
cnt = 0
L = []
for i in range(n):
  L.append(cnt)
  if h[i+1]>=h[i]:
    cnt +=1
  else:
    cnt =0
print(max(L))

Measured memory_bytes: 14224
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

vector< vector< int > > adjList;
vector< int > d, f;

void dfs(int id) {
  static int time = 1;
  if (!d[id-1]) {
    d[id-1] = time++;
    for (int i = 0; i < adjList[id-1].size(); i++)
      dfs(adjList[id-1][i]);
    f[id-1] = time++;
  }
}

int main(int argc, char **argv) {
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  adjList = vector< vector< int > > (n, vector< int > ());
  d = vector< int > (n, 0);
  f = vector< int > (n, 0);
  for (int i = 0; i < n; i++) {
    int id, k;
    cin >> id >> k;
    for (int j = 0; j < k; j++) {
      int holder;
      cin >> holder;
      adjList[id-1].push_back(holder);
    }
  }
  for (int i = 0; i < n; i++)
    if (!d[i])
      dfs(i+1);
  for (int i = 0; i < n; i++)
    cout << i+1 << ' ' << d[i] << ' ' << f[i] << endl;
  return 0;
}



Measured memory_bytes: 3200
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(h, w) = sc.nextLine.split(" ").map(_.toInt)
    val table = List.fill(h)(sc.nextLine.toList).map(_.toList)
    table.filter(_.contains('#')).transpose.filter(_.contains('#')).transpose.map(_.mkString).foreach(println(_))
  }

}


Measured memory_bytes: 30060
#include<iostream>
#include<iomanip>
#include<cmath>
#include<algorithm>
#include<vector>
#include<math.h>
 
using namespace std;
int main(){
    string s, p;
    cin >> s >> p;
    s = s + s;
     
    if(s.find(p) != -1) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
     
    return 0;
}


Measured memory_bytes: 3204
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <list>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,m,n) for (int i = (int) (m); i < (int) (n); i++)
#define rep1(i,m,n) for (int i = (int) (m); i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
int main(void){
    string S,T;
    cin>>S>>T;
    cout<<T+S<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
#include <iomanip>
#include <vector>
#include <queue>
#include <functional>
#include <random>
#include <time.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
	ll c[4][4];
	for (int i = 1; i <= 3; i++)for (int j = 1; j <= 3; j++)cin >> c[i][j];
	for (int i = -100; i <= 100; i++) {
		for (int j = -100; j <= 100; j++) {
			for (int k = -100; k <= 100; k++) {
				ll a[4], b[4];
				a[1] = i, a[2] = j, a[3] = k;
				b[1] = c[1][1] - a[1];
				b[2] = c[2][2] - a[2];
				b[3] = c[3][3] - a[3];
				bool f = 1;
				for (int i = 1; i <= 3; i++)for (int j = 1; j <= 3; j++) {
					if (a[i] + b[j] != c[i][j]) {
						f = 0;
						break;
					}
				}
				if (f) {
					cout << "Yes" << endl;
					return 0;
				}
			}
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <math.h> // sqrt
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <iomanip> // setprecision
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vb = vector<bool>;
using vll = vector<long long>;
using pii = pair<int, int>;
using psi = pair<string, int>;

auto f(double t, double a, double b) {
    if (tan(t) <= b / a) {
        return a*b - a*(a*tan(t))/2;
    }
    else {
        return b*(b/tan(t))/2;
    }
}

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    x /= a;
    double left = 0, right = M_PI/2;
    for (int iter = 0; iter < 100; iter++) {
        double theta = (left + right) / 2;
        if (f(theta, a, b) >= x) {
            left = theta;
        }
        else {
            right = theta;
        }
    }
    cout << fixed << setprecision(10) << left*180/M_PI << endl;
}


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

signed main(){
  int A, B, K; cin >> A >> B >> K;
  int x, y;
  if(A >= K){
    x = A - K;
    y = B;
  }
  else{
    x = 0;
    y = B - (K - A);
    if(y < 0){
      y = 0;
    }
  }
  cout << x << " " << y << endl;
}

Measured memory_bytes: 768
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define per(i,m,n) for(lli i=m-1;i>=n;i--)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int a,b,h;
  cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
}

Measured memory_bytes: 256
n, h = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

a = sorted(a, reverse=True)
b = sorted(b, reverse=True)

ans = 0
i = 0
while i < n and a[0] < b[i]:
    h -= b[i]
    i += 1
    ans += 1
    if h <= 0:
        break
if h <= 0:
    print(ans)
else:
    print(ans + (h + a[0] - 1) // a[0])


Measured memory_bytes: 17876
#include<bits/stdc++.h>
#define pb push_back
#define INF (ll)1e9
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define fixed setprecision(9)
using namespace std;
using ll = long long;

int main(){
	int n,k;
	cin>>n>>k;
	vector<double> v(n);
	for(int i=0;i<n;i++)
	{
		cin>>v[i];
	}
	int index=0;
	ll ma = (ll)0;
	for(int i=0;i<k;i++){
		ma += v[i];
	}
	ll prev = ma;
	for(int i=1;i<=n-k;i++){
		ll sum = prev - v[i-1]+ v[i+k-1];
		if(sum > ma){
			index = i;
			ma  = sum;
		}
		prev = sum;
	}
	long double ans = 0;
	for(int i=index;i<index+k;i++){
		ans += ((v[i]*(v[i]+1)/2.00)/v[i]);
		
	}
	//cerr<<v[index]<<"\n";
	cout<<fixed<<ans;
		
	
	return 0;
}




Measured memory_bytes: 1792
//
// Created on 2020/07/11.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;


int main() {
    int n;
    cin>>n;
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
        int temp;
        cin>>temp;
        if(temp % 2 == 1 && i % 2 == 1){
            ans ++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void)
{
  int n;
  int count=0;
  int ans=0;
  char s[10];

  scanf("%s",s);

  n=strlen(s);
  for(int i=0;i<n;i++)
  {
    if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T')
    {
      count++;
      if(i==n-1)
      {
        if(ans<count){
          ans=count;
        }
      }
    }
    else
    {
      if(ans<count)
      {
        ans=count;
      }
      count=0;
    }

  }
  printf("%d",ans);

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char s;
	int k=0,base=1;
	while((s=getchar())!='-'&&s!=EOF&&!(s>='0'&&s<='9'));
	if(s==EOF)exit(0);
	if(s=='-')base=-1,s=getchar();
	while(s>='0'&&s<='9')
	{
		k=k*10+(s-'0');
		s=getchar();
	}
	return k*base;
}
void write(int x)
{
	if(x<0)
	{
		putchar('-');
		write(-x);
	}
	else
	{
		if(x/10)write(x/10);
		putchar(x%10+'0');
	}
}
char ch[400000];
int n;
int f[50];
long long ans;
int main()
{
	scanf("%s",ch);	
	n=strlen(ch);
	for (int i=n-1;i>=0;i--)
	{
		f[ch[i]-'a']++;
		ans+=((n-(i))-f[ch[i]-'a']);
	}
	ans++;
	printf("%lld",ans);
	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for (int i = a; i < b; ++i)

#define MAX_N 100000
int N;
array<int, 3> actions[MAX_N];
int dp[MAX_N][3];

int main() {
	cin >> N;
	FOR(i,0,N) FOR(j,0,3) cin >> actions[i][j];
	FOR(i,0,3) dp[0][i] = actions[0][i];
    FOR(i,1,N){
    	dp[i][0] = max(dp[i-1][1],dp[i-1][2])+actions[i][0];
    	dp[i][1] = max(dp[i-1][0],dp[i-1][2])+actions[i][1];
    	dp[i][2] = max(dp[i-1][0],dp[i-1][1])+actions[i][2];
    }
    cout << max(max(dp[N-1][0],dp[N-1][1]),dp[N-1][2]) << "\n";
    return 0;
}

Measured memory_bytes: 2560
#include<stdio.h>

#define MAX 100000

int main()
{
    int H,N,i;

    int Ai[MAX];

    scanf("%d%d",&H,&N);

    for(i=0;i<N;i++)
    {
        scanf("%d",&Ai[i]);

        H=H-Ai[i];
    }

    if(H<=0)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    
    

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
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 dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int q;
int l[100100],r[100100];
vector<int> p={2};
vector<int> pv;
int ans[100100];

int main(){
	for(int i=3;i<=100000;i++){
		int flag=true;
		for(int j=0;p[j]*p[j]<=i&&j<p.size();j++){
			if(i%p[j]==0){
				flag=false;
				break;
			}
		}
		if(flag){
			p.push_back(i);
			//cout<<i<<endl;
		}
	}
	
	for(int i=1;i<p.size();i++){
		auto it=lower_bound(p.begin(),p.end(),(p[i]+1)/2);
		if(it!=p.end()){
			int 	pos=distance(p.begin(),it);
			if(p[pos]==(p[i]+1)/2){
				pv.push_back(p[i]);
				//cout<<p[i]<<endl;
			}
		}
	}
	for(int i=0;i<pv.size();i++)
		ans[pv[i]]++;
	
	for(int i=1;i<=100000;i++)
		ans[i]=ans[i-1]+ans[i];
	
	cin>>q;
	REP(i,q){
		int t,s;
		cin>>t>>s;
		cout<<ans[s]-ans[t-1]<<endl;
	}
	return 0;
}
	

Measured memory_bytes: 1152
import sys
input = sys.stdin.buffer.readline

def main():
    X,Y,A,B,C = map(int,input().split())
    p = list(map(int,input().split()))
    q = list(map(int,input().split()))
    r = list(map(int,input().split()))
    p.sort()
    q.sort()
    r.sort()
    p = p[-X:]
    q = q[-Y:]
    use = p+q+r
    use.sort(reverse=True)
    print(sum(use[:X+Y]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 21088
import sys
import numpy as np
import math
import collections
import copy
import decimal
import itertools
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations
 
# input = sys.stdin.readline

a, b, c, d = map(int, input().split())

ans = max(a*c, a*d)
ans = max(ans, b*c)
ans = max(ans, b*d)
print(ans)








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

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

#define INF 999999999

typedef long* vector;

int main(void){
    int N,M;
    scanf("%d%d",&N,&M);

    int* A;
    int* B;
    long* C;
    NEW(A,M);
    NEW(B,M);
    NEW(C,M);

    vector* dist;
    NEW(dist,N);
    for(int i=0;i<N;i++){
        NEW(dist[i],N);
        for(int j=0;j<N;j++) dist[i][j]=INF;
        dist[i][i]=0;
    }


    for(int i=0;i<M;i++){
        scanf("%d%d%ld",&A[i],&B[i],&C[i]);
        A[i]--;
        B[i]--;
        dist[A[i]][B[i]]=C[i];
        dist[B[i]][A[i]]=C[i];
    }

    //ワーシャルフロイド法
    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++) dist[i][j]=MIN(dist[i][j], dist[i][k]+dist[k][j]);
        }
    }

    int ans=0;
    for(int i=0;i<M;i++){
        if(dist[A[i]][B[i]]!=C[i]) ans++;
    }
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, A, B;
  cin >> N >> A >> B;
  if ((B - A) % 2 == 0)
    cout << (B - A) / 2 << endl;
  else
    cout << min(A - 1 + ((B - A + 1) / 2), N - B + ((B - A + 1) / 2)) << endl;
  return 0;
}


Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')

  const S = input[0]
  const T = input[1]

  let count = 0
  for (let i = 0; i < 3; i++) {
    if (S[i] === T[i]) {
      count++
    }
  }

  console.log(count)
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29572
#include<bits/stdc++.h>
using ll = int_fast64_t;
const ll INF = 1e18;

int main(){
        std::string s, t;
        std::cin >> s >> t;

        std::vector<std::vector<ll>> alp(26, std::vector<ll>(0));
        ll l = 0;
        for(auto c: s){
                l ++;
                alp[c-'a'].push_back(l);
        }

        for(auto &a: alp){
                if(a.size()) a.push_back(a[0]+l);
                else a.push_back(INF);
        }

        ll h = 0, ans = 0;
        for(auto c: t){
                ll nt = *(std::upper_bound(alp[c-'a'].begin(), alp[c-'a'].end(), h));
                if(nt==INF){
                        puts("-1");
                        return 0;
                }
                ans += nt-h;
                h = nt%l;
        }
        printf("%ld\n", ans);
        return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	string s;
	cin>>s;
	lli i,count=0;
	fr(i,s.length()/2)
	{
		if(s[i]!=s[s.length()-i-1])
		{
			count++;
		}
	}
	cout<<count;
	
	return 0;
}

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

int main()
{
    string S;
    cin >> S;
    string ans = "";
    for (char c = 'a'; c <= 'z'; ++c)
    {
        bool found = false;
        if (S.find(c) == string::npos)
        {
            ans = c;
            break;
        }
    }
    if (ans == "")
    {
        cout << "None" << endl;
    }
    else
    {
        cout << ans << endl;
    }
}

Measured memory_bytes: 3780
//g++ t.cpp -o t && t < p.txt
//d>p.txt&&t<p.txt&&t2<p.txt

#include <iostream> // プログラムの耳と口
#include <vector> // 超有能配列秘書
#include <algorithm> // みんな大好きソートと二分探索
#include <queue> // きゅーちゃん、だいすき
#include <string> // to_string
#include <functional> // 関数を変数に入れる子
#include <set> // 値の取得・挿入・削除を高速に
#include <map> // setの妹 これまた優秀
#include <random> // 乱択さん
#include <cassert>

#define DB cerr<<"D"<<endl
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";};
using P=pair<ll,ll>;
const ll M = 1e9+7;
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;}
bool vaild(int x, int y, int hh, int ww){return 0<=x&&x<hh&&0<=y&&y<ww;}
int keta(ll a) {int res=0; while(a>0) res+=(a%10/5)+(a%5), a/=10; return res;}

int main() {
  int n; cin>>n;
  ll a[n]; for(int i=0;i<n;i++) cin>>a[i];
  ll k = 0, m = 1000;
  for(int i=0;i<n;i++) {
    //cout<<k<<" "<<m<<endl;
    if (i+1 < n && a[i] < a[i+1]) k += m/a[i], m-=m/a[i]*a[i];
    else m+=k*a[i], k=0;
  }
  cout<<m<<endl;
}
// ・配列の大きさok？　・priority_queueはgreater？　・debug消した？
// ・落ち着いて。提出まで4分待ってね……WJ……1/10……2/10……

// Thank you for making problems and running the contest


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x,i##end=y;i<=i##end;++i)
#define _rep(i,x,y) for(int i=x,i##end=y;i>=i##end;--i)
#define N 200005
inline bool down(int&x,const int y){return x>y?x=y,1:0;}
int n,a[N];
int main(){
	std::ios::sync_with_stdio(0);
	std::cin.tie(0),std::cout.tie(0);
	std::cin>>n;
	rep(i,1,n) std::cin>>a[i];
	std::sort(a+1,a+n+1);
	int mx=a[n]+1>>1;
	int mi=2e9,id=0;
	rep(i,1,n) if(down(mi,abs(a[i]-mx))) id=i;
	std::cout<<a[n]<<' '<<a[id]<<'\n';
	return 0;
}

Measured memory_bytes: 3976
#include <iostream>
#include <complex>
using namespace std;
typedef complex<long double> P;
const long double EPS = 1e-15;
int main(){
	int N;
	cin >> N;
	while(N--){
		P a,b,c,d;
		cin >> a.real() >> a.imag() >> b.real() >> b.imag() >> c.real() >> c.imag() >> d.real() >> d.imag();
		P one = b-a;
		P two = d-c;
		bool f = false;
		if( abs(one.real()) < EPS || abs(two.real()) < EPS ){
			f = abs(one.real()) < EPS && abs(two.real()) < EPS;
		}else{
			f = abs(one.imag()/one.real() - two.imag()/two.real()) < EPS;
		}
		cout << (f?"YES":"NO") << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll arr[100100],n,ans,temp1,temp2,a,b,m,p,k;
int main()
{
    cin>>a>>b;
    ans=a+b;
    if(ans>=10)cout<<"error";
    else
        cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long n=sc.nextLong(),a=sc.nextLong(),b=sc.nextLong();
    long max=(n-1)*b+a,min=b+(n-1)*a;
    if(a>b) {
    	System.out.println(0);
    }else if(a==b) {
    	System.out.println(1);
    }else {
    	if(n!=1) {
    		System.out.println(max-min+1);
    	}else {
    		System.out.println(0);
    	}
    }
    
  }
}


Measured memory_bytes: 23764
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//int→string
//string→int
//------------------------------------------
inline int toInt(string s) {
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}

template<class T>
inline string toString(T x) {
    ostringstream sout;
    sout << x;
    return sout.str();
}

//sqrt
//-------------------------------------------
template<class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//repetition
//------------------------------------------
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  FOR(i,0,n)
#define REPR(i, n) for(int i = n;i >= 0;i--)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL func(LL t, LL x){
    LL count = t/x;
    return count;
}

int main() {

    int A; cin >> A;
    int B; cin >> B;
    int C; cin >> C;

    int diff = A%B;

    bool good = false;

    for(int i=1;i <=100;i++){
        int tmp = diff * i;
        if(tmp%B == C){
            good = true;
        }
    }

    if(good){
        printf("YES");
    }else{
        printf("NO");
    }

    return 0;
}















































Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	int n,a[3][105],dp[3][105],i,j;
	scanf("%d",&n);
	for(i = 1;i<=n;i++) scanf("%d",&a[1][i]);
	for(i = 1;i<=n;i++) scanf("%d",&a[2][i]);
  memset(dp,0,sizeof(dp));  
        for(i = 1; i <= 2; i++) {  
            for(j = 1; j <= n; j++) {  
                dp[i][j] = a[i][j] + max(dp[i-1][j],dp[i][j-1]);  
            }  
        }
		printf("%d\n",dp[2][n]);  
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

class UF{
    public:
    int N;
    vector<int> par;
    vector<int> rank;
    vector<int> diff_weight;
    UF(int N=1){
        par.resize(N);
        diff_weight.resize(N);
        rank.resize(N);
        for(int i=0; i<N; i++) par[i] = i, rank[i] = diff_weight[i] = 0;
    }
    int root(int x){
        if(par[x]==x) return x;
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }
    int weight(int x){
        root(x);
        return diff_weight[x];
    }
    int diff(int x, int y){
        return weight(y) - weight(x);
    }
    bool isSame(int x, int y){
        return root(x)==root(y);
    }

    bool merge(int x, int y, int w=0){
        w += weight(x);
        w -= weight(y);
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return false;
        if(rank[rx]<rank[ry]) swap(rx, ry), w=-w;
        if(rank[rx]==rank[ry]) ++rank[rx];
        par[ry] = rx;
        diff_weight[ry] = w;
        return true;
    }
};

signed main(){
    int N; cin>>N;
    UF uf(N);
    int M; cin>>M;
    vector<int> L(M);
    vector<int> R(M);
    vector<int> D(M);
    REP(i, M){
        int l, r, d;
        cin>>l>>r>>d;
        L[i] = l;
        R[i] = r;
        D[i] = d;
        uf.merge(l, r, d);
    }
    bool res = true;
    REP(i, M){
        if(uf.diff(L[i], R[i]) != D[i]) res = false;
        if(!res) break;
    }
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<int,int> P;
int G[10][10];
int N,M,a,b,ans=0;
int main(){
  cin>>N>>M;
  rep(i,10){
    rep(j,10) G[i][j]=0;
  }
  rep(i,M){
    cin>>a>>b;
    a-=1;b-=1;
    G[a][b]=1;
    G[b][a]=1;
  }
  vector<int> v;
  for(int i=1;i<N;++i){
    v.push_back(i);
  }
  do {
    int s=0;
    bool f=true;
    for(auto x:v){
      if (!G[s][x]) f=false;
      s=x;
    }
    if (f) {
      ans+=1;
    }
  }while(next_permutation(v.begin(),v.end()));
  cout <<ans<<endl;
}


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

using namespace std;

int main() {
	int h, r;

	cin >> h >> r;
	if (h >= 0) {
		cout << "1" << endl;
	}
	else if (-h == r) {
		cout << "0" << endl;
	}
	else {
		cout << "-1" << endl;
	}

	return 0;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
using ll = long long;
using ld = long double;
int MOD = 1e9 + 7;
using namespace std;
struct UnionFind
{
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N)
    { //最初は全てが根であるとして初期化
        for (int i = 0; i < N; i++)
            par[i] = i;
    }

    int root(int x)
    { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {                     // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry)
            return;   //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y)
    { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main()
{
    deque<int> de;
    int n;
    cin >> n;
    for (int i = 0; i < n;i++){
        int x;
        cin >> x;
        if(i%2==0){
            de.push_back(x);
        }else{
            de.push_front(x);
        }
    }
    if(n%2==0){
        for (int i = 0; i < n;i++){
            cout << de[i]<<" " ;
        }
    }else{
        for (int i = n - 1; i >= 0;i--){
            cout << de[i] <<" ";
        }
    }
    cout << endl;
}

Measured memory_bytes: 2944
// #pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define pb push_back
#define N 1000000007
#define N2 998244353
#define Nmax 100001
#define INF (ll)1e18
#define pll pair<ll,ll>
#define pii pair<ll,ll>
#define mp make_pair
#define fi first
#define se1 second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(ll i=m;i<(n);i++)
#define get(n) ll (n); scanf("%lld",&(n));
#define get2(n,k) ll (n),(k); scanf("%lld%lld",&(n),&(k));
#define get3(n,m,k) ll (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k));
#define gets(s) string (s); cin >> (s);
#define ALL(c) (c).begin(),(c).end()
#define fill_nums(A,n) vector<ll> A((n)); for(ll i=0;i<n;i++) scanf("%lld",&A[i]);
#define fill_edges(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1); adj[b-1].pb(a-1);}
#define fill_direct(adj,m) for(ll i=0;i<m;i++) {ll a, b; scanf("%lld %lld",&a,&b); adj[a-1].pb(b-1);}
#define pi 3.1415926535897

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

    vector<vector<ll>> dp(2, vector<ll>(2,0));
    dp[0][1] = 1;

    for(ll i=0;i<s.length();i++) {
        vector<vector<ll>> dp2(2, vector<ll>(2,0));
        
        dp2[0][0] = (dp2[0][0] + dp[0][0] + dp[1][0])%N;
        dp2[1][0] = (dp2[1][0] + 2*(dp[0][0] + dp[1][0]))%N;

        ll digi = s[i]-'0';
        if(digi==0) {
            dp2[0][1] = (dp2[0][1] + dp[0][1] + dp[1][1])%N;
        }
        else {
            dp2[0][0] = (dp2[0][0] + dp[0][1] + dp[1][1])%N;
            dp2[1][1] = (dp2[1][1] + 2*(dp[0][1] + dp[1][1]))%N;
        }

        dp = dp2;
                // cout<< dp[0][0] <<" "<< dp[1][0] <<" " << dp[0][1] << " "<< dp[1][1]<<endl;;

    }

    ll ans = (dp[0][0]+dp[1][0]+dp[0][1]+dp[1][1])%N;

    printf("%lld\n",(N+ans)%N);
    return 0;  
}

Measured memory_bytes: 512
A, V = ARGF.gets.chomp.split.collect {|el| el.to_i}
B, W = ARGF.gets.chomp.split.collect {|el| el.to_i}
T = ARGF.gets.chomp.to_i

sp = V - W
dd = (A - B).abs
#p sp, dd
ans = if sp > 0 && (dd <= T * sp)
        "YES"
      else
        "NO"
      end

puts ans
  


Measured memory_bytes: 14336
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
long long x[110000];
long long y[110000];
vector<int>hb;
int pr[11000];
long long gcd(long long a,long long b){
	while(b){
		a%=b;swap(a,b);
	}return a;
}
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<=a;i++){
		scanf("%lld",x+i);
	}
	pr[0]=pr[1]=-1;
	for(int i=2;i<10100;i++){
		if(pr[i]==0){
			pr[i]=1;
			hb.push_back(i);
			for(int j=i+i;j<10100;j+=i)pr[j]=-1;
		}
	}
	long long tmp=0;
	for(int i=0;i<=a;i++){
		tmp=gcd(tmp,ABS(x[i]));
	}
	for(int i=2;i*i<=tmp;i++){
		if(tmp%i)continue;
		if(i>10100)hb.push_back(i);
		while(tmp%i==0)tmp/=i;
	}
	if(tmp>10100)hb.push_back(tmp);
	reverse(x,x+a+1);
	for(int i=0;i<hb.size();i++){
		bool ok=true;
		int p=hb[i];
		for(int j=0;j<=a;j++)y[j]=(x[j]%p+p)%p;
		
		for(int j=a;j>=0;j--){
			if(y[j]){
				if(j>=p){
					y[j-p+1]=(y[j-p+1]+y[j])%p;
					y[j]=0;
				}else{
					ok=false;break;
				}
			}
		}

		if(ok)printf("%d\n",hb[i]);
	}
}


Measured memory_bytes: 512