akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    map<int, int> A;
    rep(i, N) {
        int tmp;
        cin >> tmp;
        A[tmp]++;
    }

    vector<ll> B;
    for (auto x : A) {
        int y = x.second;

        while (y >= 2) {
            B.push_back(x.first);
            y -= 2;
        }
    }

    if (B.size() < 2) {
        cout << 0 << endl;
    } else {
        sort(B.begin(), B.end());
        reverse(B.begin(), B.end());

        ll ans = B[0] * B[1];

        cout << ans << endl;
    }
}

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

int main()
{
  int n;
  cin>>n;
  vector<int> v(n);
  for(auto &e:v)
    cin>>e;
  vector<vector<long long> >dp(n,vector<long long>(n,0));
  for(int l=n-1;l>=0;l--)
  {
    for(int r=l;r<n;r++)
    {
      if(l==r)
        dp[l][r]=v[l];
      else
      { 
          dp[l][r]=max(v[l]-dp[l+1][r],v[r]-dp[l][r-1]);
      }
     }
   }
   cout<<dp[0][n-1];                  
  return 0; 
}

Measured memory_bytes: 73660
#include <iostream>
using namespace std;
 
int main() {
  long long k,a,b;
  cin >> k >> a >> b;

  long long ans1;
  ans1 = (k-a+1) / 2;
  ans1 = (ans1-1) * (b-a);
  ans1 = ans1 + b + (k-a+1)%2;

  long long ans2;
  ans2 = k+1;

  if(ans1 > ans2){
    cout << ans1 << endl;
  } else {
    cout << ans2 << endl;
  }
  return 0;
}

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

int n;
long long arr[100001];
long long ssum[100002];

int main(void) {
    scanf("%d",&n);
    for(int i=0;i<=n;i++) {
        scanf("%lld",&arr[i]);
    }
    ssum[n]=arr[n];
    for(int i=n-1;i>=0;i--) {
        ssum[i]=ssum[i+1]+arr[i];
    }
    long long tree=1;
    long long ret=0;
    for(int i=0;i<=n;i++) {
        ret+=tree;
        tree-=arr[i];
        if (tree<0) {
            printf("-1");
            return 0;
        }
        tree=min(tree*2,ssum[i+1]);
    }
    printf("%lld",ret);
}

Measured memory_bytes: 5280
N,T = map(int, input().strip().split())

cn = []
for i in range(N):
    tup = tuple(map(int, input().strip().split()))
    if tup[1] <= T:
        cn.append(tup)
if len(cn) == 0:
    print("TLE")
    exit()

sorted_cn =sorted(cn,key =  lambda c: c[0])
print(sorted_cn[0][0])

Measured memory_bytes: 3064
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <sstream>
#include <iomanip>
#include <cassert>
#include <bitset>
#include <numeric>
using namespace std;
using namespace __gnu_pbds;
typedef tree< // find_by_order & order_of_key
        int ,
        null_type ,
        less<int> ,
        rb_tree_tag ,
        tree_order_statistics_node_update 
> new_set;
#define MOD 1000000007
#define MAXN (int)(1e5+10)
int dp[MAXN][3];
int arr[MAXN][3];
int main(void){
#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    memset(dp, 0, sizeof(dp));
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d %d %d", &arr[i][0], &arr[i][1], &arr[i][2]);
    }
    for (int i = 1; i <= n; ++i){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + arr[i][0];
        dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + arr[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + arr[i][2];
    }
    printf("%d\n",max({dp[n][0], dp[n][1], dp[n][2]}));
    return 0;
}


Measured memory_bytes: 2560
#   C

import numpy as np

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

sum_poss = 0
for n in range(1, N+1):
    m = 0
    poss = 1
    while n*2**m < K:
        m += 1
        poss /= 2
    sum_poss += poss/N
    
#sum_poss /= N


print(sum_poss)

Measured memory_bytes: 12496
#include<iostream>
using namespace std;
int main(){
    
    
    int n;
    
    cin>>n;
    int a[105];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--){
        if(i!=0)cout<<a[i]<<" ";
        if(i==0)cout<<a[i];
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//String s = sc.next();
		//String t = sc.next();
		//String g = sc.next();
		long n = sc.nextLong();
		long m = sc.nextLong();
		//long k = sc.nextLong();
		//long l = sc.nextLong();
		long count=0;
		long[] array=new long[3];

		/*for(int i=0;i<=3;i++) {
			if(s.substring(i,i+1).equals("+")) {
				count++;
			}else {
				count--;
			}
		}*/
		//Arrays.sort(array);
		if((n*m)%2==0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
		//System.out.println();
		//System.out.println(Math.abs(array[2]-array[1])+Math.abs(array[1]-array[0]));
	}
}




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

using namespace std;

const int NMAX = 8 + 5;

int n, m;
string mat[NMAX];

