akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] c = new int[n+1];
    int[] s = new int[n+1];
    int[] f = new int[n+1];
    for(int i = 1; i < n; i++){
      c[i] = sc.nextInt();
      s[i] = sc.nextInt();
      f[i] = sc.nextInt();
    }
    for(int i = 1; i <= n; i++){
      int tmp = s[i] + c[i];
      for(int j = i + 1; j < n; j++){
        if(tmp < s[j]){
          tmp = s[j];
        }else{
          tmp = f[j] * (int)Math.ceil(tmp / (double)f[j]);
        }
        tmp += c[j];
      }
      System.out.println(tmp);
    }
  }
}

Measured memory_bytes: 27432
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		while(true) {
			count = 0;
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) {
				break;
			} else {
				for(int i = 1;i <= num1; i++){
					for(int j = i + 1;j <= num1;j++){
						for(int y = j + 1;y <= num1;y++){
							if(i + j + y == num2) {
								count++;
							}
						}
					}
				}
				System.out.println(count);
			}
		}





	}
}

Measured memory_bytes: 26660
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n; cin >> n;
  int v[n],c[n],x=0;
  for (int i=0;i<n;i++) {
    cin >> v[i];
  }
  for (int i=0;i<n;i++) {
    cin >> c[i];
  }
  for (int i=0;i<n;i++) {
    if(v[i]>c[i]) {
      x+=v[i]-c[i];
    }
  }
  cout << x << endl;
}

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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList();
        var lenA = inputs[0];
        var lenB = inputs[1];
        var H = inputs[2];
        var M = inputs[3];

        var totalMin = 12 * 60;
        var degA = (H * 60 + M) * 360d / (12d * 60d);
        var degB = M * 360d / 60d;
        var radA = (degA * Math.PI / 180d);
        var radB = (degB * Math.PI / 180d);

        var ax = lenA * Math.Sin(radA);
        var ay = lenA * Math.Cos(radA);
        var bx = lenB * Math.Sin(radB);
        var by = lenB * Math.Cos(radB);

        var dx = Math.Abs(ax - bx);
        var dy = Math.Abs(ay - by);
        var len = Math.Sqrt(Math.Pow(dx, 2) + Math.Pow(dy, 2));
        Console.WriteLine(len);
    }
}

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

int main() {

    int n;

    cin >> n;

    long long int t[n],a[n];

    for(int i=0; i<n; i++){
        cin >> t[i] >> a[i];
    }

    long long int choku = 1,aoki = 1;

    for(int i=0; i<n; i++){

        long long int lef = choku/t[i];

        if(choku%t[i] != 0){
            lef++;
        }

        long long int rig = aoki/a[i];

        if(aoki%a[i] != 0){
            rig++;
        }

        long long int mins = max(lef,rig);

        choku = mins*t[i]; aoki = mins*a[i];

    }

    cout << choku + aoki << endl;

    return 0;
}

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

string s;

int main()
{
	getline(cin,s);
	
	if (s[2]==s[3] && s[4]==s[5])
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
	
	return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
ll n,m;
ll a[200100];
int main(void){
	scanf("%lld %lld",&n,&m);
	for(int i = 1;i<=n;++i){
		scanf("%lld",&a[i]);
	}
	if(m >= n) printf("0\n");
	else{
		ll sum = 0;
		sort(a+1,a+1+n);
		for(int i = 1;i<=(n-m);++i){
			sum += a[i];
		}
		printf("%lld\n",sum);
	}
	return 0;
}

Measured memory_bytes: 1792
function main()
    m=10^9+7
    n=myread(Int)
    a=myreads(Int)
    s=zeros(Int,n+1)
    for i=1:n
        s[i+1]=mod(s[i]+a[i],m)
    end
    ans=0
    for i=1:n
        ans=mod(ans+mod(s[end]*a[i],m),m)
        ans=mod(ans-mod(s[i+1]*a[i],m),m)
    end
    println(ans)
end

# ----------input function----------
sread()=chomp(readline())
sreads(sp=" ")=split(readline(),sp)
myread(ty)=parse(ty,sread())
myreads(ty)=parse.(ty,sreads())
main()

Measured memory_bytes: 201680
#include <iostream>
#include <stack>
#include <queue>
#include <map>
#include <vector>
#include <cstdio>
#include <string>
#include <climits>
#include <cmath>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
    string s;
    cin>>s;
    cout<<s[0];
    cout<<s.size()-2;
    cout<<s[s.size()-1]<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

string N;
vector<ll> n;
ll dp[105][2][105];

main() {
  cin >> N;

  ll K;
  scanf("%lld", &K);

  //ベクターnを構成
  for (auto a : N) {
    n.push_back(a - '0');
  }
  int len = N.size();  // nの長さ

  dp[0][0][0] = 1;  //初期条件。他は0で初期化されている

  for (int i = 0; i < len; i++) {
    for (int smaller = 0; smaller < 2; smaller++) {
      for (int k = 0; k < 10; k++) {
        int lim = smaller ? 9 : n[i];
        for (int l = 0; l <= lim; l++) {
          ll next_smaller = smaller || l < lim;
          ll next_non0_num = k + (l != 0);
          dp[i + 1][next_smaller][next_non0_num] += dp[i][smaller][k];
        }
      }
    }
  }

  ll ans = dp[len][0][K] + dp[len][1][K];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define inf 0x3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int a[102],b[102],c[102],d[102],n;
int g[102][102];
int vis[102],dis[102];
int ans=0;
bool find(int x)
{
    for(int i=1;i<=n;i++)
    {
        if(!vis[i] && g[x][i])
        {
            vis[i]=1;
            if(!dis[i] || find(dis[i]))
            {
                dis[i]=x;
                return true;
            }
        }
    }
    return false;
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
    }
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&c[i],&d[i]);
    }
    memset(g,0,sizeof(g));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(a[i]<c[j] && b[i]<d[j])
                g[i][j]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        memset(vis,0,sizeof(vis));
        if(find(i)) ans++;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
