akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int main(){
  string a;
  cin>>a;
  int A=a[0]-'0',B=a[1]-'0',C=a[2]-'0',D=a[3]-'0';


  for(int i=0;i<2;i++){
    for(int j=0;j<2;j++){
      for(int k=0;k<2;k++){
        int temp=0;
        if(i==0){
          temp+=A+B;
        }else temp+=A-B;

        if(j==0)temp+=C;
        else temp-=C;

        if(k==0)temp+=D;
        else temp-=D;

        if(temp==7){
          cout<<A;
          i==0 ? cout<<'+' : cout<<'-';
          cout<<B;
          j==0 ? cout<<'+' : cout<<'-';
          cout<<C;
          k==0 ? cout<<'+' : cout<<'-';
          cout<<D<<"=7";

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


}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	
    public static void main(String args[]){
Scanner sc=new Scanner(System.in);
String a=sc.next();
String b=sc.next();
String c=sc.next();
a=a.toUpperCase();
b=b.toUpperCase();
c=c.toUpperCase();
String A=a.substring(0,1);
String B=b.substring(0,1);
String C=c.substring(0,1);

System.out.println(A+B+C);
 }
}
  

Measured memory_bytes: 22996
#include<iostream>
#define R(i,n)for(int i=0;i<=n;i++)
int a,b,c,x,s;main(){std::cin>>a>>b>>c>>x;R(i,a)R(j,b)R(k,c)if(x==(500*i+100*j+50*k))s++;std::cout<<s;}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

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

  int64 N, D;
  cin >> N >> D;
  two_sat sat(N);
  vector<int64> X(N), Y(N);
  REP(i, N) {
    cin >> X[i] >> Y[i];
  }
  REP(i, N) {
    REP(j, N) {
      if (i == j) continue;
      if (abs(X[i] - X[j]) < D)
        sat.add_clause(i, false, j, false);
      if (abs(X[i] - Y[j]) < D)
        sat.add_clause(i, false, j, true);
      if (abs(Y[i] - X[j]) < D)
        sat.add_clause(i, true, j, false);
      if (abs(Y[i] - Y[j]) < D)
        sat.add_clause(i, true, j, true);
    }
  }
  if (sat.satisfiable()) {
    cout << "Yes" << endl;
    auto ans = sat.answer();
    REP(i, ans.size()) {
      cout << (ans[i] ? X[i] : Y[i]) << endl;
    }
  } else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3800
#include <iostream>
using namespace std;
using LL = long long;
const int Maxn = 1e5 + 20;
const LL Mod = 1e9 + 7;
int A[Maxn];
int B[3];
int main(){
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	for(int i = 1; i <= N; ++i){
		cin >> A[i];	
	}
	B[0] = -1, B[1] = -1, B[2] = -1;
	LL ans = 1;
	for(int i = 1; i <= N; ++i){
		int cnt = 0;
		for(int j = 0; j < 3; ++j){
			if(B[j] + 1 == A[i]){
				++cnt;	
			}	
		}
		if(cnt == 0){
			cout << "0";	
			return 0;
		} 
		ans = cnt * ans % Mod;
		for(int j = 0; j < 3; ++j){
			if(B[j] + 1 == A[i]){
				B[j] += 1;	
				break;
			}	
		}
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

#define inf 2000000001
#define max 2000000
int a[max];
int h = 0;
int parent(int i){return i / 2;}
int left(int i){return 2 * i;}
int right(int i){return 2 * i + 1;}

void heapincrease(int i, int key){
    if(key < a[i]) return;
    a[i] = key;
    while(i > 1 && a[parent(i)] < a[i]){
        swap(a[i], a[parent(i)]);
        i = parent(i);
    }
}

void insert(int key){
    h++;
    a[h] = -inf;
    heapincrease(h, key);
}

void maxheap(int i){
    int l = left(i);
    int r = right(i);
    int largest;
    if(l <= h && a[l] > a[i]) largest = l;
    else largest = i;
    if(r <= h && a[r] > a[largest]) largest = r;
    if(largest != i){
        swap(a[i], a[largest]);
        maxheap(largest);
    }
}

int heapextract(){
    if(h < 1) return -inf;
    int maxv = a[1];
    a[1] = a[h];
    h--;
    maxheap(1);
    return maxv;
}

int main(){
    string com;
    int x;
    while(com != "end"){
        cin >> com;
        if(com == "insert"){
            cin >> x;
            insert(x);
        }else if(com == "extract"){
            x = heapextract();
            cout << x << endl;
        }
    }
}


Measured memory_bytes: 6956
// package arc.arc078;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        long[] sum = new long[n+1];
        for (int i = 0; i < n ; i++) {
            sum[i+1] = sum[i] + in.nextLong();
        }

        long best = Long.MAX_VALUE;
        for (int i = 1 ; i <= n-1 ; i++) {
            long snuke = sum[i];
            long araisan = sum[n] - sum[i];
            best = Math.min(best, Math.abs(snuke - araisan));
        }
        out.println(best);
        out.flush();
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

Measured memory_bytes: 24680
import sys
input = lambda : sys.stdin.readline().rstrip()

n = int(input())
a = list(map(int, input().split()))
a = [(item, i) for i,item in enumerate(a)]
s = sorted(a)[::-1] # (value, index)
dp = [[None] * (n+1) for _ in range(n+1)] # 高い方からx+y人について、a_i * (p_i - i) + a_i * (i - p_i) の和の最大値

dp[0][0] = 0
tmp = 0
# dp[x][y] : 右にx個、左にy個
for i in range(n):
    val, ind = s[i]
    dp[i+1][0] = dp[i][0] + val * ((n-i-1) - ind)
for i in range(n):
    val, ind = s[i]
    dp[0][i+1] = dp[0][i] + val * (ind - i)

for i in range(2,n+1):
    for x in range(1,i):
        y = i - x
        val, ind = s[i-1]
        v1 = dp[x-1][y] + val * ((n-1 - (x-1)) - ind)
        v2 = dp[x][y-1] + val * (ind - (y-1))
        dp[x][y] = max(v1, v2)
print(max((dp[x][n-x] for x in range(n+1))))

Measured memory_bytes: 123424
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

const double EPS = 1e-10;

signed main(){
    int n;
    cin >> n;
    double x[4], y[4];
    rep(i, 0, n){
        rep(j, 0, 4){
            cin >> x[j] >> y[j];
        }
        double h1, h2;
        int cnt = 0;
        if(fabs(x[1] - x[0]) < EPS) cnt++;
        else h1 = (y[1] - y[0]) / (x[1] - x[0]);
        if(fabs(x[3] - x[2]) < EPS) cnt++;
        else h2 = (y[3] - y[2]) / (x[3] - x[2]);
        if(fabs(h1 - h2) < EPS || cnt == 2) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
}

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

using ll = int64_t;

signed main(){

  ll x,k,d;
  cin>>x>>k>>d;
  x = abs(x);

  __int128_t _x=x,_k=k,_d=d;

  if(_x>_k*_d){
    cout<< x-k*d <<endl;
  }
  else{
    k -= x/d;
    x -= x/d*d;
    cout<<(k&1?abs(x-d):x)<<endl;
  }

}

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

int main() {
string s;
 cin>>s;
  if(s=="SSS"){cout<<0<<endl;}
   if(s=="SSR"){cout<<1<<endl;}
  if(s=="SRS"){cout<<1<<endl;} 
  if(s=="SRR"){cout<<2<<endl;} 
  if(s=="RSS"){cout<<1<<endl;} 
  if(s=="RSR"){cout<<1<<endl;}
  if(s=="RRS"){cout<<2<<endl;}
  if(s=="RRR"){cout<<3<<endl;}
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
  int N,R;
  int ans;
  cin >> N >> R;
  if(N>=10){
      ans=R;
  }else{
      //R=ans-100*(10-N);
      ans=R+100*(10-N);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll q,h,w;
    cin >> q >> h >> w;
    ll cnt=0;
    rep(i,q){
        ll Q,H,W;
        cin >> H >> W;
        if(H>=h&&W>=w){
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;

typedef long long ll;

ll f(ll x, ll y) {
  if (x % y == 0) return x / y;
  else return x / y + 1;
}

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

  ll tnum, anum;
  cin >> tnum >> anum;

  for (int i=0; i<N-1; i++) {
    int t, a;
    cin >> t >> a;

    ll tmp = max(f(tnum, t), f(anum, a));
    tnum = t * tmp;
    anum = a * tmp;
  }

  cout << tnum + anum << endl;
  return 0;
}


Measured memory_bytes: 384
length = int(input())

s, t = map(str, input().split())

newString = ''
p = 0
if len(s) == length and len(t) == length:
    ls = (c for c in s)
    lt = (c for c in t)
    while (p != length):
        temString = next(ls) + next(lt)
        newString += temString
        p += 1
    print(newString)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int W,H;
int t[20][20];
int c;
char ch;

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

bool inField(int y,int x){
  if( 0<=y && y<H && 0<=x && x<W ){
    return true;
  }else{
    return false;
  }
}

void visit(int y,int x){
  c++;
  t[y][x]=1;
  for(int i=0;i<4;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if( inField(ny,nx) && t[ny][nx]==0){
      visit(ny,nx);
    }
  }
}
int main(){
  while(1){
    cin>>W>>H;
    if(W==0&&H==0)break;
    int sy,sx;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        cin>>ch;
        if(ch=='.'){
          t[i][j]=0;
        }
        if(ch=='@'){
          sy=i;
          sx=j;
        }
        if(ch=='#'){
          t[i][j]=-1;
        }
      }
    }
    c=0;
    visit(sy,sx);
    cout<<c<<endl;
  }
  return 0; 
}




Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

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

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> a(n);
  ll odd = 0, even = 0;
  REP(i, n) {
    cin >> a[i];
    a[i] /= 2;
  }
  ll l = 1;
  REP(i, n) { l = lcm(l, a[i]); }
  REP(i, n) {
    if ((l / a[i]) % 2 == 0) {
      even++;
    } else {
      odd++;
    }
  }
  if (even > 0) {
    cout << 0 << endl;
    return 0;
  }
  cout << m / l - m / (2 * l) << endl;
}

Measured memory_bytes: 1024
H, W = map(int, input().split())

A = [tuple(map(int, input().split())) for _ in range(H)]
B = [tuple(map(int, input().split())) for _ in range(H)]

C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]

D = 80 * (H + W) + 1
D2 = D * 2

dp = [[0] * W for _ in range(H)]

dp[0][0] |= 1 << (D + C[0][0])
dp[0][0] != 1 << (D - C[0][0])

for h in range(H):
    for w in range(W):
        tmp = C[h][w]
        if h:
            dp[h][w] |= dp[h - 1][w] << tmp
            dp[h][w] |= dp[h - 1][w] >> tmp
        if w:
            dp[h][w] |= dp[h][w - 1] << tmp
            dp[h][w] |= dp[h][w - 1] >> tmp

ans = D2

tmp = dp[H - 1][W - 1]

for i in range(D2):
    if (tmp >> i) & 1:
        ans = min(ans, abs(i - D))

print (ans)

Measured memory_bytes: 22136
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long 
#define mp make_pair
#define pb push_back
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)  ((a)*((b)/gcd(a,b)))
#define pi 3.14159265358979323846
#define reus ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int32_t main()
{
	reus;

//	#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
//	#endif
    
    int k;
    cin>>k;
    int x;
    x=7%k;
    for(int i=1;i<=k;i++)
    {
    	if(x==0)
    	{
    		cout<<i<<endl;
    		return 0;
		}
		x=(x*10+7)%k;
	}
	cout<<-1<<endl;
	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <string.h>
void swap(char *st1,char *st2){
	char tmp[3];
	memcpy(tmp,st1,3);
	memcpy(st1,st2,3);
	memcpy(st2,tmp,3);
}
int main(void){
	int n,i,j,min;
	char ori[36][3],bub[36][3],sel[36][3];
	scanf("%d",&n);
	for (i=0;i<n;i++)
		scanf("%s",ori[i]);
	memcpy(bub,ori,n*3);
	memcpy(sel,ori,n*3);
	for(i=0;i<n;i++)
		for(j=n-1;j>=i+1;j--)
			if (bub[j][1]<bub[j-1][1])
				swap(bub[j],bub[j-1]);
	for(i=0;i<n;i++){
		min=i;
		for(j=i;j<n;j++)
			if (sel[j][1]<sel[min][1])
				min=j;
		swap(sel[i],sel[min]);
	}
	for(i=0;i<n;i++)
		printf("%s%c",bub[i],i!=n-1?' ':'\n');
	printf("Stable\n");
	for (i=0;i<n;i++)
		printf("%s%c",sel[i],i!=n-1?' ':'\n');
	for(i=0;i<n;i++)
		if(sel[i][0]!=bub[i][0]||sel[i][1]!=bub[i][1])
			i=999;
	if(i==1000)printf("Not stable\n");
	else printf("Stable\n");
	
	return 0;
}

Measured memory_bytes: 620
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
		static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		int n=s[1]*2+1;
		Console.WriteLine("{0}",s[0]/n+(s[0]%n==0?0:1));
	}
}


public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}


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

int main(){
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (y + r > H || y - r < 0 || x + r > W || x - r < 0)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}

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

int FindNearestPlus(int x, const std::vector<int> &forbid)
{
    if (forbid.empty())
    {
        return x;
    }

    if (x < *forbid.cbegin())
    {
        return x;
    }

    auto current = x;
    for (const auto& val : forbid)
    {
        if (current != val)
        {
            return current;
        }
        ++current;
    }

    return current;
}

int FindNearestMinus(int x, const std::vector<int>& forbid)
{
    if (forbid.empty())
    {
        return x;
    }

    if (x > *forbid.cbegin())
    {
        return x;
    }

    auto current = x;
    for (const auto& val : forbid)
    {
        if (current != val)
        {
            return current;
        }
        --current;
    }

    return current;
}

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

    int n;
    std::cin >> n;
    std::vector<int> pos;
    std::vector<int> neg;
    bool xSelf = false;
    for (int i = 0; i < n; ++i)
    {
        int e;
        std::cin >> e;
        if (e > x)
        {
            pos.push_back(e);
        }
        else if (e < x)
        {
            neg.push_back(e);
        }
        else
        {
            xSelf = true;
        }
    }

    std::sort(pos.begin(), pos.end());
    std::sort(neg.begin(), neg.end(), [](const int& lhs, const int& rhs) {return lhs > rhs; });

    if (!xSelf)
    {
        std::cout << x;
        return 0;
    }

    const auto posAns = FindNearestPlus(x + 1, pos);
    const auto absPos = std::abs(posAns - x);

    const auto negAns = FindNearestMinus(x - 1, neg);
    const auto absNeg = std::abs(negAns - x);

    if (absPos < absNeg)
    {
        std::cout << posAns;
    }
    else
    {
        std::cout << negAns;
    }
}

Measured memory_bytes: 3636
/*                         _
                        _ooOoo_
                       o8888888o
                       88" . "88
                       (| -_- |)
                       O\  =  /O
                    ____/`---'\____
                  .'  \\|     |//  `.
                 /  \\|||  :  |||//  \
                /  _||||| -:- |||||_  \
                |   | \\\  -  /'| |   |
                | \_|  `\`---'//  |_/ |
                \  .-\__ `-. -'__/-.  /
              ___`. .'  /--.--\  `. .'___
           ."" '<  `.___\_<|>_/___.' _> \"".
          | | :  `- \`. ;`. _/; .'/ /  .' ; |
          \  \ `-.   \_\_`. _.'_/_/  -' _.' /
===========`-.`___`-.__\ \___  /__.-'_.'_.-'================

                  Please give me AC.
*/

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <bitset>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <chrono>
#include <random>

using namespace std;

using int64 = long long;
using uint64 = unsigned long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define print(x) cout << (x) << '\n'
#define print2(x, y) cout << (x) << ' ' << (y) << '\n'
#define print3(x, y, z) cout << (x) << ' ' << (y) << ' ' << (z) << '\n'
#define printn(v) rep(i, (v).size() - 1) cout << (v)[i] << ' '; cout << (v)[n - 1] << '\n';
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define debug2(x, y) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// constant
const int INF = (1 << 30) - 1;
const int64 INF64 = (1LL << 62) - 1;

template<typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    T r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

template<typename T>
T lcm(const T a, const T b) {
    return a / gcd(a, b) * b;
}

template<typename T>
bool chmin(T &a, const T &b) {
    if (a > b) return a = b, true; else return false;
}

template<typename T>
bool chmax(T &a, const T &b) {
    if (a < b) return a = b, true; else return false;
}

// End of template.

int main() {
    cout << fixed << setprecision(15);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    // cin.read(buf, sizeof buf); // 注意: ./a.out < in か pbp | ./a.out で入力すること

    int64 a;
    string b;
    cin >> a >> b;
    int64 b100 = 100 * (b[0] - '0') + 10 * (b[2] - '0') + b[3] - '0';
    print((a * b100) / 100);

    return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <math.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const int mINF = -1001001001;


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


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

int main() {
  string s;
  cin >> s;
  cout << (s.find_last_of('Z') - s.find_first_of('A') + 1) << endl;
}

Measured memory_bytes: 3716
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  ll T[N], A[N];
  for(int i=0;i<N;++i) cin>>T[i];
  for(int i=0;i<N;++i) cin>>A[i];
  if(T[N-1]!=A[0]) {
    cout<<0<<endl;
    return 0;
  }
  ll mh = A[0];
  int l=-1, r=-1;
  for(int i=0;i<N;++i) {
    if(T[i]==mh && A[i]==mh) {
      l = i;
      break;
    }
  }
  for(int i=N-1;i>=0;--i) {
    if(T[i]==mh && A[i]==mh) {
      r = i;
      break;
    }
  }
  if(l==-1 || r==-1) {
    cout<<0<<endl;
    return 0;
  }
  ll ans = 1;
  for(int i=1;i<l;++i) {
    if(T[i-1]==T[i]) {
      ans *= T[i];
      ans %= mod;
    }
  }
  for(int i=N-2;i>r;--i) {
    if(A[i]==A[i+1]) {
      ans *= A[i];
      ans %= mod;
    }
  }
  for(int i=l+1;i<r;++i) {
    ans *= A[i];
    ans %= mod;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 5168
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.C_Challenge
{
    class ABC_060
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            long t = long.Parse(input[1]);
            input = Console.ReadLine().Split(' ');
            var ts = new long[n];
            for (int i = 0; i < n; i++)
            {
                ts[i] = long.Parse(input[i]);
            }

            long allTime = 0;
            long initIndex = 0;
            for(int i = 1; i < n; i++)
            {
                if (ts[i - 1] + t < ts[i])
                {
                    allTime += ts[i - 1] + t - ts[initIndex];
                    initIndex = i;
                }
            }
            allTime += ts[n - 1] + t - ts[initIndex];

            Console.WriteLine(allTime);
        }
    }
}


Measured memory_bytes: 28256
#include <iostream>
#include <cstdio>
#include <cmath>
 
using namespace std;
 
int main(void) {
 
    int a,b;
    string op;
 
    while(true) {
        cin >> a >> op >> b;
 
        if(op == "?")   break;
 
        if(op == "+") {
            cout << a + b << endl;
        } else if(op == "-") {
            cout << a - b << endl;
        } else if(op == "*") {
            cout << a * b << endl;
        } else if (op == "/") {
            cout << a / b << endl;
        }
    }
 
 
 
    return 0;
}

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

#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define rjm rep(j,m)


#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}


#define EPS 1e-10
#define ETOL 1e-8
#define MOD 100000009

li a, b, x;

inline li calc(li n) {
    if (n < 0)return 0;
    if (n == 0)return 1;
    return n / x + 1;
}

int main() {
    cin >> a >> b >> x;
    cout << calc(b) - calc(a - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define T int t, q=0; cin>>t; while(q++<t)
 
int main()
{
    int n, x, y;
    cin>>n>>x>>y;
    int ans[n+1]={};
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
//            int z=min(j-i, min(abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(x-j)));
//            cout<<z<<" ";
            ans[min(j-i, abs(x-i)+1+abs(j-y))]++;
 
        }
    }
    for(int i=1;i<n;i++)
        cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a > b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        if (b > c) {
            int tmp = b;
            b = c;
            c = tmp;
        }
        if (a > b) {
            int tmp = a;
            a = b;
            b = tmp;
        }
        System.out.println(String.format("%d %d %d", a, b, c));
        sc.close();
    }
}


