akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <list>
#include <cmath>
#include <stack>
#include <queue>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using namespace std;

const int mod = 1000000007;
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 {
		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) {
		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];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	if (n % 2 != 0)
	{
		cout << "No";
		return 0;
	}
	for (int i = 0; i < n / 2; i++)
	{
		if (s[i] != s[n / 2 + i])
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 31488
import java.util.Scanner;

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

        char[] s = sc.next().toCharArray();
        char[] t = sc.next().toCharArray();

        boolean flag = false;
        int i = s.length - t.length;
        for(i = s.length - t.length; i >= 0; i--) {
            flag = true;
            for(int j = 0; j < t.length; j++) {
                if(!(s[i + j] == '?' || s[i + j] == t[j])) {
                    flag = false;
                    break;
                }
            }
            if(flag) break;
        }

        if(flag) {
            for(int j = 0; j < s.length; j++) {
                if(s[j] == '?') {
                    if(i <= j && j < i + t.length) s[j] = t[j - i];
                    else s[j] = 'a';
                }
            }
            System.out.println(String.valueOf(s));
        }else {
            System.out.println("UNRESTORABLE");
        }

        sc.close();
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,k[100005],l[100005];
  cin>>a>>b;
  vector<bool>v(a,false);
  vector<int>many(a,1);
  v[0]=true;
  for(int i=0;i<b;++i){
    cin>>k[i]>>l[i]; 
    if(v[k[i]-1])v[l[i]-1]=true;
    many[k[i]-1]--;
    many[l[i]-1]++;
    if(many[k[i]-1]==0)v[k[i]-1]=false;
  }
  int ans=0;
  for(int i=0;i<a;++i){
    if(v[i])ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1408
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <algorithm>
#define brijesh ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pb push_back
#define popb pop_back
#define l1 long long
#define vi vector<int>
#define vl vector<l1>
#define vs vector<string>
using namespace std;
int main() {
    brijesh;
    l1 a,b;
        cin>>a>>b;
        if(500*a<b)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
}

Measured memory_bytes: 3636
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val a = readLine()!!
    val b = readLine()!!
    val c = readLine()!!
    var cnt = 0
    for(i in 0..(n - 1)){
        if(a[i] != b[i]){
            cnt++
            if(b[i] != c[i] && c[i] != a[i]) cnt++
        }else if(b[i] != c[i] || c[i] != a[i]) cnt++
    }
    println(cnt)
}

Measured memory_bytes: 31764
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define P pair<int,int>
const LL inf = 0x3f3f3f3f;
const LL mod = 1e9+7;
const LL N = 1e5+10;
template <typename tp> inline void read(tp &x)
{
	x=0;char c=getchar();int f=0;
	for(;c>'9'||c<'0';f|=(c=='-'),c=getchar());
	for(;c<='9'&&c>='0';x=(x<<3)+(x<<1)+c-'0',c=getchar());
	if(f) x=-x;
}
LL n,ans,num[N];
signed main()
{
	read(n);
	for(int i=1;i<=n;i++) read(num[i]);
	for(int i=1;i<=n;i++)
	{
		ans+=num[i]/2;
		num[i]%=2;
		if(i!=n)
		{
			int flag=min(num[i],num[i+1]);
			num[i]-=flag;
			num[i+1]-=flag;
			ans+=flag;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1024
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

history = list()
sat = 0
for i in range(N):
  a = A[i]
  b = B[a - 1]
  sat += b
  #print(len(history) == 0)
  if len(history) == 0:
    pass
  elif history[-1] == a - 1:
    sat += C[a-2]
  history.append(a)
    
print(sat)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
    
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        
        sc.nextInt();
        int n = sc.nextInt() -1;
        String target = sc.next();
        
        char c = (char)((int)target.charAt(n) - (int)('A'-'a'));
        char[] targetChars = target.toCharArray();
        targetChars[n] = c;
        
        System.out.println(String.valueOf(targetChars));
        
    }
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

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

const int INF = 1000000000;
const int MOD = 1000000007;
const double eps = 1e-9;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    string s, t;
    cin >> s >>t;

    int ans = 2 * N;

    rep(i, N) {
        string subs = s.substr(i, N - i);
        string subt = t.substr(0, N - i);
        if (subs == subt) { ans -= subs.size(); break; }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
int main(void){
    int a[100],c[100];
    char b[100];
    int i=0,x;
    
    while(1){
        
        scanf("%d %c %d",&a[i],&b[i],&c[i]);
//        printf("%c\n",b[i]);
        if(b[i]=='?'){
            break;
        }
        i++;
    }
    for(x=0;x<i;x++){
        if(b[x]=='+'){
            printf("%d\n",a[x]+c[x]);
        }else if(b[x]=='-'){
            printf("%d\n",a[x]-c[x]);
        }else if(b[x]=='*'){
            printf("%d\n",a[x]*c[x]);
        }else if(b[x]=='/'){
            printf("%d\n",a[x]/c[x]);
        }
    }
}



Measured memory_bytes: 2140
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C, D = MAP()

if min(B, D)-max(A, C) <= 0:
	print(0)
else:
	print(min(B, D)-max(A, C))


Measured memory_bytes: 5144
#include<stdio.h>

int main()
{
  int N,i,ans;
  scanf("%d",&N);
 for(i=0;i<=10;i++)
 {
 if(i*1000>=N)
 {
   ans=i*1000-N;
   printf("%d",ans);
   return 0;
 }
 }
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;
const int INF = 1001001001;


int main() {
  int n; cin >> n;
  vector<int> a(n);
  vector<int> num(100000,0);
  ll sum = 0;
  rep(i,n){
    cin >> a[i];
    num[a[i]]++;
    sum += a[i];
  }
  int q; cin >> q;
  rep(i,q){
    int b, c; cin >> b >> c;
    sum += (c-b)*(num[b]);
    num[c]+=num[b];
    num[b]=0;
    cout << sum << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4004
#include<bits/stdc++.h>
using namespace std;
#define rip(a,b) for(int a=0;a<=b;++a)
int n,y,k10,k5,k1;
int main(){
  scanf("%d %d",&n,&y);
  rip(k10,n){
    rip(k5,n){
      k1 = (y-(10000*k10)-(5000*k5))/1000;
      if(n==(k10+k5+k1) && k1>=0){
        printf("%d %d %d\n",k10,k5,k1 );
        return 0;
      }
    }
  }
  printf("%d %d %d\n",-1,-1,-1 );
}

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

int main() {
	ios :: sync_with_stdio(false);
	stack <int> s;
	int n;
	while(cin >> n) {
		if(n == 0) {
			cout << s.top() << '\n';
			s.pop();
		} else
			s.push(n);
	}
	return 0;
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  sort(all(A), greater<ll>());
  ll com = 0; // 心地よさ
  ll tmp = N;
  for(int i = 0; i < N; ++i) {
    if(i == 0) {
      tmp--;
      com += A[0];
    } else {
      tmp--;
      if(tmp >= 2) {
        com += (A[i] * 2);
        tmp--;
      }
      else if(tmp == 1) {
        com += A[i];
        tmp--;
      }
    }
  }
  cout << com << endl;
}

Measured memory_bytes: 4836
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
long long n, k, l, r, a[40], pos;
vector<long long>p[30], q[30];
int main() {
	cin >> n >> k >> l >> r; pos = n / 2;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < (1 << pos); i++) {
		long long R = 0; for (int j = 0; j < pos; j++) { if ((i / (1 << j)) % 2 == 1) { R += a[j]; } }
		p[__builtin_popcount(i)].push_back(R);
	}
	for (int i = 0; i < (1 << (n - pos)); i++) {
		long long R = 0; for (int j = 0; j < n - pos; j++) { if ((i / (1 << j)) % 2 == 1) { R += a[j + pos]; } }
		q[__builtin_popcount(i)].push_back(R);
	}
	for (int i = 0; i < 30; i++)sort(p[i].begin(), p[i].end());
	for (int i = 0; i < 30; i++)sort(q[i].begin(), q[i].end());
	long long cnts = 0;
	for (int i = 0; i <= pos; i++) {
		int V = k - i; if (V < 0)continue;
		for (int j = 0; j < p[i].size(); j++) {
			int pos1 = lower_bound(q[V].begin(), q[V].end(), l - p[i][j]) - q[V].begin();
			int pos2 = lower_bound(q[V].begin(), q[V].end(), r + 1 - p[i][j]) - q[V].begin();
			cnts += pos2 - pos1;
		}
	}
	cout << cnts << endl;
	return 0;
}

Measured memory_bytes: 23408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(ll, X, t);
  print(max(X - t, 0ll));
}


Measured memory_bytes: 256
#include<iostream>
#include<complex>
#include<cmath>
using namespace std;
typedef complex<double> xy_t;

xy_t p[110];

double cross_product(xy_t a,xy_t b){
    return (conj(a)*b).imag();
}

int main(){
    int n=0;
    double x,y,s=0.0;
    xy_t a,b,c;
    while(~scanf("%lf,%lf",&x,&y)){
        p[n]=xy_t(x,y);
        n++;
        //cout<<p[n]<<endl;
    }
    a=p[0];
    for(int i=0;i<n-2;i++){
        b=p[i+1],c=p[i+2];
        s+=cross_product(b-a,c-a)/2;
        //cout<<b<<c<<s<<endl;
    }
    cout<<abs(s)<<endl;
}


Measured memory_bytes: 3256
(defun main ()
  (let ((n (read))
        (flg T)
        (ans 0))
    (loop for i from 1 upto n
          if flg do (if (= n (floor (/ (* i 108) 100))) (progn (setf ans i)
                                                               (setf flg nil))))
    (format t "~A~%" (if flg ":(" ans))))


(main)


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

using namespace std;
const int INF = numeric_limits<int>::max() / 2;
typedef vector<int> VI;
typedef vector<VI> VVI;

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

  int n,m,k;cin>>n>>m>>k;
  std::vector<int> d(m+1);
  for(int i=0;i<m;i++){
      cin>>d[i];
      d[i]--;
  }
  VVI v(n+1,vector<int>(k+1));
  for(int i=0;i<n;i++)for(int j=0;j<k;j++){
    cin>>v[i][j];
    v[i][j]--;
  }
  std::vector<int> dp((1<<m)+1,INF);
  dp[(1<<m)-1]=0;
  queue<int> que;
  que.push((1<<m)-1);
  while(!que.empty()){
      for(int i=0;i<k;i++){
          int tmp=que.front(),next=0;
          for(int j=0;j<m;j++){
              if(tmp%2){
                  int mv=v[d[j]][i];
                  for(int p=0;p<m;p++){
                    if(d[p]==mv) next|=(1<<p);
                  }
              }
              tmp/=2;
          }
          //cout<<next<<endl;
          //cout<<"*"<<dp[next]<<endl;
          if(dp[next]==INF){
              que.push(next);
          }
          dp[next]=min(dp[next],dp[que.front()]+1);
      }
      que.pop();
  }
  cout<<dp[0]<<endl;
    return 0;
}

Measured memory_bytes: 3448
/* D-"Median of Medians" */
/*  */
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#define ll long long
#define N_MAX 100000
using namespace std;

int main(){
    ll N,A,B,q,rest;
    cin >> N >> A >> B;

    rest = N%(A+B);
    q = N/(A+B);
    if(A == 0){
        cout << 0;
    }
    else if(rest < A){
        cout << A*q + rest;
    } else{
        cout << A*q + A;

    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#define ll long long
#define ull unsigned long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, W;
    cin >> n >> W;
    vector<int> Weights(n), Values(n);
    for (int i = 0; i < n; i++){
        cin >> Weights[i] >> Values[i];
    }
    int sumValues = accumulate(Values.begin(), Values.end(), 0);
    vector<vector<ll>> dp(n, vector<ll>(sumValues + 1, INT32_MAX));
    //DP[item][Val] -> store min weight such that total value is Val

    dp[0][0] = 0;
    dp[0][Values[0]] = Weights[0];

    for (int item = 1; item < n; ++item){
        int weight = Weights[item];
        int value = Values[item];
        dp[item][0] = 0;
        for (int i = 1; i <= sumValues; i++){
            dp[item][i] = dp[item - 1][i];
            if (i >= value) dp[item][i] = min(dp[item][i], dp[item - 1][i - value] + weight);
        }
    }

    int ans = 0;
    for (int i = 1; i <= sumValues; i++){
        if (dp.back()[i] <= W) ans = i;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 79488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[6];
		for (int i = 0; i < 6; i++) {
			num[i] = sc.nextInt();
		}
		Dice dice = new Dice(num);
		int q = sc.nextInt();
		int[] top = new int[q];
		int[] front = new int[q];
		for (int i = 0; i < q; i++) {
			top[i] = sc.nextInt();
			front[i] = sc.nextInt();
		}
		int[] result = dice.right(q, top, front);
		for (int i = 0; i < q; i++) {
			System.out.println(result[i]);
		}
		sc.close();
	}
}

class Dice {

	private int face[] = new int[6];

	Dice(int[] num) {
		for (int i = 0; i < 6; i++) {
			this.face[i] = num[i];
		}
	}

	public void order(String str) {
		char[] order = str.toCharArray();
		for (int i = 0; i < order.length; i++) {
			switch (order[i]) {
			case 'N':
				rollToNorth();
				break;
			case 'S':
				rollToSouth();
				break;
			case 'E':
				rollToEast();
				break;
			case 'W':
				rollToWest();
				break;
			}
		}
	}

	public int[] right(int q, int[] top, int[] front) {
		int[] result = new int[q];
		for (int i = 0; i < q; i++) {
			if (top[i] == this.face[0]) {

			} else if (top[i] == this.face[1]) {
				rollToNorth();
			} else if (top[i] == this.face[2]) {
				rollToWest();
			} else if (top[i] == this.face[3]) {
				rollToEast();
			} else if (top[i] == this.face[4]) {
				rollToSouth();
			} else if (top[i] == this.face[5]) {
				rollToNorth();
				rollToNorth();
			}
			if (front[i] == this.face[0]) {

			} else if (front[i] == this.face[1]) {

			} else if (front[i] == this.face[2]) {
				turnClockwise();
			} else if (front[i] == this.face[3]) {
				turnAnticlockwise();
			} else if (front[i] == this.face[4]) {
				turnClockwise();
				turnClockwise();
			} else if (front[i] == this.face[5]) {

			}
			result[i] = this.face[2];
		}
		return result;
	}

	public void rollToNorth() {
		int tmp;
		tmp = face[0];
		face[0] = face[1];
		face[1] = face[5];
		face[5] = face[4];
		face[4] = tmp;
	}

	public void rollToSouth() {
		int tmp;
		tmp = face[0];
		face[0] = face[4];
		face[4] = face[5];
		face[5] = face[1];
		face[1] = tmp;
	}

	public void rollToEast() {
		int tmp;
		tmp = face[0];
		face[0] = face[3];
		face[3] = face[5];
		face[5] = face[2];
		face[2] = tmp;
	}

	public void rollToWest() {
		int tmp;
		tmp = face[0];
		face[0] = face[2];
		face[2] = face[5];
		face[5] = face[3];
		face[3] = tmp;
	}

	public void turnClockwise() {
		int tmp;
		tmp = face[1];
		face[1] = face[2];
		face[2] = face[4];
		face[4] = face[3];
		face[3] = tmp;
	}

	public void turnAnticlockwise() {
		int tmp;
		tmp = face[1];
		face[1] = face[3];
		face[3] = face[4];
		face[4] = face[2];
		face[2] = tmp;
	}

	public int getFace(int index) {
		return face[index];
	}
}


Measured memory_bytes: 26444
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
	
	public static boolean dfs(int node, long cost, boolean[] visited, long[] costs, ArrayList<HashMap<Integer, Long>> adj){
		visited[node] = true;
		costs[node] = cost;
		//System.out.println(node + " " + cost);
		
		for(final Entry<Integer, Long> entry : adj.get(node).entrySet()){
			final int next = entry.getKey();
			final long next_cost = costs[node] + entry.getValue();
			
			if(!visited[next]){
				if(!dfs(next, next_cost, visited, costs, adj)){ return false; }
			}else{
				if(costs[next] != next_cost){ return false; }
			}
		}
		
		return true;
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		
		ArrayList<HashMap<Integer, Long>> adj = new ArrayList<HashMap<Integer, Long>>();
		for(int i = 0; i < N; i++){ adj.add(new HashMap<Integer, Long>()); }
		
		for(int i = 0; i < M; i++){
			final int L = sc.nextInt() - 1;
			final int R = sc.nextInt() - 1;
			final long D = sc.nextLong();
			
			adj.get(L).put(R, D);
			adj.get(R).put(L, -D);
		}
		
		boolean[] visited = new boolean[N];
		long[] costs = new long[N];
		
		for(int i = 0; i < N; i++){
			if(visited[i]){ continue; }
			if(!dfs(i, 0, visited, costs, adj)){
				System.out.println("No");
				return;
			}
		}
		
		System.out.println("Yes");
		
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}	
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 133364
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;


int main(){
	int n, d, x;
	cin >> n >> d >> x;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	vector<int> vec;
	for (int i = 0; i <= 100; i++){
		for (int j = 0; j < n; j++){
			vec.push_back(a[j]*i+1);
		}
	}
	int coun = 0;
	sort(vec.begin(), vec.end());
	for (int i = 0; ; i++){
		if (vec[i] > d) break;
		coun++;
	}
	cout << x + coun << endl;
}



Measured memory_bytes: 3660
import numpy as np

if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split(" ")))
    a = np.array(a)

    aSortedIndex = np.argsort(a)

    for i in range(n):
        print((aSortedIndex[i] + 1), end=" ")


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

int main()
{
  string s;
  cin>>s;
  string answer="";
  // if(s[0]=='B'){
  //   answer="";
  // }
  // else answer=s[0];
  for(int i = 0 ; i < s.length(); ++i){
    if(s[i]=='B'){
      if(answer.length()>0)
      answer.erase(answer.length()-1,1);
      }
    else answer+=s[i];
  }
  cout<<answer<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a = 0;
		for(int i=N; i<1000; i++) {
			if(i%111==0) {
				a = i;
				break;
			}
		}
		sc.close();
		System.out.println(a);
	}

}

Measured memory_bytes: 35500
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265359

int main() {
    int n;
    int a[200010];
    cin >> n;
    ll sum=0;;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i == 0) {
            
        }
        else if(a[i-1] < a[i]){

        }else{
            sum += a[i-1] - a[i];
            a[i] = a[i-1];
        }
    }
    cout << sum  << endl;
    return 0;
}

