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

typedef long long int LL;
typedef long long int LLint;
typedef pair<int,int> intpair;
typedef pair<bool,bool> boolpair;
typedef pair<string,string> strpair;
typedef pair<LL,LL> LLpair;
typedef pair<double,double> doublepair;
typedef pair<float,float> floatpair;
typedef vector<int> intvector;
typedef vector<bool> boolvector;
typedef vector<string> strvector;
typedef vector<LL> LLvector;
typedef vector<double> doublevector;
typedef vector<float> floatvector;
#define wait(sec) usleep((sec) * 1000000)
#define ED return 0;
#define TEST cout << "OK" << endl;
#define UP(a,b) ((a+(b-1))/b)
#define SORT(vec) sort(vec.begin(),vec.end());
#define DOUBLECHANGE(count) cout << setprecision(count);
#define REV(vec) reverse(vec.begin(),vec.end());
#define ipow(x,y) LL(pow(x,y))
#define INF 999999999
const long long mod = 1000000007;

int main(){
//    random_device rnd;
//    mt19937 mt(rnd());
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> vec (3);
    for(int i = 0;i < 3;i++){
        cin >> vec[i];
    }
    SORT(vec);
    if(vec[1] == 5 && vec[0] == 5 && vec[2] == 7){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
        
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
int start;
inline int myabs(int x){
	return x<0?-x:x;
}
int _x,_y;
void Move(int &x,int &y,int len){
	int l1=myabs(x+len)+myabs(y);
	int l2=myabs(x-len)+myabs(y);
	int l3=myabs(x)+myabs(y+len);
	int l4=myabs(x)+myabs(y-len);
	int Min=min(min(l1,l2),min(l3,l4));
	if(l1==Min){
		cout<<"D";
		_x-=len;
		x+=len;
		return;
	}
	if(l2==Min){
		cout<<"U";
		_x+=len;
		x-=len;
		return;
	}
	if(l3==Min){
		cout<<"L";
		_y-=len;
		y+=len;
		return;
	}
	if(l4==Min){
		cout<<"R";
		_y+=len;
		y-=len;
		return;
	}
	while(1);
}
void solve(int &x,int &y){
	_x=0;_y=0;
	for(int i=35;i>=start;i--){
		Move(x,y,1ll<<i);
	}
	if(start){
		if(x||y){
			while(x<0){
				x++;
				_x--;
				cout<<"D";
			}
			while(x>0){
				x--;
				_x++;
				cout<<"U";
			}
			while(y<0){
				y++;
				_y--;
				cout<<"L";
			}
			while(y>0){
				cout<<"R";
				y--;
				_y++;
			}
		}else{
			cout<<"RL";
		}
	}
	cout<<endl;
}
int n;
int x[1005],y[1005];
signed main(){
//	freopen("data.in","r",stdin);
//	freopen("data.out","w",stdout); 
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x[i]>>y[i],swap(x[i],y[i]);
	for(int i=1;i<=n;i++)if(abs(x[i]+y[i])%2!=abs(x[1]+y[1])%2){
		puts("-1");return 0;
	}
	cout<<(abs(x[1]+y[1])%2?36:37)<<endl;
	start=1-abs(x[1]+y[1])%2;//start=0 -> odd start=1 -> even
	for(int i=35;i>=start;i--)cout<<(1ll<<i)<<" ";
	if(start)cout<<"1 1"<<endl;
	for(int i=1;i<=n;i++){
		solve(x[i],y[i]);
	}
	return 0;
}

Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	m := make(map[int]int, N)
	for i := 0; i < M; i++ {
		var c1, c2 int
		fmt.Scan(&c1, &c2)
		m[c1]++
		m[c2]++
	}
	for i := 1; i <= N; i++ {
		fmt.Println(m[i])
	}
}


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


int main() {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;

  int tm = 0;
  int ts = 0;
  float tc = 0;
  int m = 0;
  int s = 0;
  float c = 0;


  for(int i=0; 100*A*i<=F; i++){
    tm = 0;
    ts = 0;
    tc = 0;
    for(int j=0; 100*A*i+100*B*j<=F; j++){
      for(int k=0; 100*A*i+100*B*j+C*k<=F; k++){
        for(int l=0; 100*A*i+100*B*j+C*k+D*l<=F; l++){
          ts = C*k+D*l;
          tm = ts + 100*A*i+100*B*j;
          tc = ts*100 / (float(tm));

          if(C*k+D*l<=E*(A*i+B*j) && tc > c){
            s = ts;
            m = tm;
            c = tc;
          }
        }
      }
    }
  }

  if(m == 0 && s == 0) cout << 100*A << " " << 0 << endl;
  else cout << m << " " << s << endl;
  return 0;
}


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


using namespace std;

int main()
{
	int a, b, c;
	int ans = 0;


	cin >> a >> b >> c;

	for (;;)
	{
		if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1)
		{
			cout << ans << endl;
			break;
		}

		if (a == b && b == c)
		{
			cout << -1 << endl;
			break;
		}


		int tmp_a = a, tmp_b = b, tmp_c = c;
		a = (tmp_b + tmp_c) / 2;
		b = (tmp_a + tmp_c) / 2;
		c = (tmp_a + tmp_b) / 2;

		ans++;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int taro = 0;
        int hanako = 0;

        for(int i = 0; i < n; i++){
            int ret = compareTo(sc.next(), sc.next());
            if(ret > 0) taro += 3;
            else if(ret < 0) hanako += 3;
            else {
                taro += 1;
                hanako += 1;
            }
        }

        System.out.println(String.format("%d %d", taro, hanako));
    }

    /**
     *
     * @param str1
     * @param str2
     * @return str1 > str2 -> 1, str1 == str2 -> 0, str1 < str2 -> -1
     */
    public static int compareTo(String str1, String str2){
        int length1 = str1.length();
        int length2 = str2.length();
        if(length1 > length2){
            for(int i = 0; i < length2; i++){
                if(str1.charAt(i) > str2.charAt(i)) return 1;
                else if(str1.charAt(i) < str2.charAt(i)) return -1;
            }
            return 1;
        }
        else if(length1 < length2){
            for(int i = 0; i < length1; i++){
                if(str1.charAt(i) > str2.charAt(i)) return 1;
                else if(str1.charAt(i) < str2.charAt(i)) return -1;
            }
            return -1;
        }
        else {
            for(int i = 0; i < length1; i++){
                if(str1.charAt(i) > str2.charAt(i)) return 1;
                else if(str1.charAt(i) < str2.charAt(i)) return -1;
            }
            return 0;
        }
    }
}