Measured memory_bytes: 26332
a,b,c,d = list(map(int, list(str(input()))))

def calc(n, op, m):
  if(type(n) is not int):
    return False
  if(op == "+"):
    return n + m
  elif(op == "-"):
    return n - m
  elif(op == "*"):
    return n * m
  elif(m != 0):
    return n / m
  else:
    return False

ops1 = ["/", "+", "-", "*"]
ops2 = ["/", "+", "-", "*" ]
ops3 = ["/", "+", "-", "*" ]
for op1 in ops1:
  for op2 in ops2:
    for op3 in ops3:
      if(calc(calc(calc(a,op1,b),op2,c),op3,d) == 7):
        print(a,op1,b,op2,c,op3,d,"=7", sep="")
        exit()
          


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

const int maxn=200010;
int n,k;
int a[maxn];
int x;

bool cmp(int x,int y){ return x>y; }

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&x), a[x]++;
	sort(a+1,a+1+n,cmp);
	int ans=0;
	for(int i=1;i<=k;i++) ans+=a[i];
	printf("%d\n",n-ans);
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e7 + 10;
bool flag[maxn];
int G[maxn], pri;
int read() {
	int x;
	scanf("%d", &x);
	return x;	
}
int main() {
	int n = read();
	vector<int> V(n + 1);
	for (int i = 1; i <= n; ++i) for (int j = i; j <= n; j += i) {
		V[j]++;
	}
	long long ans = 0;
	for (int i = 1; i <= n; ++i) ans = ans + 1ll * i * V[i];
	cout << ans << endl;
}