Measured memory_bytes: 4352
n, m = map(int, input().split())
dic = {i: -1 for i in range(1, n + 1)}
for _ in range(m):
    s_, c_ = map(int, input().split())
    if dic[s_] == -1:
        dic[s_] = c_
    else:
        if dic[s_] != c_:
            print(-1)
            exit()
if n != 1 and dic[1] == 0:
    print(-1)
    exit()
res = ""
keys = list(dic.keys())
keys.sort()
for k in keys:
    if dic[k] == -1:
        if k == 1 and n != 1:
            res += "1"
        else:
            res += "0"
    else:
        res += str(dic[k])
print(res)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;

/*2進数配列+1*/
vector<int> twoadd(vector<int> v, int N){
    v[N-1]+=1;
    int ind = N-1;
    int j=N-1;
    for(j=N-1;j>=1;j--){
        if(v[j]>1){
            v[j-1]+=1;
            v[j]=0;
        }
    }
    return v;
}

/*フィボナッチ*/
long long fibonatti(long long d){
    long long count = 0;
    long long f1 = 1;
    long long f2 = 1;/*ここを変える*/
    long long temp;
    if(d == 1){
        count = f1;
    }else if(d == 2){
        count = f2;
    }else if(d==0){
        count = 1;
    }else{
        for(int i=0;i<d-2;i++){
            temp = f1+f2;
            f1 = f2;
            f2 = temp;
        }
        count = temp;
    }
    return count;
}

