akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        k: i32,
        q: usize,
        a: [i32; q],
    }

    let mut p = vec![k - q as i32; n];

    for i in 0..q {
        p[(a[i] - 1) as usize] = p[(a[i] - 1) as usize] + 1;
    }

    for n in p.iter() {
        if n > &0 {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}

Measured memory_bytes: 6780
import java.util.*;

public class Main
{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    int w = sc.nextInt();
	    int n = sc.nextInt();

	    int[] lots = new int[w];
	    for(int i = 1; i <= w; ++i){
		lots[i-1] = i;
	    }

	    while(0 < n--){
		String[] horizontal_line = sc.next().split(",");
		swapVerticalLines(lots, Integer.parseInt(horizontal_line[0])-1, Integer.parseInt(horizontal_line[1])-1);
	    }

	    for(int i = 0; i < w; ++i){
		System.out.println(String.valueOf(lots[i]));
	    }
	}
    }

    private static void swapVerticalLines(int[] lots, int line1, int line2){
	int tmp = lots[line1];
	lots[line1] = lots[line2];
	lots[line2] = tmp;
    }
}

Measured memory_bytes: 17204
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);


    string s;
    cin >> s;
    int n = s.length();
    bool res = false;
    if (s[0] == 'A') {
        int cs = 0;
        int lowers = 0;
        for (int i = 2; i + 1 < n; ++i) {
            if (s[i] == 'C') {
                ++cs;
            }
        }
        for (int i = 0; i < n; ++i) {
            if (islower(s[i])) {
                ++lowers;
            }
        }
        if (cs == 1 && lowers + 2 == n) {
            res = true;
        }
    }

    if (res) {
        cout << "AC\n";
    } else {
        cout << "WA\n";
    }
    return 0;
}

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

using namespace std;

const double EPS = 1e-7;
const int N = 4e5+5, M = 1e5+5, OO = 0x3f3f3f3f;
typedef long long ll;

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


int n,d;
int main(){
    cin>>n>>d;
    int x=0,c=0;
    while(x<n){
        x+=(d*2)+1;
        c++;
    }
    cout<<c<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

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

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n,m;
	cin>>n>>m;
	vector<ll> a(m);
	set<ll> b;
	for(int i = 0; i < m; i++){
		cin>>a[i];
		b.insert(a[i]);
	}

	vector<ll> ans(n+1,0);
	ans[0] = 1;
	for(int i = 1; i <= n; i++){
		// ans[i] = !b.count(i-1)?ans[i-1]:0 + !b.count(i-2)?ans[i-2]:0;
		ans[i] = (i-1>=0?ans[i-1]:0) + (i-2>=0?ans[i-2]:0);
		if(b.count(i)){
			// cout<<"i = "<<i << endl;
			ans[i]=0;
		}
		ans[i] %= mod;
	}
	cout<<ans[n]<<endl;

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

	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
//#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch PickingGoods | diff PickingGoods.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address PickingGoods.cpp && ./a.out

/*

 8/15/2020

 6:17-6:45 AC

 */

const int MAX_N=3000+1;
LL V[MAX_N][MAX_N];
int N,M,K;

//const LL Inf=1e18;
LL dp[MAX_N][MAX_N][4];
void solve() {
  dp[0][0][0]=0;
  REP(i,N)REP(j,M)REPE(k,3) {
    if(dp[i][j][k]>0) dump(i,j,k,dp[i][j][k]);
    // right
    SMAX(dp[i][j+1][k],dp[i][j][k]);
    if(k<3) SMAX(dp[i][j+1][k+1],dp[i][j][k]+V[i][j]);

    // down
    SMAX(dp[i+1][j][0],dp[i][j][k]);
    if(k<3) SMAX(dp[i+1][j][0],dp[i][j][k]+V[i][j]);
  }
  LL res=0;
  REPE(k,3) {
    LL a=dp[N-1][M-1][k];
    dump(k,a);
    if(k<3) a+=V[N-1][M-1];
    SMAX(res,a);
  }
  cout<<res<<endl;
}

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

  cin>>N>>M>>K;
  REP(i,K) {
    int r,c; LL v; cin>>r>>c>>v;
    --r,--c;
    V[r][c]=v;
  }
  solve();

  return 0;
}