Measured memory_bytes: 31424
S="012 345 678 036 147 258 048 246 "
A=sum([input().split()for i in range(3)],[])
for b in [input()for i in range(int(input()))]:
  if b in A:
    S=S.replace(str(A.index(b)),"")
print("YNeos"[S.find("  ")<0::2])

Measured memory_bytes: 3060
#include <stdio.h>

int main(void) {
  int a, b;
  scanf("%d%d", &a, &b);
  char s;
  if(a > b) s = '>';
  else if(a == b) s = '=';
  else s = '<';
  if(s != '=')printf("a %c b\n", s);
  else printf("a == b\n");
  return 0;
}


Measured memory_bytes: 2752
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll x;
    cin >> x;
    ll ft = x / 500;
    ll rest = x % 500;

    ll fy = rest / 5;

    cout << ft * 1000 + fy * 5 << endl;
}

Measured memory_bytes: 256
#include<iostream>//AT3676
#include<cstdio>
#include<cstring>
#include<string>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
using namespace std;
int main()
{
	int a,b,c,d,n;
	cin>>n;
	a=n/1000;b=n/100%10;c=n/10%10;d=n%10;
	if(a+b+c+d==7){printf("%d+%d+%d+%d=7\n",a,b,c,d);return 0;}
	if(a+b+c-d==7){printf("%d+%d+%d-%d=7\n",a,b,c,d);return 0;}
	if(a+b-c+d==7){printf("%d+%d-%d+%d=7\n",a,b,c,d);return 0;}
	if(a+b-c-d==7){printf("%d+%d-%d-%d=7\n",a,b,c,d);return 0;}
	if(a-b+c+d==7){printf("%d-%d+%d+%d=7\n",a,b,c,d);return 0;}
	if(a-b-c+d==7){printf("%d-%d-%d+%d=7\n",a,b,c,d);return 0;}
	if(a-b+c-d==7){printf("%d-%d+%d-%d=7\n",a,b,c,d);return 0;}
	if(a-b-c-d==7){printf("%d-%d-%d-%d=7\n",a,b,c,d);return 0;}
	return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <numeric>
#include <functional>
#include <math.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define INF ((int)1e9)
#define INFLL ((ll)1e18)
#define MOD (1000000007LL)


int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    vector<int> C(M);
    for (int m = 0; m < M; ++m) {
        int B;
        cin >> A[m] >> B;
        C[m] = 0;
        for (int b = 0; b < B; ++b) {
            int c;
            cin >> c;
            C[m] += 1<<(c-1);
        }
    }
    
    vector<int> DP(1<<N, INF);
    DP[0] = 0;
    for (int k = 0; k < 1<<N; ++k) {
        for (int m = 0; m < M; ++m) {
            DP[C[m]|k] = min(DP[C[m]|k], DP[k]+A[m]);
        }
    }
    int Ans = DP[(1<<N)-1];
    if (Ans < INF) {
        cout << Ans << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


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

int main() {
  int sx,sy,tx,ty; cin >> sx >> sy >> tx >> ty;
  int x = tx - sx, y = ty - sy;
  
  for (int i =0; i<y; i++) cout << 'U';
  for (int i =0; i<x; i++) cout << 'R';
  for (int i =0; i<y; i++) cout << 'D';
  for (int i =0; i<x; i++) cout << 'L';
  cout << 'L';
  for (int i =0; i<y+1; i++) cout << 'U';
  for (int i =0; i<x+1; i++) cout << 'R';
  cout << 'D'; cout << 'R';
  for (int i =0; i<y+1; i++) cout << 'D';
  for (int i =0; i<x+1; i++) cout << 'L';
  cout << 'U';
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    long long array[N];
    int i;
    for(i=0; i<N; i++) {
        cin >> array[i];
    }

    sort(array, array + N);
    long long wa = 0;
    for(i=0; i<N-K; i++) {
        wa += array[i];
    }
    cout << wa << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
  int n, m;
  int trout[1001], dice[1001];
  int i, j;
  int now;

  while (scanf("%d%d", &n, &m), n || m){
    now = 1;
    for (i = 1; i <= n; i++){
      scanf("%d", &trout[i]);
    }
    for (i = 1; i <= m; i++){
      scanf("%d", &dice[i]);
    }

    for (i = 1; now < n; i++){
      now += dice[i];
      now += trout[now];
    }

    printf("%d\n", i - 1);
  }

  return (0);
}

Measured memory_bytes: 1036
import java.util.Scanner;
import java.io.*;



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

    try{
      String s = readAll().toLowerCase();
      byte[] b = s.getBytes("US-ASCII");
      int[] al = new int[26];
      int a = 97;
      int z = 122;
      for(int i = 0; i < 26; i++){
        al[i] = 0;
      }

      for(int v: b){
        if(v >= a&& v <= z){
          al[v - a]++;
        }
      }
      for(int i = 0; i < 26; i++){
        System.out.printf("%c : %d\n", (char) (i + a), al[i]);
      }
      //System.out.printf("%s\n", s);
    }catch(Exception e){}
  }

  public static String readAll() throws IOException {
    StringBuilder builder = new StringBuilder();

    try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
        String string = reader.readLine();
        while(string != null){
            builder.append(string + System.getProperty("line.separator"));
            string = reader.readLine();
        }
    }

    return builder.toString();
}
}


