akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-13;
const double PI  = acos(-1.0);


int p[1<<15]={1,1};
set<int> primes;
int main(){
	FOR(i,2,1<<15){
		if(!p[i]){
			primes.insert(i);
			for(int j=i;j<(1<<15);j+=i){
				p[j]=1;
			}
		}
	}

	int n;
	while(cin>>n,n){
		int ans=0;
		FOR(i,2,n/2+1){
			if(EXIST(primes,i)&&EXIST(primes,n-i)){
				ans++;
			}
		}
		cout<<ans<<endl;
	}

}

Measured memory_bytes: 1484
#include<stdio.h>
#include<stdlib.h>

#define N 100

int pr,stack[1000];

void push(int a){
  stack[++pr]=a;
}

int pop(){
  pr--;
  return stack[pr+1];
}

int main(){
  int x,y;
  char ary[N];
  pr=0;
  while(scanf("%s",ary)!=EOF){
    if(ary[0]=='+'){
      x=pop();
      y=pop();
      push(x+y);
    }
    else if(ary[0]=='-'){
      y=pop();
      x=pop();
      push(x-y);
    }
    else if(ary[0]=='*'){
      x=pop();
      y=pop();
      push(x*y);
    }
    else{
      push(atoi(ary));
    }
  }
  printf("%d\n",pop());
  return 0;
}
  



Measured memory_bytes: 2124
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    ll m;
    cin >> m;
    
    ll totald = 0;
    ll sum = 0;
    rep(i, m){
        ll d, c;
        cin >> d >> c;
        sum += d * c;
        totald += c;
    }

    //cout << sum << " " << totald << endl;

    cout << (sum - 1) / 9 + totald - 1 << endl;
}

Measured memory_bytes: 256
s = input()
t = input()
ans = len(t)

for i in range(len(s)-len(t)+1):
    count = 0
    for j in range(len(t)):
        if s[i+j]!=t[j]:
            count += 1
    # print(count)
    ans = min(ans, count)

