akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef long long int ll;
void hack(ll n)
{
    if(n==124)
    cout<<"hacked";   
}
ll gcd(ll a,ll b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
ll mod=998244353;
ll mod1=1e9+6;
#define int ll
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0) return power(a*a%mod,b/2);
    else return a*power(a*a%mod,b/2)%mod;
}
ll power1(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0) return power(a*a%mod1,b/2);
    else return a*power(a*a%mod1,b/2)%mod1;
}
void show(vector <pair<int,int>> v)
{
    for(int i=0;i<v.size();++i) cout<<v[i].first<<" "<<v[i].second<<" ";
        cout<<endl;
}
#define endl '\n'
vector<int> v[3001];
int parent[3001];
map<pair<int,pair<int,int>>,int>m1;
bool vi[3001];


int32_t main()
{
    IOS
 
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int ans=0;
    for(int i=0;i<n;++i)
    {
        if(s[i]=='L')
        {
            int count=1;
            for(int j=i+1;j<n;++j)
            {
                if(s[j]=='L')
                {
                    count++;
                    if(j==n-1)
                        i=n-1;
                }
                else
                {
                    i=j-1;
                    break;
                }
            }
            ans+=count-1;
        }
    }
    for(int i=0;i<n;++i)
    {
        if(s[i]=='R')
        {
            int count=1;
            for(int j=i+1;j<n;++j)
            {
                if(s[j]=='R')
                {
                    count++;
                    if(j==n-1)
                        i=n-1;
                }
                else
                {
                    i=j-1;
                    break;
                }
            }
            ans+=count-1;
        }
    }
    cout<<min(n-1,ans+2*k);

}


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

int main() {

	using namespace std;

	int N;
	cin >> N;
	vector< vector<int> > D(N, vector<int>(2));

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> D[i][j];
		}
	}

	for (int i = 0; i < N; i++) {
		int count = 0;
		int j = i;
		while (D[j][0] == D[j][1]) {

			count++;
			if (count >= 3) {
				cout << "Yes" << endl;
				return 0;
			}

			if (j < N - 1) {
				j++;
			}
			else {
				break;
			}
		}

	}

	cout << "No" << endl;

	return 0;

}

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

int main() {
  int N;
  cin >> N;
  vector<int> S(N);
  for (int i = 0; i < N; i++) cin >> S.at(i);
  int sum = accumulate(S.begin(), S.end(), 0L);
  vector<int> V;
  for (auto s : S) if (s % 10) V.push_back(s);
  if (V.size()) sort(V.begin(), V.end());
  if (sum % 10) return cout << sum << "\n", 0;
  if (V.size()) cout << sum - V.at(0) << "\n";
  else cout << 0 << "\n";
}

Measured memory_bytes: 3572
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    x = int(input())
    if x==0:
        print(1)
    else:
        print(0)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9156
#include<iostream>

using namespace std;

