akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 100010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


 
void solve(void)
{  
  int N;cin>>N;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  int SUM = 0;
  int res = INF;
  int flg = 0;
  //if flg == 0 vec[i] ought to be positive integer else negative integer
  int cnt = 0;
  for (int i = 0; i < N; i++)
  {
    SUM += vec[i];
    if(flg == 0)
    {
      if(SUM <= 0)
      {
        int D = 1 - SUM;
        SUM += D;
        cnt += abs(D);
      }
    }
    else
    {
       if(SUM >= 0)
      {
        int D = -1 - SUM;
        SUM += D;
        cnt += abs(D);
      }
    }
    flg ^= 1;  
  }
  chmin(res,cnt);
  flg = 1;
  SUM = 0;
  cnt = 0;
  
  for (int i = 0; i < N; i++)
  {
    SUM += vec[i];
    if(flg == 0)
    {
      if(SUM <= 0)
      {
        int D = 1 - SUM;
        SUM += D;
        cnt += abs(D);
      }
    }
    else
    {
       if(SUM >= 0)
      {
        int D = -1 - SUM;
        SUM += D;
        cnt += abs(D);
      }
    }
    flg ^= 1;  
  }
  chmin(res,cnt);
  cout<<res<<endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3992
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: isize = read();
    let x: Vec<isize> = (0..n).map(|_| read()).collect();

    let mut ans: isize = -1;
    for p in 1..101 {
        let mut sum = 0;
        for xi in &x {
            sum += (xi - p) * (xi - p);
        }
        if ans == -1 || ans > sum {
            ans = sum;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		String N=stdIn.next();
		if(N.indexOf("7")!=-1)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


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

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int gcd(int p, int q){
  if(p<q) swap(p,q);
  while(q!=0){
    int tmp=p%q;
    p=q;
    q=tmp;
  }
  return p;
}

int main(int argc, char const *argv[]) {
  int i,j,k;

  string a="abcdefghijklmnopqrstuvwxyz";

  int n;
  scanf("%d\n",&n);
  for(int times=0; times<n; ++times){
    string s;
    getline(cin,s);
    //cout << s << endl;

    string ans;
    bool end=false;

    for(i=1; i<=25; ++i){//??¢???????????????
      if(gcd(26,i)!=1) continue;

      rep(j,26){
        //????????£?????§????¨?
        set<int> ch;
        rep(k,a.size()) ch.insert((i*k+j)%26);
        //??????
        if(ch.size()!=a.size()) continue;

        //printf("(%d,%d)\n",i,j);

        //?????????
        ans="";
        int p=0;
        rep(k,s.size()){
          if('a'<=s[k] && s[k]<='z'){
            ans+='a'+(i*(s[k]-'a')+j)%26;
          }
          else{
            ans+=s[k];
            string tmp=ans.substr(p,k-p);
            //cout << tmp << endl;

            if(tmp=="this"||tmp =="that")
              end=true;

            p=k+1;
          }
        }

        string tmp=ans.substr(p,k-p);
        //cout << tmp << endl;

        if(tmp=="this"||tmp =="that")
          end=true;


        if(end) break;
      }
      if(end) break;
    }

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

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

using namespace std;

bool is_in(vector<int> vec, int target) {
    for(auto it = vec.begin(); it != vec.end(); it++) {
        if(*it == target) {
            return true;
        }
    }
    return false;
}


int main()
{
    int X, N;

    cin >> X >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++) {
        cin >> vec[i];
    }

    if(N == 0) {
        cout << X << endl;
        return 0;
    }

    sort(vec.begin(), vec.end());

    int result = X;
    int min_diff = 101;
    for(int i = -1000; i <= 1000; i++) {
        if(is_in(vec, i)) {
            continue;
        }
        int diff = X - i;
        if(diff < 0) {
            diff *= -1;
        }
        
        if(min_diff > diff) {
            min_diff = diff;
            result = i;
        }
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(final String [] args) {
        final Scanner scanner = new Scanner(System.in);
        final String input = scanner.next();
        if (input.charAt(0) != '1' || input.charAt(input.length() - 1) != '0') {
            System.out.println(-1);
            return;
        }
        for (int i = 0, j = input.length() - 2; i < j; ++i, --j) {
            if (input.charAt(i) != input.charAt(j)) {
                System.out.println(-1);
                return;
            }
        }
        int currentEnd = 1;
        for (int i = 1; i < input.length(); ++i) {
            if (input.charAt(i - 1) == '1') {
                System.out.println(currentEnd + " " + (i + 1));
                currentEnd = (i + 1);
            } else {
                System.out.println(currentEnd + " " + (i + 1));
            }
        }
    }
}


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

class Cube{
public:
  int f[6];
  Cube(){}
  void roll_z(){ roll(1, 2, 4, 3);} //
  void roll_y(){ roll(0, 2, 5, 3);} // to W
  void roll_x(){ roll(0, 1, 5, 4);} // to N
  void roll(int i, int j, int k, int l){
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }
  void move(char ch){
    if ( ch == 'E' ) for ( int i = 0; i < 3; i++ ) roll_y();
    if ( ch == 'W' ) roll_y();
    if ( ch == 'N' ) roll_x();
    if ( ch == 'S' ) for ( int i = 0; i < 3; i++ ) roll_x();
  }
};

int main(){
  Cube c;
  string com;

  for ( int i = 0; i < 6; i++ ) cin >> c.f[i];
  cin >> com;

  for ( int i = 0; i < com.size(); i++ ) c.move(com[i]);

  cout << c.f[0] << endl;

  return 0;
}



Measured memory_bytes: 3152
import java.util.*;


class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in=new Scanner(System.in);
		int N=in.nextInt();
		int T=in.nextInt();
		
		int com=1001;
		while(in.hasNext()){
		    int n=in.nextInt();
		    int t=in.nextInt();
		    if(t>T)
		        continue;
		    else
		    {
		       if(n<=com) com=n;
		       
		    }     
		       
		}
	
		if(com==1001) System.out.println("TLE");
		else System.out.println(com);
		
	}
}

Measured memory_bytes: 21844
#include<stdio.h>
#include<string.h>
typedef long long ll;
typedef long l;
int return_max(int a,int b){
  if(a>b){
    return a;
  }else{
    return b;
  }
}

int return_min(int a,int b){
  if(a<b){
    return a;
  }else{
    return b;
  }
}

int main(void)
{
  char s[200010];
  char t[200010];
  scanf("%s %s",s,t);
  int count=0;
  int len=strlen(s);
  for(int i=0;i<len;i++){
    if(s[i]!=t[i])count++;
  }

  printf("%d\n",count);
  return 0;
}


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

#define ff      first
#define ss      second
#define pb      push_back
#define ll      long long
#define MX      100005
#define inf     1000000
#define mod     1000000007
#define endl    "\n"

#define W(t)            while(t--)
#define all(v)          v.begin(),v.end()
#define ZERO(a)         memset(a,0,sizeof(a))
#define MINUS(a)        memset(a,-1,sizeof(a))
#define rep(i,a,b)      for(i = a; i < b; i++)
#define IOS             ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;

int main()
{
	IOS

	int i,j,t,n;
	pair<int,int> a[200];

	cin>>n;

	rep(i,0,n) cin>>a[i].ff>>a[i].ss;

	rep(i,0,n){
		if(i+2 < n){
			if(a[i].ff==a[i].ss&&a[i+1].ff==a[i+1].ss&&a[i+2].ff==a[i+2].ss)
				{
					cout<<"Yes\n";
					return 0;
				}
		}
	}
	cout<<"No\n";
}

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

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)

signed main(){

	lli n;
	cin>>n;

	lli a[310][310];
	REP(i,0,n)REP(j,0,n)cin>>a[i][j];

	REP(k,0,n)REP(i,0,n)REP(j,0,n){
		if(a[i][j] > a[i][k]+a[k][j]){
			cout<<-1<<endl;
			return 0;
		}
	}

	REP(k,0,n)REP(i,0,n)REP(j,0,n){
		if(i==j || j==k || k==i)continue;
		
		if(a[i][j] == a[i][k]+a[k][j]){
			a[i][j] = INF;
		}
	}


	lli ans=0;
	REP(i,0,n){
		REP(j,0,n){
		
			if(a[i][j] != INF)ans += a[i][j];
		}
	}

	cout<<ans/2<<endl;

	return 0;
}

Measured memory_bytes: 1024
a, b, c, d = map(int, list(input()))
if a-b-c-d==7 :
    print(f"{a}-{b}-{c}-{d}=7")
elif a-b-c+d==7 :
    print(f"{a}-{b}-{c}+{d}=7")
elif a-b+c-d==7 :
    print(f"{a}-{b}+{c}-{d}=7")
elif a-b+c+d==7 :
    print(f"{a}-{b}+{c}+{d}=7")
elif a+b-c-d==7 :
    print(f"{a}+{b}-{c}-{d}=7")
elif a+b-c+d==7 :
    print(f"{a}+{b}-{c}+{d}=7")
elif a+b+c-d==7 :
    print(f"{a}+{b}+{c}-{d}=7")
elif a+b+c+d==7 :
    print(f"{a}+{b}+{c}+{d}=7")


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

typedef long long ll;
typedef unsigned long long ull;

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

    int i=1;
    do{
        int x=i;
        if(x%3==0){
            cout << " " << i;
            continue;
        }
        do{
            if(x%10==3){
                cout << " " << i;
                break;
            }
            x/=10;
        }while(x!=0);
    }while(++i<=n);
    
    cout << endl;

    return 0;
}


Measured memory_bytes: 3084
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

//#define MOD (int)(1e5 + 7)
#define MOD (100007)

static inline void done(const char *s)
{
	puts(s);
	exit(0);
}

#define yes() done("Yes");
#define no() done("No");
#define invalid() done("-1");

static int comp(const void *a, const void *b)
{
	int *pa = (int *)a;
	int *pb = (int *)b;
	return *pa < *pb;
}

static inline int *readNint(int n)
{
	int *a = calloc(sizeof(int), n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	return a;
}

static inline long *readNlong(int n)
{
	long *a = calloc(sizeof(long), n);
	for (int i = 0; i < n; i++)
		scanf("%ld", &a[i]);
	return a;
}

char S[200000 + 100000 + 200000];

int main(int argc, char **argv)
{
	int st = 200000;
	scanf("%s", &S[st]);
	int L = strlen(&S[st]);
	int lt = st + L;
	fprintf(stderr, "%d %s\n", L, &S[st]);
	int dir = 1;
	int Q;
	scanf("%d", &Q);
	char buf[256];
	fgets(buf, 256, stdin); // discard
	for (int q = 0; q < Q; q++) {
		char buf[256];
		fgets(buf, 256, stdin);
		fprintf(stderr, "%d %s\n", q, buf);
		char T = buf[0];
		char F = buf[2];
		char C = buf[4];
		if (T == '1') {
			dir = -dir;
			continue;
		}
		if (F == '1') {
			if (dir == 1) {
				--st;
				S[st] = C;
			} else {
				S[lt] = C;
				++lt;
			}
		} else {
			if (dir == -1) {
				--st;
				S[st] = C;
			} else {
				S[lt] = C;
				++lt;
			}
		}
	}
	if (dir == 1) {
		printf("%s\n", &S[st]);
	} else {
		for (int i = lt - 1; i >= st; i--) {
			printf("%c", S[i]);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 768
int main(){
int a[10000],i,n,max,min;
long s=0;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%d",&a[i]);
}
for(i=1; i<=n; i++){
s += a[i];
//printf("%d\n",s);
}
max=a[1];
for(i=2;i<=n;i++){
if(a[i]>max){
max=a[i];
}
}
min=a[1];
for(i=2;i<=n;i++){
if(a[i]<min){
min=a[i];
}
}
printf("%d %d %ld\n",min,max,s);
return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll i,j,k,m,n;
    ll t,a,b,c;
    ll ansa,ansb;
    ll cnt=0;
    cin>>n;
    cin>>t>>a;
    b=t,c=a;
    for(i=2; i<=n; i++)
    {
        cin>>t>>a;
        if(b/t>=c/a)
        {
            ansa=b/t*t;
            ansb=b/t*a;
        }
        else
        {
            ansa=c/a*t;
            ansb=c/a*a;
        }
        while(ansa<b||ansb<c)
        {
            ansa+=t,ansb+=a;
        }
        b=ansa,c=ansb;
    }
    cout<<b+c<<endl;
    return 0;
}



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

using namespace std;



int main() {
	int N ;
	cin >> N;
	long long ans = 0;
	for (int n = 0; n <= N;++n) {
		if (0 == n%3) {
			continue;
		}
		if (0 == n%5) {
			continue;
		}
		ans += (long long)n;
	}
	cout << ans <<endl;
	return 0;
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s;
  cin >> s;

  bool AC = true;

  if (s[0] != 'A') AC = false;

  for (auto e : s) {
    if (e != 'A' && e != 'C') {
      if (e >= 'A' && e <= 'Z') AC = false;
    }
  }

  int Ccnt = 0;
  for (int i = 2; i <= s.length() - 2; ++i) {
    if (s[i] == 'C') ++Ccnt;
  }
  if (Ccnt != 1) AC = false;

  cout << (AC ? "AC" : "WA") << "\n";

  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> buttons(n);
  
  map<int, bool> appears;
  
  for(int i=0; i<n; i++) {
    cin >> buttons.at(i);
  }
  
  int current = 1;
  int counter = 0;
  
  while(true){
    counter++;
    current = buttons[current-1];
    if(current == 2){
      cout << counter << endl;
      return 0;
    } else if (appears.find(current) != appears.end() ) {
      cout << -1 << endl;
      return 0;
    }
    appears[current] = true;
  }
}


Measured memory_bytes: 5376
#include <iostream>

using namespace std;

int main()
{
int n,A=0,B=0,C=0,D=0;
cin>>n;
string s;
for(int i=0;i<n;i++){
    cin>>s;
    if(s=="AC")A++;
    else if (s=="WA")B++;
    else if (s=="TLE")C++;
    else if (s=="RE")D++;
}
cout<<"AC"<<" x "<<A<<endl;
cout<<"WA"<<" x "<<B<<endl;
cout<<"TLE"<<" x "<<C<<endl;
cout<<"RE"<<" x "<<D<<endl;
    return 0;
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        VI cnt(32);
        FOR(_,0,n) {
            int a; cin >> a;
            FOR(i,0,cnt.size()) if (a&(1<<i))
                cnt[i]++;
        }
        bool good = true;
        FOR(i,0,cnt.size()) if (cnt[i]&1)
            good = false;
        if (good)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
class Main {

	/**
	 * 九九を出力する。
	 *
	 * @param a
	 *            利用しない。
	 */
	public static void main(String[] a) {

		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				System.out.println(i + "x" + j + "=" + i * j);
			}
		}

	}
}

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

int main(){
    int n, q;
    string s;
    cin >> n >> q >> s;
    vector<int> v(n, 0);
    int sum = 0;
    for(int i = 1; i < n; i++)
    {
        if (s.substr(i - 1, 2) == "AC") {
            sum++;
        }
        v[i] += sum;
    }
    
    for(int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        int count = v[r - 1] - v[l - 1];
        cout << count << "\n";
    }
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

ll mod_pow(ll a,ll b,ll p){ //(a^b)%p
	ll res=1;
	a%=p;

	while(b>0){
		if(b&1==1) res=((res%p)*(a%p))%p;
		a=(a%p*a%p)%p;
		b>>=1;
	}
	return res;
}

//mod_inv=mod_pow(denominator,MOD-2,MOD);
int fac[MAXSIZE+6];
int inv[MAXSIZE+6];

void pre(){
	fac[0] = 1;
	for(int i=1;i<=MAXSIZE;i++){
		fac[i] = fac[i-1] * (i);
		fac[i]%=mod;
	}
	inv[MAXSIZE] = mod_pow(fac[MAXSIZE],mod-2,mod);
	for(int i=MAXSIZE-1;i>=0;i--){
		inv[i] = (i+1) * inv[i+1];
		inv[i]%=mod;
	}
}

int nCr(int n, int r){
	if(r>n) return 0;
	int ans = fac[n];
	ans%=mod;
	ans = ans * inv[r];
	ans%=mod;
	ans = ans * inv[n-r];
	ans%=mod;
	return ans;
}


int32_t main(){
	fastio();
	pre();
	int n , k;
	cin >> n >> k;
	k = min( k , n - 1);
	int ans = 0;
	for(int i = 0 ; i <= k; i++){
		ans += nCr( n , i) * (nCr( n  - i + i - 1 , n - i - 1));
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 19284
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
bool alr[MAXN];
int main(){
    int r, c;
    cin >> r >> c;
    int n;
    cin >> n;
    vector<pair<int,int> >upp, lef, rig, dow;
    for(int i =1; i <= n; i++){
            bool ivica1 = false, ivica2= false;
            int x1, y1, x2, y2;
            cin >> x1 >> y1 >> x2 >> y2;
            ivica1 = (x1 == 0 || x1 == r || y1 == 0 || y1 == c);
            ivica2 = (x2 == 0 || x2 == r || y2 == 0 || y2 == c);
            if(!ivica1 || !ivica2) continue;
            if(x1 == 0){
                upp.push_back({y1, i});
            } else if(x1 == r){
                dow.push_back({y1, i});
            } else if(y1 == 0){
                lef.push_back({x1, i});
            } else if(y1 == c){
                rig.push_back({x1, i});
            }
            if(x2 == 0){
                upp.push_back({y2, i});
            } else if(x2 == r){
                dow.push_back({y2, i});
            } else if(y2 == 0){
                lef.push_back({x2, i});
            } else if(y2 == c){
                rig.push_back({x2, i});
            }
    }
    sort(upp.begin(), upp.end());
    sort(rig.begin(), rig.end());
    sort(dow.begin(), dow.end());
    reverse(dow.begin(), dow.end());
    sort(lef.begin(), lef.end());
    reverse(lef.begin(), lef.end());
    vector<int> indices;
    for(auto x : upp) indices.push_back(x.second);
    for(auto x : rig) indices.push_back(x.second);
    for(auto x : dow) indices.push_back(x.second);
    for(auto x : lef) indices.push_back(x.second);
    int op = 0;
    bool okay = true;
    stack<int> st;
    for(int i = 0; i < indices.size(); i++){
        int x = indices[i];
        if(!alr[x]){
            st.push(x);
            alr[x] = true;
        } else {
            if(st.top() != x) {okay = false;
            break;}
            st.pop();
        }
    }
    cout << (okay ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 3796
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n;
		while((n = scan.nextInt()) > 0){
			int[][] c = new int[n][2];
			int sumA = 0;
			int sumB = 0;
			
			for(int i = 0; i < n; i ++){
				int a = c[i][0] = scan.nextInt();
				int b = c[i][1]	= scan.nextInt();
				
				if(a > b)
					sumA += a + b;
				else if(a == b){
					sumA += a;
					sumB += b;
				}else if(a < b)
					sumB += a + b;
			}
			System.out.println(sumA + " " + sumB);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <functional>
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, p[20];
    cin >> n;

    int max = 0;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        if (p[i] > max) max = p[i];
    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += p[i];
    }
    cout << sum - max / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

unsigned gcd(unsigned a, unsigned b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

const UINT mod = 1000000007;

UINT PowMod(UINT x, UINT y)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = PowMod(x, y / 2);
		return tmp * tmp % mod;
	}
	else
	{
		auto tmp = PowMod(x, y / 2);
		return (tmp * tmp % mod) * x % mod;
	}
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

int main()
{
	int a, b;
	cin >> a >> b;
	cout << ((a <= 9 && b <= 9) ? a * b : -1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_set>
#include<vector>
#include<utility>
#include<cstring>
#define pb(a)             push_back(a)
#define mp(a,b)           make_pair(a,b)
#define pf printf
#define ff first
#define ss second
#define sef second.first
#define ses second.second
#define ms(a,b)            memset(a, b, sizeof(a))
#define loop(i,a)          for(int i=1;i<=a;i++)
#define pii                pair <int,int>
#define sl(a)              scanf("%I64d",&a)
#define sll(a,b)           scanf("%I64d %I64d",&a,&b)
#define si(a)              scanf("%d",&a)
#define sii(a,b)           scanf("%d %d",&a,&b)
using namespace std ;
typedef long long ll ;
const ll mod = 1e9+7;
int main()
{
  ll n,k;
  cin >> n >> k ;
  vector < ll > arr(n+5) , brr(n+5,0),crr(n+5,0);
  loop(i,n+1)
  {
      arr[i]=i-1;
  }
  int last = n+1;
  loop(i,n+1)
  {
      brr[i]=arr[i]+brr[i-1];
      crr[last]=arr[last]+crr[last+1];
      last--;
  }
  /*loop(i,n+1)
  {
      cout << arr[i] << " " << brr[i] << " " << crr[i] << endl;
  }*/
  ll ans = 0;
  for(int i=k;i<=n+1;i++)
  {
      ll part = 1 - brr[i]+crr[n+2-i] ;
      ans=(ll)(ans+part)%mod;
  }
  cout << ans << endl;
  return 0 ;
}


Measured memory_bytes: 8008
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> vint;
typedef vector<char> vchar;

#define PI 3.141592653589793238462643383279
#define intinf 2000000014
#define longinf 2000000000000000014LL
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> x >> y >> z
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct edge{
  int to, cost;
};

vector<edge> G[1000];

ll bellmanford(int v, int e, int r){
  ll d[v], res = 0;
  int roopcnt, i, j;
  rep(i, v)d[i] = longinf;
  d[r] = 0LL;
  for(roopcnt = 0;roopcnt < v;roopcnt++){
    bool upd = false;
    rep(i, v){
      rep(j, G[i].size()){
        edge tmp = G[i][j];
        if(d[i] != longinf && d[tmp.to] > d[i] + tmp.cost){
          d[tmp.to] = d[i] + tmp.cost;
          upd = true;
        }
      }
    }
    if(!upd)break;
    if(roopcnt == v - 1){
      pri("NEGATIVE CYCLE");
      return 0;
    }
  }

  rep(i, v){
    if(d[i] >= longinf)pri("INF");
    else pri(d[i]);
  }

  return res;
}

signed main(void){
  int i, j, tmp, tmp2;
  for(int testcase = 0;;testcase++){
    int3(v, e, r);
    rep(i, e){
      int3(s, t, d);
      G[s].pb((edge){t, d});
    }
    bellmanford(v, e, r);

/*/

//*/ break;
  }
  return 0;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define INF         1e9
#define fastRead    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

const int MAX = 1e6 + 6;
int main()
{
    fastRead;
    int n, k;
    cin>>n>>k;
    
    vector<int>vec(n);
    for(int i =0 ; i < n ; i++) cin>>vec[i];
    
    for(int i =0 ; i < k ; i++ ) {
        
        vector<int>tmp(n+1);
        
        for(int i= 0 ; i < n ; i++ ) {
            int l = max(0, i - vec[i]);
            int r = min(n-1, i + vec[i]);
            tmp[l]++;
            tmp[r+1]--;
//            cout<<i<<" -> "<<l<<" "<<r<<'\n';
        }
        for(int i =1 ; i < n ; i++ ) {
            tmp[i] += tmp[i-1];
        }
        for(int i =0 ; i < n ; i++ ) vec[i] = tmp[i];
        
        bool ok = 1;
        for(int i =0 ; i < n ; i++ ) {
            if(vec[i] != n ) ok = 0;
        }
        if(ok) break;
    }
    
    for(auto x : vec) cout<<x<<" ";
    cout<<'\n';
    return 0;
    
}

Measured memory_bytes: 4868
def recon(l, r)
  return if l > r
  c = @pre.shift
  m = @in.index(c)
  recon(l, m-1)
  recon(m+1, r)
  @out << c
end

n = gets.to_i
@pre = gets.split.map { |i| i.to_i }
@in = gets.split.map { |i| i.to_i }
@out = []
recon(0, n-1)
puts @out*' '

Measured memory_bytes: 8712
# -*- coding: utf-8 -*-

from functools import reduce

N = int(input())
TN = [int(input()) for i in range(N)]

# ようは最小公倍数を出せればいいと思う
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(TN))

Measured memory_bytes: 3572
#include <stdio.h>
int main(void) {
        char text[50];
        if(scanf("%s",text)==1);
        int t=0,i;
        for(i=0;i<3;i++){
                if(text[i]=='o')t++;
        }
        printf("%d\n",700+100*t);
        return 0;
}


Measured memory_bytes: 128
/**
*
* Author: Mouhanad
* Lang: GNU C++14
*
**/
#include<bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define ii pair < int , int >
#define LS pair < ll , string >
typedef long long ll;
const int inf = 1<<30;
const int N =100100;
int n , a[N] , q ;

int main ( ){
  string s , t ;
  cin >> s >> t ;
  cin >> n >> q ;
  string h;
  cin >> h ;
  if ( s == h ) n--;
  if ( t == h ) q--;
  cout << n <<" " << q <<endl;
return 0 ;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int H[] = new int[N];
        int cnt = 0;
        for(int i=0; i<N; i++) {
        	H[i] = sc.nextInt();
        	if(i==0) {
        		cnt++;
        	}else {
        		for(int j=0; j<i; j++) {
        			if(H[i]<H[j]) {
        				break;
        			}if(j==i-1) {
        				cnt++;
        			}
        		}
        	}
        }
        sc.close();
        System.out.println(cnt);      
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define for(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)    for(i, 0, n)
#define sz(x)        ((int)(x).size())
#define inf          1<<25

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

//typedef vector<int> vi;
//typedef vector<long long> vl;
//typedef vector<double> vd;
//typedef pair<int,int> pii;
//typedef pair<long,long> pll;
//typedef long long ll;

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

int main() {
    int n;
    cin >> n;
    
    int x;
    set<int> s;
    rep(i, n) cin >> x, s.insert(x);
    
    cout << s.size() << endl;
    
    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)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const ll Inf = 1e15;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    ll ans = Inf;
    ll cnt = 0;
    vector<ll> a(n), b(n);
    rep (i, n) {
      cin >> a[i];
      b[i] = a[i];
    }
    ll sum = 0;
    rep (i, n) {
      sum += a[i];
      if (i % 2 == 1 && sum >= 0) {
        ll diff = abs(sum) + 1;
        cnt += diff;
        sum = -1;
      } else if (i % 2 == 0 && sum <= 0) {
        ll diff = abs(sum) + 1;
        cnt += diff;
        sum = 1;
      }
    }
    ans = (ll)min(ans, cnt);
    cnt = 0;
    sum = 0;
    rep (i, n) {
      sum += a[i];
      if (i % 2 == 0 && sum >= 0) {
        ll diff = abs(sum) + 1;
        cnt += diff;
        sum = -1;
      } else if (i % 2 == 1 && sum <= 0) {
        ll diff = abs(sum) + 1;
        cnt += diff;
        sum = 1;
      }
    }
    ans = (ll)min(ans, cnt);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	n := readI()
	s := make(map[string]int)
	for i := 0; i < n; i++ {
		tmp := readS()
		if _, ok := s[tmp]; ok {
			s[tmp]++
		} else {
			s[tmp] = 1
		}
	}
	max := 0
	maxS := make([]string, 0)
	for k, v := range s {
		if v > max {
			max = v
			maxS = []string{k}
			continue
		} else if v == max {
			maxS = append(maxS, k)
		}
	}
	sort.Strings(maxS)
	for i := 0; i < len(maxS); i++ {
		fmt.Println(maxS[i])
	}
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 32552
#include <bits/stdc++.h>
using namespace std;
#define MAX_N 100000
#define MAX_M 100000
const int INF = 1e9;

int main() {
  int A,B,C,i;
  cin>>A>>B>>C;
  for(i=0;i*A+(i/7)*B<C;i++){
  }
  cout<<i<<endl;
}


Measured memory_bytes: 3092
#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>;
 
struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int root(int x) {
    if (d[x] < 0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);}
  int size(int x) { return -d[root(x)];}
};

int main(void){
    int n, m, k;
    std::cin >> n >> m >> k;
    int a, b, c, d;
    std::vector<int> friendcnt(n, 0);
    std::vector<int> block[n];

    UnionFind uf(n);
    for(int i = 0; i < m; i++){
        std::cin >> a >> b;
        a--;
        b--;
        friendcnt[a]++;
        friendcnt[b]++;
        uf.unite(a, b);
    }

    for(int i = 0; i < k; i++){
        std::cin >> c >> d;
        c--;
        d--;
        block[c].push_back(d);
        block[d].push_back(c);
    }
    int answer;
    for(int i = 0; i < n; i++){
        answer = uf.size(i) - 1 - friendcnt[i];
        for(auto j : block[i]){
            if(uf.same(i, j)){
                answer--;
            }
        }
        std::cout << answer << " ";
        //answer = 0;
    }
    std::cout << std::endl;
}

Measured memory_bytes: 6784
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int L = sc.nextInt();
		
		String[] S = new String[N];
		for(int i=0;i<N;i++) {
			S[i] = sc.next();
		}
		sc.close();

		Arrays.sort(S);
		
		for(int i=0;i<N;i++) {
			out.print(S[i]);
		}
		out.println();
		
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
	
	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray1origin(Scanner sc, int n) {
		int[] result = new int[n + 1];
		for (int i = 1; i <= n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


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

using namespace std;

int main () {
	char a, b, c;
	scanf("%c%c%c", &a, &b, &c);
	if (a == '7' || b == '7' || c == '7')
		printf("Yes");
	else 
		printf("No");
	return 0;
}


Measured memory_bytes: 3828
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <list>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <complex>
#include <assert.h>
#include <limits.h>
//#include <bits/stdc++.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp

//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<int,ll>pil;
typedef pair<ll,ll> pll;
//const double INF=1e20;
const int INF=0x3f3f3f3f;
//const int INF= 0x7fffffff;
//const ll INF=0x3f3f3f3f3f3f3f3fll;
const ll INFF=0x3f3f3f3f3f3f3fll;
//const ll INFF=1e14+5;
const int MAX=1e6+5;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
//const ll MOD=1e9+7;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
//#define double long double
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
//const long double eps=-1.0;
//clock_t t1 = clock();
//fprintf(stderr, "%ld ms\n", clock() - t1);
void open()
{
    freopen("in2.txt","r",stdin);
    freopen("out2.txt","w",stdout);
}
int a[105];
int main()
{
    for(int i=0;i<3;i++)scanf("%d",&a[i]);
    sort(a,a+3);
    int an=0;
    if(a[0]%2!=a[1]%2)
    {
        ++a[0];++a[2];an=1;
    }
    an+=(a[2]-a[1])+(a[1]-a[0])/2;
    printf("%d\n",an);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mode        998244353
#define mod         1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define pi          3.14159265358979323


void solve()
{
       ll n;
       cin>>n;
       ll a[n];
       rep(i,0,n) cin>>a[i];
       ll pre[n], suf[n];
       pre[0]=a[0], suf[n-1]=a[n-1];
       for(int i=1; i<n; i++) pre[i] = __gcd(pre[i-1], a[i]);
       for(int i=n-2; i>=0; i--) suf[i]=__gcd(suf[i+1],a[i]);
       ll ans=max(suf[1], pre[n-2]);
       for(int i=1; i<n-1; i++) ans=max(ans, __gcd(pre[i-1],suf[i+1]));
       cout<<ans;
}

int main() {
	ll T = 1;
	speed_up
	//cin>>T;
	while(T--)
	    solve();
	return 0;
}


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

#ifdef ARTEM
	#define deb(x) x
#else
	#define deb(x)
	const int LIMIT = 2 * int(1e5) + 123;
#endif

void solve();

int main() {
	solve();
}

/* ================ actual code starts here ================ */

void solve() {
	int n;
	long long d;
	scanf("%d%lld", &n, &d);

	int ans = 0;
	for(int i = 0; i < n; i++) {
		long long xi, yi;
		scanf("%lld%lld", &xi, &yi);
		if(d * d >= xi * xi + yi * yi) {
			ans++;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 3740
from bisect import bisect_right
N,H = map(int,input().split())
A = []
B = []
for _ in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)
A = sorted(A,reverse=True)
B = sorted(B)
a = A[0]
ind = bisect_right(B,a)
cnt = 0
flag = 0
for i in range(N-1,ind-1,-1):
    H -= B[i]
    cnt += 1
    if H<=0:
        flag = 1
        break
if flag==0:
    k = H//a
    if H%a>0:
        k += 1
    cnt += k
print(cnt)

Measured memory_bytes: 63064
using System.Linq;
using System.Text;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Threading;

namespace AtCoder
{
    class Program
    {

        struct Point
        {
            public int x;
            public int y;

            public Point(int x, int y)
            {

                this.x = x;
                this.y = y;

            }

        }


        const int BiggestMod = 1000000007;

        public static void Main()
        {

            Console.WriteLine(int.Parse(Console.ReadLine()) < 30 ? "No" : "Yes");

        }

    }

}

Measured memory_bytes: 27540
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int c;
    if(b<10)c = a*10+b;
    else if(b<100)c = a*100+b;
    else c = a*1000+b;
    int i;
    for(i=4;i<320;i++)
    {
        if(i*i==c)
        {
            printf("Yes");
            break;
        }
    }
    if(i>=320)printf("No");
    return 0;
}


Measured memory_bytes: 128
<>=~$";$s+=$_ for@@=glob<>;printf sort{$b-$a}grep{$t=0;$h=$_;@_=map$t+=$_,sort{$a-$b}map$_%$h,@@;$'>=$_[-$t/$h-1]}map$s%$_?():($_,$s/$_),1..3e4

Measured memory_bytes: 3200
import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int ans = 1;
    int count = 0;
    for (int i = n; i > 0; i--) {
      int countA = 0;
      int a = two(i);
      while (a!=-1){
        countA++;
        a = two(a);
      }
      if (countA>count) {
        ans = i;
        count = countA;
      }
    }
    System.out.println(ans);
  }
  static int two (int n) {
    if (n%2==0) {
      return n/2;
    } else {
      return -1;
    }
  }
}


Measured memory_bytes: 23636
#include <iostream>

using namespace std;
unsigned gcd(unsigned a,unsigned b);
unsigned lcm(unsigned a,unsigned b);
int main(){
  unsigned a,b;

  while(cin>>a>>b){
    cout<<gcd(a,b)<<" "<<lcm(a,b)<<endl;
  }
  return 0;
} 

unsigned gcd(unsigned a,unsigned b){

  while(a%b){
    a^=b;
    b^=a;
    a^=b;
    b=b%a;
  }
  return b;
}
unsigned lcm(unsigned a,unsigned b){
  return a/gcd(a,b)*b;
}

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

int main(void)
{
  int a,b,c,k;

  scanf("%d %d %d %d",&a,&b,&c,&k);

  if(k<=a) printf("%d\n",k);
  else if(a<k && k<=a+b) printf("%d\n",a);
  else printf("%d\n",2*a+b-k);

  return 0;
}

Measured memory_bytes: 1732
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			if (n == 0) {
				break;
			}
			
			ArrayList<Integer> cards = new ArrayList<Integer>();
			for (int i = n; i >= 1; i--) {
				cards.add(i);
			}
			
			for (int i = 0; i < r; i++) {
				int p = sc.nextInt();
				int c = sc.nextInt();
				
				for (int j = 0; j < c; j++) {
					int k = cards.remove(p - 1 + c - 1);
					cards.add(0, k);
				}
			}
			System.out.println(cards.get(0));
		}
	}
}

Measured memory_bytes: 29508
#include<iostream> //cinなど
#include<string> //文字列
#include<algorithm> //sort など
#include<math.h> //paw(冪乗など)
#include<set> // 集合
#include<map> //写像
#include<stdio.h> //printf
#include<stack>

using namespace std;


int main(){
  string sa,sb,sc;
  cin >> sa >> sb >> sc;
  char player = 'a';
  int ia = 0,ib = 0,ic = 0;
  int win;
  while(1){
    if(player == 'a'){
      if(ia == sa.size()){win = 0;break;}
      ia++; player = sa[ia-1];
    }
    if(player == 'b'){
      if(ib == sb.size()){win = 1;break;}
      ib++; player = sb[ib-1];
    }
    if(player == 'c'){
      if(ic == sc.size()){win = 2;break;}
      ic++; player = sc[ic-1];
    }
  }
  if(win == 0) cout<< "A"<<endl;
  else if(win == 1) cout<< "B" <<endl;
  else cout<< "C" << endl;
   return 0;
}


Measured memory_bytes: 256