ll mob=1000000007;
using namespace std;
int main()
{ int n;
cin>>n;
ll a=0;
for(long i=1;i<=n;i++)
{
    if(i%5==0||i%3==0)
    {
        continue;
        
    }
    else
    {
        a+=i;
    }
}
cout<<a;

return 0;
}










Measured memory_bytes: 3160
<?php
$ans = "";
fscanf(STDIN, "%d", $N);
for ($i = 0; $i < $N; $i++) {
    fscanf(STDIN, "%d %d %d", $x[$i], $y[$i], $h[$i]);
}
array_multisort($h, SORT_DESC, $x, $y, $h);

for ($xx = 0; $xx <= 100; $xx++) {
    for ($yy = 0; $yy <= 100; $yy++) {
        $hh = abs($xx - $x[0]) + abs($yy - $y[0]) + $h[0];

        $bool = true;
        for ($i = 1; $i < $N; $i++) {
            $tmp = max($hh - abs($xx - $x[$i]) - abs($yy - $y[$i]), 0);
            if ($tmp !== $h[$i]) {
                $bool = false;
                break;
            }
        }
        if ($bool === true) {
            $ans = "{$xx} {$yy} {$hh}";
            break;
        }

    }
}
printf("%s", $ans);


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
   ll n;
   cin>>n;

   int cnt=0;
   for(int i=2; ; i++){
      for(ll z=i; n%z==0; z*=i){
         n/=z;
         cnt++;
      }
      while(n%i==0) n/=i;
      if (n==1) break;
      if (i==1000000){
         if(n>1000000) cnt++;
         break;
      }
   }

   cout << cnt << endl;
   return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    sum += i;
  }
  cout << sum - n << endl;
  return 0;
}


Measured memory_bytes: 256
L, R = list(map(int, input().split(" ")))

if R - L >= 2019:
    print(0)
else:
    L = L % 2019
    R = R % 2019
    
    if L >R:
        print(0)
    else:
        mi = (L*(L+1)) %2019
        for i in range(L, R):
            for j in range(i+1, R+1):
                tmp = (i*j) % 2019
                if tmp < mi:
                    mi = tmp
                    
        print(mi)

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

int main(void)
{
	int i;
	char s[20];

	scanf("%s", s);

	for (i = 0; i < 19; i++) {
		if (i == 5 || i == 13) {
			printf(" ");
			continue;
		}
		printf("%c", s[i]);
	}
	printf("\n");

	return (0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

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

	vector<double> a(n);
	cin >> a;

	double ave = accumulate(all(a), 0.0) / n;
	double diff = 1e8;
	int ans;
	rep(i,n){
		if(abs(a[i] - ave) < diff){
			diff = abs(a[i] - ave);
			ans = i;
		}
	}
	cout << ans << endl;
}


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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b; cout<<max({a+a-1,b+b-1,a+b})<<"\n";
	return 0;
}

Measured memory_bytes: 256
s = list(input())
t = list(input())

last = -1
for i in range(len(s) - len(t)+1):
    for a,b in zip(s[i:i+len(t)], t):
        if a == "?":
            continue
        if a != b:
            break
    else:
        last = i

if last == -1:
    print("UNRESTORABLE")
    import sys
    sys.exit()