int main(){

    int n;
    int ans = 0, cnt = 0;

    cin >> n;

    int a[n];

    for(int i = 0; i < n; i ++){
        cin >> a[i];
        if(i == 0){
            ans = a[0];
        }
        cnt = 0;
        while(a[i] % 2 == 0){
            a[i] /= 2;
            cnt++;
        }
        if(ans > cnt){
            ans = cnt;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif


void solve(){
    int a; cin>>a;
    int ans = a + a*a + a*a*a;
    cout<<ans;
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int N; cin >> N;
    vec h(N); readv(h);
    int ans = 0;
    while(true){
        bool f = false;
        REP(i, N){
            if(h[i] > 0){
                FOR(j, i, N){
                    if(h[j] > 0) h[j]--;
                    else break;
                }
                f = true;
                ans++;
                break;
            }
        }

        if(!f) break;
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;

public class Main {

    public static final int MOD = 1000000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int D = Integer.parseInt(sc.next());
        int[] c = new int[26];
        int[] cd = new int[26];
        for (int i = 0; i < 26; i++) {
            c[i] = Integer.parseInt(sc.next());
        }
        int[][] s = new int[D][26];
        for (int i = 0; i < D; i++) {
            for (int j = 0; j < 26; j++) {
                int temp = Integer.parseInt(sc.next());
                s[i][j] = temp;
            }
        }
        int[] t = new int[D];
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < D; i++) {
            int con = best(c, cd, s, i + 1);
            cd[con] = i + 1;
            t[i] = con + 1;
//            int temp = Integer.parseInt(sc.next());
//            t[i] = temp;
//            int temp = max[i];
//            cd[temp - 1] = i + 1;
//            ans += s[i][temp - 1] - totalSubC(c, cd, i + 1);
//            sb.append(ans);
//            sb.append(max[i]);
//            sb.append(con + 1);
//            sb.append("\n");
        }
//        int m = Integer.parseInt(sc.next());
        int ans = total(c, cd, s, t, D);
        for (int i = 0; i < 10000; i++) {
            Random r = new Random();
            int d = r.ints(0, D).findFirst().getAsInt();
            int q = r.ints(1, 27).findFirst().getAsInt();
            int old = t[d];
            t[d] = q;
            int temp = total(c, cd, s, t, D);
            if (ans > temp) {
                t[d] = old;
            }
        }
        for (int i = 0; i < D; i++) {
            sb.append(t[i]);
            sb.append("\n");
        }
        System.out.println(sb.toString());
    }

    private static int totalSubC(int[] c, int[] cd, int d) {
        int ans = 0;
        for (int i = 0; i < 26; i++) {
            ans += c[i] * (Math.max(0, d - cd[i]));
        }
        return ans;
    }

    private static int total(int[] c, int[] cd, int[][] s, int[] t, int D) {
        int ans = 0;
        for (int i = 0; i < D; i++) {
            cd[t[i] - 1] = i + 1;
            ans += s[i][t[i] - 1] - totalSubC(c, cd, i + 1);
        }
        return ans;
    }

    private static int best(int[] c, int[] cd, int[][] s, int d) {
        int ans = 0;
        int max = -1000000;
        for (int i = 0; i < 26; i++) {
            int old = cd[i];
            cd[i] = d;
            for (int j = 0; j < 26; j++) {
                int temp = s[d - 1][j] - totalSubC(c, cd, d);
                if (max < temp) {
                    ans = j;
                    max = temp;
                }
            }
            cd[i] = old;
        }
        return ans;
    }
}

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

long long fac[510000], finv[510000], inv[510000];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % 1000000007;
        inv[i] = 1000000007 - inv[1000000007%i] * (1000000007 / i) % 1000000007;
        finv[i] = finv[i - 1] * inv[i] % 1000000007;
    }
}



long long COM(long long n, long long k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % 1000000007) % 1000000007;
}






long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}



int main(){
  COMinit();
  long long N,A,B;
  cin>>N>>A>>B;
  long long tt = modpow(2,N,1000000007);
  if(tt == 0){
    tt = 1000000006;
  }
  else{
    tt--;
  }
  long long tempa = 1;
  long long tempb = 1;
  for(long long i = N-A+1;i<=N;i++){
    tempa = tempa * i % 1000000007;
  }
  for(long long i = 1;i<=A;i++){
    tempb = tempb * i % 1000000007;
  }
  long long tempc = tempa * modinv(tempb,1000000007) % 1000000007;
  
  tempa = 1;
  tempb = 1;
  for(long long i = N-B+1;i<=N;i++){
    tempa = tempa * i % 1000000007;
  }
  for(long long i = 1;i<=B;i++){
    tempb = tempb * i % 1000000007;
  }
  long long tempcc = tempa * modinv(tempb,1000000007) % 1000000007;
  
  if(tt<(tempc+tempcc)){
    cout << (tt+1000000007+1000000007-tempc-tempcc)%1000000007 << endl;
  }
  else{
    cout << tt-tempc-tempcc << endl;
  }
  return 0;
}

Measured memory_bytes: 12160
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long N,X,T;
  cin>>N>>X>>T;
  if(N%X==0)
  {
    
    X=N/X;
    T=T*X;
    cout<<T<<endl;
  }
  else
  { N=(N/X)+1;
   T=N*T;
   cout<<T<<endl;
}
  return 0;
}


Measured memory_bytes: 3548
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x==2&&y==2) System.out.println("Yes");
		else if ((x==1||x==3||x==5||x==7||x==8||x==10||x==12)&&(y==1||y==3||y==5||y==7||y==8||y==10||y==12)){
			System.out.println("Yes");
		}
		else if ((x==4||x==6||x==9||x==11)&&(y==4||y==6||y==9||y==11)){
			System.out.println("Yes");
		}
		else System.out.println("No");
	}

}


Measured memory_bytes: 23124
l, r = map(int, input().split())

if (r - l) > 2019:
    print(0)

