akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

#define zton(i,n) for(int i=0;i<=n;i++)
#define oneton(i,n) for(int i=1;i<=n;i++)
#define fo(i,n) for(int i=0;i<n;i++)
#define fab(i,a,b) for(int i=a;i<b;i++)
#define loop(i,b,a) for(int i=a;i>=b;i--)
#define dsort(arr,n) sort(arr, arr + n, greater<int>())
#define vsortd(a) sort(a.begin(), a.end(), greater<double>())
#define vsort(a) sort(a.begin(), a.end())
#define ll long long int
#define test int tc;cin>>tc;while(tc--)
#define dbg(x) cout<<#x<<'='<<(x)<<endl;
#define dbg2(x,y) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl;
#define dbg3(x,y,z) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl;
#define dbg4(x,y,z,w) cout<<#x<<'='<<(x)<<endl<<#y<<'='<<(y)<<endl<<#z<<"="<<(z)<<endl<<#w<<"="<<(w);
#define minheap priority_queue <int, vector<int>, greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define ff first
#define ss second
#define mpr make_pair
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mkv vector<int>
#define allzero(dp) memset(dp,0,sizeof(dp))
#define endl "\n"
#define print(x) cout<<x<<endl;

const int mod=998244353;
using namespace std;
bool sortcol( const vector<int>& v1,const vector<int>& v2 ) {return v1[1] < v2[1];}
typedef pair<int, int> pi;

void fastio()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

bool sortfun(const pair<ll,ll> &a,const pair<ll,ll> &b){
    return (a.ss>b.ss);
   // if(a.first==b.first)return a.second<b.second;
    //return false;
}

ll power(ll x, ll y){
    ll res = 1;x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        y=y>>1;x=(x*x)%mod;}
    return res;
}


void solve()
{
    ll n;cin>>n;
    ll ans=n%1000;
    if(ans==0)
        print(0)
    else
        print(1000-ans)
}

int main()
{
   // fastio();
  //  test
    solve();
}


Measured memory_bytes: 3616
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
int gi() { 
    int data = 0, w = 1; 
    char ch = 0; 
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar();
    return w * data; 
}
char ch[200]; 
int main () { 
	scanf("%s", ch + 1); 
	if (ch[2] == 'B') puts("ARC"); 
	else puts("ABC"); 
    return 0; 
} 

Measured memory_bytes: 3128
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int s,w;
        cin>>s>>w;
        if(s<=w) cout<<"unsafe";
        else cout<<"safe";
    }
    return 0;
}

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

tn = 0
xn = 0
yn = 0

while n > 0:
    n -= 1
    c = "f"
    I = input()
    N = I.split()
    t = int(N[0])
    x = int(N[1])
    y = int(N[2])

    ts = t - tn
    xs = x - xn
    ys = y - yn
    s = ts - ( xs + ys )

    if s == 0:
        c = "t" 
    elif s > 0:
        if s % 2 ==0:
            c = "t"
    if c == "f":
        break

if c == "t":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cfloat>
#include <iomanip>

using namespace std;
using P = pair<int, int>;

vector<int> table[605];
double dp[605];
double pb[605];

signed main() {
    int N, M;
    cin >> N >> M;
    vector<P> edges;
    for (int i = 0; i < M; i++) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        table[s].push_back(t);
        edges.push_back(P(s, t));
    }

    dp[N-1] = 0;
    for (int i = N-2; i >= 0; i--) {
        double sum = 0;
        int num = 0;
        for (int next : table[i]) {
            sum += dp[next];
            ++num;
        }
        sum /= num;
        dp[i] = sum + 1;
    }

    pb[0] = 1;
    for (int i = 0; i < N; i++) {
        int sz =table[i].size();
        if (sz == 0) continue;
        double cof = 1.0 / sz;

        for (int next : table[i]) {
            pb[next] += pb[i] * cof;
        }
    }

    double ret = dp[0];
    for (P edge : edges) {
        int i = edge.first;
        int j = edge.second;
        int n = table[i].size();
        if (n == 1) continue;
        double val = dp[0];
        val -= pb[i] * dp[i];
        val += pb[i] * ((n * dp[i] - n - dp[j]) / (n-1) +1);
        ret = min(ret, val);
    }

    cout << setprecision(10) << fixed << ret << endl;
    return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define lb lower_bound
#define ub upper_bound
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n,m;cin>>n>>m;
  if(n==m)cout<<"Yes"<<ENDL;
  else cout<<"No"<<ENDL;
}
//( ・ __ ・ ) KEEP BEING ORGANIZED
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl

namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	string key = "keyence";
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		for (int j = 0; j + i < s.size(); j++) {
			string a = s.substr(0, i) + s.substr(i + j);
			if (a == key) {
				cout << "YES" << endl;
				return 0;
			}
		}
	}
	cout << "NO" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007
#define KETA 40

using namespace std;

