akhauriyash/Code-Regression huggingface dataset:
public class Main {
  private static void solve() {
    long[] pre = {nl(), nl(), nl()};
    
    long k = nl();
    System.out.println((pre[0] - pre[1]) * (k % 2 == 0 ? 1 : -1));
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}




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

using namespace std;

using ll = long long;

bool Check() {
    int c[3][3];
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> c[i][j];

    int b[3] = {c[0][0], c[0][1], c[0][2]};
    int a[3] = {0, c[1][0] - b[0], c[2][0] - b[0]};

    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j)
            if (c[i][j] != a[i] + b[j]) return false;
    return true;
}

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

    if (Check()) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector < vector<int> >ed;

struct UnionFind {
	vector<int> data;
	vector<int> sum;
	vector<int> res;
	UnionFind(int size) {
		data.resize(size, -1);
		sum.resize(size, 0);
		res.resize(size, 0);
	}
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			sum[x] += sum[y];

		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<pair<int, int> >  vp;
	vector<int> A(N);
	vector<int> B(N);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
		vp.emplace_back(A[i] - B[i], i);
	}
	int a, b;
	ed.resize(N);
	for (int i = 0; i < M; i++) {
		cin >> a >> b;
		a--;
		b--;
		ed[a].push_back(b);
		ed[b].push_back(a);
	}
	sort(vp.begin(), vp.end());
	UnionFind uf(N);
	for (int i = 0; i < N; i++) {
		uf.sum[i] = B[i];
	}
	int t;
	res = 0;
	vector<int> rank(N);

	for (int i = 0; i < N; i++) {
		rank[vp[i].second] = i;
	}
	set<int> st;
	for (int i = 0; i < N; i++) {
		a = vp[i].second;
		t = (int)1 << 60;
		int all = 0;
		st.clear();
		for (int j = 0; j < ed[a].size(); j++) {
			if (rank[a] > rank[ed[a][j]]) {
				st.insert(uf.root(ed[a][j]));
			}
		}
		for (auto j : st) {
			all += uf.sum[j];
		}
		for (auto j : st) {
			int x = uf.res[j];
			x = max(A[a], x + B[a]) + all - uf.sum[j];
			t = min(t, x);
		}
		if (t == ((int)1 << 60)) {
			t = max(A[a], B[a]);
		}
		for (int j = 0; j < ed[a].size(); j++) {
			if (rank[a] > rank[ed[a][j]]) {
				uf.unionSet(ed[a][j], a);
			}
		}
		cerr << a << " " << t << endl;
		uf.res[uf.root(a)] = t;
	}
	cerr << uf.sum[uf.root(0)] << endl;
	res = uf.res[uf.root(0)];
	cout << res << endl;
}

Measured memory_bytes: 14064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int Max = 5e2 + 5, Mod = 1e9 + 7;

int main()
{
	ll n;
	cin >> n;
	cout << (n) * (n - 1) / 2 << endl;
	return 0;
}

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

int N;

void dfs(string s, char mx) {
  if((int)s.length() == N) {
    cout << s << endl;
  } else {
    for(char c = 'a'; c <= mx; c++) {
      dfs(s + c, ((c == mx)? (char) (mx+1) : mx));
    }
  }
}

int main() {
  cin >> N;
  dfs("", 'a');
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int cnt=0,n,a[100],m=0; cin>>n;
  for(int i=0;i<n;++i) cin>>a[i];
  for(int i=0;i<n;i=i+cnt+1){
    cnt=0;
    while(a[i+cnt]==1) ++cnt;
    m=max(m,cnt);
  }
  cout<<m+1<<endl;
  return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <climits>
using namespace std;

int main() {
  int N;
  cin >> N;
  
  long a[N][3];
  long dp[N+1][3]; //i-1日目にjを選択したときの最大の幸福度
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j < 3 ; j++) {
	  dp[i][j]=0L;
    }
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 3 ; j++) {
      for (int k = 0; k < 3 ; k++) {
        if(j==k) continue;
        dp[i+1][j] = max(dp[i+1][j], dp[i][k]+a[i][j]);
      }
    }
  }
  
  cout << max({dp[N][0],dp[N][1],dp[N][2]}) << endl;
  return 0;
}


Measured memory_bytes: 4992
#include<stdio.h>