else:
    ans = 2018
    for i in range(l, r+1):
        for j in range(i+1, r+1):
            ret = (i * j) % 2019
            ans = min(ans, ret)

    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    int N, M;
    cin >> N >> M;
    int H[N];
    for (int i = 0; i < N; i++) {
        cin >> H[i];
    }
    vector<pair<int, int>> v(M);
    for (int i = 0; i < M; i++) {
        cin >> v[i].first >> v[i].second;
        v[i].first--;
        v[i].second--;
    }

    vector<bool> good(N, true);
    for (int i = 0; i < M; i++) {
        if (H[v[i].first] <= H[v[i].second]) {
            good[v[i].first] = false;
        }
        if (H[v[i].second] <= H[v[i].first]) {
            good[v[i].second] = false;
        }
    }
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (good[i]) {
            ans++;
        }
    }
    cout << ans << endl;
}

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

#define  optimize   ios::sync_with_stdio(0); cin.tie(0);
#define PI  acos(-1.0)
#define RESET(a, b) memset(a, b, sizeof(a))
#define pb push_back
int main()
{
    optimize
    int a;
    cin>>a;
    ll sum=0;
    sum=a*(1+a+(a*a));
    cout<<sum<<endl;
}


Measured memory_bytes: 3652
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



namespace ConsoleApplication2
{

    class Program
    {
        static void Main(string[] args)
        {

            
            int  max=0;

            string[] mass = Console.ReadLine().Split(' ');

            int[] result = new int[3];

            int[] listinput = new int[mass.Length];

            for (int i = 0; i < mass.Length; i++)
            {
                listinput[i] = int.Parse(mass[i]);
            }

            result[0] = listinput[0] + listinput[1];

            result[1] = listinput[0] - listinput[1];

            result[2] = listinput[0] * listinput[1];

            max = result[0];

            for(int i=0;i<result.Length;i++)
            {
                if(max<result[i])
                {
                    max = result[i];
                }
            }


            Console.WriteLine(max);
        }
    }
}

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

int main(){
    long long N,ans;
    cin >> N;
    //cerr << (double)4/3485 << endl;
    long long ansh=0,ansn=0,answ=0;
    for(long long  h= 1;h<=3500;h++){
        bool flag = false;
        for(long long n = 1;n<=3500;n++){
            if((4*h*n-N*n-h*N) == 0) break;
            long long a = N*h*n;
            long long b = 4*h*n-N*n-h*N;
            long long w = N*h*n/(4*h*n-N*n-h*N);
            //cerr << w << endl;
            if(a%b == 0 && w > 0){
                ansh = h;
                ansn = n;
                answ = w;
                //flag = true;
                //break;
            }
            
        }
        if(flag) break;
    }


    cout << ansh << " " << ansn << " " << answ<<endl;
}

