akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    
    string S;
    cin >> S;
    S = S.substr(0, S.size()-1);
    if(S.size() % 2 == 1) S = S.substr(0, S.size()-1);
    
    while(S.substr(0,S.size()/2) != S.substr(S.size()/2,S.size()/2)){
        S = S.substr(0,S.size()-2);
    }
    cout << S.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
int n,k,a[110],b[100100],nb;
int main(){
	read(n);read(k);
	for (int i=1;i<=n;i++)read(a[i]);
	int la=0;
	while (k){
		int mi=110,nm=0;
		for (int i=1;i<=n;i++){if (i!=la&&a[i]<mi){mi=a[i];nm=i;}}
		if (la!=0){if (a[la]>0){a[la]--;b[++nb]=la;}else{puts("-1");return 0;}}
		for (int i=1;i<=n;i++){
			if (i!=nm&&i!=la){
				if (a[i]>0){b[++nb]=i;a[i]--;}
				else{puts("-1");return 0;}
			}
		}
		la=nm;
		k--;
	}
	if (a[la]>0){a[la]--;b[++nb]=la;}else{puts("-1");return 0;}
	for (int i=1;i<=n;i++)if (i!=la){if (a[i]>0){b[++nb]=i;a[i]--;}else{puts("-1");return 0;}}
	cout<<nb<<endl;
	for (int i=1;i<=nb;i++) cout<<b[i]<<' ';cout<<endl;
	return 0;
}


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

#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(int i=a;i<b;i++)
#define inf (long long int) 1e18
#define vi vector<int> 
#define pii pair<int, int>
#define mii map<int, int> 
#define mod 1000000007

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