/*最大公約数*/
unsigned long long GCD(long long L,long long R){
    if(L>R){
        long long temp=R;
        R = L;
        L = temp;
    }
    unsigned long long pp=0,ppt=0;
    unsigned long long ans=0;
    if(R%L==0){
        ans = L;
    }else{
        while(true){
            ppt = pp;
            pp=R%L;
            if(pp == 0){
                ans = ppt;
                break;
            }
            R = L;
            L = pp;
        }
    }    
    return ans;    
}

/*最小公倍数*/
unsigned long long LCM(long long L,long long R){
    unsigned long long ans;
    unsigned long long gcd = GCD(L,R);
    ans = (L/gcd)*R;
    return ans;
}

/*Combination set*/
#define mod 1000000007
#define maxcomb 3000/*大きいものを求めるときはここを変える*/
vector<long long> fc(maxcomb+1);
vector<long long> ifc(maxcomb+1);
long long modpow(long long x,long long n){
    long long ans = 1;
    while(n > 0){
        if(n & 1) {
            ans = ans*x%mod;
        }
        x = x*x%mod;
        n >>= 1;
    }
    return ans;
}
void Conb(){
    fc[0]= 1;
    ifc[0]=1;
    for(long long i=0;i<maxcomb;i++){
        fc[i+1] = fc[i]*(i+1)%mod;//n!(mod)
        ifc[i+1] = ifc[i]*modpow(i+1,mod-2)%mod;//k!^{M-2} (mod)
    }
}
unsigned long long Combination(long long L,long long R){
    unsigned long long up=1,ans;
    Conb();
    if(L==0&&R==0){
        return 1;
    }else if(L<R||L<0){
        return 0;
    }else{
        long long t = ifc[L-R]*ifc[R]%mod;
        ans = t*fc[L]%mod;
    }
    return ans;
}
/*Combination set ここまで*/