Measured memory_bytes: 384
from collections import defaultdict


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        self.size = [1] * n

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.size[y] += self.size[x]
            self.size[x] = 0
        else:
            self.par[y] = x
            self.size[x] += self.size[y]
            self.size[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # すべての頂点に対して親を検索する
    def all_find(self):
        for n in range(len(self.par)):
            self.find(n)


D = defaultdict(int)
n,k,l =  map(int, input().split())
uf = UnionFind(n)
tf = UnionFind(n)

dp =[1]*n
for i in range(k):
    x,y =map(int, input().split())
    uf.union(x-1, y-1)  # (3)
for i in range(l):
    x,y =map(int, input().split())
    tf.union(x-1, y-1)  # (3)
tf.all_find()
uf.all_find()
D = defaultdict(int)
for r, t in zip(uf.par, tf.par):
    D[(r, t)] += 1
 
ans = [D[(r, t)] for r, t in zip(uf.par, tf.par)]
print(*ans, sep=' ')

Measured memory_bytes: 55260
n = int(input())
ans = 0
 
def max(a,b):
    if a>b:
        return a
    else:
        return b
 
def min(a,b):
    if a<b:
        return a
    else:
        return b
 
def gcd(a,b):
    p = max(a,b)
    q = min(a,b)
    d = q
    while p % q != 0:
        d = p % q
        p = q
        q = d
    return d
 
 
for i in range(1,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            ans += gcd(gcd(i,j),k)
 
print(ans)

Measured memory_bytes: 75996
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define PRIME_MAX 10000
vector<bool> prime(PRIME_MAX+1,true);
 
void init_prime(){
	prime[0] = prime[1] = false;
	for(int i=2;i*i<=PRIME_MAX;i++)
		if(prime[i]) for(int j=i*i;j<=PRIME_MAX;j+=i)prime[j] = false;
}

int main(){
	init_prime();
	vector<int> data;
	rep(i,PRIME_MAX+1)
		if(prime[i])data.push_back(i);
	
	int n;
	while(cin >> n , n){
		int ret = 0;
		rep(i,data.size()){
			int sum = 0;
			for(int j = i ; j < data.size() ; j++){
				sum += data[j];
				if(sum > n)break;
				if(sum == n)ret++;
			}
		}
		cout << ret << endl;
	}
}

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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a0, L;
    while (cin >> a0 >> L, a0 || L) {
        map<ll, ll> m;
        ll a = a0, times = 0;
        while (m.count(a) == 0) {
            m[a] = times;
            string stra = to_string(a);
            while (stra.size() < L) stra = "0" + stra;
            string ma = stra, Ma = stra;
            sort(all(ma));
            sort(all(Ma), greater<char>());
            a = stoll(Ma) - stoll(ma);
            ++times;
        }
        cout << m[a] << " " << a << " " << times-m[a] << endl;
    }
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define fr(i,k) for(i=0;i<k;i++)
#define ALL(c) (c).begin(),(c).end()
#define deb(x) cerr<<#x<<"  = "<<x<<endl;
#define SZ(x) (x).size();
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define em emplace_back
#define ulli unsigned long long int
#define INF 1e18
#define endl "\n"
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
void solve();

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}


int main() {
	fastio;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int t;
	t = 1;

	//cin >> t;
	while (t--)
	{
		solve();
	}
	return 0;
}


void solve()
{
	ll n, m, i, j;
	cin >> n >> m;

	vector<vector<char>> v(n, vector<char>(m));
	vector<vector<ll>> dp(n, vector<ll>(m, 0));

	for (i = 0; i < n; i++)
	{
		for (j = 0; j < m; j++)
			cin >> v[i][j];
	}

	for (i = 0; i < n; i++)
	{
		if (v[i][0] == '#')
			break;

		dp[i][0] = 1;
	}

	for (i = 0; i < m; i++)
	{
		if (v[0][i] == '#')
			break;

		dp[0][i] = 1;
	}

	for (i = 1; i < n; i++)
	{
		for (j = 1; j < m; j++)
		{
			if (v[i][j] == '#')
				continue;

			if (dp[i - 1][j] != 0)
				dp[i][j] = dp[i - 1][j] % MOD;

			if (dp[i][j - 1] != 0)
				dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
		}
	}

	cout << dp[n - 1][m - 1] << endl;



}


Measured memory_bytes: 12148
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG =  True
def ddprint(x):
  if DBG:
    print(x)

n = inn()
od = (n%2 == 1)
print((n*n-2*n+(1 if od else 0)) // 2)
for i in range(1,n):
    for j in range(i+1,n+1):
        if i+j != (n if od else n+1):
            print("{} {}".format(i,j))


Measured memory_bytes: 3592
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint,time,random
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

def cal(T):
    res = 0
    last = [0] * 26
    for day in range(D):
        t = T[day]; t -= 1
        last[t] = 0
        res += s[day][t]
        for i in range(26):
            if i == t: continue
            last[i] += 1
            res -= c[i] * last[i]
    return res
start_time = time.time()
n = 26
D = inp()
c = inpl()
s = [inpl() for _ in range(D)]
last = [0] * n
res = [-1] * D
for d in range(D):
    ans = -1
    mx = -INF
    for i in range(n):
        now = s[d][i]
        for j in range(n):
            if i == j: continue
            now -= s[d][j] * (last[j]+1)
        if now > mx:
            mx = now
            ans = i
    res[d] = ans+1
    for j in range(n):
        last[j] += 1
        if j == ans: last[j] = 0
score = cal(res)
# print(now_score)
while time.time() - start_time < 1.83:
    td,tq = random.randrange(0,D), random.randrange(1,n+1)
    old_q = res[td]
    res[td] = tq
    now = cal(res)
    if now > score:
        score = now
    else:
        res[td] = old_q

for x in res:
    print(x)

Measured memory_bytes: 87232
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>
using namespace std;

const int V_MAX=100000;

vector<int> G[V_MAX];
vector<bool> check(V_MAX,false);
vector<int> pre(V_MAX,INT_MAX);
vector<int> low(V_MAX,INT_MAX);
vector<bool> articulation(V_MAX,false);
int order;

void dfs(int s,int p){
	int counter=0;
	if(check[s]==true){return;}
	check[s]=true;
	pre[s]=order;
	low[s]=order;
	order++;
	for (int i=0;i<G[s].size();i++){
		if(G[s][i]!=p && pre[G[s][i]]<low[s]){
			low[s]=pre[G[s][i]];
		}
		if(check[G[s][i]]==false){
			dfs(G[s][i],s);
			counter++;
			if(s!=0 && G[s][i]!=p && pre[s]<=low[G[s][i]]){
			articulation[s]=true;
			}
		}
	}
	if(s==0 && counter>1){
		articulation[0]=true;
	}
	if(low[p]>low[s]){
		low[p]=low[s];
	}
}

int main(){
	int V,E,s,t;
	cin>> V >> E;
	for (int i=0;i<E;i++){
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	
	order=0;
	dfs(0,0);
	
	for(int i=0;i<V;i++){
		if(articulation[i]==true){
			cout << i << endl;
		}
	}
	/*
	for(int i=0;i<V;i++){
		cout << pre[i] << " ";
	}
	cout << endl;
	
	for(int i=0;i<V;i++){
		cout << low[i] << " ";
	}
	*/
	return 0;
}

Measured memory_bytes: 6024
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int L, R, D; cin >> L >> R >> D;
  cout << R / D - (L - 1) / D << endl;

  return 0;
}


Measured memory_bytes: 3588
from math import factorial as f
L = [0]
N = int(input())
A = list(map(int, input().split()))
cnt = 0
dic = {}
dic[0] = 1
for i in range(N):
    n = L[-1] + A[i]
    L.append(n)
    dic.setdefault(n, 0)
    dic[n] += 1
for key in dic.keys():
    if dic[key] > 1:
        cnt += f(dic[key]) // f(2) // f(dic[key] - 2)
print(int(cnt))

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

using namespace std;
typedef long long ll;
int nowarn;

ll a, b, c, d, n;
ll ans = 0;

int main() {
	nowarn = scanf( "%lld%lld%lld%lld%lld", &a, &b, &c, &d, &n );
	if( n >= 2 ) {
		ll cost = min(a*8, b*4);
		cost = min(cost, c*2);
		cost = min(cost, d);
		ans += (ll)n / 2 * cost;
		n %= 2;
	}
	if( n ) {
		ll cost = min(a*4, b*2);
		cost = min(cost, c);
		ans += cost;
	}
	printf( "%lld\n", ans );
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    String S = sc.next();
    char[]c = S.toCharArray();

    if(c[K-1]=='A'){
        c[K-1]='a';
    }else if(c[K-1]=='B'){
        c[K-1]='b';
    }else{
        c[K-1]='c';
    }
    System.out.println(String.valueOf(c));    
      }
}

Measured memory_bytes: 35504
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
#include <set>
using namespace std;

#define ll long long
#define ld long double
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))