int main(void){
int a,b,n,i,m,t[100],c[100];
scanf("%d %d",&n,&m);
for(i=0;i<n;i++){
scanf("%d %d",&c[i],&t[i]);
}
a = c[0];
b = t[0];
for(i=0;i<n;i++){
if(t[i]<=m){
if(a>=c[i]){
a = c[i];
b = t[i];
}
}
}
if(b<=m){
printf("%d\n",a);
return 0;
}
else{
printf("TLE\n");
}

return 0;
}

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

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

    pair<ll, int> x[n];
    for(int i = 0; i < n; i++){
        cin >> x[i].first;
        x[i].second = i;
    }

    sort(x, x + n);
    int cou = n / 2 - 1;
    ll ans[n];

    for(int i = 0; i < n; i++){
        if(i <= cou){
            ans[x[i].second] = x[cou + 1].first;
        }else{
            ans[x[i].second] = x[cou].first;
        }
    }

    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 6912
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
ll mod_pow(ll x,ll n,ll mod){ll res=1;while(n>0){if(n&1) res=res*x%mod;x=x*x%mod;n>>=1;}return res;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
//2の進数表示の最高位
//例: 7->2 8->3
ll high_order_bit(ll n){ll tmp=1,i=-1;while(tmp<=n){tmp*=2;i++;}if(n==0) return 0;else return i;}
// 6 -> vec[0] [1] [2]
//          0   1   1
//vec[i]:2^iの位
vector<ll> binary_expansion(ll n){vector<ll> B(high_order_bit(n)+1);ll tmp=n;for(ll i=high_order_bit(n);i>=0;i--){B[i]=tmp/pw2[i];tmp%=pw2[i];}return B;}
vector<ll> divisor(ll x){vector<ll> div;for(ll i=1;i*i<=x;i++){if(i*i!=x && x%i==0){div.pb(i);div.pb(x/i);}else if(x%i==0) div.pb(i);}sort(all(div));return div;}
vector<ll> vectorprime(ll x){vector<bool> is_prime(x+1);vector<ll> prime;rep(i,x+1) is_prime[i]=true;is_prime[0]=is_prime[1]=false;for(ll i=2;i<=x;i++){if(is_prime[i]){prime.pb(i);}for(int j=i*2;j<=x;j+=i) is_prime[j]=false;}return prime;}
map<ll,ll> prime_factor(ll x){map<ll,ll> m;ll sq=(ll)sqrt(x) + 1;vector<ll> v_prime=vectorprime(sq);ll tmp=x;rep(i,sz(v_prime)){ll count=0;while(tmp % v_prime[i] == 0){tmp /= v_prime[i];count++;}if(count != 0) m[v_prime[i]]=count;if(tmp==1) break;}if(tmp != 1) m[tmp]=1;return m;}
ll fac[500001],finv[500001],inv[500001],dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
void table(){fac[0]=fac[1]=1;finv[0]=finv[1]=1;inv[1]=1;for(ll i=2;i<500001;i++){fac[i]= fac[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
ll dev(long long a,long long b){return (a*inv[b])%MOD;}
ll comb(ll n, ll k){if(n<k) return 0;if(n<0 || k<0) return 0;return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
ll perm(ll n,ll k){if(n<k) return 0;if(n<0 || k<0) return 0;return (fac[k]*comb(n,k))%MOD;}


int main(){
    {table();}
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string s; cin>>s;
    ll ans=0;
    rep(i,sz(s)) if(s[i]=='1') ans++;
    cout<<ans<<endl;
}



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

#define endl '\n'
#define ll long long

void int_scan(int&);
void ll_scan(ll&);

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int k, n;
	int_scan(k);
	int_scan(n);
	int s, curr, prev;
	int_scan(prev);
	s = prev;
	priority_queue<int> dist;
	for (int i = 1; i < n; ++i) {
		int_scan(curr);
		dist.push(curr - prev);
		prev = curr;
	}
	dist.push(s + k - curr);
	dist.pop();

	int sum = 0;
	for (int i = 0; i < n - 1; ++i) {
		sum += dist.top();
		dist.pop();
	}
	cout << sum << endl;
}

void int_scan(int& n)
{
	bool negative = false;
	char c;
	n = 0;

	c = getchar();
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	for (; (c > 47 && c < 58); c = getchar())
		n = n * 10 + c - 48;

	if (negative)
		n *= -1;
}

void ll_scan(ll& n)
{
	bool negative = false;
	char c;
	n = 0;

	c = getchar();
	if (c == '-')
	{
		negative = true;
		c = getchar();
	}
	for (; (c > 47 && c < 58); c = getchar())
		n = n * 10 + c - 48;

	if (negative)
		n *= -1;
}

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

int main(){
  int n;
  cin >> n;
  int l[n], sum = 0, ma = -1;
  rep(i, n) {
    cin >> l[i];
    sum += l[i];
    ma = max(ma, l[i]);
  }
  if (ma < sum-ma) {
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }

}


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 <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 <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());

    if (t <= s) { cout << "No" << endl; }
    else { cout << "Yes" << endl; }
}

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

int main() {
    char n[6];//q;
    cin>>n;
    int f=0;
    for(int i=0;i<6;i++)
    {
        
        if(n[2]==n[3])
        {
           if(n[4]==n[5])
           {
               f=1; 
               break;
           }
        }
             
            
        }
        if(f==1)
        cout<<"Yes"<<endl;
        else
        cout<<"No\n";
    
	// your code goes here
	return 0;
}


Measured memory_bytes: 256
w = input()
word = {}
l = len(w)

for i in range(l):
    n = word.get(w[i], 0)
    n = n+1
    word[w[i]] = n

flag = True
for i in word.values():
    if(i % 2 == 1):
        flag = False
        break

if(flag):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
using ll = long long;

int main(void) {
    int A, B, C, D;

    cin >> A >> B >> C >> D;

    bool tturn = true;
    while(A > 0 && C > 0){
        if(tturn){
            C -= B;
        } else {
            A -= D;
        }
        tturn = !tturn;
    }

    if(A > 0){
        cout << "Yes" <<endl;
    } else {
        cout << "No"<< endl;
    }

    return 0;
}


Measured memory_bytes: 3628
// AGC012A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int N;
	cin >> N;
	long a[300001];
	for (int i = 1; i <= 3 * N; i++) cin >> a[i];
	//for (int i = 1; i <= 3 * N; i++) cout<< a[i]<<endl;
	long sum = 0;
	sort(a + 1, a + 3 * N + 1, greater<int>());

	//for (int i = 1; i <= 3 * N; i++) cout << a[i] << endl;
	for (int i = 1; i <= 2 * N; i++) 
	{
		if (i % 2 == 0)sum += a[i];
	}
	cout << sum << endl;
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#define pb push_back
#define all(x) x.begin(), x.end()
#define pi pair<int, int>
#define l first
#define r second
#define int long long

using namespace std;

const int maxn = 5e3 + 2, mod = 998244353, inf = 4e18;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, x;
    cin >> n >> x;
    cout << 3 * (n - __gcd(n, x));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <map>
#include <string.h>
#include <algorithm>
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
#define set_precision cout << fixed << setprecision(10)
#define rep(i, a, b) for (int i = a; i < b; i++)
#define repb(i, a, b) for (int i = a; i >= b; i--)
#define replb(i, a, b) for (ll i = a; i >= b; i--)
#define repl(i, a, b) for (ll i = a; i < b; i++)
#define repit(arr) for (auto it = arr.begin(); it != arr.end(); 
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vl vector<long long int>
#define Vi vector<vector<int>>
#define vpi vector<pair<int,int> >
#define seti set<int>
#define setl set<ll>
#define dseti set<int, greater<int>>
#define dsetl set<ll, greater<ll>>
#define mseti multiset<int>
#define msetl multiset<ll>
#define dmseti multiset<int, greater<int>>
#define dmsetl multiset<ll, greater<ll>>
#define sortA(arr) sort(arr.begin(), arr.end())
#define dsortA(arr) sort(arr.begin(), arr.end(), greater<int>())
#define ssort(arr) stable_sort(arr.begin(), arr.end())
#define search(arr, c) binary_search(arr.begin(), arr.end(), c)
#define pb push_back
#define ll long long
#define cl_bf cin.ignore(numeric_limits<streamsize>::max(), '\n');
#define castl static_cast<ll>
#define BRAHAMASTRA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ull unsigned long long int

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	BRAHAMASTRA

	ull n;
	cin>>n;
	ull sum=0;
	for(int i=1;i<n;++i)
	{
		sum+=(floor((n-1)/i));
	}
	cout<<sum<<"\n";
}

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


int main() {
	int a[100000] = {0};
	int i=0, j=0,n;
	cin >> n;
	for (int k = 0; k < n; k++) {
		cin >> a[k];
	}
	while (j < n - 1) {
		if (a[j] <= a[n - 1]) {
			int swap = a[j];
			a[j] = a[i];
			a[i] = swap;
			i++;
		}
		j++;
	}
	int swap = a[n - 1];
	a[n - 1] = a[i];
	a[i] = swap;
	for (int k = 0; k < i; k++) {
		cout << a[k] << " " << flush;
	}
	cout << "[" << a[i] << "]" << flush;
	for (int k = i + 1; k < n; k++) {
		cout << " " << a[k] << flush;
	}
	cout << endl;
	return 0;
}

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

#define LLINF (1LL<<60)
typedef long long ll;

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

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;
    //-----------------------------------
    bool is=(N/10==9)||(N%10==9);
    cout << ((is) ? "Yes" : "No") <<endl;
    return (0);
}

