akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if(x->right != NIL) return treeMinimum(x->right);
  Node *y = x->parent;
  while(y != NIL && x == y->right) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y; // 削除する対象
  Node *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  if(y->left != NIL) {
    x = y->left;
  } else {
    x = y->right;
  }

  if(x != NIL) {
    x->parent = y->parent;
  }

  if(y->parent == NIL) {
    root = x;
  } else {
    if(y == y->parent->left) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if(y != z) {
    z->key = y->key;
  }
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;
  
  z = (Node *)malloc(sizeof(Node));
  z->key   = k;
  z->left  = NIL;
  z->right = NIL;
  
  while(x != NIL) {
    y = x;
    if(z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL) {
    root = z;
  } else {
    if( z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

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

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}


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

int main() {
	int N, M, X, Y, x, y, xMax = -101, yMin = 101;
	cin >> N >> M >> X >> Y;
	for (int i = 0;i < N;++ i) {
		cin >> x;
		xMax = xMax > x ? xMax : x;
	}
	for (int i = 0;i < M;++ i) {
		cin >> y;
		yMin = yMin < y ? yMin : y;
	}
	cout << (xMax < yMin && X < yMin && xMax < Y ? "No " : "") << "War";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

xに関しては最大のみ、yに関しては最小のみ考えれば良くて、後は場合分けで終わる
要はxMax, X < Z ≦ Y, yMinとなるので、X<Yは与えられてるから後の3つを比較すれば良い
*/

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

using namespace std;
typedef unsigned int INT;
typedef unsigned long long LONG;
typedef long long LL;
#define Foru(i, a, b) for(LONG i=(a);i<(b);++i)
#define Forl(i, a, b) for(LL i=(a);i>=(b);--i)
#define pb emplace_back
#define ft first
#define sd second
const int N = 100000 + 5;
const int INF = 0x3f3f3f3f;
const int MAXINT = 2147483647;
const int mod = 1000000007;
const long long MAXLONG = 9223372036854775807;
typedef pair<int, int> PII;

//读入输出外挂，只适用于整数，使用时流同步打开，C语言不准关流
//getchar()<<cin(关流)<<scanf()<<cin
template<class T>
inline bool read(T &ret) {
    char c;
    int sgn;
    if (static_cast<void>(c = getchar()), c == EOF) return 0;
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (static_cast<void>(c = getchar()), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//输出只能用于正整数
template<class T>
inline void write(T x) {
    if (x > 9) write(x / 10);
    putchar(x % 10 + '0');
}

int getlen(int x) {
    int ans = 0;
    if (x == 0) ans++;
    while (x) {
        ans++;
        x /= 10;
    }
    return ans;
}

void slove(int question_num) {
    while (question_num--) {
        map<int, int> s;
        int n, m, flag = 1;
        cin >> n >> m;
        for (int i = 1; i <= m; ++i) {
            int a, b;
            cin >> a >> b;
            if (!s.count(a) || (s[a] == 0 && b == 0)) {
                s[a] = b;
            } else if (s[a] != b) flag = 0;
        }
        int fin = 1, put = 0;
        if (flag)
            for (int i = 0; i < 1000; ++i) {
                int len = getlen(i);
                if (len > n) break;
                else if (len < n) continue;
                else {
                    int a[5] = {0};
                    int w = i;
                    while (w) {
                        a[len--] = w % 10;
                        w /= 10;
                    }
                    for (auto k:s) {
                        if (a[k.first] != k.second) {
                            fin = 0;
                        }
                    }
                    if (fin && !put)
                        cout << i, put = 1;
                    fin = 1;
                }
            }
        if (!flag) cout << -1;
        else if (!put) cout << -1;
    }
}

int main() {
    //ios::sync_with_stdio(false);
    int num = 1;
    //    read(num);
    slove(num);
    return 0;
}


Measured memory_bytes: 256
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)*/

#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <bitset>  // std::bitset<N>
#include <sstream> //stringstream
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
//ここから書き始める

int main(){
	/*両端が違う文字だと、繰り返しごとに干渉を受けない
	両端が同じ文字だと繰り返しごとに干渉を受ける
	全部同じ文字の時は、文字数*繰り返し数
	*/
	int one=1;//文字の種類が一つだけ
	string s; cin >> s;
	ll ans = 0;
	ll k ; cin >> k;
	ll n = s.size();//文字列のサイズ
	//一種類かどううか
	if(n==1) one = 1;
	else {
		rep(i,n-1){
			if(s[i+1]!=s[i]){//一種類じゃないならone = 0 (no)
				one = 0 ;
				break;
			}
		}
	}	
		ll count = 0;
	if(one){
		ans = n * k / 2;
	}
		//両端が同じ文字
	else if(s[0] == s[n - 1]){
		s+=s;
		rep(i,n*2-1){
			if(s[i+1]==s[i]){
				s[i+1]='A';
				count++;
			}
		}
		if(count%2!=0){
			count++;
			ans = count / 2 * k-1;
		}
		else{
			ans =count/2 *k;
		}
	}
	else{
		rep(i,n-1){
			if(s[i+1]==s[i]){
				s[i+1]='A';
				count++;
			}
		}
		ans = count * k;
	}
	cout<<ans<<endl;
	}






Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String S = sc.nextLine();
    
    int n = S.length();
    char c1 = S.charAt(0);
    int ans = 1;
    for(int i = 1; i < n; i++){
      char c2 = S.charAt(i);
      if(i == n-1 && c1 == c2){
        break;
      }
      
      if(c1 == c2){
        i++;
        ans++;
        c1 = '.';
        continue;
      }
      ans++;
      c1 = c2;
    }
    System.out.println(ans);
  }
}
    

Measured memory_bytes: 26956
#include<iostream>
using namespace std;
int main()
{

  int n;
  int h[105];
  int ans=0;
  cin >> n; 

  h[0]=0;

  for( int i=1;i<=n;i++ ){
    cin >> h[i];
    if( h[i] > h[i-1] ){
      ans+=h[i]-h[i-1];
    }
  }

  cout << ans << endl;
  return(0);

}


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

using namespace std;

int main()
{
    long long a;
    long long sum=0,sum2=100;
    cin>>a;
    while (sum2 < a){
        sum2 += sum2/100;
        sum++;
    }
    cout << sum<<endl;

    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct mint {
	ll x;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
	assert(n < mod);
	fact[0] = 1;
	for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
	ifact[n] = fact[n].inv();
	for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
	if (k < 0 || k > n) return 0;
	return fact[n]*ifact[k]*ifact[n-k];
  }
};

combination comb(3000010);

mint solve(int x,int y){
	mint ret=comb(x+y+2,x)*(y+2)-x-1;
	ret/=mint(x+1);
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> r(2),c(2);
	cin>>r[0]>>c[0]>>r[1]>>c[1];
	mint ans=solve(r[1],c[1])-solve(r[1],c[0]-1)-(solve(r[0]-1,c[1])-solve(r[0]-1,c[0]-1));
	cout<<ans.x<<endl;
}

Measured memory_bytes: 47104
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  int big=a[0];
  for(int i=0;i<n;i++){
    if(a[i]>big)big=a[i];
  }
  int ideal_1=big/2;
  int ideal_2=(big+1)/2;
  int diff_1=abs(ideal_1);
  int diff_2=abs(ideal_2);
  int target_1=0;
  int target_2=0;
  int target;
  for(int i=0;i<n;i++){
    if(abs(ideal_1-a[i])<diff_1){
      diff_1=abs(ideal_1-a[i]);
      target_1=a[i];
    }
    if(abs(ideal_2-a[i])<diff_2){
      diff_2=abs(ideal_2-a[i]);
      target_2=a[i];
    }
  }
  if(diff_1<diff_2 && target_1 != big)target=target_1;
  if(diff_1>=diff_2 && target_2 != big)target=target_2;
  cout<<big<<" "<<target;
  return 0;
}

Measured memory_bytes: 768
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}

a,b=map(int,input().split())
if a<=8 and b<=8:
    print("Yay!")
else:
    print(":(")

Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
 int i,x[4],y[4];

 for(i=0;i<2;i++){
 scanf("%d %d",&x[i],&y[i]);
 }
 for(i=2;i<4;i++){
 x[i]=x[i-1]+y[i-2]-y[i-1];
 y[i]=-x[i-2]+x[i-1]+y[i-1];
 printf("%d %d ",x[i],y[i]);
 }
 return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1); vector<ll> pw10(19,1);
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll mid(ll x,ll y,ll z){return x>y?y>=z?y:min(z,x):x>=z?x:min(y,z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll myceil(ll x,ll y){if(x<=y) return 1;else if(x%y==0) return x/y;else return x/y+1;}

//a,b x
int main(){
	//rep1(i,50) pw2[i]=2*pw2[i-1];
	//rep1(i,18) pw10[i]=10*pw10[i-1];
	ll N,M; cin>>N>>M;
	cout<<maxx(N+M,N-M,N*M);
		
}

Measured memory_bytes: 256
'use strict';
const x = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = x.split(/\n/);

for (let i = 0; i < lines.length ; i++) {
  const arr = lines[i].split(/\s/).map(Number);
  if ((arr[0]===0)&&(arr[1]===0)) break;

  for (let i = 0; i < arr[0]; i++){
    if ((i===0)||(i===arr[0]-1)){
      for (let j= 0; j < arr[1]; j++){
        process.stdout.write('#');
      }
      console.log();
    }
    else {
      process.stdout.write('#');
      for (let j=1; j < arr[1]-1; j++){
        process.stdout.write('.');
      }
      console.log('#');
    }
  }
    console.log();
}




Measured memory_bytes: 30076
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int w, n;
  while (cin >> w >> n) {
    vector<int> vec;
    for (int i = 0; i < w; ++i) {
      vec.push_back(i + 1);
    }
    for (int i = 0; i < n; ++i) {
      int a, b;
      scanf("%d,%d", &a, &b);
      a -= 1;
      b -= 1;
      int tmp = vec[a];
      vec[a] = vec[b];
      vec[b] = tmp;
    }
    for (int i = 0; i < vec.size(); ++i) {
      cout << vec[i] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
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; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ll N;
  cin >> N;
  priority_queue<ll> que;
  for(int i = 0; i < N; i++){
    ll L;
    cin >> L;
    que.push(L);
  }
  ll longest = que.top(); que.pop();
  ll other = 0;
  while(!que.empty()){
    other += que.top();
    que.pop();
  }
  if(longest < other) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);


int main() {
	int a,b;
	cin >> a >> b;
	if(a == b) cout << a + b << endl;
	else cout << max(a,b)*2-1 << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, bisect
sys.setrecursionlimit(300000)


def solve(N: int, L: "List[int]"):
    ret = 0
    L.sort()
    for i in range(N):
        for j in range(i + 1, N):
            mx = L[i] + L[j] - 1
            r = bisect.bisect_right(L, mx)
            cnt = max(0, r - j - 1)
            ret += cnt
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    L = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, L)

if __name__ == '__main__':
    main()


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);

template<long P = 1000000007>
class Mod {
public:
  Mod() : a(0) {}
  Mod(long x) : a(x) {}
  long get() { return a; }
  Mod operator + (Mod x) { return Mod<P>((a + x.get()) % P); }
  Mod operator += (Mod x) { a = (a + x.get()) % P; return *this; }
  Mod operator - (Mod x) { return Mod<P>((a + P - x.get()) % P); }
  Mod operator -= (Mod x) { a = (a + P - x.a) % P; return *this; }
  Mod operator * (Mod x) { return Mod<P>((a * x.get()) % P); }
  Mod operator *= (Mod x) { a = (a * x.a) % P; return *this; }
  Mod operator / (Mod x) { return *this * pow(x, P - 2); }
  Mod operator /= (Mod x) { a = (*this * pow(x, P - 2)); return *this; }
private:
  long a;
};

template<typename T>
T pow(T x, long n) {
  T res = 1;
  T p = x;
  while( n != 0 ) {
    if( n & 0x01 ) res *= p;
    p *= p;
    n >>= 1;
  }
  return res;
}

long xs[112345];
long n;

long solve() {
  Mod<> x = 1;
  long c = 0;
  long rem = n;
  for(long i = 1; i < n; ++i) {
    c += 1;
    if( i == 1 ) continue;
    if( c > (xs[i] + 1) / 2 ) {
      fprintf(stderr, "k  = %ld\n", std::min(c, rem));
      x = x * std::min(c, rem);
      rem -= 1;
      while( c > (xs[i] + 1) / 2 ) {
        c -= 1;
      }
    }
  }
  while( rem != 1 && rem != 0 ) {
    x *= rem;
    fprintf(stderr, "k' = %ld\n", rem);
    rem -= 1;
  }      
  return x.get();
}

int main() {
  scanf("%ld", &n);
  for(int i = 1; i <= n; ++i) {
    scanf("%ld", &xs[i]);
  }
  Mod<> x = 1;
  for(long i = 1; i <= n - 1; ++i) {
    x *= i;
  }
  long t = solve();
  printf("%ld\n", t);  
  return 0;
}

Measured memory_bytes: 1024
# Youtubeをみて作りましょう


N, M = map(int, input().split())

request_list = []

for i in range(M):
    request_list.append(list(map(int,input().split())))
    
request_list.sort(key=lambda x: x[1])

ans = 0
f = False

while True:
    ans += 1
    end_point = request_list[0][1]
    for i in range(len(request_list)):
        if request_list[0][0] < end_point:
            del request_list[0]
            if len(request_list) == 0:
                f = True
                break
        else:
            break
            
            
    
    if f:
        break
    
print(ans)



Measured memory_bytes: 29564
#include<iostream>
 
using namespace::std;
 
int ar[100005];
 
int main(){
	int n;
  	cin>>n;
  	for(int i=0,t;i<n;i++)
    	cin>>t,ar[t]=i+1;
  	for(int i=1;i<=n;i++)
      	cout<<ar[i]<<' ';
  	cout<<'\n';
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1LL)


void solve(){
  int n;ll m, ans=0;
  cin >> n >> m;
  vector<int> a(n,0);vector<ll> sum(n,0);
  RPT(i,0,n) cin >> a[i];
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  sum[0] = a[0];
  FOR(i,1,n) sum[i] = sum[i-1] + a[i];
  ll l = 0, r = ((ll)a[0])*n+10, mm;
  auto F = [&](ll x, bool flg){
    ll fl = 0, fr;ll num = 0;
    if(flg) ans = 0;
    while(2*a[fl]>=x){
      fl++;
      if(fl==n) break;
    }
    fl--;
    fr = fl;
    for(;fl>=0;--fl){
      while(a[fl]+a[fr]>=x){
        fr++;
        if(fr==n) break;
      }
      fr--;
      num += 2*(fr-fl)+1;
      if(flg) ans += 2*(sum[fr]-sum[fl]) + 2*a[fl]*(fr-fl+1);
    }
    return num;
  };
  while(r-l>1){
    mm = (l+r) / 2;
    ll tmp = F(mm, false);
    if(m>tmp) r = mm;
    else l = mm;
  }
  ll tmp = F(r,true);
  ans += l*(m-tmp);
  cout << ans << endl;
}

int main(){
  solve();
  return 0;
}

Measured memory_bytes: 1408
n = int(input())
l = list(map(int,input().split()))


def selectionSort(A,n):
    count = 0
    for i in range(n):
        minj = i
        
        for j in range(i,n):
            if A[j] < A[minj]:
                minj=j
        A[i],A[minj]=A[minj],A[i]
        count = count + int( i != minj)
    return count

count=selectionSort(l,n)

print(' '.join(map(str,l)))
print(count)


Measured memory_bytes: 5600
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {
    int N = 0;
    int temp = 0;
    int D[100][2];
    cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 2; j++) {
            cin >> D[i][j] ;
        }
    }
    for (int i = 0; i < N - 2; i++) {
        if (D[i][0] == D[i][1]) {
            if (D[i + 1][0] == D[i + 1][1]) {
                if (D[i + 2][0] == D[i + 2][1]) {
                    cout << "Yes";
                    return 0;
                }
            }
        }


    }
    cout << "No";

    return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
        double a, b ,C;
        cin >>a >> b >>C;
        double C_r = C * M_PI /180;
        double c = pow( (pow(a,2)+pow(b,2)-(2.0*a*b*cos(C_r))),0.5);
        double S = (a * b * sin(C_r)) /2;
        double L = a + b + c;
        double h = S / a * 2;
        cout << fixed << S <<" "<< L<< " "<< h  <<endl;

        return 0;
}