//set<uint32_t> member;	// 重複するデータを保持する事はできない member.insert(2) member.insert(2) ⇒ member.count(2)は1
//multiset<uint32_t> v;	// 重複するデータも保持する事はできる   member.insert(2) member.insert(2) ⇒ member.count(2)は2

// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値 ex) 3.30303 ⇒ 4
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }
// 最大公約数
static int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
// 最小公倍数
static int lcm(int a, int b) { return a * b / gcd(a, b); }
// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
// ex) auto dp = make_vec<uint64_t>(SIZE + 1, 2, 2);

// ABC 166 B
// https://atcoder.jp/contests/abc165/tasks/abc165_b
int main()
{
	uint64_t x;
	cin >> x;


	uint64_t src = 100;
	uint32_t result = 0;

	while (1) {

#if 1
		src *= 1.01;
#else
		src *= 101;
		src /= 100;
#endif
		result++;
		if (src >= x) {
			break;
		}
	}

	printf("%d\n",result);
	return 0;
}


Measured memory_bytes: 3764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long t[] = new long[n];
        for (int i = 0; i < n; i++) {
            t[i] = in.nextLong();
        }

        long ans = 1L;
        for (int i = 0; i < n; i++) {
            ans = lcm(ans, t[i]);
        }

        System.out.println(ans);
    }

    static long gcd(long a, long b) {
        if (b % a == 0) {
            return a;
        }
        return gcd(b % a, a);
    }

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

Measured memory_bytes: 22996
import java.util.Scanner;
public class Main { 
    public static void main(String[] args) { 
        Scanner sc = new Scanner(System.in);  
        while (true) { 
            int H = sc.nextInt(); 
            int W= sc.nextInt(); 
            if (H == 0 && W == 0) { 
                break; 
            } else {
                for (int i = 0 ; i < H ; i++){
                    for (int j = 0 ; j < W ; j++){
                        System.out.printf("#");
                    }
                    System.out.printf("\n");
                } 
                System.out.printf("\n");
            }
        } 
    }
}


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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    // x±rが[0, W]に入り、y±rが[0, H]に入る。
    if((x >= r) && (x + r <= W) && (y >= r) && (y + r <= H)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,a,n) for(int i=a;i<n;i++)