print(ans)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    int n,a=0,b=0;
    cin >> n;
    a = n / 10;
    b = a / 10;
    if (n%10==7) {
        cout << "Yes" << endl;
    }
    else if(a%10==7){
        cout << "Yes" << endl;
    }
    else if(b%10==7){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3612
#include<stdio.h>
int main()
{
  char s[4];
  
  scanf("%s",s);
  
  if(s[0]==s[1]||s[1]==s[2]){
    printf("Bad");
  }
  else if(s[2]==s[3]){
    printf("Bad");
  }
  else{
    printf("Good");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }


constexpr int b = 80 * 80 + 3;
constexpr int M = b * 2 + 3;
int main()
{
    int H, W;
    cin >> H >> W;
    vector<vector<int>> A(H, vector<int>(W));
    vector<vector<int>> B(H, vector<int>(W));
    cin >> A >> B;

    vector<vector<bitset<M>>> dp(H, vector<bitset<M>>(W));
    dp[0][0][b + A[0][0] - B[0][0]] = 1;
    REP(i, H) REP(j, W) {
        bitset<M> bs;
        if (i) bs |= dp[i - 1][j];
        if (j) bs |= dp[i][j - 1];
        int d = abs(A[i][j] - B[i][j]);
        dp[i][j] |= (bs << d) | (bs >> d);
    }
    int ret = M;
    REP(i, M) if (dp.back().back()[i]) ret = min(ret, abs(i - b));
    cout << ret << endl;
}


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

#define MAX 100000

typedef struct List{
  int key;
  struct List *next;
  struct List *prev;
}LIST;

LIST *list;

LIST* search(int key){
  LIST *x = list->next;
  while(x!=list && x->key!=key) x = x->next;
  return x;
}

void init(){
  list = (LIST *)malloc(sizeof(LIST));
  list->next = list;
  list->prev = list;
}

void print(){
  LIST *x = list->next;
  int i = 0;
  while(1){
    if(x == list) break;
    if(i++ > 0) printf(" ");
    printf("%d", x->key);
    x = x->next;
  }
  printf("\n");
}

void insert(int key){
  LIST *x = (LIST *)malloc(sizeof(LIST));
  x->key = key;
  x->next = list->next;
  list->next->prev = x;
  list->next = x;
  x->prev = list;
}

void deletenode(LIST *x){
  if(x == list) return;
  x->prev->next = x->next;
  x->next->prev = x->prev;
  free(x);
}

void deletekey(int key){ deletenode(search(key)); }

void deleteFirst(){ deletenode(list->next); }

void deleteLast(){ deletenode(list->prev); }

int main(){

  int key, n, i, size = 0, np = 0, nd = 0;
  char com[20];

  scanf("%d", &n);

  init();

  for(i = 0; i < n; i++){
    scanf("%s %d", com, &key);
    if(com[0] == 'i'){
      insert(key);
      np++;
      size++;
    }
    else if(com[0] == 'd'){
      if(strlen(com) > 6){
        if(com[6] == 'F') deleteFirst();
        else if(com[6] == 'L') deleteLast();
      }else {
        deletekey(key);
        nd++;
      }
      size--;
    }
  }

  print();

  return 0;
}

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

void solve() {
    int N;
    cin >> N;
    vector<int> bag;
    int destroy = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        int k = bag.size();
        if (a == k+1) {
            bag.push_back(a);
        } else {
            destroy++;
        }
    }
    if (destroy <= N - 1) cout << destroy << endl;
    else cout << -1 << endl;
}

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


Measured memory_bytes: 1400
a,b,c = map(int,raw_input().split())

if a>b:
	tmp = a
	a = b
	b = tmp

if b>c:
	tmp = b
	b = c
	c = tmp

if a>b:
	tmp = a
	a = b
	b = tmp

print "%d %d %d" %(a,b,c)	

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

int main(){
    ll k;
    cin >> k;
    vector<int> a(k+1);
    a[1] = 0;
    ll cnt = 0;
    for(int i=1; i<=k; i++){
        a[i]=(a[i-1]*10+7)%k;
        if(a[i] == 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}

Measured memory_bytes: 7168
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
set<int> nums;
int main(){
	int n;
	cin>>n;
	int x;
	int p[214514];
	rep(i,n){
				cin>>x;
		p[x]=i;
		//p[i]--;
	}
	int a[214514];
	int b[214514];
	
	for(int i=1;i<=n;i++){
		a[i]=i*20001;
		b[i]=(n+1-i)*20001;
	}
	for(int i=1;i<=n;i++){
		b[i]=b[i]+p[i];
	}
	for(int i=1;i<=n;i++){
		cout<<a[i];
		if(i!=n)cout<<" ";
		else cout<<endl;
	}
	for(int i=1;i<=n;i++){
		cout<<b[i];
		if(i!=n)cout<<" ";
		else cout<<endl;
	}
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
const int INF = 10000;

template<typename ISTREAM>
void readWeightedGraphMatrix(ISTREAM& cin, vector< vector<int> >& weightedGraphMatrix) {
	size_t n;
	cin >> n;
	int weight;
	weightedGraphMatrix = vector< vector<int> >(n, vector<int>(n));
	for (size_t i = 0; i != n; ++i) {
		for (size_t j = 0; j != n; ++j) {
			cin >> weight;
			weightedGraphMatrix.at(i).at(j) = weight != -1 ? weight : INF;
		}
	}
}

int MST(const vector< vector<int> >& weightedGraphMatrix) {
	enum Color {
		WHITE, GRAY, BLACK//白は未訪問でTと隣接していない、。グレーはTと隣接状態だが未訪問、黒は訪問済み。木は閉路を持たないグラフなので、全域木の計算では
		//各点は1度だけ訪問されるはず。
	};
	const size_t n = weightedGraphMatrix.size();
	vector<Color> color(n,Color::WHITE);
	vector<int> d(n, INF);
	vector<int> p(n, INF);
	color.front() = Color::GRAY;
	d.front() = 0;
	int currentNode = 0;
	while (true) {
		int min = INF;
		int u;
		//TからV-Tへ接続する辺の重みの中で最小のものを求める。
		//同時に、その辺に接続する辺のT内のノードを求める。
		for (size_t i = 0; i != n; ++i) {
			if (color.at(i) == Color::BLACK || color.at(i) == Color::WHITE) continue;//訪問済みはスキップ
			if (d.at(i) >= min)continue;
			min = d.at(i);//TからV-Tの中のノードiへ向かう辺の重みの最小値を更新
			u = i;
		}

		
		if (min == INF) {
			//ノード０からアクセス可能なすべての点を訪問済みになったらMST構築完了
			break;
		}

		color.at(u) = Color::BLACK;//訪問

		for (int v = 0; v != n; ++v) {
			if (color.at(v) == Color::BLACK) continue;//訪問済みはスキップ
			if (weightedGraphMatrix.at(u).at(v) == INF ) continue;
			if (weightedGraphMatrix.at(u).at(v) >= d.at(v)) continue;
			d.at(v) = weightedGraphMatrix.at(u).at(v);
			p.at(v) = u;
			color.at(v) = Color::GRAY;

		}
	
	}
	int sum = 0;
	for (int i = 0; i != n; ++i) {
		if (p.at(i) == INF)continue;
		sum += weightedGraphMatrix.at(i).at(p.at(i));
	}
	return sum;
}

template<typename T>
void execute(T& cin) {
	vector< vector<int> > graphList;
	readWeightedGraphMatrix(cin, graphList);
	cout << MST(graphList) << endl;
}


int main()
{


	execute(cin);



	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define LIMIT 32

struct Puzzle{
    char cont[9];
    int space;
    string path;
    bool operator < ( const Puzzle &p ) const{
        for ( int i = 0; i < 9; i++ ){
            if ( cont[i] == p.cont[i] ) continue;
            return cont[i] > p.cont[i];
        }
        return false;
    }
};

int limit;
static const int dx[4] = {-1, 0, 1, 0};
static const int dy[4] = {0, -1, 0, 1};
static const char direction[4] = {'d', 'r', 'u', 'l'};

bool isTarget(Puzzle puzzle){
    for ( int i = 0; i < 8; i++ ){
        if ( puzzle.cont[i] != '1' + i ) return false;
    }
    return true;
}

void bfs(Puzzle s){
    queue<Puzzle> Q;
    map<Puzzle, bool> V;
    Puzzle u, v;
    s.path = "";
    Q.push(s);
    V[s] = true;
    
    while( !Q.empty() ){
        u = Q.front(); Q.pop();
        if ( isTarget(u) ){
            cout << u.path.size() << endl;
            return;
        } else if ( u.path.size() > LIMIT ) break;
        
        int sx, sy, tx, ty;
        sx = u.space/3;
        sy = u.space%3;
        
        for ( int r = 0; r < 4; r++ ){
            tx = sx + dx[r];
            ty = sy + dy[r];
            if ( tx < 0 || ty < 0 || tx >= 3 || ty >= 3 ) continue;
            v = u;
            v.cont[u.space] = u.cont[tx*3+ty];
            v.cont[tx*3+ty] = '0';
            v.space = tx*3+ty;
            if ( !V[v] ){
                V[v] = true;
                v.path += direction[r];
                Q.push(v);
            }
        }
    }
    cout << "unsolvable" << endl;
}

int main(){
    Puzzle in;
    for ( int i = 0; i < 9; i++ ){
        cin >> in.cont[i];
        if ( in.cont[i] == '0' ) {
            in.space = i;
        }
    }
    
    bfs(in);
	return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL S;
  cin >> S;
  cout << "0 0 ";
  if (S == 1000000000LL * 1000000000LL)
  {
    cout << "1000000000 0 0 1000000000" << endl;
  }else{
    cout << "1000000000 ";
    cout << 1000000000 - S % 1000000000;
    cout << " ";
    cout << 1;
    cout << " ";
    cout << S / 1000000000 + 1;
    cout << endl;
  }
  // cout << S * S + (1000000000 - S) * (1000000000 - S)  << endl;
  // 1000000000*1000000000-1*1000000000
  // 1000000000*999999999-1*0
  // 1000000000*1 -1*1000000000
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
using namespace std;

int main()
{

	long long int n, x[210000], cent, a[210000];

    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> x[i];
        a[i] = x[i];
    }

    sort(x, x + n);
    cent = (x[n/2-1] + x[n/2])/2;
    for(int i = 0; i < n; i++){
        if(cent < a[i]) cout << x[n/2 - 1] << endl;
        else cout << x[n/2] << endl;
    }

	return 0;

}


Measured memory_bytes: 5376
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	ll h;
	cin >> h;
	ll count = 0;
	ll t = 1;

	while(h!=1) {
		h /= 2;
		count += t;
		t *= 2;
	}

	cout << count+t << endl;

	return 0;
}

Measured memory_bytes: 3644
use std::io::BufRead;
use std::str::FromStr;

fn main() {
    let stdin = std::io::stdin();
    let mut t = Tokenizer::new(stdin.lock().lines().map(|x| x.unwrap()));

    let a: i32 = t.take();
    let b: i32 = t.take();
    let ans = problem( a,b );
    println!("{}",ans);
}

fn problem( a: i32, b: i32 ) -> i32 {
    let len = b*2;
    if a > len {
        return a - len;
    }
    0
}


#[cfg(test)]
mod test {
    use super::*;
    #[test]
    fn test1() {
        let result = problem( 12, 4 );
        assert_eq!(result,4);
    }
    #[test]
    fn test2() {
        let result = problem( 20, 15 );
        assert_eq!(result,0);
    }
}


struct Tokenizer<S: Iterator<Item = String>> {
    input: S,
    items: Vec<String>,
}

impl<S: Iterator<Item = String>> Tokenizer<S> {
    pub fn new(input: S) -> Self {
        Tokenizer {
            input: input,
            items: Vec::new(),
        }
    }

    pub fn take<T: FromStr>(&mut self) -> T {
        loop {
            if let Some(r) = self.items.pop() {
                return r.parse().ok().expect("parse failed");
            }
            let mut items = self
                .input
                .next()
                .unwrap()
                .split_whitespace()
                .map(|x| x.to_string())
                .collect::<Vec<String>>();
            items.reverse();
            self.items = items;
        }
    }
}


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

int main() {
 int N;
 cin >> N;
 vector<int> S(N), T(N), U(N);
 for (int i = 0; i < N; i++) {
   cin >> S.at(i);
 }
  T = S;
  sort(T.begin(), T.end());
  if (T == S) {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      U = S;
      swap(U.at(i), U.at(j));
      if (U == T){
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void){
	int i,len;
	char input[101],word[101],tmp[201],text[201];
	char *re;
	
	scanf("%s",text);
	strcpy(tmp,text);
	strcat(text,tmp);
	
	scanf("%s",word);
	
	if((re=strstr(text,word))!=NULL){
		puts("Yes");
	}
	else puts("No");

return 0;
}

Measured memory_bytes: 540
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()


int main() {
  ll x;
  cin >> x;
  ll ans;
  ll cnt = 100;
  rep(i, 100000000) {
    cnt *= 1.01;
    if (cnt >= x) {
      ans = i+1;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0; i < N; i++) cin >> vec.at(i);
  int n=0;
  for(int i=0; i < N; i++){
    if(vec.at(i)>=K) n++;
  }
  cout << n << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pl;
#define all(a) (a).begin(),(a).end()
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,n) for(ll (i)=(n)-1;(i)>=0;i--)
#define SHOW(x) cout << #x << ": " << x << endl;
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

// a^n mod (繰り返し二乗法) 
ll modpow(ll a, ll n) {
    ll ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return ret % MOD;
}

//nが巨大なとき
ll big_nCr_mod(ll n,ll r){
    ll denominator = 1,numerator = 1;
    //nCr = nCn-r
    if(n <= r * 2) r = n - r;
    //分子計算
    for(ll i = 0;i < r;i++){
        numerator *= n - i;
        numerator %= MOD;
    }
    //分母計算
    //フェルマーの小定理より分母をYとすると、
    //Y ^ (MOD - 1) % MOD = 1 より、Yの逆元は Y^(-1) = Y ^ (MOD - 2) % MOD 
    //そのため、乗算(MODが使える)をするために Y ^ (MOD - 2) % MOD を計算
    for(ll i = 1;i < r + 1;i++){
        denominator *= i;
        denominator %= MOD;
    }
    denominator = modpow(denominator,MOD - 2);
    return (numerator * denominator) % MOD;
}

int main(){
    ll n,a,b,ans;
    cin>>n>>a>>b;
    ans = modpow(2,n);
    ans = (ans - 1 - big_nCr_mod(n,a) - big_nCr_mod(n,b) + MOD * 3) % MOD;
    cout<<ans<<endl;
}


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

int factorise(int n)
{
    int count=0;
    int i=1;
    for( i=1;i*i<n;i++)
    {
        if(n%i==0)
        count++;
    }
    
    if(i*i==n)
    return 2*count+1;
    else
    return 2*count;
    
}

int main() 
{
int n;
cin>>n;
int res=0;
for(int i=1;i<=n;i++)
{
    int no=n-i;
    res+=factorise(no);
}

   
   cout<<res<<"\n";
   return 0;
}

Measured memory_bytes: 3628
S = input()
K = int(input())



def func(S):
    inner = 0
    S = list(S)
    for i in range(len(S) - 1):
        if S[i] == S[i + 1]:
            S[i + 1] = '#'
            inner += 1
    return inner

if len(set(list(S))) == 1:
    print(len(S) * K // 2)
else:
    inner = func(S)
    inter = func(S * 2) - func(S) * 2
    print(inner * K + inter * (K - 1))

Measured memory_bytes: 38256
#include <stdio.h>


int main()
{
int a,b,c;
int i,j;

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

for (i=1;i<=a;i++){
if((b*i+c)%a==0) {
puts("YES");
return 0;
} 
}

puts("NO");
return 0;



}

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

int main() {
  int n; cin >> n;
  int F[50];
  F[0] = F[1] = 1;
  for (int i = 2; i <= n; i++) F[i] = F[i - 1] + F[i - 2];

  cout << F[n] << endl;

  return 0;
}


Measured memory_bytes: 3092
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define rep(I,N) up(I,0,N-1)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<"\n";}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<"\n";}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<"\n";}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<"\n";}
inline void                                              out(ld p){printf("%.12Lf\n",p);}
template<class T>inline void outml(T p){for_each(all(p),out<decltype(p[0])>);}//ml=multi line
template<class T>inline void outol(T V){auto n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}//ol=one line
int n,m,x,c[100],a[100][100],d[100];
long cost,ans=1L<<60;
inline void solve(void){
  in(n,m,x);
  rep(i,n){
    in(c[i]);
    rep(j,m){
      in(a[i][j]);
    }
  }
  for(int i=0;i<1<<n;i++){
    cost=0;
    rep(j,m)d[j]=0;
    for(int j=0;j<n;j++){
      if(i>>j&1){
        rep(k,m){
          d[k]+=a[j][k];
        }
        cost+=c[j];
      }
    }
    bool f=true;
    rep(j,m){
      if(d[j]<x){
        f=false;
        break;
      }
    }
    if(f){
      chmin(ans,cost);
    }
  }
  if(ans!=1L<<60)out(ans);
  else out(-1);
}
int main(void){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll INF=LLONG_MAX;
const ll r=1000000007;

int main(){
  int n,m;
  cin>>n>>m;
  vector<ll>a(m);
  rep(i,m)cin>>a[i];
  ll dp[n+1];
  rep(i,n+1)dp[i]=0;
  dp[0]=1;
  rep(i,m)dp[a[i]]=INF;
  rep(i,n){
    if(dp[i]<INF&&dp[i]>0){
      if(dp[i+1]<INF){
	dp[i+1]+=dp[i]%r;
      }
      if(dp[i+2]<INF&&i<n-1){
	dp[i+2]+=dp[i]%r;
      }
    }
    //rep(i,n+1)cout<<dp[i]<<" ";
    //cout<<"\n";
  }

  cout<<dp[n]%r<<endl;
}







Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int x[20000];
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=0;i<2*n;i++)
	cin>>x[i];
	sort(x,x+2*n);
	for(int i=0;i<2*n;i+=2)
	{
		ans+=min(x[i],x[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

class Data
{
public:
    double t;
    long long v;
    Data(){
        t = 0.0;
        v = 0;
    }
    Data(double t, long long v){
        this->t = t;
        this->v = v;
    }
    Data operator+(const Data& d){
        double t2 = (t * v + d.t * d.v) / (v + d.v);
        long long v2 = v + d.v;
        return Data(t2, v2);
    }
};

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    cout << setprecision(10);

    int n, l;
    cin >> n >> l;

    deque<Data> dq;
    double sum = 0.0;
    while(--n >= 0){
        Data in;
        cin >> in.t >> in.v;

        if(!dq.empty()){
            long long out = in.v;
            while(out > 0){
                auto& d = dq.front();
                if(out < d.v){
                    sum -= out * d.t;
                    d.v -= out;
                    out = 0;
                }
                else{
                    sum -= d.v * d.t;
                    out -= d.v;
                    dq.pop_front();
                }
            }
        }

        sum += in.v * in.t;
        while(!dq.empty() && in.t < dq.back().t){
            in = in + dq.back();
            dq.pop_back();
        }
        dq.push_back(in);

        double ans = sum / l;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 18704
class abc_156:
    
    def __init__(self):
        pass
    
    def A(self):
       pass
    def B(self):
        pass
        
    def C(self):
        N=int(input())
        X=list(map(int,input().split()))
        
        ans=[]
        sum_data=0
        
        X.sort()
        L=X[0]
        R=X[len(X)-1]
        
        for i in range(L,R+1):
            sum_data=0
            for j in range(len(X)):
                sum_data+=(X[j]-i)**2
            ans.append(sum_data)
        
        ans.sort()
        print(ans[0])
      
    def D(self):
        pass
        
    def E(self):
        pass
    
    def F(self):
        pass
    
    
if __name__=='__main__':
    obj=abc_156()
    obj.C()
    

Measured memory_bytes: 38640
using System;
using System.Linq;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(i => int.Parse(i)).ToArray();

            var maxV = int.MinValue;
            for(var i = 0; i < n - 1; i++){
                for(var j = i + 1; j < n; j++){
                    var x = Math.Abs(a[j] - a[i]);
                    maxV = Math.Max(maxV, x);
                }
            }

            Console.WriteLine(maxV);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,a,b)	for(int i=a;i<=b;i++)
#define rrep(i,a,b)	for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
const int N=1e5+5,inf=0x3f3f3f3f;
struct node{
	ll a,b;
}p[N];
ll n,m;
bool cmp(node a,node b)
{
	return a.b>b.b;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	rep(i,1,n)
		cin>>p[i].a>>p[i].b;
	sort(p+1,p+1+n,cmp);
	ll mx=0,res=0;
	rep(i,1,n)
		mx=max(mx,p[i].a);
	rep(i,1,n)
	{
		if(p[i].b<=mx)
			break;
		m-=p[i].b;
		res++;
		if(m<=0)
			break;
	}
	if(m>0)
		res=res+(m+mx-1)/mx;
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 1792
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.range;
import std.array;

void main(){
	auto a=readln.chomp;
	if(a=="oxx"||a=="xox"||a=="xxo")writeln(700+100);
	else if(a=="oox"||a=="oxo"||a=="xoo")writeln(700+200);
	else if(a=="ooo")writeln(700+300);
	else writeln(700);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){

	int res1, res2, res3;

	scanf("%d", &res1);

	scanf("%d", &res2);
	
	scanf("%d", &res3);

	if(res1 < res2 && res2 < res3){
		printf("Yes\n");
	}

	else{
		printf("No\n");
	}

return 0;
}

Measured memory_bytes: 580
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		long d=a%c;
		if(d!=0)a+=(c-d);
		d=b%c;
		b-=d;
		long ans=(b-a)/c+1;
		System.out.println((b-a)/c+1);
		
	
	}
	
}

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

typedef long long int64;
typedef unsigned long long uint64;

int n, k;
vector<int64> a;
vector<uint64> dp;

int main(){

	cin >> n >> k;
	a.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	dp.resize(n + 1);
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; ++i){
		dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
		for (int j = max(0, i - k); j < i; ++j){
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}
	}
	
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>


using ll = long long;
typedef std::pair<int, int>p;

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

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

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
int d[210];
bool flag = true;
bool fl = true;
struct edge { int to, cost; };
std::vector<edge>v[100];
bool used[210];

int main() {
	int n, a[210], ans = 0;
	std::cin >> n;
	for (int i = 0;i < n*2;i++) {
		std::cin >> a[i];
	}
	std::sort(a, a + n * 2);
	for (int i = 0;i < n*2;i += 2) {
		ans += min(a[i], a[i + 1]);
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main() {
    string a;
  	cin >> a;
  	int ans;
  	for(int i = 0; i < 3; i++){
      if(a[i] == '1') a[i] = '9';
      else if(a[i] == '9') a[i] = '1';
    }
  	ans = atoi(a.c_str());
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<unordered_map>
using namespace std;


int main()
{   
    string S, T;
   
    cin >> S >> T;
    
    if(S == T.substr(0, S.length())){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3628
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
void makegraph(int x,vector<vec> &v){rep(i,x-1){int a=in(),b=in();v[a].pb(b);v[b].pb(a);}}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=924844033;
#define N 355050

ll n,m,k;
ll a[N];
ll x[N];
main(){
    n=lin();
    k=lin();
    rep(i,n)a[i]=lin();
    ll ans=0;
    ll ttt=0;
    rep3(ii,40,0){
        if(!((1ll<<ii)&k)){
            ll mask=(1ll<<(ii));
            ll t=0;
            rep(j,n)if((a[j]&mask))t++;
            ttt+=mask*t;
        }
        else{
            ll temp=0;
            rep3(i,ii-1,0){
                ll mask=(1ll<<i);
                ll t=0;
                rep(j,n){
                    if(a[j]&mask)t++;
                }
                t=max(t,n-t);
                temp+=mask*t;
            }
            ll mask=(1ll<<(ii));
            ll t=0;
            rep(j,n)if((a[j]&mask))t++;
            temp+=mask*t;
            temp+=ttt;
            ttt+=mask*(n-t);
            ans=max(ans,temp);
        }
    }
    cout<<max(ans,ttt);
}

Measured memory_bytes: 2304
n = int(input());
told,xold,yold = 0,0,0; 
ans = 'Yes';
for i in range(n) :
    tnew,xnew,ynew = [int(x) for x in input().split()];
    dis = abs(xnew-xold) + abs(ynew-yold);
    diff = tnew - told;
    if (diff - dis)%2 == 1 or diff < dis :
        ans = 'No';
        break;
    else :
        told,xold,yold = tnew,xnew,ynew;

print(ans);

Measured memory_bytes: 9004
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int[]a=new int[3*N];
        for(int i=0;i<N;i++){
            a[i]=sc.nextInt();
            a[N+i]=a[i]+1;
            a[2*N+i]=a[i]-1;
        }
        int max=0;
        int aa=1;
        Arrays.sort(a);
        for(int i=0;i<3*N-1;i++){
            if(a[i]==a[i+1]){
                aa++;
            }else{
                if(aa>=max){
                    max=aa;
                    aa=1;
                }else{
                    aa=1;
                }
            }
        }
        System.out.println(max);
        

        
}
        
        
    }


Measured memory_bytes: 58628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int Min(int a, int b, int c) {
	if (a <= b) { return std::min(a, c); }
	else return std::min(b, c);
}
int Max(int a, int b, int c) {
	if (a >= b) { return std::max(a, c); }
	else return std::max(b, c);
}
int main(void) {
	int a, b, k; cin >> a >> b >> k;
	int t = 0;
	for (int i = min(a,b);; i--) {
		if (a % i == 0 && b % i == 0) {
			t++;
			if (t == k) {
				cout << i << endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ll long long
#define endl '\n'
using namespace std;
using namespace __gnu_pbds;
template<typename T>
using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
vector<pair<int,int>>vec;
int n,w;
ll memo[101][100100];
ll solve(int idx=0,int val=0){
    if(idx==n && val==0)
        return 0;
    if(val<0 || idx==n)
        return 2e18;
    if(val==0)
        return 0;
    ll &cur=memo[idx][val];
    if(cur!=-1)
        return cur;
    cur=2e18;
    cur=min(cur,vec[idx].first+solve(idx+1,val-vec[idx].second));
    cur=min(cur,solve(idx+1,val));
    return cur;
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    memset(memo,-1,sizeof(memo));
    cin>>n>>w;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        vec.push_back({a,b});
    }
    ll s=0;
    for(int i=100000;i>=0;i--){
        ll r=solve(0,i);
        if(r<=w){
            s=i;
            break;
        }
    }
    cout<<s;
}

Measured memory_bytes: 79232
#include <stdio.h>
#include <stdlib.h>

typedef struct task{
  long time;
  long dead;
}task;

int compare(const void *a,const void *b){
  long x = ((task *)a)->dead;
  long y = ((task *)b)->dead;
  if(x > y){
    return 1;
  }else if (x < y){
    return -1;
  }else{
    return 0;
  }
}

int main(){
  int n;
  task t[200000];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%ld %ld",&t[i].time,&t[i].dead);
  }
  qsort(t,n,sizeof(task),compare);
  long sum = 0;
  int out = 0;
  for(int j=0;j<n;j++){
    if(sum + t[j].time > t[j].dead){
      printf("No\n");
      out = 1;
      break;
    }
    sum += t[j].time;
  }
  if(out == 0) printf("Yes\n");
  return 0;
}

Measured memory_bytes: 6396
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

H,W=mint()
N=intput()
A=[0]+lint()
C=[[0]*W for _ in range(H)]
k=1
a=0
for i in range(H):
    tmp = range(W) if i%2==0 else range(W-1,-1,-1)
    for j in tmp:
        C[i][j]=k
        a+=1
        if a==A[k]:
            k+=1
            a=0
for c in C:
    lprint(c,' ')
    print('')

Measured memory_bytes: 75732
import java.io.PrintWriter

fun main(args: Array<String>) {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (n, a, b) = readLongList()
    if (Math.abs(a - b) % 2 == 0L) {
        println(Math.abs(a - b) / 2)
    } else {
        val tmp = Math.min(a - 1, n - b) + 1 + (b - a - 1) / 2
        println(tmp)
    }
}


fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 37996
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INF = 1<<29;
const int MOD = 1000000007;
 
void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};



int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    string s;
    cin >> s;
    string cur, prev;
    int ans = 0;
    rep(i,sz(s)){
        cur += s[i];
        if(cur != prev){
            ans++;
            prev = cur;
            cur = "";
        }
    }
    print(ans);
}

Measured memory_bytes: 720
#include <stdio.h>

int main(void) {
  int a, b, c, arr[101]={0}, i, cnt=0;
  scanf("%d %d %d", &a, &b, &c);

  arr[a]++;
  arr[b]++;
  arr[c]++;
  
  for (i=0; i<101; i++) {
    if (arr[i]>0) cnt++;
  }
  
  printf("%d\n", cnt);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

string a,b,c;

int main()
{
    cin >> a >> b >> c;
    if(a.back() == b.front() && b.back() == c.front())
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;

int main() {
    int A, B, C; cin >> A >> B >> C;
    if (A == B) {
        cout << C << endl;
    } else if (B == C) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
def GCD(a, b):
    if b == 0:
        return a
    else:
        return GCD(b, a % b)

def main():
    K = int(input())
    ans = 0
    for i in range(1, K+1):
        for j in range(1, K+1):
            for k in range(1, K+1):
                tmp = GCD(i, j)
                ans += GCD(tmp, k)
    print(ans)

    return 0


if __name__ == '__main__':
    main()

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define fbo find_by_order
#define ook order_of_key
#define mark(x) cout<<"Here -- "<<x<<endl;
#define pv(v)   {rep(i,v.size()) cout<<v[i]<<" "; cout<<endl;}


ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    double a,b; cin>>a>>b;
    int x, y ;
    
    int ans = -1;
    x = floor((a+1)/0.08);
    y = (b)*10;
    for(double i = y ; i<=x; i++){
        if(floor(i*0.08)==a&&floor(i*0.1)==b){
            ans = i;
            break;
        }
    }

    cout<<ans;

    return 0;
} 

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		sc.close();

		long t = N % K;
		System.out.println(Math.min(t, K - t));
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
vector<int> d;
bool dpx[8005][20005];
bool dpy[8005][20005];
string s;
int x,y,j=0;
int tmp=0;

int main(void)
{
  memset(dpx,false,sizeof(dpx));
  memset(dpy,false,sizeof(dpy));
  cin >> s;
  cin >> x >> y;
  int ssize=int(s.size());
  d.push_back(0);
  for (int i = 0; i < ssize; ++i)
    {
      if(s[i]=='F')
	{
	  d.back()++;
	}
      else if(s[i]=='T') {
	d.push_back(0);
      }
    }
  /*for (int i = 0; i < int(d.size()); ++i)
    {
    cout << d[i] << endl;
    }*/
  int dsize=int(d.size());
  if(d.size()==1)
    {
      if(x==d[0])
	{
	  cout << "Yes" << endl;
	  return 0;
	}
      else
	{
	  cout << "No" << endl;
	  return 0;
	}
    }
  x-=d[0];
  dpx[0][10000]=true;
  dpy[0][10000]=true;
  dpy[1][10000+d[1]]=true;
  dpy[1][10000-d[1]]=true;
  dpx[1][10000]=true;
  for(int j=2;j<dsize;j++)
    {
      for (int i = 0; i <= 20000; ++i)
	{
	  dpx[j][i]=false;
	  if(i+d[j] <= 20000 ) dpx[j][i]|=dpx[j-2][i+d[j]];
	  if(i-d[j] >= 0 ) dpx[j][i]|=dpx[j-2][i-d[j]];
	}
    }

  for(int j=2;j<dsize;j++)
    {
      for (int i = 0; i <= 20000; ++i)
	{
	  dpy[j][i]=false;
	  if(i+d[j] <= 20000 ) dpy[j][i]|=dpy[j-2][i+d[j]];
	  if(i-d[j] >= 0 ) dpy[j][i]|=dpy[j-2][i-d[j]];
	}
    }
  if(dsize&1)
    {
      if(dpx[dsize-1][10000+x] && dpy[dsize-2][10000+y])
	{
	  cout << "Yes" << endl;
	}
      else
	{
	  cout << "No" << endl;
	}
    }
  else
    {
      if(dpy[dsize-1][10000+y] && dpx[dsize-2][10000+x])
	{
	  cout << "Yes" << endl;
	}
      else
	{
	  cout << "No" << endl;
	}
    }
  return 0;
}


Measured memory_bytes: 313088