/*ここから*/
int main() {
    int N;
    cin >> N;
    vector<long> A(N+1);
    vector<long> B(N);
    long long sum = 0;
    for(int i=0;i<N+1;i++){
        cin >> A[i];
        sum += A[i];
    }
    for(int i=0;i<N;i++){
        cin >> B[i];
    }
    long long ans = 0;
    for(int i=0;i<N;i++){
        if(B[i]>=A[i]){
            B[i] = B[i]-A[i];
            A[i] = 0;
            if(A[i+1]>B[i]){
                A[i+1]-=B[i];
            }else{
                A[i+1]=0;
            }
        }else{
            A[i] -= B[i];
        }
    }
    for(int i=0;i<N+1;i++){
        sum -= A[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4832
#include <stdio.h>
int main(void){
  int H,W,i,j,k;

  for(i=0; i<300; i++){
      scanf("%d %d",&H,&W);
      if(H==0 && W==0) break;
      for(j=0; j<H; j++){
          for(k=0; k<W; k++){
               if((j+k)%2 == 0) printf("#");
                else    printf(".");
          }
          putchar('\n');
      }
      putchar('\n');
  }
  return 0;
}


Measured memory_bytes: 2128
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(long a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
const int MOD=1e9+7;
static inline int ModPow(int a,int b){return b?1l*ModPow(1l*a*a%MOD,b>>1)*(b&1?a:1)%MOD:1;}
int main(void)
{
  int N=IN();return OUT(1l*(1l*(ModPow(10,N)-ModPow(9,N)-ModPow(9,N)+1l*ModPow(8,N))%MOD+MOD)%MOD),0;
}

Measured memory_bytes: 1492
import java.util.Scanner;

public class Main {

    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }

        int h = a[0] - 1;
        for(int i=1; i<n; i++) {
            if(a[i] < h) {
                System.out.println("No");
                return;
            }
            h = Math.max(h, a[i]-1);
        }
        System.out.println("Yes");


    }

}


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

using ll=long long;

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x-a)%b << endl;
}