Measured memory_bytes: 355328
#include<bits/stdc++.h>
using namespace std;
typedef long long L;
map<L,L>mp;
L idx,loc=1,ii,jj,aa,a,d;
void encode(L a,L ar[]){
    idx=0;
    while(a){
        ar[idx++]=a%10;
        a/=10;
    }
    while(idx<d){
        ar[idx++]=0;
    }
}
L decode(L ar[]){
    L num=0;
    for(L i=0;i<idx;i++){
        num=(num*10)+(ar[i]);
    }
    return num;
}
void solve(L a,L d){
    loc=1;
    while(!mp[a]){//cout<<"no"<<endl;
        mp[a]=loc++;
        L ar1[10],ar2[10],a1,a2;
        encode(a,ar1);
        for(L i=0;i<idx;i++)ar2[i]=ar1[i];
        sort(ar1,ar1+idx);
        sort(ar2,ar2+idx,greater<L>());
        a1=decode(ar1);
        a2=decode(ar2);
        a=a2-a1;
    }//cout<<a<<" "<<mp[a]<<endl;
    ii=mp[a]-1;jj=loc-mp[a];aa=a;
}
int main()
{
    while(scanf("%lld%lld",&a,&d)&& a||d){
        solve(a,d);
        cout<<ii<<" "<<aa<<" "<<jj<<"\n";
        mp.clear();
    }



    return 0;
}



Measured memory_bytes: 3148
#include "bits/stdc++.h"
using namespace std;
//#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
//constexpr int INF = 1e18;
 
 
 
signed main(){
	int N;
	cin >> N;
	vector<string>v(N);
	REP(i, N) {
		cin >> v[i];
	}
	vector<vector<vector<int>>>vs;
	REP(i, N) {
		vector<vector<int>>tmp(v[i].size() + 1, vector<int>(26));
		REP(j, v[i].size()) {
			REP(k, 26) {
				tmp[j + 1][k] += tmp[j][k] + (v[i][j] - 'a' == k);
			}
		}
		vs.emplace_back(tmp);
	}
	vector<int>id(N);
	iota(ALL(id), 0);
	auto dfs = [&](auto&&f, vector<int>&a, int tail) -> long long {
		vector<int>cnt(26);
		REP(i, a.size()) {
			if(v[a[i]].size() - tail == 1) {
				++cnt[v[a[i]][0] - 'a'];
			}
		}
		long long ret = 0;
		REP(i, a.size()) {
			REP(j, 26) {
				int t = vs[a[i]][vs[a[i]].size() - tail - 1][j] - vs[a[i]][0][j];
				if(t) ret += cnt[j];
			}
		}
		ret -= accumulate(ALL(cnt), 0ll);
		vector<vector<int>>next(26);
		REP(i, a.size()) {
			if(v[a[i]].size() - tail == 1) continue;
			next[v[a[i]][v[a[i]].size() - tail - 1] - 'a'].emplace_back(a[i]);
		}
		vector<int>().swap(a);
		REP(i, 26) {
			if(next[i].size() == 0) continue;
			ret += f(f, next[i], tail + 1);
		}
		return ret;
	};
	out(dfs(dfs, id, 0));
}

Measured memory_bytes: 958664
#include<stdio.h>

int main(void){
    int x,y,res;
    scanf("%d",&x);
    scanf("%d",&y);
    if(y>=x){
        res=x;
        x=y;
        y=res;
    }
    res=x%y;
    while(res!=0){
        x=y;
        y=res;
        res=x%y;
    }
    printf("%d\n",y);
    return 0;
}


Measured memory_bytes: 2096
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
#define fst first
#define snd second
const ll mn=1e5+2;
ll a[mn];
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n; scanf("%lld",&n);
	ll odd=0,even=0;
	for (ll i=0;i<n;i++) {
		ll x; scanf("%lld",&x);
		if (x&1) odd++;
		else even++;
	}
	bool ans=true;
	if (odd&1) ans=false;
	if (ans) printf("YES\n");
	else printf("NO\n");
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int A = sc.nextInt();
   
   if(A<1200) System.out.println("ABC");
   else if (A>=2800)System.out.println("AGC");
   else System.out.println("ARC");
 }
}

Measured memory_bytes: 21716
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