ans = s
for i in range(len(ans)):
    if ans[i] == "?":
        ans[i] = "a"

for i in range(len(t)):
    ans[i+last] = t[i]

print("".join(ans))


Measured memory_bytes: 38256
using System;
namespace HelloWorld
{
    class Program
    {
        static void Main()
        {
            string[] line = new string[1500];
            int[] score = new int[1500];
            while (true)
            {
                double sum = 0;
                double sigma = 0;
                int studenti = int.Parse(Console.ReadLine());       //n
                if (studenti == 0) break;
                line = Console.ReadLine().Split();
                for (int i = 0; i < studenti; i++)
                {
                    score[i] = int.Parse(line[i]);
                    sum += score[i];
                }
                double average = sum / studenti; //in the classroom //m
                for (int i = 0; i < studenti; i++)
                {
                    sigma += Math.Pow((score[i] - average), 2);
                }
                double ANSxANS = sigma / studenti;
                Console.WriteLine(Math.Sqrt(ANSxANS));
            }
        }
    }
}


Measured memory_bytes: 15960
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[55][3300][55];
signed main(){
	int n,a;cin >> n >> a;
	int x[n];
	rep(i,n)cin >> x[i];
	dp[0][0][0] = 1;
	rep(m,n+1){
		rep(i,n){
			rep(j,3000){
				int ni = i+1,nj = j+x[i];
				dp[i+1][j][m] += dp[i][j][m];
				dp[ni][nj][m+1] += dp[i][j][m];
			}
		}
	}
	int ans = 0;
	for(int i = 1;i <= n;i++){
		//trace(i,dp[n][a*i][i]);
		ans += dp[n][a*i][i];
	}
	cout << ans << endl;
	

	return 0;
}

Measured memory_bytes: 69256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scan = new Scanner(System.in);
		
		int W = scan.nextInt();
		int H = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int r = scan.nextInt();
		
		if(x + r > W || y + r > H || x < r || y < r) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
		
	}

}


Measured memory_bytes: 26308
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[5000001], invf[5000001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
	int n;
	cin>>n;
	ll c[200020];
	for(int i=0; i<n; i++){
		cin>>c[i];
	}
  sort(c, c+n);
	ll ans=0;
	for(int i=0; i<n; i++){
		(ans+=c[i]*(n+1-i))%=MOD;
	}
	for(int i=0; i<2*n-2; i++){
		(ans*=2)%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int n, le[1005], y[1005], ans = INT_MAX;
map<int, vector<int>> m[20];
map<int, int> s[20];
set<int> hv[20];
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>> q;
char x[20];

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", x);
		le[i] = strlen(x);
		m[0][0].push_back(i);
		for (int j = 0; j < le[i]; ) {
			y[i] = y[i] * 2 + (x[j] == '1');
			m[++j][y[i]].push_back(i);
		}
		hv[le[i]].insert(y[i]);
	}
	for (int ii = 0; ii < n; ii++) {
		int val = le[ii];
		int lee = le[ii];
		int bm = y[ii];
		auto it = m[lee].find(bm);
		if (it == m[lee].end())
			continue;
		for (int i : it->second)
			if (i != ii) {
				int nle = le[i] - lee;
				int nbm = y[i] - (bm << nle);
				int nval = val + nle;
				// printf("nle=%d nbm=%d nval=%d i=%d %d ii=%d %d %d\n", nle, nbm, nval, i, y[i], ii, y[ii], (bm << lee));
				auto pp = s[nle].insert(make_pair(nbm, nval));
				if (!pp.second && pp.first->second <= nval)
					continue;
				pp.first->second = nval;
				q.emplace(nval, make_pair(nle, nbm));
			}
	}
	while (!q.empty()) {
		int val = q.top().first;
		int lee = q.top().second.first;
		int bm = q.top().second.second;
		q.pop();
		if (s[lee][bm] != val)
			continue;
		// printf("val=%d lee=%d bm=%d\n", val, lee, bm);
		for (int i = 1; i < lee; i++) {
			int tbm = bm >> (lee - i);
			if (hv[i].count(tbm)) {
				int nle = lee - i;
				int nbm = bm - (tbm << (lee - i));
				int nval = val;
				auto pp = s[nle].insert(make_pair(nbm, nval));
				if (!pp.second && pp.first->second <= nval)
					continue;
				pp.first->second = nval;
				q.emplace(nval, make_pair(nle, nbm));
			}
		}
		auto it = m[lee].find(bm);
		if (it == m[lee].end())
			continue;
		for (int i : it->second) {
			if (le[i] == lee)
				ans = min(ans, val);
			else {
				int nle = le[i] - lee;
				int nbm = y[i] - (bm << nle);
				int nval = val + nle;
				auto pp = s[nle].insert(make_pair(nbm, nval));
				if (!pp.second && pp.first->second <= nval)
					continue;
				pp.first->second = nval;
				q.emplace(nval, make_pair(nle, nbm));
			}
		}
	}
	printf("%d\n", ans == INT_MAX ? 0 : ans);
}