Measured memory_bytes: 256
use std::io::prelude::*;
use std::io;

fn main() {
    let mut stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_to_string(&mut buf).unwrap();
    
    let mut lines = buf.lines();
    let n: i32 = lines.next().unwrap().parse().unwrap();
    
    let mut ans: f64 = 0.0;
    
    let btc: f64 = 380000.0;
    
    for _ in 0..n {
        let mut line = lines.next().unwrap().split_whitespace();
        let x: f64 = line.next().unwrap().parse().unwrap();
        let u: &str = line.next().unwrap();
        
        ans += if u == "JPY" {
            x
        } else {
            x * btc
        };
        
    }
    
    println!("{}", ans);
    
}

Measured memory_bytes: 4352
#include <cstdio>
#include <algorithm>
#include <complex>
using namespace std;

int main() {
  int tc; scanf("%d", &tc);
  for(int tci = 0; tci < tc; tci++) {
    complex<double> p1, p2, p3, p4;
    scanf("%lf%lf%lf%lf%lf%lf%lf%lf",
        &p1.real(), &p1.imag(),
        &p2.real(), &p2.imag(),
        &p3.real(), &p3.imag(),
        &p4.real(), &p4.imag());
    complex<double> p5 = p2-p1;
    complex<double> p6 = p4-p3;
    if(fabs(imag(p5 * conj(p6))) < 1e-9) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}

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

int main(){
    int a,b,c,x,i,j,k,count=0;
    cin >> a >> b >> c >> x;

    for(i=0; i<=a; i++){
        for(j=0; j<=b; j++){
            for(k=0; k<=c; k++){
                int ans = 500*i+100*j+50*k;
                if(ans==x) count++;
            }
        }
        
    }

    cout << count << endl;


}

Measured memory_bytes: 3560
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    X, Y = input().split()
    if X > Y:
        print(">")
    elif X < Y:
        print("<")
    else:
        print("=")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4084
def dfs(graph, start, visited):
    if visited[start] != -99999:
        return True
    
    stack = [start]
    visited[start] = 0
    while stack:
        label = stack.pop()
        for nextnode, distance in graph[label]:
            if visited[nextnode] == -99999:
                stack.append(nextnode)
                visited[nextnode] = visited[label] + distance
            elif visited[nextnode] != visited[label] + distance:
                return False
    return True

N, M = (int(i) for i in input().split())  

graph = [[] for i in range(N+1)]

for i in range(M):
    L, R, D = (int(i) for i in input().split())
    graph[L].append((R, D))
    graph[R].append((L, -1 * D))


visited = [-99999 for i in range(N+1)]

flag = True
for i in range(1, N + 1):
    ans = dfs(graph, i, visited)
    if not ans:
        flag = False
        break

if flag:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 65972
#include <iostream>

int main(int argc, char** argv)
{
	int n;
	std::cin >> n;

	int min = 1000000;
	int max = -1000000;
	long long sum = 0;
	
	for (int i = 0; i < n; ++i)
	{
		int a;
		std::cin >> a;

		if (min > a)
		{
			min = a;
		}
		if (max < a)
		{
			max = a;
		}

		sum += a;
	}

	std::cout << min << " " << max << " " << sum << std::endl;
}


Measured memory_bytes: 3084
#include <stdio.h>
int F[50];
int fibo(int);

int main(){
  int i,n;
  for(i=0;i<50;i++)F[i]=-1;
  scanf("%d",&n);
  printf("%d\n",fibo(n));
  return 0;
}

int fibo(int n){
  if(n==1||n==0)F[n]=1;
  if(F[n]!=-1)return F[n];
  return F[n]=fibo(n-1)+fibo(n-2);
}



Measured memory_bytes: 2056
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;


int main(void) {
    int n, m; cin >> n >> m;

    vector<int> l(m);
    vector<int> r(m);
    vector<int> g(100100, 0);
    for(int i=0; i<m; i++){
      cin >> l[i] >> r[i];
      g[l[i]]++;
      g[r[i]+1]--;
    }

    for(int i=1; i<=n; i++) {
      g[i] += g[i-1];
    }
    int cnt = 0;
    for(int i=0; i<g.size(); i++){ 
      if(g[i] == m) cnt++;
    }
    cout << cnt << endl;


    

    return 0;
}



// EOF


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <sstream>
#include <cstdlib>

using namespace std;

int p,s;
const int QST=1000000000;
int table[201][21];
int origTable[201][21];

int main(){
  bool fst=true;
  while(cin>>p&&p){
    if(!fst)cout<<endl;
    fst=false;
    int cnt=0;
    cin>>s;
    string str;
    for(int i=0;i<=p;i++){
      for(int j=0;j<=s;j++){
	cin>>str;
	if(str[0]=='?'){
	  table[i][j]=QST;
	  origTable[i][j]=table[i][j];
	  cnt++;
	}
	else{
	  int num=atoi(str.c_str());
	  table[i][j]=num;
	  origTable[i][j]=table[i][j];
	}
      }
    }
    bool update=true,isFail=false;
    while(update){
      update=false;
      for(int i=0;i<=p;i++){
	int c=0;
	int last=-1;
	for(int j=0;j<=s;j++){
	  if(table[i][j]==QST){
	    c++;
	    last=j;
	  }
	}
	if(c==1){
	  int sum=0;
	  if(last==s){
	    for(int j=0;j<s;j++)sum+=table[i][j];
	    table[i][last]=sum;
	  }
	  else{
	    sum=table[i][s];
	    for(int j=0;j<s;j++)if(table[i][j]!=QST)sum-=table[i][j];
	    table[i][last]=sum;
	  }
	  cnt--;
	  update=true;
	  break;
	}
      }
      for(int j=0;j<=s;j++){
	int c=0;
	int last=-1;
	for(int i=0;i<=p;i++){
	  if(table[i][j]==QST){
	    c++;
	    last=i;
	  }
	}
	if(c==1){
	  int sum=0;
	  if(last==p){
	    for(int i=0;i<p;i++)sum+=table[i][j];
	    table[last][j]=sum;
	  }
	  else{
	    sum=table[p][j];
	    for(int i=0;i<p;i++)if(table[i][j]!=QST)sum-=table[i][j];
	    table[last][j]=sum;
	  }
	  cnt--;
	  update=true;
	  break;
	}
      }
      if(cnt>0&&!update){
	isFail=true;
	break;
      }
      // 矛盾が起きてるかどうかを調べる
      for(int i=0;i<=p;i++){
	int sum=0;
	bool ok=true;
	for(int j=0;j<=s;j++){
	  if(table[i][j]==QST){
	    ok=false;break;
	  }
	  else if(j!=s)sum+=table[i][j];
	}
	// fail
	if(!ok)continue;
	// 全部埋まってる
	if(sum!=table[i][s]){
	  update=false;
	  isFail=true;
	  break;
	}
      }
      for(int j=0;j<=s;j++){
	int sum=0;
	bool ok=true;
	for(int i=0;i<=p;i++){
	  if(table[i][j]==QST){
	    ok=false;break;
	  }
	  else if(i!=p)sum+=table[i][j];
	}
	// fail
	if(!ok)continue;
	if(!(sum==table[p][j])){
	  update=false;
	  isFail=true;
	  break;
	}
      }
    }
    if(isFail)cout<<"NO"<<endl;
    else{
      for(int i=0;i<=p;i++)
	for(int j=0;j<=s;j++)
	  if(origTable[i][j]==QST)
	    cout<<table[i][j]<<endl;
    }
  }

  return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

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

  ll result=0;
  rep1(i, n-1){
    if(a[i-1] > a[i]){
      ll d = a[i-1] - a[i];
      a[i] += d;
      result += d;
    }
  }

  cout<<result<<endl;

  return 0;
}

Measured memory_bytes: 4840
n = int(input())
la = list(map(int, input().split()))

ct = [0] * (2*10**5+1)
ans = [0] * (n+1)
ld = [0] * (n+1)

for i in range(len(la)):
    ct[la[i]] += 1

sa = set(la)

for j in sa:
    ans[j] = ct[j] * (ct[j]-1) // 2
    ld[j] = ans[j] - ((ct[j]-2) * (ct[j]-1) // 2)

total = sum(ans)

# print(ct[0:10])
# print(ans)

for k in range(n):
    knum = la[k]
    print(total - ld[knum])


Measured memory_bytes: 26140
import java.util.*;
public class Main{
	public static void main(String[] args)
	{
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String s=sc.next();
		char a[]=s.toCharArray();
		int i=0;
		int j=n-1;
		int count=0;
		int flag=0;
		int flag2=0;
		int flag3=0;
		while(i<=j)
		{
			
			while(a[i]=='R'&&i<j)
			{
				
				i++;
			}
			if(i==n-1)
			{
				break;
			}
			while(a[j]=='W'&&i<j)
			{
				
				j--;
			}
			if(j==0)
			{
				break;
			}
			
			if(i<j)
			{
			char c=a[i];
			a[i]=a[j];
			a[j]=c;
		
			count++;
			
			
			i++;
			j--;
			}
			if(i==j)
			{
				break;
			}
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 41360
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int n;
        cin >> n;
        int a[n+1],b[n+1],c[n+1],i,j,k;
        for(i=1; i<=n; i++) cin >> a[i] >> b[i] >> c[i];
        int dp[n+1][3];
        dp[1][0]=a[1];
        dp[1][1]=b[1];
        dp[1][2]=c[1];
        for(i=2; i<=n; i++){
            dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
            dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
            dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
        }
        cout << max3(dp[n][0],dp[n][1],dp[n][2]) << '\n';
        

}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
// using Graph = vector<vector<int>>;
using P = pair<ll, ll>;
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //////////////////////////////////////
  int h, m, H, M, k, sum = 0;
  cin >> h >> m >> H >> M >> k;
  if (M - m < 0) {
    H--;
    sum += 60 + M - m;
  } else {
    sum += M - m;
  }
  sum += 60 * (H - h);
  cout << max(0, sum - k) << endl;
  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
int main(void)
{
    char a[10010];
    int i;
    int jcount,icount;

    while(scanf("%s",a) != EOF){
        jcount = icount = 0;
        for(i = 0; i < strlen(a); i++){
            if(a[i] == 'J' && a[i+1] =='O' && a[i+2] == 'I')
                jcount++;
            if(a[i] == 'I' && a[i+1] == 'O' && a[i+2] == 'I')
                icount++;
        }
        printf("%d\n%d\n",jcount,icount);
    }
    return 0;
}

Measured memory_bytes: 552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int N, L;
  vector<string> strs;
  vector<int> ascendingOrder = vector<int>(110, 0);  //各文字列内の任意の位置において文字の辞書順を調べ、一番小さい場合カウント(
  vector<int> strOrderToMerge;  //各文字列内の任意の位置において文字の辞書順を調べ、一番小さい場合カウント

  cin >> N >> L;
  
  for (int i = 0; i < N; i++)
  {
    string str;
    cin >> str;
    strs.push_back(str);
  }

  sort(strs.begin(), strs.end());

  for (int i = 0; i < N; i++)
  {
    cout << strs[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

int main()
{
	std::string s, t;
	std::cin >> s >> t;

	int a = 0;
	int b = 0;
	std::cin >> a >> b;

	std::string u;
	std::cin >> u;

	if (u == s)
	{
		a -= 1;
	}
	else
	{
		b -= 1;
	}

	std::cout << a << ' ' << b << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()

const vector<char> inp={'M','A','R','C','H'};



int main(){
    int n; cin>>n;
    vector<ll> p(5,0);
    rep(i,n){
        string a; cin>>a;
        rep(j,5){
            if(a[0]==inp[j]){
                p[j]++;
            }
        }
    }
    ll ans=0;
    rep(i,3){
        for(int j=i+1; j<=3; ++j){
            for(int k=j+1; k<=4; ++k){
                ans+=p[i]*p[j]*p[k];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
 
using namespace std;
int main(){
	int size;
  	cin >> size;
  
  	vector<int> x(size), perm1(size), perm2(size);
  for( int i = 0; i < size; i++){
   cin >> perm1[i];
  }
  for( int i = 0; i < size; i++){
   cin >> perm2[i];
  }
  for( int i = 0; i < size; i++){
  	x[i] = i+1;
  }
  
  int a = 0, b = 0, counter = 0;
  
  do{
    counter ++;
    if(perm1 == x){
     a = counter; 
    }
    if(perm2 == x){
      b = counter;
    }
    
  }
  while(next_permutation(x.begin(), x.end()));
  cout << abs(a-b);
}

Measured memory_bytes: 256
U = 5*10**5
MOD = 10**9+7
 
def main():
  fact = [1]*(U+1)
  fact_inv = [1]*(U+1)

  for i in range(1,U+1):
      fact[i] = (fact[i-1]*i)%MOD
  fact_inv[U] = pow(fact[U], MOD-2, MOD)

  for i in range(U,0,-1):
      fact_inv[i-1] = (fact_inv[i]*i)%MOD

  def comb(n, k):
      if k < 0 or k > n:
          return 0
      z = fact[n]
      z *= fact_inv[k]
      z *= fact_inv[n-k]
      z %= MOD
      return z

  n, k = map(int, input().split())
  if k+1 < n:
    ans = 0
    for i in range(k+1, n):
      ans += comb(n, i) * comb(n-1, i)
      ans %= MOD
    ans = comb(2*n-1, n) - ans
    ans %= MOD
  else:
    ans = comb(2*n-1, n)
  print(ans)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 42612
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<int,int,int,int> iiii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

int l[100001],r[100001];
int main() {
	int n;
	scanf("%d",&n);
	fup(i,1,n,1)scanf("%d%d",l+i,r+i);
	sort(l,l+n+1);sort(r,r+n+1);reverse(l,l+n+1);
	ll ans=0;
	fup(i,0,n,1)
	{
		if(l[i]-r[i]<=0)break;
		else ans+=l[i]-r[i];
	}
	printf("%lld",ans*2);
}

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

int main(){
    int n, r;
    cin >> n >> r;
    if(n > 10){
        cout << r << endl;
    }else{
        cout << r + (100 * (10 - n)) << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define min(a,b) (a<b?a:b)
using namespace std;
const int N=650;
int gi(){
    char ch=getchar(); int x=0,q=0;
    while(ch<'0'||ch>'9') q=ch=='-'?1:q,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return q?-x:x;
}
char s[N][N];
int a[N][N];
int main(){
    int n=gi();
    for (int i=1; i<=n; ++i) scanf("%s",s[i]+1);
    for (int i=1; i<=n; ++i)
	for (int j=1; j<=n; ++j)
	    s[i+n][j]=s[i][j+n]=s[i+n][j+n]=s[i][j];
    for (int i=1; i<=2*n; ++i)
	for (int j=1; j<=2*n; ++j)
	    while(a[i][j]<min(2*n-i,2*n-j)+1&&s[i+a[i][j]][j]==s[i][j+a[i][j]])
		++a[i][j];
    int ans=0;
    for (int i=1; i<=n; ++i)
	for (int j=1; j<=n; ++j){
	    int flag=1;
	    for (int k=0; k<n; ++k)
		if (a[i+k][j+k]<n-k)
		    { flag=0; break; }
	    ans+=flag;
	}
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
 
// a,b,cの最大値、最小値をそれぞれminimumの参照先、maximumの参照先に代入する



int main() {
    int64_t n ,k;
    cin >>n >> k;
  	int base = k;
    int cnt = 0;
    while(n>=base){

        base*=k;
        cnt++;
    }
    cout << cnt+1 << endl;
}


Measured memory_bytes: 256