pll p[100005];
set<int> st;
void solve(){  
	int n;
	cin>>n;
	rep(i,0,n){
		cin>>p[i].F;	
		p[i].S=i;
	}
	sort(p,p+n);
	st.insert(p[n-1].S);
	int ans=0;
	repd(i,n-2,0){
		int pos=p[i].S;
		int val = p[i].F;
		auto it = st.lower_bound(pos);
		int lo1,lo2,hi1,hi2;
		if(it==st.end()){
			hi1=n;
			hi2=n;
		}
		else{
			hi1=*it;
			++it;
			if(it==st.end()){
				hi2=n;
			}
			else hi2=*it;
		}
		it = st.lower_bound(pos);
		if(it==st.begin()){
			lo1=-1;
			lo2=-1;
		}
		else{
			--it;
			lo1=*it;
			if(it==st.begin()){
				lo2=-1;
			}
			else{
				--it;
				lo2=*it;
			}
		}
		ans+=val*((hi1-pos)*(lo1-lo2)+(pos-lo1)*(hi2-hi1));
		st.insert(pos);	
	}
	cout<<ans<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

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

using namespace std;

int main(void) {
    int N;
    string s;
    cin >> N >> s;
    s.push_back(s[0]);

    string ans;
    ans.clear();
    ans.push_back('S');
    ans.push_back('S');
    for(int i=1; i<=N; i++) {
        if(ans[i] == 'S' && s[i] == 'o' || ans[i] == 'W' && s[i] == 'x') {
            ans.push_back(ans[i-1]);
        } else if(ans[i-1] == 'S') {
            ans.push_back('W');
        } else {
            ans.push_back('S');
        }
    }
    if(ans[0] == ans[N] && ans[1] == ans[N+1]) {
        ans.pop_back();
        ans.pop_back();
        cout << ans << endl;
        return 0;
    }

    ans.clear();
    ans.push_back('S');
    ans.push_back('W');
    for(int i=1; i<=N; i++) {
        if(ans[i] == 'S' && s[i] == 'o' || ans[i] == 'W' && s[i] == 'x') {
            ans.push_back(ans[i-1]);
        } else if(ans[i-1] == 'S') {
            ans.push_back('W');
        } else {
            ans.push_back('S');
        }
    }
    if(ans[0] == ans[N] && ans[1] == ans[N+1]) {
        ans.pop_back();
        ans.pop_back();
        cout << ans << endl;
        return 0;
    }

    ans.clear();
    ans.push_back('W');
    ans.push_back('S');
    for(int i=1; i<=N; i++) {
        if(ans[i] == 'S' && s[i] == 'o' || ans[i] == 'W' && s[i] == 'x') {
            ans.push_back(ans[i-1]);
        } else if(ans[i-1] == 'S') {
            ans.push_back('W');
        } else {
            ans.push_back('S');
        }
    }
    if(ans[0] == ans[N] && ans[1] == ans[N+1]) {
        ans.pop_back();
        ans.pop_back();
        cout << ans << endl;
        return 0;
    }

    ans.clear();
    ans.push_back('W');
    ans.push_back('W');
    for(int i=1; i<=N; i++) {
        if(ans[i] == 'S' && s[i] == 'o' || ans[i] == 'W' && s[i] == 'x') {
            ans.push_back(ans[i-1]);
        } else if(ans[i-1] == 'S') {
            ans.push_back('W');
        } else {
            ans.push_back('S');
        }
    }
    if(ans[0] == ans[N] && ans[1] == ans[N+1]) {
        ans.pop_back();
        ans.pop_back();
        cout << ans << endl;
        return 0;
    }

    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r, g, b;
    cin >> r >> g >> b;
    if((r * 100 + g * 10 + b) % 4 == 0){
        cout << "YES" << "\n";
    }else{
        cout << "NO" << "\n";
    }


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int ans =0;
        for(int i =1; i<=9; i++) {
        	for(int j =1; j<=9; j++) {
        		if(i*j==N) {
        			ans+=1;
        		}else {
        			ans+=0;
        		}
        	}
        }
        if(ans>0) {
        System.out.println("Yes");
        }else {
        System.out.println("No");
        }
	}
}

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

int ans[200005];