Measured memory_bytes: 3568
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACoffee solver = new ACoffee();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACoffee {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            String[] arr = s.split("");
            if (arr[2].equals(arr[3]) && arr[4].equals(arr[5])) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }

    }
}



Measured memory_bytes: 21844
n=int(input())
h=[1,6,6**2,6**3,6**4,6**5,6**6,9,9**2,9**3,9**4,9**5,9**6]
dp=[10**9]*(n+1)

dp[0]=0
for i in range(n):
    for j in range(len(h)):
        if i+h[j]<=n:
            dp[i+h[j]]=min(dp[i+h[j]],dp[i]+1)
    
print(dp[n])

Measured memory_bytes: 42092
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
#define IO ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);
typedef long long ll;
typedef long double ld;
 

 
ll MOD=1e9 + 7;
ll OO=1e9 + 10;
const int N=20 + 1,M=1e5 + 5;
int arr[N][N];
int dp[N][(1<<21)];



int n,m,k,cnt,SU,idx,len,MN,MX,T;
int l,r,mid;
int a,b,c;
string str,t;

int Solve(int idx,int mask){
	if(idx == n)
		return 1;
	
	int &ret = dp[idx][mask];
	if(~ret)
		return ret;
	ret = 0;
	
	for(int i=0;i<n;++i){
		if(arr[idx][i] && !(mask&(1<<i))){
			ret+= Solve(idx+1,mask|(1<<i));
			ret%=MOD;
		}
	}
		
	
	return ret;
}


