akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define int long long
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b; cin >> a >> b;
    if(a > 8 || b > 8) OUT(":(");
    else OUT("Yay!");

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
    int n,m;
    cin>>n>>m;
    vector<int> dp(n+1,inf);
    dp[0] = 0;
    vector<int> c(m);
    for(int i=0;i<m;i++){
	cin>>c[i];
    }
    for(int i=0;i<m;i++){
	for(int j=0;j<=n;j++){
	    if(  c[i] <= j ){
		dp[j] = min(dp[j],dp[j-c[i]]+1);
	    }
	}
    }
    cout<<dp[n] <<endl;

	return 0;
}



Measured memory_bytes: 3164
import java.util.*;

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

        long n = sc.nextInt();
        long a = sc.nextInt();
        long b = sc.nextInt();

        if(a > b){
            System.out.println(0);
        }else if(n == 1){
            if(a == b){
                System.out.println(1);
            }else{
                System.out.println(0);
            }
        }else{
            System.out.println((b - a) * (n - 2) + 1);
        }
    }
}


Measured memory_bytes: 21716
#include"bits/stdc++.h"

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int S;
	cin >> S;
	int m = 1000010;
	for (int i = 1; i < m; i++)
	{
		if (S == 1 || S == 2 || S == 4) {
			cout << i + 3 << endl;
			return 0;
		}
		else if (S % 2 == 1) {
			S = 3 * S + 1;
		}
		else if(S % 2 ==0){
			S /= 2;
		}
	}

	return 0;
}

Measured memory_bytes: 256
t = []
T = []
d = []
index_cnt = 0
ma = 0
for i in range(5):
    temp = input()
    t.append(int(temp))
    if t[i] % 10 != 0:
        Ti = t[i] + (10 - t[i] % 10)
    else:
        Ti = t[i]
    T.append(Ti)
    di = 10 - t[i] % 10
    if di == 10:
        d.append(0)
    else:
        d.append(di)
    if d[i] > ma:
        ma = d[i]
        index_cnt = i
total = 0
for i in range(5):
    if i == index_cnt:
        total += t[i]
    else:
        total += T[i]
print(total)


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>

using namespace std;

template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}
template<class T>
ostream &operator<<(ostream &out, const vector<T> &arr){
	for(auto &x: arr) out << x << ' '; cout << "\n";
	return out;
}

enum {NW, N, W};

void printlcs(const string &s, vector<vector<int>> &dp, int i, int j) {
    if (i == 0 || j == 0) {
        return;
    }
    if (dp[i][j] == NW) {
        printlcs(s, dp, i-1, j-1);
        cout << s[i-1];
    } else if (dp[i][j] == N) {
        printlcs(s, dp, i-1, j);
    } else if (dp[i][j] == W) {
        printlcs(s, dp, i, j-1);
    }
}

void lcs(string s, string t) {


    int size_s = s.size();
    int size_t = t.size();

    vector<vector<int>> dp(size_s + 1, vector<int>(size_t + 1));
    vector<vector<int>> pdp(size_s + 1, vector<int>(size_t + 1));

    for (int i = 0; i <= size_s; i++) {
        for (int j = 0; j <= size_t; j++) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            } else if (s[i-1] == t[j-1]) {
                dp[i][j] = dp[i-1][j-1] + 1;
                pdp[i][j] = NW;
            } else if (dp[i-1][j] > dp[i][j-1]) {
                dp[i][j] = dp[i-1][j];
                pdp[i][j] = N;
            } else {
                dp[i][j] = dp[i][j-1];
                pdp[i][j] = W;
            }
        }
    }

    printlcs(s, pdp, size_s, size_t);
    

}

int main() {

    string s, t;

    cin >> s >> t;

    lcs(s, t);
    
    return 0;
}

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

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(m);
    vector<char> c(m);
    rep(i,m) cin >> s[i] >> c[i];
    rep(i,1000) {
        string str = to_string(i);
        if ((int)str.size() != n) continue;
        bool same = true;
        rep(j,m) {
            if (str[s[j]-1] != c[j]) {
                same = false;
                break;
            }
        }
        if(same) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
*H, = map(int, input().split())

ans = [1] * N

for i in range(M):
    A, B = map(int, input().split())
    if H[A - 1] <= H[B - 1]:
        ans[A - 1] = 0
    if H[A - 1] >= H[B - 1]:
        ans[B - 1] = 0
print(sum(ans))

Measured memory_bytes: 20004
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int ans[200005];
int x;
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(int i=n;i>=1;i--)
    {
        int cnt=0;
        for(int j=2;j*i<=n;j++)
        {
            if(ans[i*j]==1) cnt++;
        }
        if(cnt%2!=a[i])
        {
            ans[i]=1;
            x++;
        }
    }
    printf("%d\n",x);
    for(int i=1;i<=n;i++)
    {
        if(ans[i]==1)
        {
            printf("%d ",i);
        }
    }
    printf("\n");
}


Measured memory_bytes: 2432
#include <stdio.h>

