akhauriyash/Code-Regression huggingface dataset:
import math
import queue
from collections import defaultdict
 
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def printQueue(q):
	r=q
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)

n = readInt()
if n%2==1:
	print((n+1)//2)
else:
	print(n//2)

Measured memory_bytes: 3948
S = input()

MOD = 10**9+7
dp = [[0 for _ in range(4)]for _ in range(len(S)+1)]
dp[0][0] = 1

for ind,i in enumerate(S):
    if(i=='A'):
        dp[ind+1][0] = dp[ind][0]
        dp[ind+1][1] = dp[ind][1] + dp[ind][0]
        dp[ind+1][2] = dp[ind][2]
        dp[ind+1][3] = dp[ind][3]
    elif(i=='B'):
        dp[ind+1][0] = dp[ind][0]
        dp[ind+1][1] = dp[ind][1]
        dp[ind+1][2] = dp[ind][2] + dp[ind][1]
        dp[ind+1][3] = dp[ind][3]
    elif(i=='C'):
        dp[ind+1][0] = dp[ind][0]
        dp[ind+1][1] = dp[ind][1]
        dp[ind+1][2] = dp[ind][2]
        dp[ind+1][3] = dp[ind][3] + dp[ind][2]
    else:
        dp[ind+1][0] = dp[ind][0]*3
        dp[ind+1][1] = dp[ind][1]*3 + dp[ind][0]
        dp[ind+1][2] = dp[ind][2]*3 + dp[ind][1]
        dp[ind+1][3] = dp[ind][3]*3 + dp[ind][2]
        
    dp[ind+1][0]%=MOD
    dp[ind+1][1]%=MOD
    dp[ind+1][2]%=MOD
    dp[ind+1][3]%=MOD

print(dp[-1][3]%MOD)


Measured memory_bytes: 57052
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
#define MAX 100005
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}
int main()
{

    ll n,a,b,c,d,e;
   cin>>n;
    ll arr[5];
    cin>>arr[0]>>arr[1]>>arr[2]>>arr[3]>>arr[4];
    sort(arr,arr+5);
    ll ans = n/arr[0];
    if(n%arr[0]!=0) ans++;
        cout<<ans+4<<endl;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // min, max, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <stack> // stack
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)

using namespace std;

typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;

int main() {
	ll l, r;
	cin >> l >> r;
	ll res = 1e10;
	for (ll i = l; i <= min(2019 + l, r); i++) {
		for (ll j = i + 1; j <= min(2019 + l, r); j++) {
			res = min(res, i * j % 2019);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
n,k = input().split()
n = int(n)
k = int(k)
count = 0
for i in range(1,k+1):
    if 6 * i % k == 0 and 2 * i % k == 0:
        s = (n - i) // k
        count += (s + 1) ** 3
print(count)


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

int main() {
	int x,y,z;
	cin >> x >> y >> z;

	cout << z << " " << x << " " << y << endl;


	return 0;
}




Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int K;
    in(K);

    string S;
    in(S);

    if (S.size() <= K)
        outl(S);
    else
        outl(S.substr(0, K) + "...");

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <math.h>
#include <string>

using namespace std;

int main(){

  long long n, k, digid;
  cin >> n >> k;

  for(int i=0; i>-1; i++){
    //cout << i <<" "<< n << endl;
    if(n < k) {
      digid = i+1;
      break;
    }
    n = n / k;
  }
  cout << digid;

}


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        a: usize, b: usize, q: usize,
        s: [usize; a],
        t: [usize; b],
        x: [usize; q],
    }

    let mut s_to_t = Vec::new();
    for &spos in &s {
        let idx = t.upper_bound(&spos);
        let dist = if idx > 0 && idx < b {
            min(t[idx] - spos, spos - t[idx-1])
        } else if idx == 0 {
            t[idx] - spos
        } else {
            spos - t[idx-1]
        };
        s_to_t.push(dist);
    }

    let mut t_to_s = Vec::new();
    for &tpos in &t {
        let idx = s.upper_bound(&tpos);
        let dist = if idx > 0 && idx < a {
            min(s[idx] - tpos, tpos - s[idx-1])
        } else if idx == 0 {
            s[idx] - tpos
        } else {
            tpos - s[idx-1]
        };
        t_to_s.push(dist);
    }

    for x in x {
        let mut res = Vec::new();
        let idx = s.lower_bound(&x);
        if idx < a {
            res.push(s[idx] - x + s_to_t[idx]);
        }
        if idx > 0 {
            res.push(x - s[idx-1] + s_to_t[idx-1]);
        }
        let idx = t.lower_bound(&x);
        if idx < b {
            res.push(t[idx] - x + t_to_s[idx]);
        }
        if idx > 0 {
            res.push(x - t[idx-1] + t_to_s[idx-1]);
        }
        let ans = res.into_iter().min().unwrap();
        println!("{}", ans);
    }

}


Measured memory_bytes: 9280
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
   string s, t;
   int n = 0;

   cin >> s >> t;

   for(int i = 0; i < 3; i++){
      if(s[i] == t[i]){
         n++;
      }
   }

   cout << n;

   return 0;
}


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

typedef long long lint;
typedef pair<int, int> pii;

const int INF = 2e9;
const int MOD = 1e9+7;
const int MAX = 1e5+10;
const lint LNF = 2e18;

lint x, n=100;

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

	cin>>x;
	int ans = 0;
	while(n<x){
		n *= 1.01;
		ans ++;
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
struct edge{int to,cost;};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=MOD;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%MOD;
    int memo=modpow(a,b/2);
    return memo*memo%MOD;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
    x=modpow(x,MOD-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
    return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,a[100010];
signed main(){
    cin>>n;
    int ans=0;
    rep(i,n){
        cin>>a[i];
        if(i){
            if(a[i]>a[i-1])ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3880
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class E
{
	public static void Main() => (new Solver()).Solve();
}


public class Solver
{
	public static readonly int INF = int.MaxValue / 2;

	private int N;
	private int M;
	private int L;
	private int[] A;
	private int[] B;
	private int[] C;
	private int Q;
	private int[] s;
	private int[] t;

	public void Solve()
	{
		N = GetInt();
		M = GetInt();
		L = GetInt();
		A = new int[M];
		B = new int[M];
		C = new int[M];
		for(int i = 0; i < M; i++)
		{
			A[i] = GetInt() - 1;
			B[i] = GetInt() - 1;
			C[i] = GetInt();
		}
		Q = GetInt();
		s = new int[Q];
		t = new int[Q];
		for(int i = 0; i < Q; i++)
		{
			s[i] = GetInt() - 1;
			t[i] = GetInt() - 1;
		}

		int[,] d = new int[N, N];
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				d[i, j] = (i == j) ? 0 : INF;

		for(int i = 0; i < M; i++)
		{
			d[A[i], B[i]] = C[i];
			d[B[i], A[i]] = C[i];
		}

		warshall_floyd(ref d);

		int[,] e = new int[N, N];
		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				e[i, j] = (i == j) ? 0 : INF;

		for(int i = 0; i < N; i++)
			for(int j = 0; j < N; j++)
				if(i != j && d[i, j] <= L)
					e[i, j] = 1;

		warshall_floyd(ref e);

		int[] ans = new int[Q];
		for(int i = 0; i < Q; i++)
			ans[i] = (e[s[i], t[i]] == INF) ? -1 : e[s[i], t[i]] - 1;

		Console.WriteLine(string.Join("\n", ans.Select(x => x.ToString()).ToArray()));
	}

	private static void warshall_floyd(ref int[,] d)
	{
		int V = d.GetLength(0);
		for(int k = 0; k < V; k++)
			for(int i = 0; i < V; i++)
				for(int j = 0; j < V; j++)
					d[i, j] = Math.Min(d[i, j], d[i, k] + d[k, j]);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(int N) => Enumerable.Range(0, N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(int N) => Enumerable.Range(0, N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(int N) => Enumerable.Range(0, N).Select(_ => GetDouble()).ToArray();
	public static string[] GetStrings(int N) => Enumerable.Range(0, N).Select(_ => GetString()).ToArray();
}


Measured memory_bytes: 27208
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define int long long
#define double long double
#define mod 1000000007
#define F first
#define S second
#define P pair<long long,long long>
#define all(a) a.begin(),a.end()
#define INF 1000000000000000000
using namespace std;

signed main(){
    int a,b,c; cin>>a>>b>>c;
    if(a==b and b==c){
        if(a%2==0)cout<<-1<<endl;
        else cout<<0<<endl;
        return 0;
    }
    int cnt=0;
    while(a%2==0 and b%2==0 and c%2==0){
        int d=a/2+b/2, e=a/2+c/2, f=b/2+c/2;
        a=d; b=e; c=f;
        cnt++;
    }
    cout<<cnt<<endl;
}

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9)+7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-9;

vector<string> m;
vector<vector<int> > g;
vector<bool> used;

void dfs(int now, int depth=0){
    used[now] = true;
    for(int i=0;i<depth;i++) cout << '.';
    cout << m[now] << endl;
    for(auto nxt:g[now]){
        dfs(nxt, depth+1);
    }
}

int main(){
    int n;
    cin >> n;
    m.resize(n);
    g.resize(n);
    used.resize(n);
    for(int i=0;i<n;i++){
        int k;
        cin >> k >> m[i];
        if(k>0) g[k-1].push_back(i);
    }
    for(int i=0;i<n;i++){
        if(!used[i]) dfs(i);
    }
    return 0;
}



Measured memory_bytes: 3420
#include <iostream>
#include <set>
#include <vector>

using namespace std;
typedef long long ll;

const int MAXN = 1e6+10;
bool isprime[MAXN];
vector<ll> prime;
ll a, b;

ll gcd(ll x, ll y) {
  if (y == 0) {
    return x;
  }
  return gcd(y, x % y);
}

void init() {
  for (int i=0;i<MAXN;i++) {
    isprime[i] = true;
  }
  isprime[0] = isprime[1] = false;
  for (int i=2;i<MAXN;i++) {
    if (isprime[i]) {
      prime.push_back(i);
      for (int j=i * 2;j<MAXN;j+=i) {
        isprime[j] = false;
      }
    }
  }
}

void solve() {
  init();
  if (a < b) {
    swap(a, b);
  }
  ll g = gcd(a, b);
  set<ll> s;
  int cur = 0;
  while (g > 1 && cur < prime.size()) {
    while (g % prime[cur] == 0) {
      g /= prime[cur];
      s.insert(prime[cur]);
    }
    cur++;
  }
  if (cur == prime.size()) {
    s.insert(g);
  }
  cout << s.size() + 1 << endl;
}

int main() {
  cin >> a >> b;
  solve();
}


Measured memory_bytes: 2424
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void){
    int n, x, cnt1 = 0, cnt2 = 0, cnt3 = 0;
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &x);
        if(x % 4 == 0) cnt1++;
        else if(x % 2 == 0) cnt2++;
        else cnt3++;
    }
    if(cnt2){
        if(cnt1 >= cnt3) puts("Yes");
        else puts("No");
    }else{
        if(cnt1 >= cnt3 - 1) puts("Yes");
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

vl factor(ll n) {
  vl res;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      res.push_back(i);
      if(n / i != i) res.push_back(n / i);
    }
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  vl f = factor(n);
  ll ans = factor(n - 1).size() - 1;
  for(auto v : f) {
    if(v == 1) continue;
    ll x = n;
    while(x % v == 0) x /= v;
    if(x % v == 1) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int fn(int a, int b, int c, int d)
{
    if(c-b<=0)
    {
        return(1);
    }
    else if(a-d<=0)
    {
        return(2);
    }
    else
        return fn(a-d,b,c-b,d);
}
int main()
{
    int a,b,c,d,z;
    cin>>a>>b>>c>>d;
    z=fn(a,b,c,d);
    if(z==1)
        cout<<"Yes"<<endl;
    else if(z==2)
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3612
#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)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int n, m;

struct edge {
    int from;
    int to;
    int cost;
};

vector<int> dist;
vector<edge> edges;

bool bellman_ford(int s = 0) {
    dist.resize(n, Inf);
    dist[s] = 0;
    rep (i, n) {
        bool update = false;
        rep (j, m) {
            edge e = edges[j];
            if (dist[e.from] != Inf && dist[e.to] > dist[e.from] + e.cost) {
                dist[e.to] = dist[e.from] + e.cost;
                if (i == n - 1) return false;
            }
        }
    }
    return true;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int r;
    cin >> n >> m >> r;
    edges = vector<edge>(m);
    rep (i, m) cin >> edges[i].from >> edges[i].to >> edges[i].cost;
    if (!bellman_ford(r)) {
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    rep (i, n) {
        if (dist[i] == Inf) {
            cout << "INF" << endl;
            continue;
        }
        cout << dist[i] << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3240
#include<cstdio>
#define maxn 200005
#define LL long long
int n,a[maxn],l[maxn],r[maxn],st[maxn],tp;
LL ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
	{
		while(tp&&a[st[tp]]>=a[i]) tp--;
		l[i]=st[tp]; st[++tp]=i;
	}
	tp=0; st[0]=n+1;
	for(int i=n;i;i--)
	{
		while(tp&&a[st[tp]]>=a[i]) tp--;
		r[i]=st[tp]; st[++tp]=i;
	}
	for(int i=1;i<=n;i++) ans+=1ll*a[i]*(i-l[i])*(r[i]-i);
	printf("%lld\n",ans);
}

Measured memory_bytes: 3328
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Array as A
import Data.Bits (shiftR)

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    as' = A.listArray (0, n) . scanl (+) 0 $ as :: A.Array Int Int
    l = as' A.! n
    i = binarySearch l n as' :: Int
  print $ min (l - 2 * (as' A.! i)) (2 * (as' A.! succ i) - l)

binarySearch :: Int -> Int -> A.Array Int Int -> Int
binarySearch l n as = binarySearch' 0 n
  where
    h = halve l
    binarySearch' i j | j == succ i = i
                      | as A.! m <= h = binarySearch' m j
                      | otherwise = binarySearch' i m
      where
        m = halve (i + j)

halve :: Int -> Int
halve = flip shiftR 1

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 30332
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    //*
    int a;
    cin >> a ;
    //*/
    
    /*
    vector<int> a(3);
    cin >> a.at(0) >> a.at(1) >> a.at(2) ;
    
    sort(a.begin(), a.end());
    */
    
    //*
    if( a % 10 == 9 || a / 10 % 10 == 9 ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    //*/
    
    //cout << ( a - 1 ) * ( b - 1 ) << endl;

    return 0; 
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }
int main(){
  ll n;
  cin>>n;
  if(n % 11 == 0)cout << (n / 11) * 2 << endl;
  else if(n % 11 <= 6)cout << (n / 11) * 2 + 1 << endl;
  else cout << (n / 11) * 2 + 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define dbg(x) cout << #x << ": " << x << endl;
using namespace std;

map<int, bool> vis;
int a[10010];

int main()
{
    int x, n;
    cin >> x >> n;
    rep(i, 1, n) {
        cin >> a[i];
        vis[a[i]] = true;
    }
    int delta = 0;
    while (true) {
        if (!vis[x - delta]) {
            cout << x - delta << endl;
            return 0;
        }
        if (!vis[x + delta]) {
            cout << x + delta << endl;
            return 0;
        }
        delta++;
    }

}


Measured memory_bytes: 3640
<?php
$arguments = fopen("php://stdin", "r");
$arg1 = trim(fgets($arguments));
$arg2 = trim(fgets($arguments));
$arg1 = explode(" ", $arg1);
$arg2 = explode(" ", $arg2);
$duration = $arg1[0];
$homeworks = $arg1[1];
$total_work_days = 0;
for($i=$homeworks-1; $i>=0; $i--){
  $total_work_days += $arg2[$i];
}
$free_days = $duration - $total_work_days;
if($free_days < 0){
  fputs(STDOUT, -1);
}else{
  fputs(STDOUT, $free_days);
}
?>

Measured memory_bytes: 16760
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = sorted(LI())[::-1]
    c = [A[0]]
    for x in A[1:]:
        c.append(x)
        c.append(x)
    ans= 0
    for i in range(len(c)):
        ans += c[i]
        if i == N - 2:
            break
    print(ans)

main()



Measured memory_bytes: 135044
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");

	int A, B;
	scanf("%d %d", &A, &B);
	if (A >= 13) printf("%d\n", B);
	else if (A >= 6) printf("%d\n", B >> 1);
	else printf("0\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final char[] s = scanner.next().toCharArray();
        for (int i = 0; i < s.length; i++) {
            final char c = s[i];
            char tmp = (char) ((c + n) % 'A' + 'A');
            s[i] = tmp > 'Z' ? (char) (tmp - 26) : tmp;
        }

        System.out.println(new String(s));
    }
}


Measured memory_bytes: 24404
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long int n, m;
    cin >> n >> m;
    long long int a[n];
    for(int i = 0;i < n;i++) {
        a[i] = 0;
    }
    for(int i = 0;i < m;i++) {
        int x;
        cin >> x;
        a[x-1] = 1;
    }

    long long int dp[n+1];
    dp[0] = 1;
    if(a[0]!=1) {
        dp[1] = 1;
    } else {
        dp[1] = 0;
    }

    for(int i = 2;i <= n;i++) {
        if(a[i-1]==0) { 
            dp[i] = dp[i-1] + dp[i-2];
            dp[i]%=1000000007;
        } else {
            dp[i] = 0;
        }
    }
    cout << dp[n]%1000000007 << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 1000

int n, i, j, sum, minj, count;
int A[MAX], B[MAX], C[MAX];

int min(int x, int y)
{
  if(x < y) return x;
  else return y;
}

int solve(int x)
{
  for(i = 0; i < n; i++){
    if(A[i] == x) return i;
  }
}

int main()
{
  int ans = 0, x, tmp;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
    B[i] = A[i];
  }

  for(i = n - 1; i > 0; i--){
    for(j = 0; j < i; j++){
      if(B[j + 1] < B[j]){
        tmp = B[j];
        B[j] = B[j + 1];
        B[j + 1] = tmp;
      }
    }
  }

  for(i = 0; i < n; i++){
    C[i] = 0;
  }

  for(i = 0; i < n; i++){
    x = i;
    count = 0;
    sum = 0;
    minj = (1 << 24);
    while(C[x] == 0){
      C[x] = 1;
      count++;
      sum += A[x];
      minj = min(minj, A[x]);
      x = solve(B[x]);
    }
    if(count < 2) continue;
    ans += min(sum + B[0] * (count + 1) + minj, sum + minj * (count - 2));

  }

  printf("%d\n", ans);

  return 0;
}



Measured memory_bytes: 2140
use proconio::input;

fn main() {
    input!(n: usize, s: [String; n]);
    let mut ans = vec![0; 4];
    for t in s.iter() {
        ans[match t.as_str() {
            "AC" => 0,
            "WA" => 1,
            "TLE" => 2,
            "RE" => 3,
            _ => panic!(),
        }] += 1;
    }
    println!("AC x {}", ans[0]);
    println!("WA x {}", ans[1]);
    println!("TLE x {}", ans[2]);
    println!("RE x {}", ans[3]);
}


Measured memory_bytes: 7808
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int main() {
    int n,a;cin >> n;deque<int> d;
    rep(i, n) {
        cin >> a;
        if (i % 2 == 1)d.push_front(a);
        else d.push_back(a);
    }
    if (n % 2 == 1) reverse(d.begin(), d.end());
    rep(i, n) cout << d[i] << " ";
    cout << endl;
}

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

int main()
{
  int arr[3][3], arr2[3][3] = {0,0}, q, t, k, count0 = 0,count= 0,count1 = 0,count2 = 0 ,count3 = 0 , count11 = 0, count22 = 0, count33 = 0;
  for(int i = 0; i < 3; i++)
  {
    for(int j = 0; j < 3; j++)
    {
      cin>>arr[i][j];
    }
  }
  cin>>q;
  while(q > 0)
  {
    cin>>t;
    k = 0;
    for(int i = 0; i < 3; i++)
    {
      for(int j = 0; j < 3; j++)
      {
        if(arr[i][j] == t)
        {
          arr2[i][j] = t;
          k++;
          break;
        }
      }
      if(k != 0)
      {
        break;
      }
    }
    q--;
  }
  for(int i = 0; i < 3; i++)
  {
    for(int j = 0; j < 3; j++)
    {
      if(i == j)
      {
        if(arr2[i][j] != 0)
          count++;
      }
      if(i+j == 2)
      {
        if(arr2[i][j] != 0)
          count0++;
      }
    }
  }
  for(int i = 0; i < 3; i++)
  {
    int j = 0;
    if(arr2[i][j]!=0)
    {
      count1++;
    }
    j = 1;
    if(arr2[i][j]!=0)
    {
      count2++;
    }
    j = 2;
    if(arr2[i][j]!=0)
    {
      count3++;
    }
  }
   for(int j = 0; j < 3; j++)
  {
    int i = 0;
    if(arr2[i][j]!=0)
    {
      count11++;
    }
    i = 1;
    if(arr2[i][j]!=0)
    {
      count22++;
    }
    i = 2;
    if(arr2[i][j]!=0)
    {
      count33++;
    }
  }
  if(count0 ==3 || count1 == 3 || count2 == 3 || count3 == 3 || count11 == 3 || count22 == 3 || count33 == 3 || count ==3)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		int a = saori.saori_hayami();
		int b = saori.saori_hayami();
		int ans = x-a;
		boolean flg = true;
		while(flg){
			if(ans - b >= 0){
				ans -= b;
			} else {
				flg = false;
				break;
			}
		}
		System.out.println(ans);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 20948
/**
  @date Time-stamp: <2019-04-13 21:18:53 tagashira>
  @file a.cpp
  @brief https://atcoder.jp/contests/abc123/tasks/abc123_a
**/

#include <cmath>
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  int A, B;
  cin >> A >> B;

  if (abs(A - B) <= 1) {
    cout << A + B << endl;
  } else {
    cout << max(A, B) * 2 - 1 << "\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstdio>
#include<list>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;

int g[40][40];
int og[40][40];
const int MAX = 10000000;
char name[1000][52];
int dist[1000];

enum{
  RetPeo = 0,
  SetLet = 1
};

struct event{
  int time;
  int type;
  int pos;
  int id;

  event(int ti, int ty, int po, int i = 0) :
    time(ti), type(ty), pos(po), id(i){}
};

bool operator < (const event &lhs, const event &rhs){
  if(lhs.time != rhs.time) return lhs.time > rhs.time;
  return lhs.type < rhs.type;
}

int n, m;

int nextof(int s, int d){
  if(s == d) return d;
  REP(i, n) if(i != s && og[s][i] + g[i][d] == g[s][d]) return i;
  return 0;
}

int main(){
  bool fst = true;
  while(scanf("%d%d", &n, &m), n + m){
    if(!fst) puts("");
    else fst =false;


    REP(i,n) REP(j,n) g[i][j] = MAX;
    REP(i,n) g[i][i] = 0;

    REP(i,m){
      int a, b, c;
      scanf("%d%d%d", &a, &b, &c);
      g[a - 1][b - 1] = g[b - 1][a - 1] = c;
    }
    REP(i,n) REP(j,n) og[i][j] = g[i][j];

    REP(k,n) REP(i,n) REP(j,n)
      g[i][j] = min(g[i][j], g[i][k] + g[k][j]);

    int l; scanf("%d", &l);
    priority_queue<event> pq;

    REP(ll, l){
      int s, d, t;
      scanf("%d%d%d %s", &s, &d, &t, name[ll]);
      dist[ll] = d - 1;
      pq.push(event(t, SetLet, s - 1, ll));
    }

    vector<int> last(n, 0);
    vector<bool> people(n, true);
    typedef pair<int, pair<int, int> > letter;
    vector<list<letter> > q(n);

    while(pq.size()){
      int etime = pq.top().time;

      //printf("time: %d\n", time);
      //printf("type=%d pos=%d id=%d\n", type, pos, id);

      vector<string> ans;

      while(pq.size() && pq.top().time == etime){
        event e = pq.top(); pq.pop();
        int time = e.time;
        int type = e.type;
        int pos  = e.pos;
        int id   = e.id;
        if(type == RetPeo){
          people[pos] = true;
        }else if(type == SetLet){
          if(dist[id] == pos){
            ans.push_back(name[id]);
          }else{
            //printf("%d => %d\n", pos, nextof(pos, dist[id]));
            q[pos].push_back(letter(time, make_pair(nextof(pos, dist[id]), id)));
          }
        }
      }

      if(ans.size() > 1) sort(ans.begin(), ans.end());
      REP(i, ans.size()){
        printf("%s %d\n", ans[i].c_str(), etime);
      }

      REP(pos, n) if(people[pos]){
        if(q[pos].size()){
          if(q[pos].size() > 1) q[pos].sort();

          // int nexttime = q[pos].front().first;
          int nextpos  = q[pos].front().second.first;

          for(list<letter>::iterator it = q[pos].begin(); it != q[pos].end();){
            int np = (*it).second.first;
            int le = (*it).second.second;

            if(np == nextpos){
              pq.push(event(etime + og[pos][np], SetLet, np, le));
              it = q[pos].erase(it);
            }else{
              ++it;
            }
          }

          people[pos] = false;
          last[pos]   = etime;
          pq.push(event(etime + 2 * og[pos][nextpos], RetPeo, pos));
        }
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
 
using namespace std;
 
const long long MOD=1e9+7;
const double PI=3.14159265359;
 
 
 
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    vector<int> vi(n);
    for(int i=0; i<n; i++){
        cin>>vi[i];
    }
    
    
    int a=*min_element(vi.begin(),vi.end());
    int b=*max_element(vi.begin(),vi.end());
    
    if(b>a+1){
        cout<<"No";
        return 0;
    }
    
    if(b==a && b!=n-1){
        if(a<=n/2 ){
            cout<<"Yes";
        }
        else{
            cout<<"No";
        }
        return 0;
    }
    
    
    int cta=count(vi.begin(),vi.end(),a);
    int ctb=count(vi.begin(),vi.end(),b);
    //cout<<a<<" "<<b;
    //cout<<cta<<" "<<ctb<<endl;
    
    if(b==n-1){
        if(ctb==n || ctb==2) cout<<"Yes";
        else cout<<"No";
        return 0;
    }
    if(cta<b && 2*(b-cta)<=ctb){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
long long Mod, F[1010], InvF[1010];
long long Pow(long long a, long long b){
    long long r=1;
    while(b){
        if(b&1)r=r*a%Mod;
        a=a*a%Mod;b>>=1;
    }
    return r;
}
long long Comb(int a, int b){
    if(a<b||b<0)return 0ll;
    return F[a]*InvF[b]%Mod*InvF[a-b]%Mod;
}
int D[210][210][410], S[210][210][410];
int DD[210][210][410];
long long CC[210];
void Do(int d){
    int i, j, k;
    for(i=0;i<=101;i++){
        for(k=0;k<=i+i;k++){
            for(j=i;j<=i+d&&k<=200;j++){
                D[i][k][j]=S[i][j][k]=0;
            }
        }
    }
    D[0][0][0]=1;
    for(i=0;i<=100;i++){
        for(j=0;j<=i+i;j++){
            for(k=i;k<=i+d&&k<=200;k++){
                S[i][j][k]=D[i][j][k];
                if(k){
                    S[i][j][k]+=S[i][j][k-1];
                    if(S[i][j][k]>=Mod)S[i][j][k]-=Mod;
                }
            }
            for(k=i+1;k<=i+d&&k<=200;k++){
                int tj=j;
                if(k==i+1)tj++;
                if(k==i+d)tj++;
                D[i+1][tj][k]=(D[i+1][tj][k]+S[i][j][k])%Mod;
            }
        }
    }
    for(i=0;i<=101;i++){
        for(j=0;j<=i+i;j++){
            long long s=0;
            for(k=i;k<i+d;k++){
                s+=D[i][j][k];
            }
            DD[d][i][j]=s%Mod;
        }
    }
    
}
long long Calc(int n, int K){
    if(K*2<n-1)return 0ll;
    int d = 2*K-n+2, i, j, k;
    for(i=0;i<=n;i++)CC[i]=0;
    for(j=0;j<=n;j++){
        CC[j+1]=(CC[j+1] + DD[d][n-K-1][j])%Mod;
    }
    long long s=0;
    for(i=1;i<=n;i++){
        s=(s+CC[i]*Pow(i,Mod-2))%Mod;
    }
    s=s*F[n]%Mod;
    return s;
}
long long Get(int n, int K){
    if(K==n-1)return F[n];
    long long res=0;
    int i;
    for(i=0;i<=K;i++){
        res=(res+Calc(n-i,K-i)*Comb(n,i)%Mod*F[i])%Mod;
    }
    return res;
}
int main(){
    int i;
    int n, K;
    scanf("%d%d%lld",&n,&K,&Mod);
    F[0]=InvF[0]=1;
    for(i=1;i<=n;i++){
        F[i]=F[i-1]*i%Mod;
        InvF[i]=Pow(F[i],Mod-2);
    }
    long long res=0;
/*    for(i=K;i>=1;i--){
        res=(res+Get(n,i))%Mod;
    }*/
    for(i=1;i<=2*K-n+2;i++)Do(i);
    for(i=K;i>=1;i--){
        res=(res+Get(n,i))%Mod;
    }
    printf("%lld\n",res);
}


Measured memory_bytes: 86420
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

char a;

int main(){
    cin>>a;
    if(a=='A')out('T');
    if(a=='T')out('A');
    if(a=='C')out('G');
    if(a=='G')out('C');

}


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

using namespace std;

using ll = long long int;
using vi = vector<int>;
#define f(n) for(int i = 0; i < n; i++)
#define fj(n) for(int j = 0; j < n; j++)
#define fk(n) for(int k = 0; k < n; k++)
#define ci(n) cin >> n;
#define ic(n) int n; cin >> n;
#define lc(n) int n; cin >> n;
#define all(a) a.begin(), a.end()
#define pri(a, n) for(int i = 0; i < n; i++) cout << a[i] << " "; cout << "\n";
#define sc(a, n) int a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define scl(a, n) ll a[n] = {0}; for(int i = 0; i < n; i++) cin >> a[i];
#define pb push_back
#define eb emplace_back
#define int long long
const int inf = 1e9, maxn = 2e5, mod = 998244353;

struct Vector
{
    int x, y;
    Vector(int _x = 0, int _y = 0) : x(_x), y(_y) {}
};
int operator * (Vector a, Vector b)
{
    return a.x * b.x + a.y * b.y;
}
int operator % (Vector a, Vector b)
{
    return a.x * b.y - a.y * b.x;
}
Vector operator - (Vector a)
{
    return Vector(-a.x, -a.y);
}
bool operator == (Vector a, Vector b)
{
    return ((a * b) > 0) && ((a % b) == 0);
}
void solve(int ci)
{
   ic(x)
   ic(n)
   int p[max(n, 1ll)];
   f(n) cin >> p[i];
   int am[102] = {0};
   f(n) am[p[i]]++;
   int ans = 0;
   for(int i = 0; i <= 101; i++) if(am[i] == 0 && abs(x - ans) > abs(x - i)) ans = i;
   cout << ans;
}
main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    //cin >> t;
    f(t) solve(i + 1);
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){

	int n,start,goal;

	scanf("%d",&n);

	for(int i=0; i < n; i++){
		scanf("%d %d",&start,&goal);

		if(start <= 5){
			if(start < goal){
				printf("%d",start);
				for(int k = start+1; k <= goal; k++){
					printf(" %d",k);
				}
				printf("\n");
			}else{
				printf("%d",start);
				for(int k = start-1; k >= goal; k--){
					printf(" %d",k);
				}
				printf("\n");
			}
		}else{ //start > 6
			if(goal >= 5){  //??´??????????????????
				if(start < goal){
					printf("%d",start);
					for(int k= start+1; k <= goal; k++)printf(" %d",k);

					printf("\n");

				}else{ //start > goal
					printf("%d",start);
					for(int k= start+1; k <= 9; k++)printf(" %d",k);
					if(goal != 5){
						printf(" 5 4 3 2 1 0 1 2 3 4");
					}
					for(int k=5; k <= goal; k++)printf(" %d",k);
					printf("\n");
				}

			}else{ //goal <= 4
				printf("%d",start);
				for(int k=start+1; k <= 9; k++)printf(" %d",k);
				for(int k=5; k >= goal; k--)printf(" %d",k);
				printf("\n");
			}

		}

	}

    return 0;
}



Measured memory_bytes: 2548
using System;
using System.IO;
using System.Text;

namespace Contest
{
    class Program
    {
        public void Solve()
        {
            var sc = new Scanner();

            string b = sc.Next();
            if (b == "A") Console.WriteLine("T");
            if (b == "T") Console.WriteLine("A");
            if (b == "C") Console.WriteLine("G");
            if (b == "G") Console.WriteLine("C");
        }

        static void Main(string[] args) => new Program().Solve();
    }

    class Scanner
    {
        private char _separator = ' ';
        private StreamReader _stream = new StreamReader(Console.OpenStandardInput());
        private int _pos = 0;
        private string[] _line = new string[0];
        public string Next()
        {
            if (_pos >= _line.Length)
            {
                _line = _stream.ReadLine().Split(_separator);
                _pos = 0;
            }
            return _line[_pos++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public string[] Array()
        {
            if (_pos >= _line.Length)
                _line = _stream.ReadLine().Split(_separator);
            _pos = _line.Length;
            return _line;
        }
        public int[] IntArray()
        {
            var arr = Array();
            var res = new int[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = int.Parse(arr[i]);
            }
            return res;
        }
        public long[] LongArray()
        {
            var arr = Array();
            var res = new long[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = long.Parse(arr[i]);
            }
            return res;
        }
        public double[] DoubleArray()
        {
            var arr = Array();
            var res = new double[arr.Length];
            for (int i = 0; i < arr.Length; i++)
            {
                res[i] = double.Parse(arr[i]);
            }
            return res;
        }
    }
}


Measured memory_bytes: 13140
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
using namespace std;
#define MAX_N 100001
#define INF 2147483647
#define REP(i,COUNT) for(int i=0;i<(int)(COUNT);i++)
struct edge{
  int to, cost;
};
typedef vector<vector<edge> > AdjList;
AdjList graph;
typedef pair<int, int> P;
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
vector<int> dist;
vector<int> dist2;
vector<int> prever;
void dijkstra(int n,int s){
  dist = vector<int>(n,INF);
  dist2 = vector<int>(n,INF);
  prever = vector<int>(n,-1);
  dist[s] = 0;

  priority_queue<P, vector<P> , greater<P> > que;
  que.push(P(0,s));
  
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    int d = p.first;
    //if(dist[v] < d){
    //  cout << dist[v] << " " << d << endl;
    //  continue;
    //}
    REP(i,graph[v].size()){
      edge e = graph[v][i];
      if(dist[e.to] > dist[v] + e.cost){
        dist[e.to] = dist[v] + e.cost;
        prever[e.to] = v;
        que.push(P(dist[e.to],e.to));
      }

    }

  }
}

int main()
{
  int N,M,a,b,cost=0,t;
  P p;
  cin >> N >> M;
  graph = vector<vector<edge> >(N,vector<edge>(0));
  REP(i,M){
    cin >> a >> b;a--;b--;
    graph[a].push_back((edge){b,cost});
    graph[b].push_back((edge){a,cost});
  }
  queue<P> que;
  que.push(P(0,2));
  while(!que.empty()){
    p = que.front();que.pop();
    t = p.first;
    if(t == N-1){
      cout << "POSSIBLE" << endl;
      return 0;
    }
    if(p.second == 0)
      continue;
    for(int i=0;i<graph[t].size();i++){
      que.push(P(graph[t][i].to,p.second-1));
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 13672