int main(){
	
	IO
	memset(dp,-1,sizeof dp);
	
	cin>>n;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			cin>>arr[i][j];
	
	cout<<Solve(0,0)<<endl;

	
}


Measured memory_bytes: 175652
import Data.List

main :: IO ()
main = mapM_ putStrLn $ solve

solve :: [String]
solve = foldr ff [] $ zip a b
    where
        a = foldr (\x acc -> replicate 9 x ++ acc) [] [1..9]
        b = cycle [1..9]

ff :: (Int, Int) -> [String] -> [String]
ff (a, b) acc = (show a ++ "x" ++ show b ++ "=" ++ show (a * b)) : acc

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define ll long long
#define endl "\n"
#define vi vector<int>
#define vl vector<ll>
#define all(v) (v).begin(),(v).end()
#define mst(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mt make_tuple
#define eb emplace_back
using namespace std;
const int N=1e3+5,mod=998244353;
const ll inf=3e18;
void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(1){
        c=c-b;
        if(c<=0){cout<<"Yes"<<endl;return;}
        a=a-d;
        if(a<=0){cout<<"No"<<endl;return;}
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll t,p;
    t=1;
    //cin>>t;
    for(p=1;p<=t;p++){
        solve();
    }
    return 0;
}


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

int main(void){
	int n;

	while(cin>>n && n){
		int ansmax = 0, ansmin=1000;
		while(n--){
			int sum = 0;
			for(int i=0;i<5;i++){int x;cin>>x;sum+=x;}
			ansmax = max(ansmax,sum);
			ansmin = min(ansmin,sum);
		}
		cout<<ansmax<<" "<<ansmin<<endl;
	}

	return 0;
}

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