Measured memory_bytes: 3936
#include<bits/stdc++.h>
using namespace std;
 const int N = 100;
int a[2 * N] = { 0 };

int main ()
{
   int n, k= 0;
	cin >> n;
	for(int i = 0; i < 2 * n; ++i)
	{
		cin >> a[i];
	}
	sort(a, a + 2 * n, greater<int>() );
	for(int i = 0; i < 2 * n; i += 2){
		k+= min(a[i], a[i + 1]);
	}
	cout << k << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=1e3+5;
const ll inf=1e18;
int main()
{
    ll n;
    cin>>n;
    vector<ll>  a(n);
    for(ll i=0; i<n; i++)
        cin>>a[i];
    sort(a.begin(), a.end());
    ll prod=1;
    for(ll i=0; i<n; i++)
    {
        if(prod*a[i]!=1000000000000000000&&prod>=ceil(1000000000000000000*1.0/(a[i]*1.0)))
        {
            cout<<-1;
            return 0;
        }
        prod*=a[i];
    }
    cout<<prod;
}

Measured memory_bytes: 3992
#![allow(non_snake_case)]
use std::cmp::Ordering;

#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

#[derive (Debug, Eq, PartialEq)]
struct Restaurant {
    id: usize,
    city: String,
    point: i32,
}

impl Restaurant {
    fn new(id: usize, city: String, point: i32) -> Self {
        Restaurant {
            id: id,
            city: city,
            point: point,
        }
    }
}

impl Ord for Restaurant {
    fn cmp(&self, other: &Self) -> Ordering {
        if self.city != other.city {
            self.city.cmp(&other.city)
        } else {
            other.point.cmp(&self.point)
        }
    }
}

impl PartialOrd for Restaurant {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}

fn main() {
    input! {
        N: usize,
        rs_: [(String, i32); N],
    }
    let mut rs = vec![];
    for i in 0..N {
        rs.push(Restaurant::new(i, rs_[i].0.clone(), rs_[i].1.clone()));
    }
    rs.sort();

    for i in 0..N {
        println!("{}", rs[i].id + 1);
    }
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    int n; cin >> n;
    double count = 0;
    rep1(i,n){
        if(i & 1) count++;
    }
    cout << count / (n + 0.0);
    }



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

ll dp[45];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int n;
    cin >> n;
    dp[0] = 1;
    dp[1] = 1;
    for(int i=2; i<=n; ++i){
        dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;
    
	return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define exists(s,x) (s).find(x)!=(s).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)
#define fi first
#define se second

template<class T>
class SegTree {
    int n;
    vector<T> dat;
    T id;
    function<T(T,T)> op;
    function<T(T,T)> update;

    T query_(int a, int b, int k, int l, int r) {
        if(r<=a || b<=l) return id;
        if(a<=l && r<=b) return dat[k];
        T c1 = query_(a,b,2*k+1,l,(l+r)/2);
        T c2 = query_(a,b,2*k+2,(l+r)/2,r);
        return op(c1,c2);
    }
public:
    SegTree(int n_, T id_, function<T(T,T)> op_, function<T(T,T)> update_)
        : id(id_), op(op_), update(update_) {
            n = 1;
            while(n<n_) n*=2;
            dat = vector<T>(2*n-1, id);
    }

    void change(int i, T x) {
        i += n - 1;
        dat[i] = update(dat[i], x);
        while(i>0) {
            i = (i-1)/2;
            dat[i] = op(dat[2*i+1], dat[2*i+2]);
        }
    }

    T query(int a, int b) {return query_(a,b,0,0,n);}

    T operator[](int i) {return dat[i+n-1];}
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    string s; cin >> s;
    auto op = [](bitset<26> a, bitset<26> b) { return (a|b);};
    auto update = [](bitset<26> a, bitset<26> b) {return b;};
    SegTree<bitset<26>> ST(N,bitset<26>(0),op,update);
    REP(i,N) {
        bitset<26> b;
        b.set(s[i]-'a');
        ST.change(i,b);
    }
    int q; cin >> q;
    while(q--) {
        int type; cin >> type;
        if(type == 1) {
            int idx; char c;
            cin >> idx >> c; idx--;
            bitset<26> b;
            b.set(c-'a');
            ST.change(idx,b);
        }
        else {
            int l,r; cin >> l >> r; l--;
            cout << ST.query(l,r).count() << '\n';
        }
    }
    return 0;
}

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


int main(){
    int rate;
    cin >> rate;
    if(rate<1200) cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)

	var n int
	fmt.Fscan(r, &n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &s[i])
	}

	var q int
	fmt.Fscan(r, &q)
	t := make([]int, q)
	for i := 0; i < q; i++ {
		fmt.Fscan(r, &t[i])
	}

	found := make(map[int]int, 0)
	for _, v1 := range s {
		for _, v2 := range t {
			if v1 == v2 {
				found[v1]++
			}
		}
	}

	fmt.Println(len(found))
}



