akhauriyash/Code-Regression huggingface dataset:
def main():
    n, m = map(int, input().split())
    ans = [0]*n
    flag = False

    if m == 0:
        if n > 1:
            ans[0] = 1
            print(''.join(map(str, ans)))
            return 0
        
        print(''.join(map(str, ans)))
        return 0

    s_c = []
    for i in range(m):
        temp_s, temp_c = map(int, input().split())
        s_c.append([temp_s, temp_c])
        ans[temp_s-1] = temp_c

    for i, j in s_c:
        if not(ans[i-1] == j) or (i-1 == 0 and j == 0 and n > 1):
            flag = True
            break

    if flag:
        print(-1)
    else:
        if ans[0] == 0 and n > 1:
            ans[0] = 1
        
        print(''.join(map(str, ans)))
        


if __name__ == '__main__':
    main()

Measured memory_bytes: 61624
#include <iostream>
#include <climits>

using namespace std;

long long int cnt = 0;

void merge(int A[], int left, int mid, int right) {
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1 + 1], R[n2 + 1];
    for (int i = 0; i < n1; i++) L[i] = A[left + i];
    for (int i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;
    int l = 0, r = 0;
    for (int i = left; i < right; i++) {
        if (L[l] <= R[r]) A[i] = L[l++];
        else {A[i] = R[r++]; cnt += n1 - l;}
    }
}