Measured memory_bytes: 26332
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int main(){
  int n,w,d;
  while(cin >> n >> w >> d, w){
    vector<pii> v;
    v.push_back(pii(w,d));

    for(int i=0;i<n;i++){
      int id,s;
      cin >> id >> s; id--;
      pii cut = v[id];
      w = cut.first, d = cut.second;
      v.erase(v.begin() + id);

      s %= w+d;
      if(s<w){
	int nw1 = min(s,w-s), nw2 = max(s,w-s);
	v.push_back(pii(nw1,d));
	v.push_back(pii(nw2,d));
      }else{
	int nd1 = min(s-w,d-s+w), nd2 = max(s-w,d-s+w);
	v.push_back(pii(w,nd1));
	v.push_back(pii(w,nd2));
      }
    }

    vector<int> p;
    for(int i=0;i<(int)v.size();i++)p.push_back(v[i].first*v[i].second);
    sort(p.begin(), p.end());
    for(int i=0;i<(int)v.size();i++){
      cout << p[i] << (i+1==(int)p.size()?"\n":" ");
    }
  }
}

Measured memory_bytes: 1220
#　最小値を求めるDP　
#　Atcoder DP まとめコンテスト「A.Frog」　https://atcoder.jp/contests/dp/tasks/dp_a

N = int(input())
h = [int(x) for x in input().split()]

inf = float('inf')
dp = [inf] * N

dp[0] = 0
dp[1] = abs(h[1] - h[0]) #　1、２の初期値を設定

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

for i in range(2, N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[N - 1])

Measured memory_bytes: 14052
S=input()