int palindrome(string s){
    int l = 0;
    int h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

long long modexp(long long a, long long b, long long m){
    if (b==0)
        return 1;
    long long temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    int n;
    cin>>n;
    int sum=0;
    int a[n];
    loop(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    cout<<sum-n<<endl;
}


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

int main(){
  ll N = 0,K = 0,ans = 1,x = 0;
  cin >> N >> K;
  x = K;
  bool a = true;
  while(a){
    if(N >= x){
      ans++;
      x *= K;
    }
    else{
      a = false;
    }
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;cin>>n;
  vector<pair<ll,ll>>p;
  for(int i=0;i<n;i++){
    ll a,b;
    cin>>a>>b;
    pair<ll,ll>pq=make_pair(a,b);
    p.push_back(pq);
  }
  sort(p.begin(),p.end(),greater<pair<ll,ll>>());
  cout<<p[0].first+p[0].second<<endl;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll cnt = 0, mn = 1e9, sum = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if(a < 0) cnt++;
    sum += abs(a);
    mn = min(mn, abs(a));
  }
  if(cnt % 2) sum -= mn * 2;
  cout << sum << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    boolean test = true;
    
    for(int i=1; test; i++){
        if((A*i)%B == C){
            test = false;
            break;
        }else if((A*i)%B == 0){
            //System.out.println("C");
            break;
        }else{
            
        }
    }
    if(!test){
        System.out.println("YES");
    }else{
        System.out.println("NO");
    }
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int> Number(N);
  for(int i=0; i<N; i++){
    cin >> Number.at(i);
  }
  int count = 0;
  int oldmin = 1000000;
  for(int i=0; i<N; i++){
    if(oldmin >= Number.at(i)){
      oldmin = Number.at(i);
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 1024
import numpy as np
N, x = map(int, input().split())
A = np.array(list(map(int, input().split())))

count = np.sum((A - x)[A - x > 0])
A[A > x] = x
for i in range(1, N):
    if A[i] + A[i - 1] > x:
        decrease = A[i] + A[i - 1] - x
        A[i] = A[i] - decrease
        count += decrease
print(count)

Measured memory_bytes: 23112
#include <stdio.h>



void SelectionSort(char ch[],char A[], int n)
{
  int i,j,mini;
  char t;
  for(i=0;i<n;i++){
    mini=i;
    for(j=i;j<n;j++){
      if (A[j]<A[mini]){
        mini=j;
      }
    }
    t=A[i];
    A[i]=A[mini];
    A[mini]=t;
    t=ch[i];
    ch[i]=ch[mini];
    ch[mini]=t;
  }
}

void BubbleSort(char ch[],char A[], int n)
{
  int i,j;
  char t;
  for(i=0;i<n;i++){
    for(j=n-1;i<j;j--){
      if (A[j]<A[j-1]){
        t=A[j];
        A[j]=A[j-1];
        A[j-1]=t;
        t=ch[j];
        ch[j]=ch[j-1];
        ch[j-1]=t;
      }
    }
  }
}
int main()
{
  int n,i;
  char ori_num[36],ori_ch[36],num0[36],ch0[36],num1[36],ch1[36],str[2];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",str);
    ch0[i]=str[0];
    num0[i]=str[1];
    ori_ch[i]=str[0];
    ori_num[i]=str[1];
  }

  BubbleSort(ch0,num0,n);
  for(i=0;i<n-1;i++){
    printf("%c%c ",ch0[i],num0[i]);
  }
  printf("%c%c\n",ch0[n-1],num0[n-1]);
  printf("Stable\n");

  for(i=0;i<n;i++){
    ch1[i]=ori_ch[i];
    num1[i]=ori_num[i];
  }
  SelectionSort(ch1,num1,n);
  for(i=0;i<n-1;i++){
    printf("%c%c ",ch1[i],num1[i]);
  }
  printf("%c%c\n",ch1[n-1],num1[n-1]);

  if ((strncmp(num0,num1,n)==0) && (strncmp(ch0,ch1,n)==0)){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
return 0;
}



Measured memory_bytes: 2040
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 2e5 + 5;
int a[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int t; t = 1;
    while (t --){
        int n , k; cin >> n >> k;
        for (int i = 1 ; i <= n ; i++) cin >> a[i];
        for (int i = k + 1; i <= n ; i++){
            cout << (a[i] > a[i - k] ? "Yes" : "No") << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 4432
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
    string input;
    getline(cin, input);
    for(string::iterator itr = input.begin(); itr < input.end(); itr += 2){
        cout << *itr;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 512
while(n,k=gets.split.map &:to_i)[0]>0
l=(1..k).map{gets.to_i}.sort
d=l.each_cons(2).map{|i,j|"#{j-i}"}*""
if l[0]>0
p d.scan(/1+/).map(&:size).max+1
else
p d[1..-1].gsub(/1+/){"#$& #$&"}.scan(/1+21*|1*21+|1+/).map(&:size).max+2
end
end

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

int main() {
  int a, b;
  cin >> a >> b;
//  cout << a << endl,
//  cout << b << endl;
//  cout << a % 2 << endl;
  if (a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  else {
    cout << "Odd" << endl;
  }
}

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

using namespace std;

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

  int n = s.size();

  if (n % 2 == 0) {
    bool same = true;
    for (int i = 1; i < n; i++) {
      if (s[i] != s[0]) {
        same = false;
      }
    }
    if (same) {
      cout << n << endl;
      return 0;
    }
    
    int ans = n / 2;

    for (int i = 1; n / 2 + i < n; i++) {
      if (s[n / 2 + i - 1] == s[n / 2] && s[n / 2 - i] == s[n / 2]) {
        ans++;
      } else {
        break;
      }
    }

    cout << ans << endl;
  } else {
    int ans = n / 2 + 1;

    int mid = n / 2;
    for (int i = 1; mid + i < n; i++) {
      if (s[mid + i] == s[mid] && s[mid - i] == s[mid]) {
        ans++;
      } else {
        break;
      }
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 512
//--- pB ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		long X = reader.nl();
		long cur = 1L * 100;
		long ans = 0;
		while (cur < X) {
			ans ++;
			long inst = (long)Math.floor(1.0 * cur * 0.01);
			cur += inst;
		}
		out.println(ans);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 32856
s = str(input())
q = int(input())
state = True
front = ""
ending = ""
for _ in range(q):
  qi = str(input())
  if qi[0] == "2":
    fi,ci = map(str,qi[2:].split())
    if state == True:
      if fi == "1":
        front += ci
      else:
        ending += ci
    else:
      if fi == "1":
        ending += ci
      else:
        front += ci
  else:
    state = not state
if state:
  first = front[::-1]
  lastt = ending
else:
  first = ending[::-1]
  lastt = front
  s = s[::-1]
print(first+s+lastt)

Measured memory_bytes: 4468
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
using namespace std;

struct query {
	int S, T, X;
};
vector<query> Querys;
int N, Q, RN;
vector<int> D;
vector<int> seg;
vector<int> razy;

void eval(int k) {
	if (razy[k] == 0)return;
	seg[k] = min(seg[k], razy[k]);
	if (k < RN) {
		razy[2 * k] = razy[k];
		razy[2 * k+1] = razy[k];
	}
	razy[k] = 0;
	return;
}

void change(int a, int b, int x, int k = 1, int l = 0, int r = RN - 1) {
	eval(k);
	if (b < l || r < a)return;
	if (a <= l && r <= b) {
		razy[k] = x;
		eval(k);
		return;
	}
	change(a, b, x, 2 * k, l, (l + r) / 2);
	change(a, b, x, 2 * k + 1, (l + r) / 2 + 1, r);
	seg[k] = min(seg[2 * k], seg[2 * k + 1]);
	return;
}

int get(int a, int b, int k = 1, int l = 0, int r = RN - 1) {
	eval(k);
	if (r < a || b < l)return INT_MAX;
	if (a <= l && r <= b)return seg[k];
	return min(get(a, b, 2 * k, l, (l + r) / 2),get(a, b, 2 * k + 1, (l + r) / 2 + 1, r));
}

void solve() {
	cin >> N >> Q;
	Querys.clear();
	Querys.resize(N);
	for (int n = 0; n < N; n++)cin >> Querys[n].S >> Querys[n].T >> Querys[n].X;
	sort(Querys.begin(), Querys.end(), [](const query& a, const query& b) {return (a.X > b.X); });
	D.clear();
	D.resize(Q);
	for (int n = 0; n < Q; n++)cin >> D[n];
	RN = 1;
	while (RN < Q)RN *= 2;
	seg.clear();
	seg.resize(2 * RN,INT_MAX);
	razy.clear();
	razy.resize(2 * RN,0);
	for (query q:Querys) {
		int s = -1, e = Q;
		while (e - s > 1) {
			int m = (e + s) / 2;
			if (D[m] < q.S - q.X)s = m;
			else e = m;
		}
		int S = e;
		if (S == Q)continue;
		s = -1, e = Q;
		while (e - s > 1) {
			int m = (e + s) / 2;
			if (D[m] < q.T - q.X)s = m;
			else e = m;
		}
		int T = s;
		if (T == -1)continue;
		change(S, T, q.X);
	}
	for (int n = 0; n < Q; n++) {
		int a = get(n, n);
		if (a == INT_MAX)cout << -1 << endl;
		else cout << a << endl;
	}
	return;
}

//////////////////////////////
//////////////////////////////

int main() {
#ifdef DEBUGTIME
	for (int time = 0; time < DEBUGTIME; time++) {
		solve();
		cout << "####################" << endl;
	}
#else
	solve();
#endif
	return 0;
}



Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

vector<vector<int> > v(100010);
map<pair<int,int>,int > mp;
int ans[100010];
int memo[100010];

int main()
{
	int n,m;cin >> n >> m;
	int cou = n;
	REP(i,m)
	{
		int a,b;cin >> a >> b;
		a--;b--;
		v[a].PB(b);v[b].PB(a);
		mp[MP(a,b)] = 0;
		mp[MP(b,a)] = 0;
	}
	
	vector<pair<int,pair<int,int> > > list;
	
	int Q;cin >> Q;
	
	REP(i,Q)
	{
		int a,b,c;cin >> a >> b >> c;
		a--;
		list.PB(MP(a,MP(b,c)));
	}
	
	for(int i = Q-1;i >= 0;i--)
	{
		if(cou == 0)break;
		
		int color = list[i].SE.SE;
		if(ans[list[i].FI] == 0)
		{
			ans[list[i].FI] = color;
			cou--;
		}
		if(list[i].SE.FI == 0)
		{
			continue;
		}
				
		int m_Dist = list[i].SE.FI;
				
		queue<pair<pair<int,int>,int> > q;
		q.push(MP(MP(list[i].FI,list[i].SE.FI),-1));
		
		while(!q.empty())
		{
			pair<pair<int,int>,int> now = q.front();q.pop();
			int node = now.FI.FI;
			int dist = now.FI.SE;
			int prev = now.SE;
						
			//cout << node << ' ' << color << endl;
			REP(j,v[node].size())
			{
				if(v[node][j] == prev)
				{
					continue;
				}
				if(mp[MP(node,v[node][j])] >= dist)
				{
					continue;
				}
				mp[MP(node,v[node][j])] = dist;
				mp[MP(v[node][j],node)] = max(mp[MP(v[node][j],node)],dist);
				if(ans[v[node][j]] == 0)
				{
					ans[v[node][j]] = color;
					cou--;
				}
				
				if(dist>1)
				{
					q.push(MP(MP(v[node][j],dist-1),node));
				}
			}
		}
	}
	
	REP(i,n)
	{
		cout << ans[i] << endl;
	}
	
	
	return 0;
}


Measured memory_bytes: 21744
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int n;
		Scanner s  = new Scanner(System.in);
		n = s.nextInt();
		double [] probabilities = new double[n];
		for(int i=0;i<n;i++) {
			probabilities[i] = s.nextDouble();
		}
		double [][] dp = new double[n+1][n+1];
		//dp[i][j] = probability of getting j heads from the first i coins
		dp[0][0] = 1;
		//probability of getting 0 heads from 0 coins is 0
		for(int i=1;i<dp.length;i++) {
			for(int j=0;j<=i;j++) {
				if(j==0) {
					dp[i][j]=dp[i-1][j]*(1-probabilities[i-1]);
				}
				else {
					dp[i][j] = dp[i-1][j]*(1-probabilities[i-1]) + dp[i-1][j-1] * probabilities[i-1];
				}
			}
		}
		double sum = 0;
		for(int i=n/2 + 1;i<n+1;i++) {
			sum+=dp[n][i];
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 118340
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  string a,b;cin>>a>>b;
  int c=a.size()-b.size();
  rep(i,min(b.size(),a.size())*2){
    if(i%2==0){
      cout<<a[i/2];
    }
    else cout<<b[i/2];
  }
  if(c>0)cout<<a[a.size()-1];
  if(c<0)cout<<b[b.size()-1];
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

class P
{
    static void Main()
    {
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        Console.WriteLine(a[0] * a[1] % 2 == 0 ? "Even" : "Odd");
    }
}

Measured memory_bytes: 13268
#include<stdio.h>

int main() {

	int N, K, seisu, i;

	seisu = 1;
	i = 0;

	scanf("%d", &N);
	scanf("%d", &K);

while(i < N){
		if (2 * seisu <= seisu + K) {
			seisu = 2 * seisu;
		}
		else {
			seisu = seisu + K;
		}
		i++;
	}
  
	printf("%d \n", seisu);

	return 0;
}

Measured memory_bytes: 128
#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 ALL(x) x.begin(),x.end()
#define fs first
#define sd second
#define couts(x) cout << (x) << (" ")
#define coutn(x) cout << (x) << ("\n")
#define endl "\n"

template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T1, typename T2> std::istream &operator>>(std::istream &is, std::pair<T1,T2> &p){is >> p.first >> p.second; return is; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::deque<T> &vec){ os << "deque["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> std::ostream &operator<<(std::ostream &os, const std::unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> std::ostream &operator<<(std::ostream &os, const std::unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }

template<class T> using V = vector<T>;
template<class T> using V2 = V<V<T>>;
template<class T> using V3 = V<V2<T>>;



void solve(){
  int n, m; string s;
  cin >> n >> s; m = (int)s.size();
  int r=0, g=0, b=0; ll ans;
  FOR(i,0,m){
    if(s[i]=='R') ++r;
    if(s[i]=='G') ++g;
    if(s[i]=='B') ++b;
  }
  ans = (ll)r * (ll)g * (ll)b;
  {
    int i=0, j=0, k=0;
    for(;i<m;++i){
      j = i+1;
      for(;j<m;++j){
        k = i + 2*(j-i);
        if(k>=m) break;
        if(s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]) ans--;
      }
    }
  }
  couts(ans);
}


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


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
dp = [0] * N
dp[0] = 3
r = 1
g = 0
b = 0
if a[0] != 0:
  dp[0] = 0
for i in range(N - 1):
  f = 0
  if a[i + 1] == r:
    dp[i + 1] += dp[i]
    f = 0
  if a[i + 1] == g:
    dp[i + 1] += dp[i]
    f = 1
  if a[i + 1] == b:
    dp[i + 1] += dp[i]
    f = 2
  if f == 0: r += 1
  if f == 1: g += 1
  if f == 2: b += 1
  dp[i + 1] %= mod
print((dp[-1]) % mod)

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

void Multiplication1() {
	int A, B;
	cin >> A >> B;
	cout << A * B;
}

void Multiplication2() {
	int N;
	long long int* A;
	long long int ans = 1;
	cin >> N;
	A = new long long int[N];
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) ans *= A[i];
	if (ans > (long long int)pow(10, 18)) {
		cout << -1;
		return;
	}
	cout << ans;
	delete[] A;
}

void Multiplication3() {
	long long int A, ans;
	long double B;
	cin >> A >> B;
	ans = A * B;
	cout << ans;
}


int main() {
	Multiplication3();
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>

using namespace std;

int main() {
    string S;
    cin >> S;
    int cnt0=0,cnt1=0;

    for(int i=0;i<S.size();i++){
        if(S[i]=='0')cnt0++;
        else cnt1++;
    }

    if(cnt0==0||cnt1==0){
        cout<<0;
    } else {
        cout<<S.size() - abs(cnt0-cnt1);
    }

    return 0;
}

Measured memory_bytes: 512
N, M = map(int, input().split())
Q = [[0, 0] for i in range(N+1)]
AC = 0
WA = 0

for _ in range(M):
    p, s = input().split()
    p = int(p)
    if Q[p][0] == 0:
        if s == "WA":
            Q[p][1] += 1
        else:
            AC += 1
            WA += Q[p][1]
            Q[p][0] = 1
    else:
        continue

print(AC, WA)


Measured memory_bytes: 17684
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i =0; i < n ;i++)
using namespace std;

int main(){
    int x, y;
    cin >> x >> y;
    
    int ans = x + y/2;
    
   
    cout << ans << endl;
    return 0;
}

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

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

    vector<bool> visit(n, false);
    visit.at(0) = true;

    while (1)
    {
        ans++;
        light = a[light - 1];
        if (visit[light - 1])
        {
            ans = -1;
            break;
        }
        if (light == 2)
        {
            break;
        }
        visit[light - 1] = true;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import itertools

N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
a = list(itertools.accumulate(a))

cnt = 0

for i in range(len(a)):
    if x > a[i]:
        if i == len(a)-1:
            break
        cnt += 1
    elif x == a[i]:
        cnt += 1
        break
    else:
        break

print(cnt)

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

int main(){
  int n,m;
  while(1){
    cin >> n >> m;
    if(n == 0 && m==0) break;
    int item[1010];
    for(int i=0;i<n;i++){
      cin >> item[i];
    }
    sort(item,item+n);
    int ans=0,f=1;
    for(int i=n-1;i>=0;i--){
      if(f==m){
	f=1;
      }
      else{
	ans += item[i];
	f++;
      }
    }
    cout << ans <<"\n";
  }

}

Measured memory_bytes: 1176
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout.precision(20);

  int a,b,h,m;
  cin >> a >> b >> h >> m;

  double t = 30 * h + 30 * (m / 60.0) - 6 * m;

  double t1 = cos(t * 3.14159265358979 / 180);

  cout << sqrt(a * a + b * b - 2 * a * b * t1) << endl;


  return 0;
}

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

int main(){
	string a;
	getline(cin, a);
	for(int i = 0; i < a.length(); i++){
		if(a[i] < 91 && a[i] > 64)
			a[i] += 32;
		else if(a[i] > 96 && a[i] < 123)
			a[i] -= 32;
	}
	cout << a << endl;
}


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

#define MAX 7368791
int t[MAX+1];

int main()
{
  int m,n;
  while(cin >> m >> n && (m || n))
    {
      int k=m;
      memset(t,0,sizeof(t));
      
      for(int i=0;i < n;i++)
	{
	  while(t[k]) k++; //約数のblankが見つかるまで＋＋
	  for(int j=k;j < MAX;j+=k) t[j] = 1;
	}
      for(;t[k];k++);
      cout << k << endl;
    }
  return 0;
}


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

string s;
long qq=1,gyakugen,a=0,ab=0,abc=0,mod=1000000007;

long modpow(long modpow_x,long modpow_y) {
  long modpow_return=1;
  for(long i=1;i<=modpow_y;i*=2) {
    if(modpow_y/i%2==1) modpow_return=modpow_return*modpow_x%mod;
    modpow_x=modpow_x*modpow_x%mod;
  }
  return modpow_return;
}

int main() {
  gyakugen=modpow(3,mod-2);
  cin >> s;
  for(long i=0;i<s.size();i++) {
    if(s[i]=='?') qq=qq*3%mod;
  }
  for(long i=0;i<s.size();i++) {
    if(s[i]=='A') {
      a=(a+qq)%mod;
    } else if(s[i]=='B') {
      ab=(ab+a)%mod;
    } else if(s[i]=='C') {
      abc=(abc+ab)%mod;
    } else {
      abc=(abc+(ab*gyakugen%mod))%mod;
      ab=(ab+(a*gyakugen%mod))%mod;
      a=(a+(qq*gyakugen%mod))%mod;
    }
  }
  cout << abc << endl;
}

Measured memory_bytes: 512
from fractions import gcd
N=int(input())
a = list(map(int, input().split()))
lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm, i)
ans = 0
for i in a:
    ans += (lcm//i)#%(10**9+7)
print(ans%(10**9+7))

Measured memory_bytes: 6112
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prl = lambda x: print(*x ,sep='\n')

n = ni()
res = n // 1000
print((res+1) * 1000 - n if n % 1000 != 0 else 0)

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

signed main(){
    int a;cin>>a;
    string s;cin>>s;
    if(a>3199)cout<<s<<endl;
    else cout<<"red"<<endl;
}

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

int cmpnum(const void * n1, const void * n2) {
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void) {

  long n,k;
  scanf("%ld %ld", &n, &k);
  long a[n],f[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  for (long i = 0; i < n; i++) {
    scanf("%ld", &f[i]);
  }
  qsort(a, n, sizeof(long), cmpnum);
  qsort(f, n, sizeof(long), cmpnum);
  long mul[n];
  long max = 0;
  long cost = 0;
  for (long i = 0; i < n; i++) {
    mul[i] = a[i]*f[n-1-i];
    if (mul[i] > max) {
      max = mul[i];
    }
    cost += a[i];
  }
  if (cost <= k) {
    printf("0\n");
    return 0;
  }
  long start = 0;
  long end = max;
  long center;
  while (start+1 != end) {
    center = (start+end)/2;
    cost = 0;
    for (long i = 0; i < n; i++) {
      if (mul[i] <= center) {
        continue;
      }
      cost += (mul[i]-center+f[n-1-i]-1)/f[n-1-i];
    }
    if (cost > k) {
      start = center;
    } else {
      end = center;
    }
  }
  printf("%ld\n", end);

  return 0;
}

Measured memory_bytes: 6380
//Shrinking 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    string s,ss;cin>>ss;
    int n = ss.size(),ans = inf;
    set<char>t{};
    rep(i,0,n)t.insert(ss[i]);
    for(auto i:t){
        s = ss;int c = 0;
        while(true){
            bool flag = true;
            rep(k,0,s.size())if(s[k]!=i)flag = false;
            if(flag||s.size()==1)break;
            c++;
            rep(k,0,s.size()-1)if(s[k+1]==i)s[k]=i;
            s.erase(s.begin()+s.size()-1);
        }
        ans=min(ans,c);
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#define N 100001
using namespace std;

int d[N]={0};

int main(){
 int n,i,m;
 cin >> n;
 for(i=1;i<=n;i++){
   d[i]=d[i-1]+1;
   m=6;
   while(i>=m)
   {
       if(d[i]>d[i-m]){d[i]=d[i-m]+1;}
       m=m*6;
   }
   m=9;
   while(i>=m)
   {
       if(d[i]>d[i-m]){d[i]=d[i-m]+1;}
       m=m*9;
   }
 } 
 cout << d[n] << endl;
 return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  int n,a;cin>>n>>a;

  out(n*n-a);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n;
    in>>n;
    vector<ll> a(n),c(n+1);
    for(auto&i:a) in>>i,++c[i];
    ll ans{};
    Fr(i,n) ans+=c[i]*(c[i]-1)/2;
    fr(i,n) cout<<ans-c[a[i]]*(c[a[i]]-1)/2+(c[a[i]]-1)*(c[a[i]]-2)/2<<endl;
}

Measured memory_bytes: 5760
N, L = map(int, input().split())

tp = []
tm = []
for i in range(1, N+1):
    t = L+i-1
    if t >= 0:
        tp.append(t)
    else:
        tm.append(t)

if len(tp) == 0:
    tm.remove(max(tm))        
elif len(tm) == 0:
    tp.remove(min(tp))
else:
    mtp = min(tp)
    mtm = abs(max(tm))    
    if mtp <= mtm :
        tp.remove(mtp)
    else:
        tm.remove(mtm)

sum = 0
for i in tp:
    sum += i
for i in tm:
    sum += i

print(sum)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x;
	cout<<48-x<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
using System;

namespace abc0818
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            if (int.Parse(Console.ReadLine()) >= 3200) Console.WriteLine(Console.ReadLine());
            else
            {
                Console.ReadLine();
                Console.WriteLine("red");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define MOD 1000000007
#define pb push_back
#define ll long long
using namespace std;
const int nmax=201234;

int n,h[nmax],mid;
ll a[nmax],res;

struct linetree
{
    int l,r;
    ll v;
} dp[4*nmax];

void build(int f)
{
    if(dp[f].l!=dp[f].r)
    {
        int mid=(dp[f].l+dp[f].r)/2;
        dp[2*f].l=dp[f].l;
        dp[2*f].r=mid;
        dp[2*f+1].l=mid+1;
        dp[2*f+1].r=dp[f].r;
        build(2*f);
        build(2*f+1);
    }
}

ll solve(int pos)
{
    int i=1;
    res=0;
    while(dp[i].l!=dp[i].r)
    {
        mid=(dp[i].l+dp[i].r)/2;
        if(dp[i].v+a[pos]>res)
            res=dp[i].v+a[pos];
        if(h[pos]<=mid)
            i=2*i;
        else
            i=2*i+1;
    }
    if(dp[i].v+a[pos]>res)
            res=dp[i].v+a[pos];
    i=1;
    while(dp[i].l!=dp[i].r)
    {
        if(dp[i].l==h[pos])
            dp[i].v=res;
        mid=(dp[i].l+dp[i].r)/2;
        if(h[pos]<=mid)
        {
            if(dp[2*i+1].v<res)
                dp[2*i+1].v=res;
            i=2*i;
        }
        else
            i=2*i+1;
    }
    dp[i].v=res;
}

int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        scanf("%d",&h[i]);
    }
    for(int i=1; i<=n; ++i)
    {
        scanf("%lld",&a[i]);
    }
    dp[1].l=1;
    dp[1].r=n;
    build(1);
    for(int i=1; i<=n; ++i)
    {
        solve(i);
    }
    res=0;
    for(int i=1; i<4*n; ++i)
    {
        if(res<dp[i].v)
            res=dp[i].v;
    }
    printf("%lld",res);
    return 0;
}

Measured memory_bytes: 13184
import java.io.*;
import java.util.*;

public class Main{
    public static void main(String args[]) throws Exception{
    	BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
    	long N= Integer.parseInt( br.readLine() );
//    	ArrayList<Integer>  min= new ArrayList<Integer>();
//    	//min.get(i): minimum amount that needs for i measurements
//    	min.add(0);
//    	min.add(2);
    	
    	int cnt= 1;
    	long tmp_min= 2;
    	while( tmp_min<=N ){
    		tmp_min= 3*(tmp_min-1)+1;
    		cnt++;
    	}
    	cnt--;
    	
		System.out.println( cnt );
    }
}

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

using namespace std;


int N, M, A, B;

void stupid() {
  char mat[1000][1000] = {{}};
  int X = A, Y = B;
  if(M & 1) {
    for(int i = 0; i + 1 < N; i += 2) {
      if(Y > 0) {
        mat[i][M - 1] = '^';
        mat[i + 1][M - 1] = 'v';
        --Y;
      }
    }
  }
  if(N & 1) {
    for(int i = 0; i + 1 < M; i += 2) {
      if(X > 0) {
        mat[N - 1][i] = '<';
        mat[N - 1][i + 1] = '>';
        --X;
      }
    }
  }

  for(int i = 0; i + 1 < N; i += 2) {
    for(int j = 0; j + 1 < M; j += 2) {
      if(X > 0) {
        mat[i][j] = '<';
        mat[i][j + 1] = '>';
        --X;
        if(X > 0) {
          mat[i + 1][j] = '<';
          mat[i + 1][j + 1] = '>';
          --X;
        }
      } else if(Y > 0) {
        mat[i][j] = '^';
        mat[i + 1][j] = 'v';
        --Y;
        if(Y > 0) {
          mat[i][j + 1] = '^';
          mat[i + 1][j + 1] = 'v';
          --Y;
        }
      }
    }
  }

  if(X == 0 && Y == 0) {
    cout << "YES" << endl;
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < M; j++) {
        if(mat[i][j] == 0) cout << ".";
        else cout << mat[i][j];
      }
      cout << endl;
    }
    exit(0);
  }
}

void clever() {
  char mat[1000][1000] = {{}};
  int X = A - 2, Y = B - 2;

  mat[0][0] = '^';
  mat[1][0] = 'v';
  mat[0][1] = '<';
  mat[0][2] = '>';
  mat[2][0] = '<';
  mat[2][1] = '>';
  mat[1][2] = '^';
  mat[2][2] = 'v';

  for(int i = 3; i + 1 < N; i += 2) {
    if(Y > 0) {
      mat[i][0] = '^';
      mat[i + 1][0] = 'v';
      --Y;
    }
  }

  for(int i = 3; i + 1 < M; i += 2) {
    if(X > 0) {
      mat[0][i] = '<';
      mat[0][i + 1] = '>';
      --X;
    }
  }

  for(int i = 1; i + 1 < N; i += 2) {
    for(int j = 1; j + 1 < M; j += 2) {
      if(i == 1 && j == 1) continue;

      if(X > 0) {
        mat[i][j] = '<';
        mat[i][j + 1] = '>';
        --X;
        if(X > 0) {
          mat[i + 1][j] = '<';
          mat[i + 1][j + 1] = '>';
          --X;
        }
      } else if(Y > 0) {
        mat[i][j] = '^';
        mat[i + 1][j] = 'v';
        --Y;
        if(Y > 0) {
          mat[i][j + 1] = '^';
          mat[i + 1][j + 1] = 'v';
          --Y;
        }
      }
    }
  }

  if(X == 0 && Y == 0) {
    cout << "YES" << endl;
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < M; j++) {
        if(mat[i][j] == 0) cout << ".";
        else cout << mat[i][j];
      }
      cout << endl;
    }
    exit(0);
  }
}

int main() {
  cin >> N >> M >> A >> B;
  stupid();
  if(N >= 3 && M >= 3 && N & 1 && M & 1 & A >= 2 && B >= 2) clever();
  cout << "NO" << endl;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
    #endif
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) { 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}

void solve() {	
	int h, w, n;
	cin >> h >> w >> n;
	int row = (n + w - 1) / w;
	int col = (n + h - 1) / h;
	cout << min(row, col);
}

Measured memory_bytes: 256
<?php

$line = fgets(STDIN);
$nk = explode(' ', trim($line));
$n = $nk[0];
$k = $nk[1];

$line = fgets(STDIN);
$d = explode(' ', trim($line));

$pay = $n;
do {
  $flag = 0;
  $arr = array_unique(str_split(strval($pay)));
  foreach($arr as $value) {
    if (in_array($value, $d)) {
      $flag = 1;
    }
  }
  if (0 === $flag) {
    break;
  }
  $pay++;
} while (1);
echo $pay;

Measured memory_bytes: 4728
#include <iostream>
#include <utility>

using namespace std;

#define MOD 100000
#define MAX_W 100
#define MAX_H 100

struct Cross {
    int west[2], south[2]; // 東、南それぞれについて前回曲がらなかったとき曲がったときのパターン数
};

Cross dp[MAX_H][MAX_W];
int w, h;

void init() {
    for (int i = 0; i < h; i++) {
        dp[i][0].south[0] = 1;
        dp[i][0].south[1] = 0;
    }
    for (int i = 0; i < w; i++) {
        dp[0][i].west[0] = 1;
        dp[0][i].west[1] = 0;
    }
    for (int i = 1; i < h; i++) {
        for (int j = 1; j < w; j++) {
            dp[i][j].west[0] = dp[i][j].west[1] = dp[i][j].south[0] = dp[i][j].south[1] = 0;
        }
    }
}

void solve() {
    for (int i = 1; i < h; i++) {
        for (int j = 1; j < w; j++) {
            dp[i][j].west[0] = dp[i][j-1].west[0] + dp[i][j-1].west[1];
            dp[i][j].west[1] = dp[i][j-1].south[0];
            dp[i][j].south[0] = dp[i-1][j].south[0] + dp[i-1][j].south[1];
            dp[i][j].south[1] = dp[i-1][j].west[0];

            dp[i][j].west[0]  %= MOD;
            dp[i][j].west[1]  %= MOD;
            dp[i][j].south[0] %= MOD;
            dp[i][j].south[1] %= MOD;
        }
    }
}

int main() {
    while (cin >> w >> h) {
        if (w == 0 && h == 0) break;
        init();
        solve();
        Cross g = dp[h-1][w-1];
        cout << (g.south[0] + g.south[1] + g.west[0] + g.west[1]) % MOD << endl;
    }
    return 0;
}

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

using namespace std;

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

    int a, b;
    cin >> a >> b;

    int result = 0;
    for(int i=0; i < 2; i++){
        if(a > b)
            result += a--;
        else{
            result += b--;
        }
    }

    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N int
	fmt.Scan(&N)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}
	sort.Ints(A)
	fmt.Println(A[N-1] - A[0])
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define pii pair<int,int>
#define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
#define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll N, M, a, b; cin >> N >> M;
  vector< vector<ll> > G(N); 
  REP(i,M){
    cin >> a >> b;
    a--; b--; //0-indexed
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  } 
  vector<ll> ans(N,-1);
  

  queue<ll> que;
  vector<bool> visited(N,false);
  visited[0] = true;
  vector<bool> reached(N,false);
  reached[0] = true;
  REP(i,G[0].size()){
    que.push(G[0][i]);
    reached[G[0][i]] = true;
    ans[G[0][i]] = 0;
  }
  
  ll cnt = 0;
  while(!que.empty()){
    //if(cnt == N-1 ) break;
    auto p = que.front();
    que.pop();
    if(!visited[p]){
 	   visited[p] = true;
 	   REP(i,G[p].size()){
 	     if(!reached[G[p][i]]){
           reached[G[p][i]] = true;
 	       que.push(G[p][i]);
 	       if(ans[G[p][i]] == -1 ){
             ans[G[p][i]] = p;
            // cout << G[p][i]+1 << "-->" << p+1 << endl;
           }
 	     }
 	   }
    }
  }
  cout << "Yes" << endl;
  REP2(i,1,N) cout << ans[i] + 1 << endl; //1-indexed
  return 0;
}


Measured memory_bytes: 13128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <algorithm>
#include <iostream>
#include <iterator>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;


class BAtCoderBeginnerContest111 {
public:
    void solve(std::istream& in, std::ostream& out) {
        string str;
        in >> str;

        char top = str[0];
        int xxx = stoi(str);
        int yyy = (int)(top - '0') * 111;

        if (xxx <= yyy) out << yyy << endl;
        else out << yyy + 111 << endl;
    }
};


int main() {
    BAtCoderBeginnerContest111 solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	long long N;
	cin >> N;

	long long ans = N * (N - 1) / 2;

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
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;
    }
};

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
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];
    }
};

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long n;
    scanf("%lld", &n);
    long long k;
    scanf("%lld", &k);

    combination c(n);

    mint res;
    for (size_t i = 0; i <= k; i++)
    {
        res += c(n, i) * c(n - 1, i);
    }
    cout << res.x << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int n,m;

    cin>>n>>m;

    vector<int> v(n);
    double sum = 0;

    for(int k = 0; k < n; k++)
    {
        cin>>v[k];
        sum += v[k];

    }

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


    vector<int>::iterator lower,upper; 
    double g = sum/(4 * m);
    lower = lower_bound (v.begin(), v.end(), g);  




    if(  n - (lower - v.begin()) >= m)
    {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    
  
}

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

using namespace std;

int main(){
	long long n, ans = 0;
	cin >> n;
	vector<long long> a(5);
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		if(s[0] == 'M') a[0]++;
		else if(s[0] == 'A') a[1]++;
		else if(s[0] == 'R') a[2]++;
		else if(s[0] == 'C') a[3]++;
		else if(s[0] == 'H') a[4]++;
	}
	for(int i = 0; i < 5; i++){
		for(int j = i + 1; j < 5; j++){
			for(int k = j + 1; k < 5; k++){
				ans += a[i] * a[j] * a[k];
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/**
*   @Author : MeGA
*   @InitTime :01/24/20 12:43:05
*   @Idea : 
*
*
*
*
*
*
*
**/
#include <bits/stdc++.h>
using namespace std;

const int N=2e5+7;
bool vis[N];
long long val[N];
vector<int>adj[N];

int dfs(int idx,int up){
    if(vis[idx]){
       return 0;
    }
    vis[idx]=1;
    val[idx]+=val[up];
    for(int u:adj[idx]){
        dfs(u,idx);
    }
}
int main(){
#ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
#endif
      int n,q;
      scanf("%d %d",&n,&q);
      for(int i=0;i<n-1;i++){
          int a,b;
          scanf("%d %d",&a,&b);
          adj[a].push_back(b);
          adj[b].push_back(a);
      }
      for(int i=0;i<q;i++){
         int p,x;
         scanf("%d %d",&p,&x);
         val[p]+=x;
      }
      dfs(1,0);
      for(int i=1;i<=n;i++){
          if(i==1){
            printf("%lld",val[i]);
          }else{
            printf(" %lld",val[i]);
          }
           
      }



}

Measured memory_bytes: 21376