Measured memory_bytes: 1244
K = int(input())
# K = 2
import math
import itertools

def better_gcd(a,b,c):
    tup = set((a,b,c))
    kinds = len(tup)
    if kinds == 3:
        return math.gcd(a, math.gcd(b, c)) * 6
    elif kinds == 2:
        return math.gcd(*tup) * 3
    else:
        return a

ans = 0
cands = list(itertools.combinations_with_replacement(range(1,K+1), 3))
for c in cands:
    ans += better_gcd(*c)
print(ans)

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

typedef long long ll;

int n;
ll a[100000];

ll solve(int i, bool s, ll p){
    if(i == n){
        return 0;
    }

    ll v = a[i] + p;

    ll q = 0;
    if(s && v <= 0){
        q = 1 - v;
    }
    else if(!s && v >= 0){
        q = -1 - v;
    }
    
    return abs(q) + solve(i + 1, !s, p + q);
}

int main(){
    cin >> n;
    rep(i, n){
        cin >> a[i];
    }

    rep(i, n - 1){
        a[i + 1] += a[i];
    }

    cout << min(solve(0, true, 0), solve(0, false, 0)) << endl;
    return 0;
}

Measured memory_bytes: 2560
n = int(input())
sp = [ input().split() for i in range(1,n+1) ]

#n = 6
#sp = [['khabarovsk', '20'], ['moscow', '10'], ['kazan', '50'], ['kazan', '35'], ['moscow', '60'], ['khabarovsk', '40']]

for i in range(n):
  sp[i][1] = int(sp[i][1])
  sp[i].append(i+1)

sp.sort(key=lambda x:(x[0],-x[1]))

for _,_,i in sp:
  print(i)


Measured memory_bytes: 3060
#!/usr/bin/env python
# coding: utf-8

# In[12]:


N = int(input())
B = list(map(int, input().split()))


# In[14]:


A = [B[0]]
for i in range(N-2):
    A.append(min(B[i],B[i+1]))
A.append(B[-1])
print(sum(A))


# In[ ]:






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

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forn(i,n) for (int i = 0; i < n; i++)
#define forr(i,a,b) for (int i = a; i <= b; i++)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const int MX = 200005, mod = 1000000007;
int b, w;
ll fac[MX], inv[MX], x, y;

ll pot (ll b, int p) {
	ll res = 1;
	while (p) {
		if (p & 1) (res *= b) %= mod;
		(b *= b) %= mod;
		p /= 2;
	}
	return res;
}

ll comb (int n, int k) {
	if (n < k || n < 0) return 0;
	return fac[n] * inv[n - k] % mod * inv[k] % mod;
}

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	fac[0] = inv[0] = 1;
	for (int i = 1; i < MX; i++) {
		fac[i] = i * fac[i - 1] % mod;
		inv[i] = pot(fac[i], mod - 2);
	}

	cin >> b >> w;

	for (int i = 1; i <= b + w; i++) {
		(x += comb(i - 2, b - 1) * pot(pot(2, i - 1), mod - 2)) %= mod;
		(y += comb(i - 2, w - 1) * pot(pot(2, i - 1), mod - 2)) %= mod;

		cout << MOD((1 - x - y) * pot(2, mod - 2) + y, mod) << endl;
	}

	return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <vector>

using namespace std;

#define rep(i,n) for(int i=0;i<int(n);i++)

int calc(vector<int>& c,int k)
{
	int res=1;
	rep(i,c.size()-k+1){
		int temp=1;
		rep(j,k)
			temp*=c[i+j];
		res=max(res,temp);
	}
	return res;
}

int main()
{
	for(int n,k;cin>>n>>k,n|k;){
		vector<int> c(n);
		rep(i,n) cin>>c[i];
		
		int before=calc(c,k);
		int after=before;
		rep(i,n) rep(j,i){
			swap(c[i],c[j]);
			after=max(after,calc(c,k));
			swap(c[i],c[j]);
		}
		cout<<after-before<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define umap unordered_map
//std::cout << std::setfill('0') << std::right << std::setw(4) << 12; // "0012"

ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}


int main(){
  int N; cin>>N;
  bool odd = false;
  ll a[N]; CINA(a,N);
  sort(a,a+N);
  ll r = a[0];
  for(int i=1;i<N;i++){
    r = gcd(a[i],r);
  }
  cout << r;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))