int main(){
int a,b,c;
    cin >> a >> b >> c;
    cout << c <<" "<< a <<" "<< b << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
X = [[0]*W for _ in range(H)]
Y = [[0]*W for _ in range(H)]
S = [input() for _ in range(H)]
for y, s in enumerate(S):
    for x, c in enumerate(s):
        if c==".":
            X[y][x] = X[y][x-1] + 1
    vp = X[y][-1]

    for x in range(W-2, -1, -1):
        v = X[y][x]
        if v != 0:
            v = X[y][x] = max(v, vp)
        vp = v

for x in range(W):
    for y in range(H):
        c = S[y][x]
        if c==".":
            Y[y][x] = Y[y-1][x] + 1

    vp = Y[-1][x]
    for y in range(H-2, -1, -1):
        v = Y[y][x]
        if v != 0:
            v = Y[y][x] = max(v, vp)
        vp = v

ans = 0
for x, y in zip(X, Y):
    for xx, yy in zip(x, y):
        ans = max(ans, xx+yy)
print(ans-1)


Measured memory_bytes: 125404
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;

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

    REP(i, s.size())
        if (i%2 == 0)
            cout << s[i];
    cout << endl;
}

Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int X, Y;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> X >> Y;
  if (X%Y == 0) {
    cout << -1 << "\n";
  }
  else {
    cout << X << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

bool dp[10000001];

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

	ll n, k;
	cin>>n>>k;
	ll a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<=k;i++){
		for(int j=0;j<n;j++){
			if(i >= a[j] && dp[i-a[j]] == false){
				dp[i] = true;
			}
		}
	}
	if(dp[k]) cout<<"First";
	else cout<<"Second";
	return 0;
}




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