Measured memory_bytes: 256
#include <stdio.h>

int x,y;
int hoge;
int hoge1;
main(){
	
	scanf("%d",&x);

	int hai[256];

	
	for(hoge=0;hoge<x;hoge++){
		scanf("%d",&y);
		hai [hoge]=y;
	}
	
	for(hoge1=x-1;hoge1>=0;hoge1--){
		if(hoge1==0){printf("%d\n",hai[hoge1]);}
		else{printf("%d ",hai[hoge1]);}
	}
	
  return 0;
}
  

Measured memory_bytes: 596
#include<stdio.h>
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		if(n==22) printf("Christmas Eve Eve Eve\n");
		else if(n==23)   printf("Christmas Eve Eve\n");
		else if(n==24)   printf("Christmas Eve\n");
		else if(n==25)   printf("Christmas\n");
	}
} 

Measured memory_bytes: 128
n,m=map(int,input().split())
l=[[int(j) for j in input().split()] for i in range(n)]
x=0
for i in range(1,m+1):
    a=0
    for j in range(n):
        for k in range(l[j][0]):
            if i==l[j][k+1]:
                a+=1
    if a==n:
        x+=1
print(x)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int maxN = 1e6 + 5;
int root[maxN], x[maxN], y[maxN], val[maxN], z;
int get_root(int u) {
	if(root[u] == u) return u;
	return root[u] = get_root(root[u]);
}
int myabs(int u) {
	if(u < 0) return -u;
	return u;
}
int work(int num1, int num2, int num3) {
	return (num1 - 1) * 6 + num2 * 3 + num3;
}
int N, M, Q, Mod, G;
bool vis[2][maxN];
int main() {
	cin >> N >> M >> Q >> Mod;
	for(int i = 1; i <= M; ++i) {
		cin >> x[i] >> y[i] >> val[i];
		G = __gcd(G, myabs(val[i] - val[1]));
	}
	if(G == 0) G = Mod;
	Mod = __gcd(Mod, G * 3);
	z = val[1] % G;
	for(int i = 1; i <= 6 * N; ++i) root[i] = i;
	for(int i = 1; i <= M; ++i) {
		int W = (val[i] - z) / G;
		for(int j = 0; j <= 1; ++j) {
			for(int k = 0; k <= 2; ++k) {
				int t1, t2;
				t1 = get_root(work(x[i], j, k));
				t2 = get_root(work(y[i], 1 - j, (2 * k + W) % 3));
				if(t1 != t2) root[t1] = t2;
				t1 = get_root(work(y[i], j, k));
				t2 = get_root(work(x[i], 1 - j, (2 * k + W) % 3));
				if(t1 != t2) root[t1] = t2;
			}
		}
	}
	for(int i = 0, j = z;i < (Mod * 2);++i, j = (j * 2) % Mod) 
	vis[i&1][j]=1;
	while(Q--) {
		int S, T, V;
		cin >> S >> T >> V;
		bool ans = 0;
		for(int i = 0; i <= 1; ++i) 
		for(int j = 0; j <= 2; ++j) 
		if(get_root(work(T, 0, 0)) == get_root(work(S, i, j))) 
		ans |= vis[i][(V + z + (3 - j) * G) % Mod];
		if(ans) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
  int n; string s;
  cin >> n >> s;
  int east = 0, west = 0;
  for (int i = 1; i < n; i++)
  {
    if (s[i] == 'E') east++;
  }
  int ans = east;
  for (int i = 1; i < n; i++)
  {
    if (s[i-1] == 'W') west++;
    if (s[i] == 'E') east--;
    ans = min(ans,west+east);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;

    if ((A + B) % 2 == 0) {
        cout << (A + B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int w = stdIn.nextInt();
		int h = stdIn.nextInt();
		int x = stdIn.nextInt();
		int y = stdIn.nextInt();
		int r = stdIn.nextInt();
		
		String result = "Yes";
		if (x - r < 0 || y - r < 0) {
			result = "No";
		} 
		
		if (x + r > w || y + r > h) {
			result = "No";
		}
		
		System.out.println(result);
	}

}



Measured memory_bytes: 26272
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;
int MOD = 1000000007;
int a,b,c,d;
signed main(){
    cin >> a >> b >> c >> d;
    if(abs(a-c)<= d || (abs(a-b) <= d  && abs(b-c) <= d)) cout << "Yes";
    else cout << "No";
    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;

const int N=105;
const int inf=1000000000;

int n,m,s,t,sx,sy,tx,ty,cnt,last[N*2],dis[N*2],cur[N*2];
struct edge{int to,next,c;}e[N*N*N*2];
queue<int> que;
char str[N];

void addedge(int u,int v,int c)
{
	e[++cnt].to=v;e[cnt].c=c;e[cnt].next=last[u];last[u]=cnt;
	e[++cnt].to=u;e[cnt].c=0;e[cnt].next=last[v];last[v]=cnt;
}

bool bfs()
{
	for (int i=s;i<=t;i++) dis[i]=0;
	while (!que.empty()) que.pop();
	dis[s]=1;que.push(s);
	while (!que.empty())
	{
		int u=que.front();que.pop();
		for (int i=last[u];i;i=e[i].next)
			if (e[i].c&&!dis[e[i].to])
			{
				dis[e[i].to]=dis[u]+1;
				if (e[i].to==t) return 1;
				que.push(e[i].to);
			}
	}
	return 0;
}

int dfs(int x,int maxf)
{
	if (x==t||!maxf) return maxf;
	int ret=0;
	for (int &i=cur[x];i;i=e[i].next)
		if (e[i].c&&dis[e[i].to]==dis[x]+1)
		{
			int f=dfs(e[i].to,min(e[i].c,maxf-ret));
			e[i].c-=f;
			e[i^1].c+=f;
			ret+=f;
			if (maxf==ret) break;
		}
	return ret;
}

int dinic()
{
	int ans=0;
	while (bfs())
	{
		for (int i=s;i<=t;i++) cur[i]=last[i];
		ans+=dfs(s,inf);
	}
	return ans;
}

int main()
{
	scanf("%d%d",&n,&m);
	s=0;t=n+m+1;cnt=1;
	for (int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		for (int j=1;j<=m;j++)
			if (str[j]=='S') sx=i,sy=j;
			else if (str[j]=='T') tx=i,ty=j;
			else if (str[j]=='o')addedge(i,j+n,1),addedge(j+n,i,1);
	}
	if (sx==tx||sy==ty) {puts("-1");return 0;}
	addedge(s,sx,inf);addedge(s,sy+n,inf);
	addedge(tx,t,inf);addedge(ty+n,t,inf);
	printf("%d",dinic());
	return 0;
}

Measured memory_bytes: 768
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n = nk[0];
        int k = nk[1];
        List<Tuple<int, int>> items = new List<Tuple<int, int>>();
        for (int i = 0; i < n; i++)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            items.Add(new Tuple<int, int>(ab[0], ab[1]));
        }
        long max = 0;
        for (int i = 29; i >= 0; i--)
        {
            long score = 0;

            List<Tuple<int, int>> newItems = new List<Tuple<int, int>>();
            //i桁目を取るか、取らないか それより上の桁の制約は既にない。
            foreach (var item in items)
            {
                if (((item.Item1 >> i) & 1) == 1)
                {
                    if (((k >> i) & 1) == 1) newItems.Add(item);
                }
                else
                {
                    if (((k >> i) & 1) == 1) score += item.Item2;
                    newItems.Add(item);
                }
            }
            items = newItems;
            max = Max(max, score);
        }
        max = Max(max, items.Sum(x => (long)x.Item2));
        Console.WriteLine(max);
    }
}


Measured memory_bytes: 37900
N = gets.to_i
A = gets.split.map(&:to_i)

f = A.count {|a| a % 4 == 0 }
o = A.count(&:odd?)
f += 1 if N - o == f

puts o == 0 || (f != 0 && o <= f) ? 'Yes' : 'No'


Measured memory_bytes: 10500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1000000007;

int main(){
    int n;cin>>n;
    string s1;cin>>s1;
    string s2;cin>>s2;
    int r=0;
    int p_a=0;
    int p_b=-1;
    ll ans=1;
    while(true){
        if(r>=n) break;
        if(s1[r]==s2[r]){
            p_a=0;
            r++;
        }
        else{
            p_a=1;
            r+=2;
        }
        if(p_b==-1 and p_a==0) ans*=3;
        else if(p_b==-1 and p_a==1) ans*=6;
        else if(p_b==0 and p_a==0) ans*=2;
        else if(p_b==0 and p_a==1) ans*=2;
        else if(p_b==1 and p_a==0) ans*=1;
        else if(p_b==1 and p_a==1) ans*=3;
        ans%=mod;
        p_b=p_a;
    }
    cout<<ans<<endl;
}


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

using namespace std;

int main() {
	int N;
	cin >> N;

	vector< tuple<int, int, int> > h(N);
	vector< tuple<int, int, int> > dp(N + 1);

	for(auto &x: h) {
		int a, b, c;
		cin >> a >> b >> c;
		x = make_tuple(a, b, c);
	}

	dp[0] = make_tuple(0,0,0);

	for(int i = 1; i <= N; i++) {
		int a[3];
			a[0] = max(get<1>(dp[i-1]) + get<0>(h[i-1]), get<2>(dp[i-1]) + get<0>(h[i-1]));
			a[1] = max(get<2>(dp[i-1]) + get<1>(h[i-1]), get<0>(dp[i-1]) + get<1>(h[i-1]));
			a[2] = max(get<0>(dp[i-1]) + get<2>(h[i-1]), get<1>(dp[i-1]) + get<2>(h[i-1]));
		dp[i] = make_tuple(a[0], a[1], a[2]);
	}

	cout << max({get<0>(dp[N]), get<1>(dp[N]), get<2>(dp[N])}) << endl;
}


Measured memory_bytes: 2560
#!/usr/bin/env python3
import array
def get_fact(n, mod):
    fact = array.array('l')
    fact.append(1)
    for i in range(n):
        fact.append((i + 1) * fact[-1] % mod)
    return fact

mod = 10 ** 9 + 7
n, m = map(int, input().split())
fact = get_fact(max(n, m), mod)
if n == m:
    result = (fact[n] * fact[m]) * 2
elif abs(n - m) == 1:
    result = fact[n] * fact[m]
else:
    result = 0
print(result % mod)


Measured memory_bytes: 3864
#include<bits/stdc++.h>
#include <iostream> 
#include <string> 
#define lli long long int
#define deb1(x) cout<<#x<<" :: "<<x<<"\n";
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define deb2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define deb3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
#define deb(v) for(lli i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define all(a) a.begin(),a.end()
#define ll long long
using namespace std;
#define f first
#define sd second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define sz(x) (ll)x.size()
#define vl vector<lli>
#define pii pair<lli,lli>
lli mod=1e9+7;
using namespace std;
lli t,n,u,x,y,k;
const lli N = 100001;
int main(){
    fast
     t=1;
//    cin>>t;
    while(t--){
        string s;
        cin>>s;
        n=s.length();
        if(s[n-1]=='s')cout<<s<<"es"<<endl;
        else cout<<s<<"s"<<endl;
    }
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

int main(){
    int n;
    while(cin >> n, n){
        vector<pair<int, int>> v(n);
        rep(i, n) cin >> v[i].second >> v[i].first;
        sort(v.begin(), v.end());
        int m = 0; bool is = true;
        rep(i, n){
            m += v[i].second;
            if(v[i].first < m){is = false; break;}
        }
        cout << (is?"Yes":"No") << endl;
    }
}

Measured memory_bytes: 1188
n = int(input());
arr = list(map(int, input().split()));
count = 0;
for i, num in enumerate(arr):
  if(i == 0 or i == (n - 1)): 
    continue;
  
  target_arr = [arr[i-1], arr[i], arr[i+1]]
  if(sorted(target_arr)[1] == arr[i]):
  	count+=1;

print(count)
  

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	vector<vector<vector<int>>> A(N+1);
	for (int i=0; i<N-1; i++) {
		int a, b;
		cin >>a >>b;
		A.at(a).push_back({b, i});
		A.at(b).push_back({a, i});
	}
	vector<int> q;
	int ixq=0;
	q.push_back(1);
	vector<int> CL(N-1, 0);
	vector<int> CP(N+1, 0);
	int MC=0;
	while(ixq<q.size()) {
		int I=q.at(ixq);
		int CO=1;
		for (int j=0; j<A.at(I).size(); j++) {
			int T=A.at(I).at(j).at(0);
			int L=A.at(I).at(j).at(1);
			if (CL.at(L)==0) {
				q.push_back(T);
				if (CO==CP.at(I))
					CO++;
				CL.at(L)=CO;
				CP.at(T)=CO;
				MC=max(MC, CO);
				CO++;
			}
		}
		ixq++;
	}
	cout <<MC <<endl;
	for (int i=0; i<N-1; i++)
		cout <<CL.at(i) <<endl;
	return 0;
}



Measured memory_bytes: 16888
#include<iostream> 
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <sstream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

int main() {
	int a, b, c, d,x,y;
	cin >> a >> b >> c >> d;
	x = a + b;
	y = c + d;
	if (x > y) {
		cout << "Left" << endl;
	}
	else if(y > x) {
		cout << "Right" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int x,mn=0,y=0,n;	

int main() {
cin>>x;
y=x;
n=x;
while(y>=1){
	int sum=0;
     while( x%2==0)
	{
		sum++;
		x/=2;
	}
	if(sum>mn)
	{
		n=y;
		mn=sum;
	}
	y--;
	x=y;
}
cout<<n<<endl;
	return 0;
}

Measured memory_bytes: 256
H, W = tuple(map(int, input().split()))
N = int(input())
a = list(map(int, input().split()))

table = [["0" for i in range(W)] for i in range(H)]
x,y,c = 0,0,1

for i in range(1,N+1):
    for j in range(a[i-1]):
        table[y][x] = str(i)
        if 0 <= x+c <= W-1:
            x += c
        elif (x+c == W)or(x+c == -1):
            c *= -1
            y += 1

for i in range(H):
    tmp = ' '.join(table[i])
    print(tmp)


Measured memory_bytes: 3828
def insertion_sort(a, n)
  1.upto(n - 1) do |i|
    puts a.join(' ')

    v = a[i]
    j = i - 1

    while j >= 0 && a[j] > v
      a[j + 1] = a[j]
      j -= 1
    end

    a[j + 1] = v
  end

  puts a.join(' ')
end

N = gets.to_i
A = gets.split.map(&:to_i)

insertion_sort(A, N)

Measured memory_bytes: 8728
n, y = gets.strip.split.map(&:to_i)

a, b, c = 0, 0, 0

(0..n).each do |i|
  (0..(n-i)).each do |j|
    if y == 10000*i + 5000*j + 1000*(n-i-j)
      puts "#{i} #{j} #{n-i-j}"
      exit
    end
  end
end

puts "-1 -1 -1"

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int h, w, dp[2005][2005][4];
string s[2005];

int main() {
    cin >> h >> w;
    REP(i,h){
        cin >> s[i];
    }
    REP(i,h){
        REP(j,w){
            if(s[i][j]=='#')continue;
            dp[i][j+1][0] = dp[i][j][0]+1;
            dp[i+1][j][1] = dp[i][j][1]+1;
        }
    }
    REPR(i,h-1){
        REPR(j,w-1){
            if(s[i][j]=='#')continue;
            dp[i][j-1][2] = dp[i][j][2]+1;
            dp[i-1][j][3] = dp[i][j][3]+1;
        }
    }
    int ans = 0;
    REP(i,h){
        REP(j,w){
            if(s[i][j] == '#')continue;
            int tmp = 1;
            REP(k,4){
                tmp += dp[i][j][k];
            }
            ans = max(ans, tmp);

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


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


#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pb2 pop_back
#define pf2 pop_front
#define line printf("\n")
#define pq priority_queue
#define rep(k,i,j) for(int k = (int)i;k<(int)j;k++)
#define repd(k,i,j) for(int k = (int)i;k>=(int)j;k--)
#define ll long long
#define ALL(a) a.begin(),a.end()
#define vi vector<int>

using namespace std;

double EPS = 1e-9;
int INF = 1e9+7;;
long long INFLL = 1e17;
double pi = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

clock_t first_attempt = clock();
inline void cek_time(){
	clock_t cur = clock()- first_attempt;
	cerr<<"TIME : "<<(double) cur/CLOCKS_PER_SEC<<endl;
}
inline void OPEN (string s) {
	freopen ((s + ".in").c_str (), "r", stdin);
	freopen ((s + ".out").c_str (), "w", stdout);
}

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> bbst;
//find_by_order(idx) : i-th index 
//order_of_key(val)  : val has which index

//end of template


ll dp(ll n, ll k) {
	if (n < k) return 0;
	// if (n >= k * (k + 1)) return dp((n - k*k)%k + k*k, k);
	
	ll x = n / k;
	ll i = n - x * k;
	i %= (x + 1);
	if (i  == 0) return x;
	return dp(x * k + i - (x + 1), k);
}

int main() {
	int n;
	cin >> n;
	
	ll nim = 0;
	rep(k,0,n){
		ll a, b;
		cin >> a >> b;
		nim ^= dp(a, b);
		
		// printf("%lld %lld\n", a, b);
		// rep(k,0,a + 1)printf("dp %lld \n", dp(k,b));
		// line;
	}
	
	printf("%s\n", nim ? "Takahashi" : "Aoki");
}

Measured memory_bytes: 256
import java.lang.Math

fun main(args: Array<String>)
{
    val s = readLine()!!

    if (s == "Sunny") println("Cloudy")
    else if (s == "Cloudy") println("Rainy")
    else if (s == "Rainy") println("Sunny")
 }

fun readInts(): List<Int> = readLine()!!.split(" ").map(String::toInt)
fun readLongs(): List<Long> = readLine()!!.split(" ").map(String::toLong)

fun readIntArr(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray()
fun readLongArr(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray()

fun readIntArrS(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArray()
fun readLongArrS(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArray()

fun readIntArrSD(): IntArray = readLine()!!.split(" ").map(String::toInt).toIntArray().sortedArrayDescending()
fun readLongArrSD(): LongArray = readLine()!!.split(" ").map(String::toLong).toLongArray().sortedArrayDescending()

fun readString() = readLine()!!


Measured memory_bytes: 31656
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 1e5+5;
int n,k,a[MAX],b[MAX];
int main(){
    cin >> n >> k;
    int i,j;
    for(i=0;i<n;i++) cin >> a[i] >> b[i];
    int high = -1;
    for(i=30;i>=0;i--){
        if((1<<i)&k){
            high = i;
            break;
        }
    }
    ll ans1 = 0;
    if(high==-1){
        for(i=0;i<n;i++){
            if(!a[i]) ans1 += b[i];
        }
        cout << ans1 << endl;
        return 0;
    }
    while(high>=0){
        bool chk = false;
        if(((1<<high)&k)) chk = true;
        ll tmp = 0;
        for(i=0;i<n;i++){
            for(j=30;j>=0;j--){
                if((1<<j)&a[i]) break;
            }
            if(j>high) continue;
            if(!((1<<high)&a[i]) || (high==0 && chk)) tmp += (ll)b[i];
            if(j==high && chk) a[i] -= (1<<j);
        }
        if(!chk && high>0){
          high -= 1;
          continue;
        }
        if(tmp>ans1) ans1 = tmp;
        high -= 1;
    }
    cout << ans1 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	vector<int> v(26);
	for (int i = 0; i < 26; i++) {
		v.at(i) = 10000;
	}

	for (int i = 0; i < n; i++) {
		string S;
		cin >> S;

		vector<int> v2(26);
		for (int j = 0; j < S.size(); j++) {
			int n = (int)S.at(j) - 'a';
			//cout << n << endl;
			v2.at(n)++;
		}

		//for (int j = 0; j < 26; j++) {
		//	if (j) cout << ' ';
		//	cout << v2.at(j);
		//	if (j == 25) cout << endl;
		//}

		for (int j = 0; j < 26; j++) {
			v.at(j) = min(v.at(j), v2.at(j));
		}
	}

	//for (int i = 0; i < 26; i++) {
	//	cout << i << ":" << v.at(i) << endl;
	//}

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < v.at(i); j++) {
			char ch= (char)i + 97;
			cout << ch;
		}
	}
	cout << endl;
}

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

const int MOD = 1000000007;

signed main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  for(int c = K; c<=N+1; c++) {
    int mn = c * (c-1) / 2;
    int mx = c * (2*N-c+1) / 2;
    ans = (ans + (mx - mn + 1)) % MOD;
    //cerr << mn << "\t" << mx << "\t" << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
io = STDIN
n=io.gets.chomp.to_i
s=[]
n.times do
  s<<io.gets.chomp.to_i
end
ss=s.sort.select{|i|i%10!=0}
if ss==[]
  puts 0
else
  sum=s.inject(:+)
  ss.each do |i|
    break if sum%10 != 0
    sum-=i
  end
  puts sum
end


Measured memory_bytes: 1788
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

a = INT()
b = INT()
h = INT()
print(int((a+b)*h/2))

Measured memory_bytes: 4264
def actual(n, s):
    if len(s) % 2 == 1:
        return 'No'

    len_half = int(n / 2)

    if s[:len_half] == s[len_half:]:
        return 'Yes'

    return 'No'

n = int(input())
s = input()

print(actual(n, s))


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

int main() {
  int n;
  cin >> n;
  
  int m = (n - 1) / 2;
  
  int64_t count = 0;
  
  for (int i = 0; i < m; i++) {
    int j = i + 1;
    count += (n + j - 1) / j - 1;
  }
  int x = n - m - 1;
  count += x;
  
  cout << count << endl;
}


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

#define ll              long long int
#define scan(any)       for(auto &i:any) cin>>i;
#define print(any)      for(auto i:any) cout<<i<<" "; 
#define endl            '\n'
#define pb              push_back
#define vll             vector<ll> 
#define f(i,x,y)        for(i=x;i<y;i++)
#define INF             LLONG_MAX
#define fast            ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define s(x)            sort(x.begin(),x.end())
#define all(v)          v.begin(),v.end()
#define p2(n,x)         cout << fixed << setprecision(x) <<n<<endl; 
#define pll             pair<ll,ll> 
#define ff              first
#define ss              second
#define blt(x)          __builtin_popcount(x)

void solve()
{
    ll i,j,k,n;
    cin>>n;
    ll a=0;
    f(i,1,n)
    a+=((n-1)/i);
    cout<<a;
}

int main()
{
    
    fast
    ll t = 1;

    while(t--)
    solve();
    
    return 0;
}

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

int main() {
  vector<int> v(3);
  rep(i,3) cin >> v[i];
  sort(v.begin(), v.end());
  cout << v[2]*10+v[1]+v[0] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define faf ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define ll long long
#define pb push_back
#define mp make_pair
#define For(i,k,n) for(i=k;i<=n;i++)


const  ll modo=1e9+7;


ll x=-1;
ll y=-1;

ll gcdextended(ll a ,ll b)
{
    if(b==0)
    {
        x=1;
        y=0;
    }
    else{
        gcdextended(b,a%b);
        ll tx=y;
        ll ty=(x-((a/b)*y));
        x=tx;
        y=ty;
    }
}

ll modinverse(ll a,ll m)
{
    gcdextended(a,m);
    return (x+m)%m;
}

ll ncr(ll n , ll r)
{
    ll res=1;
    ll lim=max(n-r,r);
    ll i;
    ll cc=1;
    for(i=lim+1;i<=n;i++)
    {
        res=(((res*i)%modo)*modinverse(cc,modo))%modo;
        cc++;
    }
    return res;
}




int main()
{
    faf;
    ll n,k;
    cin>>n>>k;
    ll rr=n-k;
    ll i;
    //cout<<ncr(1000000007,1)<<endl;
    ll res;

    for(i=1;i<=k;i++)
    {
        if(i-1<=rr){
        res=(ncr(k-1,i-1)*ncr(rr+1,i))%modo;
        cout<<res<<"\n";}
        else cout<<"0"<<endl;
    }


}

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

int N,M;
int s,g;

struct state{
  int t,c,to;
  bool operator<(const state& st) const {
    return t < st.t;
  }
};
vector<state> U[200015];
vector<int> V[200015];
typedef pair<int,int> P;

map<P,int> ids;

struct edge {
  int to,c;
  edge(){
  }
  edge(int to,int c):to(to),c(c){}
  bool operator<(const edge& e) const {
    return c > e.c;
  }
};

vector<edge> G[400115];
vector<int> gs;
const int INF = (1<<29);
int H[400115];
int cnt;
int dijk(){
  fill( H,H+cnt+1,INF );
  priority_queue<edge> q;

  q.push( edge(ids[P(s,0)],0) );
  H[ids[P(s,0)]] = 0;

  while( !q.empty() ) {
    edge p = q.top(); q.pop();
    if( H[p.to] < p.c ) continue;
    for(edge e : G[p.to]){
      if( H[e.to] > p.c + e.c){
        H[e.to] = p.c + e.c;
        q.push( edge(e.to,p.c+e.c) );
      }
    }
  }
  int res = INF;
  for( int gg : gs ){
    res = min( res, H[gg] );
  }
  return res;
}

int main() {
  cin >> N >> M >> s >> g; --s; --g;
  cnt = 0;

  ids[P(s,0)] = cnt++;
  V[s].push_back(0);

  for(int i=0;i<M;i++){
    int u,v,t,c; cin >> u >> v >> t >> c; --u; --v;
    U[u].push_back( (state){t,c,v} );
    V[v].push_back( t+c );
    if( ids.count( P(v,t+c) ) == 0 ) {
      ids[P(v,t+c)] = cnt++;
    }
    if( v == g ) gs.push_back(ids[P(v,t+c)] );
  }


  for(int i=0;i<N;i++){
    sort( U[i].begin(), U[i].end() );
    sort( V[i].begin(), V[i].end() );
    V[i].erase( unique( V[i].begin(), V[i].end()), V[i].end() );

    for(int j=U[i].size()-1,k=V[i].size()-1;j>-1&&k>-1;j--){
      state su = U[i][j];
      int sv = V[i][k];
      while( sv > su.t) {
        k--; if( k<0 ) break;
        sv = V[i][k];
      }
      if( k < 0 ) break;
      int nu = ids[P(i,sv)];
      int nv = ids[P(su.to,su.t+su.c)];
      G[nu].emplace_back( nv, abs(su.t-sv) );
    }
    for(int j=V[i].size()-1;j>0;j--){
      int nv = ids[P(i,V[i][j])];
      int nu = ids[P(i,V[i][j-1])];
      G[nu].emplace_back( nv, abs(V[i][j]-V[i][j-1]));
    }

  }
  
/*
    for( auto id : ids) {
      cout << id.first.first << " "<< id.first.second << " = " << id.second << endl;
      for( edge e : G[id.second] ) {
        cout << " -> " << e.to<< " "<< e.c << endl;
      }
    }

*/
  cout << dijk() << endl;
}

Measured memory_bytes: 47696
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
using namespace std;
int d[100010],n,a,b;
bool judge(long long mid)
{
    int sum=0;
    for(int i=0;i<n;i++)
    {
        long long t=(long long)d[i]-mid*b;
        if(t>0)
        {
            sum+=(int)ceil(t*1.0/(a-b));
            if(sum>mid||sum<0)
                return false;
        }
    }
    return true;
}
int main()
{
    long long l=0,r=0;
    cin>>n>>a>>b;
    for(int i=0;i<n;i++)
    {
        scanf("%d",&d[i]);
        r=max(r,(long long)d[i]);
    }
    while(l<r)
    {
        long long mid=l+r>>1;
        if(judge(mid))
        r=mid;
        else l=mid+1;
    }
    cout<<r<<endl;
}


Measured memory_bytes: 640