akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int dfs(int k, int n, int pn, int d){
  if (d == 0) {
    // if(k == 0) {
    //   for(auto aa:a) LOG("%2d ", aa);
    //   LOG("\n");
    // }
    return (k == 0) & 1;
  }
  int res = 0;
  FOR(i, pn + 1, n + 1){
    int nk = k - i;
    if(nk < 0) continue;
    res += dfs(nk, n, i, d - 1);
  }
  return res;
}

int main() {
  int n, s, k;
  while(cin >> n >> s >> k, n | s | k) {

    cout << dfs(k, n, 0, s) << endl;
  }
}

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

int main()
{
    string s;
    bool status;
    bool a[26] = {0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0};

    while( cin >> s )
    {
        if( s == "#" )
            break;
        status = a[s[0]-'a'];
        int cnt = 0;
        for( int i = 1; i < s.size(); i++ )
            if( a[s[i]-'a'] != status )
            {
                cnt++;
                status = a[s[i]-'a'];
            }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

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

    int n;
    cin >> n;
    vector<long long> A(n);
    for(int i = 0; i < n; i++){
        cin >> A[i];
    }

    // 素因数分解
    map<int, int> mp;
    for(int i = 0; i < n; i++){
        int tmp = A[i];
        for(int j = 2; j <= sqrt(A[i]); j++){
            if(tmp % j == 0){
                int cnt = 0;
                while(tmp % j == 0){
                    tmp /= j;
                    cnt++;
                }
                if(mp.count(j)) mp[j] = max(mp[j], cnt);
                else mp[j] = cnt;
            }
            if(tmp == 1) break;
        }
        if(tmp != 1){
            if(mp.count(tmp)) mp[tmp] = max(mp[tmp], 1);
            else mp[tmp] = 1;
        }
    }

    long long l = 1;
    for(auto x : mp){
        for(int i = 0; i < x.second; i++){
            l = (l * x.first) % MOD;
        }
    }

    long long ans = 0;
    for(int i = 0; i < n; i++){
        ans = (ans + (l * modinv(A[i], MOD)) % MOD) % MOD;
    }

    cout << ans << endl;

    return 0;
}

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

int main(void){
    int N;
    cin >> N; 
    int arr[N];
    for(int i = 0; i < N; ++i){
        cin >> arr[i];
        cout << arr[i];
        if(i != N - 1)
            cout << " ";
    }
    cout << endl;
    for(int i = 1; i < N; ++i){
        int key = arr[i];
        int j = i - 1;
        while(j >= 0 && arr[j] > key){
            arr[j + 1] = arr[j];
            --j;
        }
        arr[j + 1] = key;
        for(int k = 0; k < N; ++k){
            cout << arr[k];
            if(k != N - 1)
                cout << " ";
        }
        cout << endl;
    }
    return 0;
}

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


#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep3(i, n, m) for (int i = n; i <= m; i++)

using ll = long long;

/* vector<ll> v(N);
  小さい順: sort(v.begin(), v.end());
  逆順: reverse(v.begin(), v.end());
  vector<pair<ll, ll> > p; ＃ソートした場合、１つ目でソート
  tie(b, a) = p.at(i); #pairを分割
  tasks.emplace_back(b, a)  ＃配列tasksの最後に(b,a)を追加
  xの二乗:  pow(x, 2.0);
  int: -2,147,483,648 ～ 2,147,483,647(2×10^9)
  ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807(9×10^18)
  long long型の2次元配列(3×4要素の)の宣言
  vector<vector<ll>> ;
  string -> int : stoi(S);
  int -> string : to_string(N);
  Sのn文字以降をm文字取り出す : S.substr(n,m)
*/
 
 //126~
 //126-d

int main() {
  int n,m,ans;
  int Max =0;
  int Min =10000000;
  cin >> n>> m;
  vector<int> l(m),r(m);
  rep(i,m){
    cin >> l[i] >> r[i];
    Max= max(Max,l[i]);
    Min= min(Min,r[i]);
  }
  ans=max(0,Min-Max+1);
  
  cout << ans << endl;

}

Measured memory_bytes: 1024
n = gets.to_i
all_sum = (1 + n) * n / 2
fizz_count = n / 3
fizz_sum = fizz_count > 0 ? (1 + fizz_count) * fizz_count * 3 / 2 : 0
buzz_count = n / 5
buzz_sum = buzz_count > 0 ? (1 + buzz_count) * buzz_count * 5 / 2 : 0
fizzbuzz_count = n / 15
fizzbuzz_sum = fizzbuzz_count > 0 ? (1 + fizzbuzz_count) * fizzbuzz_count * 15 / 2 : 0
ans = all_sum - fizz_sum - buzz_sum + fizzbuzz_sum
puts ans


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

int main() {
    int a,b;
    cin >> a >> b;
    char c,d;
    c = '0' + a;
    d = '0' + b;
    string s,t;
    for (int i = 0; i < b; ++i) {
        s.push_back(c);
    }
    for (int i = 0; i < a; ++i) {
        t.push_back(d);
    }
    if (s > t) cout << t << endl;
    else
    {
        cout << s << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<l_l> D;
ll SIZE[100500];
map<ll, ll> mp;
ll dist[100050];
vector<ll> pathes[100050];
ll ONED;

void dfs(int now, int from) {
    for(auto to : pathes[now]) {
        if(to == from) continue;
        dist[to] = dist[now] + 1;
        dfs(to, now);
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    D.resize(N);
    for(int i = 1; i <= N; i++) {
        cin >> D[i-1].first;
        D[i-1].second = i;
        SIZE[i] = 1;
        mp[D[i-1].first] = i;
    }
    ONED = D[0].first;
    sort(D.begin(), D.end(), greater<l_l>());
    vector<l_l> ans;
    for(int i = 0; i < N - 1; i++) {
        int index = D[i].second;
        ll val = D[i].first;
        val += SIZE[index] - (N - SIZE[index]);
        if(SIZE[index] * 2 >= N) {
            cout << -1 << endl;
            return 0;
        }
        if(mp[val] == 0) {
            cout << -1 << endl;
            return 0;
        }
        SIZE[mp[val]] += SIZE[index];
        ans.push_back({index, mp[val]});
        pathes[index].push_back(mp[val]);
        pathes[mp[val]].push_back(index);
    }
    dfs(1, -1);
    ll distsum = 0;
    for(int i = 1; i <= N; i++) distsum += dist[i];
    if(distsum != ONED) {
        cout << -1 << endl;
        return 0;
    }
    for(auto e : ans) cout << e.first << " " << e.second << endl;
    return 0;
}

Measured memory_bytes: 22384
using System;
using System.Collections.Generic;
 
class Program
{
    static void Main(string[] args)
    {
        var Box = Console.ReadLine();
        var Each = Box.Split(' ');
        int A, B, num;
        A = int.Parse(Each[0]);
        B = int.Parse(Each[1]);
        num = A + B;
        if(A % 3 == 0 || B % 3 == 0 || num % 3 == 0)
        {
          Console.WriteLine("Possible");
        }
        else
        {
          Console.WriteLine("Impossible");
        }
      
        Console.ReadLine();
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
int n,m;
deque<int> di,dt;
priority_queue<int> pqi,pqt;
int res=0;
void dfs(int x,int y,priority_queue<int> pq,deque<int> d)
{
	/*//begin
	cout <<x<<" "<<y<<" ##\n";
	pqt=pq;
	while (!pqt.empty())
	{
		cout <<-pqt.top()<<" ";
		pqt.pop();
	}
	cout <<"\n";
	dt=d;
	while (!dt.empty())
	{
		cout <<dt.front()<<" ";
		dt.pop_front();
	}
	cout <<"\n\n";
	//end   --------------------必须删! */
	if (x==2)
	{
		while (y && !pq.empty())
		{
			int t=-pq.top();
			if (t>0) break;
			pq.pop();
			y--;
		}
		int r=0;
		while (!pq.empty())
		{
			r+=-pq.top();
			pq.pop();
		}
		//cout <<"r: "<<r<<" ############################\n";
		res=max(res,r);
		return;
	}
	if (x==1)
	{
		for (int i=0;i<=y;i++)
		{
			int t=i;
			dt=d,pqt=pq;
			while (t && !dt.empty())
			{
				pqt.push(-dt.front());
				dt.pop_front();
				t--;
			}
			dfs(2,y-i,pqt,dt);
		}
	}
	else
	{
		for (int i=0;i<=y;i++)
		{
			int t=i;
			dt=d,pqt=pq;
			while (t && !dt.empty())
			{
				pqt.push(-dt.back());
				dt.pop_back();
				t--;
			}
			dfs(1,y-i,pqt,dt);
		}
	}
}
int main()
{
	cin >>n>>m;
	for (int i=0;i<n;i++)
	{
		int x;
		cin >>x;
		//x=i+1-n/2;
		di.push_back(x);
	}
	dfs(0,m,pqi,di);
	cout <<res;
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import *

N = int(input())
a = list(map(int, input().split()))
l = min(a)
r = max(a)
ans = 10**18

for i in range(l, r+1):
    cnt = 0
    
    for ai in a:
        cnt += (ai-i)**2
    
    ans = min(ans, cnt)

print(ans)

Measured memory_bytes: 38512
n,m=map(int, input().split())
a=[]
for i in range(m):
  a.append(int(input()))
  

mod=1000000007

dp=[0]*(n+1)
dp[0]=1


if n==1:
  print(1)
  exit()

if m==0:
  dp[1]=1
  for i in range(n-1):
    dp[i+2]=dp[i+1]+dp[i]
  dp[i+2] = dp[i+2] % mod
  print(dp[n])
  exit()

if a[0]==1:
  dp[1]=0
else:
  dp[1]=1



a_i2=0
a_i1=0
a_i=0

for i in range(n-1):
  if i+2 == a[a_i2]:
      a_i2 += 1
      if a_i2 == m:
        a_i2 -= 1
  else:
    if i+1 == a[a_i1]:
      if i == a[a_i]:
        dp[i+2]=0
        a_i += 1
        if a_i == m:
          a_i -= 1
      else:
        dp[i+2]=dp[i]
      a_i1 += 1
      if a_i1 == m:
        a_i1 -= 1
    else:
      if i == a[a_i]:
        dp[i+2]=dp[i+1]
        a_i += 1
        if a_i == m:
          a_i -= 1
      else:
        dp[i+2]=dp[i+1]+dp[i]

  dp[i+2] = dp[i+2] % mod
  #print(dp)

print(dp[n])



Measured memory_bytes: 460148
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int A = scan.nextInt();
		int B = scan.nextInt();
		int C = scan.nextInt();
		int number = 0;

		Integer[] checker = {A, B, C};
		Arrays.sort(checker);

		System.out.println(checker[2] * 10 + checker[1] + checker[0]);

	}
}

Measured memory_bytes: 23124
#include<iostream>

using namespace std;

int cnt[102];

int main() {
    while (1) {
        int n, q;
        cin >> n >> q;
        if (n == 0) break;

        for (int i = 0; i < 102; ++i) cnt[i] = 0;
        for (int i = 0; i < n; ++i) {
            int m;
            cin >> m;
            for (int j = 0; j < m; ++j) {
                int day;
                cin >> day;
                cnt[day]++;
            }
        }

        int ans = 0;
        int maxcnt = 0;
        for (int i = 1; i < 102; ++i) {
            if (cnt[i] > maxcnt){
                ans = i;
                maxcnt = cnt[i];
            }
        }

        cout << (maxcnt < q ? 0 : ans) << endl;
    }
}

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

int main(){
    int N; cin >> N;
    map<int, int> mp;
    for(int i = 0; i <N; i++){
        int t; cin >>t;
        mp[t]++;
    }
    int ans = 0;
    for(auto p: mp){
        int x = p.first;
        int n = p.second;
        if(n < x) ans += n;
        else ans += n - x;
    }

    cout << ans <<endl;
}

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

int main()
{
    int i,c=0;
    char a[3];
    scanf("%s",a);
    for(i=0;i<3;i++){
        if(a[i]=='A'&&a[i+1]=='B'||a[i]=='B'&&a[i+1]=='A'){
            c=1;
            break;
        }

    }
    if(c==1)
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 128
r, c = map(int, input().split())
d = [0] * c

for _ in range(r):
    a = input()
    b = list(map(int, a.split()))
    e = sum(b)
    a += ' {}'.format(e)
    print(a)
    d = [d[i] + b[i] for i in range(c)]

d = list(map(int, d))
g = sum(d)
f = ''
for i in d:
    f += str(i) + ' '
f += str(g)
print(f)



Measured memory_bytes: 5616
import math
import itertools

def swap(a,b):
    return max(a,b),min(a,b)

def comb(n,r):
    return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))

_ = input()
an = list(map(int,input().split()))
#an = [5,10,12]
an.sort()
target = an[-1]/2
res = min(enumerate(an), key=lambda x: abs(target - x[1]))
print(an[-1], res[1])



Measured memory_bytes: 20448
#include <cstdio>
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  int m, n, cnt = 0;
  scanf("%d", &n);
  m = n;
  while(m > 0) {
    cnt += m % 10;
    m /= 10;
  }
  if(n % cnt == 0) printf("Yes\n");
  else printf("No\n");
  return 0;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	string s;
	cin >> s;
	reverse(s.begin(),s.end());
	vector<int> ans;
	int now = 0;
	while(now != n){
		int count = 0;
		REP(i,m){
			if(now + i == n+1) break;
			if(s[now + i] == '0') count = i;
		}
		now += count;
		if(count == 0){
			cout << -1 << endl;
			return 0;
		}else{
			ans.push_back(count);
		}
	}
	
	reverse(ans.begin(),ans.end());
	rep(i,ans.size()){
		cout << ans[i] << " ";
	}
	cout << endl;
	
    return 0;
}



Measured memory_bytes: 1144
#include<stdio.h>

int main(){
  
  int x,y,z;
  scanf("%d %d %d",&x,&y,&z);

  for(int i=0;; i++){
    if( x >= y*i + z*(i+1) ){
      /*何もしない*/
    }else{
      printf("%d",i-1);
      break;
    }
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main()
{
    int a, b, c, i, output=0;
    cin >> a >> b >> c;
    for(i=a;i<=b;i++)
    {
        if (c%i==0)
     output++;
    }
cout<< output << endl;
   
   return 0;
}


Measured memory_bytes: 3112
while True:
    n,x=map(int,input().split())
    if n==0 and x==0:
        break
    cnt=0
    for i in range(1,n+1):
        for j in range(1,n+1):
            if not j>i:
                continue
            for k in range(1,n+1):
                if not k>j:
                    continue
                if i+j+k==x:
                    cnt+=1
                            
    print(cnt)                            





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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::pair<int,int> PII;

typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::vector<PII> VPII;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

int N;
VI p;
int main() {
    std::cin >> N;
    p.resize(N);
    REP(i, N) {
        std::cin >> p[i];
    }

    int cnt = 0;
    REP(i, N) {
        if(i+1 == p[i]) {
            std::swap(p[i], p[i+1]);
            ++cnt;
        }
    }
    std::cout << cnt << std::endl;
}

Measured memory_bytes: 640
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))

print(dp[n-1])


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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="77675555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
import bisect
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
x = inpl()

infty = 10**9
c = bisect.bisect_left(x,0)
if c == N:
    print(-x[-K])
    exit()
elif x[c] > 0:
    K += 1
    N += 1
    x.insert(c,0)

if c >= K-1:
    turn = c-(K-1)
else:
    turn = 0

ans = infty
while turn <= c and turn + K <= N:
    L = -x[turn]
    R = x[turn + K - 1]
    cur = L + R + min(L,R)
    if cur < ans:
        ans = cur
    turn += 1

print(ans)

Measured memory_bytes: 14384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int n = sc.nextInt();

		boolean fin = false;

		for(int i=0;i<n;i++) {
			int a = sc.nextInt();
			h -= a;
			if(h<=0) {
				System.out.println("Yes");
				fin = true;
				break;
			}
		}

		if(!fin) {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 47952
#include <stdio.h>

int main(void){
   
    int n,m,i,j;
    int a[2500];
    int b[2500];
    int c[2500];
    
    scanf( "%d %d",&n,&m );
    
    for( i = 0; i < m; i++ ){
        scanf( "%d %d",&a[i],&b[i] );
    }
    
    for( i = 1; i <= n; i++ ){
        for( j = 0; j < m; j++){
            if( i == a[j] || i == b[j] ){
                c[i]++;
            }
        }
        printf( "%d\n",c[i] );
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll w, h, n;
    cin >> w >> h >> n;

    ll hidari = 0;
    ll migi = w;
    ll shita = 0;
    ll ue = h;
    rep(i, n) {
        ll x, y, a;
        cin >> x >> y >> a;
        if(a == 1) {
            chmax(hidari, x);
        }
        else if(a == 2) {
            chmin(migi, x);
        }
        else if(a == 3) {
            chmax(shita, y);
        }
        else if(a == 4) {
            chmin(ue, y);
        }
    }

    if(hidari >= migi || shita >= ue) {
        out(0);
    }
    else {
        out((migi - hidari)*(ue - shita));
    }

    re0;
}

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

int list[300001];
char eye;

int main()
{
    int n, ans, total = 0, countup = 0;
    cin>>n;
    for(int i = 1; i <= n; i++)
    {
        cin>>eye;
        if(eye == 'E')
            total++;
        list[i] = total;
    }
    ans = n;
    for(int i = 1; i <= n; i++)
    {
        countup = list[n] - list[i] + i-1 - list[i-1];
        if(countup < ans)
            ans = countup;
    }
    cout<<ans;
}


Measured memory_bytes: 1408
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;
int main() {
  int n, m;
  ll a, ans = 0LL;
  priority_queue<ll> q;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a;
    q.push(a);
    ans += a;
  }
  for (int i = 0; i < m; i++) {
    a = q.top();
    q.pop();
    ans -= a;
    a /= 2LL;
    ans += a;
    q.push(a);
  }
  cout << ans << endl;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string str;
    cin >> str;
    int cnt = 0;

    for(int i=0;i<str.length();i++){
        if(str[i] == 'R'){
            cnt++;
            if(str[i+1] == 'S'){
                break;
            }
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3644
N,M=map(int, input().split())
inseq=list(map(int, input().split()))

class UnionFindTree:
    def __init__(self, n):
        self.nodes = list(range(n+1))
    def find(self, x):
        if self.nodes[x] == x:
            return x
        parent = self.find(self.nodes[x])
        self.nodes[x] = parent
        return parent
    def unite(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b:
            return
        self.nodes[a] = self.nodes[b]
    def is_same(self, a, b):
        return self.find(a) == self.find(b)

union = UnionFindTree(N)
for j in range(M): 
    union.unite(*[int(i) for i in input().split()])

res = 0
for i, v in enumerate(inseq, start=1):
    if union.is_same(i, v):
        res += 1
print(res)


Measured memory_bytes: 14008
n = int(input())
Ds = list(map(int, input().split()))
L1 = [0] * (10 ** 5 + 1)
L2 = [0] * (10 ** 5 + 1)
for d in Ds:
  L1[d] += 1
L2[0] = L1[0]
for i in range(1,10 ** 5 +1):
  L2[i] = L1[i] + L2[i - 1]
print(L2.count(n //2))

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

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    int n;
    cin >> n;

    map<string,int> mp;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        mp[s]++;
    }

    int maxv = 0;
    for(auto i : mp) maxv = max(maxv,i.second);

    for(auto i : mp){
        if(i.second == maxv){
            cout << i.first << endl;
        }
    }
}


Measured memory_bytes: 23808
n,m=[int(i) for i in input().split()]
A=[]
b=[]
for i in range(n):
	A.append([int(j) for j in input().split()])

for i in range(m):
	b.append(int(input()))

for i in range(n):
	s=0
	for j in range(m):
		s+=A[i][j]*b[j]
	print(s)

Measured memory_bytes: 8016
from collections import deque
n = int(input())
Adjacent_list = [[] for x in range(n)]
check = [-1 for i in range(n)]
for i in range(n-1):
    a,b,c = map(int,input().split())
    Adjacent_list[a-1].append([b,c])
    Adjacent_list[b-1].append([a,c])
q,k = map(int,input().split())
deq = deque()
deq.appendleft([k,0])
check[k-1] = 0
while deq:
    num = deq.pop()
    for i in range(len(Adjacent_list[num[0]-1])):
        ls = Adjacent_list[num[0]-1][i]
        if check[ls[0]-1] != -1:
            continue
        check[ls[0]-1] = num[1] + ls[1]
        deq.appendleft([ls[0],num[1]+ls[1]])
for i in range(q):
    x,y = map(int,input().split())
    print(check[x-1]+check[y-1])

Measured memory_bytes: 61040
#include <algorithm>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

typedef long long Long;
#define whole(xs) xs.begin(), xs.end()

Long FizzBuzzCount(Long N) {
    return N / 3 + N / 5 - N / 15;
}

Long Count(Long N) {
    Long Ret = (N / 3 + N / 5) * 4 + 1;
    for (Long n = 1, i = 1; ; n *= 10, i++) {
        Long n1 = n * 10;
        if (n1 < N) {
            Ret += ((n1 - n) - (FizzBuzzCount(n1) - FizzBuzzCount(n))) * i;
        } else {
            Ret += ((N - n) - (FizzBuzzCount(N) - FizzBuzzCount(n))) * i;
            break;
        }
    }
    return Ret;
}

#define INF Long(1e17)

string to_s(Long n) {
    ostringstream os;
    os << n;
    return os.str();
}

string toFizzBuzzString(Long n) {
    if (n % 15 == 0) {
        return "FizzBuzz";
    } else if (n % 3 == 0) {
        return "Fizz";
    } else if (n % 5 == 0) {
        return "Buzz";
    } else {
        return to_s(n);
    }
}

char At(Long s) {
    Long lb = 0, ub = INF;
    while (lb + 1 < ub) {
        Long mid = (lb + ub) / 2;
        if (Count(mid) <= s) {
            lb = mid;
        } else {
            ub = mid;
        }
    }
    string x = toFizzBuzzString(lb + 1);
    return x[s - Count(lb)];
}

int main() {
    Long s; cin >> s;
    for (Long i = s; i < s + 20; i++) {
        cout << At(i - 1);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, j) for(int i = 0; i < (int)(j); i++)
constexpr int INF = 1 << 28;
struct Edge{
    int to;
    ll cost;
    int from; // from ????????????????????¨?????????
    Edge(int to, ll cost, int from = -1):to(to), cost(cost), from(from) {}
};
using EdgeList = vector<vector<Edge>>;
constexpr ll INFL = 1LL << 60;
bool operator < (Edge a, Edge b) {
    return a.cost < b.cost;
}
bool operator > (Edge a, Edge b) {
    return a.cost > b.cost;
}
// ??£???????????°?????? E ???????°???¨?????¨????????????????±???????
// O(ElogV)
vector<Edge> prim(const EdgeList &E) {
    int N = E.size(), start = 0;      
    vector<Edge> ans;
    priority_queue<Edge, vector<Edge>, greater<Edge>> que;
    vector<bool> visited(N);
    int visited_num = 0;    
    que.emplace(start, 0);
    
    while(visited_num < N and not que.empty()){
        Edge now = que.top(); que.pop();
        if(visited[now.to]) continue;
        visited[now.to] = true;
        visited_num++;
        ans.push_back(now);
        for(Edge e : E[now.to]){
            if(not visited[e.to]) {
                que.emplace(e.to,  e.cost);
            }
        }
    }
    assert(visited_num == N); // ??£????????§?????? 
    return ans;
}
// for kruskal
struct UnionFind{
    int n;
    vector<int> p;
    UnionFind(int nn):n(nn) {
        p.resize(n);
        rep(i, n) p[i] = i;
    }
    int root(int x) {
        return p[x] == x ? x : (p[x] = root(p[x]));
    }
    void unite(int x,int y) {
        x = root(x); y = root(y);
        if(x != y) p[y] = x;
    }
    bool query(int x,int y){
        return root(x) == root(y);
    }
};
// ??£???????????°?????? E ???????°???¨?????¨???????????????????????§?±???????
// ?????£?????°???????????´??????????°???£????£?????±???????
// O(ElogV)
vector<Edge> kruskal(const EdgeList &E) {
    vector<Edge> edges;    
    rep(i, E.size()) for(auto &e : E[i]) edges.push_back(Edge(e.to, e.cost, i));
    sort(begin(edges), end(edges));
    
    vector<Edge> ans;
    UnionFind uf(E.size());
    for(auto &e : edges) {
        if(not uf.query(e.from, e.to)) {
            ans.push_back(e);
            uf.unite(e.from, e.to);
        }
    }
    return ans;
}
// round robin algorithm ??? EloglogV ?????????
int main() {
    int N, M; cin >> N >> M;
    EdgeList E(N);
    rep(i, M) {
        int a, b, c; cin >> a >> b >> c;
        E[a].push_back(Edge(b, c));
        E[b].push_back(Edge(a, c));
    }
    auto mst = prim(E);
    ll ans = 0;
    for(auto &e : mst) ans += e.cost;
    cout << ans << endl;
    return 0;
}

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

namespace program
{
    class Program
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());

            List<Restaurant> restaurant = new List<Restaurant>();
            string[] input;
            for(int i = 0; i < N; i++)
            {
                input = Console.ReadLine().Split(' ');
                restaurant.Add(new Restaurant() { Town = input[0], Point = int.Parse(input[1]), num = i + 1 });
            }

            restaurant.Sort((a, b) => a.Town != b.Town ? a.Town.CompareTo(b.Town) : b.Point.CompareTo(a.Point));

            foreach(var r in restaurant)
            {
                Console.WriteLine(r.num);
            }
		}
        class Restaurant
        {
            public string Town;
            public int Point;
            public int num;
        }
	}
}


Measured memory_bytes: 11476
n = int(input())
memo = [{} for i in range(n+1)]
m = 10**9+7

def ppp(l):
    for i in range(4):
        t = list(l)
        if i >= 1:
            t[i-1],t[i] = t[i],t[i-1]
        if "".join(t).count("AGC") >= 1:
            return False
    return True
def dfs(c,l):
    if l in memo[c]:
        return memo[c][l]
    if c == n:
        return 1
    ret = 0
    for b in "AGCT":
        if ppp(l+b):
            ret = (ret + dfs(c + 1,l[1:] + b)) % m
    memo[c][l] = ret
    return ret
print(dfs(0,"TTT"))

Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
const int maxn = 3004;
string s, t;
int dp[maxn][maxn];
int n, m;

int getdp( int a, int b ) {
    if ( a < 1 || b < 1 ) return dp[a][b] = 0;
    int &ret = dp[a][b];
    if ( ret != -1 ) return ret;
    ret = 0;
    if ( s[a] == t[b] ) ret = max(ret, getdp(a-1, b-1) + 1);
    else ret = max(getdp(a-1, b), getdp(a, b-1));
    return ret;
}



int main () {
    cio();
    cin>>s>>t;
    n = size(s), m = size(t);
    s = '0' + s;
    t = '0' + t;
    memset(dp, -1, sizeof(dp));
    getdp(n, m);
    
    vector<char> ans;
    int i = n, j = m;
    while ( i >= 1 && j >= 1 ) {
        if ( s[i] == t[j] && dp[i][j] == dp[i-1][j-1] + 1 ) {
            ans.pb(s[i]);
            i--, j--;
        }
        else if ( dp[i][j] == dp[i][j-1] ) j--;
        else i--;
    }
    reverse(all(ans));
    for ( auto ci : ans ) cout<<ci;
    cout<<endl;
}

Measured memory_bytes: 39156
#include <stdio.h>

int main(){
   int a, b;
   char op;
   scanf("%d %c %d", &a, &op, &b);

   while( op != '?'){
   switch ((int) op) {
      case 43 :
         printf("%d\n", (a+b));
         break;
      case 45 :
         printf("%d\n", (a-b));
         break;
      case 42 :
         printf("%d\n", (a*b));
         break;
      case 47 :
         printf("%d\n", (a/b));
         break;
      case 63 :
         break;
      }
   scanf("%d %c %d", &a ,&op, &b);
   }
   return 0;
}

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

ans=0
for i in range(0,n):
    for j in range(i+1,n):
        for k in range(j+1,n):

            if l[i]!=l[j] and l[j]!=l[k] and l[i]!=l[k]:
                if  l[i]+l[j]>l[k] and l[j]+l[k]>l[i] and l[k]+l[i]>l[j]:
                    ans+=1

print(ans) 

Measured memory_bytes: 9236
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int n, i;
  cin >> n >> i;
  cout << n - i + 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;


int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int main(int argc, const char * argv[]) {
    
    // source code
    int N;
    scanf("%d",&N);
    int A[N];
    inputArray(A,N);
    int min=A[0],max =A[0];
    rep(i,N){
        if(min > A[i])
            min = A[i];
        if(max < A[i])
            max = A[i];
    }
    printf("%d",max-min);
}

Measured memory_bytes: 256
s = int(input())
a = [s]
i = 1
while True:
  if a[i - 1] % 2 == 0:
    n = int(a[i - 1] / 2)
  else:
    n = a[i - 1] * 3 + 1
  if n in a:
    break
  else:
    a.append(n)
    i += 1

print(i + 1)

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 998244353;

const int MAXN = 2e5 + 5;

int v[MAXN];

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, n) {
		scanf("%d", &v[i]);
	}
	sort(v, v + n);
	ll ans = 1ll;
	REP(i, 0, n) {
		ll mul = gcd(v[i], i);
		ans = (ans * mul) % MOD;
	}
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, price=0;
  cin >> N;
  vector<int> p(N);
  for(int i=0; i<N; i++)
    cin >> p.at(i);
  sort(p.begin(), p.end());
  price += p.at(N-1)/2;
  for (int i=0; i<N-1; i++)
    price += p.at(i);
  cout << price << endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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


  cin >> n;

  bool f = true;

  REP(i, n) {
    int a;
    cin >> a;
    if(a % 2 == 0) {
      if(a % 3 != 0 && a % 5 != 0) {
        f = false;
        break;
      }
    }
  }

  cout << (f ? "APPROVED" : "DENIED") << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 10000
 
int main(void){
 
  int n, q, c=0, i, j;
  int s[N], t[N];
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
 
  scanf("%d",&q);
 
  for(j=0;j<q;j++){
    scanf("%d",&t[j]);
  }
 
  for(j=0;j<q;j++){
    for(i=0;i<n;i++){
 
      if(s[i] == t[j]){
        c++;
        break;
      }
    }
  }
 
  printf("%d\n", c);
 
  return 0;
}

Measured memory_bytes: 644
#include <stdio.h>

int n,m;
struct phrase_t {
	int min,max;
	int score;
} phrase[400];
int melody[400];
int result[400];

int memo[400];

int tansaku(int rest) {
	int i,j;
	int result=0;
	int nowscore;
	if(rest==0)return 0;
	if(rest<0)return -10000000;
	if(memo[rest]>0)return memo[rest]-1;
	for(i=0;i<n;i++) {
		for(j=phrase[i].min;j<=phrase[i].max;j++) {
			nowscore=tansaku(rest-j)+phrase[i].score;
			if(result<nowscore)result=nowscore;
		}
	}
	memo[rest]=result+1;
	return result;
}

int main(void) {
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d%d%d",&phrase[i].min,&phrase[i].max,&phrase[i].score);
	scanf("%d",&m);
	for(i=0;i<m;i++) {
		scanf("%d",&melody[i]);
		result[i]=tansaku(melody[i]);
		if(result[i]==0) {
			puts("-1");
			return 0;
		}
	}
	for(i=0;i<m;i++)printf("%d\n",result[i]);
	return 0;
}

Measured memory_bytes: 632
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program
{
    static char[] abc = "abcdefghijklmnopqrstuvwxyz".ToCharArray();
    static long mod = 1000000007;
    static void Main(string[] args)
    {

        //var QL = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var S = Console.ReadLine();
        var N = S.Length;
        //var A = new long[N];


        var white = 0L;
        long ans = 0;

        
        
        for (int i = N - 1; i >= 0; i--)
        {
            if (S[i] == 'W')
            {
                white++;
            }
            else
            {
                ans += white;
            }
        }


        Console.WriteLine(ans);

    }


    
}


Measured memory_bytes: 26644
#include<stdio.h>
int main ()
{
    int i,y,x,N,K,L,R,D;
    scanf("%d %d %d",&L,&R,&D);//5 10 2// 3
    for(i=L,y=0;i<=R;i++)//1 100 1
    {
       if(i%D==0)
       {
           y++;
       }
    }
    printf("%d\n",y);
    return 0;
}


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

//main関数
int main() {
    //入力
    long r,D,x;
    cin>>r>>D>>x;
    //計算
    
    //出力
    for(int i=0;i<10;i++){
        x=r*x-D;
        cout<<x<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int main(){
    int h,w;
    cin >>h>>w;
    vector<vector<char>> c(h,vector<char> (w,'.'));
    vector<vector<bool>> black(h,vector<bool> (w,false));
    vector<vector<bool>> paint(h,vector<bool> (w,false));
    int sy,sx,gy,gx;
    rep(i,h){
        rep(j,w){
            cin >> c[i][j];
            if(c[i][j]=='#'){
            black[i][j] = true;
            }
        }
    }
    int dx[]={1,0},dy[]={0,1};
    rep(i,h){
        rep(j,w){
            for(int k=0;k<2;k++){
                int ny = i + dy[k];
                int nx = j + dx[k];
                if(nx>=w||ny>=h){
                    continue;
                }
                if(black[i][j]&&black[ny][nx]){
                    paint[i][j]=true;
                    paint[ny][nx]=true;
                }
            }
        }
    }
    bool ans=true;
    rep(i,h){
        rep(j,w){
            if(black[i][j]){
                if(!paint[i][j]){
                    ans = false;
                }
            }
        }
    }
    if(ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;
  vector<array<ll, 3>> vc(n);
  for (auto &c : vc) {
    cin >> c[0] >> c[1] >> c[2];
  }

  ll ans = 0;
  for (int i = 0; i < (1 << 3); ++i) {
    sort(vc.begin(), vc.end(), [&](auto a, auto b) {
      ll sa = 0, sb = 0;
      for (int j = 0; j < 3; j++) {
        if (i & (1 << j)) {
          sa -= a[j];
          sb -= b[j];
        } else {
          sa += a[j];
          sb += b[j];
        }
      }

      return sa > sb;
    });

    ll sx = 0, sy = 0, sz = 0;
    for (int i = 0; i < m; ++i) {
      auto &c = vc[i];
      sx += c[0];
      sy += c[1];
      sz += c[2];
    }

    ll sum = abs(sx) + abs(sy) + abs(sz);
    ans = max(ans, sum);
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
 
ll N,K,L,R;
ll a[40];
 
vector< P > x,y;
 
void pt(int si,int ti,vector< P > &x){
  int num=ti-si;
  for(int S=0;S<(1<<num);S++){
    ll sum=0,cnt=0;
    for(int j=0;j<num;j++)
      if(S>>j&1)
        sum+=a[si+j],cnt++;
    x.push_back(P(cnt,sum));
  }
}
 
int main(){
  cin>>N>>K>>L>>R;
  for(int i=0;i<N;i++)cin>>a[i];
  pt(0,N/2,x);
  pt(N/2,N,y);
 
  sort(y.begin(),y.end());
   
  ll ans=0;
  for(int i=0;i<(int)x.size();i++){
    vector< P > :: iterator itl,itr;
    itl=lower_bound(y.begin(),y.end(),P(K-x[i].first,L-x[i].second));
    itr=upper_bound(y.begin(),y.end(),P(K-x[i].first,R-x[i].second));
    ans+=(itr-itl);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 43740
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s1,s2;
int main()
{
	getline(cin,s1);
	getline(cin,s2);
	reverse(s1.begin(),s1.end());
	if(s1 != s2) cout<<"NO\n";
	else cout<<"YES\n"; 
	return 0;
}

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

int main() {
  int s;
  cin >> s;
  if (s / 100 <= 12 && s % 100 <= 12 && (s / 100 != 0 && s % 100 != 0)) {
    cout << "AMBIGUOUS" << endl;
  } else if (s / 100 <= 12 && s / 100 != 0) {
    cout << "MMYY" << endl;
  } else if (s % 100 <= 12 && s % 100 != 0) {
    cout << "YYMM" << endl;
  } else {
    cout << "NA" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>

////多倍長整数, cpp_intで宣言
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#pragma gcc target ("avx2")
#pragma gcc optimization ("Ofast")
#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()

using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1e9 + 7;
constexpr long double eps = 1e-6;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	sort(all(a));
	printf("%d\n", accumulate(a.begin(), a.begin() + k, 0));

	Please AC;
}

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


char s[200009];

int sum;

int main(){
	scanf("%s",s+1);
	int len=strlen(s+1);
	for(int i=1;i<=len;++i)sum=sum+s[i]-'0';
	if(sum%9==0)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 3872
#!/usr/bin/env python3
import sys, itertools ,fractions
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0



a, b, c = map(int, input().split())
for i in itertools.permutations([a, b, c], 3):
    if i[0] == sum(i[1:]) or sum(i[:2]) == i[2]:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 64364
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

const int maxn = 10010;
bool f[110][maxn];

int main()
{
	int n;
	scanf("%d",&n);
	f[0][0] = true;
	for (int i=1;i<=n;i++)
	{
		int s;
		scanf("%d",&s);
		for (int j=0;j<maxn;j++) f[i][j] = f[i-1][j];
		for (int j=s;j<maxn;j++)
			if (f[i-1][j-s]) f[i][j] = true;
	}
	for (int i=maxn;i>=0;i--)
		if (f[n][i] && i%10!=0)
		{
			printf("%d\n",i);
			return 0;
		}
	puts("0");
	return 0;
}
	

Measured memory_bytes: 1280