Measured memory_bytes: 42312
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a,b,c;
signed main()
{
	scanf("%d%d%d",&a,&b,&c);
	if(c>2)
	{
		for(int i=1;i<=b;i++)
		printf("%d ",c);
		for(int i=b+1;i<=a;i++)
		printf("%d ",c-1);
	}
	else
	{
		for(int i=1;i<=b;i++)
		printf("%d ",c);
		for(int i=b+1;i<=a;i++)
		printf("%d ",c+1);
	}
	return 0;
}

Measured memory_bytes: 1280
(defun solver ()
  (let ((a (read)) (b (read))
        (s (read-line)))
    (if (parse-integer s :start 0 :end a :junk-allowed t)
        (if (char= (char s a) #\-)
            (if (parse-integer s :start (+ a 1) :end (+ a b 1) :junk-allowed t)
                (format t "Yes~%")
                (format t "No~%"))
            (format t "No~%"))
        (format t "No~%"))))

(solver)

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

int main()
{
	int64_t n, m;
	cin >> n >> m;
	vector<pair<int, int>> ab(n);
	for (int i = 0; i < n; i++) {
		int64_t a_in, b_in;
		cin >> a_in >> b_in;
		ab.at(i) = make_pair(a_in, b_in);
	}

	sort(ab.begin(), ab.end());
	int64_t ans = 0;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int64_t ai, bi;
		ai = ab.at(i).first;
		bi = ab.at(i).second;
		if (cnt + bi < m) {
			ans += ai * bi;
			cnt += bi;
		} else {
			ans += ai * (m - cnt);
			cnt = m;
			break;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 1152
import sys
input=sys.stdin.readline

def main():
    N,M = map(int,input().split())
    if N==1 and M==1:
        print(1)
    elif N==1:
        print(M-2)
    elif M==1:
        print(N-2)
    elif N>=2 and M>=2:
        print((N-2)*(M-2))

if __name__ == '__main__':
    main()


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct Combinatorics {
  using int64 = long long;
  const int64 mod = 1e9+7;
  int64 fact[1202020];
  int64 invfact[1202020];
  Combinatorics() {
    fact[0] = invfact[0] = 1;
    for(int i = 1; i < 1202020; ++i) {
      fact[i] = fact[i-1]*i%mod;
      invfact[i] = minv(fact[i]);
    }
  }
  int64 mpow(int64 x, int64 n) const {
    int64 res = 1;
    while(n > 0) {
      if(n&1) res = res*x%mod;
      x = x*x%mod;
      n >>= 1;
    }
    return res;
  }
  int64 minv(int64 x) const {
    return mpow(x, mod-2);
  }
  int64 mfact(int64 x) const {
    return fact[x];
  }
  int64 C(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[r]%mod*invfact[n-r]%mod;
  }
  int64 P(int64 n, int64 r) const {
    if(r < 0 || n < r) return 0;
    return fact[n]*invfact[n-r]%mod;
  }
}C;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n;
  cin >> n;

  int ans = 0;
  int prv = 0;
  reps(i, 1, n) {
    int tmp = C.C(i-1, n-1-i)*C.mfact(i)%mod*C.mfact(n-1-i)%mod;
    ans += i*(tmp+mod-prv)%mod;
    ans %= mod;
    prv = tmp;
  }
  cout <<ans << endl;

  return 0;
}


Measured memory_bytes: 19072
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380



    int m[3][3];
int main() {
    cout << fixed << setprecision(10);

    REP(i, 3) {
        REP(j, 3) {
            cin >> m[j][i];
        }
    }
    int n;
    cin >> n;
    REP(k, n) {
        int num;
        cin >> num;
        REP(i, 3) {
            REP(j, 3) {
                if (num == m[j][i]) {
                    m[j][i] = 0;
                }
            }
        }
    }

    if (m[0][0] + m[0][1] + m[0][2] == 0) {
        cout << "Yes";
        return 0;
    }
    if (m[1][0] + m[1][1] + m[1][2] == 0) {
        cout << "Yes";
        return 0;
    }
    if (m[2][0] + m[2][1] + m[2][2] == 0) {
        cout << "Yes";
        return 0;
    }

    if (m[0][0] + m[1][0] + m[2][0] == 0) {
        cout << "Yes";
        return 0;
    }
    if (m[0][1] + m[1][1] + m[2][1] == 0) {
        cout << "Yes";
        return 0;
    }
    if (m[0][2] + m[1][2] + m[2][2] == 0) {
        cout << "Yes";
        return 0;
    }

    if (m[0][0] + m[1][1] + m[2][2] == 0) {
        cout << "Yes";
        return 0;
    }
    if (m[0][2] + m[1][1] + m[2][0] == 0) {
        cout << "Yes";
        return 0;
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main()
{
	long long int A,B,K;
	scanf("%lld%lld",&A,&B);
	K=(A+B)/2;
	if (abs(A-K) == abs(B-K))
	printf("%lld\n",K);
	else
	{
		printf("IMPOSSIBLE\n");
	}
	return 0;
}



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

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

  if (n%k) cout << 1 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/* Author : Ravikumar Navale */
#define fastIo() ios_base :: sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define pb push_back
#define endl  "\n"
typedef long long int ll;
vector<pair<ll,ll> >v1, v2, v3;
const ll MOD = 1e9 + 7;
const ll NM = 1e8 + 7;
const ll maxn = 1e5 + 7;
const long double peek = 1e7 ;
map<ll,ll> ma;
vector<ll> pr;
vector<bool> b(NM,true);
vector<ll> prod((1e5+7),0);



int main(){
    
    ll N;
    cin >> N;
    if(N%2)
        cout << N/2;
    else
        cout << (N/2) -1 ;
    
    
    return 0;
    


}



Measured memory_bytes: 13184
n = gets.to_i
if n % 4 == 0 || n % 7 == 0 || n % 11 == 0
  puts "Yes"
else
  (0..25).each do |x|
    (0..14).each do |y|
      if 4 * x + 7 * y == n
        puts "Yes"
        exit
      end
    end
  end
  puts "No"
end

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        int A = NextInt();
        int B = NextInt();
        int K = NextInt();
        List<int> a = new List<int>();
        int count = 0;
        for (int i = 1; i <= 100; i++)
        {
            if (A % i == 0 && B % i == 0) a.Add(i);
        }
        Console.WriteLine(a[a.Count()-K]);
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
 
const int mxN=100, mxK=1e5;
int n, a[mxN], k;
bool dp[mxK+1];
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	cin >> n >> k;
	for(int i=0; i<n; ++i)
		cin >> a[i];
	for(int i=0; i<=k; ++i) {
		for(int j=0; j<n; ++j)
			if(i-a[j]>=0&&!dp[i-a[j]])
				dp[i]=1;
	}
	cout << (dp[k]?"First":"Second");
}

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

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

int main() {
  int n;
  cin >> n;
  int mid[2];
  vector<p> xy;
  rep(i, n) {
    int x, y;
    cin >> x >> y;
    xy.emplace_back(x, y);
  }
  // rep(i,n)cout<<xy[i].first<<endl;
  int max = (-1) * inf;
  int min = inf;
  rep(i, n) {
    int fzero = xy[i].first + xy[i].second;
    if (max < fzero) {
      max = fzero;
    }
    if (min > fzero) {
      min = fzero;
    }
  }
  int ans = max - min;
  max = (-1) * inf;
  min = inf;
  rep(i, n) {
    int fzero = xy[i].first - xy[i].second;
    if (max < fzero) {
      max = fzero;
    }
    if (min > fzero) {
      min = fzero;
    }
  }
  if (ans < max - min) ans = max - min;
  cout << ans << endl;
  return 0;
}

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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int minword = min(a, min(b, c));
	if (minword == a)
		cout << min(b, c) + a;
	else if (minword == b)
		cout << b + min(a, c);
	else
		cout << c + min(a, b);

	return 0;
}

Measured memory_bytes: 256
n,a = map(int, input().split())
x = list(map(int,input().split()))
x = [i-a for i in x]

d = {}
d[0] = 1
for i in x:
    for j,k in list(d.items()):
        d[j+i] = d.get(j+i,0)+k
print(d[0]-1)

Measured memory_bytes: 3188
module Main where
import Data.Set(empty,insert,delete,member,size)

main = interact $ printer . solver . parser
int = read :: String -> Int

printer = unlines . (:[]) . show
parser = map int . tail . words

solver as = result
  where
    setadd st a = if member a st then delete a st else insert a st
    v = foldl setadd empty as
    result = size v


Measured memory_bytes: 16636
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;
const int M = 100000007;

int combi[500][500];

ll func(vector<int> v) {
  ll res = 1;
  int now = v[0];
  for (int i=1; i<v.size(); ++i) {
    res = (res * combi[v[i]+now][v[i]]) % M;
    now += v[i];
  }
  return res;
}

int main() {
  REP(i,500) combi[i][0] = 1;
  REP(i,500-1) REP(j,500-1) combi[i+1][j+1] = (combi[i][j+1]+combi[i][j]) % M;
  int n;
  while(cin>>n,n) {
    double p[n],q[n];
    int a[n], b[n];    
    REP(i,n) {
      cin>>p[i]>>a[i]>>q[i];
      b[a[i]] = i;
    }
    bool visited[n];
    memset(visited,0,sizeof(visited));
    vector<vector<int> > cycle;
    REP(i, n) {
      if (visited[i]) continue;
      int now = i;
      vector<int> tmp;
      do {
        tmp.push_back(now);
        visited[now] = 1;
        now = b[now];
      } while(now!=i);
      cycle.push_back(tmp);
    }
    double ans = 0;
    ll sub = 1;
    REP(i, cycle.size()) {
      int start;
      double mi = INF;
      int tmp = 0;
      REP(j, cycle[i].size()) {
        //cout << mi << " " << q[cycle[i][j]] - p[cycle[i][j]] << endl;
        int cc = cycle[i][j];
        if (abs(mi - (1/p[cc] - 1/q[cc])) < EPS) {
          tmp++;
        } else if (mi > 1/p[cc] - 1/q[cc]) {
          mi = 1/p[cc] - 1/q[cc];
          start = j;
          tmp = 1;
        }
      }
      sub = (sub*tmp)%M;
      //cout << "start = " << start << endl;
      REP(j, cycle[i].size()) {
        //cout << cycle[i][j] << " ";
        if (start == j) {
          ans += 1.0/p[cycle[i][j]];
        } else {
          ans += 1.0/q[cycle[i][j]];
        }
      }
    }
    vector<int> v;
    REP(i, cycle.size()) {
      v.push_back(cycle[i].size());
    }
    printf("%.12f %lld\n", ans, (sub*func(v)) % M);
    //cout << ans << " " << (sub*func(v)) % M << endl;
  }
}

Measured memory_bytes: 1964
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n) cin >> c[i];
    sort(all(a));
    sort(all(b));
    sort(all(c));

    ll ans = 0;
    rep(i, n){
        ll x = distance(upper_bound(all(c), b[i]), c.end());
        ll y = distance(a.begin(), lower_bound(all(a), b[i]));
        ans += x * y;
    }

    cout << ans << endl;
}