typedef long long  ll;
typedef pair<ll,ll> P1;
typedef pair<string,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<Pi,int> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	int n;
	int p[51];
	int d[51]={};

	cin>>n;

	rep(i,n){
		cin>>p[i];
		d[i]=p[i];
	}
	sort(p, p + n);

	int t=0;
	rep(i,n){
		if(d[i]!=p[i])t++;
		if(t>2){
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;

	return 0;

}


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

#define rep(i, n) for(int i=0; i<n; ++i)

#define N 200003
struct SCC {
  int n;
  int group[N];
  int label;

  vector<int> *g, *rg;
  vector<int> ord;

  set<int> g0[N];
  vector<int> gp[N];
  int deg[N];

  bool used[N];
  void dfs(int v) {
    used[v] = true;
    for(int w : g[v]) {
      if(!used[w]) dfs(w);
    }
    ord.push_back(v);
  }

  void rdfs(int v, int col) {
    group[v] = col;
    used[v] = true;
    for(int w : rg[v]) {
      if(!used[w]) rdfs(w, col);
    }
  }

  // construct scc
  inline void init(int n, vector<int> *g, vector<int> *rg) {
    this->n = n; this->g = g; this->rg = rg;

    for(int i=0; i<n; ++i) used[i] = false;
    ord.reserve(n);
    for(int i=0; i<n; ++i) {
      if(!used[i]) dfs(i);
    }
    assert(ord.size() == n);

    for(int i=0; i<n; ++i) used[i] = false;
    int cnt = 0;
    for(int i=n-1; i>=0; --i) {
      int v = ord[i];
      if(!used[v]) rdfs(v, cnt++);
    }
    label = cnt;
  }

  inline void construct() {
    for(int i=0; i<n; ++i) deg[i] = 0;
    for(int v=0; v<n; ++v) {
      int s = group[v];
      for(auto w : g[v]) {
        int t = group[w];
        if(s == t || g0[s].count(t)) {
          continue;
        }

        g0[s].insert(t);
        ++deg[t];
      }

      gp[s].push_back(v);
    }
  }
};

SCC scc;
vector<int> g[N], rg[N];

int main() {
  int n, m;
  cin >> n >> m;
  rep(i, m) {
    int s, t; cin >> s >> t;
    g[s].push_back(t);
    rg[t].push_back(s);
  }
  scc.init(n, g, rg);
  int q; cin >> q;
  auto group = scc.group;
  rep(i, q) {
    int u, v; cin >> u >> v;
    if(group[u] == group[v]) {
      cout << 1 << endl;
    } else {
      cout << 0 << endl;
    }
  }
}


Measured memory_bytes: 27152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first.first
#define yy first.second
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod ((__int128)1000000007)
using namespace __gnu_pbds;
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifdef LOCAL
//	freopen("in", "r", stdin);
#endif
}
typedef long long ll;
typedef ll _I;
typedef double ld;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <ld> vd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n, k;
string s;
char t;

int main() {
	doin();
	cin >> n >> s >> k, k--;
	t = s[k];
	for(auto& i : s)
		cout << (i == t ? i : '*');
}



Measured memory_bytes: 256
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/4/ALDS1_4_B
# pythonでは便利な実装がすでにあるのでそれを使えるように
# 実装例はここにある https://docs.python.org/ja/3/library/bisect.html#searching-sorted-lists

from bisect import bisect_left
# 他にもbisect, bisect_leftがあったりするが、重複した値があったときに右側を返すか左側を返すかの違い
# bisectはrightと一緒


def find_exact_equal(a: list, x: int):
    i = bisect_left(a, x)
    if i != len(a) and a[i] == x:
        return 1  # 見つかったら1を返す。
    return 0  # 見つからなかったら0


n = input()
S = list(map(int, input().split()))
q = input()
T = list(map(int, input().split()))

cnt = 0
for t in T:
    cnt += find_exact_equal(S, t)

print(cnt)