void mergeSort(int A[], int left, int right) {
    if(right > 1 + left) {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main() {
    int n;
    cin >> n;
    int A[n];
    for(int i = 0; i < n; i++) cin >> A[i];

    mergeSort(A, 0, n);

    cout << cnt << endl;
}


Measured memory_bytes: 4660
#include<bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define bs binary_search
#define mp make_pair
#define F first
#define S second
#define It iterator
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define rint register int
#define en "\n"
#define br break
#define con continue
#define fri(n) for( int i=0;i<n;i++)
#define frj(n) for( int j=0;j<n;j++)
#define T(i) int i=1;cin>>i;while(i--)
#define fast ios_base::sync_with_stdio(0);cin.tie();cout.tie();
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi>vii;
typedef map<int,int> mi;
typedef set<int> S;
typedef list<int> L;
typedef stack<int> St;
typedef queue<int> Qu;
typedef deque<int> Dq;
typedef map<string,int> msi;
typedef map<pi,int> mpi;
typedef map<int,vii> mivi;
typedef map<pi,vi> mpivi;
int cost(int a[],int n,int ans[])
{
    if(ans[n-2]==-1)ans[n-2]=cost(a,n-2,ans);
    if(ans[n-1]==-1)ans[n-1]=cost(a,n-1,ans);
    return min(abs(a[n]-a[n-2])+ans[n-2],abs(a[n]-a[n-1])+ans[n-1]);
}
void solve()
{
    int n;cin>>n;
    int a[n+1]={};fri(n)cin>>a[i+1];
    int ans[n+1]={};fri(n+1)ans[i]=-1;
    ans[2]=abs(a[2]-a[1]);
    ans[1]=0;
    cout<<cost(a,n,ans);
}
int main()
{
    fast;
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //T(t)
    {
        solve();
    }
}


Measured memory_bytes: 7488
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.LinkedList;

/**
 * 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;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        static int n;
        static int keta;
        static int ans;

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String str = in.next();
            n = Integer.parseInt(str);
            keta = str.length();
            ans = 0;

            LinkedList<String> A = new LinkedList<>();

            dfs(0, 0, 0, 0);

            out.println(ans);

        }

        public static int dfs(long num, int x, int y, int z) {
            if (num > n) {
                return 0;
            }
            dfs(num * 10 + 3, x + 1, y, z);
            dfs(num * 10 + 5, x, y + 1, z);
            dfs(num * 10 + 7, x, y, z + 1);
            if (x > 0 && y > 0 && z > 0) ans++;

            return ans;
        }

    }
}



Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
int main()
{int n,i,j;
 cin>>n;
 int a[n+1],d[n+1];
 for(i=1;i<=n;i++)
 {
   cin>>a[i];
 }
a[0]=a[1];
 d[0]=0;
 d[1]=0;
/*for(j=0;j<=n;j++)
 {
     cout<<a[j]<<" ";
 }*/
 for(j=2;j<=n;j++)
 {
   d[j]=min(abs(a[j]-a[j-1])+d[j-1],abs(a[j]-a[j-2])+d[j-2]);
  // cout<<d[j]<<endl;

            }
            cout<<d[n]<<endl;
 return 0;
}



Measured memory_bytes: 1024
import sys
import numpy as np

def main(N, P):
    minDist = np.ones((N, N), dtype=np.int32)
    isFilled = np.ones((N, N), dtype=np.int32)

    for h in range(N):
        for w in range(N):
            minDist[h][w] = min(h, N - h - 1, w, N - w - 1)

    ans = 0
    dh = (1, -1, 0, 0)
    dw = (0, 0, 1, -1)
    for p in P:
        h, w = divmod(p, N)
        ans += minDist[h][w]
        isFilled[h][w] = 0

        st = [(h, w)]
        while st:
            h, w = st.pop()
            dist = minDist[h][w] + isFilled[h][w]

            for i in range(4):
                toH, toW = h + dh[i], w + dw[i]
                if 0 <= toH < N and 0 <= toW < N:
                    if minDist[toH][toW] > dist:
                        minDist[toH][toW] = dist
                        st.append((toH, toW))
    return ans

def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('main', 'i4(i4, i4[:])')(main)
    cc.compile()

if sys.argv[-1] == 'ONLINE_JUDGE':
    cc_export()
    exit(0)
if sys.argv[-1] != 'LOCAL':
    from my_module import main

N = int(input())
P = np.asarray(list(map(lambda a: int(a) - 1, input().split())), dtype=np.int32)

print(main(N, P))


Measured memory_bytes: 56804
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        sc.close();
        int ans = 0;
        int work = 0;

        for (int i = 1; i <= x; i++) {
            for (int j = 2; j < 10; j++) {
                work = (int) Math.pow(i, j);
                if (work <= x) {
                    ans = Math.max(ans, work);
                } else {
                    break;
                }
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21716
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>

#define p(a, b) pair<a, b>

using namespace std;

bool ok(string sb,string t){
    for(int i = 0; i < sb.size(); i++){
        if(sb[i] == '?'){
            continue;
        }
        if(sb[i] != t[i]){
            return false;
        }
    }
    return true;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,t;
    cin >> s >> t;
    int mx = -1;
    for(int i = 0; i < s.size() - t.size() + 1;i++){
        string sb = s.substr(i,t.size());
        //cout << sb << endl;
        if(ok(sb,t)){
            mx = i;
        }
    }
    if(mx == -1){
        cout << "UNRESTORABLE";
        return 0;
    }
    for(int i = 0; i < t.size(); i++){
        s[mx + i] = t[i];
    }
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '?')
            cout << 'a';
        else
            cout << s[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define VI vector<int>
#define pii pair<int,int>
using namespace std;
int n, m, k;
char A[11][1010];
int S[11];
bool valid(int r){
	for(int i = 0; i < r; i++) if(S[i] > k) return false;
	return true;
}
int f(int msk){
	memset(S, 0, sizeof S);
	int cuts = __builtin_popcount(msk);
	int p = cuts + 1;
	int l = 0;
	for(int i = 0; i < m; i++){
		int r = 0;
		for(int j = 0; j < n; j++){
			S[r] += A[j][i] == '1';
			if(msk & (1<<j)) r++;
		}
		if(!valid(p)){
			if(l == i) return INT_MAX;
			cuts++;
			memset(S, 0, sizeof S);
			l = i;
			i--;
		}
	}
	return cuts;
}
int main(){
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 0; i < n; i++) scanf("%s", A[i]);
	int ans = INT_MAX;
	for(int i = 0; i < (1<<(n-1)); i++){
		ans = min(ans, f(i));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
N, M = gets.chomp.split(" ").map(&:to_i)
X = gets.chomp.split(" ").map(&:to_i)
Y = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

x = (1...N).inject(0){|r, i|
  r + (i * (N-i) * (X[i] - X[i-1])) % MOD
}
y = (1...M).inject(0){|r, i|
  r + (i * (M-i) * (Y[i] - Y[i-1])) % MOD
}

puts ((x % MOD) * (y % MOD)) % MOD


Measured memory_bytes: 17572
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,k;
vector<long>a;
main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int m;cin>>m;a.push_back(m);
	}
	sort(a.begin(),a.end());
	long ans=1e18;
	long suml=0,sumr=0;
	for(int i=k-1;i<n;i++)
	{
		suml=a[i-k+1];
		sumr=a[i];
		if(sumr<0)ans=min(ans,-suml);
		else if(suml>0)ans=min(ans,sumr);
		else ans=min(ans,min(-suml-suml+sumr,sumr+sumr-suml));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1400
# https://atcoder.jp/contests/abc087/tasks/abc087_b

import itertools
import collections
import bisect

def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    ans = 0
    for a in range(A+1):
        for b in range(B+1):
            rest = X - 500 * a - 100 * b
            if 0 <= rest <= 50 * C:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int n, a;
  cin >> n;
  int ret = 0;
  for (int i = 0; i < n; i++){
    cin >> a;
    while(a % 2 == 0){
      a /= 2;
      ret++;
    }
  }
  cout << ret << endl;

  return 0;
}

ll gcd(ll a, ll b){
  if (a < b)
    return gcd(b, a);
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}

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

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int k, n;
int a[200001];

signed main() {
	int i;
	
	cin >> k >> n;
	rep(i, n) cin >> a[i];
	a[n] = k + a[0];
	
	int ans = k;
	rep(i, n) {
		int res = k - (a[i + 1] - a[i]);
		ans = min(ans, res);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>


using namespace std;

// vector<vector<int>> mat(N, vector<int>(M, 0));

int main(int argc, const char *argv[])
{
    //
    int L,R;

    cin>>L>>R;
    int L_div = L/2019;
    if(R - L >= 2019)
    {
        cout<<0;
        return 0;
    }
    L = L%2019;
    R = R%2019;

    long long prod = 0;
    if(R<L)
    {
        swap(L,R);
    }
  
    long long min = 9223372036854775807;
    for (int i = L; i <= R; i++)
    {
        for (int j = L; j <= R ; j++)
        {

            if(i<j)
            {
                    prod = i * j;
                    prod = prod % 2019;
                    if (prod < min)
                    {
                        min = prod;
                    }         
                }
            }

        }
    
    
    cout<<min;

    return 0;
}

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

int main() {
    ll N, D; cin >> N >> D;
    ll cnt = 0;
    for (ll i = 0; i < N; ++i) {
        ll X, Y; cin >> X >> Y;
        if (X * X + Y * Y <= D * D) {
            ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll n;
    cin >> n;
    vector<ll> t(n), a(n);
    REP(i, n){
        cin >> t[i];
    }
    REP(i, n){
        cin >> a[i];
    }
    
    vector<bool> tt(n), aa(n);
    tt[0] = true;
    for(ll i = 1; i < n; i++){
        if(t[i] != t[i - 1]){
            tt[i] = true;
        }
    }
    aa[n - 1] = true;
    for(ll i = n - 2; i >= 0; i--){
        if(a[i] != a[i + 1]){
            aa[i] = true;
        }
    }
    
    ll ans = 1;
    REP(i, n){
        if(tt[i]){
            if(t[i] > a[i]){
                ans = 0;
            }
        }
        else if(aa[i]){
            if(a[i] > t[i]){
                ans = 0;
            }
        }
        else{
            ans *= min(t[i], a[i]);
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



  //二分探索(最小値を出す問題は疑う)

// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < n; ++i){
// 		res += max(0ll, a[i]-x/f[i]);
//     }
//     return res <= k;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }



int main(){
  int N;
  cin >> N;
REP(i, 9)REP(j, 9){
  if(N == (i + 1) * (j + 1)) {
    yes;
    return 0;
  }
}
no;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a,b;
int main()
{
  scanf("%d%d",&a,&b);
  if(a<=0&&b>=0)
    return puts("Zero"),0;
  if(a<0)
   	puts((b-a)&1?"Positive":"Negative");
  else
	puts("Positive");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,L;
  cin >> N >> L;
  vector<int> vec(N);
  int count=0;
    for(int i=0;i<N;i++){
    count += L+i;
    if(L+i>=0){
      vec.at(i)=L+i;
    }
    else{
      vec.at(i)=-(L+i);
    }
  }
  sort(vec.begin(), vec.end());
  if(L<0 && N <= -L){
    cout << count + vec.at(0);
  }
  else{
    cout << count - vec.at(0);
  }
}

Measured memory_bytes: 256
#pragma GCC optimize (2)
#include<bits/stdc++.h>
using namespace std;
const int N=200005, P=1000000007;
int dp[N], pre[N];

inline int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
    return x*f;
}

int main()
{
    int n=read(); dp[0]=1;
    for (int i=1; i<=n; i++) 
    {
        int c=read();
        dp[i]=dp[i-1];
        if (pre[c] && pre[c]<i-1) dp[i]=(dp[i]+dp[pre[c]])%P;
        pre[c]=i;
    }
    printf("%d\n", dp[n]);
	return 0;
}


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

int main(void) {
  int h, w;
  cin >> h >> w;

  vector<vector<int>> a(h+1,vector<int>(w+1, 0));
  for (int i = 1; i <= h; i++) {
    for (int j = 1; j <= w; j++) {
      int aa;
      cin >> aa;
      a[i][j]=aa%2;
    }

  }

  vector<vector<bool>> used(h, vector<bool>(w, false));

  int n=0;
  vector<string> ans;
  for (int i = 1; i <= h-1; i++) {
    for (int j = 1; j <= w; j++) {
      if(a[i][j]==1){
	n++;
	stringstream s;
	s << i << ' ' << j << ' ' << i+1 << ' ' << j;
	ans.push_back(s.str());
	a[i+1][j] = (a[i+1][j]+1)%2;
      }
    }
  }

  for (int j = 1; j <= w-1; j++) {
    if(a[h][j]==1){
      n++;
      stringstream s;
      s << h << ' ' << j << ' ' << h << ' ' << j+1;
      ans.push_back(s.str());
      a[h][j+1] = (a[h][j+1]+1)%2;
    }
  }

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

  return 0;
}


Measured memory_bytes: 9972
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
#define print(n) cout<<n<<endl
const int M=100111;
const int inf=1000000007;
const long long INF=1000000000000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};

int n,m;
string a[55],b[55];
bool check(int x,int y){
	if(x>=n||y>=n)return false;
	rep(i,0,m){
		rep(j,0,m){
			if(a[y+i][x+j]!=b[i][j])return false;
		}
	}
	return true;
}

int main(){
	cin>>n>>m;
	rep(i,0,n)cin>>a[i];
	rep(i,0,m)cin>>b[i];
	bool ok=false;
	rep(i,0,n-m+1){
		rep(j,0,n-m+1){
			if(check(i,j))ok=true;
		}
	}
	if(ok?print("Yes"):print("No"));
}

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

int main(void){
    string S;
    int N = 4;
    cin >> S;

    for (int i = 0; i < (1 << (N - 1)); i++){
        int tmp = S[0] - '0';
        for (int j = 0; j < (N - 1); j++){
            if (i & (1 << j)){
                tmp += S[j+1] - '0';
            } else {
                tmp -= S[j+1] - '0';
            }
        }
        if (tmp == 7){
            cout << S[0] - '0';
            for (int k = 0; k < (N - 1); k++){
                if (i & (1 << k)){
                    cout << '+';
                } else {
                    cout << '-';
                }
                cout << S[k+1] - '0';
            }
            cout << '=' << 7;
            break;
        }
    }
}

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

ll n,a,b;

int main(){
    cin>>n>>a>>b;
    if((a-b)%2){
        cout<<min(a-1,n-b)+1+(b-a)/2<<endl;
    }
    else cout<<(b-a)/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;

int main(){
        int n;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        sort(a,a+n);
        int ans=0;
        for(int i=0;i<n;i++){
            if(i!=n-1){
                ans=ans+a[i];
            }else{
                ans=ans+a[n-1]/2;
            }
        }
        cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c, x;
    scanf ("%d %d %d %d", &a, &b, &c, &x);
    int ans = 0;
    int i, j, k;
    for(i = 0; i <= a; i++) {
        for(j = 0; j <= b; j++) {
            for(k = 0; k <= c; k++) {
                if(i * 500 + j * 100 + k * 50 == x) ans++;
            }
        }
    }
    printf("%d\n", ans);
    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++)

typedef long long ll;
typedef pair<int, int> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976

int cnt[26];

int main()
{
    string s,t;
    cin >> s >> t;
    rep(i,s.size()) cnt[s[i]-'a']++;
    bool ok = true;
    rep(i,t.size()){
        if(cnt[t[i]-'a'] == 0) ok = false;
    }
    if(ok){
        vector<ll> pos[26];
        ll n = s.size();
        rep(i,n){
            pos[s[i]-'a'].push_back(i);
        }
        ll ans = 1, tmp = 0;
        rep(i,t.size()){
            int chr = t[i]-'a';
            if(i == 0){
                ans += pos[chr][0];
                tmp = pos[chr][0];
            }else{
                auto iter = upper_bound(pos[chr].begin(), pos[chr].end(), tmp);
                if(iter == pos[chr].end()) {
                    ans += (n + pos[chr][0] - tmp);
                    tmp = pos[chr][0];
                }else{
                    ans += (*iter - tmp);
                    tmp = *iter;
                }
            }
        }
        cout << ans << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 1724
#include<sstream>
using namespace std;
void mnp(string &s){
	stringstream r;
	for(int i=0,cnt=1;i<s.size();i++){
		if(i+1<s.size()&&s[i]==s[i+1])cnt++;
		else r<<cnt<<s[i],cnt=1;
	}
	r>>s;
}
int main(){
	int n; string s;
	while(cin>>n>>s,n){
		for(int i=0;i<n;i++)mnp(s);
		cout<<s<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
def sum_from_1_to_n(n):
    return n * (n + 1) // 2


def main():
    n, k = map(int, input().split())
    mod = 10 ** 9 + 7
    answer = 0
    max_num = sum_from_1_to_n(n)
    for i in range(k, n + 2):
        answer += max_num - sum_from_1_to_n(n - i) - sum_from_1_to_n(i - 1) + 1
        answer %= mod
    print(answer)


if __name__ == '__main__':
    main()



Measured memory_bytes: 9192
import math
from math import ceil
from math import factorial
from collections import Counter
from operator import itemgetter
import bisect
ii = lambda: int(input())
iia = lambda: list(map(int,input().split()))
isa = lambda: list(input().split())
def gcd(a,b):
	if(b==0):
		return a
	return gcd(b,a%b)

n = ii()

if(n%2==1):
	print(0)
else:
	x = len(str(n))
	a = []
	i = 10
	while(i<=n):
		a.append((n//i))
		i*=5
	print(sum(a))
	


Measured memory_bytes: 3316
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;


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

    long long days = N;
    for (int i = 0; i < M; i++) {
        long long Ai;
        cin >> Ai;
        days -= Ai;
    }

    if (days >= 0) {
        cout << days << endl;
    } else {
        cout << "-1" << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
import numpy as np
import math
[A,B] = input().split()
c = 0
if '.' in B:
    c = int(B.find('.'))
c = len(B)-c-1
B = B.replace(".","")
A = np.int64(A)
B = np.int64(B)
C = A*B
if c == 0 or C <=100:
    print(math.floor(C/int(10**c)))
else:
    print(str(C)[:-c])

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

typedef long long LL;
LL L,R;

int main(){
	scanf("%lld%lld",&L,&R);
	if(L==R){
		puts("1");
		return 0;
	}
	LL ans,mul;
	for(ans=0,mul=1;L*mul>0 && L*mul<=R;mul<<=1,ans++);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
from bisect import bisect_left

N = int(input())
data = list(map(int, input().split(' ')))
sorteddata = sorted(data)

def takeClosest(myList, myNumber):
    pos = bisect_left(myList, myNumber)
    if pos == 0:
        return myList[0]
    if pos == len(myList):
        return myList[-1]
    before = myList[pos - 1]
    after = myList[pos]
    if after - myNumber < myNumber - before:
       return after
    else:
       return before

ans = takeClosest(sorteddata, sorteddata[-1] / 2)
print(str(sorteddata[-1]) + ' ' + str(ans))

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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<int> P(N);
  vector<int> I(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i) >> P.at(i);
    I.at(i) = i + 1;
  }
  for (int i = 0; i < N - 1; i++) {
    for (int j = N - 1; j > i; j--) {
      if (S.at(j - 1) > S.at(j)) {
        swap(S.at(j - 1),S.at(j));
        swap(P.at(j - 1),P.at(j));
        swap(I.at(j - 1),I.at(j));
      }else if (S.at(j - 1) == S.at(j) && P.at(j - 1) < P.at(j)){
        swap(S.at(j - 1),S.at(j));
        swap(P.at(j - 1),P.at(j));
        swap(I.at(j - 1),I.at(j));
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << I.at(i) << endl;
  }
}

Measured memory_bytes: 256
S = input()
T = input()
ans = 99999999
for i in range(len(S)-len(T)+1):
    word = S[i:i+len(T)]
    cnt = 0
    for j in range(len(word)):

        if word[j]!=T[j]:
            cnt+=1
    ans = min(ans,cnt)
print(ans)

Measured memory_bytes: 9128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int c = 0;
    rep(i,4){
        if (s[i] == '+') c++;
        else c--;
    }
    PRINT(c);
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var a [3]int
	fmt.Scan(&a[0], &a[1], &a[2])

	var flg5, flg7 int

	for _, v := range a {
		if v == 5 {
			flg5++
		} else if v == 7 {
			flg7++
		}
	}
	if flg5 == 2 && flg7 == 1 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
	return
}

Measured memory_bytes: 512
N, Y = list(map(int, input().split()))

l = [-1, -1, -1]
flg = False
for i in range(N+1):
  for j in range(N+1-i):
    k = N-(i+j)
    if 10000*i + 5000*j + 1000*k == Y:
      l = [i, j, k]

print('{} {} {}'.format(l[0], l[1], l[2]))

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

# 1〜N をそれぞれ素因数分解して合算することで N! を素因数分解する
e = [0] * (N+1)
for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j

def num(m):
    return len(list(filter(lambda x: x >= m-1, e)))


ans = 0
ans += num(75)
ans += num(25) * (num(3) - 1)
ans += num(15) * (num(5) - 1)
ans += num(5) * (num(5) - 1) * (num(3) - 2) // 2

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;

int main(){
    int N;
    cin >> N;
    vi x(N), y(N);
    vi z(N);
    long double sum = 0.0;
    long double sum2 = 0.0;
    long double c = 0.0;
    for(int i=0; i<N; i++){
        z.at(i) = i + 1;
        cin >> x.at(i) >> y.at(i);
    }

    do{
        for(int i=0; i<N-1; i++){
            long double xxx = (x.at(z.at(i)-1)-x.at(z.at(i+1)-1))*(x.at(z.at(i)-1)-x.at(z.at(i+1)-1));
            long double yyy =  (y.at(z.at(i)-1)-y.at(z.at(i+1)-1))*(y.at(z.at(i)-1)-y.at(z.at(i+1)-1));
            sum += sqrt(xxx + yyy);
        }
        sum2 += sum;
        c++;
        sum = 0;
    }while (next_permutation(z.begin(), z.end()));
    cout <<fixed << setprecision(10) << sum2 / c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
const int MAXN=1e4+10;
int sum[MAXN][3],id[MAXN];
char col[MAXN];
int get_id(char x){
    if(x=='R') return 0;
    else if(x=='G') return 1;
    else return 2;
}
int main(){
    int n;scanf("%d %s",&n,col+1);
    for(int i=1;i<=n;i++) id[i]=get_id(col[i]);
    for(int i=n;i>=1;i--){
        for(int j=0;j<3;j++){
            sum[i][j]=sum[i+1][j];
        }
        sum[i][id[i]]++;
    }
    long long res=0;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(id[i]==id[j]) continue;
            int rem=3-id[i]-id[j];
            int pos=j-i+j;
            if(j<n) res+=sum[j+1][rem];
            if(pos<=n&&id[pos]==rem) res--;
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3820
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    int N;
    cin >> N;
    vint v(N);
    rep(i, N) cin >> v[i];
    sort(v.begin(), v.end());
    double ans = v[0];
    REP(i, 1, N) {
        ans = (ans + double(v[i])) / 2.0;
    }
    printf("%20.8f\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int start = sc.nextInt();
    Main abc116B = new Main();
    System.out.println(abc116B.solve(start));
  }

  public int solve(int start) {
    ABC116BSolve abc116BSolve = new ABC116BSolve();
    return abc116BSolve.search(start);
  }

  class ABC116BSolve {

    public int search(int start) {
      boolean[] history = new boolean[1000000];
      int current = start;
      int i = 1;
      while (true) {
        if (history[current]) return i;
        history[current] = true;
        if (current % 2 == 1) {
          current = 3 * current + 1;
        } else {
          current /= 2;
        }
        i++;
      }
    }
  }
}


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

int soinnsuubunnkai(int n)
{
    int n_tmp = n;
    int j = 0;
    vector<int> v;
    for (int ns = 3; n_tmp > ns; ns += 2)
    {
        for (j = 0; n % ns == 0; j++)
        {
            n /= ns;
        }

        if (j > 0)
        {
            v.push_back(j);
        }
    }

    int num = 1;
    for (int ind = 0; ind < v.size(); ind++)
    {
        num *= (v[ind] + 1);
    }

    if (num == 8)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

int main()
{
    int n;
    cin >> n;
    if (n < 105)
    {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    for (int i = 105; i <= n; i += 2)
    {
        ans += soinnsuubunnkai(i);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//2018.9.25 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline int read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
const int N=1e5+10;
namespace MAIN{
    int n,l;
    int a[N];
    int tot;
    int step[N],stepx;
    inline void MAIN(){
        n=read(),l=read();
        for(res i=1;i<=n;i++)a[i]=read();
        res j=1;
        for(res i=1;i<n;i++)if(a[i]+a[i+1]>a[j]+a[j+1])j=i;
        if(a[j]+a[j+1]<l)puts("Impossible");
        else {
            puts("Possible");
            for(res i=n-1;i>j;i--)printf("%d\n",i);
            for(res i=1;i<=j;i++)printf("%d\n",i);
        }
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	int s=(c+b-1)/b, t=(a+d-1)/d;
	if(s<=t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


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

using namespace std;
using vi = vector<int>;

int const INF = 1e9;

int main(void)
{
    int    n;
    string s;
    vi     pw, pb;

    cin >> n >> s;
    s = ' ' + s;

    pw.resize(n + 1, 0), pb.resize(n + 1, 0);
    for (int i = 1; i <= n; ++i)
    {
        pw[i] = pw[i - 1] + (s[i] == '.');
        pb[i] = pb[i - 1] + (s[i] == '#');
    }

    int ans = INF, left, right;

    // WWWBBB
    for (int i = 1; i <= n - 1; ++i) // i : pos of last white, inclusive
    {
        left = pb[i], right = (pw[n] - pw[i]);
        ans = min(ans, left + right);
    }
    ans = min({ans, n - pb[n], n - pw[n]});

    cout << ans << endl;

    return 0;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int main(int argc, char const *argv[])
{
    ll n, k;
    cin >> n >> k;
    ll d = 0, e = 0;
    FOR(a, 1, n + 1)
    {
        if (a % k == 0)
        {
            d++;
        }
        if (a % k == k / 2)
        {
            e++;
        }
    }
    if (k % 2 == 0)
    {
        cout << d * d * d + e * e * e << endl;
    }
    else
    {
        cout << d * d * d << endl;
    }
    return 0;
}


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

int func(string A,string B){
  int count = 0;
  for(char i= 'a';i<='z';i++){
    if(0 <= A.find(i) && A.find(i) < A.size() && 0 <= B.find(i) && B.find(i) < B.size()){
      count++;
    }
  }
  return count;
}
int main(){
  int a;
  cin >> a;
  string b;
  cin >> b;
  int MAX = 0;
  for(int i = 1;i<a;i++){
    string A = b.substr(0,i);
    string B = b.substr(i,a-i); 
    int m = func(A,B);
    MAX = max(m,MAX);
  }
  cout << MAX << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; 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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	char s[3];
	cin >> s;
    rep(i,3) if(s[i]=='7') {
        cout << "Yes" << "\n";
        return 0;
    }
	cout << "No" << "\n";
	return 0;
}


Measured memory_bytes: 3620
d, g = map(int, input().split())
scoreMap = [list(map(int, input().split())) for i in range(d)]

minimum = 0

for i in range(2**d):
    score = 0
    solved = 0
    for j in range(d):
        if (i >> j) & 1 == 1:
            score += scoreMap[j][0] * 100 * (j + 1) + scoreMap[j][1]
            solved += scoreMap[j][0]
    if score < g:
        for k in range(d)[::-1]:
            if (i >> k) & 1 == 0:
                if (g - score > scoreMap[k][0] * 100 * (k + 1)):
                    score += scoreMap[k][0] * 100 * (k + 1) + scoreMap[k][1]
                    solved += scoreMap[k][0]
                    if score > g:
                        break
                else:
                    solved += (g - score) // (100 * (k + 1))
                    if (g - score) % (100 * (k + 1)) != 0:
                        solved += 1
                    score = g
                    break
    if minimum == 0 or solved < minimum:
        minimum = solved

print(minimum)

Measured memory_bytes: 3064
/* author: Mohammad Sheraj */
/* Clang++17 launch.json for debugger */
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
// char buf[10]; fgets(buf, 10, stdin);
// Use long long instead of long
// cout<<"Case #"<<t<<": "<<answer<<endl;
///////////////////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <stack>
#include <queue> //includes priority_queue
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <set> //sorts by value
#include <map> //sorts by key
#include <algorithm> //max/min //lower_bound/upper_bound //binary_search //reverse //transform //next_permutation
#include <math.h> //ceil/floor
#include <numeric> //gcd //there will be sqiggly red line but no compilation error

using namespace std;
///////////////////////////////////////////////////////////////////////

int main() {
    // freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    // int T;
    // cin>>T;
    // for(int test_case=1;test_case<=T;test_case++) {
    // }
    string s;
    cin>>s;
    cout<<s.substr(0,3)<<endl;
}

Measured memory_bytes: 3100
use std::collections::VecDeque;

fn main() {
    let n = read::<usize>();
    let mut vd = VecDeque::<u64>::new();

    for i in 1..10 {
        vd.push_back(i);
    }

    let mut idx = 0;
    while let Some(val) = vd.pop_front() {
        idx += 1;
        if idx == n as u64 {
            println!("{}", val);
            break;
        }

        let x = val % 10;
        if x > 0 {
            vd.push_back(val * 10 + x - 1);
        }
        vd.push_back(val * 10 + x);
        if x < 9 {
            vd.push_back(val * 10 + x + 1);
        }
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 6396
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 200005
using namespace std;
int n,dis[M];
vector<int> e[M];
queue<int> q;
int bfs(int cur) {
    MSET(dis, 0);
    dis[cur] = 1;
    q.push(cur);

    while (!q.empty()) {
        cur = q.front();
        q.pop();
        for (int i: e[cur]) if (!dis[i]) {
            dis[i] = dis[cur]+1;
            q.push(i);
        }
    }
    return max_element(dis+1, dis+n+1) - dis;
}
int main()
{
    while (~scanf("%d",&n)) {
        REP(i,1,n) e[i].clear();
        REP(i,1,n-1) {
            int x,y;
            scanf("%d %d",&x,&y);
            e[x].push_back(y);
            e[y].push_back(x);
        }

        int root = 1;
        root = bfs(root);
        root = bfs(root);
        printf("%s\n", dis[root]%3==2 ? "Second" : "First");
    }
    
    return 0;
}






Measured memory_bytes: 13556
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph=vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;


int main(void)

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

	ll h, w;
	cin >> h >> w;

	ll ans = h * w/2;
    if(h==1 ||w==1)
    {
        cout<<1<<endl;
        ret;
    }
	if (h % 2 == 1 && w % 2 == 1)
	{
		ans += 1;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

city_num, ori = list(map(int, input().split()))
cityies = list(map(int, input().split()))
stan = cityies[0]
difference = [abs(ori-stan)]

if len(cityies) > 1:
    for city in cityies[1:]:
        diff = abs(city - stan)
        difference.append(diff)

max_num = gcd(difference)
print(max_num)

Measured memory_bytes: 16304
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=a; i<b; i++)
#define repi(i, a, b) for(int i=a; i>b; i--)
#define db(x) (cerr << #x << ": " << x << '\n')
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define ll long long
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll, ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define fi first
#define se second
#define umap unordered_map
#define umapi umap<int, int>
#define mapi map<int, int>
#define uset unordered_set
#define useti uset<int>
#define seti set<int>
#define pqueue priority_queue
#define si(a) scanf("%d", &a)
#define sll(a) scanf("%lld", &a)
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 1000000007
#define MOD 1000000007
#define N 
using namespace std;

template<typename T>
using maxpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using minpq = priority_queue<T>;
#define int ll
#define ppii pair<pii, int>

struct comp{
	int i;
	comp(int j) :i(j){
	}
	bool operator()(ppii a, ppii b) const {
			int _a = 0, _b = 0;
			if(i & 1) _a -= a.fi.fi, _b -= b.fi.fi;
			else _a += a.fi.fi, _b += b.fi.fi;
			
			if(i & (1 << 1)) _a -= a.fi.se, _b -= b.fi.se;
			else _a += a.fi.se, _b += b.fi.se;
			
			if(i & (1 << 2)) _a -= a.se, _b -= b.se;
			else _a += a.se, _b += b.se;
			
			return _a > _b;
	}
};

int acc(int ans[]) {
	int s = 0;
	rep(i, 0, 3)
		s += abs(ans[i]);
	return s;
}

main()
{	

	clock_t clk = clock();
	cerr << "I will return...\n";
	
	int n, m; cin >> n >> m;
	
	ppii a[n];
	for(auto& p : a) cin >> p.fi.fi >> p.fi.se >> p.se; 
	
	int mx = 0;
	rep(i, 0, 8) {
		sort(a,  a + n, comp(i));
		int ans[3] = {0};
		rep(j, 0, m) {
			ans[0] += a[j].fi.fi;
			ans[1] += a[j].fi.se;
			ans[2] += a[j].se;
		}
		mx = max(mx, acc(ans));
	}
	
	cout << mx << '\n';
	
	cerr << "...don't you ever hang your head.\n";
	cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << '\n';
}








Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    _, b, c = LS()
    x = int(b[0] + c[0]) % 4
    if not x:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    II()
    a = LI()
    a.sort()
    print(a[-1]-a[0])
    return

#C
def C():
    II()
    a = LI()
    a = list(map(lambda x: x // 400, a))
    d = defaultdict(int)
    for ai in a:
        d[ai] += 1
    ans1 = 0
    ans2 = 0
    for key, value in d.items():
        if key <= 7:
            ans1 += 1
            ans2 += 1
        else:
            ans2 += value
    if ans1 == 0:
        ans1 = 1
    print(ans1, ans2)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
	long long a,b;
	string x,y,z;
	cin>>x>>y;
	cin>>a>>b;
	cin>>z;
	if (z==x)
	{
		cout<<a-1<<" "<<b<<endl;
	}
	else
	{
		cout<<a<<" "<<b-1<<endl;
	}
}

Measured memory_bytes: 256