#define ll long long int
#define li long int
using namespace std;
int n;
vector<int> a(100005);
vector<int> b(100005);
vector<int> c(100005);
vector<vector<ll>> dp(100005,vector<ll> (4,-1));
ll cost(int ind,int parent)
{
    if(ind==n)
    {
        return 0;
    }
    if(dp[ind][parent]==-1)
    {
        if(parent==1)
        {
            dp[ind][parent]=a[ind]+max(cost(ind+1,2),cost(ind+1,3));
            //return dp[ind][parent];
        }
        else if(parent==2)
        {
            dp[ind][parent]=b[ind]+max(cost(ind+1,1),cost(ind+1,3));
            //return dp2[ind];
        }
        else
        {
            dp[ind][parent]=c[ind]+max(cost(ind+1,2),cost(ind+1,1));
            //return dp3[ind];
        }
    }
    return dp[ind][parent];

}
int main()
{
    cin>>n;
    f(i,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    ll ans=max(cost(0,1),cost(0,2));
    ans=max(ans,cost(0,3));
    cout<<ans;
}


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

int main(){
    int n, a[10], ma=0, sum=0;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }

    for(int i=0;i<n;i++){
        sum += a[i];
        if(a[i]>ma){
            ma = a[i];
        }
    }
    sum -= ma;

    if(ma < sum){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
}

Measured memory_bytes: 256
N = gets.to_i
AS = gets.split.map(&:to_i)

as = AS.sort
max = as[-1]
bmap = as.to_h { |n| [n, true] }
bmap.default = false

as.each.with_index do |n, i|
  next unless bmap[n]

  v = n
  while (v += n) <= max
    bmap[v] = false
  end

  bmap[n] = false if as[i + 1] == n
end

puts bmap.values.select(&:itself).count


Measured memory_bytes: 71308
a, b = map(int, input().split())
SUM_1 = 0
SUM_2 = 1
i = 0
array = [x for x in range(1000)]
array.pop(0)

while True:
    SUM_1 = SUM_1 + array[i]#隣り合う2つ
    SUM_2 = SUM_2 + array[i+1]#隣り合う2つ

    if SUM_1 - a == SUM_2 - b:
        print(SUM_1 - a)
        break
    
    i += 1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define local
//if you find any bug in my code, please tell me.
int main()
{
#ifdef local
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
#endif
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    cout<<string(ty-sy,'U')<<string(tx-sx,'R');
    cout<<string(ty-sy,'D')<<string(tx-sx+1,'L');
    cout<<string(ty-sy+1,'U')<<string(tx-sx+1,'R')<<'D'<<'R';
    cout<<string(ty-sy+1,'D')<<string(tx-sx+1,'L')<<'U';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
struct UnionFind
{
	vector<int> par;
	UnionFind(int n) :par(n, -1) {}
	int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	void unite(int x, int y)
	{
		x = find(x); y = find(y);
		if (x == y) return;
		if (par[y] < par[x]) swap(x, y);
		if (par[x] == par[y]) par[x]--;
		par[y] = x;
		if (find(x) != find(y)) par[find(y)] = x;
	}
	int count()
	{
		int cnt = 0;
		REP(i, par.size()) if (par[i] < 0) cnt++;
		return cnt;
	}
	bool same(int x, int y)
	{
		return find(x) == find(y);
	}
};

struct Dice
{
private:
	int top, right, front;
public:
	Dice() :top(1), right(2), front(3) {};
	Dice(int t, int r, int f) :top(t), right(r), front(f) {};
	void set(int t, int r, int f) { top = t, right = r, front = f; }
	int get_top() { return top; }
	int get_bottom() { return 7-top; }
	int get_right() { return right; }
	int get_left() { return 7 - right; }
	int get_front() { return front; }
	int get_back() { return 7 - front; }
	void to_front() { swap(front, top); top = 7 - top; }
	void to_back() { REP(i, 3) to_front(); }
	void to_right() { swap(top, right); top = 7 - top; }
	void to_left() { REP(i, 3) to_right(); }
	void to_clock() { swap(front, right); right = 7 - right; }
	void to_counter() { REP(i, 3) to_clock(); }
};

int main()
{
	int n; 
	while (cin >> n, n)
	{
		Dice d(1, 3, 2);
		int ans = 1;
		REP(i, n)
		{
			string s; cin >> s;
			if (s == "North") d.to_back();
			else if (s == "South") d.to_front();
			else if (s == "East") d.to_right();
			else if (s == "West") d.to_left();
			else if (s == "Right") d.to_clock();
			else if (s == "Left") d.to_counter();
			ans += d.get_top();
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
const int MOD=1e9+7;
const ll MAX = 210000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  int S;cin >> S;
  COMinit();
  ll t = S / 3;
  ll ans = 0;
  for(int i=1;i<=t;++i){
    ll tmp = S - i * 3;
    ans += COM(tmp+i-1, i-1) % MOD;
    ans %= MOD;
    //cout << "i " << i << "ans " << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8540
# solution
# online help taken
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,Q = map(int,input().split())
aLst = [[int(i) for i in input().split()] for _ in range(N-1)]
pLst = [[int(i) for i in input().split()] for _ in range(Q)]
to = [[]for _ in range(N+1)]

for a,b in aLst:
    to[a].append(b)
    to[b].append(a)

ps = [0]*(N+1)
for a,b in pLst:
    ps[a] += b

def dfs(v, i):
    for j in to[v]:
        if j == i:
            continue
        ps[j] += ps[v]
        dfs(j,v)

dfs(1,0)
print(' '.join(map(str, ps[1:])))

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

int main (){
    int N, M;
    cin >> N >> M;
    vector<vector<int>> to(N, vector<int>());
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        --a;--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<int> count(N, -1);
    queue<int> que;
    que.push(0);
    count[0] = 0;
    while (!que.empty())
    {
        int y = que.front();
        que.pop();
        if (count[y] == 3)
        {
            break;
        }

        for (int x : to[y])
        {
            if (count[x] != -1)
            {
                continue;
            }
            count[x] = count[y] + 1;
            que.push(x);
        }     
    }
    
    if (count[N - 1] == 2)
    {
        cout << "POSSIBLE" << endl;
    } else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    
    

    return 0;
    
}

Measured memory_bytes: 13168
#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long LL;
typedef vector<long> VI;
typedef vector<VI> VVI;

VI A;
LL K;

LL simulate(LL N){
	LL retval = N;
	REP(i,K) retval -= (retval % A[i]);
	return retval;
}

LL binary_search_min(LL maxval){
	LL middle,minv = llINF;
	LL l = 0;
	LL r = maxval;
	LL ans;
	while (l <= r){
		middle = (l + r) / 2;
		ans = simulate(middle);
		#ifdef DEBUG
		 dump(middle);
		 dump(ans);
		#endif

		if (ans == 2) minv = min(middle,minv); 
		if(ans >= 2) r = middle-1;
		else l = middle+1;
	}

	return minv;
}

LL binary_search_max(LL maxval){
	LL middle,maxv = -1;
	LL l = 0;
	LL r = maxval;
	LL ans;
	while (l <= r){
		middle = (l + r) / 2;
		ans = simulate(middle);

		if (ans == 2) maxv = max(middle,maxv);

		if(ans <= 2) l = middle + 1;
		else r = middle-1;
	}

	return maxv;
}


int main (void){
	LL maxval = -1;
	cin >> K;
	A = VI(K);

	REP(i,K) {
		cin >> A[i];
		if (maxval < A[i]) maxval = A[i];
	}

	LL a = binary_search_max(2+K*maxval);
	LL b = binary_search_min(2+K*maxval);

	if (a == -1 || b == llINF || b > a) cout << (-1) << endl;
	else cout << b << " " << a << endl;

	return 0;
}

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

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    int t = a + b;
    if(a - b > t) t = a - b;
    if(a * b > t) t = a * b;
    printf("%d", t);
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
H = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(M)]
A = [list() for _ in range(N)] 
ans = 0  
for a ,b in AB:
    A[b-1].append(a-1)
    A[a-1].append(b-1)
for i in range(N):
    for j in A[i]:
        #満たさないものを数える
        if H[i] <= H[j]:
            ans += 1
            break
print(N-ans)

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

using namespace std;
int main(){
    int x,y;
    cin>>x>>y;
    int a=2*x-(y/2);
	int b=(y/2-x);
    if((y-2*x)<0 || (2*x-(y/2))<0){
    	cout<<"No"<<"\n";
    	return 0;
	}
	else if(a+b !=x){
    	cout<<"No"<<"\n";
    	return 0;
	}
	else if(2*a+4*b!=y) {
    	cout<<"No"<<"\n";
    	return 0;
	}
     cout<<"Yes"<<"\n";
    return 0;
}

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

int main(void){
  int a,b;
  char buf[32] = { 0 };
  
  //数字読み込み
  fgets(buf, sizeof(buf), stdin);
  sscanf(buf, "%d %d", &a, &b);
  
  if(a * b % 2 == 0)
    printf("Even\n");
  else
    printf("Odd\n");
  return 0;
}

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

int main()
{
	long long A, B;
	cin >> A >> B;

	long long gcd = __gcd( A, B );
	set<long long> st;
	for( long long i = 2; i * i <= gcd; i++ ) {
			while( gcd % i == 0 ) {
				gcd /= i;
				if( st.count( i ) == 0 ) st.insert( i );
			}	}
	st.insert( 1 );
	if( gcd != 1 ) st.insert( gcd );
	long long ans = st.size();

	cout << ans << endl;
}


Measured memory_bytes: 3612
#include<iostream>
using namespace std;
int n,ans;
bool work(int x){
	if(x<10) return true;
	else if(x>=10&&x<100) return false;
	else if(x>=100&&x<1000) return true;
	else if(x>=1000&&x<10000) return false;
	else if(x>=10000&&x<100000) return true;
	else return false;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) if(work(i)) ans++;
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<max(a*b,max(a-b,a+b))<<e;


}


Measured memory_bytes: 256
A, B = map(int, input().split())
a = [i for i in range(1, 1001) if int(i * 0.08) == A]
b = [i for i in range(1, 1001) if int(i * 0.1) == B]
c = set(a) & set(b)
if len(c):
    print(min(c))
else:
    print(-1)


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();

		sc.close();

		long quotiment = N/K;

		long answer = 0;

		if(N%K == 0) {
			System.out.println(answer);
		}else {
			long innerQuot = N - (K * quotiment);
			long outerQuot = K * (quotiment + 1) - N;
			if(innerQuot <= outerQuot) {
				System.out.println(innerQuot);
			}else {
				System.out.println(outerQuot);
			}
		}
	}
}


Measured memory_bytes: 21844
// https://atcoder.jp/contests/abc068/tasks/arc079_b

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

const ll INF = 1e18;

void solve() {
  ll K;
  cin >> K;
  ll N = 50;
  VL res(N);

  rep(i, N) res[i] = i;

  ll quot = K / N;
  ll rest = K % N;

  rep(i, N) res[i] += quot;

  rep(i, N) {
    if (i < rest) {
      res[i] += N - (rest - 1);
    } else {
      res[i] -= rest;
    }
  }

  cout << N << endl;
  print_ints(res);
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
/*Infor {{{
 ******************************************************
 * > File Name: b.cpp
 * > Author: zrz_orz
 * > Mail: 1281941815@qq.com
 * > Created Time: 2018/9/8/周六 20:04:01
 ******************************************************
}}}*/

#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define cini(a) scanf("%d", &(a))
#define cinc(a) scanf("%c", &(a))
#define cinl(a) scanf("%lld", &(a))
#define cins(a) scanf("%s", (a))
#define cind(a) scanf("%lf", &(a))
#define coui(a) printf("%d", (a))
#define couc(a) printf("%c", (a))
#define coul(a) printf("%lld", (a))
#define cous(a) printf("%s", (a))
#define coud(a) printf("%f", (a))
#define SPA printf(" ")
#define LIN printf("\n")
#define ull unsigned long long int
/*}}}*/

/*Constant {{{*/
const int N = 11;
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
int n;
char s[N];
map<string, int>mp;
/*}}}*/

/*Declare {{{*/
/*}}}*/

/*Main {{{*/
int main() {
  scanf ("%d", &n);
  char last;
  for (int i = 1; i <= n; i++) {
    memset(s, 0, sizeof s);
    if (i == 1) {
      scanf ("%s", s);
      mp[s] = 1;
      last = s[strlen(s) - 1];
      continue;
    }
    scanf ("%s", s);

    if(mp[s]) {
      cout<<"No\n"<<endl;
      return 0;
    }
    if (s[0] != last) {
      cout<<"No\n"<<endl;
      return 0;
    }
    last = s[strlen(s) - 1];
    mp[s] = 1;
  }
  cout<<"Yes\n"<<endl;
  return 0;
}
/*}}}*/

/*Define {{{*/
/*}}}*/


Measured memory_bytes: 256
s = input()
l = len(s)

s1 = [ ((-1)**i + 1)//2 for i in range(l)]
s2 = [ ((-1)**(i+1) + 1)//2 for i in range(l)]

m = 0
n = 0
for i in range(l):
  m += (int(s[i]) - s1[i])**2
  n += (int(s[i]) - s2[i])**2

print(min([m,n]))

Measured memory_bytes: 4852