akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);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(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#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 bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

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>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec a(N); cin >> a;

    int x = 0;
    REP(i, N) x ^= a[i];
    Ans(x, "No", "Yes");

    return 0;
}


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

struct Node{
    int key;
    struct Node *right;
    struct Node *left;
    struct Node *parent;
};
struct Node *root;

void inorder(struct Node *);
void preorder(struct Node *);
void insert(int);

int main(){
    int n,x;
    char com[20];

    scanf("%d", &n);

    for (int i = 0; i < n; i++ ){
        scanf("%s", com);
        if(com[0] == 'i'){
            scanf("%d",&x);
            insert(x);
        } 
        else if(com[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } 
    }

    return 0;
}

void inorder(struct Node *A){
    if(A == NULL)return;
    inorder(A->left);
    printf(" %d",A->key);
    inorder(A->right);
}

void preorder(struct Node *A){
    if(A == NULL)return;
    printf(" %d",A->key);
    preorder(A->left);
    preorder(A->right);
}

void insert(int key){
    struct Node *y = NULL;
    struct Node *x = root;
    struct Node *z = malloc(sizeof(struct Node));
    z->key = key;
    z->left = z->right = z->parent = NULL;

    while(x != NULL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else{
            x = x->right;
        }
    }

    z->parent = y;

    if(y == NULL){
        root = z;
    }
    else if(z->key < y->key){
        y->left = z;
    }
    else{
        y->right = z;
    }
}


Measured memory_bytes: 25184
#include<stdio.h>

int main(){
	char s[50];
	int n,k;
	int x;
	
	scanf("%d" "%d",&n,&k);	
	scanf("%s",&s);
	if(s[k-1]=='A'){
	s[k-1]='a';
 	 }else if(s[k-1]=='B'){
	s[k-1]='b';
 	 }else if(s[k-1]=='C'){
	s[k-1]='c';
 	 }
	for(x=0;x<n;x++){
	printf("%c",s[x]);
    }
return 0;
}

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

#define loop(i,a,b) for(int i=(a); i<int(b); i++)
#define rep(i,b) loop(i,0,b)

char v[] ="0123456789543210123456789";

void solve(int s,int g) {
    int ans = 10000;
    int p = 0;
    rep(i,25){
        if(v[i] != s+'0') continue;
        loop(j,i+1,25){
            if(v[j] == g + '0') {
                ans = min(ans,j-i);
                p = i;
                continue;
            }
        }
    }

    for(int i=p; i<=p+ans; i++) cout<< (i==p?"":" ") <<v[i];
    cout << endl;
}

int main() {
    int n; cin >> n;
    rep(i,n){
        int f, t;
        cin >> f >> t;
        solve(f,t);
    }
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
vector<int> e[105];
int res[105];
bool ok[105];
int n;
int inf=1<<30;
int main(){
//	freopen("a.txt","r",stdin);
	cin>>n;
	int u,v,k;
	fill(res,res+103,inf);
	while(cin>>u){
		cin>>k;
		for(int i=0;i<k;i++)cin>>v,e[u].push_back(v);
	}
	queue<pair<int,int> >q;
	q.push({1,0});
	ok[1]=1;
	while(!q.empty()){
		pair<int,int> p=q.front();q.pop();
		int i=p.first;int d=p.second;
		res[i]=min(res[i],d);
		for(int j=0;j<e[i].size();j++)
			if(!ok[e[i][j]])q.push({e[i][j],d+1}),ok[e[i][j]]=1;
	}
	for(int i=1;i<=n;i++)
		printf("%d %d\n",i,(ok[i])?res[i]:-1);
	return 0;
}


Measured memory_bytes: 3252
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static int gcd(int a, int b) {
		return b == 0 ? a : gcd(b, a % b);
	}

	static void solve() throws Exception {
		int n = scanInt(), m = scanInt();
		String s = scanString(), t = scanString();
		int g = gcd(n, m);
		int ng = n / g, mg = m / g;
		for (int i = 0; i < g; i++) {
			if (s.charAt(ng * i) != t.charAt(mg * i)) {
				out.print(-1);
				return;
			}
		}
		out.print((long) n * mg);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 24276
/**
*    author:  boutarou
*    created: 18.07.2020 19:37:14
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
using ll = long long;
using P = pair<int, int>;

const ll INF = 1e9;

int main() {
    int n;
    cin >> n;
    vector<ll>a(n);
    rep(i, n) cin >> a[i];
    ll ans = a[0];
    rep(i, n) {
        ans = gcd(ans, a[i]);
    }
    cout << ans << endl;

    return 0;
}

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

signed main() {
    int n;
    string s;
    cin >> n >> s;

    map<char, int> m;
    for (char c : s) m[c]++;

    cout << (m['R'] > m['B'] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)
INF = float("inf")


def main():
    X, Y = map(int, input().split())
    B = (Y - 2*X) // 2
    if 2*B == Y-2*X:
        A = X-B
        if 0 <= A and 0 <= B:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
    return


if __name__ == '__main__':
    main()


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

using namespace std;

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

    int n, m;
    std::cin >> n >> m;
    std::vector <int> v(n);
    for (int i = 0; i < n; ++i) {
        std::cin >> v[i];
    }

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

    int ans = 0;
    for (int i = 0; i < m; ++i) {
        ans += v[i];
    }
    std::cout << ans << '\n';

    return 0;
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int N, M;
vector<int> G[8];
int reached[8];
int res = 0;

void dfs(int current, int t) {
	if(t == 0) {
		bool flag = true;
		rep(i, 0, N) {
			if(reached[i] == 0) flag = false;
		}
		if(flag) res++;
		reached[current]--;
		return;
	}

	rep(i, 0, G[current].size()) {
		reached[G[current][i]]++;
		dfs(G[current][i], t - 1);
	}
	reached[current]--;
}
		


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

	cin >> N >> M;
	rep(i, 0, M) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	memset(reached, 0, sizeof(reached));
	reached[0] = 1;
	dfs(0, N - 1);
	cout << res << endl;
}


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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

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

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}

int main(){
  int N;
  cin >> N;
  vector<ll> A(N);
  rep(i,N){
    cin >> A[i];
  }
  ll p = 1000000000 + 7;
  vector<int> memo(61);//memo[k]は、数列Aにおける2のk乗桁が1であるものの個数
  rep(i,N){
    ll a = A[i];

    int k = 0;
    while(a){
      if(a%2) memo[k]++;
      a /= 2;
      k++;
    }
  }
  vector<ll> memo2(61);//memo2[k]は2k％pの値
  rep(i,61){
    memo2[i] = calc(2,i,p);
  }
  
  ll ans = 0;
  rep(i,N){
    ll a = A[i];
    //vector<int> bitv;
    int k = 0;
    while(true){//k桁目の値の確認とbit化を同時にやる
      //v.push_back(a%2);//A[i]のk桁目
      if(a%2){//A[i]の2k桁は1
        int c = N - memo[k];//2k桁が0であるものの数
        ans += c * memo2[k];
        ans %= p;
      }
      else{//A[i]の2k桁は0
        int c = memo[k];//2k桁が1であるものの数
        ans += c * memo2[k];
        ans %= p;
      }
      a /= 2;
      k++;
      if(k >= 61) break;//0~59桁目まで見る
    }
  }
  cout << (ans*calc(2,p-2,p)) %p << endl;
 }

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
vector<vector<long>> multiply(vector<vector<long>> arr,vector<vector<long>> b){
    vector<vector<long>> ans(arr.size(),vector<long>(b.size(),0));
    for(int i=0;i<arr.size();i++){
        for(int j=0;j<b[0].size();j++){
            for(int k = 0;k<arr[0].size();k++){
                ans[i][j] = (ans[i][j]%mod + ((arr[i][k]%mod)*(b[k][j]%mod))%mod)%mod;
            }
        }
    }
    return ans;
}
vector<vector<long>> power(vector<vector<long>> arr,long k){
    if(k==1){
      return arr;  
    }
    vector<vector<long>> ans  = power(arr,k/2);
    if(k%2==1){
        return multiply(arr,multiply(ans,ans));
    }
    else{
        return multiply(ans,ans);
    }
}
long solve(vector<vector<long>> arr,long k,long n){
    vector<vector<long>> a = power(arr,k);
   long ans = 0;
   for(int i=0;i<n;i++){
       for(int j=0;j<n;j++){
           ans = (ans%mod + a[i][j]%mod)%mod;
       }
   }
   return ans;
    
}
int main() {
	long n,k;
	cin>>n>>k;
	vector<vector<long>> arr(n,vector<long>(n));
	for(int i=0;i<n;i++){
	    for(int j=0;j<n;j++){
	        cin>>arr[i][j];
	    }
	}
	cout<<solve(arr,k,n)<<'\n';
	return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll x,y;
    cin>>x>>y;
    ll s[] = {1,1,3,1,2,1,2,1,1,2,1,2,1};
    
    if (s[x] == s[y])cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

ll n,m;

int main(){
	cin>>n>>m;
	if(abs(n-m)>1){
		cout<<"0"<<endl;
		return 0;
	}
	ll ans=1;
	for(ll i=1;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	
	for(ll i=1;i<=m;i++){
		ans*=i;
		ans%=MOD;
	}
	
	if(n==m){
		ans*=2;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# Print a Rectangle

def draw(h, w):
    for i in range(h):
        for j in range(w):
            print('#', end = "")
        print()
    return ""

inputEnd = 0
while inputEnd == 0:
    n = [int(i) for i in input().rstrip().split()]
    h = n[0]
    w = n[1]
    if h == 0 and w == 0:
        inputEnd += 1
    else:
        print(draw(h, w))



Measured memory_bytes: 7012
import math

def main():
    N = int(input())
    A = list(map(int, input().split()))
    lcm = 1
    for a in A:
        lcm = lcm * a // math.gcd(lcm, a)
    m = lcm - 1

    f = 0
    for a in A:
        f += m % a
    print(f)


if __name__ == '__main__':
    main()


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

int main() {
  long long h, w; cin >> h >> w;
  int i = 0;
  if((h * w) % 2 == 1) i = 1;
  if(h == 1) {
    cout << 1;
    return 0;
  }
  if(w == 1){
    cout << 1;
    return 0;
  }
  cout << ((h * w) / 2) + i;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define add insert
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    string str1,str2;
    cin>>str1>>str2;
    bool flag = false;
    for (int i =str1.length()-1; i>=0; i--)
    {
        bool f=true;
        for (int j=0; j<str2.length(); j++)
        {
            if(str1[j+i]==str2[j]||str1[j+i]=='?');
            else f=false;
        }
        if(f)
        {
            flag =true;
            for (int j = i; j<i+str2.length(); j++)
            {
                str1[j]=str2[j-i];
            }
            break;
        }
    }

    if(!flag)
    {
        cout<<"UNRESTORABLE";
        return 0;
    }
    for (char a : str1)
    {
        if(a=='?')
        {
            a='a';
        }
        cout<<a;
    }
    return 0;
}


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

int main() {
  int K, N;
  string S;
  cin >> N;
  cin >> S;
  cin >> K;
  char r = S[K-1];
  for (int i = 0; i < N; i++) {
    cout << (S[i] == r ? r : '*');
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
void fast()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);

}

int main()
{
    fast();
    int x,y;
    cin>>x>>y;
    int high=x*4;
    int low=x*2;
    cout<<(y>=low&&y<=high&&y%2==0?"Yes\n":"No\n");
}



Measured memory_bytes: 3648
from collections import deque
n, m = map(int, input().split())
h = [int(x) for x in input().split()]

tree = [[] for _ in range(n)]
for i in range(m):
  a, b = map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)

ans = 0
for i in range(n):
  judge = True
  for v in tree[i]:
    if h[i] <= h[v]:
      judge = False
  if judge:
    ans += 1

print(ans)

Measured memory_bytes: 29696
unittest
{
	assert( [ "2 3 1 1" ].parse.expand.solve == 2 );
	assert( [ "10 7 3 4" ].parse.expand.solve == 3570 );
	assert( [ "100000 100000 99999 99999" ].parse.expand.solve == 1 );
	assert( [ "100000 100000 44444 55555" ].parse.expand.solve == 738162020 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto hwab = input.front.split.to!( long[] );
	return tuple( hwab[ 0 ], hwab[ 1 ], hwab[ 2 ], hwab[ 3 ] );
}

auto solve( long h, long w, long a, long b )
{
	auto ans = 0L;
	auto y1 = h - a - 1;
	auto y2 = h - y1 - 2;
	for( auto x1 = b; x1 < w; x1++ )
	{
		auto x2 = w - x1 - 1;
		ans = ans.addMod( ( y1 + x1 ).combinationMod( x1 ).mulMod( ( y2 + x2 ).combinationMod( x2 ) ) );
	}
	return ans;
}

// 足し算
auto addMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return ( x + y ) % MOD;
}

// 掛け算
auto mulMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y % MOD;
}

// 割り算
auto divMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x * y.powMod!MOD( MOD - 2 ) % MOD;
}

// べき乗
auto powMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	auto a = 1L;
	for( ; 0 < y; y >>= 1 )
	{
		if( y & 1 ) a = a * x % MOD;
		x = x ^^ 2 % MOD;
	}
	return a;
}

// 階乗
auto factorialMod( long MOD = 10L ^^ 9 + 7 )( long x )
{
	static memo = [ 1L ];
	if( memo.length <= x )
	{
		auto i = memo.length;
		memo.length = x + 1;
		for( ; i <= x; i++ ) memo[ i ] = memo[ i - 1 ] * i % MOD;
	}
	return memo[ x ];
}

// 組み合わせ数
auto combinationMod( long MOD = 10L ^^ 9 + 7 )( long x, long y )
{
	return x.factorialMod!MOD.divMod!MOD( y.factorialMod!MOD.mulMod!MOD( ( x - y ).factorialMod!MOD ) );
}


Measured memory_bytes: 3708
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int a, b;
	cin >> a >> b;
	int res = a * b;
	res -= a + b - 1;
	cout << res << endl;
	return 0;
}


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

#define pb(x) push_back(x)
#define memset0(x) memset((x), 0, sizeof(x))
#define memsetM1(x) memset((x), -1, sizeof(x))
#define int long long
typedef unsigned int ull;
typedef pair<int,int> pii;
typedef tuple<int, int, int> Tiii;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define ALL(x) (x).begin(), (x).end()
#define PB push_back

constexpr int INF = (int)1e18;
constexpr int MOD = (int)998244353;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) &= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))
#define FRO freopen("in.txt","r",stdin);
#define         DEBUG(args...)    do {   cerr << #args << ' ' ;  print(args); } while(0); cerr<< endl ;
template< typename T > void print(const T& v) {    cerr << v << ' ' ;}
template< typename T1, typename... T2 >
void print( const T1& first, const T2&... rest ){
    print(first);
    print(rest...) ;
}
// ====================================================================

vector<int>arr;
int n;

signed main()
{
        ios::sync_with_stdio(0);
        cin.tie(0);
        int i,j,t,tcs=0,k,m,u,v;
        cin>>n>>k;
        bool dp[k+1];
        memset0(dp);
        arr.resize(n);
        for(i=0;i<n;i++) cin>>arr[i];
        for(i=0;i<=k;i++)
        {
                if(!dp[i])for(j=0;j<n;j++)
                {
                        if(i+arr[j]>k) break;
                        dp[i+arr[j]]=1;
                }
        }
        if(dp[k]) cout<<"First";
        else cout<<"Second";


	return 0;
}


Measured memory_bytes: 384
N = int(input())
dp = [N] * (N+1)
dp[0] = 0

for i in range(1, N+1):
    pow6 = []
    pow9 = []
    for j in range(i):
        if 6**j > i:
            break
        pow6.append(6**j)
    for k in range(i):
        if 9**k > i:
            break
        pow9.append(9**k)
    L = set(pow6 + pow9)
    
    for l in L:
        if i-l < 0:
            break
        dp[i] = min(dp[i], dp[i-l]+1)

print(dp[N])

Measured memory_bytes: 3828
from collections import deque


n, m = map(int, input().split())
edg = [[] for i in range(n+1)]
ans = [-1]*(n+1)


for _ in range(m):
	u, v = map(int, input().split())
	edg[u].append(v)
	edg[v].append(u)



def bfs():
	q = deque()
	q.append(1)
	ans[1] = 1

	while q:
		top = q[0]
		q.popleft()
		for child in edg[top]:
			if ans[child] == -1:
				# print(str(top) + " --> " + str(child))
				ans[child] = top
				# print(ans[child])
				q.append(child)


bfs()
if -1 in ans[1:]:
	print("No")
else:
	print("Yes")
	for i in ans[2:]:
		print(i)


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


int main() {
  string s;
  cin>>s;
  
  map<string,int> m;
  m["MON"]=0;
  m["TUE"]=1;
  m["WED"]=2;
  m["THU"]=3;
  m["FRI"]=4;
  m["SAT"]=5;
  m["SUN"]=6;
  
  if(s=="SUN")cout<<7;
  else{cout<<m["SUN"]-m[s];}

}

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


int main() {
  ll n;
  scanf("%lld", &n);
  vector<ll> a(3*n);
  rep(i, 3*n) scanf("%lld", &a[i]);;
  sort(&a[0], &a[0]+n*3);
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += a[n + 2*i];
  }
  cout << ans << endl;
}




Measured memory_bytes: 2560
# D - Flipping Signs
# https://atcoder.jp/contests/abc125/tasks/abc125_d

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

ng_cnt = 0

for i in range(N):
    if A[i] < 0:
        ng_cnt += 1
        A[i] = -A[i]

if ng_cnt % 2 == 0:
    print '{}'.format( sum(A) )
else:
    print '{}'.format( sum(A) - min(A)*2)


Measured memory_bytes: 11320
import numpy as np

H,W = map(int,input().split())
temp = np.array([list(input()) for _ in range(H)])
# 周りに壁を、0,1化
map = np.zeros((H+2,W+2),dtype=np.int32)
map[1:-1,1:-1][temp == '.'] = 1

# x軸正方向の集計
def F(transpose,reverse):
  x = map.copy()
  if transpose:
    x = x.T
  x = np.ravel(x)
  if reverse:
    x = x[::-1]
  zero_idx = np.nonzero(x==0)[0]
  x[zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum()
  if reverse:
    x = x[::-1]
  if transpose:
    x = x.reshape(map.T.shape).T
  else:
    x = x.reshape(map.shape)
  return x

answer = np.zeros_like(map)
for t in [True,False]:
  for r in [True,False]:
    answer += F(t,r)
    
answer = answer.max() - 3
print(answer)

Measured memory_bytes: 188708
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>

#include <sstream>

using namespace std;

bool DaC(int m, vector<int> &a, int i, int n){

  if(m<0){
    return false;
  }
  
  if(m==0){
    return true;
  }

  if(i>=n){
    return false;
  }
    
  
  return (DaC(m-a[i], a, i+1, n) || DaC(m, a, i+1, n));
}
		   
		   
int main(){
  int n;
  vector<int> a;
  int q;
  vector<int> m;

  cin >> n;
  
  for(int i=0;i<n;i++){
    int tmp;
    cin >> tmp;
    a.push_back(tmp);
  }

  cin >> q;

  for(int i=0;i<q;i++){
    int tmp;
    cin >> tmp;
    m.push_back(tmp);
  }

  for(int i=0;i<m.size();i++){
    if(DaC(m[i], a, 0, n)){
      cout << "yes" << endl;
    }else{
      cout << "no" << endl;
    }
  }
  
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//const long long inf = 1e17;
int main()
{
    ll n,k;
    cin>>n>>k;
    ll mx = 0,w[n+5],v[n+5];
    for(ll i=0;i<n;i++)
    {   
        cin>>w[i]>>v[i];
        mx=mx+v[i];
        
    }
    ll dp[n+1][mx+1];
  
     for(ll i=0;i<=n;i++)
     {
         for(ll j=0;j<=mx;j++)
         {
             dp[i][j]=100000000000000000;
         }
     }
   // ll dp[n+1][mx+1]={(ll)1e17};
 //   memset(dp,(ll)1e17,sizeof(dp));
    dp[0][0]=0;
   // cout << w[105] << '\n';
    for(ll i=0;i<n;i++)
    {    //cout<<dp[i][j]<<endl;
        for(ll j=0;j<=mx;j++)
        {
            if(j<v[i])
            {
                dp[i+1][j]=dp[i][j];
            }
            else
            {
               // dp[i+1][j]=dp[i][j];
                dp[i+1][j]=min( dp[i][j], dp[i][j-v[i] ] +w[i]);
               // cout<<dp[i][j]<<endl;
            }
          //  cout<<dp[i][j]<<endl;
        }
    }
    ll sol=0;
    for (int i = 0; i <= mx; i++) 
    {
    if (dp[n][i] <= k) 
      sol= i;
     
    }
    
    cout<<sol<<endl;
    
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, k;
    cin >> n >> k;
    vll v(n);
    REP(i, n) cin >> v[i];
    ll hold = min(n, k), res = 0;
    for(int i = 0; i <= hold; i++){
        for(int j = 0; j + i <= hold; j++){
            ll discardable = k - (i + j), tmp = 0;
            vll hand;
            REP(k, i) hand.push_back(v[k]);
            REP(k, j) hand.push_back(v[n - 1 - k]);
            VSORT(hand);
            REP(k, i + j){
                if(hand[k] > 0 || k >= discardable) tmp += hand[k];
            }
            res = max(res, tmp);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		while(true) {
			int tyukan = sc.nextInt();
			int kimatu = sc.nextInt();
			int saisi = sc.nextInt();
			String result = "";
			if(tyukan == -1 && kimatu == -1 && saisi == -1) {
				break;
			} else if (tyukan == -1 || kimatu == -1){
				result = "F";
			} else {
				if(tyukan + kimatu >= 80) {
					result = "A";
				} else if(tyukan + kimatu >= 65) {
					result = "B";
				} else if((tyukan + kimatu >= 50) || (tyukan + kimatu >= 30 && saisi >= 50)) {
					result = "C";
				} else if(tyukan + kimatu >= 30) {
					result = "D";
				} else {
					result = "F";
				}

			}

			System.out.println(result);
		}


	}
}

Measured memory_bytes: 26260
<?php
$n=trim(fgets(STDIN));
$X=explode(' ',trim(fgets(STDIN)),$n);
$Y=explode(' ',trim(fgets(STDIN)),$n);

$A=0;
$B=0;
$C=0;
$D=0;
for($i=0;$i<$n;$i++){
  $a=($X[$i]<$Y[$i])?$Y[$i]-$X[$i]:$X[$i]-$Y[$i];
  $b=$a*$a;
  $A+=$a;
  $B+=$b;
  $C+=$b*$a;
  if($D<$a){$D=$a;}
}
echo $A
,PHP_EOL
,pow($B,1/2)
,PHP_EOL
,pow($C,1/3)
,PHP_EOL
,$D;
?>

Measured memory_bytes: 15640
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>

using namespace std;
using ll = long long int; 


ll keta(ll a){
  ll ans = 1;
  while(1){
    if(a/10 > 0){
      ans++;
      a = a/10;
    }
    if(a<10) break;
  }
  return ans;
}


int main(void){

  string s;
  cin>>s;

  for(int i=0;i<s.length();i++){
   // cout<<s[i] <<s.length()-i<<endl;
    if(s.length()<10 && s.length() - i != 5 && s.length() - i != 7 && s.length()-i != 6){
      cout<<"NO"<<endl;
      return 0;
    }
    if(s[i] == 'd'){
      if(s[i+1] != 'r'){
        cout<<"NO"<<endl;
        return 0;
      }
      if(s[i+2] != 'e'){
        cout<<"NO"<<endl;
        return 0;
      }
      if(s[i+3] != 'a'){
        cout<<"NO"<<endl;
        return 0;
      }
      if(s[i+4] != 'm'){
        cout<<"NO"<<endl;
        return 0;
      }
      if(s[i+5]=='e' && s[i+6] == 'r'){
        //cout<<"in"<<endl;
        if(s[i+7]=='a') i+=4;
        else i+=6;
       // break;
      }else{
        i+=4;
        //break;
      } 
    }else if(s[i] == 'e'){
      //cout<<'a';
      if(s[i+1] != 'r'){
        cout<<"NO"<<endl;
        return 0;
      }
      if(s[i+2] != 'a'){
        cout<<"NO"<<endl;
        return 0;
      }
      if(s[i+3] != 's'){
        cout<<"NO"<<endl;
        return 0;
      }
      if(s[i+4] != 'e'){
        //cout<<'e';
        cout<<"NO"<<endl;
        return 0;
      }
      if(s[i+5]=='r'){
        if(s[i+6]=='a') i+=4;
        else i+=5;
       // break;
      }else{
        i+=4;
       // break;
      } 
    }else{
      cout<<"NO"<<endl;
      return 0;
    }    
  }
  cout<<"YES"<<endl;
  return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val mod = 1000000007
    val (N,X) = readIntList()
    val x = readLongList()

    var gcd = Math.abs(x[0]-X)

    for (y in x)
        gcd = gcd(gcd, Math.abs(y-X))

    println(gcd)
}

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

fun gcd(a:Long, b:Long):Long {
    if (a%b == 0L) return b
    return gcd(b, a % b)
}

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

int main(){
	char s[10];
  	cin >> s;
  	sort(s,s+4);
 	printf((s[0] ==s[1] &&s[1] !=s[2] &&s[2] ==s[3]) ? "Yes\n" : "No\n");
}


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

bool f[200020];

int main(){
  int n,m;
  cin >> n >> m;
  int p[m];
  string s[m];
  rep(i,m){
    cin >> p[i] >> s[i];
    p[i]--;
  }
  ll ac=0;
  ll wa[200020]={};
  ll x=0;
  rep(i,m){
    if(s[i]=="AC" && !f[p[i]]){
      ac++;
      f[p[i]]=true;
    }
    else if( s[i]=="WA" && !f[p[i]])wa[p[i]]++;
  }
  rep(i,n)if(f[i])x+=wa[i];
  cout << ac << ' ' << x << endl;
return 0;
}

Measured memory_bytes: 7808
import numpy as np
N, M, X = map(int, input().split())
data = np.array([list(map(int, input().split())) for i in range(N)], dtype=np.int64)

prices = data[:, 0]
effects = data[:, 1:]
 
ans_cands = []
# 2**N通りをchecl
for i in range(2 ** N):
    cur_costs = []
    cur_effects = np.zeros(M)
    # 現在の組み合わせでどの本を買ってるのかをcheck
    for j in range(N):
        if (i >> j) & 1:
            cur_costs.append(prices[j])
            cur_effects += effects[j, :]

    if np.all(cur_effects >= X):
        ans_cands.append(sum(cur_costs))

ans = min(ans_cands) if len(ans_cands) > 0 else -1
print(ans)

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

int main() {

    while(true){
    
        // 1. input end check.
        long long a, b;
        char op;
        cin >> a >> op >> b;
        
        if(op == '?') break;
        
        // 2. output answer.
        if(op == '+') cout << (a + b) << endl;
        if(op == '-') cout << (a - b) << endl;
        if(op == '*') cout << (a * b) << endl;
        if(op == '/') cout << (a / b) << endl;
    
    }
    
    return 0;
    
}


Measured memory_bytes: 3108
#include <stdio.h>

int main()
{
  int h,w,n;
  scanf("%d%d%d",&h,&w,&n);
  if (h > w)
  {
    if (n % h == 0)
      printf("%d",n/h);
    else
      printf("%d",n/h+1);
  }
  else
  {
    if (n%w == 0)
      printf("%d",n/w);
    else
      printf("%d",n/w+1);
  }
}

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

#define MAX_E 300
#define MAX_V 100
#define INF 1 << 28

struct edge {
    int to, cost;
    edge(int to, int cost) : to(to), cost(cost) {}
    void operator=(const edge& o) {
        to = o.to;
        cost = o.cost;
    }
};

typedef pair<int, int> P;

vector<edge> GTime[MAX_V];
int hour[MAX_V];
vector<edge> GMoney[MAX_V];
int money[MAX_V];
int V, E;

void shortest_path(int s) {
    priority_queue< P, vector<P>, greater<P> > q;
    fill(hour, hour+V, INF);
    fill(money, money+V, INF);
    hour[s] = 0;
    money[s] = 0;

    q.push(P(0, s));
    while (!q.empty()) {
        P p = q.top(); q.pop();
        int v = p.second;
        if (hour[v] < p.first) continue;
        for (int i = 0; i < GTime[v].size(); i++) {
            edge e = GTime[v][i];
            if (hour[e.to] > hour[v] + e.cost) {
                hour[e.to] = hour[v] + e.cost;
                q.push(P(hour[e.to], e.to));
            }
        }
    }

    q.push(P(0, s));
    while (!q.empty()) {
        P p = q.top(); q.pop();
        int v = p.second;
        if (money[v] < p.first) continue;
        for (int i = 0; i < GMoney[v].size(); i++) {
            edge e = GMoney[v][i];
            if (money[e.to] > money[v] + e.cost) {
                money[e.to] = money[v] + e.cost;
                q.push(P(money[e.to], e.to));
            }
        }
    }
}

int main() {
    while (cin >> E >> V) {
        if (E == 0 && V == 0) break;
        for (int i = 0; i < MAX_V; i++) {
            GTime[i].clear();
            GMoney[i].clear();
        }
        for (int i = 0; i < E; i++) {
            int a, b, _money, _hour;
            cin >> a >> b >> _money >> _hour;
            GTime[a-1].push_back(edge(b-1, _hour));
            GTime[b-1].push_back(edge(a-1, _hour));
            GMoney[a-1].push_back(edge(b-1, _money));
            GMoney[b-1].push_back(edge(a-1, _money));
        }
        int k; cin >> k;
        for (int i = 0; i < k; i++) {
            int from, to, qtype;
            cin >> from >> to >> qtype;
            shortest_path(from-1);
    //        for (int i = 0; i < V; i++) {
    //            cout << money[i] << ' ';
    //        } cout << endl;
    //        for (int i = 0; i < V; i++) {
    //            cout << hour[i] << ' ';
    //        } cout << endl;
    
            if (qtype == 0) {
                cout << money[to-1] << endl;
            } else {
                cout << hour[to-1] << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


int main(void) {
  ll X, K, D;
  cin >> X >> K >> D;

  bool is_minus = X < 0 ? true : false;

  ll x = X < 0 ? X * -1 : X;

  if (x / D >= K) {
    x = x - (D * K);
    if (is_minus) x *= -1;
    cout << abs(x) << endl;
    return 0;
  }

  ll xd = x / D;
  x -= D * xd;
  K -= xd;
  if (K % 2 != 0) {
    x -= D;
  }

  if (is_minus) x *= -1;

  cout << abs(x) << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>

using namespace std;

struct Info{
	int id,num;
};

bool isContain(int array[],int size,int id){
	for(int i=0; i < size; i++){
		if(array[i] == id)return true;
	}
	return false;
}

int main(){

	int member_num,n,table[21][21],num_of_smaller[21],first,second,fixed[21],fixed_index = 0,label = 100000,data_dealt_num = 0;

	scanf("%d",&member_num);
	Info member[member_num];
	stack<int> tmp_store;

	for(int i=1; i <= member_num; i++){
		for(int k=1; k <= member_num; k++)table[i][k] = 0;
		num_of_smaller[i] = 0;
		member[i-1].id = i;
		fixed[i-1] = 0;
	}

	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d %d",&first,&second);
		table[first][second] = 1;
		num_of_smaller[first]++;
	}

	for(int i = 1; i <= member_num; i++){
		if(num_of_smaller[i] == 0){
			fixed[fixed_index++] = i;
			member[i-1].num = label--;
			break;
		}
	}

	while(data_dealt_num < n){

		for(int i=1; i <= member_num; i++){
			if(isContain(fixed,fixed_index,i) == false){
				bool flg = true;
				for(int k= 1; k <= member_num; k++){
					if(table[i][k] == 1 && isContain(fixed,fixed_index,k) == false){
						flg = false;
						break;
					}
				}

				if(flg){
					tmp_store.push(i);
					data_dealt_num += num_of_smaller[i];
				}
			}
		}

		while(!tmp_store.empty()){
			fixed[fixed_index++] = tmp_store.top();
			member[tmp_store.top()-1].num = label;
			tmp_store.pop();
		}
		label--;
	}

	for(int i=1; i <= member_num-1; i++){
		for(int k=member_num-1; k >= i; k--){
			if(member[k].num < member[k-1].num)swap(member[k],member[k-1]);
		}
	}

	for(int i=0; i < member_num; i++){
		printf("%d\n",member[i].id);
	}

    return 0;
}

Measured memory_bytes: 2692
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	int ans=0;
	for(int i=a;i<=b;i++){
		if(i%c==0)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3592
// Best practice
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 
 
#define fbo find_by_order
#define ook order_of_key
 
signed main() {
   tezz
   
    string s1,s2;
    cin >> s1 >> s2;
    cout << s2 << s1;
    
   
   return 0;
}
 


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

deque<int> q;
int main(){
	int i,cnt=0;
	string s;
	cin>>s;
	for(i=0;i<s.size();i++){
		if(s[i]=='0'){
			q.push_back(0);
		}
		else if(s[i]=='1'){
			q.push_back(1);
		}
		else
			if(!q.empty()){
				q.pop_back();
			}
	}
	
	while(!q.empty()){
		cout<<q.front();
		q.pop_front();
	}
	return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n; i++)
#define P pair<ll, ll>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  ll ans = 1001001001;
  for(ll i = 0; i <= max(x, y) * 2; i += 2){
    ll A = max((ll)0, x - i/2) * a;
    ll B = max((ll)0, y - i/2) * b;
    ll AB = i * c;
    ans = min(ans, A+B+AB);
  }
  cout << ans << endl;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() {
  ll n, m;
  cin >> n >> m;
  vll a(m);
  rep(i,m) cin >> a[i];
  ll sum = 0;
  rep(i,m) sum += a[i];
  if(n>=sum) cout << n-sum << endl;
  else cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
double comp(pair<int,int>at){
	return(100.0*at.S/(double)(at.F+at.S));
}
int main(){
	int a,b,c,d,e,f;
	cin >>a>>b>>c>>d>>e>>f;
	pair<int,int>now=mp(0,0);//water,suger
	pair<int,int>ans=mp(100*a,0);
	double max=comp(mp(100,e));
	for (int ia = 0; ia*a * 100 <= f; ia++)
	{
		for (int ib = 0; (ia*a + ib*b) * 100 <= f; ib++)
		{
			now.F = (ia*a + ib*b) * 100;
			if (now.F == 0)
			{
				break;
			}
			for (int ic = 0; now.F + ic*c <= f; ic++){
				for (int id = 0; now.F + ic*c + id*d <= f; id++){
					now.S =ic*c+ id*d;
					if (comp(now) > max)
					{
						break;
					}
					if (comp(now) > comp(ans))
					{
						ans = now;
					}
				}
			}
		}
	}
	cout<<ans.F+ans.S<<" "<<ans.S<<endl;
}

Measured memory_bytes: 3592
package main
 
import (
	"fmt"
	"os"
)

func main() {
	var a int
	var b string
	var o string
	fmt.Scan(&a)
	fmt.Scan(&b)
	if a % 2 != 0 {
		fmt.Print("No")
		os.Exit(0)
	}
	f := a / 2
	var lists string
	for i, v := range b{
		lists += string(v)
		if i + 1 == f {
			break
		}
	}
	lists = lists + lists
	if b == lists {
		o = "Yes"
	} else {
		o = "No"
	}
	fmt.Print(o)
}

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int H[1000];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	int N, T, A, ans = 0;
	cin >> N >> T >> A;
	A = (T - A) * 1000;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
		if (abs(A - 6 * H[ans]) > abs(A - 6 * H[i])) {
			ans = i;
		}
	}
	cout << ans + 1 << '\n';
	return 0;
}

Measured memory_bytes: 256