bool works(int lin, int col) {
    if (mat[lin][col] != '#')
        return false;
    if (lin == n && col == m)
        return true;

    if (mat[lin + 1][col] == '#')
        return works(lin + 1, col);
    if (mat[lin][col + 1] == '#')
        return works(lin, col + 1);
    return false;
}

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

    for (int i = 1; i <= n; ++ i) {
        cin >> mat[i];
        mat[i] = " " + mat[i];
    }

    int cnt = 0;
    for (int i = 1; i <= n; ++ i)
        for (auto it: mat[i])
            cnt += (it == '#');

    if (cnt != n + m - 1) {
        cout << "Impossible\n";
        return 0;
    }

    if (works(1, 1))
        cout << "Possible\n";
    else
        cout << "Impossible\n";
    return 0;
}


Measured memory_bytes: 256
// by jojifrank
#pragma GCC optimize ("-O2")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FAST            ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ll              long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define all(a)          (a).begin(),(a).end()
#define clz(a)          __builtin_clz(a) // count leading zeroes
#define ctz(a)          __builtin_ctz(a) // count trailing zeroes
#define popc(a)         __builtin_popcount(a) // count set bits (for ints only diff for ll)
#define rep(i,a,b)      for(ll i=a;i<b;i++)
#define rfor(i,a,b)     for(ll i=a; i>=b; i--)
#define debug(x)        cerr << #x << " = " << x << endl;
#define F               first
#define S               second
#define endl            '\n'
#define SIZE            1000005
#define deci(n)         cout<<fixed<<setprecision(n)
#define ordered_set     tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key(k)
// find_by_order(k)
const ld PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
const ll lul2 = 998244353;
const ll lul = 1000000007;

void mod(ll &x)
{
    if(x>=lul) x-=lul;
    if(x<0) x+=lul;
}

ll _gcd(ll a, ll b)
{
    if(b == 0) return a;
    return _gcd(b,a%b);
}

ll expo(ll n, ll p)
{
    if(p == 0) return 1;
    ll x = expo((n*n)%lul, p/2)%lul;
    if(p&1) return (x*n)%lul;
    return x;
}
//---------------------------------------------------------------------