int main() {
  int N;
  string X;
  cin>>N>>X;
  int num;
  for(int i=1;i<200005;++i) {
    num = 0;
    for(int j=0;j<20;++j) {
      if((i&(1<<j))!=0) num++;
    }
    ans[i] = 1 + ans[i%num];
  }
  num = 0;
  for(int i=0;i<N;++i) {
    if(X[i]=='1') num++; 
  }
  if(num==0) {
    for(int i=0;i<N;++i) cout<<1<<endl;
    return 0;
  }
  if(num==1) {
    for(int i=0;i<N;++i) {
      if(X[i]=='1') {
        cout<<0<<endl;
      }
      else {
        if(i==N-1) {
          cout<<2<<endl;
        }
        else {
          cout<<1<<endl;
        }
      }
    }
    return 0;
  }
  int amari1=0, amari2=0;
  int two1=1, two2=1;
  for(int i=N-1;i>=0;--i) {
    if(X[i]=='1') {
      amari1 += two1%(num+1);
      amari2 += two2%(num-1);
      amari1 %= num+1;
      amari2 %= num-1;
    }
    two1 *= 2;
    two1 %= num+1;
    two2 *= 2;
    two2 %= num-1;
  }
  int ans1[N];
  two1 = 1;
  two2 = 1;
  for(int i=N-1;i>=0;--i) {
    if(X[i]=='1') { // amari2
      ans1[i] = ans[(amari2-two2+(num-1))%(num-1)]+1;
    }
    else { // amari1
      ans1[i] = ans[(amari1+two1)%(num+1)]+1;
    }
    two1 *= 2;
    two2 *= 2;
    two1 %= num+1;
    two2 %= num-1;
  }
  for(int i=0;i<N;++i) cout<<ans1[i]<<endl;
}


Measured memory_bytes: 5288
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : x : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  ls <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    ds = scanl (+) 0 ls
  print . length . takeWhile (<= x) $ ds

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


Measured memory_bytes: 508
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a string
	fmt.Scan(&a)
	s1, _ := strconv.Atoi(a[0:1])
	s2, _ := strconv.Atoi(a[1:2])
	s3, _ := strconv.Atoi(a[2:3])
	sum := s1 + s2 + s3
	fmt.Println(sum)
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int N; cin >> N;
  FOR(l,1,10) {
    int r = N/l;
    if(l*r == N && 1 <= r && r <= 9) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector <int> Treeleft, Treeright;
vector <int> Treecnt;
void update1(int v, int l, int r, int al, int ar, int val)
{
	if(l >= al && r <= ar)
	{
		Treeright[v] = min(Treeright[v], val);
	}
	else if(l <= ar && r >= al)
	{
		update1(v * 2, l, (r + l) / 2, al, ar, val);
		update1(v * 2 + 1, (r + l) / 2 + 1, r, al, ar, val);
	}
}
void update2(int v, int l, int r, int al, int ar, int val)
{
	if(l >= al && r <= ar){
		Treeleft[v] = max(Treeleft[v], val);
	}
	else if(l <= ar && r >= al)
	{
		update2(v * 2, l, (r + l) / 2, al, ar, val);
		update2(v * 2 + 1, (r + l) / 2 + 1, r, al, ar, val);
	}
}
int ans1(int v, int l, int r, int ind)
{
	if(l == r)
	{
		return Treeleft[v];
	}
	else if(ind <= (r + l) / 2)
	{
		return max(Treeleft[v], ans1(v * 2, l, (r + l) / 2, ind)); 
	}
	else
	{
		return max(Treeleft[v], ans1(v * 2 + 1, (r + l) / 2 + 1, r, ind));
	}
}
int ans2(int v, int l, int r, int ind)
{
	if(l == r)
	{
		return Treeright[v];
	}
	else if(ind <= (r + l) / 2)
	{
		return min(Treeright[v], ans2(v * 2, l, (r + l) / 2, ind));
	}
	else
	{
		return min(Treeright[v], ans2(v * 2 + 1, (r + l) / 2 + 1, r, ind));
	}
}
void update3(int v, int l, int r, int ind)
{
	if(l == r)
	{
		Treecnt[v]++;
	}
	else if(ind <= (r+ l) / 2)
	{
		update3(v * 2, l, (r + l) / 2, ind);
		Treecnt[v]++;
	}
	else
	{
		update3(v * 2 + 1, (r + l) / 2 + 1, r, ind);
		Treecnt[v]++;
	}
}
int ans3(int v, int l, int r, int al, int ar)
{
	if(al <= l && r <= ar)
	{
		return Treecnt[v];
	}
	else if(al <= r && ar >= l)
	{
		return ans3(v * 2, l, (r + l) / 2, al, ar) + ans3(v * 2 + 1, (r + l) / 2 + 1, r, al, ar);
	}
	else
	{
		return 0;
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k, q;
	cin >> n >> k >> q;
	Treecnt.resize(4 * n);
	Treeleft.resize(4 * n);
	Treeright.resize(4 * n);
	vector <int> A(n);
	vector <pair <int, int> > B(n);
	for(int i = 0; i < n; i++)
	{
		cin >> A[i];
		B[i] = {A[i], i};
	}
	sort(B.begin(), B.end());
	int ans = 1e9;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < 4 * n; j++)
		{
			Treeright[j] = n;
			Treeleft[j] = -1;
			Treecnt[j] = 0;
		}
		for(int j = 0; j < i; j++)
		{
			update1(1, 0, n - 1, 0, B[j].second, B[j].second);
			update2(1, 0, n - 1, B[j].second, n - 1, B[j].second);
		}
		int cnt = 0;
	//	cout << i << "\n";
		int p1 = 1e9;
		for(int j = i; j < n; j++)
		{
			int l1 = ans1(1, 0, n - 1, B[j].second);
			int r1 = ans2(1, 0, n - 1, B[j].second);
			if(l1 + 1 <= r1)
			{
				int e = ans3(1, 0, n - 1, l1 + 1, r1 - 1);
	//			cout << j << " " << l1 << " " << r1 << " " << e << "\n";
				if(r1 - l1 - 1 - e>= k)
				{
	//				cout << j << "\n";
					cnt++;
					p1 = min(p1, B[j].first);
					update3(1, 0, n - 1, B[j].second);
				}
			}
			if(cnt >= q)
			{
				ans = min(ans, B[j].first - p1);
				break;
			}
		}
	}
	cout << ans;
    return 0;
}