Measured memory_bytes: 16744
#include<stdio.h>
#include<string.h>
typedef struct g{int p[4][2],z;char c;}g;//up,left,right,down
int H,W,i,j,k,N,p[128],o,q;
g G[7];
char X[51][51];
int dfs(int d)
{
	int i,j,k,r=0;
	if(d==o)
	{
		for(k=0;k<o;k++)
			for (i=G[k].p[0][0];i<=G[k].p[3][0];i++)
				for (j=G[k].p[1][1];j<=G[k].p[2][1];j++)
					if(X[i][j]=='.'||G[p[X[i][j]]].z>G[k].z)
						return 0;
		return 1;
	}
	else
	{
		for(i=0;i<o;i++)
		{
			if(G[i].z==-1)
			{
				G[i].z=d;
				r|=dfs(d+1);
				G[i].z=-1;
			}
		}
	}
	return r;
}
int main()
{
	for(scanf("%d",&N);N--;)
	{
		scanf("%d%d\n",&H,&W);
		memset(p,-1,sizeof(p));
		memset(G,-1,sizeof(G));
		for(i=o=0;i<H;i++)
			gets(X[i]);
		for(i=0;i<H;i++)
			for(j=0;j<W;j++)
			{
				if((q=X[i][j])!='.')
				{
					if(p[q]==-1)
					{
						p[q]=o++;
						G[p[q]].c=X[i][j];
						G[p[q]].p[0][0]=G[p[q]].p[1][0]=G[p[q]].p[2][0]=G[p[q]].p[3][0]=i;
						G[p[q]].p[0][1]=G[p[q]].p[1][1]=G[p[q]].p[2][1]=G[p[q]].p[3][1]=j;
					}
					else
					{
						if(G[p[q]].p[0][0]>i)//up
						{
							G[p[q]].p[0][0]=i;
							G[p[q]].p[0][1]=j;
						}
						if(G[p[q]].p[1][1]>j)//left
						{
							G[p[q]].p[1][0]=i;
							G[p[q]].p[1][1]=j;
						}
						if(G[p[q]].p[2][1]<j)//right
						{
							G[p[q]].p[2][0]=i;
							G[p[q]].p[2][1]=j;
						}
						if(G[p[q]].p[3][0]<i)//down
						{
							G[p[q]].p[3][0]=i;
							G[p[q]].p[3][1]=j;
						}
					}
				}
			}
		puts(dfs(0)?"SAFE":"SUSPICIOUS");
	}
	return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  if ( s[0] != 'A' ) {
    cout << "WA" << endl;
    return 0;
  }
  int c_cnt = 0;
  int len = s.size();

  for ( int i = 1; i < len; i++ ) {
    if ( isupper( s[i] ) ) {
      if (  i > 1 && i < len - 1  && s[i] == 'C' )
        c_cnt++;
      else {
        cout << "WA" << endl;
        return 0;
      }
    }
  }
  if ( c_cnt != 1 ) {
    cout << "WA" << endl;
    return 0;
  }
  cout << "AC" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define d 15
bool hi(string f){
  for(int i=0;i<f.size();i+=2){
    if(f.substr(i,2)!="hi"){
      return 0;
    }
  }
  return 1;
}
int main() {
  string s;
  cin>>s;
  if(hi(s)){ cout<<"Yes";}
  else {cout<<"No";}
  return 0;
}

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

int main(){
    int year;
    long long A[30];
    A[0]=1;
    A[1]=1;
    A[2]=2;
    int n;
    while(cin>>n && n!=0){
        for(int i=3;i<=n;++i){
            A[i]=A[i-1]+A[i-2]+A[i-3];
        }
        year=(A[n]/10)/365+1;
        cout<<year<<"\n";
    }
}

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

int main() {
  int n;
  cin>>n;
  vector<int>d(n);
  for(int i=0;i<n;i++) cin>>d[i];
  sort(d.begin(),d.end());
  int core=d[0];
  int ans=n;
  for(int i=1;i<n;i++){
    if(d[i]==core) ans--;
    else core=d[i];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		sc.close();

		int min = 0;
		int now = 0;
		for (int i = 0; i < n; i++) {
			if (s[i] == '(') {
				now++;
			} else {
				now--;
			}
			min = Math.min(min, now);
		}
		min = -min;

		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < min; i++) {
			sb.append('(');
		}
		sb.append(s);
		for (int i = 0; i < now + min; i++) {
			sb.append(')');
		}
		System.out.println(sb.toString());
	}
}


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

int main(){
	int a;
	string num;
	while (1){
		a = 0;
		cin >> num;
		if (num == "0")break;
		
		for (int i = 0; i < num.size(); i++){
			a += num[i]-'0';
		}
		cout << a << endl;
	}


	return 0;
}

Measured memory_bytes: 3188
A,B,K=map(int,input().split())
List=[]
for i in range(K):
  if A<= A+i <= B:
    List.append(A+i)
  if A<= B-i <= B:
    List.append(B-i)
s_l=set(List)
NewList=list(s_l)
NewList.sort()
for i in NewList:
  print(i)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
#define ll long long
using namespace std;
  
int main(){
  int n;
  ll t, a, pt, pa;
  cin >> n;
  cin >> pt >> pa;
  for(int i = 1; i < n; i++){
    cin >> t >> a;
    ll tmp = max((pt + t - 1) / t, (pa + a - 1) / a);
    pt = tmp * t, pa = tmp * a;
  }
  cout << pt + pa << endl;
  return 0;
}

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

int main() {
	vector<string> vec;
	vec = {"Sunny", "Cloudy", "Rainy"};
	
	string s;
	cin >> s;
	
	for (int i = 0; i < vec.size(); i++) {
		if (s == vec.at(i)) {
			cout << vec.at((i  + 1) % 3) << endl;
		}
	}
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main() {
    let vec: Vec<i32> = read_line();
    let (k, x) = (vec[0], vec[1]);
    let min = x - (k - 1);
    let max = x + (k - 1);
    for i in min..max+1 { print!("{} ", i); }
    println!();
}

Measured memory_bytes: 4352
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e18;

ll func(string s,string t){
    ll ans=0;
    for(char c='a';c<='z';c++){
        bool founds=false,foundt=false;
        rep(i,s.length()){
            if(s[i]==c) founds=true;
        }
        rep(i,t.length()){
            if(t[i]==c) foundt=true;
        }
        if(founds && foundt) ans++;
    }
    return ans;
}

int main(){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans=0;
    for(ll i=0;i<=n;i++){
        ll tmp=func(s.substr(0,i),s.substr(i));
        ans=max(ans,tmp);
    }
    cout << ans << endl;
} 

Measured memory_bytes: 256
fn read_spc<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    snuke();
}