ans="Yes"
a.append(10000000000)
for i in range(n):
    if a[i]>a[i+1]:
        ans="No"
    elif a[i]<a[i+1]:
        a[i+1]-=1
print(ans)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i = 0;i<n;i++) cin >> x[i];
    sort(all(x));
    int ans = INF;
    
    for(int p = 1;p <= x.back();p++){
        int cost=0;
        for(int i = 0;i<n;i++){
            cost += (x[i]-p)*(x[i]-p);
        }
        ans = min(ans,cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
int main(){ 
  
  long long a;
  double b;
  
  std::cin >> a >> b;
  
  long long ib = b * 100 + 0.5;
  a *= ib;
  a /= 100;
  
  printf("%lld\n",a);
  
 return 0; 
}

Measured memory_bytes: 3784
t = []

n = gets.to_i

count = 0

n.times do
  a = gets.to_i
  xys = []

  a.times do
    x, y = gets.split.map(&:to_i)
    xys << [x, y]
  end

  t << xys
end

# puts t.to_s

(2**n).times do |i|
  fl = true

  nn = i.to_s(2)
  nn = nn.rjust(n, '0')

  n.times do |j|
    next if nn[j] == '0'

    t[j].each do |x, y|
      fl = false if nn[x - 1] != y.to_s
    end
  end

  if fl
    count = [nn.count('1'), count].max
  end
end

puts count


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    rep(i, 365) {
        cout << 26-i%26 << endl;
    }
}

Measured memory_bytes: 3628
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;

int main() {
	int h, w, kk;
	cin >> h >> w >> kk;
	int dp[105][10] = {};
	dp[0][0] = 1;
	
	rep(i, h) {
		rep(j, w) {
			rep(k, 1 << (w - 1)) {
				bool ok = 1;
				rep(l, w - 2) {
					if ((k >> l & 1) && (k >> (l + 1) & 1))
						ok = 0;
				}
				//*
				if (ok) {
					if ((k >> (j - 1) & 1) && j > 0) {
						dp[i + 1][j] += dp[i][j - 1];
						dp[i + 1][j] %= mod;
					}
					else if ((k >> j & 1) && j < w - 1) {
						dp[i + 1][j] += dp[i][j + 1];
						dp[i + 1][j] %= mod;
					}
					else {
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= mod;
					}
				}
				//*/
				/*/
				if (ok) {
					if (j >= 1 && ((k >> (j - 1)) & 1)) {
						// The case which goes left
						// 左方向に横線をたどるケース
						dp[i + 1][j - 1] += dp[i][j];
						dp[i + 1][j - 1] %= mod;
					}
					else if (j <= w - 2 && ((k >> j) & 1)) {
						// The case which goes right
						// 右方向に横線をたどるケース
						dp[i + 1][j + 1] += dp[i][j];
						dp[i + 1][j + 1] %= mod;
					}
					else {
						// The case which goes straight
						// 横線をたどらないケース
						dp[i + 1][j] += dp[i][j];
						dp[i + 1][j] %= mod;
					}
				}
				//*/
			}
					   			 		
		}
	}


	cout << dp[h][kk-1] << endl;
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#define INF (__INT32_MAX__ / 2)

using namespace std;

int year, month, date;
int main(int argc, char **argv) {
    scanf("%d/%d/%d", &year, &month, &date);

    if(year < 2019) printf("Heisei\n");
    else if(year > 2019) printf("TBD\n");

    else if(month < 4) printf("Heisei\n");
    else if(month > 4) printf("TBD\n");

    else if(date < 30) printf("Heisei\n");
    else if(date > 30) printf("TBD\n");

    else printf("Heisei\n");
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> books;
int m,n;

bool check(int r){
	int rank=0;
	int place=0;
	for(int i = 0; i < books.size(); i++){
		if(books[i]>r)
			return false;
		// àµTCYª éå«³æè¬³¯êÎ
		if(place+books[i]<=r){
			place+=books[i];
		}
		else{
			rank++;
			if(rank>=m)
				return false;
			place=0;
			place+=books[i];
		}
	}
	return true;
}

int main(){

	while(cin>>m>>n&&!(n==0&&m==0)){
		for(int i = 0; i < n; i++){
			int t;
			cin>>t;
			books.push_back(t);
		}

		int ub=1500000;
		int lb=-1;
		while(ub-lb>1){
			int med=ub+lb;
			med/=2;
			// ¨¯éÈç
			if(check(med)){
				ub=med;
			}
			else{
				lb=med;
			}
		}
		cout<<ub<<endl;
		books.clear();
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;


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

	ll n;
	cin >> n;

	vector<ll> bat(100001, 0);

	vector<ll> a(n);
	ll sum = 0;
	rep(i, n)
	{
		cin >> a[i];
		bat[a[i]]++;
		sum += a[i];
	}

	ll q;
	cin >> q;

	vector<ll> b(q), c(q);
	rep(i, q)
	{
		cin >> b[i] >> c[i];
		sum -= bat[b[i]] * b[i];
		sum += bat[b[i]] * c[i];
		bat[c[i]] += bat[b[i]];
		bat[b[i]] = 0;
		cout << sum << endl;
	}




	return 0;
}

Measured memory_bytes: 6360
# -*- coding:utf-8 -*-

def solve():
    K, N = list(map(int, input().split()))
    As = list(map(int, input().split()))

    As.sort()
    if len(As) == 1:
        print(0)
        return

    Ls = []  # 隣家間の距離をぶちこんでいく
    for i in range(1, len(As)):
        Ls.append(As[i]-As[i-1])
    Ls.append(As[0] + K-As[-1])

    Ls.sort()
    print(K-Ls[-1])


if __name__ == "__main__":
    solve()


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

#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define lfs <<fixed<<setprecision(10)<<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = n - 1; i >= (ll)(m); i--)
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>v,ll n){cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
template<typename T>
void emp(map<T,ll>&m, T x){m.emplace(x,0).first->second++;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  ll res=0,res1=INF,res2=-INF,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>q(n),x(n);
  rep(i,0,n)cin>>q[i]>>x[i];
  ll a=1,b=0;
  rep(i,0,n){
    if(q[i]==1){
      a*=x[i];b*=x[i];
    }
    else if(q[i]==2){
      b+=x[i];
    }
    else b-=x[i];
  }
  cout<<-b spa a<<endl;
  return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

std::map<long long, long long> PrimeFactorization(long long iValue)
{
    std::map<long long, long long> result;
    long long rootValue = sqrt(iValue);
    long long tmpValue = iValue;
    for (long long i = 2; i <= rootValue; i++)
    {
        int divisionCnt = 0;
        while (tmpValue % i == 0)
        {
            tmpValue /= i;
            divisionCnt++;
        }

        if (divisionCnt != 0)
        {
            result[i] = divisionCnt;
        }
    }
    if (1 != tmpValue)
    {
        result[tmpValue] = 1;
    }
    return result;
}


int main(void)
{
    long long n;
    cin >> n;

    map<long long, long long> pf;
    pf = PrimeFactorization(n);

    long long tmpN = n;
    long long ans = 0;
    for (const auto& kv : pf) {
        for (long long i = 1; i <= kv.second; i++)
        {
            long long currentZ = pow(kv.first, i);
            if (0 == tmpN%currentZ)
            {
                ans++;
                tmpN /= currentZ;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    string s;

    cin >> s;

    if(s == "AAA" or s == "BBB") cout << "No\n";
    else cout << "Yes\n";


  
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

int main(int argc, char **argv)
{
  std::string S;
  std::cin >> S;
  
  uint64_t N  = S.size(); 
  uint64_t Nw = std::count(S.begin(), S.end(), 'W');
  
  //  W ...... W B ...... B
  // | <- Nw -> | <- Nb -> |
  //  0 ... Nw-1|Nw ... N-1
  
  uint64_t c = 0, m = Nw;
  for (uint64_t n = 0; n < N; ++n) {
    if (S[n] == 'B') {
      c += m - n;
      ++m;
    }
  }
  std::cout << c << std::endl;
  
  return 0;
}

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

using namespace std;

const int N=1e5+10;
const int M=4e3+10;
int n,k;
int a[2][M][M];

void reduce(int &x,int &y){
        int px=x/k,py=y/k;
        int sh=min(px,py);
        x-=sh*k;y-=sh*k;
        px=x/(2*k),py=y/(2*k);
        x-=px*2*k,y-=py*2*k;
        if (x>=k) y+=k,x-=k;
}
int get(int type,int xb,int yb,int xa,int ya){
        return a[type][xb][yb]+a[type][xa][ya]-a[type][xa][yb]-a[type][xb][ya];
}
int main(){
        cin>>n>>k;
        for(int i=1;i<=n;i++){
                int x,y;
                char ch;
                cin>>x>>y>>ch;
                reduce(x,y);
//                cout<<x+1<<" "<<y+1<<'\n';
                a[ch=='B'][x+1][y+1]++;
        }
        for(int type=0;type<=1;type++){
                for(int i=1;i<=k;i++)
                        for(int j=1;j<=2*k;j++) a[type][i][j+2*k]=a[type][i][j];
                for(int i=1;i<=k;i++)
                        for(int j=1;j<=4*k;j++) a[type][i+k][(j-1+k)%(4*k)+1]=a[type][i][j];
                for(int i=1;i<=2*k;i++)
                        for(int j=1;j<=4*k;j++) a[type][i][j]+=a[type][i-1][j]+a[type][i][j-1]-a[type][i-1][j-1];
        }
        int ans=0;
        for(int rx=1;rx<=k;rx++)
                for(int ry=1;ry<=2*k;ry++){
                        int cx0=rx+k-1,cy0=ry+k-1;
                        int cx1=cx0,cy1=cy0+k;
                        ans=max(ans,get(0,cx0,cy0,cx0-k,cy0-k)+get(1,cx1,cy1,cx1-k,cy1-k));
                }
        cout<<ans;
}


Measured memory_bytes: 65792
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    n, m = [int(i) for i in input().strip().split()]
    accepted = [False] * (n + 1)
    WA_cnt = [0] * (n + 1)
    for _ in range(m):
        p, s = input().strip().split()
        p = int(p)
        if accepted[p]:
            continue
        else:
            if s == "AC":
                accepted[p] = True
            elif s == "WA":
                WA_cnt[p] += 1
    ac = 0
    wa = 0
    for res, cnt in zip(accepted, WA_cnt):
        if res:
            ac += 1
            wa += cnt

    print(ac, wa)

    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 10440
// ConsoleApplication1.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <stdio.h>
#include <iostream>


using namespace std;

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

	if (S == "ABC") cout << "ARC";
	else cout << "ABC";
	return 0;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 3132
N,K = map(int,input().split())
R,S,P = map(int,input().split())
win = {'r':P,'s':R,'p':S}
T = input()
WAKE = ['']*K

for i in range(N):
    WAKE[i%K] += T[i]

ans = 0
for i in range(K):
    if len(WAKE[i])>=0:
        pre = WAKE[i][0]
        ans += win[pre]
        for j in range(1,len(WAKE[i])):
            now = WAKE[i][j]
            if pre != now:
                ans += win[now]
                pre = now
            else:
                pre = ''
print(ans)

Measured memory_bytes: 6132
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
using namespace std;
int main()
{
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a <= k) {
		cout << "Yay!";
	}
	else {
		cout << ":(";
	}
	return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
h = [int(input()) for _ in range(N)]
h.sort()
res = 10 ** 9
for i in range(N - K + 1):
  hmin, hmax = h[i], h[i + K - 1]
  res = min(res, hmax - hmin)
print(res)

Measured memory_bytes: 7384
#include <iostream>
using namespace std;
void ABC60(void);
void ABC61(void);
void ABC62(void);
void ABC63(void);
void ABC64(void);
void ABC65(void);
void ABC66(void);
void ABC67(void);
void ABC68(void);
void ABC69(void);

int main(void){
    ABC63();
}

void ABC63(void){
    int a,b;
    cin>>a>>b;
    if(a+b<10)cout<<a+b;
    else cout<<"error";
}

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

int main(){
    typedef pair<int, int> P;
    int n;
    cin >> n;
    vector<bool> check(n+1);
    vector<long long> distance(n+1);
    for (int i = 0; i<=n; i++){
        check[i] = false;
        distance[i] = 0;
    }
    check[1] = true;
    vector<vector<P>> move(n+1);
    int x,y,z;
    for (int i = 1; i<n; i++){
        cin >> x >> y >> z;
        move[x].push_back({y, z});
        move[y].push_back({x, z});
    }
    queue<int> q;
    q.push(1);
    while (q.size() > 0){
        x = q.front(); q.pop();
        for (int i = 0; i<move[x].size(); i++){
            y = move[x][i].first;
            z = move[x][i].second;
            if (!check[y]){
                check[y] = true;
                distance[y] = distance[x] + z;
                q.push(y);
            }
        }
    }
    for (int i = 1; i<=n; i++){
        if (distance[i] % 2) cout << 0 << endl;
        else cout << 1 << endl;
    }
}



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

int main(void){
    int H,W;
    cin >> H >> W;
    vector<string> vec(2*H);
    for(int i=0;i<2*H;i+=2){
        cin >> vec[i];
        vec[i+1] = vec[i];
    }
    for(int i=0;i<2*H;i++) cout << vec[i] << endl;
}

Measured memory_bytes: 256