l=len(S)

if l%2==0:
    count=l//2
    a=S[l//2-1]
    for i in range(l//2):
        if S[l//2-1-i]==a and S[l//2+i]==a:
            count+=1
        else:
            break
    print(count)
else:
    count=l//2+1
    a=S[l//2]
    for i in range(l//2):
        if S[l//2-1-i]==a and S[l//2+1+i]==a:

            count+=1
        else:
            break
    print(count)

Measured memory_bytes: 3188
//Patwari26
#include<bits/stdc++.h>
using namespace std;
#define int         long long
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
int expo(int base,int exponent,int mod){
    int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}
void solve(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    ll dp[k+1]={0};
    // ll diff[k+1]={0};
    rrep(i,k,1){
        ll nums=k/i;
        ll curr=0;
        curr=(curr+(i*expo(nums,n,hell))%hell)%hell;
        dp[i]=expo(nums,n,hell);
        for(int j=2*i;j<=k;j+=i){
            curr=(curr-(i*dp[j])%hell+hell)%hell;
            dp[i]=(dp[i]-dp[j]+hell)%hell;
        }
        ans=(ans+curr)%hell;
    }
    // rep(i,1,k) ans=(ans+dp[i])%hell;
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 4432
#include<bits/stdc++.h>
 
#define si(x) scanf("%d",&x)
#define sf(x) scanf("%lf",&x)
#define sl(x) scanf("%lld",&x)
#define pr(x) printf("%d\n",x)
#define prll(x) printf("%lld\n",x)
 
#define ll long long int
#define ull unsigned long long int
#define F first
#define S second
 
#define rep(i,x,y) for(int i=x;i<y;i++)
#define ii pair<int,int> 
#define pll pair<ll,ll> 
#define vi vector<int> 
#define vvi vector< vi > 
#define vl vector<long long int>
#define vvl vector< vl >
#define vii vector< ii >
#define vvii vector< vii >
#define priority_queue pq;
#define sz(a) ll((a).size()) 
#define pb push_back 
#define mp make_pair
 
#define ROUNDOFFINT(d) d = (int)((double)d + 0.5)
#define SET(a,b) memset(a,b,sizeof(a))
#define all(c) (c).begin(),(c).end() 
#define tr(i,c) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) ((c).find(x) != (c).end()) 
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ison(x,i) (((x) >> (i)) & 1)	//checks if ith bit is on
#define set0(x,i) (x & ~(1 << i))		//set ith bit in x to be zero
#define clr(a) memset(a,0,sizeof(a))
 
#define MOD 1000000007
#define INF 4000000000000000000
#define MAX 1000000+5
#define BASE 31
using namespace std;
 
 
int main() {
	ll n,a,b;
	sl(n); sl(a); sl(b);
	if(a<=b)
	{
		ll ans=((n-1)*b+a)-(b+(n-1)*a)+1;
		ans=max(0ll,ans);
		prll(ans);
	}
	else
	{
		prll(0ll);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

long long calc(int num)
{
    long long ans = num;
    --num;
    while (num != 0) {
        ans *= num;
        ans %= MOD;
        --num;
    }
    return ans;
}

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

    long long ans;
    if (abs(N-M) > 1)
        ans = 0ll;
    else if (N == M)
        ans = (((calc(N) * calc(M)) % MOD) * 2) % MOD;
    else
        ans = (calc(N) * calc(M)) % MOD;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  string S,T,Text;
  
  cin>>S>>T;
  for(int i=0;i<S.size();i++){
    if(T==S.substr(i)+S.substr(0,i)){//最初はそのまま、次は1個が前にいって
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#define EPS (1e-7)
using namespace std;


long long lcm(long long n, long long m) {
	long long r,x,tmp;
	x = m * n;
	/* 自然数 a > b を確認・入替 */
	if (n < m) {
		tmp = n;
		n = m;
		m = tmp;
	}

	/* ユークリッドの互除法 */
	r = n % m;
	while (r != 0) {
		n = m;
		m = r;
		r = n % m;
	}
	return x / m;

}



int main() {

	string S;
	cin >> S;
	
	string ans="No";
	sort(S.begin(), S.end());

	if (S[0] == S[1] && S[2] == S[3] && S[1] != S[2]) {
		ans = "Yes";
	}


	cout << ans << endl;

	return 0;
}


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

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> A(n);
    for (int i = 0; i < n; ++i) {
        A[i] = k - q;
    }
    for (int i = 0; i < q; ++i) {
        int a;
        cin >> a;
        A[a-1]++;
    }
    for (int i = 0; i < n; ++i) {
        if (A[i] > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int64_t H,W;
  cin >> H >> W;
  if(H==1 || W==1){
    cout << 1 << endl; 
  }
  else{
  if(H%2==1 && W%2==1) cout << (H*W+1)/2 <<endl;
  else cout << H*W/2 << endl;
  } 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void out(vector<int> a) {
  int n = a.size();
  for (int i = 0; i < n - 1; i++) cout << a[i] << ' ';
  cout << a[n - 1] << '\n';
}
signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  out(a);
  for (int i = 1; i < n; i++) {
    int v = a[i];
    int j = i - 1;
    while (j >= 0 and a[j] > v) {
      a[j + 1] = a[j];
      j--;
    }
    a[j + 1] = v;
    out(a);
  }
  return 0;
}


Measured memory_bytes: 3192
// ABC168B - 

#include <bits/stdc++.h>
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;

int main() {
	int K;
	string S;
	cin >> K >> S;

	if (S.size() <= K) {
		cout << S << endl;
	} else {
		cout << S.substr(0, K) << "..." << endl;
	}

	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define int long long
#define double long double
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N;
VPII g[100010];
int ans[100010];
int K;


void dfs(int v, int p, int c){
    rep(i, 0, SZ(g[v])){
        if(g[v][i].first == p) continue;
        c++;
        c %= K;
        if(ans[g[v][i].second] == -1) ans[g[v][i].second] = c;
        dfs(g[v][i].first, v, ans[g[v][i].second]);
    }
}


signed main(){
    cin >> N;
    rep(i, 0, N-1){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb({ b, i });
        g[b].pb({ a, i });
    }

    fill(ans, ans+N, -1);
    rep(i, 0, N) chmax(K, SZ(g[i]));
    dfs(0, -1, -1);

    cout << K << endl;
    rep(i, 0, N-1) cout << ans[i]+1 << endl;

    return 0;
}

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

using namespace std;

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

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

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	n<1000 ? cout<<"ABC"<<'\n' : cout<<"ABD"<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string a,b,c;
  cin>>a>>b>>c;
  
  cout<<a[0]<<b[1]<<c[2]<<endl;
  return 0;
}

Measured memory_bytes: 256
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

a, b = inl()
import math
print(math.ceil((a + b) / 2))


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

using namespace std;

struct store{
	long long int price;
	long long int amount;
};

bool acompare(store a,store b){
	return a.price< b.price;
}

int main(){
	long int n,m;
	scanf("%ld %ld",&n,&m);
	long long int sum = 0;
	long long int buy = 0;
	//long long int store[n];
	struct store store[n];
	long long int i,j;
	for(i=0;i<n;i++){
		scanf("%lld %lld",&store[i].price,&store[i].amount);
	}
	
	sort(store,store+n,acompare);
	/*for (i=0;i<n;i++){
		printf("%d %d\n",store[i][0],store[i][1]);
	}*/
	long long int visit = 0;
	while(buy < m) {
		if(m-buy <= store[visit].amount) {
			sum +=(m-buy) * store[visit].price;
		}
		else sum += store[visit].price*store[visit].amount;
		buy+=store[visit].amount;
		visit++;
	}
	printf("%lld\n",sum);
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int n;
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a == 7){
		if (b == 5 && c == 5){
			a = 1;
		}
	}
	else if (b == 7){
		if (a == 5 && c == 5){
			a = 1;
		}
	}
	else if (c == 7){
		if (a == 5 && b == 5){
			a = 1;
		}
	}
	
	if (a == 1){
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	
	return (0);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000000007;
const int MAX = 201000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; 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;
  }
}

long long COM(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n,k; cin >> n >> k;
  COMinit();
  FOR(i, 1, k+1){
    cout << (ll) (COM(n-k+1,i) * COM(k-1,i-1))%MOD << endl;
  }
}


Measured memory_bytes: 4992
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

using namespace std;

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

	string s, x;
	int t;

	map<string, int> finished;

	int now = 0;
	for (int i = 0; i < n; i++) {
		cin >> s >> t;
		now += t;
		finished[s] = now;
	}

	cin >> x;
	int ans = finished[s] - finished[x];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

AB_list = []
for i in range(N):
    AB = list(map(int, input().split()))
    AB_list.append(AB)
    
AB_list = sorted(AB_list, key=lambda x: x[0])

sum_drink = 0
sum_money = 0
num = 0
while True:
    if sum_drink + AB_list[num][1] <= M:
        sum_drink += AB_list[num][1]
        sum_money += AB_list[num][0] * AB_list[num][1]
        num += 1
        if num == N:
            break
    else:
        tmp_drink = M - sum_drink
        sum_money += AB_list[num][0] * tmp_drink
        break

print(sum_money)

Measured memory_bytes: 29792
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;


int main() {
  int n;
  cin>>n;
  vin s(n);
  rep(i,n) cin>>s[i];
  //////////////
  int sum=0;
  rep(i,n) sum+=s[i];
  ///////
  
  rep(i,n){
    if(s[i]%10==0){
      s[i]=0; 
    }
    
  }
  sort(all(s));
  rep(i,n){
  	if(sum%10==0){
  	   sum-=s[i];
  	}
    else break;
  }
  if(sum%10!=0)
  cout<<sum<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    cout<<48-n<<endl;
}

Measured memory_bytes: 3592
/**
 * @Author:      H S-J
 * @DateTime:    2017-12-22 21:16:07
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;
#define MST(a, b) memset(a, b, sizeof(a));
#define CLR(a) MST(a, 0);
#define DBG(x) cout << '#' << " = " << (x) << endl;
#define ALL(x) x.begin(), x.end()
#define INS(x) inserter(x, x.begin())
#define lson(x) (x) << 1
#define rson(x) (x) << 1|1
#define pb push_back
#define rep(x, y, z) for (int x = y; x < z; ++x)
#define ech(x, y, z) for (auto x = z.begin(), y = z.end(); x != y; ++x)
#define lowbit(x) (x & (-x))
#define opr operator
#define _st first
#define _nd second
#define prior_q1(x) priority_queue<x>
#define prior_q2(x) priority_queue<x, vector<x>, greater<x> >
typedef long long LL;
typedef stringstream strstm;
struct FastIO {
    static const int S = 1310720;
    int wpos;
    char wbuf[S];
    FastIO() : wpos(0) {}
    inline int xchar() {
        static char buf[S];
        static int len = 0, pos = 0;
        if (pos == len)
            pos = 0, len = fread(buf, 1, S, stdin);
        if (pos == len) return -1;
        return buf[pos ++];
    }
    inline int xuint() {
        int c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x;
    }
    inline int xint() {
        int s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline LL xlongint() {
        LL s = 1, c = xchar(), x = 0;
        while (c <= 32) c = xchar();
        if (c == '-') s = -1, c = xchar();
        for (; '0' <= c && c <= '9'; c = xchar()) x = x * 10 + c - '0';
        return x * s;
    }
    inline void xstring(char *s) {
        int c = xchar();
        while (c <= 32) c = xchar();
        for (; c> 32; c = xchar()) * s++ = c;
        *s = 0;
    }
    inline void wchar(int x) {
        if (wpos == S) fwrite(wbuf, 1, S, stdout), wpos = 0;
        wbuf[wpos ++] = x;
    }
    inline void wint(LL x) {
        if (x < 0) wchar('-'), x = -x;
        char s[24];
        int n = 0;
        while (x || !n) s[n ++] = '0' + x % 10, x /= 10;
        while (n--) wchar(s[n]);
    }
    inline void wstring(const char *s) {
        while (*s) wchar(*s++);
    }
    ~FastIO() {
        if (wpos) fwrite(wbuf, 1, wpos, stdout), wpos = 0;
    }
} io;
int f(int n) {
	int res = 0;
	while(n) {
		res += n%10;
		n /= 10;
	}
	return res;
}
int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);
	int n, a, b;
	cin >> n >> a >> b;
	LL ans = 0;
	rep(i, 1, n+1) {
		int tmp = f(i);
		if(tmp >= a && tmp <= b) ans += i;
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i,n) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < n; i++) ans = (ans+v[i])/2;
  printf("%.10f\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,r;cin >> n >> r;
    cout << r+100*max(0,10-n) << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;

int main(){
  string s;
  cin >> s;
  int cnt = 0;
  for(int i = 0; i < s.size() - 1; i++){
    if(s[i] != s[i + 1]){cnt++;}
  }
  cout << cnt << endl;
}

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

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

    std::vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        std::cin >> A[i];
    }

    int ans = 0;
    for (int i = 0; i < N; i++)
    {
        while (A[i] % 2 == 0)
        {
            A[i] /= 2;
            ans++;
        }
    }

    std::cout << ans << std::endl;
}

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

int main() {
    int a, b, c;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    std::vector<int> v {a, b, c};
    std::sort (v.begin(), v.end());
    std::cout << v[0] << " " << v[1] << " " << v[2] << std::endl;
}


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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

int N,H,W;
int main() {
    cin>>N>>H>>W;
    p(max(0,(N-H+1)*(N-W+1)));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[m];
		int[] d = new int[m];
		for(int i = 0;i < n;i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		for(int i = 0;i < m;i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}
		int min,num;
		for(int i = 0;i < n;i++) {
			int x = a[i] - c[0];
			int y = b[i] - d[0];
			if(x<0) {
				x = x * -1;
			}
			if(y<0) {
				y = y * -1;
			}
			min = x + y;
			num=1;
			int z = 0;
			for(int k = 1;k < m;k++) {
				x = a[i] - c[k];
				y = b[i] - d[k];
				if(x<0) {
					x = x * -1;
				}
				if(y<0) {
					y = y * -1;
				}
				z = x +y ;
				if(min > z) {
					min = z;
					num = k+1;
				}
			}
			System.out.println(num);
		}
	}

}

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

#define DeltaCube23 ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define minimum(a) *min_element(a.begin(), a.end())
#define maximum(a) *max_element(a.begin(), a.end())
#define MOD 1000000007
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i >= (b); i--)

typedef long long int lli;

using namespace std;

const int mx=2e6+5;

int main()
{
    DeltaCube23
	int t=1;
	//cin>>t;
	while(t--)
	{
	    string s,t;
	    cin>>s;
	    cin>>t;
	    int n=s.length();
	    lli res=0;
	    forf(i,0,n)
	    if(s[i]!=t[i])
	    res++;
	    cout<<res<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
ll a[1000005],ch[1000005];
void solve(){
	ll n,res=0;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a[x]++;
	}
	for(ll i=1;i<=1000000;i++)
	if(a[i])
	for(ll j=2*i;j<=1000000;j+=i)
	ch[j]=1;
	for(ll i=1;i<=1000000;i++)
	if(a[i]==1&&ch[i]==0)
	res++;
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	ll qc=1;
    for(ll i=1;i<=qc;i++)
    solve();
}


Measured memory_bytes: 19268
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextLine()) {
			String str = sc.nextLine();
			String ans = "";
			for(int i=0;i<str.length();i++) {
				char c = str.charAt(i);
				if(c=='@') {
					char t = str.charAt(i+1);
					for(int j=0;j<t-'0';j++) {
						ans += str.charAt(i+2);
					}
					i += 2;
				}else {
					ans += c;
				}
			}
			System.out.println(ans);
		}
	}
}



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

#define Inf ll(1e18)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=505;
int n;
ll a[maxn][maxn],sum[2][maxn][maxn],dp[maxn][maxn],ans;
void ckmax(ll &a,ll b){
	if(b>a)a=b;
}
ll getval(int tp,int x1,int x2,int y1,int y2){
	if(x1>x2||y1>y2)return 0;
	return sum[tp][x2][y2]+sum[tp][x1-1][y1-1]-sum[tp][x2][y1-1]-sum[tp][x1-1][y2];
}

int main(){
	scanf("%d",&n);
	REP(i,n)REP(j,n){
		if(i==j)a[i][j]=0;
		else{
			scanf("%lld",&a[i][j]);
			if(i>j)sum[0][i][j]=a[i][j];
			else sum[1][j][i]=a[i][j];
		}
	}
	REP(i,n)REP(j,n)sum[0][i][j]+=sum[0][i][j-1],sum[1][i][j]+=sum[1][i][j-1];
	REP(i,n)REP(j,n)sum[0][i][j]+=sum[0][i-1][j],sum[1][i][j]+=sum[1][i-1][j];
	REP(i,n)REP(j,n)dp[i][j]=-Inf;
	dp[1][1]=0;
	REP(i,n)REP(j,n)if(dp[i][j]!=-Inf){
		ckmax(ans,dp[i][j]+getval(0,j+1,n,i,n)+getval(1,j+1,n,1,j-1));
		for(int k=j+1;k<=n;k++){
			if(k==1)continue;
			ll cur1=getval(0,k,k,j,k-1)+getval(0,j+1,k-1,i,k-1);
			ll cur2=getval(1,k,k,1,k-1)+getval(1,j+1,k-1,1,j-1);
			ckmax(dp[j][k],dp[i][j]+cur1+cur2);
		}
	}
	printf("%lld\n",sum[0][n][n]+sum[1][n][n]-ans);
	return 0;
} 

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

typedef long long LL;

#define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; i++)
#define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; i--)

template <typename Tp> void in(Tp &x) {
	char ch = getchar(), f = 1; x = 0;
	while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
	if (ch == '-') ch = getchar(), f = -1;
	while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	x *= f;
}

template <typename Tp> void out(Tp x) {
	if (x > 9) out(x / 10);
	putchar(x % 10 + '0');
	return;
}

template <typename Tp> Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;}
template <typename Tp> Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;}
template <typename Tp> bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);}
template <typename Tp> bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);}

const int MAXN = 100010;

int n;
int A[MAXN];

int abs(int x) {return x < 0 ? -x : x;}

int main()
{
	in(n);
	FOR(i, 1, n) in(A[i]);

	std::sort(A + 1, A + n + 1);

	int min = 0x3f3f3f3f, son;
	
	FOR(i, 1, n - 1) {
		if (abs(A[i] - A[n] / 2) <= min) min = abs(A[i] - A[n] / 2), son = A[i];
	}

	printf("%d %d\n", A[n], son);
	
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	string N;
	
	cin>>N;
	
	if(count(N.begin(), N.end(), '7')) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3636
n=int(input())
d,x=list(map(int,input().split()))
a=[]
for i in range(n):
    a.append(int(input()))
# 1, Ai+1, 2Ai+1, 3Ai+1
# 1, 3, 5, 7
for i in a:
    a1=0
    for j in range(1,d+1):
        if j==(a1*i+1):
            a1+=1
            x+=1
print(x)


Measured memory_bytes: 3060
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/

#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
ll gcd(ll a, ll b) {
	if(b == 0) return a;
	return gcd(b, a % b);
}

// const ll MAX_N = 1e5;
// ll N;
// ll h[MAX_N];
// ll dp[MAX_N+1]; // メモ化テーブル
 
// // i番目以降の品物から重さの総和がj以下になるように選ぶ
// void rec(ll i){
// 	if (i==0) dp[i] = 0;
// 	else if (i==1) dp[i] = abs(h[1]-h[0]);
// 	else dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
// 	return;
// }
 
 
int main() {
	// 入力
	ll N;cin>>N;
	ll A[N];REP(i,N)cin>>A[i];
	
	// 解法
	ll X[N]= {0};
	REP(i,N){
		if (i==0)X[i] = 0;
		else{
			X[i] = A[i-1] - X[i-1];
		}
	}
	// REP(i,N){
	// 	printf("%lld ", X[i]);
	// }
	// printf("\n");
	// REP(i,N){
	// 	printf("%lld ", A[i]);
	// }
	// printf("\n");
	ll X_sum = 0;
	REP(i,N) X_sum += X[i]*2;
	ll A_sum = 0;
	REP(i,N) A_sum += A[i];
	// printf("X sum: %lld, A sum: %lld\n", X_sum, A_sum);
	ll X0 = (A_sum - X_sum)/2;
	// printf("X0: %lld\n", X0);
	REP(i,N){
		if (i%2==0) printf("%lld ", (X[i]+X0)*2);
		else printf("%lld ", (X[i]-X0)*2);
	}
	printf("\n");
	
	// //出力
	// cout << ans << endl;
}


Measured memory_bytes: 2816
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long n = sc.nextLong();
        System.out.println(a*Math.min(b-1,n)/b);
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }
    
    public void close() throws Exception{
        this.reader.close();
        return;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public double nextDouble() {
         return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}

Measured memory_bytes: 25308
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace test
{
	class MainClass
	{
		public static void Main(string[] args)
		{
			int N = int.Parse(Console.ReadLine());
			int n = (int)Math.Ceiling(((-1 + Math.Sqrt(8 * N + 1)) / 2));
			int p = n;
			Queue<int> q = new Queue<int>();
			q.Enqueue(n);
			for (int i = n - 1; i > 0; i--)
			{
				if (p < N && p + i <= N)
				{
					p += i;
					q.Enqueue(i);
				}
				if (p == N)
					break;
				
			}
			while (q.Count != 0)
			{
				Console.WriteLine(q.Dequeue());
			}

		}
	}
}


Measured memory_bytes: 3032
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a;
  for(int i = 0; i < n; i++){
    int k;
    cin >> k;
    a.push_back(k);
  }
  sort(a.begin(),a.end(),greater<int>());
  int sum_a = 0, sum_b = 0;
  for(int i = 0; i < n; i++){
    if(i%2==0){
      sum_a += a[i];
    }else{
      sum_b += a[i];
    }
  }
  cout << sum_a - sum_b << endl;
}


Measured memory_bytes: 256