fn snuke() {
    let whn: Vec<i64> = read_spc();
    let mut w = whn[0];
    let mut h = whn[1];
    let n = whn[2];
    let mut xya: Vec<Vec<i64>> = vec![];
    for i in 0..n {
        let xya_i: Vec<i64> = read_spc();
        xya.push(xya_i);
    }
    let mut x1 = 0;
    let mut x2 = w;
    let mut y3 = 0;
    let mut y4 = h;
    for xya_i in xya {
        let x = xya_i[0];
        let y = xya_i[1];
        let a = xya_i[2];
        match a {
            1 => x1 = max_i64(x1, x),
            2 => x2 = min_i64(x2, x),
            3 => y3 = max_i64(y3, y),
            _ => y4 = min_i64(y4, y)
        }
    }
    w = max_i64(0, x2 - x1);
    h = max_i64(0, y4 - y3);
    println!("{}", w * h);
}

fn max_i64(n: i64, m: i64) -> i64 {
    let diff = n - m;
    match diff {
        diff if diff < 0 => m,
        _                => n
    }
}

fn min_i64(n: i64, m: i64) -> i64 {
    let diff = n - m;
    match diff {
        diff if diff > 0 => m,
        _                => n
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(int i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;
vector<set<pair<ll,ll>>> pq,qp;
vector<vector<ll>> p,q;
vector<ll> used;
vector<pair<ll,ll>> xy;
unordered_map<ll, ll> ma,mb;
void dfs(int node,int k)
{
  //cout<<node<<endl;
  int x=xy[node].first,y=xy[node].second;
  used[node]=1;
  vector<ll> aa={x+k,x-k,y+k,y-k},bb={y-k,y-k,x-k,x-k},nn;
  rep(i,2)
  {
    if(!ma.count(aa[i]))continue;
    int idx=ma[aa[i]];
    auto s=pq[idx].lower_bound(make_pair(bb[i],0)),
         t=pq[idx].upper_bound(make_pair(bb[i]+2*k+1,0));
    while(s!=t)
    {
      auto tp=*s;s++;
      pq[ma[aa[i]]].erase(tp);
      qp[mb[tp.first]].erase({aa[i],tp.second});
      nn.push_back(tp.second);
    }
  }
  repi(i,2,4)
  {
    if(!mb.count(aa[i]))continue;
    int idx=mb[aa[i]];
    auto s=qp[idx].lower_bound(make_pair(bb[i]+1,0)),
         t=qp[idx].upper_bound(make_pair(bb[i]+2*k,0));
     while(s!=t)
     {
      auto tp=*s;s++;
      pq[ma[tp.first]].erase({aa[i],tp.second});
      qp[mb[aa[i]]].erase(tp);
      nn.push_back(tp.second);
     }
  }
  for(auto t:nn)dfs(t,k);
}
int cal(int x,int y,int k)
{
  vector<ll> aa={x+k,x-k,y+k,y-k},bb={y-k,y-k,x-k,x-k};
  int res=0;
  rep(i,2)
 {
   if(!ma.count(aa[i]))continue;
   int idx=ma[aa[i]];
   auto s=lower_bound(all(p[idx]),bb[i]),t=upper_bound(all(p[idx]),bb[i]+2*k);
   res+=t-s;
 }
 repi(i,2,4)
 {
   if(!mb.count(aa[i]))continue;
   int idx=mb[aa[i]];
   auto s=lower_bound(all(q[idx]),bb[i]+1),t=upper_bound(all(q[idx]),bb[i]+2*k-1);
   res+=t-s;
 }
 return res;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int  n,a,b;
  cin>>n>>a>>b;
  a--;b--;
  int cnt=0;
  xy.resize(n);
  rep(i,n)
  {
    int x,y;
    cin>>x>>y;
    xy[i]={x+y,x-y};
    mb[x-y]=cnt;
    ma[x+y]=cnt++;
  }
  pq.resize(cnt);
  qp.resize(cnt);
  p.resize(cnt);
  q.resize(cnt);
  rep(i,n)
  {
    int id=ma[xy[i].first];
    pq[id].insert({xy[i].second,i});
    p[id].push_back(xy[i].second);
    id=mb[xy[i].second];
    qp[id].insert({xy[i].first,i});
    q[id].push_back(xy[i].first);
  }
  rep(i,cnt)
  {
    sort(all(p[i]));
    sort(all(q[i]));
  }
  used.resize(n,0);
  int k=abs((xy[a].first+xy[a].second)-(xy[b].first+xy[b].second))+abs((xy[a].first-xy[a].second)-(xy[b].first-xy[b].second));
  k/=2;
  dfs(a,k);
  ll res=0;
  rep(i,n)
  {
    if(used[i]){res+=cal(xy[i].first,xy[i].second,k);}
  }
  cout<<res/2<<endl;


  return 0;

}


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

namespace AtCoder
{
  class Program
  {
    static void Main(string[] args)
    {
      int N = int.Parse(Console.ReadLine());
      List<int> ts = new List<int>();
      List<int> xs = new List<int>();
      List<int> ys = new List<int>();
      for(int i = 0; i < N; i++)
      {
        string[] ss = Console.ReadLine().Split(' ');
        ts.Add(int.Parse(ss[0]));
        xs.Add(int.Parse(ss[1]));
        ys.Add(int.Parse(ss[2]));
      }

      int t = 0, x = 0, y = 0;
      for(int i = 0; i < N; i++)
      {
        int td = ts[i] - t;
        int xd = xs[i] - x;
        int yd = ys[i] - y;

        int d = Math.Abs(xd) + Math.Abs(yd);
        if(td < d)
        {
          Console.WriteLine("No");
          //Console.ReadLine();
          return;
        }
        if(td % 2 != d % 2)
        {
          Console.WriteLine("No");
          //Console.ReadLine();
          return;
        }

        t = ts[i];
        x = xs[i];
        y = ys[i];
      }

      Console.WriteLine("Yes");
      //Console.ReadLine();
    }

  }
}

Measured memory_bytes: 42848
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] aArray = br.readLine().split(" ");
        int tmp = 0;
        for(String a : aArray){
            tmp += Integer.parseInt(a);
        }
        double avg = (double)tmp / n;
        double min = Math.abs(avg - Integer.parseInt(aArray[0]));
        int result = 0;
        for(int i = 1; i<n; i++){
            if(min > Math.abs(avg - Integer.parseInt(aArray[i]))){
                min = Math.abs(avg - Integer.parseInt(aArray[i]));
                result = i;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21204
count=0
import math
n=int(input())
a=1
b=1
c=1
while c<=n:
    while b<=n:
        while a<=n:
            d=math.gcd(a,b)
            e=math.gcd(d,c)
            count+=e
            a+=1
        a=1
        b+=1
    b=1
    c+=1
print(count)

      
      
      

Measured memory_bytes: 67460
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

const long long INF = 1LL << 60;

//long long ans = INF;
int N, M;
long long X;

int main(){
    cin >> N >> M >> X;
    long long C[N];
    long long A[N][M];

    for (int i = 0; i < N; ++i){
        cin >> C[i];
        for (int j=0; j < M; ++j){
            cin >> A[i][j];
        }
    }
    long long ans = INF;

    for(int i = 0; i < (1<<N); ++i){
        long long cost, lev[M];
        for (int j=0; j < M; ++j){
            lev[j] = 0;
        }
        cost = 0;
        for (int j=0; j < N; ++j){
            if (i & (1<<j)){
                cost += C[j];
                for(int k=0; k < M ; ++k){
                    lev[k] += A[j][k];
                }
            }
        }
        bool flag = true;
        for (int k=0; k < M ; ++k){
            if (lev[k] < X){
                flag = false;
                break;
            }
        }
        //cout << "bb=" << cost << endl;
        if(flag){
            //cout << "aa=" << cost << endl;
            chmin(ans, cost);
        }
    }
    if (ans == INF){
        cout << "-1" << endl;
        return 0;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 3620
N, M = map(int, input().split())
A,B = [],[]

for i in range(N):
  A.append(input())
for i in range(M):
  B.append(input())

ans = ""
for i in range(N-M+1):
#  print(A[i])
  if B[0] in A[i]:
    ans += "T"
    y = A[i].find(B[0])
#    print("{}行目の{}文字目".format(i+1, y+1))
    for j in range(1,M):
      
      if A[i+j][y:y+M] == B[j]:
        ans += "T"
      else:
        ans += "F"
#      print(i, j, ans)

if "T" * M in ans:
  print("Yes")
else:
  print("No")

   


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int rev(int a){
  int p=0;
  while(a!=0){
    p+=a%10;
    p*=10;
    a/=10;
  }
  return p/10;
}
bool pallin(int a){
  if(a==rev(a))
    return true;
  else
    return false;
}
int main()
{
   int a,b;
  cin>>a>>b;
  int ans=0;
  for(int i=a;i<=b;++i)
    if(pallin(i))
      ans++;
  cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(){
	int  a,b;
	while(1){
		scanf("%d%d",&a,&b);
		if(!(a|b))return 0;
		printf("%lf\n",2*sqrt(((double)a/2)*((double)a/2)+b*b)*a+a*a);
	}
}



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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	string s; cin >> s;
	int n = s.size();
	cout << s.substr(0, n - 8) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[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; }

int main()
{
    int n, m; cin >> n >> m;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    sort(ALL(a));

    if(n % a[m-1]==0){
        pr(n/a[m-1]);
        return 0;
    }

    arr<int> dp(m, vector<int>(n+1, 0));
    rep(i, m) rep(j, n+1) dp[i][j] = j;

    FOR(i, 1, m){
        // prarr(dp);
        // pr(a[i]);
        FOR(j, 1, n+1){
            // dp[i][j] = dp[i-1][j];
            int k = j/a[i];
            FOR(ki, 0, k+1) chmin(dp[i][j], dp[i-1][j - ki*a[i]]+ki);
        }
    }
    pr(dp[m-1][n]);
    return 0;}


Measured memory_bytes: 7036
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,c;
Vi ss,tt,cc;
vector<tuple<ll,ll,ll>> v;
ll ck[100010];

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>c;
    ss.resize(n);tt.resize(n); cc.resize(n);
    rep(i,n){
        cin>>ss[i]>>tt[i]>>cc[i];
        ss[i]--;
        v.pb(make_tuple(cc[i],ss[i],tt[i]));
    }
    rep(i,100010)ck[i]=0;
    sort(all(v));
    rep(i,v.size()-1){
        if(get<0>(v[i])==get<0>(v[i+1])){
            if(get<2>(v[i]) >= get<1>(v[i+1])){
                v[i+1] = make_tuple(get<0>(v[i]),get<1>(v[i]),get<2>(v[i+1]));
                v[i]=make_tuple(-1,get<1>(v[i]),get<2>(v[i+1]));
            }
        }
    }
    rep(i,v.size()){
        if(get<0>(v[i])==-1)continue;
        ck[get<1>(v[i])]++;
        ck[get<2>(v[i])]--;
    }
    ll ans = 0;
    rep(i,100009){
        ck[i+1] += ck[i];
        chmax(ans,ck[i+1]);
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 7284
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) long long((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    ll ans = 1e12;
    for (ll i = 1; i < sqrt(n) + 1; i++) {
        if (n % i == 0) ans = min(ans, i + n / i - 2);
    }
    OUT(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int res = 1;
  rep(i, n) {
    if (a[i] == res) res++;
  }
  cout << (res == 1 ? -1 : n - res + 1) << endl;


  
  return 0;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func rcv() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n, k := rcv(), rcv()
	h := make([]int, n)
	for i := 0; i < n; i++ {
		h[i] = rcv()
	}
	sort.Ints(h)

	a := int(^uint(0) >> 1)
	for i := k - 1; i < n; i++ {
		if x := h[i] - h[i-k+1]; x < a {
			a = x
		}
	}
	fmt.Println(a)
}


Measured memory_bytes: 1408
#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 n;
  cin>>n;
  vector<LL> p(n);
  REP(i,n){
    cin >> p[i];
  }

  LL cnt = 0;
  REP(i, n - 2)
  {
    vector<LL> q;
    q.push_back(p[i]);
    q.push_back(p[i+2]);
    q.push_back(p[i+1]);

    SORT(q);
    if(q[1]==p[i+1]){
      cnt++;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
def soin_to(n):
    N = n
    i = 0
    while(N%2 == 0):
        i += 1
        N /= 2
    return i

N = int(input())
nums = list(map(int, input().split()))
count = 0
for i in range(N):
    count += soin_to(nums[i])

print(count)

Measured memory_bytes: 4148
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e9+7;

int main()
{
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m),b(m);
    vector<vector<ll>> c(m);
    rep(i,m){
        cin >> a[i] >> b[i];
        rep(j,b[i]){
            ll x;
            cin >> x;
            c[i].push_back(x);
        }
    }
    vector<vector<ll>> dp(m+1,vector<ll>(1<<n,INF));
    dp[m][(1<<n)-1]=0;
    for(ll i=m-1;i>=0;i--){
        for(ll s=0;s<(1<<n);s++){
            ll t=s;
            for(auto x:c[i]){
                t|=(1<<(x-1));
            }
            dp[i][s]=min(dp[i+1][s],dp[i+1][t]+a[i]);
        }
    }
    cout << (dp[0][0]==INF?-1:dp[0][0]) << endl;
    return 0;
} 

Measured memory_bytes: 32512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a + b == 15) {
			System.out.println("+");
		} else if (a * b == 15) {
			System.out.println("*");
		} else {
			System.out.println("x");
		}

	}
}


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

int main(){
  int x,y;
  cin>>x>>y;
  for(int i=0;i<2000;i++){
  if(i*8/100==x&&i*10/100==y){
  cout<<i<<endl;
  break;
  }
  if(i==1999){
  cout<<-1<<endl;
  }
  }
}

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

//vector <long long> v[1000000];

//stack <long long> pus, wyn;

queue <long long> qu;

long long int  x[1000000], y, z, czy=0, w, n, m;
char s[10][10];

int main()
{
    long long int a, b, c, d, k, i, j, q, t, p;

//    q=1;


//    scanf("%lld", &q);
//    for(t=0; t<q; t++)
    {
        scanf("%lld", &n);
        for(i=0; i<n; i++)scanf("%lld", &x[i]);

        sort(x, x+n);

        qu.push(x[n-1]);

        w=0;

        for(i=n-2; i>=0; i--)
        {
            w+=qu.front();
            qu.pop();
            qu.push(x[i]);
            qu.push(x[i]);
        }

        printf("%lld\n", w);
    }

    return(0);
}


Measured memory_bytes: 6792
#include <stdio.h>

/* 選択ソート (0オリジン) */
int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, mini;
  for(i=0; i<N-1; i++) {
    mini = i;
    for(j=i; j<N; j++) {
      if(A[j] < A[mini]) mini = j;
    }

  	t = A[i];
  	A[i] = A[mini];
  	A[mini] = t;

  	if(i != mini) sw++;
  }
  return sw;
}

int main(void) {
  int A[100], N, i, sw;
  scanf("%d", &N);
  for(i=0;i<N;i++) scanf("%d",&A[i]);

  sw = selectionSort(A,N);

  for(i=0;i<N;i++) {
    if(i>0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}

Measured memory_bytes: 604
//#pragma comment(linker, "/STACK:102400000,102400000") 手动扩栈
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <string>
#include <map>
#include <queue>
#include <set> //插入时相同的不插，边插边排序，里面还有multiset可以重复
#include <algorithm>
inline int read(){int now=0;register char c=getchar();for(;!isdigit(c);c=getchar());
for(;isdigit(c);now=now*10+c-'0',c=getchar());return now;}
#define foc(i,x,y) for(int i = x ; i <= y ; i ++)
#define rea(i,x,y) for(int i = x ; i >= y ; i --)
#define scf(a) scanf("%d",&a)
#define sca(a,b) scanf("%d%d",&a,&b)
#define pri(a) printf("%d\n",a)
#define pri_(a) printf("%d ",a)
#define prn printf("\n")
#define mem(a) memset(a,0,sizeof(a))
#define LL unsigned long long
using namespace std;
const double eps = 1e-9;
const int maxn = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;
LL num[100],sum[100];
LL dfs(LL n,LL m)
{
    if(n==0)
        return 1;
    if(m<=1)
    {
        return 0;
    }
    else if(m<=num[n-1]+1)
    {
        return dfs(n-1,m-1);
    }
    else if(m==num[n-1]+2)
    {
        return sum[n-1] + 1;
    }
    else if(m<num[n])
    {
        LL s = sum[n-1] + dfs(n-1,m-2-num[n-1]) + 1;
        return s;
    }
    else if(m==num[n])
    {
        return sum[n];
    }
}
int main()
{
    num[0] = 1;
    sum[0] = 1;
    foc(i,1,55)
    {
        num[i] = (num[i-1] * 2) + 3;
        sum[i] = (sum[i-1] * 2) + 1;
    }
    LL n,m;
    cin >> n >> m;
    cout << dfs(n,m) << endl;
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
line = gets
data = line.split(" ")
odd = Array.new
even = Array.new
multiples_four = Array.new
N.times do |i|
  num = data[i].to_i
  if num % 4 == 0
    multiples_four << num
  elsif num % 2 == 0
    even << num
  else
    odd << num
  end
end
if even.length == 0
  if odd.length <= multiples_four.length + 1
    puts "Yes"
  else
    puts "No"
  end
elsif odd.length > 0
  if odd.length <= multiples_four.length
    puts "Yes"
  else
    puts "No"
  end
else
  if multiples_four == 0
    puts "No"
  else
    puts "Yes"
  end
end

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

int main(){
  string S;
  cin >> S;
  
  for(int i=0; i<S.size(); i++){
    if(S.at(i) == '1'){
      S.at(i) = '9';
    }
    else{
      S.at(i) = '1';
    }
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
# import math
# from itertools import permutations as permus
# from fractions import gcd
# from collections import deque
from collections import Counter

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
arrN = []
for _ in range(n):
    arrN += [input()]  #table.append(input())とも書ける
m = int(input())
arrM = []
for _ in range(m):
    arrM += [input()]  #table.append(input())とも書ける

countaN = Counter(arrN)
countaM = Counter(arrM)
countaAns = countaN - countaM

if len(countaAns) !=0:
    s,ans = countaAns.most_common()[0]
else:
    ans = 0

print(ans)

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

char rec[310][310];
int n, ans;

int sm(int x, int offset) {
	return (x + offset + n - 1) % n + 1;
}

int main() {
	scanf("%d\n", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%s", rec[i]+1);
	}
	for (int a = 0; a < n; a++) {\
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				int nx = sm(i, a);
				int ny = sm(j, -a);
				if (rec[i][j] != rec[ny][nx]) goto end;
			}
		}
		// printf("%d %d\n", a, b);
		ans++;
		end:;
	}
	printf("%d", ans * n);
	return 0;
}

Measured memory_bytes: 512
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
	int i,j,n,m,K,a;cin>>n;
	vector<pair<int,int>>sta(n);
	for(i=0;i<n;i++){cin>>sta[i].fir>>sta[i].sec;}
	static int dis[65536];
	for(int bi=0;bi<(1<<16);bi++){dis[bi]=99999;}
	
	vector<int>sp;
	for(j=0;j<n;j++){
		int h=sta[j].fir,w=sta[j].sec;
		for(int y=-h+1;y<=3;y++){
			for(int x=-w+1;x<=3;x++){
				int aaa=0;
				for(int ny=y;ny<y+h;ny++){
					for(int nx=x;nx<x+w;nx++){
						if(ny<0||nx<0||ny>=4||nx>=4){continue;}
						aaa|=(1<<(ny*4+nx));
					}
				}
				sp.pub(aaa);
			}
		}
	}
	SO(sp);
	sp.erase(unique(sp.begin(),sp.end()),sp.end());
	string kan[4];cin>>kan[0]>>kan[1]>>kan[2]>>kan[3];
	int R=0,B=0,G=0;
	for(int y=0;y<4;y++){
		for(int x=0;x<4;x++){
			if(kan[y][x]=='R'){R+=1<<(y*4+x);}
			if(kan[y][x]=='B'){B+=1<<(y*4+x);}
			if(kan[y][x]=='G'){G+=1<<(y*4+x);}
		}
	}
	dis[0]=0;
	queue<int>que;que.push(0);
	
	int full=65535;
	while(que.size()){
		int now=que.front();que.pop();
		int time=dis[now];
		//cerr<<pta<<" "<<time<<endl;
		for(int pta:sp){
			//ptaが押すパターン
			a=(now&(~pta))|(R&pta);
			if(mineq(dis[a],time+1)){que.push(a);}
			a=(now&(~pta))|(G&pta);
			if(mineq(dis[a],time+1)){que.push(a);}
			a=(now&(~pta))|(B&pta);
			if(mineq(dis[a],time+1)){que.push(a);}
		}
	}
	cout<<dis[65535]<<endl;
	return 0;
}



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

int main(){
    int a,b;
    cin >> a >> b;
    int sa = b-a;
    int left = 0;
    for(int i = 1; i <= b-a-1; i++){
        left += i;
    }
    cout << left-a << endl;
}

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

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0;i < n;i++){
        cin >> l[i];
    }
    sort(l.begin(),l.end());
    int sum = 0;
    for(int i = 0;i < (n-1);i++){
        sum += l[i];
    }
    if(l[n-1] < sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readA(T)(size_t n,ref T[]t){t=new T[](n);auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readM(T)(size_t r,size_t c,ref T[][]t){t=new T[][](r);foreach(ref v;t)readA(c,v);}

void main()
{
  int h, w; readV(h, w);
  int[][] a; readM(h, w, a);

  auto i2p(int p)
  {
    auto i = p/w, j = p%w;
    return tuple(i, i%2 == 0 ? j : w-j-1);
  }

  int[] o;
  foreach (i; 0..h*w) {
    auto p = i2p(i);
    if (a[p[0]][p[1]]%2 == 1) o ~= i;
  }

  int[] m;

  foreach (b; 0..o.length/2) {
    auto i1 = o[b*2], i2 = o[b*2+1];
    foreach (i; i1..i2) m ~= i;
  }

  writeln(m.length);
  foreach (mi; m) {
    auto p1 = i2p(mi), p2 = i2p(mi+1);
    writefln("%d %d %d %d", p1[0]+1, p1[1]+1, p2[0]+1, p2[1]+1);
  }
}


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

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

    int N, K;
    cin >> N >> K;

    int ans = 1;

    for(int i = 0; i < N; i++) {
        if(ans < K) ans *= 2;
        else ans += K;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 2e5+9;

template <class T, class Op = multiplies<T>>
T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}
template <unsigned M> struct modular {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wconversion"
  static constexpr unsigned mod = M;
  using m = modular;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
#pragma GCC diagnostic pop
};
using mint = modular<inf>;
mint A[N];

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n;
    cin>>n;
    mint m = 0;
    for(int i=0;i<n;++i) {
        cin>>A[i].v;
        m += A[i];
    }

    mint res = 0;
    for(int i=0;i<n-1;++i) {
        m -= A[i];
        res += m*A[i];
    }
    cout<<res.v<<endl;
    return 0;
}

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

const int mod = 1000000007;

long long calc(long long a, long long b, long long p)
{
	if (b == 0) return 1;
	if (b % 2 == 0)
	{
		long long d = calc(a, b / 2, p);
		return (d * d) % p;
	}
	else
		return (a * calc(a, b - 1, p)) % p;
}

signed main(void)
{
	int n, k;
	long long ans, p, q;

	cin >> n >> k;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	p = q = 0;
	rep(i, n) 
	{
		for(int j = i + 1; j < n; j++)
		{
			if (a[i] > a[j])
				p++;
		}
	}	
	rep(i, n) a.push_back(a[i]);
	rep(i, n) 
	{
		for(int j = n; j < a.size(); j++)
		{
			if (a[i] > a[j])
				q++;
		}
	}
	ans = p * k;
	ans %= mod;
	ans += q * k % mod * (k - 1) % mod * calc(2, mod - 2, mod);
	ans %= mod;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256