int main(void){
  int s, w, sum, i, j, d, e;
  scanf("%d %d", &s, &w);
  char c[s+1][w+1];

  for(i = 0; i < s; i++){
    scanf("%s", c[i]);
  }

  for(i = 0; i < s; i++){
    for(j=0; j < w; j++){
      sum = 0;
      if(c[i][j] == '#') putchar('#');
      else{
	for(d = -1; d <= 1; d++){
	  for(e = -1; e <= 1; e++){
	    if(c[i+e][j+d] == '#'){
	      sum++;
	    }
	  }
	}	
	printf("%d", sum);
      }
    }
    putchar('\n');
  }
  return 0;
}



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

int main(){
    int n, m;
    ll k;
    cin >> n >> m >> k;
    
    vector<ll> a(n+1, 0);
    vector<ll> b(m+1, 0);
    
    rep2(i,1, n+1){
        cin >> a[i];
        if(i!=0)a[i]+=a[i-1];
        
    }
    
    int lim_b = m;
    rep2(i,1, m+1){
        cin >> b[i];
        if(i!=0)b[i]+=b[i-1];
        if(b[i]>k)lim_b = (i<lim_b)? i : lim_b;
    }
    
    ll ans = 0;
    rep(i, n+1){
        if(a[i]>k)break;
        for(int j=lim_b; j>=0; j--){
            if(a[i]+b[j]<=k){
                ans = (i+j)>ans? (i+j) : ans;
                lim_b = j;
                break;
            }
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 6420
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define bitcount(x)  __builtin_popcount(x)
#define bitcountll(x)  __builtin_popcountll(x)
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 1000005
int main()
{
    int t,a,b;
    //in(t);
    t=1;
    while(t--)
    {
        in2(a,b);
        out(max(max(2*a-1,2*b-1),a+b));
    }
}





Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

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

#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
#define MAX_N (100001)
typedef long long ll;

using namespace std;





signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<int> v(n);
	int sum = 0;
	rep(i, n) {
		cin >> v[i];
		sum += v[i];
	}
	int k = sum / (4 * m);
	if (sum % (4 * m) == 0)k--;
	int cnt = 0;
	rep(i, n) {
		if (v[i] > k) {
			cnt++;
		}
	}
	if (cnt >= m) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>

#define rep(i,p) for(long long int i=0;i<p;i++)
#define reep(i,p) for(long long int i=1;i<=p;i++)
#define ll long long

using namespace std;

int main(){

string a;
cin >> a;

if(a[0] >= 'A' && a[0] <= 'Z'){
	cout << "A";
}
else{
	cout << "a";
}











	return 0;

}



Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











int main(){
    string g;
    int y, m, d;
    while(cin >> g, g != "#"){
        cin >> y >> m >> d;
        if(y < 31){
            cout << "HEISEI " << y << " " << m << " " << d << endl;
        }
        else if(y > 31){
            cout << "? " << y - 30 << " " << m << " " << d << endl; 
        }
        else{
            if(m < 5){
                cout << "HEISEI " << y << " " << m << " " << d << endl;
            }
            else{
                cout << "? " << y - 30 << " " << m << " " << d << endl;
            }
        }
    }
}


Measured memory_bytes: 3140
#include <chrono>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <time.h>
#include <random>
#include <string>
#include <cassert>
#include <vector>
#include <ostream>
#include <istream>
#include <stack>
#include <deque>
#include <queue>
#include <functional>

using namespace std;

#define int long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define pii pair<int, int>
#define ld long double

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << " ";
    return a;
}

#ifdef LOCAL
    #define dbg(x) cout << #x << " : " << (x) << "\n";
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 10;
//    const ld PI = 3.1415926535;
#else
    #define dbg(x)
    const int INF = 1e18;
//    const int mod = 2600000069;
//    const int p = 179;
//    const ld PI = 3.1415926535;
#endif

//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,sse3,sse4")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("fast-math")
//#pragma GCC target("avx2")
//#pragma GCC optimize("section-anchors")
//#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
//#pragma GCC optimize("vpt")
//#pragma GCC optimize("rename-registers")
//#pragma GCC optimize("move-loop-invariants")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC optimize("function-sections")
//#pragma GCC optimize("data-sections")

const int MAXN = 2e5 + 1;
const int mod = 1e9 + 7;

int f[MAXN];

int powmod(int a, int p) {
    if (p == 0) return 1;
    if (p == 1) return a;
    int k = powmod(a, p / 2);
    if (p & 1) return (((k * k) % mod) * a) % mod;
    return (k * k) % mod;
}

int rev(int k) {
    return powmod(k, mod - 2);
}

int C(int n, int k) {
    int ans = f[n];
    ans *= rev(f[k]);
    ans %= mod;
    ans *= rev(f[n - k]);
    ans %= mod;
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    #else
//        freopen("capitals.in", "r", stdin);
//        freopen("capitals.out", "w", stdout);
    #endif
    f[0] = 1;
    for (int i = 1; i < MAXN; i++) f[i] = (f[i - 1] * i) % mod;
    int n, k;
    cin >> n >> k;
    if (k == 1) {
        int ans = (n - 1) * n;
        cout << ans;
        return 0;
    }
    int ans = 1, cur;
    for (int i = 1; i <= min(n - 1, k); i++) {
        cur = C(n, i) * C(n - 1, i);
        cur %= mod;
        ans += cur;
        ans %= mod;
    }
    cout << ans;
}
/*

*/


Measured memory_bytes: 1792
str = input()
n = len(str)

def check(str):
    for i in range(len(str)//2):
        if str[i] != str[-i-1]:
            return False
    return True

a = str[0 : (n - 1) // 2]
b = str[(n + 3) // 2 - 1: n]
if check(str) == False or check(a) == False or check(b) == False: print("No")
else: print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define Int int32_t
#define all(c) c.begin(), c.end()
#define FAST ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define pii pair< int , int >
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define bitcnt(n) __builtin_popcountll(n)
#define setpre(n) cout << fixed << setprecision(n)
#define tr(c) for(auto x : c )cout << x << " ";
#define ol(c , s , e ) for(int pos=s; pos<e ; pos++) cout << c[pos] << " ";
#define PI acos(-1l)
const int M = 1000000007;
const int N=3e6+5;
const int INF = 1e9+5;

#ifdef rohit
template<typename... T >
void bug(T... __VA_ARGS__) {
    ((cerr << __VA_ARGS__ << " ") , ...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", bug(__VA_ARGS__) , cerr << endl;
#endif

void solve(){
    int n;
    cin >> n;
    int a[n] , xr =0;
    for(int i=0 ; i<n ;i++){
        cin >>  a[i];
        xr ^=a[i];
    }
    for(int i=0 ;i< n ; i++){
        int ans =0;
        ans=xr^a[i];
        cout << ans << " " ;
    }

}

signed main(){
    FAST;
    //TODO: check test cases.
    int tc=1;
//    cin >> tc;
    for(int t = 1 ; t <= tc ; t++){
        solve();
    }
}

/* Extra Cares
* 1)In graphs or dp problems sometimes long long creates MLE.
* 2)Check whether int to long long typecasting is commented or not?
* 3)Check overflows.
*/


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

int main() {
  int N;
  cin >> N;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  int count = 1;
  for (int i = 1; i < N; i++) {
    bool k = true;
    for(int j = 0; j < i; j++) {
      if (h.at(i) < h.at(j)) {
        k = false;
        break;
      }
    }
    if (k) {
      count++;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
using System;


public class my
{

	public static void Main()
	{
		int max = 1000000;
		var p = new bool[max];
		
		for(int i = 2; i < max; i++) {
			p[i] = true;
		}
		
		for(int i = 2; i < max; i++) {
			if(p[i]) {
				for(int j = 2 * i; j < max; j += i) {
					p[j] = false;
				}
			}
		}
		
		string s;
		
		while( null != ( s = Console.ReadLine()) ) {
			var n = int.Parse(s);
			int cnt = 0;
			
			for(int i = 2; i <=n; i++) {
				if(p[i]) cnt++;
			}
			
			Console.WriteLine(cnt);
		}
		
		
	}

	private static int GetInt()
	{
		return int.Parse(Console.ReadLine());
	}
}

Measured memory_bytes: 10036
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>

using namespace std;


#define INF pow(10, 9)
// typedef priority_queue<tuple<int,int,int>, vector< tuple<int, int, int> >, greater< tuple<int, int, int> > > PQ;






int main(void)
{


    int D, T, S;
    cin >> D; // x, y
    if( D == 0)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }





    return 0;
}


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

int main() {
	int A, B, C, D, L, R;
	cin >> A >> B >> C >> D;
	L = A + B;
	R = C + D;
	if (L > R) {
		cout << "Left" << endl;
	} else if (L == R) {
		cout << "Balanced" << endl;
	} else {
		cout << "Right" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
#include<set>
#define cinf(n,x,y) for(int i=0;i<(n);i++) cin >> x[i] >>y[i];
typedef long long int ll;
using namespace std;

class UnionFind{
public:
	vector<int> par,num;

	int find(int v){
		return (par[v]==v)? v: (par[v]=find(par[v]));
	}
	explicit UnionFind(int N):par(N),num(N,1){
		for(int i=0;i<N;i++)par[i]=i;
	}
	void unite(int u,int v){
		u=find(u),v=find(v);
		if(u==v)return ;
		//if(num[u]<num[v])swap(u,v);
		num[u] += num[v];
		par[v] = u;
	}
	bool same(int u,int v){
		return find(u) == find(v);
	}
	bool ispar(int v){
		return v=find(v);
	}
	int size(int v){
		return num[find(v)];
	}
};

int main(){
	long long int n,m; cin >>n>>m;
	UnionFind Uf(n);
	vector<int> a(m),b(m);
	cinf(m,a,b);
	vector<ll> ans;
	ll cnt=n*(n-1)/2;
	ans.push_back(cnt);
	for(int i=m-1;i>=0;i--){
		if(!Uf.same(a[i]-1,b[i]-1)){
            cnt-=Uf.size(a[i]-1)*Uf.size(b[i]-1);
			Uf.unite(a[i]-1,b[i]-1);
		}
		ans.push_back(cnt);
	}
	reverse(ans.begin(),ans.end());
	for(int i=1;i<=m;i++){
		cout << ans[i] << endl;
	}
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(2 * n);
  for (int i = 0; i < 2 * n; i ++) {
    cin >> a.at(i);
  }

  sort(a.begin(), a.end());
  int sum = 0;
  for (int i = 0; i < 2 * n; i += 2) {
    sum += a.at(i);
  }

  cout << sum << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
mod=10**9+7
def comb(n,k,mod):
    x = y = 1
    for i in range(min(k,n-k)):
        x = x*(n-i)%mod
        y = y*(i+1)%mod
    return x * pow(y, mod-2, mod) % mod
  
for i in range(1,k+1):
  if n-k+1>=i:
    
    print((comb(n-k+1,i,mod)*comb(k-1,i-1,mod))%mod)
  else:
    print(0)
    

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main() {
  int K;
  int ansa = 0;
  int ansb = 0;
  int ans=0;
  cin >> K;

  for(int i=1; i<K+1; i++){
    for(int j=1; j<K+1; j++){
      for(int k=1; k<K+1; k++){
        ansa=gcd(i,j);
        ansb=gcd(ansa, k);
        ans= ans+ansb;
      }
    }
  }

  cout << ans << endl;

return 0;
}


Measured memory_bytes: 3640
#include <iostream>

using namespace std;

int main() {
  int N;
  char s[256];
  int K;
  
  cin >> N;
  cin >> s;
  cin >> K;
  char c = s[K - 1];
  for (int i = 0; i < N; ++i) cout << (s[i] == c ? c : '*');
  cout << endl;
}

Measured memory_bytes: 256
//AC_chahiye_bas!!!!
#include<iostream>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M 1000000007
#define rep(i,n) for(int i=0;i<n;i++)

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   string s[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
   string p;
   cin>>p;
   for(int i=0;i<7;i++)
   {
       if(p==s[i])
        cout<<7-i<<endl;
   }



}



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

using namespace std;

typedef long long ll;

const int mod = 1e9+7; 

int main(){
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	sort(a,a+n);
	int j = n-1,ans = 0;
	while(k--){
		ans += a[j--];
	}
	cout << ans << "\n";

	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
		using namespace std;
		#define sz(x) (int)(x).size()
		#define int long long int
		#define loop(i,a,b) for(int i=a;i<b;i++)
		#define scan(arr,n) for (int i = 0; i < n; ++i) cin >> arr[i]
		#define vi vector<int>
		#define si set<int>
		#define pii pair <int, int>
		#define sii set<pii>
		#define vii vector<pii>
		#define mii map <int, int>
		#define pb push_back
		#define all(aa) aa.begin(), aa.end()
		#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
		//Constants
		const int mod = 1000000007; /* 1e9 + 7*/
		const int MAXN = 1000005; /*1e6 +5 */
		 
		int spf[1000009]; // stores the smallest prime factor of a number
		 vector<vi> graph;
		// vi count1;
		 
		 int gcdExtended(int a, int b, int *x, int *y); 
		 
		 int count1(int x,int y,int z);
		 //int n;
		void sieve()
		{
			spf[1] = 1;
			for (int i=2; i<MAXN; i++)
				spf[i] = i;
			for (int i=4; i<MAXN; i+=2)
				spf[i] = 2;
		 
			for (int i=3; i*i<MAXN; i++)
				if (spf[i] == i)
				{
					for (int j=i*i; j<MAXN; j+=i)
						if (spf[j]==j)
							spf[j] = i;
				}
		}
		
		void print(vi v)
		{
			for(auto x:v)
			cout<<x<<" ";
			cout<<endl;
		}
		 
		/* Iterative Function to calculate (x^y)%p 	 in O(log y) */
		int power(int x,  int y, int p)
		{
			int res = 1;     // Initialize result
			x = x % p; // Update x if it is more than or
						// equal to p 
			if (x == 0) return 0; // In case x is divisible by p;     
			while (y > 0)
			{
				// If y is odd, multiply x with result
				if (y & 1)
					res = (res*x) % p;     
				// y must be even now
				y = y>>1; // y = y/2
				x = (x*x) % p;
			}
			return res;
		}
		
		 
		void solve()
		{
			int d,t,s;
			cin>>d>>t>>s;
			cout<<fixed<<setprecision(2);
			float req=(float) d/s;
			//cout<<req<<endl;
			if(req<=t) cout<<"Yes";
			else cout<<"No";
			
		}

		 
		int32_t main()
		{
			faster;
			int t=1;
			//cin>>t;
			while(t--) solve();		 
			return 0;
		}


Measured memory_bytes: 3648
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >> getList >>= print . minimum . map solve

solve x
	| x `mod` 2 == 0 = 1 + solve ( x `div` 2 )
	| otherwise = 0


Measured memory_bytes: 636
//
// Created by mamurai on 16/09/08.
//

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

char s[1001];

int main() {
    scanf("%s", s);
    int len = strlen(s);
    bool N = false;
    bool S = false;
    bool W = false;
    bool E = false;

    for (int i = 0; i < len; ++i) {
        if (s[i] == 'N') {
            N = true;
        } else if (s[i] == 'S') {
            S = true;
        } else if (s[i] == 'W') {
            W = true;
        } else {
            E = true;
        }
    }

    if ((N == S) && (W == E)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def lr(xx):
    ll=[-1]*(n+1)
    rr=[-1]*(n+1)
    for i,x in enumerate(xx):
        if ll[x]==-1:ll[x]=i
        if i==n-1 or x!=xx[i+1]:rr[x]=i+1
    return ll,rr

n=II()
aa=LI()
bb=LI()
all,arr=lr(aa)
bll,brr=lr(bb)
# print(all,arr)
ca=[0]*(n+1)
cb=[0]*(n+1)
for a in aa:ca[a]+=1
for b in bb:cb[b]+=1
for i in range(n+1):
    if ca[i]+cb[i]>n:
        print("No")
        exit()
ng=[0]*(n+1)
for al,ar,bl,br in zip(all,arr,bll,brr):
    if al==-1 or bl==-1:continue
    if bl<ar:
        mn=max(0,al-br+1)
        mx=ar-bl
        ng[mn]+=1
        ng[mx]-=1
    else:
        mn=max(0,al+n-br+1)
        mx=min(n,ar+n-bl)
        ng[mn]+=1
        ng[mx]-=1
# print(ng)
for i in range(n):ng[i+1]+=ng[i]
shift=-1
for i in range(n):
    if ng[i]==0:
        shift=i
        break
ans=bb[-shift:]+bb[:-shift]
print("Yes")
print(*ans)


Measured memory_bytes: 68088
#include <bits/stdc++.h>
using namespace std;
#define INF_LL 1LL << 40
#define INF 1 << 31
#define MOD 1000000007
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
#define prique priority_queue
#define PI acos(-1)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vector<int>> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
struct edge {
    int to, cost;
};

ll bit[200020];
void add(int idx, ll v, ll n) {
    for(int x = idx; x <= n; x += x & -x)
        bit[x] += v;
}
ll sum(int idx, ll n) {
    int res = 0;
    for(int x = idx; x > 0; x -= x & -x)
        res += bit[x];
    return res;
}

int main() {
    ll n;
    cin >> n;
    vl a(n), b(2 * n + 2), c(n + 1);
    rep(i, n) cin >> a[i];
    ll l = 0, r = 1000000000;
    ll m;
    while(l + 1 < r) {
        ll tmp = 0;
        m = (l + r) / 2;
        rep(i, 2 * n + 2) bit[i] = 0;
        c[0] = n + 1;
        rep(i, n) c[i + 1] = c[i] + (a[i] <= m ? -1 : 1);
        rep(i, n + 1) {
            tmp += sum(c[i], 2 * n + 1);
            add(c[i], 1, 2 * n + 1);
        }
        tmp = n * (n + 1) / 2 - tmp;
        if(tmp >= n * (n + 1) / 4 + 1) {
            r = m;
        } else {
            l = m;
        }
    }
    cout << r << endl;
}


Measured memory_bytes: 4992
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var h, w int
	scanner.Scan()
	fmt.Sscan(scanner.Text(), &h, &w)

	s := make([][]string, h)
	for i := 0; i < h; i++ {
		s[i] = make([]string, w)
		scanner.Scan()
		for j, v := range strings.Split(scanner.Text(), "") {
			s[i][j] = v
		}
	}

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if s[i][j] == "." {
				continue
			}
			b := false
			if i > 0 && s[i-1][j] == "#" {
				b = true
			}
			if i < h-1 && s[i+1][j] == "#" {
				b = true
			}
			if j > 0 && s[i][j-1] == "#" {
				b = true
			}
			if j < w-1 && s[i][j+1] == "#" {
				b = true
			}

			if !b {
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 1940
#include<iostream>
using namespace std;
int main() {
	int m, d; cin >> m >> d;
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 22; j <= d; j++) {
			int d10 = (j / 10) % 10;
			int d1 = j % 10;
			if (d10>=2&&d1>=2&&d10 * d1 == i) {
				ans++;
				
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define next NEXT

const int N = 100010;
const int M = 2 * N;
const int INF = 1e9;

int e[M], next[M];
int last[N], c[N], dep[N], f[N], g[N], v[N];
int n, k, total;
int invalid;

void Add(int x, int y) {
	e[++total] = y;
	next[total] = last[x];
	last[x] = total;
}

void DFS(int x, int p) {
	dep[x] = dep[p] + 1;
	for (int i = last[x]; i; i = next[i]) {
		if (e[i] == p) continue;
		DFS(e[i], x);
	}
}

void DP(int x, int p) {
	f[x] = -INF;
	g[x] = INF;
	for (int i = last[x]; i; i = next[i]) {
		if (e[i] == p) continue;
		DP(e[i], x);
		f[x] = max(f[x], f[e[i]] - 1);
		g[x] = min(g[x], g[e[i]] + 1);
	}
	if (v[x]) {
		if (c[x] < f[x] || c[x] > g[x]) {
			invalid = 1;
		}
		f[x] = g[x] = c[x];
	}
	if (f[x] > g[x]) invalid = 1;
}

void REDFS(int x, int p) {
	if (!v[x]) {
		if (!p) c[x] = f[x];
		if (p) {
			if (c[p] + 1 >= f[x] && c[p] + 1 <= g[x]) {
				c[x] = c[p] + 1;
			}
			if (c[p] - 1 >= f[x] && c[p] - 1 <= g[x]) {
				c[x] = c[p] - 1;
			}
		}
	}
	for (int i = last[x]; i; i = next[i]) {
		if (e[i] == p) continue;
		REDFS(e[i], x);
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		Add(x, y);
		Add(y, x);
	}
	DFS(1, 0);
	int ans = -1;
	scanf("%d", &k);
	for (int i = 0; i < k; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		c[x] = y;
		v[x] = 1;
		if (ans == -1) {
			ans = (y & 1) ^ (dep[x] & 1);
		} else if (ans != ((y & 1) ^ (dep[x] & 1))) {
			printf("No\n");
			return 0;
		}
	}
	invalid = 0;
	DP(1, 0);
	if (invalid) {
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	REDFS(1, 0);
	for (int i = 1; i <= n; i++) {
		printf("%d\n", c[i]);
	}
	return 0;
}

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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;

const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;

/*
  filippos
  Contest : AtCoder DP contest
  Task : D - Vacation
*/

int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  int n, w; cin >> n >> w;

  vector<pii> v(n);
  for(pii &p : v)
    cin >> p.first >> p.second;

  vector<ll> dp(w + 1);
  for(pii &p : v)
    for(int i = w; i >= p.first; i--)
      dp[i] = max(dp[i], dp[i - p.first] + p.second);

  cout << dp[w];

  return cout << endl, 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<string>
#include<set>
#include<cstdlib>

using namespace std;
typedef long long ll;

int main() {
  char a;
  cin >> a;
  if(isupper(a)) cout<<"A"<<endl;
  else cout<<"a"<<endl;

}

Measured memory_bytes: 3620
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val ans = (1 to n).map(_ => sc.nextLong)
    .foldLeft(0L, 0L) {
      case ((cnt, o), a) => (cnt + (a + o) / 2, if (a == 0) 0 else (a + o) % 2)
    }

  println(ans._1)
}


Measured memory_bytes: 64656
N, M = list(map(int, input().split()))
S = list(input())

D = []
t = N
while t > 0:
  if t - M <= 0:
    D.append(t)
    break
  for i in range(M, 0, -1):
    if S[t - i] == "0":
      D.append(i)
      t -= i
      break
  else:
    print(-1)
    exit()

for i in range(len(D) -1, -1, -1):
  print(D[i],end = " ")

Measured memory_bytes: 5416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
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;
}
int main(){
    ll n,m,q;cin>>n>>m>>q;
    vl a(q),b(q),c(q),d(q);rep(i,q)cin>>a[i]>>b[i]>>c[i]>>d[i];
    ll ans=0;
    for(int bit=0;bit<(1<<(m+n));bit++){
        vl num;
        ll now=0;
        ll sum=0;
        rep(i,m+n){
            if((bit>>i)&1)num.pb(now);
            else now++;
        }
        if(sz(num)!=n||num[0]==0)continue;
        rep(i,q){
            if(num[b[i]-1]-num[a[i]-1]==c[i])sum+=d[i];
        }
        chmax(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <iterator>
#include <numeric>
#include <vector>

using namespace std;

int64_t calc(int64_t X) {
  if (X == 1) {
    return 1;
  } else {
    return 1 + 2 * calc(X / 2);
  }
}

int main() {
  int64_t H;
  cin >> H;
  cout << calc(H) << endl;
  return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;
    return 0;
}



Measured memory_bytes: 3556
//#include <bits/stdc++.h>
 
#include <iostream>
#include <algorithm>
 
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>
 
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
 
 
using namespace std;
//#define int long long
 
typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
 
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
 
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

string s;
int x, y;
vector<int> fx, fy;
bool dpx[8005][16005], dpy[8005][16005]; 

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> s;
	cin >> x >> y;
	int n = s.size();
	int cur = 0;
	int tmp = 0;
	rep(i, n) {
		if (s[i] == 'T') {
			if (cur == 0) fx.push_back(tmp);
			else fy.push_back(tmp);
			tmp = 0;
			cur^=1;
			continue;
		}
		tmp++;
	}
	if (cur == 0) fx.push_back(tmp);
	else fy.push_back(tmp);
	int sx = fx.size();
	int sy = fy.size();
	/*
	rep(i, sx) cout << fx[i] << " ";
	cout << endl;
	rep(i, sy) cout << fy[i] << " ";
	cout << endl;
	*/
	dpx[0][8000] = true;
	dpy[0][8000] = true;
	rep(i, sx)rep(j, 16005) {
		if (i == 0 && s[0] != 'T') {
			if (j - fx[i] >= 0) dpx[i + 1][j] |= dpx[i][j - fx[i]];
			continue;
		}
		if (j - fx[i] >= 0) dpx[i + 1][j] |= dpx[i][j - fx[i]];
		if (j + fx[i] <= 16000) dpx[i + 1][j] |= dpx[i][j + fx[i]];
	}
	rep(i, sy)rep(j, 16005) {
		if (j - fy[i] >= 0) dpy[i + 1][j] |= dpy[i][j - fy[i]];
		if (j + fy[i] <= 16000) dpy[i + 1][j] |= dpy[i][j + fy[i]];
	}
	if (dpx[sx][x + 8000] && dpy[sy][y + 8000]) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 127232
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;




//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        k: usize,
        da: [[Usize1];k],
    }
    let mut v = vec![1;n];
    for i in 0..k {
        for j in &da[i] {
            v[*j] = 0;
        }
    }

    let ans:usize = v.iter().sum();
    println!("{}", ans);
}



Measured memory_bytes: 2188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N,M,C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  for (int i=0; i<M; i++) cin >> B[i];
  
  vector<vector<int>> A(N,vector<int>(M));
  for (int i=0; i<N; i++) {
    for (int j=0; j<M; j++) {
      cin >> A[i][j];
    }
  }
  int count = 0;
  for (int i=0; i<N; i++) {
    int ans = 0;
    
    for (int j=0; j<M; j++) {
      ans += A[i][j] * B[j];
    }
    if (ans + C > 0) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int N;
int P[8],Q[8];
int pans = 0,qans = 0;

int dif(int a,int b)
{
  if(a > b){
    return (a - b);
  }
  else{
    return (b - a);
  }
}

int fac(int a)
{
  if(a == 1){
    return 1;
  }
  else if(a > 1){
    return a*fac(a - 1);
  }

  return -1;
  
}


int nanban(int *A){
  int i,j;
  int ans = 0;
  
  for(i = 0;i < N;i++){
    for(j = i + 1;j < N;j++){
      if(A[i] < A[j]){
	A[j]--;
      }
    }
    ans += (A[i] - 1)*fac(N - i - 1);
  }
   
  return (ans + 1);
}
      
 
      
int main()
{
  int i,j;
  int d;
  int p = 0,q = 0,ans;
  /*入力*/
  scanf("%d",&N);

  for(i = 0;i < N;i++){
    scanf("%d",&P[i]);
  }
  for(i = 0;i < N;i++){
    scanf("%d",&Q[i]);
  }

  /*調べる*/

  p = nanban(P);
  q = nanban(Q);

  ans = dif(p,q);

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

  return 0;
}

  


Measured memory_bytes: 128
N, M = map(int, input().split())

stair = [0 for i in range(N+1)]
notbroken = [1 for i in range(N+1)]
for i in range(M):
    a = int(input())
    notbroken[a] = 0
for i in range(N+1):
    if i == 0:
        stair[i] = 1
        continue
    if i == 1:
        stair[i] = 1
        continue
    stair[i] = (stair[i-1] * notbroken[i-1] + stair[i-2] * notbroken[i-2]) * notbroken[i]
    stair[i] %= 10**9+7

print(stair[N])

Measured memory_bytes: 7776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = Console.ReadLine().Trim().Split(' ');

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = ">";
            if (sS[0] == sS[1]) { sOut = "="; }
            else if (sS[0][0] < sS[1][0]) { sOut = "<"; }

            // 出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N,A;
    cin >> N;
    cin >> A;
    while(1){
        if(N < 500){
            break;
        }
        N = N - 500;
    }
    
    if(N <= A){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 256
// AOJ 2386
#include<iostream>
#include<vector>
#define REP(i,n) for(long long int i=0;i<(long long int)(n);i++)
using namespace std;

const long long int NMAX = 200;
const long long int INF = 1e7;
long long int n;
long long int d[NMAX][NMAX];

long long int solve() {
  long long int ans = 0;
  REP(i, n) REP(j, i) {
    ans += min(d[i][j], d[j][i]);
  }
  return ans;
}

int main() {
  cin >> n;
  REP(y,n) REP(x,n) {
    cin >> d[x][y];
  }

  cout << solve() << endl;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int H,W;
    cin >> H >> W;
    vector<vector<i64>> a(H,vector<i64>(W));
    rep(i,0,H) rep(j,0,W){
        cin >> a[i][j];
        a[i][j]%=2;
    }

    int prevy=-1,prevx=-1;
    vector<tuple<int,int,int,int>> ans;
    rep(i,0,H){
        for(int j=i%2==0?0:W-1,d=i%2==0?1:-1; 0<=j and j<W; j+=d){
            if(a[i][j]==0) continue;
            if(prevy==-1 and prevx==-1){
                prevy=i;
                prevx=j;
                continue;
            }
            
            int i2=i,j2=j;
            while(i2!=prevy or j2!=prevx){
                int d2=i2%2==0?-1:1,i2_=i2,j2_=j2+d2;
                if(j2_<0 or j2_>=W){
                    --i2_;
                    j2_=i2_%2==0?W-1:0;
                }
                ans.push_back(make_tuple(i2,j2,i2_,j2_));
                i2=i2_;
                j2=j2_;
            }
            prevy=-1;
            prevx=-1;
        }
    }

    cout << ans.size() << endl;
    for(auto t:ans){
        int y,x,y_,x_;
        tie(y,x,y_,x_)=t;
        cout << y+1 << " " << x+1 << " " << y_+1 << " " << x_+1 << endl;
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 6128
#include <stdio.h>
int main(void){
    int N, T, i, cst = 9999, cnt = 0;
    int c[1000];
    int t[1000];
    
    scanf("%d %d", &N, &T);
    
    for(i = 0; i < N; i++){
        scanf("%d %d", &c[i], &t[i]);
    }
    
    for(i = 0; i < N; i++){
        if(T >= t[i] && c[i] <= cst){
            cst = c[i];
        }else{
            cnt = cnt + 1;
        }
    }
    
    if(cnt == N){
        printf("TLE\n");
    }else if(cnt < N){
        printf("%d\n", cst);
    }
}

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

using namespace std;

int cnt[4];
char s[15];

int main() {
	int n;
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		
		if (s[0] == 'A') cnt[0]++;
		else if (s[0] == 'W') cnt[1]++;
		else if (s[0] == 'T') cnt[2]++;
		else cnt[3]++;
	}
	
	printf("AC x %d\n", cnt[0]);
	printf("WA x %d\n", cnt[1]);
	printf("TLE x %d\n", cnt[2]);
	printf("RE x %d\n", cnt[3]);
}


Measured memory_bytes: 3760
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int N;

    scanf("%d", &N);

    long long c[5];

    for(int i = 0; i < 5; i++){
        c[i] = 0;
    }

    char S[N][11];

    for(int i = 0; i < N; i++){
        scanf("%s", S[i]);
        if(S[i][0] == 'M'){
            c[0]++;
        }
        if(S[i][0] == 'A'){
            c[1]++;
        }
        if(S[i][0] == 'R'){
            c[2]++;
        }
        if(S[i][0] == 'C'){
            c[3]++;
        }
        if(S[i][0] == 'H'){
            c[4]++;
        }
    }

    long long x = 0;

    x += c[0] * c[1] * c[2];
    x += c[0] * c[1] * c[3];
    x += c[0] * c[1] * c[4];
    x += c[0] * c[2] * c[3];
    x += c[0] * c[2] * c[4];
    x += c[1] * c[2] * c[3];
    x += c[1] * c[2] * c[4];
    x += c[1] * c[3] * c[4];
    x += c[2] * c[3] * c[4];
    x += c[0] * c[3] * c[4];

    printf("%lld\n", x);

    return 0;
}

Measured memory_bytes: 2756
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long int lo;
typedef pair< int,int > PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 100005;
const lo mod = 1000000007;

lo n,m,b,a[li],k,flag;
lo cev;
string s;
vector<int> v;

int main(void){
	scanf("%lld %lld %lld",&n,&m,&k);
	lo mn=min(m,k);
	m-=mn;
	k-=mn;
	cev+=2*mn;
	if(k>0){
		mn=min(n,k);
		n-=mn;
		k-=mn;
		cev+=mn;
		if(k) cev++;
	}
	else cev+=m;
	printf("%lld\n",cev);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <array>
#include <memory>
#include <set>
#include <map>

using namespace std;

#define Get(ty,...) ty __VA_ARGS__;cins(__VA_ARGS__);
#define GetArray(ty,v,n) vector<ty> v(n);cin_arr(v,n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr,pred) f(arr.begin(),arr.end(),pred)
#define Arr2(f, arr) f(arr.begin(),arr.end())
#define ArrExpr(f, arr,expr) f(arr.begin(),arr.end(),[](auto x){return expr;})
#define Acc(init,arr,pred) accumulate(arr.begin(),arr.end(),init,pred)

void cins(){}

template<class Head,class... Tail>
void cins(Head& head,Tail&... tail) {
	cin >> head;
	cins(tail...);
}

template<class Arr>
void cin_arr(Arr& v,int n) {
	for (int i = 0; i < n; i++)
		cin >> v[i];
}



int main() {
	Get(string, s);
	char a, b;
	char ac = 0;
	char bc = 0;
	for (char c : s) {
		if (ac == 0)a = c, ac++;
		else if (a == c)ac++;
		else if (bc == 0)b = c, bc++;
		else if (b == c)bc++;
	}
	co << (ac == 2 && bc == 2 ? "Yes" : "No") << en;

}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー
#define inf (1<<29)             //1<<29でオーバーフロー

int main(int argc,char* argv[]){
    int n,k;
    cin >> n >> k;

    vector<ll> h(n);
    for(auto &x:h)cin >> x;

    sort(h.begin(),h.end());
    
    int hmin=0,hmax=k-1;
    ll mindiff=INF;
    for(int i=k-1;i<h.size();i++){
        ll diff=h[hmax]-h[hmin];
        mindiff=min(mindiff, diff);
        hmin++;
        hmax++;
    }

    cout << mindiff << endl;

    return 0;
}


Measured memory_bytes: 3968