Measured memory_bytes: 532
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-6;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,ans;
main() {
    file("cowdate");
    ios;
    cin>>n;
    fo(i,1,n,1) {
        int x=i;
        int len=0;
        while (x) ++len, x/=10;
        if (len&1) ++ans;
    }
    cout<<ans;
    return 0;
}
/**

*/


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

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

  unordered_set<string> data;
  string buf;
  for(int i=0; i<N; i++){
    cin >> buf;
    data.insert(buf);
  }

  cout << data.size() << endl;
}

Measured memory_bytes: 17688
N = int(input())
xy = []
for i in range(N):
    xy.append(list(map(int,input().split())))

from itertools import permutations
a = range(N)
Ps = list(permutations(a))
#print('Ps', Ps)

keiro = []
for P in Ps:
    #print('P', P)
    for i in range(N-1):
        keiro.append( ((xy[P[i]][0] - xy[P[i+1]][0])**2 + (xy[P[i]][1] - xy[P[i+1]][1])**2 )**0.5 )
out=sum(keiro)/len(Ps)
#print('keiro', keiro)
print(out)

Measured memory_bytes: 63728
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll h, w, m;
        cin >> h >> w >> m;
        if(h == 1 || w == 1){
            cout << m;
            return 0;
        }
        vector<ll> col(w + 1), row(h + 1);
        set<pair<ll,ll>> s;
        for(i = 0; i < m; i++){
            ll x, y;
            cin >> x >> y;
            row[x]++;
            col[y]++;
            s.insert({x, y});
        }
        
        
        vector<pair<ll,ll>> ca, ra;
        for(i = 0; i < h; i++){
            ra.pb({row[i + 1], i + 1});
        }
        for(i = 0; i < w ;i++){
            ca.pb({col[i + 1] ,i + 1});
        }
        sort(ra.rbegin(), ra.rend());
        sort(ca.rbegin(), ca.rend());
        vector<ll> r, c;
        for(auto u : ra){
            r.pb(u.ss);
        }
        for(auto u : ca){
            c.pb(u.ss);

        }
        ll ans = 0;
        ll csz = c.size();
        ll rsz = r.size();
        
        for(i = 0; i < rsz; i++){
            for(j = 0; j < 1; j++){
                ll val = row[r[i]] + col[c[j]];
                if(s.find({r[i], c[j]}) != s.end()){
                    val--;
                }
                ans = max(ans, val);
            }
        }
        for(i = 0; i < csz; i++){
            for(j = 0; j < 1; j++){
                ll val = row[r[j]] + col[c[i]];
                if(s.find({r[j], c[i]}) != s.end()){
                    val--;
                }
                ans = max(ans, val);
            }
        }
        cout << ans;
    }
    return 0;
}
/*
100 100 10
1 3
2 3
12 42
11 11
43 21
23 12
23 54
12 12
1 5
*/


Measured memory_bytes: 44940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(ll i=0;i<N;++i)
const ll INF = 1LL<<60;