int main () {
  int X, A, B;
  cin >> X >> A >> B;
  
  if (A >= B) {
    cout << "delicious" << endl;
  }
  else {
    if (B - A <= X) {
      cout << "safe" << endl;
    }
    if (B - A >= X + 1) {
      cout << "dangerous" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a, b;
	int i, c, g;
	
	
	c = 0;
	while(scanf("%d %d", &a, &b) != -1){
		g = a + b;
		for(i = 0; g != 0; i++)
		g /= 10;
		printf("%d\n", i);
	}
	return 0;
}	

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
	int x = 0,f = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar())if(ch == '-')f = -f;
	for(;isdigit(ch);ch = getchar())x = 10 * x + ch - '0';
	return x * f;
}
const int maxn = 1e5 + 10;
int n,k,ans;
int a[maxn],dep[maxn];
vector<int> G[maxn];
inline int dfs(int x,int fa)
{
	dep[x] = dep[fa] + 1;
    int mx = dep[x];
    for(auto to : G[x])mx = max(dfs(to,x),mx);
    if(x == 1)return 0;
    if(fa != 1 && mx - dep[x] + 1 == k) ans++,mx = 0;
    return mx;
}
int main()
{
	n = read(),k = read();
	for(int i=1;i<=n;i++)
	{
		a[i] = read();
		if(i != 1)G[a[i]].push_back(i);
	}
	if(a[1] != 1)ans++;
	dep[0] = -1;
	dfs(1,0);
	printf("%d",ans);
}

Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#include <typeinfo>
#include <numeric>
#include "math.h"
#include <string>
#include <vector>
#include <iomanip>

