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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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; }



int n;
string s[101010];
void solve(){
	cin >> n;
	i64 cnt[5] = {};
	for(int i = 0; i < n; i++){
		cin >> s[i];
		if(s[i][0] == 'M') cnt[0]++;
		if(s[i][0] == 'A') cnt[1]++;
		if(s[i][0] == 'R') cnt[2]++;
		if(s[i][0] == 'C') cnt[3]++;
		if(s[i][0] == 'H') cnt[4]++;
	}
	
	i64 ans = 0;
	for(int i = 0; i < 5; i++){
		for(int j = i+1; j < 5; j++){
			for(int k = j+1; k < 5; k++){
				ans += cnt[i]*cnt[j]*cnt[k];
			}
		}
	}
	cout << ans << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

int main(){
    int n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
    return 0;
}

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

int main(void){

  char s[101];
  scanf("%s", s);
  int c = 0;
  int cf = 0;
  for (int i = 0; i < strlen(s); i++) {
    if (s[i] == 'C') {
      c = 1;
    }
    if (c == 1 && s[i] == 'F') {
      cf = 1;
      break;
    }
  }
  if (cf == 1) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 128
n, p = [int(i) for i in input().split()]
s = [int(i) for i in list(input())][::-1]
summ  = 0
ans = 0
cnt = [0]*p # あまりの部屋
cnt[0] = 1
for i in range(n):
    d = s[i]*pow(10, i ,p)
    summ = (summ + d) %p
    cnt[summ] +=1

if p in [2,5]: # 10の因数は別処理
    if p == 2:
        ok_list = [0,2,4,6,8]
    if p == 5:
        ok_list = [0,5]
    for i in range(n):
        d = s[i]
        if d in ok_list:
            ans += n-i
else: # 他のは,あまりが同じものは差し引けばあまりが0になるのでpで割り切れる判定
    for i in range(p):
        ans += cnt[i] * (cnt[i]-1)//2 # nC2の計算

print(ans)

Measured memory_bytes: 12200
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;
int main(void){
    ll N , K ;
    cin >> N >> K ;
    ll A[N] ;
    bool ans[N - K] ;
    for(ll i = 0 ; i < N ; i++){
        cin >> A[i] ;
    }


    for(ll j = 0 ; j < N - K ; j++){
        if(A[j] >=A[K+j] ){
            cout << "No" << endl;
        }else{
            cout << "Yes"<< endl;
        }

    }
  
}

Measured memory_bytes: 5184
#include "bits/stdc++.h"
using namespace std;

#define pb  push_back
#define mp  make_pair
#define ll  long long
#define itr iterator

typedef pair<ll,ll> pii;

const ll MAX=2e5+9;
const ll INF=1e12;

long long N,A,B,C,D,l,r,dif_1,dif_2;

signed main()
{
	ios_base::sync_with_stdio(false);

	cin>>N>>A>>B>>C>>D;
	for(long long it=0;it<=N-2;it++)
	{
		l=A+it*C-(N-2-it)*D;
		r=A+it*D-(N-2-it)*C;
		dif_1=abs(B-l);
		dif_2=abs(B-r);
		if(dif_1>dif_2)
			swap(dif_1,dif_2);
		if(dif_2<C or dif_1>D)
			continue;
		return cout<<"YES",0;
	}	 
	cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 101
#define INF 1000000

int main(void) {
  int n, m, i, j, k;
  int sans, tans, sres, tres;
  int ssum, tsum;
  int s[MAX], t[MAX];
  while (1) {
    scanf("%d %d", &n, &m);
    if (n == 0 && m == 0) return 0;
    for (i = 0; i < n; i++) {
      scanf("%d", s + i);
    }
    for (i = 0; i < m; i++) {
      scanf("%d", t + i);
    }
    ssum = 0;
    tsum = 0;
    for (i = 0; i < n; i++) {
      ssum += s[i];
    }
    for (i = 0; i < m; i++) {
      tsum += t[i];
    }
    sans = INF, tans = INF;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++) {
        sres = ssum - s[i] + t[j];
        tres = tsum + s[i] - t[j];
        if (sres == tres&& s[i] + t[j] < sans + tans) {
          sans = s[i];
          tans = t[j];
        }
      }
    }
    if (sans != INF) {
      printf("%d %d\n", sans, tans);
    } else {
      puts("-1");
    }
  }
}



Measured memory_bytes: 2072
#include <cstdio>


int main(){

    int X,Y;
    scanf("%d%d",&X,&Y);

    bool ok=false;
    for(int i=0;i<=X;i++)
        if (i*2+(X-i)*4==Y) ok=true;
    
    if (ok) puts("Yes");
    else puts("No");

    return 0;
}

Measured memory_bytes: 1660
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = Long.toString(in.nextLong() + 1);
            int max = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) > '0') {
                    String t = s.substring(0, i) + (char) (s.charAt(i) - 1);
                    max = Math.max(max, sum(t) + 9 * (s.length() - i - 1));
                }
            }
            out.println(max);
        }

        int sum(String s) {
            int sum = 0;
            for (char c : s.toCharArray()) {
                sum += c - '0';
            }
            return sum;
        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                String line = null;
                try {
                    line = br.readLine();
                } catch (IOException e) {
                }
                st = new StringTokenizer(line);
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 23380
// AtCoder ABC064 D - Insertion
// 2020.1.25 bal4u

#include <stdio.h>

#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)

int in() {  // 整数の入力
	int n = 0; int c = gc();
	if (c == '-') {	c = gc();
		do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
		return -n;
	}
	do n = 10*n + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

void ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	do *s = gc();
	while (*s++ > ' ');
	*(s-1) = 0;
}

void outs(char *s) { while (*s) pc(*s++); }

int N;
char buf[220];
char *top = buf+110;

int main()
{
	int k;
	char *p;
	N = in();
	ins(p = top);
	k = 0;
	while (*p) {
		if (*p == '(') k++;
		else {
			if (k > 0) k--;
			else *--top = '(';
		}
		p++;
	}
	while (k-- > 0) *p++= ')';
	
	outs(top);
	pc('\n');
	return 0;
}


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

int main()
{
	string s;
	cin>>s;
	long long a = 0;
	for (int i = 0; i < s.length(); ++i)
	{
		a += s[i]-'0';
	}
	if(a%9==0)
		printf("Yes\n");
	else
		printf("No\n");

	
	return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>

int abs(int x){
    if(x>0) return x;
    else return -x;
}

long long factorial(int x){
    if(x==0) return 1;
    else return x*((factorial(x-1))%1000000007)%1000000007;
}

long long combi(int m, int n){
    if(abs(m-n)>=2){
        return 0;
    }else if(abs(m-n)==1){
        return (factorial(m)*factorial(n))%1000000007;
    }else{
        return (2*factorial(m)*factorial(n))%1000000007;
    }
}

int main(){
    int n, m;
    scanf("%d%d",&n,&m);
    printf("%lld\n", combi(m, n));
    return 0;
    
}

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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n, 0);
    int ans = n;
    int m, p;
    rep(i, k)
    {
        cin >> m;
        rep(j, m)
        {
            cin >> p;
            if (a[p - 1] == 0)
            {
                ans--;
            }
            a[p - 1]++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <utility>
#include <set>
#include <unordered_map>
#include <cassert>

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define IPSILON 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

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


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args)  {
		Scanner scan =new Scanner(System.in);
		int n = Integer.parseInt(scan.nextLine());
		int[] a = new int [n];
		for (int i = 0;i < n;++i){
			a[i]=Integer.parseInt(scan.next());
		}
		Arrays.sort(a);
		int target=a[0];
		int count = 1;
		int ans=0;
		for(int i = 1;i < n;++i){
			if (target != a[i]){
				if (count != target){
					if (count>target){
						ans+=count-target;
					}else{
						ans+=count;
					}
				}
				count=1;
				target=a[i];
			}else{
				++count;
			}
		}

		if (count != target){
			if (count>target){
				ans+=count-target;
			}else{
				ans+=count;
			}
		}
		System.out.print(ans);

	}
}
//end


Measured memory_bytes: 50844
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int, int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {

    
    int n,k;
    cin>>n>>k;
    ll ans=k;
    rep(i,n-1)ans*=k-1;
    fin(ans);

}

Measured memory_bytes: 256
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
r = [0 for _ in range(n+1)]
ans = 0
for i in range(1,n+1):
    x = a[i-1]
    r[i] = r[i-1] + (x*(x+1))/2/x #期待値
    if i+1 >=k:
        ans = max(ans,r[i]-r[i-k])
print(ans)


Measured memory_bytes: 25060
n = int(input())
a = list(map(int,input().split()))
m = 0
while True:
	l = 0
	for j in range(n):
		l += a[j] % 2
	if l == 0:
		m += 1
		for i in range(n):
			a[i] /= 2
	else:
		break
print(m)

Measured memory_bytes: 2940
A,B,C,D = input()
for a in '+-':
    for b in '+-':
        for c in '+-':
            f = "{0}{1}{2}{3}{4}{5}{6}".format(A,a,B,b,C,c,D)
            if eval(f)==7:
                print(f + '=7')
                exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

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

  set<int> p;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    p.insert(a);
  }

  for (int i = 0; i < 100; i++) {
    int xm = x - i;
    if (p.count(xm) == 0) {
      cout << xm << endl;
      return 0;
    }

    int xp = x + i;
    if (p.count(xp) == 0) {
      cout << xp << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3628
#include <iostream>

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


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

int main() {
	
	char b;
	cin >> b;
	if(b == 'A') puts("T");
	if(b == 'C') puts("G");
	if(b == 'G') puts("C");
	if(b == 'T') puts("A");
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    int h;

    cin >> n;
    cin >> h;

    int counter = 1;
    int max = h;

    for (int i = 1; i < n; i++) {
        cin >> h;
        if (max <= h) {
            max = h;
            counter++;
        }
    }

    cout << counter << endl;

    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using ii = pair<int, int>;

int main(){
	ios::sync_with_stdio(0);
	ll n;
	cin >> n;
	ll res = 1;
	for(ll i=1; i*i<=n; ++i)
		if(n%i==0) res = i;
	ll ans = res-1 + n/res-1;
	cout << ans << endl;
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>

#include <complex>
//定数
#define MOD 1000000007
//マクロ
#define rep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))

#define vsort(v) sort((v).begin, (v).end);


typedef unsigned long long int ull;
typedef long long lint;

using namespace std;














int main(){
    int A, P;
    


    //入力
    cin >> A >> P;

    cout << (A*3+P)/2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

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

	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	printf("%d\n", min(a*n, b));
}


Measured memory_bytes: 256
/*
ID: alec3
LANG: C++14
PROG:
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

int pct(int x) { return __builtin_popcount(x); }

using namespace std;

//ifstream fin("maze1.in");
//ofstream fout("maze1.out");



int main()
{
    io;
    double d, t, s;
    cin >> d >> t >> s;

    if (d /t <= s)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3772
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const ll INF = 3e18;
int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int> p(n);
    vector<ll> c(n);

    for(int i = 0;i < n;i++){
        cin >> p[i];
        p[i]--;
    }
    
    for(int i = 0;i < n;i++)cin >> c[i];

    vector<bool> used(n,false);
    ll ans = -INF;
    for(int i = 0;i < n;i++){
        int now = i;
        vector<ll> costs;
        while(used[now] == false){
            costs.push_back(c[now]);
            used[now] = true;
            now = p[now];
        }
        
        if(costs.size() == 0)continue;
        vector<ll> max_sum(costs.size()+1,-INF);

        for(int j = 1;j <= costs.size();j++){
            ll now_sum = 0;
            for(int l = 0;l < j;l++)now_sum += costs[l];
            max_sum[j] = now_sum;
            for(int l = 1;l < costs.size();l++){
                now_sum -= costs[l-1];
                now_sum += costs[(l+j-1) % costs.size()];
                max_sum[j] = max(max_sum[j],now_sum);
            }
        }


        for(ll j = 1;j <= costs.size();j++){
            ll rem = max_sum[j];
            ll cnt = k - j;
            if(cnt >= 0){
                ans = max(ans,rem);
                ans = max(ans,cnt / (ll)costs.size() * max_sum[costs.size()] + rem);
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3780
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
//================================================

int a = 0, b = 0, c, d, n, k=0;
string s, t;


int main()
{
	cin >> s;
	sort(all(s));
	if (s[0] == s[1] && s[1] != s[2] && s[2] == s[3])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      ArrayList<String> s = nextCharArray();
      s.set(3, "8");
      myout(myconv(s, 0));
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 33384
#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
    vector<int> v(3);
    for(auto& e : v)
        cin >> e;
    sort(v.begin(), v.end());

    if(v[0] == 5 && v[1] == 5 && v[2] == 7)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i) >> b.at(i);
    }
    vector<long long> c(m), d(m);
    for (int i = 0; i < m; i++) {
        cin >> c.at(i) >> d.at(i);
    }

    for (int i = 0; i < n; i++) {
        long long minimum = 1ll<<60;
        int index = 0;
        for (int j = 0; j < m; j++) {
            long long md = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j)); 
            if (minimum > md) {
                minimum = md;
                index = j + 1;
            }
        }
        cout << index << endl;
    }
}   

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

int main()
{
	int n;
	int i = 0, k = 0;
	long long int j = 0;
	long long int ans = 0;

	cin >> n;

	vector<int> a(n), b(n), c(n);

	for (i = 0; i < n; i++)cin >> a[i];
	for (i = 0; i < n; i++)cin >> b[i];
	for (i = 0; i < n; i++)cin >> c[i];

	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	sort(c.begin(), c.end());

	for (i = 0; i < n; i++) {
		while (a[j] < b[i] && j < n)j++;
		while (c[k] <= b[i] && k < n)k++;
		ans += j * (n - k);
	}

	cout << ans << endl;
	
	return 0;

}

Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <iomanip>
#include <numeric>
using namespace std;


main()
{
    int n ;
    string s; cin>>s;
    n=s.size();
    long long ans=0;
    map<int,int> ma;
    long long now=0;
    ma[0]++;
    reverse(begin(s),end(s));
    long long te=1;

    for(char c:s)
    {
        now+=(c-'0')*te;
        now%=2019;
        ans+=ma[now]++;
        (te*=10)%=2019;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3772
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int a,b;cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else if(a>=6)cout<<b/2<<endl;
    else cout<<0<<endl;
}










Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////


ll a,b,c,d[100005] = {},n,m;
string s,t;

int main(){


    cin >>  a >> b;

    b += a*3;

    P(b/2);
    return  0;
}


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

int work(int x, int y) {
  if (x < y) return 0;
  if (x % y == 0) return x / y;
  int d = x / y + 1;
  int nxt_x = y * (x / y);
  if ((x - nxt_x) % d == 0) return nxt_x / y;
  x -= ((x - nxt_x) / d + 1) * d;
  return work(x, y);
}

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

  int sg = 0;
  for (int i = 1; i <= N; ++i) {
    int A, K;
    scanf("%d%d", &A, &K);
    sg ^= work(A, K);
  }
  if (sg == 0) puts("Aoki");
  else puts("Takahashi");
  return 0;
}


Measured memory_bytes: 128
n,k=map(int,input().split())
B=[0]*100001

for i in range(1,n+1):
  a,b=map(int,input().split())
  B[a]+=b
for j in range(1,10**5+1):
  k-=B[j]
  if k<=0:
    print(j)
    break


Measured memory_bytes: 72408
/*
 KUNAL RAUT (ZUKONIT14)  :- "DO WHAT YOU LIKE!"
 -PICT,PUNE! :)
 */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define mod 1000000007
#define mod9 1000000009
#define pi 3.1415926535
#define MAXN 100005
#define N 1000001
#define MAX2N 1*1000 + 10
#define all(v) v.begin(), v.end()
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define forci(p,n) for(ll i=p;i<(ll)n;i++)
#define forcj(p,n) for(ll j=p;j<(ll)n;j++)
#define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define bits(a) __builtin_popcount(a)
#define test ll t;cin>>t;for(ll testi=1;testi<=t;testi++)
ll zero = 0;
ll one = 1;
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 expo(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) {
        if (y & 1)res = (1ll * res * x) % mod;
        y = y >> 1; x = (1ll * x * x) % mod;
    } return res;
}
ll ncr(ll n, ll r) { ll res = 1; if (r > n - r)r = n - r; for (ll i = 0; i < r; i++) {  res *= n - i;  res /= i + 1; } return res;}
ll max(ll a, ll b) {return (a > b) ? a : b;}
bool prime(ll n) {ll i; for (i = 2; i <= sqrt(n); i++) {if (n % i == 0)return false;} return true;}
bool sortbysec(const pair<ll, ll> &a, const pair<ll, ll> &b)
{   if (a.second == b.second)
        return a.first < b.first;
    return (a.second < b.second);
}
//https://www.youtube.com/watch?v=WTJSt4wP2ME

ll rr[] = {0, 1, 1, 1, 0, -1, -1, -1,};
ll cc[] = {1, 1, 0, -1, -1, -1, 0, 1};

ll a[MAXN], ans[MAXN];

signed main()
{
    bolt;
// #ifndef ONLINE_JUDGE
//     freopen("input00.txt", "r", stdin);
//     freopen("output00.txt", "w", stdout);
// #endif
    ll x; cin >> x;
    ll ans = 0;
    ans += 1000 * (x / 500);
    x %= 500;
    ans += (5 * (x / 5));
    cout << ans;
}








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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

int main ()

{
    int a ;
    string s ;

    cin >> a ;
    cin >> s ;

    if (a >= 3200)
    {
        cout << s ;

    }
    else
    {
        cout << "red" ;
    }

    return 0 ;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
  
typedef long long ll; 
typedef pair<ll, ll> pll;
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
 
#define MOD 1000000007  
#define ffor(a, b, c) for (ll(a) = (b); (a) < (c); ++(a)) 
#define fforsq(a, b, c) for (ll(a) = (b); (a) * (a) <= (c); ++(a)) 
 
#define rep(i, n) ffor(i, 0, n) 
#define ff first 
#define ss second  
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define TC(t) while (t--) 
#define N 200005
 
int main(){
    ll i,j,k,m,n,a,b,c,q,t,r,sum,num,ans,ind;
    cin>>n;
    vl v(n);
    vl dp(n,0);
    rep(i,n){
        cin>>v[i];
    }
    dp[0] = 0; dp[1] = abs(v[1] - v[0]);
    ffor(i,2,n){
        dp[i] = min(abs(v[i]-v[i-1]) + dp[i-1], abs(v[i]-v[i-2])+dp[i-2]);
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
//Chandigarh University
//author:- shivamkr21
#include<bits/stdc++.h>
using namespace std;
int n,k;
int c[100001],ar[100001];
int stone(int x)
{
	if(x==n)
	{
		return 0;
	}
	if(x>n)
	{
		return 1000000000;
	}
	if(ar[x]!=-1)
	{	
		return ar[x];
	}
	int i=1,ss,min=1000000000;
	while(i<=k)
	{
		ss=abs(c[x]-c[x+i]) + stone(x+i);
		if(ss<min)
		{
			min=ss;
		}
		i++;
	}
	return ar[x]=min;
}
int main()
{
	cin>>n>>k;
	memset(ar,-1,sizeof(ar));
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
	}
	cout<<stone(1);
	return 0;
}

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

int main() {
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    string ans ="No";
    if(s[a] == '-'){
        string t = s.substr(0,a);
        string u = s.substr(a+1);
        if("0"<=t && t <= "99999" && "0" <= u&& u <= "99999"){
            ans ="Yes";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
b = list(input())
ans = [None]*len(b)
def en(n):
    if n == "A":
        return "T"
    elif n == "T":
        return "A"
    elif n == "G":
        return "C"
    else:
        return "G"
for i in range(len(b)):
    ans[i] = en(b[i])
print(*ans)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=5e5+10;
char s[maxn];
int a[maxn];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	REP(i,0,n-1){
		a[i]+=(s[n-i]-'0')*9;
		a[i+1]+=a[i]/10;
		a[i]%=10;
	}
	--n;
	while(a[n+1]){
		++n;
		a[n+1]+=a[n]/10;
		a[n]%=10;
	}
	int tot=0;
	REP(i,0,n) tot+=a[i];
	REP(_,1,maxn){
		a[0]+=9;
		tot+=9;
		REP(i,0,n){
			if(a[i]<10) break;
			a[i+1]++;
			tot-=9;
			a[i]-=10;
		}
		if(a[n+1]) ++n;
		if(tot<=9*_) return printf("%d\n",_),0;
	}
	return 0;
}


Measured memory_bytes: 2688
#include<stdio.h>
int main(void)
{
   int n;
   int i;
   int a[10000];
   int max;
   int min;
   long int sum=0;
   scanf("%d",&n);
   for(i=0;i<n;i++)
   {
      scanf("%d",&a[i]);
   }
   max=min=a[0];
   for(i=0;i<n;i++)
   {
      if(a[i]>max)
      {
         max=a[i];
      }
      else if(a[i]<min)
      {
         min=a[i];
      }
      sum+=a[i];
   }
   printf("%d %d %ld\n",min,max,sum);
   return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(long long int i=0;i<n;i++)
#define foi(i,a,n) for(long long int i=a;i<n;i++)
#define el "\n"

const int INF = 2e9+5;
const int MAX = 1e5+5;
const int mod = 1e9+7;
using ll = long long int;

void solve(){
	int n,m;cin>>n>>m;
  	vector<vector<int>> gr(n,vector<int>(m,1)),dp(n,vector<int>(m,0));
  	dp[0][0]=1;
  	rep(i,n)rep(j,m){
    	char temp;cin>>temp;
      	if(temp=='#')gr[i][j]=0;
    }
  	rep(i,n)rep(j,m){
    	if(gr[i][j]){
        	if(i-1>=0)dp[i][j]+=dp[i-1][j]%mod;
          	if(j-1>=0)dp[i][j]+=dp[i][j-1]%mod;
          	dp[i][j]%=mod;
        }
    }
  	cout<<dp[n-1][m-1]<<el;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 11460
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  long long ans=1;
  bool flag_0=false;
  for(int i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i)==0){
      flag_0=true;
    }
  }

  if(flag_0==true){
    cout << 0 << endl;
    return 0;
  }

  for(int i=0;i<N;i++){
    if(1000000000000000000/ans<A.at(i)){
      cout << -1 << endl;
      return 0;
    }
    ans*=A.at(i);
  }

  cout << ans << endl;

  return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const ll MOD = 1000000007;

int N, K;
ll dp[110][10010];

int main() {
	cin >> N >> K;
	dp[N][0] = 1;
	for (int i = N-1; i>=0; --i) {
		rep(j, 10010) if (dp[i+1][j] != 0) {
			for (int k = 0; k <= K; ++k) {
				int t = (i+1)-k;

				if (t < 0 || t > j) {
					dp[i][j] = (dp[i][j] + dp[i+1][j]) % MOD;
				} else {
					int num = (j-t)/(i+1) + 1;
					dp[i][j+num] = (dp[i][j+num] + dp[i+1][j]) % MOD;
				}
			}
		}
	}

	ll ret = N * K * (K+1) / 2;
	rep(i, N-1) ret = ret * (K+1) % MOD;

	rep(i, 10010) if (dp[0][i]>0) {
		ret = (ret - dp[0][i] * i % MOD);
		if (ret < 0) ret += MOD;
	}

	cout << ret << endl;

	return 0;
}

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

int main(){
  long h, w;
  cin >> h >> w;
  if((h%3)*(w%3)==0){
    cout << 0;
  }
  else {
    long ret = min(h, w);
    for(int i=0; i<h; i++){
      if(w%2==0){
        ret = min(ret, abs(i*w-(h-i)*w/2));
      }
      else {
        long dif = max({i*w, (h-i)*(w-1)/2, (h-i)*(w+1)/2})-min({i*w, (h-i)*(w-1)/2, (h-i)*(w+1)/2});
        ret = min(ret, dif);
      }
    }
    for(int i=0; i<w; i++){
      if(h%2==0){
        ret = min(ret, abs(i*h-(w-i)*h/2));
      }
      else {
        long dif = max({i*h, (w-i)*(h-1)/2, (w-i)*(h+1)/2})-min({i*h, (w-i)*(h-1)/2, (w-i)*(h+1)/2});
        ret = min(ret, dif);
      }
    }
    cout << ret;
  }
  return 0;
}


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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;

typedef long long ll;

const long long MOD = 1000000000 + 7;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll x;
    cin >> x;
    
    for(ll i = -120; i < 120 ; i++){
        for(ll j = -120; j < 120; j++){
            ll a,b;
            a = 1; b=1;
            rep(k,5){
                a *= i;
                b *= j;
            }
            if((a-b) == x) {
                cout << i << " " << j;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3620
N, M = map(int, input().split())
A_li = [list(map(int, input().split())) for i in range(N)] 
K_li = [A_li[i].pop(0) for i in range(N)]
ans = 0
for i in range(M) :
    for j in range(N) :
        if not i + 1 in A_li[j] :
            break
        if j == N - 1 :
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, K, A[1 << 18], cnt;
map<long long, long long> Map;

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) { cin >> A[i]; A[i]--; }
	for (int i = 1; i <= N; i++) { A[i] += A[i - 1]; A[i] %= K; }

	Map[A[0]] = 1;
	for (int i = 1; i <= N; i++) {
		if (i >= K) Map[A[i - K]]--;
		cnt += Map[A[i]];
		Map[A[i]]++;
	}
	cout << cnt << endl;
	return 0;
}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n;
string s;

bool check(int len)
{
	map<string, int> h;
	for (int i = 0; i <= n - len; i ++ )
	{
		string t = s.substr(i, len);
		if (h.count(t))
		{
			if (h[t] + len <= i) return true;
		}
		else h[t] = i;
	}
	return false;
}

int main()
{
	cin >> n >> s;
	
	int l = 0, r = n;
	while (l < r)
	{
		int mid = l + r + 1 >> 1;
		if (check(mid)) l = mid;
		else r = mid - 1;
	}
	cout << r << endl;
    return 0;
}

Measured memory_bytes: 9876
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <string>
using namespace std;

int main(void){
    int n, v[100010], a[100010], b[100010];
    int amax = 0, amax2 = 0, bmax = 0, bmax2 = 0;
    int amaxn, amax2n, bmaxn, bmax2n, bbmax = 0, bbmax2 = 0, bbmaxn, bbmax2n;
    int ans1, ans2, ans3, ans4;
    cin >> n;
    
    for (int i = 0; i < 100010; i++) a[i] = b[i] = 0;
    
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    for (int i = 0; i < n; i += 2) {
        a[v[i]]++;
        if (i == 0) {amax = 1; amaxn = v[i];}
        else if (a[v[i]] > amax) {
            amax = a[v[i]];
            amaxn = v[i];
        }
    }
    
    for (int i = 0; i < 100010; i++) a[i] = 0;
    
    for (int i = 0; i < n; i += 2) {
        a[v[i]]++;
        if (v[i] != amaxn){
            if (i == 0) {amax2 = 1; amax2n = v[i];}
            else if (a[v[i]] > amax2) {
                amax2 = a[v[i]];
                amax2n = v[i];
            }
        }
    }
    if (amax2 == 0) amax2n = n + 1;
    
    for (int i = 1; i < n; i += 2) {
        b[v[i]]++;
        if (i == 1 && amaxn != v[i]) {bmax = 1;}
        else if (b[v[i]] > bmax && amaxn != v[i]) {
            bmax = b[v[i]];
        }
    }
    
    for (int i = 0; i < 100010; i++) b[i] = 0;
    
    for (int i = 1; i < n; i += 2) {
        b[v[i]]++;
        if (i == 1 && amax2n != v[i]) {bbmax = 1;}
        else if (b[v[i]] > bbmax && amax2n != v[i]) {
            bbmax = b[v[i]];
        }
    }
    
    ans1 = n - amax - bmax;
    ans2 = n - amax2 - bbmax;
    int ans;
    if (ans1 < ans2) ans = ans1; else ans = ans2;
    
    cout << ans << endl;
    
    return 0;
}


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

int gcd(int m, int n){
  if(n==0)
    return m;
  return gcd(n, m%n);
}

int main(){
  int W,H,C;
  cin >> W >> H >> C;

  int g = gcd(W, H);

  cout << W/g*H/g*C << endl;
  return 0;
}



Measured memory_bytes: 3084
n, m = map(int, input().split())
A = [0 for i in range(n)]
for i in range(n):
    A[i] = list(map(int, input().split()))
b = [0 for i in range(m)]
for i in range(m):
    b[i] = int(input())
ans = [0 for i in range(n)]
for i in range(n):
    for j in range(m):
        ans[i] += A[i][j] * b[j]
    print(ans[i])



Measured memory_bytes: 6024
#include <iostream>

using namespace std;
int main(){
  int a[10];
  for(int i = 0 ; i < 10 ; i++ ){
    cin >> a[i];
  }
  for(int i = 9 ; i > 0 ; i-- ){
    for(int j = 0 ; j < i ; j++ ){
      if(a[j] < a[j+1])swap(a[j],a[j+1]);
    }
  }
  cout << a[0] << endl << a[1] << endl << a[2] << endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    
    sort(ALL(A));
    if (A[0] < (A[N - 1] + 1) / 2) {
        cout << "Impossible\n";
        return 0;
    }
    vector<int> cnt(N, 0);
    REP(i, N) ++cnt[A[i]];
    if (A[N - 1] & 1) {
        if (cnt[(A[N - 1] + 1) / 2] != 2) {
            cout << "Impossible\n";
            return 0;
        }
        for (int i = (A[N - 1] + 1) / 2; i <= A[N - 1]; ++i) {
            if (cnt[i] < 2) {
                cout << "Impossible\n";
                return 0;
            }
        }
    } else {
        if (cnt[(A[N - 1] + 1) / 2] != 1) {
            cout << "Impossible\n";
            return 0;
        }
        for (int i = A[N - 1] / 2 + 1; i <= A[N - 1]; ++i) {
            if (cnt[i] < 2) {
                cout << "Impossible\n";
                return 0;
            }
        }
    }
    cout << "Possible\n";
    return 0;
}


Measured memory_bytes: 3644
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a + W < b) {
            System.out.println(b - (a + W));
        } else if (b + W < a) {
            System.out.println(a - (b + W));
        } else {
            System.out.println(0);
        }
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#define  boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ull unsigned long long
#define deb(x) cout<<#x<<" "<<x<<endl;
#define fr(i,l,r) for(ll i=l;i<r;i++)
#define mems(a,x) memset(a,x,sizeof(a))
#define mod 1000000007
#define ff first
#define ss second
#define pb(x) push_back(x)
#define vll vector<ll>
#define pbp(x,y) push_back(make_pair(x,y))

//Prints the array 

vll v;
ll printArr(ll a[],ll n) 
{   ll num=0,k=1;
   fr(i,0,n-1)
   k*=10;
	for (int i=0; i<n; i++) {
		//cout << a[i] << " ";
        num+=a[i]*k;k/=10; }
        //v.push_back(num);
        return num;
} 

// Generating permutation using Heap Algorithm 
void heapPermutation(ll a[], ll size, ll n) 
{ 
	// if size becomes 1 then prints the obtained 
	// permutation 
	if (size == 1) 
	{ 
		v.pb(printArr(a, n)); 
    
		return; 
	} 

	for (int i=0; i<size; i++) 
	{ 
		heapPermutation(a,size-1,n); 

		// if size is odd, swap first and last 
		// element 
		if (size%2==1) 
			swap(a[0], a[size-1]); 

		// If size is even, swap ith and last 
		// element 
		else
			swap(a[i], a[size-1]); 
	} 
} 

// Driver code 
int main() 
{ 
    ll n;
    cin>>n;
    ll a[n],b[n];
    fr(i,0,n)cin>>a[i];
    fr(i,0,n)cin>>b[i];
    ll num1=printArr(a,n);
    ll num2=printArr(b,n);
	heapPermutation(a, n, n); 
    sort(v.begin(),v.end());
  //  for(int i=0;i<v.size();i++)
  ////  cout<<v[i]<<" ";
   // cout<<endl;
    cout<<abs(lower_bound(v.begin(),v.end(),num1)-lower_bound(v.begin(),v.end(),num2));
	return 0; 
} 


Measured memory_bytes: 892