int main(){
    ll N; cin >> N;
    vector<ll> A(N);
    map<ll,ll> mp;
    rep(i,N){
        cin >> A[i];
        mp[A[i]] ++;
    }

    if(mp.size() == 3){
        ll a[3];
        ll i = 0;
        for(auto it : mp){
            a[i] = it.first;
            ++i;
            if(it.second != N/3){
                cout << "No" << endl;
                return 0;
            }
        }
        if(a[0] ^ a[1] ^ a[2]){
            cout << "No" << endl;
            return 0;
        }
    }else if(mp.size() == 2){
        bool ok = false;
        for(auto it : mp){
            if(it.first == 0 && it.second == N/3) ok = true;
        }
        if(!ok){
            cout << "No" << endl;
            return 0;
        }
    }else if(mp.size() == 1){
        for(auto it : mp){
            if(it.first != 0){
                cout << "No" << endl;
                return 0;
            }
        }
    }else{
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 5632
n = int(input())

from collections import defaultdict
dic = defaultdict(int)

for _ in range(n):
    s = list(input())
    s = tuple(sorted(s))
    dic[s] += 1

ans = 0
for s in dic:
    ans += dic[s] * (dic[s] - 1) // 2

print(ans)





Measured memory_bytes: 117508
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,r=0;cin>>n;
  ll m=n,ans=0,a[1000000];
  fill(a,a+1000000,0);
  for(ll i=2;i*i<=n;i++){
    if(m%i==0){
      while(m%i==0){
        a[r]++;
        m=m/i;
      }
      r++;
    }
  }
  ll j=1;
  for(int i=0;i<r;i++){
    while(a[i]-j>=0){
      ans++;
      a[i]-=j;
      j++;
    }
    j=1;
  }
  if(m!=1){ans++;}
  cout<< ans<<endl;
}

Measured memory_bytes: 11436
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  string s;
  cin >> s;
  rep(i,s.size()){
    if(i%2==0){
      if(s[i]=='L'){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      if(s[i]=='R'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;

const int mod = 1e9+7;
int N;

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

  cin >> N;

  vector<int> a(N);
  vector<int> b(N);
  rep(i, N) {
    cin >> a.at(i);
  }
  rep(i, N) {
    cin >> b.at(i);
  }

  int ans = 0;
  for(int k=29; k>=0; k--) {
    int TT = 1<<(k+1);
    rep(i, N) {
      b.at(i) %= TT;
    }
    sort(b.begin(), b.end());
    ll sum = 0;
    //debugln(k);
    int T = 1<<k;
    rep(i, N) {
      a.at(i) %= TT;
      int pos = T-a.at(i);
      auto it1 = lower_bound(b.begin(), b.end(), pos);
      pos += T;
      auto it2 = lower_bound(it1, b.end(), pos);
      pos += T;
      auto it3 = lower_bound(it2, b.end(), pos);
      auto it4 = b.end();
      //debug(aa);
      //debug(distance(it1, it2));
      //debugln(distance(it3, it4));
      sum += distance(it1, it2) + distance(it3, it4);
    }
    ans += (sum%2)<<k;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

bool check(ll const & a, int const & k) {
    string s = to_string(a);
    rep(i, s.size()-k) if(s[i] != s[i+k]) return false;
    return true;
}

ll gcd(ll a, ll b) {
    if(a < b) swap(a, b);

    while(b!=0) {
        ll t = a;
        a = b;
        b = t%b;
    }
    return a;
}

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

    ll a, b; cin >> a >> b;
    cout << a*b/gcd(a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

#include <stdio.h>
#include <string.h>

using namespace std;

int main() {
    string n;
   
 
   cin >> n;
   
   int j = n.size();
  
   char a = n[0];
  
   std::string b{a};     // "a"
 
  
    
   for (int i = 1;i < j + 1;i++){
     
       if (i%2 != 0 && i != 1){
         
        
         char x = n[i-1];
         std::string y{x};
         
       
         
         b = b + y;
       }
     
   }

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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  int a[3],d;
  rep(i,3) R a[i];
  R d;
  if(abs(a[1]-a[0])<=d&&abs(a[2]-a[1])<=d||abs(a[2]-a[0])<=d) pr("Yes");
  else pr("No");
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define r1 rt<<1
#define r2 rt<<1|1
#define fi first
#define se second
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

inline ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^'0'),c=getchar();
	return x*f;
}
inline void write(ll x){
	if(x<0) putchar('-'),x=-x;
	if(x>9) write(x/10);
	putchar(x%10+'0');
}

const int p=1000000007,N=1e5+5;
int t[10];
int main()
{
	ri n=read(),y,s=1;
	rep(i,1,n){
		ri x=read();y=0;
		rep(j,1,3){
			if(t[j]==x)++y;
		}
		if(!y){
			cout<<0;return 0;
		}
		s=(ll)s*y%p;
		rep(j,1,3)if(t[j]==x){
			++t[j];break;
		}
	}cout<<s;
	return 0; 
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
    	Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        if(b%a == 0){
        	System.out.println(a+b);
        }else{
        	System.out.println(b-a);
        }
    }
}

Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>

using namespace std;

#define int long long

signed main() {
	double n;

	cin >> n;

	vector<double>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

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

	double ans;

	for (int i = 0; i < n - 1; i++) {
		ans = (v[i] + v[i + 1]) / 2;
		v[i + 1] = ans;
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
/* Prime Numbers */

#include <stdio.h>
#include <math.h>

int primep(int);

int main(void) {
  int n, x, count = 0, i;

  scanf("%d", &n);

  for(i = 0; i < n; i++) {
    scanf("%d", &x);
    if(primep(x)) count++;
  }

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

  return 0;
}

int primep(int x) {
  int i, m = (int)sqrt((double)x);
  if(x == 2) return 1;
  if(x < 2 || x%2 == 0) return 0;
  for(i = 3; i <= m; i += 2)
    if(x%i == 0) return 0;
  return 1;
}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		for(int mask = 0 ; mask < 1<<(n-1) ; mask++) {
			int sum = (int)(s.charAt(0) - '0');
			String x = "" + s.charAt(0);
			for(int i = 0 ; i < s.length() - 1 ; i++) {
				if((mask&(1<<i)) >= 1) {
					sum += (int)(s.charAt(i + 1) - '0');
					x += "+" + s.charAt(i + 1);
				} else {
					sum -= (int)(s.charAt(i + 1) - '0');
					x += "-" + s.charAt(i + 1);
				}
			}
			if(sum == 7) {
				System.out.println(x + "=7");
				return;
			}
		}
	}
}

Measured memory_bytes: 21972
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

def perm(n,r,p):
    if (r < 0) or (n < r):
        return 0
    return fact[n] * factinv[n-r] % p 

p = 10 ** 9 + 7
N = 5 * 10 ** 6 + 10 # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

n,m=map(int,input().split())
ans=0
for i in range(n+1):
    dat=perm(m,n,p)*perm(m-i,n-i,p)*cmb(n,i,p)%p
    #print(dat)
    if i%2==0:
        ans+=dat
    else:
        ans-=dat

print(ans%p)
    

Measured memory_bytes: 316908
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
string increment(string strNum) {
  if (strNum == "#") return strNum; 
  int num = atoi(strNum.c_str());
  num++;
  return to_string(num);
}


int main() {
  int H, W;
  cin >> H >> W;

  string S;
  string ans[H][W];
  // 入力
  rep(i, H) {
  	cin >> S;
    rep(j, W) {
      if (S[j] == '.') {
        ans[i][j] = '0';
      } else {
      	ans[i][j] = S[j];
      }
    }
  }
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
  
  // 置き換え
  rep(i, H) {
    rep(j, W) {
      if (ans[i][j] != "#") continue;
      for (int d = 0; d < 8; ++ d) {
        const int ni = i + dy[d];
        const int nj = j + dx[d];
        if (ni < 0 or H <= ni) continue;
        if (nj < 0 or W <= nj) continue;
        ans[ni][nj] = increment(ans[ni][nj]);
      }
      
    }
  }
  
  // 出力
  rep(i, H) {
    rep(j, W) {
      cout << ans[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int n,sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		sum+=b-a+1;
	}
	printf("%d\n",sum);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n, s[110000], r[110000], ans = 0;
int main() {
	cin >> n;
	REP(i, n)cin >> s[i];
	sort(s, s + n);
	REP(i, n)r[i + 1] = r[i] + s[i];
	FORR(i, n, 1) {
		if (r[i] * 2 < s[i])break;
		else ans++;
	}
	cout << ans << endl;
}



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

char A[6];

int main() {
    scanf("%s", A);
    for(int i = 0; i < 3; ++i) {
        if(A[i] == '1') A[i] = '9';
        else A[i] = '1';
    }
    printf("%s", A);
}

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

void Insert(vector<int> vecIn, int nCount)
{
	for (int i = 1; i < nCount; i++)
	{
		int nTemp = vecIn[i];
		int j = i - 1;
		for (; j >= 0 && vecIn[j] > nTemp; --j)
		{
			vecIn[j + 1] = vecIn[j];
		}
		vecIn[j + 1] = nTemp;

		for (int i = 0; i < vecIn.size(); i++)
		{
			cout << vecIn[i];
			if (i != vecIn.size() - 1)
			{
				cout << " ";
			}
		}
		cout << endl;
	}
}


int main()
{
	int nCount = 0;
	cin >> nCount;
	vector<int> vecIn(nCount, 0);
	for (int i = 0; i < vecIn.capacity(); i++)
	{
		cin >> vecIn[i];
	}

	for (int i = 0; i < vecIn.size(); i++)
	{
		cout << vecIn[i];
		if (i != vecIn.size() - 1)
		{
			cout << " ";
		}
	}
	cout << endl;

	Insert(vecIn, nCount);
	//system("pause");
	return 0;
}

Measured memory_bytes: 3136
#include <iostream>
#include <cstring>

using namespace std;

const int MAXN=10000;
const int MAXK=1000;

int y1[10*MAXK+5];//记录y=y1行黑色格子的个数 

struct point{
	int x;
	int y;
	int c;
}a[100000];

int main(int argc, char *argv[]) {
	int N,K;
	while(cin>>N>>K) {
		int Max=0,cnt=0;//cnt记录黑色格子的总个数 
		int i;
		for(i=0;i<N;i++) {
			char ch;
			cin>>a[i].x>>a[i].y>>ch;
			a[i].x%=(2*K);//降维,*2k或%2k都仅仅是改变了它的位置，而没有改变它的颜色。
			a[i].y%=(2*K);
			if(ch=='W')
				a[i].c=1;//白色格子标记为1
			else
				a[i].c=0;
		}
		
		for(i=0;i<K;i++) {//在那个2k*2k的格子里枚举长度为k的横竖边 
			cnt=0;
			memset(y1,0,sizeof(y1));
			int j;
			for(j=0;j<N;j++) {//依次遍历各点 
				int p=(i<=a[j].x&&a[j].x<i+K);
				int q=(0<=a[j].y&&a[j].y<K); 
				//cout<<"p="<<p<<" "<<"q="<<q<<endl;
				if(p^q==a[j].c) {//通过异或运算，被两条边都覆盖了的和都没被覆盖是一个颜色，其它的格子是另一个颜色。  
					cnt++;
					y1[a[j].y]++; 
				} 
				else
					y1[a[j].y]--;
				//cout<<"y1[a["<<j<<"].y]="<<y1[a[j].y]<<endl;
			}
			for(j=0;j<K;j++) {
				if(cnt>Max)
					Max=cnt;
				if(N-cnt>Max)//若白色格子比黑色格子多，则让Max取白色格子的个数 
					Max=N-cnt;
				if(j!=K)
					cnt=cnt-y1[j]-y1[j+K];
			}
		}
		
		cout<<Max<<endl; 
	}
	
	return 0;
}

Measured memory_bytes: 1408
n=int(input())
ans=[0 for i in range(10050)]
for i in range(1,105):
  for j in range(1,105):
    for k in range(1,105):
      v=i*i+j*j+k*k+i*j+i*k+j*k
      if v<10050:
        ans[v]+=1
for i in range(n):
  print(ans[i+1])


Measured memory_bytes: 9024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int m,f,r;

		while(true) {
			m = scan.nextInt();
			f = scan.nextInt();
			r = scan.nextInt();
			if(m==-1 && f==-1 && r==-1) break;
			System.out.println(check(m,f,r));
		}

		scan.close();
	}

	static String check(int m,int f,int r) {
		int sum = m+f;
		if(m==-1 || f==-1) return "F";
		if(sum>=80) return"A";
		if(sum>=65 && sum<=80) return "B";
		if(sum>=50 && sum<=65 || r>=50) return "C";
		if(sum>=30 && sum<=50) return "D";
		return "F";
	}

}


Measured memory_bytes: 26232
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from bisect import bisect_left


def combination(n, r): #nCrを求める
    if n - r < r:
        r = n - r
    tmp = 1
    for i in range(n - r + 1, n + 1):
        tmp *= i
    for i in range(1, r + 1):
        tmp //= i
    return tmp



N = int(input())
A = list(map(int, input().split()))
A.sort()

a1 = A[-1]
tmp = bisect_left(A, a1 // 2)
b1 = A[tmp]

if tmp != 0:
    if abs(b1 / a1 - 1/2) >= abs(A[tmp - 1] / a1 - 1/2):
        b1 = A[tmp - 1]

print (a1, b1)

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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 gcd(int a, int b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));}

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

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n, t;
  cin >> n >> t;
  vector<int> a(n);
  REP(i, n) cin >> a[i];
  a.push_back(a[n-1] + t);
  int ans = 0;
  REP(i, n){
    ans += min(a[i+1]-a[i], t);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 4764