#define pai 3.14159265358979323846264338327950288
using namespace std;

// Strings
//*
int main() {
	string s, t;
	cin >> s >> t;
	cout << t + s;
}


//*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int A,B;
    cin >> A >>B;
    if(B == 1){       
        cout << 0 << endl;
    }
    else if (A >= B){
        cout << 1 << endl;
    }
    else {
        if((B-A)%(A-1)==0){
         cout << (B-A)/(A-1)+1<< endl;
        }
        else if ((B-A)-(A-1)<0){
            cout << 2 <<endl;
        }
        else{
            cout << (B-A)/(A-1)+2 <<endl;
        }
      
     }

}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	vector<int>p(N);

	for (int i = 0; i < N; i++) {
		cin >> p[i];
	}
	sort(p.rbegin(), p.rend());
	int sum = p[0] / 2;

	for (int i = 1; i < N; i++) {
		sum += p[i];
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<double, double> pdd; typedef pair<long long, long long> pll;
#define has_bit(bit_mask, x) ((bit_mask) & (1ULL << (x)))
#define turn_on_bit(bit_mask, x) (bit_mask |= (1ULL << (x)))
#define turn_off_bit(bit_mask, x) (bit_mask &= (~(1ULL << (x))))
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define arrReplace(arr, from, to) for (auto &x : arr) if (x == from) x = to;
#define INF (1LL<<30)
#define INF32 (1LL<<62)
#define F first
#define S second
#define M_PI 3.14159265358979323846
inline int ceil(int a, int b) { return (a+b-1)/b; }
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
int str_replace(string& str, const string& from, const string& to, int limit = -1) { if(from.empty()) return 0; size_t start_pos = 0; int cnt = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); cnt++; if (cnt == limit) break; } return cnt; }
#define MOD 1000000007