void solve()
{
    int x; cin>>x;
    int gcd = _gcd(x,360);
    int ans = 360;
    if(gcd!=1) ans/=gcd;
    cout<<ans;
}
int main()
{   
    FAST;
   //  #ifndef ONLINE_JUDGE
     // freopen("input.txt", "r", stdin);
     // freopen("output.txt", "w", stdout);
   //  #endif
    int t; t=1; //cin>>t;
    rep(i,1,t+1){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define debug(x) (cout << # x ": " << x << endl)
#define ll long long int
#define repeat(n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()

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

    int limit = sqrt(n);
    int ans = 0;

    for (int i = 2; i < limit && n >= i; ++i) {
        int cnt = 0;
        while (n % i == 0) {
            n /= i;
            ++cnt;
        }

        for (int i = 0; i * (i + 1) / 2 < cnt; ++i) {
            if (i < cnt - i * (i + 1) / 2) ++ans;
        }
    }

    if (n > 1) ++ans;

    cout << ans;
    return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i(0);i<N;i++){
    cin>>A[i];
  }
  ll sum(0);
  int kouho[20] = {0};
  int r=0;
  for(int i(0);i<N;i++){
    while(r < N){
      // judge
      bool flag = true;
      for(int j(0);j<20;j++){
        if((A[r]>>j&1) == 1 && kouho[j] == 1){
          flag = false;
        }
      }
      if(flag){
        for(int j(0);j<20;j++){
          if((A[r]>>j&1) == 1){
            kouho[j] = 1;
          }
        }
        r++;
        //if(r>=N) break;
      }else{
        break;
      }
    }
    sum += r-i;
    //cout << i <<" "<< r << endl;
    for(int j(0);j<20;j++){
      if((A[i]>>j&1) == 1) kouho[j] = 0;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 4764
//Abhinav ---IIIT_A
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define f(i,x,n) for(int i=x;i<(int)n;++i)
#define vpii vector<pair<int,int>> 
#define vi vector<int>
#define mpii map<pair<int,int>,int>
#define mpivpii map<int,vector<pair<int,int>>> 
#define pii pair<int,int> 
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define mpi map<int,int>
#define vvi vector<vector<int>>
#define vvvi vector<vvi>
ld pie=3.141592653589;
int mod=1e9+7;

bool Compare(pair<int,int> a, pair<int,int> b)
{
    int l1=a.ss-a.ff+1;
    int l2=b.ss-b.ff+1;
    if(l1!=l2) return l1>l2;
    return a.ff > b.ff;
}
std::priority_queue<pii, std::vector<pii>, std::function<bool(pii, pii)>> pq(Compare);



int32_t main(){ 
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  int x; cin>>x;
  if(x>=30) cout<<"Yes";
  else cout<<"No";
  return 0; 
}
// check for overflows dummy !!!


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

ll GCD(ll a, ll b)
{
	if (a%b == 0)
	{
		return(b);
	}
	else
	{
		return(GCD(b, a%b));
	}
}

ll LCM(ll a, ll b)
{
	return a * b / GCD(a, b);
}

int main() {
	ll n, m;
	cin >> n >> m;
	string s, t;
	cin >> s >> t;
	map<ll, char> mp;
	ll lcm = LCM(n, m);
	FOR(i, 0, n - 1) {
		mp[i * lcm / n] = s[i];
	}

	bool isok = true;
	FOR(i, 0, m - 1) {
		if (mp.count(i * lcm / m)) {
			if (mp[i * lcm / m] != t[i]) {
				isok = false;
			}
		}
	}
	if (isok) {
		pv(lcm);
	}
	else {
		ps(-1)
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
#include <cstdio>

typedef long long lld;

lld gcd(lld x, lld y){
  if(x == 0 || y == 0) return x + y;
  for(;;){
    lld t = x % y;
    if(t == 0) return y;
    x = y; y = t;
  }
  return -1;
}

int main(){
  lld N, X; scanf("%lld%lld", &N, &X);

  lld G = gcd(N, X);
  N /= G; X /= G;

  printf("%lld\n", (N - 1) * 3 * G);
  return 0;
}

Measured memory_bytes: 128
# ABC142 E

f=lambda:map(int,input().split())
N,M=f()
INF=float('inf')

dp=[[INF]*(1<<N) for _ in [0]*(M+1)]
dp[0][0]=0
# dp[m][s]:=n個目まででsを開けるために必要な最小コスト
def list2int(A):
    res=0
    for a in A:
        res+=2**(a-1)
    return res
    
for m in range(M):
    a,b=f()
    c=list2int(list(f()))
    for i in range(1<<N):
        # 次のカギ買った
        dp[m+1][i|c]=min(dp[m][i]+a,dp[m+1][i|c])
        # やめといた
        dp[m+1][i]=min(dp[m][i],dp[m+1][i])
res=dp[M][(1<<N)-1]
print(res if res<INF else -1)

Measured memory_bytes: 138992
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

// https://atcoder.jp/contests/abc097/tasks/abc097_b

int main() {
    int X; cin >> X;
    vector<int> exp(X+4);
    exp[1] = 1;
    for (int i = 2; i < X; i++) {
        int v = i * i;
        while(v <= X) {
            exp[v] = 1;
            v *= i;
        }
    }
    for (int i = X; i >= 0; i--) if (exp[i]){
            cout << i << "\n";
            return 0;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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 rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    string S;
    cin >> S;
    vector<int> se;
    rep(i,S.size()){
        int a=ctoi(S[i]);
        se.PB(a);        
    }
    ll ans=0;
    rep(i,se.size()){
        ans+=se[i];
    }
    if(ans%9==0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 4472
#include <stdio.h>
#include <math.h>

int isPrime(int);

int main(void)
{
  int i, count, n, current;
  count = 0;
  scanf(" %d", &n);
  for (i = 0; i < n; i++)
    {
      scanf(" %d", &current);
      if (!isPrime(current))
  	count++;
    }
  printf("%d\n", count);
  return 0;
}

// isPrime determines if num is prime, it returns 0 if prime.
int isPrime(int num)
{
  int i;
  for (i = 2; i <= (int) sqrt((double) num); i++)
    if (num % i == 0)
      return i;
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
 
int main() {
 	ll i, j, k, l;
  ll a[1000];
  cin>>a[0]>>a[1]>>a[2];
  
  sort(a,a+3);
  
  if(a[0]==5 && a[1]==5 && a[2]==7) cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int strAB(char[],int);
int main(void){
  int N,i,len,a=0,b=0,ab=0,c=0;
  char S[12];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%s",S);
    len=strlen(S);
    c+=strAB(S,len);
    if(S[0]=='B' && S[len-1]=='A'){
      ab++;
      a++;
      b++;
    }else if(S[0]=='B' && S[len-1]!='A'){
      b++;
    }else if(S[0]!='B' && S[len-1]=='A'){
      a++;
    }else{
      continue;
    }
  }
  if(a != 0 && ab==b && b==a){
    printf("%d\n",c+ab-1);
  }else if(a>b){
    printf("%d\n",c+b);
  }else{
    printf("%d\n",c+a);
  }
  return 0;
}
int strAB(char x[],int y){
  int t=0,j=0;
  while(j<y){
    if(x[j]=='A' && x[j+1]=='B'){
      t++;
    }
    j++;
  }
  return t;
}


Measured memory_bytes: 128
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi, factorial
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    N = int(input())
    xxyy = [tuple(map(int, input().split())) for _ in range(N)]
    ssum = 0
    for a,b in combinations(xxyy,2):
        #print(a,b) 
        dx = (a[0] - b[0])**2
        dy = (a[1] - b[1])**2
        tmp = sqrt(dx+dy)
        #print(tmp)
        ssum += tmp
    #print("---")
    #print(ssum)
    print(ssum*2/N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5248
#include "bits/stdc++.h"
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
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; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e18;

lint M, digit_sum = 0, digit_cnt = 0, C, D;
int main() {
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> M;
	REP(i, M) {
		cin >> D >> C;
		digit_sum += D * C;
		digit_cnt += C;
	}
	cout << (digit_sum - 1) / 9 + digit_cnt - 1 << endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
using namespace std;
struct SegTree{
	//
	int n;
	vector<long long> dat,laz;
	//
	SegTree(int n_){
		init(n_);
	}
	//
	void init(int n_){
		n=1;
		while(n<n_){
			n*=2;
		}
		dat.resize(2*n-1);
		laz.resize(2*n-1);
		fill(dat.begin(),dat.end(),0);
		fill(laz.begin(),laz.end(),0);
	}
	//
	void eval(int l,int k){
		if(k*2+1<n*2-1){
			laz[k*2+1]+=laz[k];
			laz[k*2+2]+=laz[k];
		}
		dat[k]+=laz[k]*l;
		laz[k]=0;
	}
	//
	long long update(int a,int b,int x,int k=0,int l=0,int r=-1){
		if(r==-1){
			r=n;
		}
		eval(r-l,k);
		if(r<=a||b<=l){
			return dat[k]+laz[k]*(r-l);
		}else if(a<=l&&r<=b){
			return dat[k]+(laz[k]+=x)*(r-l);
		}else{
			eval(r-l,k);
			long long va=update(a,b,x,k*2+1,l,(l+r)/2);
			long long vb=update(a,b,x,k*2+2,(l+r)/2,r);
			return dat[k]=va+vb;
		}
	}
	//
	long long query(int a,int b,int k=0,int l=0,int r=-1){
		if(r==-1){
			r=n;
		}
		eval(r-l,k);
		if(r<=a||b<=l){
			return 0;
		}else if(a<=l&&r<=b){
			return dat[k];
		}else{
			long long va=query(a,b,k*2+1,l,(l+r)/2);
			long long vb=query(a,b,k*2+2,(l+r)/2,r);
			return va+vb;
		}
	}
	//
};
int main(){
	int N,Q;
	cin>>N>>Q;
	SegTree Seg(N);
	while(Q--){
		int C;
		cin>>C;
		if(C==1){
			int S,T;
			cin>>S>>T;
			cout<<Seg.query(S-1,T)<<endl;
		}else{
			int S,T,X;
			cin>>S>>T>>X;
			Seg.update(S-1,T,X);
		}
	}
	return 0;
}


Measured memory_bytes: 7056
while 1:
    n,m=map(int,input().split())
    if n+m==0:break
    a=[1]+[0]*(n-1)
    b={}
    for _ in range(m):t,s,d=map(int,input().split());b[t]=(s,d)
    for x in sorted(b):
        if a[b[x][0]-1]:a[b[x][1]-1]=1
    print(sum(a))

Measured memory_bytes: 12536
import math
import sys
from itertools import permutations
# input = sys.stdin.readline

H,W,K=map(int,input().split())
arr=[]
for i in range(H):
    arr.append(input())

ans=0
for i in range(2**H):
    for j in range(2**W):
        count=0
        str1="{0:0"+str(H)+"b}"
        b1=str1.format(i)
        str2="{0:0"+str(W)+"b}"
        b2=str2.format(j)

        for x in range(H):
            for y in range(W):
                if b1[x]=='0' and b2[y]=='0' and arr[x][y]=='#':
                    count+=1
        if count==K:
            ans+=1
print(ans)

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

#define ALL(V) (V).begin(), (V).end()

template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T, typename U> using P = pair<T, U>;
using ll = int64_t;
using PLL = P<ll, ll>;


int main() {
    ll A, B, Q;
    V<ll> sp, sm, tp, tm;
    cin >> A >> B >> Q;
    for(ll i = 0; i < A; i++) {
        ll s;
        cin >> s;
        sp.push_back(s);
        sm.push_back(-s);
    }
    for(ll i = 0; i < B; i++) {
        ll t;
        cin >> t;
        tp.push_back(t);
        tm.push_back(-t);
    }
    sort(ALL(sp));
    sort(ALL(sm));
    sort(ALL(tp));
    sort(ALL(tm));
    for(ll i = 0; i < Q; i++) {
        V<ll> sv, tv;
        ll x;
        ll ans = 5e15;
        cin >> x;
        auto ite = lower_bound(ALL(sp), x);
        if(ite != sp.end()) sv.push_back(*ite);
        ite = lower_bound(ALL(sm), -x);
        if(ite != sm.end()) sv.push_back(-(*ite));
        ite = lower_bound(ALL(tp), x);
        if(ite != tp.end()) tv.push_back(*ite);
        ite = lower_bound(ALL(tm), -x);
        if(ite != tm.end()) tv.push_back(-(*ite));
        for(ll se : sv) for(ll te : tv) {
            ll tmp;
            if(se <= x && x <= te) tmp = (x - se) + (te - x) + min(x - se, te - x);
            if(te <= x && x <= se) tmp = (x - te) + (se - x) + min(x - te, se - x);
            if(se <= x && te <= x) tmp = max(x - se, x - te);
            if(x <= se && x <= te) tmp = max(se - x, te - x);
            ans = min(ans, tmp);
        }
        cout << ans << '\n';
    }
    return 0;
}


Measured memory_bytes: 4628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x,y;
    cin >> n >> m >> x >> y;
    int a[n];
    int b[m];
    int maxa,minb;

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

    }
    sort(a,a+n);
    maxa = a[n-1];
    for(int i = 0; i < m; i++){
        cin >> b[i];
    }
    sort(b,b+m);
    minb = b[0];
    int f = 0;
    for(int i = x + 1; i <= y; i++){
        if(maxa < i && minb >= i){
            f = 1;
        }
    }
    if(f == 0){
        cout << "War";
    }else{
        cout << "No War";
    }
}

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

ll f(ll a) {
    if (a % 2 == 0) return a / 2 * (a + 1);
    return (a + 1) / 2 * a;
}
int main() {
    ll a; cin >> a;
    ll ans = 0;
    for (int i = 1; i <= a; i ++) {
        ans += f(a / i) * i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
int a[105][2];

int main()
{
	bool flag=false;
	int n;cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i][0]>>a[i][1];
	for(int i=1;i<=n-2;i++){
		if(a[i][0]==a[i][1]&&a[i+1][0]==a[i+1][1]&&a[i+2][0]==a[i+2][1]) flag=true;
	}
	if(flag) cout<<"Yes";
	else cout<<"No";
	return 0;	
} 

Measured memory_bytes: 3056
#include <iostream>
using namespace std;
int main(){
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;
  if (y + r <= H && r <= y && x + r <= W && r <= x){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3092
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// input
	A := inputLineAsNumArray(1)[0]
	B := inputLineAsNumArray(1)[0]
	C := inputLineAsNumArray(1)[0]
	D := inputLineAsNumArray(1)[0]

	var train, bus int
	
	if A<B {
		train = A 
	} else {
		train = B
	}

	if C<D {
		bus = C 
	} else {
		bus = D
	}

	fmt.Println(train+bus)
}

func inputLineAsNumArray(length int) []int {
	line := strings.Split(readLine(), " ")
	var nums []int
	for i := 0; i < length; i++ {
		num, _ := strconv.Atoi(line[i])
		nums = append(nums, num)
	}
	return nums
}

func readLine() string {
	sc.Scan()
	return sc.Text()
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, ans=0;
    vector<int> V(3);
    char tmp, tmp2;
    string S, S2;
    bool flag=true;
    
    cin >> N>>A;
    
    // ans = (N%500)-A>0;
    // cout << ans << endl;

    // if(S[1]==S[2] &&(S[0]==S[1] | S[2]==S[3]))
    // 	cout << "Yes" <<endl;
    // else
    // 	cout << "No" <<endl;

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;
    if((N%500)-A>0)
    	puts("No");
    else
    	puts("Yes");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1000000000000000
#define mod 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

struct edge {
	int from, to, cost;
};

edge g[3000];
int d[1050];
int V, E;

signed main() {
	cin >> V >> E;
	rep(i, E) {
		cin >> g[i].from >> g[i].to >> g[i].cost;
		g[i].from--, g[i].to--;
		g[i].cost *= -1;
	}
	fill(d, d + V, inf);
	d[0] = 0;
	int final;
	for (int i = 0; i < V; i++) {
		bool update = false;
		rep(j, E) {
			edge e = g[j];
			if (d[e.from] != inf && d[e.from] + e.cost < d[e.to]) {
				d[e.to] = d[e.from] + e.cost;
				update = true;
			}
		}
		if (!update) {
			break;
		}
		if (i == V - 1 && d[V - 1] != final) {
			cout << "inf" << endl;
			return 0;
		}
		final = d[V - 1];
	}
	cout << d[V - 1] * -1 << endl;

	return 0;
}


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

int **can_num;

void set(int x1, int y1, int x2, int y2){
	can_num[x1][y1]++;
	can_num[x1][y2 + 1]--;
	can_num[x2 + 1][y1]--;
	can_num[x2 + 1][y2 + 1]++;
}

int max(int a, int b){
	return a >= b ? a : b;
}

int main(){
	int N, K, i, j, X, Y, ans = 0;
	scanf("%d%d", &N, &K);
	int *x = (int *)malloc(sizeof(int) * N);
	int *y = (int *)malloc(sizeof(int) * N);
	char *c = (char *)malloc(sizeof(char) * N);
	for(i = 0; i < N; i++){
//		printf("i = %d\n", i);
		scanf("%d %d %c", &x[i], &y[i], &c[i]);
	}
	can_num = (int **)malloc(sizeof(int *) * (2 * K + 1));
	for(i = 0; i <= 2 * K; i++){
		can_num[i] = (int *)malloc(sizeof(int) * (K + 1));
		for(j = 0; j <= K; j++){
			can_num[i][j] = 0;
		}
	}
	for(i = 0; i < N; i++){
		X = x[i] % K;
		Y = y[i] % K;
		if((x[i] / K + y[i] / K) % 2 == 1){
			if(c[i] == 'B'){
				c[i] = 'W';
			}
			else{
				c[i] = 'B';
			}
		}
		if(c[i] == 'B'){
			set(0, 0, X, Y);
			set(X + 1, Y + 1, X + K, K - 1);
			set(X + K + 1, 0, 2 * K - 1, Y);
		}
		else{
			set(0, Y + 1, X, K - 1);
			set(X + 1, 0, X + K, Y);
			set(X + K + 1, Y + 1, 2 * K - 1, K - 1);
		}
	}
	for(i = 0; i <= 2 * K; i++){
		for(j = 0; j <= K; j++){
			if(i == 0 && j > 0){
				can_num[i][j] += can_num[i][j - 1];
			}
			else if(i > 0 && j == 0){
				can_num[i][j] += can_num[i - 1][j];
			}
			else if(i > 0 && j > 0){
				can_num[i][j] += can_num[i][j - 1] + can_num[i - 1][j] - can_num[i - 1][j - 1];
			}
			ans = max(ans, can_num[i][j]);
		}
	}
/*	for(i = 0; i <= 2 * K; i++){
		for(j = 0; j <= K; j++){
			printf("can_num[%d][%d] = %d  ", i, j, can_num[i][j]);
		}
		printf("\n");
	}
*/	printf("%d\n", ans);
	return 0;
}

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

// int/long:            -2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:      -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define MOD 1000000007

#define Rep0(i, n)      for (auto i=0; i<n; i++)
#define Rep1(i, n)      for (auto i=1; i<=n; i++)
#define Sort(P) sort(P.begin(), P.end())
#define Rev(P)  reverse(P.begin(), P.end())

int     main() {
        int K, A, B;
        cin >>K >>A >>B;
        if ((A/K==B/K)&&(A%K==0))
                cout <<"OK" <<endl;
        else if (B/K>A/K)
                cout <<"OK" <<endl;
        else
                cout <<"NG" <<endl;
        return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <deque>
using namespace std;

int solve(const vector<int> &A, long long K) {
    deque<int> a; // 繰り返しの部分
    vector<bool> seen(A.size(), false); // 一度見たかどうか
    int cur = 0;
    while (true) {
        // 一度通った頂点を見つけたときの処理
        if (seen[cur]) {
            while (a[0] != cur) {
                // 最初の余計な数手分を除去する
                --K;
                a.pop_front();

                // 繰り返す前に K が限界になったらリターン
                if (K == 0) return a[0] + 1;
            }
            break;
        }
        // 最初は愚直にシミュレーションしつつ、履歴をメモしていく
        a.push_back(cur);
        seen[cur] = true;
        cur = A[cur];
    }
    return a[K % a.size()] + 1;
}

int main() {
    long long N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i], --A[i];
    cout << solve(A, K) << endl;
}

Measured memory_bytes: 4740
#include <stdio.h>

int hamming[1000001] = {0, 1};

int main(void)
{
	int i;
	int m, n;
	
	for (i = 1; i <= 1000000 / 2; i++){
		if (hamming[i] == 1){
			if (i * 2 <= 1000000) hamming[i * 2] = 1;
			if (i * 3 <= 1000000) hamming[i * 3] = 1;
			if (i * 5 <= 1000000) hamming[i * 5] = 1;
		}
	}
	
	while (scanf("%d", &m), m != 0){
		int cnt = 0;
		
		scanf("%d", &n);
		for (i = m; i <= n; i++){
			if (hamming[i] == 1){
				cnt++;
			}
		}
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;



int main(){
 string s; cin>>s;
 int n=s.size();
 bool check=false;
 int l,r;
 
 REP(i,n-1){
   if(s[i]==s[i+1]){
    l=i+1; r=i+2;
    check=true;
    break;
   }else if(i<=n-3&&s[i]==s[i+2]){
    l=i+1; r=i+3;
    check=true;
    break;
   }
 }
  if(check)cout<<l<<' '<<r<<endl;
  else cout<<"-1 -1"<<endl;
}

Measured memory_bytes: 512
import math
N = int(input())
arms = [list(map(int,input().split(" "))) for _ in range(N)]
robots = [((x-l),(x + l)) for x,l in arms]
robots = sorted(robots,key=lambda x:(x[0],x[1]))
ans = N
l,r = robots[0] # r→ limit 現状のlimit
for robot in robots[1:]:
    newl,newr = robot
    if r > newl: # 被っていたら除去
        if  r > newr: #前にあったやつを除去する場合
            r = newr

        ans -= 1
    else:
        l = newl
        r = newr

print(ans)

Measured memory_bytes: 49904
import sys
from collections import deque
import copy

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    S = read_func().strip()
    a = 0
    for s in S:
        if s == "-":
            a -= 1
        elif s =="+":
            a += 1

    print a

if __name__ == '__main__':
    main()

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

using namespace std;

int A = 0, B = 0;
int C = 0, D = 0;
int P = 0;

int main(void){
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;
    cin >> P;

    int x = A * P;
    int y = (P <= C) ? B : B + D*(P-C);

    cout << min(x,y) << endl;
}

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

#include <bits/stdc++.h>

using namespace std;

class customIO{
public:
    istream& in; ostream& out; customIO(istream& _in, ostream& _out):in(_in),out(_out){}
    string next() {string s;in >> s;return s;} double nextDouble() {return stod(next());}
    int nextInt() {return stoi(next());} long long nextLong() {return stoll(next());}
    template <typename T> void print(T t) {out << t;} template <typename T, typename ...U>
    void print(T t, U ...u) {out << t;print(u...);} template <typename T, typename ...U>
    void println(T t, U ...u) {print(t, u..., "\n");} void println() {print("\n");}
};


class B121 {
public:
    void solve(customIO &io) {
        string s = io.next();
        s += io.next();
        istringstream is(s);
        int x;
        is >> x;
        int sq = sqrt(x);
        if(sq * sq == x) {
            io.println("Yes");
        } else {
            io.println("No");
        }
    }
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed;
    cout.precision(20);
    istream &in(std::cin);
    ostream &out(std::cout);
    customIO io(in, out);

    B121 solver;
    solver.solve(io);
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
typedef pair<int,int> P;
using ll = long long;
using VI = vector<int>;

using namespace std;
int main(){
  int n;cin >> n;
  string str = "";
  while(n!=0){
    int r = n%2;
    if(r<0) r+=2;
    n = (n-r)/(-2);
    str+=(char)('0'+r);
  }
  reverse(str.begin(),str.end());
  if(str=="") str="0";
  cout << str << endl;
}


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

int main() {
  int N,M; cin >> N >> M;
  string A[50],B[50];
  for ( int i = 0; i < N; i++ ) cin >> A[i];
  for ( int i = 0; i < M; i++ ) cin >> B[i];

  bool isMatch = true;
  bool exist = false;
  for ( int li = 0; li < N; li++ ) {
    for ( int lj = 0; lj < N; lj++ ) {
      if ( li + M - 1 >= N || lj + M -1 >= N )continue;
      isMatch = true;
      for ( int i = 0; i < M; i++ ) {
	for ( int j = 0; j < M; j++ ) {
	  if ( A[i+li][j+lj] != B[i][j] ) isMatch  = false;
	}
      }
      if ( isMatch ) {
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#[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)*}
    };
}

#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[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, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i32; n],
    }

    let b = {
        let mut sum = 0;
        for i in 0..n - 1 {
            sum += (a[i + 1] - a[i]).abs()
        }
        sum += a[0].abs();
        sum += a[n - 1].abs();
        sum
    };

    let mut c = vec![0; n];
    for (i, x) in a.iter().enumerate() {
        let l = if i == 0 { 0 } else { a[i - 1] };
        let r = if i == n - 1 { 0 } else { a[i + 1] };

        let y = (x - l).abs() + (r - x).abs();
        let z = (r - l).abs();
        c[i] = z - y;
    }

    // for x in &c {
    //     print!("{}, ", x);
    // }
    // println!();

    for (i, x) in a.iter().enumerate() {
        println!("{}", b + c[i]);
    }
}


Measured memory_bytes: 5244
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
	int x,y;
	cin >> x >> y;
	string ans = "No";
	for (int a = 0; a < 101; a++)
	{
		for (int b = 0; b < 101; b++)
		{
			if(a+b==x and 2*a+4*b==y)
			{
				ans = "Yes";
			}
		}
		
	}
	cout << ans << endl;
}


Measured memory_bytes: 3624
// https://atcoder.jp/contests/abc127/tasks/abc127_b
#include <bits/stdc++.h>
using namespace std;

int main(void){
  long long r, x, D;
  cin >> r >> D >> x;

  for (int i = 1; i <= 10; i++){
    x = r * x - D;
    cout << x << endl;
  }
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int k;
    cin >> k;
    ll ans = 0;
    rep(a, 1, k + 1){
        rep(b, a, k + 1){
            rep(c, b, k + 1){
                if(a == b && b == c){
                    ans += __gcd(__gcd(a,b), c);
                }else if(a == b && b != c){
                    ans += __gcd(__gcd(a,b), c) * 3;
                }else if(a != b && b == c){
                    ans += __gcd(__gcd(a,b), c) * 3;
                }else if(a == c && b != c){
                    ans += __gcd(__gcd(a,b), c) * 3;
                }else if(a != b && b != c){
                    ans += __gcd(__gcd(a,b), c) * 6;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h> //ABC 161_b
using namespace std;
int a[105],b;
int cmp(int a,int b){
	return a>b;     }
int main(){
	int n,m,t;
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b+=a[i];
	}
	sort(a+1,a+1+n,cmp);
	t=4*m;
	if(b%t==0)
		b=b/t;
	else
		b=b/t+1;
	if(a[m]>=b)
		cout<<"Yes";
	else
	 	cout<<"No";
	return 0;
}

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


int main(void) {
    string s;
  cin >> s;
  if(s == "SUN") {
   cout << 7;
  }
  if(s == "MON") {
   cout << 6;
  }
  if(s == "TUE") {
   cout << 5;
  }
  if(s == "WED") {
	cout << 4;
  }
  if(s == "THU") {
	cout << 3;
  }
  if(s == "FRI") {
	cout << 2;
  }
  if(s == "SAT") {
	cout << 1;
  }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n){
    int aa, bb;
    cin >> aa >> bb;
    a.at(i) = aa;
    b.at(i) = bb;
  }
  ll ans = 0;
  rrep(i, n){
    ll now = a.at(i), ta = b.at(i);
    now += ans;
    if(now % ta != 0){
      ans += ta - now % ta;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
int main(void){
    int *attendance;
    int days;
    int rest;
    int num;
    int eat=0;

    scanf("%d",&num);
    scanf("%d %d",&days,&rest);
    attendance=(int *)malloc(sizeof(int)*num);

    int i,j;
    for(i=0;i<num;i++){
        scanf("%d",&attendance[i]);
        for(j=0;(j*attendance[i]+1)<=days;j++){
            eat++;
        }
    }
    printf("%d",rest+eat);
    return 0;

}



Measured memory_bytes: 128
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int A,B;
	cin>>A>>B;
	if(A+B>=10){
		ce("error")
	}else{
		ce(A+B)
	}
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(a) for(int k=head[a];k;k=e[k].ne)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<ll,ll> pa;
const int N=4e2+5,M=5e3+5,INF=1e9,mod=998244353;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
int n;
typedef vector<int> VI;
VI c[N],u,d,a[4];
map<VI,int>mp;
void rot(VI&o){int t=o[0];o[0]=o[1];o[1]=o[2];o[2]=o[3];o[3]=t;}
VI mkmn(VI&o){
	VI ro=o;re(i,1,4)
		rot(ro),
		o=min(o,ro);
	return o;
}
int ct(VI o){
	int res=1;VI ro=o;
	re(i,1,4)rot(ro),res+=(o==ro);
	return res;
}
int main(){
	read(n);rep(i,1,n){
		re(j,0,4){int x=read();c[i].pb(x);}
		mkmn(c[i]);mp[c[i]]++;
	}re(i,0,4)a[i].resize(4);
	ll ans=0;
	rep(i,1,n)re(j,1,i){
		u=c[i];d=c[j];
		mp[u]--;mp[d]--;reverse(all(u));
		re(k,0,4){
			a[0][0]=u[0];a[0][1]=u[1];a[0][2]=d[1];a[0][3]=d[0];
			a[1][0]=u[1];a[1][1]=u[2];a[1][2]=d[2];a[1][3]=d[1];
			a[2][0]=u[2];a[2][1]=u[3];a[2][2]=d[3];a[2][3]=d[2];
			a[3][0]=u[3];a[3][1]=u[0];a[3][2]=d[0];a[3][3]=d[3];
			ll res=1;
			re(o,0,4){
				mkmn(a[o]);
				res*=(mp[a[o]]--)*ct(a[o]);
			}
			ans+=res;
			re(o,0,4)mp[a[o]]++;
			rot(d);
		}
		mp[c[i]]++;mp[c[j]]++;
	}
	cout<<ans/3<<endl;
}

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

int main()
{
    int N, ans = 0, Max = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        Max = max(A[i], Max);
    }
    sort(A.begin(), A.end());
    vector<bool> OK(Max + 1, true);
    vector<int> overlap(Max + 1, 0);
    for (int i = 0; i < N; i++)
    {
        if (OK[A[i]])
            for (int j = 2 * A[i]; j <= Max; j += A[i])
                OK[j] = false;
        overlap[A[i]]++;
    }

    for (int i = 0; i < N; i++)
        if (OK[A[i]] && overlap[A[i]] == 1)
            ans++;
    cout << ans << endl;
}

Measured memory_bytes: 7972
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     int i,n,t,p=INT_MAX,j=0,x,a=0,b,l=3,r=0,y,k,c,sum=0,m,d;
     while(l--){
        cin>>a;
        if(a==7){
            sum++;
        }
        else if(a==5){
            r++;
        }

     }
     if(sum==1 && r==2){
        cout<<"YES"<<endl;
     }
     else{
        cout<<"NO"<<endl;
     }


     return EXIT_SUCCESS;
}




Measured memory_bytes: 256