Measured memory_bytes: 1408
l=[]
s=input()
p=input()
d=len(p)
r=len(s)-len(p)
for i in range(r+1):
    u=s[i:i+len(p)]
    l.append(u)
y=0
for i in range(d):
    w=s[-len(p)+i:len(s)]+s[0:i]
    l.append(w)
d=l.count(p)
if d==0:
    print('No')
else:
    print('Yes')


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

int main() {
  int N, M, total = 0;
  cin >> N >> M;
  vector<int>A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    total += A.at(i);
  }
  sort(A.rbegin(), A.rend());
  if (A.at(M-1) * 4 * M >= total) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}

Measured memory_bytes: 256
import collections

h,w=map(int,input().split())
board=[list(input()) for _ in range(h)]
q=collections.deque()
if board[0][0]=='#':
  q.append((0,0,1,1))
else:
  q.append((0,0,0,0))
dp=[[10**18]*w for _ in range(h)]
ans=10**18
while len(q)!=0:
  x,y,cnt,flag=q.popleft()
  if x==w-1 and y==h-1:
    ans=min(ans,cnt)
  else:
    if x!=w-1:
      if flag==0:
        if board[y][x+1]=='#':
          if dp[y][x+1]>cnt+1:
            q.append((x+1,y,cnt+1,1))
            dp[y][x+1]=cnt+1
        else:
          if dp[y][x+1]>cnt:
            q.append((x+1,y,cnt,0))
            dp[y][x+1]=cnt
      else:
        if board[y][x+1]=='#':
          if dp[y][x+1]>cnt:
            q.append((x+1,y,cnt,1))
            dp[y][x+1]=cnt
        else:
          if dp[y][x+1]>cnt:
            q.append((x+1,y,cnt,0))
            dp[y][x+1]=cnt
    if y!=h-1:
      if flag==0:
        if board[y+1][x]=='#':
          if dp[y+1][x]>cnt+1:
            q.append((x,y+1,cnt+1,1))
            dp[y+1][x]=cnt+1
        else:
          if dp[y+1][x]>cnt:
            q.append((x,y+1,cnt,0))
            dp[y+1][x]=cnt
      else:
        if board[y+1][x]=='#':
          if dp[y+1][x]>cnt:
            q.append((x,y+1,cnt,1))
            dp[y+1][x]=cnt
        else:
          if dp[y+1][x]>cnt:
            q.append((x,y+1,cnt,0))
            dp[y+1][x]=cnt
print(dp[-1][-1])

Measured memory_bytes: 3700