signed main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string str;
	cin >> str;
	int a = stoi(str.substr(0, 2)), b = stoi(str.substr(2, 2));
	bool a_m = (a > 0 && a <= 12), b_m = (b > 0 && b <= 12);
	if ((!a_m && !b_m)) cout << "NA\n";
	else if (a_m && b_m) cout << "AMBIGUOUS\n";
	else
	{
		if (a_m) cout << "MMYY\n";
		else cout << "YYMM\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main( )
{
    int n , num[100] , count = 0  , i ;
    scanf("%d" , &n);
    
    for( i = 1 ; i <= n ; i++)
        scanf("%d" , &num[i]);
    
    for( i = 1 ; i < n-1 ; i++)
    {
        if( num[i] < num[i+1])
        {
            if( num[i+1] < num[i+2])
                count++ ;
        }
        
        else if( num[i] > num[i+1] )
        {
                if( num[i+1] > num[i+2])    
                    count++ ;
        }
    }
    
    printf("%d\n" , count);
    
    return 0 ;
}


Measured memory_bytes: 1720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;


struct prime_n {
  int p = -1;
  bool isPrime = true;
};

int struct_prime(vector<prime_n>&primes) {
  primes[0].isPrime = false;
  primes[1].isPrime = false;
  int cnt = 0;
  for (int i = 0; i < primes.size(); i++) {
    if (!primes[i].isPrime) continue;
    primes[i].p = i;
    cnt++;
    for (int k = 2 * i; k < primes.size(); k += i) {
      primes[k].isPrime = false;
    }
  }
  return cnt;
}

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

  ll n;
  cin >> n;

  vector<prime_n> primes((int)sqrt(n)+1);
  int cnt = struct_prime(primes);

  ll ans = 0;

  ll ntemp = n;
  for (int i = 2; i < primes.size(); i++) {
    if (primes[i].isPrime && (ntemp % i == 0)) {
      int c = 1, t = 0;
      while (ntemp % i == 0) {
        ntemp /= i;
        t++;
        if (c == t) {
          ans++;
          t = 0;
          c++;
        }
      }
    }
  }
  if (ntemp != 1) ans++;

  cout << ans << endl;
  
}

Measured memory_bytes: 11132
sL = [list(input()) for _ in range(3)]
i = 0
while len(sL[i])>0:
    i = sL[i].pop(0)
    if i == "a":
        i=0
    elif i == "b":
        i=1
    else:
        i=2
if i == 0:
    i="A"
elif i == 1:
    i="B"
else:
    i="C"
print(i)

Measured memory_bytes: 38256
#http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_5_B&lang=jp
def merge(target_list, left_index, mid_index,right_index):
    sentinel = pow(10,9) + 1
    l = target_list[left_index:mid_index] + [sentinel]
    r = target_list[mid_index:right_index] + [sentinel]
    l_target = 0
    r_target = 0
    count = 0
    #print(left_index, right_index, mid_index, l,r)
    for k in range(left_index, right_index):
        count += 1
        if l[l_target] < r[r_target]:
            target_list[k] = l[l_target]
            l_target += 1
        else:
            target_list[k] = r[r_target]
            r_target += 1

    return count
    #print(target_list)
            
def merge_sort(target_list, left_index, right_index):
    count = 0
    if left_index + 1 < right_index:
        mid_index = (left_index + right_index) // 2

        count += merge_sort(target_list, left_index, mid_index)
        count += merge_sort(target_list, mid_index, right_index)
        count += merge(target_list, left_index, mid_index,right_index)
        
    return count
if __name__ == "__main__":
    l = input()
    target_list = [int(a) for a in input().split()]
    count = merge_sort(target_list, 0, len(target_list))
    print(" ".join([str(n) for n in target_list]))
    print(count)

Measured memory_bytes: 68944
#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()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    string s;
    cin>>n>>s;
    int R[20000],B[20000],G[20000];
    int r=0,b=0,g=0;
    ll ans=0;
    rep(i,n){
        if(s[i]=='R') r++;
        if(s[i]=='G') g++;
        if(s[i]=='B') b++;
        R[i]=r;
        G[i]=g;
        B[i]=b;
    }
    rep(i,n)for(int j=i+1;j<n-1;j++){
        if(s[i]=='R'){
            if(s[j]=='B'){
                ans+=g-G[j];
                if(2*j-i<n&&s[2*j-i]=='G') ans--;
            }
            if(s[j]=='G'){
                ans+=b-B[j];
                if(2*j-i<n&&s[2*j-i]=='B') ans--;
            }
        }
        if(s[i]=='G'){
            if(s[j]=='R'){
                ans+=b-B[j];
                if(2*j-i<n&&s[2*j-i]=='B') ans--;
            }
            if(s[j]=='B'){
                ans+=r-R[j];
                if(2*j-i<n&&s[2*j-i]=='R') ans--;
            }
        }
        if(s[i]=='B'){
            if(s[j]=='R'){
                ans+=g-G[j];
                if(2*j-i<n&&s[2*j-i]=='G') ans--;
            }
            if(s[j]=='G'){
                ans+=r-R[j];
                if(2*j-i<n&&s[2*j-i]=='R') ans--;
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int N,num=1,num2=0;
   cin >> N;
   vector<string> Blue(N);
    for (int i = 0; i < N; i++) {
      cin >> Blue.at(i);
    }

   int M;
   cin >> M;
   vector<string> Red(M);
    for (int ii = 0; ii < M; ii++) {
     cin >> Red.at(ii);
     }
    
   for (int j = 0; j < N ;j++){
     for (int jj = 1;jj < (N);jj++ ){
      if (Blue.at(j)==Blue.at (jj)){
       num ++; 
      }
     }
     for (int k = 0;k < (M);k++ ){
      if (Blue.at(j)==Red.at(k)){
        num -- ;  
     	 }
 	   }
     if (num2 < num ){
      num2 = num;
    	} 
     num =0;
    }
  	if (num2<0){
  	num2 =0;
  				}
       cout << num2<< endl;
   }

Measured memory_bytes: 3652
// https://atcoder.jp/contests/abc176/tasks/abc176_a

#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;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

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

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

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

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

const ll INF = 1e18;

void solve();

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

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

  return 0;
}
#endif

void solve() {
  ll N, X, T;
  cin >> N >> X >> T;
  ll res = (N + X - 1) / X * T;
  cout << res << "\n";
}


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

const int mod = 1000000007;
const int MAX_N = 100005;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

/*
int field[MAX_N][MAX_N]={-1};

int f(int x,int y){
    if(field[x][y]!=-1) return field[x][y];

    if(x<=0||y<=0) return 0;
    else return field[x][y] = (field[x-2][y-1] + field[x-1][y-2])%mod;
}

int main(void){
    int x,y;
    cin >> x >> y;

    cout << f(x,y) << endl;
}*/

int main(void){
    int x,y;
    cin >> x >> y;

    int vec12 = 0, vec21 = 0;
    while(x!=0 && y!=0){
        if(x<=y){
            x -= 1; y -= 2;
            vec12++;
        }else{
            x -=2; y -= 1;
            vec21++;
        }
    }
    if(x!=0 || y!=0){cout << 0 << endl; return 0;}

    int n = vec12+vec21;
    int r = min(vec12,vec21);
    mint ans = 1;
    for(int i=0;i<r;i++){
        ans *= n-i;
        ans /= r-i;
    }
    cout << ans << endl;
}

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

#include <numeric>
#include <vector>
#include <algorithm>

int main()
{
	int n;
	std::vector<int64_t> a(10000);
	std::cin >> n;
	for (int i = 0; i < n; i++)
	{
		std::cin >> a[i];
	}
	std::int64_t sum = 0;
	/*auto [min, max]*/auto minmax = std::minmax_element(a.begin(), a.begin() + n);
	sum = std::accumulate(a.begin(), a.end(), (std::int64_t)0);
	printf("%lld %lld %lld\n", *minmax.first, *minmax.second, sum);
}


Measured memory_bytes: 3300
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>

using namespace std;
typedef long long ll;

int main()
{
	string S;
	cin >> S;
	auto ri = S.rfind("FESTIVAL");
	S.erase(ri);
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
(function() {
    'use strict';
 
    var lines = [];
    require('readline').createInterface({
      input: process.stdin,
      output: process.stdout
    }).on('line', function(line) {
      lines.push(line);
    });
    process.stdin.on('end', function() {
      //lines.forEach(function(line) {
        //var tokens = line.split(' ').map(Number);
        //    console.log(tokens[0] + ' ' + tokens[1]);
      //}
      //)
      ;
      
    // ToDo start
      var A = lines[0].split(" ")
      if ( A[0] == A[1]){
        console.log( A[2])
      }else if(A[0] == A[2] ){
        console.log( A[1])
      }else{
        console.log( A[0] )
      }
    // ToDo end

    });

    
})();
  
  

Measured memory_bytes: 7628
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long ans = 0;
    for(int i=1;i<=n;i++){
        if(i%3 != 0 && i%5 != 0){
            ans += i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
	int N, d[100005];

	cin >> N;

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

	sort(d, d + N);

	cout << d[N / 2] - d[N / 2 - 1] << endl;

	return 0;
}


Measured memory_bytes: 640
program name
    implicit none
    integer(4):: n,k
    integer(4):: i,wnum
    real(8):: ans
    read*, n,k
    ans=0
    do i=1, n
        wnum=0
        do while(i*2**wnum < k)
            wnum = wnum + 1
        end do
        ans=ans+ 1d0/dble(n) * (0.5d0)**wnum
    end do

    print*, ans
end program name

Measured memory_bytes: 640