akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	ll A, B, K;
	
	cin >> A >> B >> K;
	
	if(A + B < K)
		cout << 0 << " " << 0 << endl;
	else if(A >= K)
		cout << A - K << " " << B << endl;
	else
		cout << 0 << " " << B - (K - A) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int solve(int a,int b,int c,int aa,int bb,int cc){
  if((aa==cc&&a%2!=c%2)||(aa!=cc&&a%2==c%2)){
    int mid=(a+c)/2;
    cout << mid << endl;
    string s;
    cin >> s;
    if(s=="Vacant")return 0;
    if(s=="Male"){
      solve(a,c,mid,aa,cc,2);
    }
    else if(s=="Female"){
      solve(a,c,mid,aa,cc,1);
    }
  }
  else{
    int mid=(c+b)/2;
    cout << mid << endl;
    string s;
    cin >> s;
    if(s=="Vacant")return 0;
    if(s=="Male"){
      solve(c,b,mid,cc,bb,2);
    }
    else if(s=="Female"){
      solve(c,b,mid,cc,bb,1);
    }
  }
}
int main(){
  int n;
  cin >> n;
  cout << 0 << endl;
  string s;
  cin >> s;
  int aa=0;
  int bb=0;
  int cc=0;
  if(s=="Vacant")return 0;
  if(s=="Male"){
    aa=2;
  }
  else aa=1;
  cout << n-1 << endl;
  string t;
  cin >> t;
  if(t=="Vacant")return 0;
  if(t=="Male"){
    bb=2;
  }
  else bb=1;
  cout << (n-1)/2 << endl;
  string o;
  cin >> o;
  if(o=="Vacant")return 0;
  if(o=="Male"){
    cc=2;
  }
  else cc=1;
  solve(0,n-1,(n-1)/2,aa,bb,cc);
}


Measured memory_bytes: 852
using System;
using System.Collections.Generic;
using System.Linq;
namespace AOJ
{
    internal class Program
    {
        public static void Main(string[] args) { new Program().solve(); }
        void solve() {
            var N = int.Parse(Console.ReadLine());
            var D = new DiceClass[N];
            for (int i = 0; i < N; ++i) {
                D[i] = new DiceClass();
                D[i].Dice = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            }

            var f = D[0].IsAllDifferentDice(D);
            Console.WriteLine(f ? "Yes" : "No");
        }
    }
    class DiceClass
    {
        //above figure is |0|
        //front figure is |1|
        //     N
        //    |0|
        //W |3|1|2|4| E
        //    |5|
        //     S
        public int[] Dice = new int[6];
        public int Above { get { return Dice[0]; } }
        private int[] genArr(params int[] a) {
            return new int[] { Dice[a[0]], Dice[a[1]], Dice[a[2]], Dice[a[3]], Dice[a[4]], Dice[a[5]] };
        }
        public int[] Roll(char dir) {
            switch (dir) {
                case 'N': return genArr(1, 5, 2, 3, 0, 4);
                case 'W': return genArr(2, 1, 5, 0, 4, 3);
                case 'E': return genArr(3, 1, 0, 5, 4, 2);
                case 'S': return genArr(4, 0, 2, 3, 5, 1);
                default: return new int[0];
            }
        }
        public void SetRoll(string dir) {
            foreach (var c in dir) SetRoll(c);
        }
        public void SetRoll(char dir) {
            Dice = Roll(dir);
        }
        public bool IsSameDice(int[] d) {
            foreach (var o in "NNNNWNNNWNNNENNNENNNWNNN") {
                SetRoll(o);
                if (Dice.SequenceEqual(d)) return true;
            }
            return false;
        }
        public bool IsAllSameDice(params DiceClass[] dices) {
            return dices.Aggregate(true, (f, dice) => IsSameDice(dice.Dice) && f);
        }
        public bool IsAnySameDice(params DiceClass[] dices) {
            return dices.Aggregate(0, (cnt, dice) =>
                 cnt + (IsSameDice(dice.Dice) ? 1 : 0)) > 1;
        }
        public bool IsAllDifferentDice(params DiceClass[] dices) {
            return !IsAnySameDice(dices);
        }
        public void Show() {
            Console.WriteLine("     N");
            Console.WriteLine("    |" + Dice[0] + "|");
            Console.WriteLine("W |" + Dice[3] + "|" + Dice[1] + "|" + Dice[2] + "|" + Dice[4] + "| E");
            Console.WriteLine("    |" + Dice[5] + "|");
            Console.WriteLine("     S");
        }
        public int Right(int above, int front) {
            Func<int, int, bool> f = (a, b) => Dice[a] == above && Dice[b] == front;
            if (f(1, 2) || f(2, 4) || f(4, 3) || f(3, 1)) return Dice[0];
            if (f(0, 3) || f(3, 5) || f(5, 2) || f(2, 0)) return Dice[1];
            if (f(0, 1) || f(1, 5) || f(5, 4) || f(4, 0)) return Dice[2];
            if (f(1, 0) || f(0, 4) || f(4, 5) || f(5, 1)) return Dice[3];
            if (f(0, 2) || f(2, 5) || f(5, 3) || f(3, 0)) return Dice[4];
            return Dice[5];
        }
    }
}


Measured memory_bytes: 9988
import sys
def main():
    input = sys.stdin.readline
    H, W = map(int, input().split())
    N = int(input())
    A = list(map(int, input().split()))

    c = [[0]*W for _ in range(H)]
    c_idx = 0
    for i in range(H):
        for j in range(W):
            if i&1: j = W-1-j
            if A[c_idx] == 0: c_idx += 1
            c[i][j] = c_idx + 1
            A[c_idx] -= 1
    
    for i in range(H):
        print(*c[i])


if __name__ == '__main__':
    main()

Measured memory_bytes: 42352
#include<iostream>
#include<stdio.h>
#include<string>
#include<cmath>
#include<math.h>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<unordered_map>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep2(i,n) for(int i = (n - 1); i >= 0; i--)
#define PI 3.141592653589793

using namespace std;
using ll = long long;

int main() {

	ll x, k, d;

	cin >> x >> k >> d;

	x = abs(x);


	if (x / k >= d) {
		cout << x - k * d << endl;
		return 0;
	}
	ll a=x%d;
	ll kp = k - (x / d);
	if (kp % 2 == 1) {
		cout << abs(a-d) << endl;
	}
	else cout << abs(x%d) << endl;


	return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstdlib>
#include <algorithm>
using namespace std;
typedef long long LL;
int J[65000];
int main() {
	int n;
	while(scanf("%d",&n),n) {
		LL sum=0;
		for(int i=0;i<n;i++) {
			int p;
			scanf("%d",&p);
			sum+=p;
		}
		for(int i=0;i<n-1;i++) {
			scanf("%d",&J[i]);
			sum+=J[i];
		}
		sort(J,J+(n-1));
		LL ans=sum;
		for(int i=2;i<=n;i++) {
			sum-=J[i-2];
			ans=max(ans,sum*i);
		}
		printf("%lld\n",ans);
	}

}

Measured memory_bytes: 1296
import sys
input = sys.stdin.readline


#main関数
def main():
    """"ここに今までのコード"""

    N = int(input())
    A = list(map(int, input().split()))
    mod = 10**9+7

    plist = [0]*1000
    lcm = 1
    nokori=set()
    for a in A:
        for j in range(2, 1001):
            count_j=0
            while a % j == 0:
                count_j += 1
                a //= j
            plist[j-1]=max(plist[j-1],count_j)
        nokori |= {a}
    for x in nokori:
        lcm *= x
        lcm %= mod

    #print(plist)
    #print(lcm)
    for i in range(1000):
        lcm *= pow(i+1, plist[i], mod)
        lcm %= mod
    
    #print(lcm)
    ans = 0

    for a in A:
        ans += lcm * pow(a, mod-2, mod)
        ans %= mod

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 42992
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    li=[0]*(10**5+2)
    for i in range(n):
        li[a[i]]+=1

    cnt=0
    for x in range(1,10**5+1):
        cnt=max(cnt,li[x-1]+li[x]+li[x+1])

    print(cnt)

if __name__=="__main__":
    main()

Measured memory_bytes: 13864
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;

int main(void){
	cin >> s;
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='o')cnt++;
	}
	cnt+=15-(int)s.size();
	printf("%s\n",cnt>=8?"YES":"NO");
	return 0;
}


Measured memory_bytes: 256
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<cmath>
#include<iomanip>
#include<iostream>
using namespace std;

int main() {
	long long int a,j,ans;
	cin >> a;
	for (int i = 1;i < 110000;i++) {
		ans = i * i;
		j = i;
		if (ans > a)
			break;
	}
	cout << (j - 1)*(j  - 1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    int H, W;
    scanf("%d %d", &H, &W);

    for (int i=0; i<H; ++i) {
        char buf[128];
        scanf("%s", buf);

        printf("%s\n", buf);
        printf("%s\n", buf);
    }

    return 0;
}


Measured memory_bytes: 128
# coding: utf-8
# def method
def isOK(a):
    a = list(map(int, a.split()))
    comp = [5,5,7]
    for i,x in enumerate(sorted(a)):
        if x != comp[i]:
            return False
    return True

a = input()
if isOK(a):
    print('YES')
else:
    print('NO')

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 9;
int n, a[N], p[N], q[N];

bool Check(int a[], int b[]){
  for (int i = 1; i <= n; i++){
    if (a[i] != b[i]) return false;
  }
  return true;
}

int main()
{
  fastio;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> p[i];
  for (int i = 1; i <= n; i++) cin >> q[i];
  for (int i = 1; i <= n; i++) a[i] = i;
  int cnt = 0; int x, y;
  do{
    if (Check(a, p)) x = cnt;
    if (Check(a, q)) y = cnt;
    cnt++;  
  } while (next_permutation(a + 1, a + 1 + n));
  cout << abs(x - y);
  return 0;
}

Measured memory_bytes: 256
def f(s):
  while 1:
    b=s.find(")")
    if b<0: return g(s)
    a=s[:b].rfind("(")
    s1=s[a:b+1]
    s=s.replace(s1,f(s1[1:-1]))

def g(s):
  a=""
  f=1
  x=[]
  def F(a,b):
    x.append(a)
    x.append(b)
    return 1,""
  for c in s:
    if c=="=": continue
    elif c in "*/": f,a=F(a,c)
    elif c in "+-":
      if f==1: f,a=0,c
      else: f,a=F(a,c)
    else: f,a=0,a+c
  x.append(a)

  s=x[:]
  x=[]
  f=""
  for e in s:
    if e in "+-": x.append(e)
    elif e in "*/": f=e
    else:
      a=int(e)
      if f=="*": a*=x.pop()
      elif f=="/": a=int(1.0*x.pop()/a)
      x.append(a)
      f=""

  s=x[:]
  x=[]
  f=""
  for e in s:
    if e=="+" or e=="-": f=e
    else:
      a=e
      if f=="+": a+=x.pop()
      elif f=="-": a=x.pop()-a
      x.append(a)
      f=""
  return str(x[0])

n=input()
for _ in [0]*n: 
  s=raw_input()
  print f(s)

Measured memory_bytes: 4356
def f(n, a):
    inf = float("inf")
    dp = [[0] * n for _ in range(n)]
    for i in range(n - 2, -1, -1):
        s = a[i]
        dpi = dp[i]
        for j in range(i + 1, n):
            mn = inf
            s += a[j]
            for d in range(i, j):
                k = dpi[d] + dp[d + 1][j]
                if k < mn:
                    mn = k
            dpi[j] = mn + s
    return dp[0][-1]


n = int(input())
a = list(map(int, input().split()))
print(f(n, a))


Measured memory_bytes: 42988
j,p[1<<20],n;
main(i)
{
	for(;++i<999;)
		for(j=i+i;!p[i]&j<1<<20;j+=i)
				p[j]=1;
	for(;scanf("%d",&n),j=0,n;printf("%d\n",j))
		for(i=1;++i<=n/2;)j+=!p[i]&!p[n-i];
	exit(0);
}

Measured memory_bytes: 4500
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();
        // dp[i][j]：ｓのｉ文字目までと、ｔのｊ文字目までの最長共通部分列の長さ
        int[][] dp = new int[s.length()+1][t.length()+1];
        for(int i = 0; i < s.length(); i++){
            for(int j = 0; j < t.length(); j++){
                if(s.charAt(i) == t.charAt(j)) dp[i+1][j+1] = dp[i][j] + 1;
                else dp[i+1][j+1] = Math.max(dp[i+1][j], dp[i][j+1]);
            }
        }
        StringBuilder sb = new StringBuilder();
        // LCSを復元する
        for(int i = s.length(), j = t.length(); i > 0 && j > 0;){
            if(s.charAt(i-1) == t.charAt(j-1)){
                sb.append(s.charAt(i-1));
                i--; j--;
            }else if(dp[i][j] == dp[i-1][j]) i--;
              else j--;
        }
        System.out.println(sb.reverse().toString());
        sc.close();
    }

}


Measured memory_bytes: 80848
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int pap[11][11],dx[]={0,1,0,-1,1,-1,1,-1,2,0,-2,0},dy[]={1,0,-1,0,1,-1,-1,1,0,2,0,-2};
int main(){
int x,y,si,l,ma,cou;
fill(pap[0],pap[0]+10*10,0);
while(scanf("%d,%d,%d",&x,&y,&si)!=EOF){
    if(si==1)l=4;
    if(si==2)l=8;
    if(si==3)l=12;
    pap[x][y]+=1;
    for(int i=0;i<l;i++){
        pap[x+dx[i]][y+dy[i]]+=1;
    }
    /*for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
        cout<<pap[i][j];
    }
    cout<<endl;
    }*/
}
for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
        //cout<<pap[i][j];
        ma=max(ma,pap[i][j]);
        if(pap[i][j]==0){
            cou++;
        }
    }
    //cout<<endl;
}
cout<<cou+2<<endl<<ma<<endl;
return 0;
}

Measured memory_bytes: 1208
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int h, w;
	for (int i = 0; i < 100000000; i++) {
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (int j = 0; j < h; j++) {
			for (int t = 0; t < w; t++) {
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
}


Measured memory_bytes: 3096
def main2():
    N, K = map(int, input().split())
    limit = 10**5

    ins = [0 for _ in range(limit + 1)]

    for _ in range(N):
        a, b = map(int, input().split())
        ins[a] += b

    c = 0
    for i in range(1, limit + 1):
        c += ins[i]

        if c >= K:
            print(i)
            exit()

if __name__ == "__main__":
    main2()

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'
#define all(x) x.begin(), x.end()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

using vvll = vector< vector<ll> >;
using vll = vector<ll> ;

const ll maxs = 2e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;


void pre(){



}

const int N = 1e7+3;
ll a[N];

void solve(){
    
    ll n;cin >> n;
    
    for(int i=1;i<N;i++){
        for(int j=i;j<N;j+=i)
            a[j]++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
        ans += i*a[i];
    cout << ans;

}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input00.txt","r",stdin);
    // #endif
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

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

int main(){
   int n;
   cin >> n;
   int num[n]={};
   for(int i=0;i<n;i++){
       cin >> num[i];
   }
   sort(num,num+n);
   cout << num[n-1] - num[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int H, W;
  cin >> H >> W;
  
  vector<string> S(H);
  rep(i, H) {
    cin >> S[i];
  }
  
  //各点
  vvi ln(H, vi(W, -1));
  vvi rn(H, vi(W, W));
  vvi un(H, vi(W, -1));
  vvi dn(H, vi(W, H));
  
  for(int i=0; i<H; i++) {
    int pr = -1;
    for(int j=0; j<W; j++) {
      ln[i][j] = pr;
      if(S[i][j] == '#') {
        pr = j;
      }
    }
  }
  
  for(int i=0; i<H; i++) {
    int pr = W;
    for(int j=W-1; j>=0; j--) {
      rn[i][j] = pr;
      if(S[i][j] == '#') {
        pr = j;
      }
    }
  }
  
  for(int j=0; j<W; j++) {
    int pr = -1;
    for(int i=0; i<H; i++) {
      un[i][j] = pr;
      if(S[i][j] == '#') {
        pr = i;
      }
    }
  }
  
  for(int j=0; j<W; j++) {
    int pr = H;
    for(int i=H-1; i>=0; i--) {
      dn[i][j] = pr;
      if(S[i][j] == '#') {
        pr = i;
      }
    }
  }
  
  int ctmax = 0;
  rep(i, H) {
    rep(j, W) {
      if(S[i][j] != '#'){
        int ct = (rn[i][j] - ln[i][j] - 1) +
          (dn[i][j] - un[i][j] - 1) - 1;
        chmax(ctmax, ct);
      }
    }
  }
  
  fin(ctmax);
}


Measured memory_bytes: 67328
import heapq

S = input()

# 数え上げ
chars = [[0, n] for n in range(256)]
for s in S:
	chars[ord(s)][0] += 1

# ハフマン木生成
# ：ノードの構造：[count, char, left=None, right=None]
# ：[1]のcharは、heapqでユニークキーとして機能するように追加した
counts = []
for char in chars:
	if not char[0]:
		continue
	heapq.heappush(counts, [char[0], char[1], None, None, char])

# ハフマン木編成
while 1 < len(counts):
	a, b = heapq.heappop(counts), heapq.heappop(counts)
	heapq.heappush(counts, [a[0] + b[0], -1, a, b])
root = heapq.heappop(counts)

# コード化(左：0、右：1)
codes = {};
def dfs(node, code):
	# 節の処理
	if node[1] < 0:
		dfs(node[2], code + "0")
		dfs(node[3], code + "1")
		return
	# 葉の処理
	codes[chr(node[1])] = code
dfs(root, "")

# 集計
count = 0
for s in S:
	count += len(codes[s])

# 1種類の場合のみ例外処理…いずれなんとか
if 1 == len(set(S)):
	print(len(S))
else:
	print(count)



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

typedef long long s64;
#define rep(i,l,r) for(int i=l;i<=r;++i)
const s64 U=1e10;
const int G3=2155;
int pr[330],pcnt;bool mark[G3];
void init(int n)
{
	rep(i,2,n)
	{
		if(!mark[i])pr[++pcnt]=i;
		for(int j=1,x;x=pr[j],i*x<=n;++j)
		{
			mark[i*x]=1;
			if(i%x==0)break;
		}
	}
//	cerr<<(s64)G3*G3*G3<<endl;
//	cerr<<pcnt<<endl;
}

map<s64,pair<int,s64> >mp;

int main()
{
	//freopen("1.in","r",stdin);
	init(G3-1);
	int n,ans=0;
	cin>>n;
	while(n--)
	{
		s64 x;
		scanf("%lld",&x);
		s64 x1=1,x2=1;
		rep(i,1,pcnt)
		{
			int p=pr[i];
			if(x%p)continue;
			int cnt=0;
			while(x%p==0){x/=p;++cnt;}
			cnt%=3;
			if(!cnt)continue;
			if(cnt==1){x1*=p;x2*=p*p;}
			else{x1*=p*p;x2*=p;}
		}
		if(x>1)
		{
			x1*=x;
			s64 g=sqrtl(x);
			if(g*g==x)
			{
				x2*=g;
			}
			else
			{
				if(x>100000)
				{
					++ans;
					continue;
				}
				x2*=x*x;
			}
		}
		if(mp.count(x1))++mp[x1].first; 
		else mp[x1]=make_pair(1,x2);
	}
	for(auto pr:mp)
	{
		s64 x1=pr.first,x2=pr.second.second;
		if(x1==x2)
		{
			++ans;
			continue;
		}
		if(x2<x1)
		{
			if(mp.count(x2))continue;
			ans+=pr.second.first;
		}
		else
		{
			if(!mp.count(x2))ans+=pr.second.first;
			else ans+=max(pr.second.first,mp[x2].first);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 5504
#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))

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 main() {
    int n, m, start;
    while (cin >> n >> m >> start, n|m|start) {
        start--;
        bool hline[1000][100] = {false};
        int hs = 0;
        REP(i, m) {
            int h, p, q;
            cin >> h >> p >> q;
            h--;
            hs = max(hs, h);
            p--;
            q--;
            hline[h][p] = true;
        }
        int p = start;
        for (int i = hs; i >= 0; i--) {
            if (hline[i][p]) {
                p++;
            } else if (p > 0 && hline[i][p-1]) {
                p--;
            }
        }
        cout << p + 1 << endl;
    }
}

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

int main()
{
    int s;
    cin >> s;
    int h=s/60/60;
    int m=(s-h*60*60)/60;
    int s2=(s-m*60-h*60*60)%60;
    cout << h<<":"<<m<<":"<<s2<<endl;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll H, W, N;
  cin >> H >> W >> N;
  vector<vector<ll>> C(H, vector<ll>(W));
  ll i = 0, j = 0;
  for (ll q = 0; q < N; q++)
  {
    ll A;
    cin >> A;
    for (ll k = 0; k < A; k++)
    {
      C.at(i).at(j) = q + 1;
      if (i % 2 == 0)
      {
        if (j == W - 1)
          i++;
        else
          j++;
      }
      else
      {
        if (j == 0)
          i++;
        else
          j--;
      }
    }
  }

  for (ll ii = 0; ii < H; ii++)
  {
    for (ll jj = 0; jj < W; jj++)
    {
      cout << C.at(ii).at(jj);
      if (jj != W - 1)
        cout << " ";
    }
    cout << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
#define BIG 200000
 
int main(void){
  int n,p,cnt=0,small=BIG;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> p;
    if(p<=small){
      cnt++;
      small = p;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); i++)
int main(){
    int r, c;
    cin >> r >> c;
    int a[110][110];
    rep(i, r){
        int cnt_c=0;
        rep(j, c){
            cin >> a[i][j];
            cout << a[i][j] << " ";
            cnt_c += a[i][j];
        }
        a[i][c] = cnt_c;
        cout << cnt_c << endl;
    }
    rep(i, c+1){
        int cnt_r=0;
        rep(j, r+1){
            cnt_r += a[j][i];
        }
        cout << cnt_r;
        if (i != c) cout << " ";
    }
    cout<< endl;
}


Measured memory_bytes: 3136
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

######################################

N, M, X = In.ints()

cost = [0]*N
ach = [[0 for i in range(M)] for j in range(N)]

for i in range(N):
    ine = In.ints()
    cost[i] = ine[0]
    ach[i] = ine[1::]

res = 99999999999


for i in range(N):            
    for comb in itertools.combinations([i for i in range(N)], i+1):        
        cur_cost = 0
        accum = [0]*M

        for el in comb:
            cur_cost+=cost[el]

            for j in range(M):
                accum[j] += ach[el][j]

            if all([x>=X for x in accum]):
                found=True
                res = min(res, cur_cost)
                break


if res == 99999999999:
    Out.int(-1)
else:
    Out.int(res)

######################################

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Measured memory_bytes: 75176
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const ll MOD9 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	int lr[k][2];
	rep(i, k) cin >> lr[i][0] >> lr[i][1];
	vector<ll> a(n + 5), b(n + 5);
	a[1] = 1, b[1] = 1;
	repl(i, 2, n + 1) {
		rep(j, k) {
			a[i] += (MOD9 + b[max(0LL, i - lr[j][0])] - b[max(0LL, i - lr[j][1] - 1)]) % MOD9;
			a[i] %= MOD9;
		}
		b[i] = b[i - 1] + a[i];
		b[i] %= MOD9;
	}
	cout << a[n] << endl;

	return 0;
}

Measured memory_bytes: 6360
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int A, B; cin >> A >> B; string S; cin >> S;
  bool ok = true;
  if(S.size()!= A+B+1) ok = false;
  rep(i, S.size()){
   if(i!=A){
     if(S[i] == '-') ok = false;
   }
    else{
      if(S[i] != '-') ok = false;
    }
  }
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>

int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int s[100005];
        for(int i=0;i<n;i++)
        {
            scanf("%d",&s[i]);
        }
        int sum=0;
        for(int i=0;i<n;i++)
        {
            if(i==0)
                sum=abs(s[i]);
            else
                sum=sum+abs(s[i]-s[i-1]);
        }
        sum=sum+abs(s[n-1]);

        for(int i=0;i<n;i++)
        {
            int c=sum;
            if(i==0)
                c=c-abs(s[i])-abs(s[i+1]-s[i])+abs(s[i+1]);
            else if(i==n-1)
                c=c-abs(s[i])-abs(s[i]-s[i-1])+abs(s[i-1]);
            else
                c=c-abs(s[i]-s[i-1])-abs(s[i]-s[i+1])+abs(s[i-1]-s[i+1]);
            printf("%d\n",c);
        }

    }
    return 0;
}




Measured memory_bytes: 1536
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>

using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

const double PI = acos(-1);

int main(void) {
  double r;
  cin >> r;
  printf("%.10f\n", 2*PI*r);
  return 0;
}


Measured memory_bytes: 3256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var t = 0;
        for (int i = 0; i < n; i++) t ^= a[i];
        var ans = new int[n];
        for (int i = 0; i < n; i++) ans[i] = t ^ a[i];
        Console.WriteLine(string.Join(" ", ans));
    }
}


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

typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;

double kaijyo(int n){
    int k(1);
    for(int i=n;i>0;i--){
        k *= i;
    }

    return k;
}

double distance(int x[],int y[],int i,int j){
    int dx = (x[i] - x[j]) * (x[i] - x[j]);
    int dy = (y[i] - y[j]) * (y[i] - y[j]);
    return sqrt(dx+dy);
}

int main(){
    int a,b,c;
    cin >> a >> b >> c;

    int x(min({a,b,c}));
    int z(max({a,b,c}));
    int y(a+b+c-x-z);

    int ans(0);
    if(z%2==x%2 && x%2==y%2){
        int t = min(z-x,z-y);
        ans += t;
        x += t; y += t;
        ans += max(z-x,z-y)/2;
    }else if(x%2==y%2){
        ans = z-y + (y-x)/2;
    }else{
        if(z%2==x%2){
            ans++;  z++;    x++;
            ans += z-y + (y-x)/2; 
        }else{
            ans++;  z++;    y++;
            ans += z-y + (y-x)/2;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
n = int(input())
m = 10**9 + 7
# ans = [0] * (n + 1)
ans = [0] * 2200
ans[0] = 1
# ans[3] = 1
# ans[4] = 1
# ans[5] = 1
for i in range(3, n + 1):
    for j in range(i - 2):
        ans[i] += ans[j]
        ans[i] %= m
print(ans[n])
# print(ans[:10])


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

using namespace std;

int main(void){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(true){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <iostream>
#include <ctime>
using namespace std;
#define _LL long long
#define rep(i, n) for (_LL i = 0; i < (_LL)(n); i++)
#define vecrep(itr, v) for (auto itr = (v).begin(); itr != (v).end(); itr++)

int main()
{
    int a; string s; cin >> a >> s;
    if( a >= 3200 )
    {
        cout << s << endl;
    }
    else
    {
        cout << "red" << endl;
    }
    return 0;    
}

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

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

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

    int n;
    cin >> n;

    vector<int> c(n), s(n), f(n);
    rep(i, n - 1) cin >> c[i] >> s[i] >> f[i];

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

        cnt += s[i];
        cnt += c[i];
        for (int j = i + 1; j < n - 1; j++) {
            if (cnt < s[j]) {
                cnt = s[j];
            }
            if (cnt % f[j] != 0) {
                cnt += (f[j] - cnt % f[j]);
            }
            cnt += c[j];
        }
        cout << cnt << endl;
    }
    cout << 0 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T, typename U, typename V>
ostream &operator<<(ostream &os, const tuple<T, U, V> &t){
  os << "(" << get<0>(t) << "," << get<1>(t) << "," << get<2>(t) << ")";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
  }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
string substr(const string &str, int S1, int S2 = -1){
  if(S2 == -1)return str.substr(S1);
  return str.substr(S1, S2-S1);
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef tuple<int, int, int> TT;
typedef pair<int, TT> PT;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);



signed main(){
  int n;cin >> n;
  vector<int> a(n);
  rep(i,n)cin >> a[i];
  sort(all(a));
  int ans = a[n/2]-a[n/2-1];
  cout << ans << endl;
  return 0;
}






Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long double ld;

#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rd3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define rl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define inf 10000000000000
#define mod 1000000007
#define maxn 100009
#define maxr 100009

void solve()
{
	ll n,k;
	rl2(n,k);
	ll r,s,p;
	rl3(r,s,p);
	string str,tmp;
	cin>>str;
	ll ans=0;
	fr(i,0,k)
	{
		VL dp(3,0);
		for(ll j=i;j<n;j+=k)
		{
			VL cs(3,0);
			if(str[j]=='s')cs[0]=r;
			if(str[j]=='p')cs[1]=s;
			if(str[j]=='r')cs[2]=p;

			VL nx(3,0);
			fr(a,0,3)
			{
				fr(b,0,3)
				{
					if(a!=b)
					{
						if(nx[a]<dp[b]+cs[a])
							nx[a]=dp[b]+cs[a];
					}
				}
			}
			dp=nx;
		}
		ans+=*max_element(ALL(dp));
	}
	wl(ans);
	NL;
	return;
}
int main(){
	//sstd::ios::sync_with_stdio(false); cin.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
int main(void){int b,f,r,v,n,i,a[4][3][10]={};scanf("%d",&n);for(i=0;i<n;++i){scanf("%d%d%d%d",&b,&f,&r,&v);a[b-1][f-1][r-1]+=v;}for(i=0;i<120;++i){if((i%10==0)&&(i)){puts("");printf("%s",(i%30==0)?"####################\n":"");}printf(" %d",a[i/30][i%30/10][i%10]);}puts("");return(0);}


Measured memory_bytes: 2756
n=int(input())
d=dict()
for i in range(n+1):
    while i>1:
        for j in range(2,i+1):
            if i%j==0:
                d[j]=d.get(j,0)+1
                break
        i=i//j
ans=1
for i in d:
    ans=(ans*(d[i]+1))%(10**9+7)
print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

const int N = 2e5 + 5;
int a[N];

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int k, n;
	cin >> k >> n;
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int maxi = 0;
	for(int i = 0; i < n - 1; i++) {
		maxi = max(maxi, a[i + 1] - a[i]);
	}
	maxi = max(maxi, k - a[n - 1] + a[0]);
	cout << k - maxi;
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	int n = N;
	bool flag = false;
	while (n>0) {
		if (n % 10 == 7) {
			flag = true;
			break;
		}
		n = n / 10;
	}
	if (flag == true) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int a, b, t;
  cin >> a >> b >> t;
  cout << (t / a) * b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    ll a,b,k;cin>>a>>b>>k;
    if(a>=k){
        a-=k;
        cout<<a<<" "<<b<<endl;
        return 0;
    }else{
        k-=a;
        a=0;
    }
    if(b>k){
        b-=k;
        cout<<a<<" "<<b<<endl;
        return 0;
    }else{
        cout<<0<<" "<<0<<endl;
        return 0;
    }

}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007

using namespace std;

ll ret(string s, int k){

  if (s.size() == 0)
    return 0;
  if (s[0] == '0')
    return ret(s.substr(1), k);

  if (k == 1){
    return (s[0] - '0') + 9 * (ll)(s.size() - 1);
  }

  string t = "";
  for (unsigned int i = 0; i < s.size() - 1; i++){
    t += string("9");
  }
  
  return ret(s.substr(1), k - 1) + (s[0] - '0' - 1) * ret(t, k - 1) + ret(t, k);
}

int main(void){
  string n;
  int k;

  cin >> n;
  cin >> k;

  cout << ret(n, k) << endl;

  return 0;
}


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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  int x;
  cin >> x;
  
  if(x < 1200) cout << "ABC" << endl;
  else cout << "ARC" << endl;
}

Measured memory_bytes: 256
table = {'2': 0,
         '3': 1,
         '4': 2,
         '5': 3,
         '6': 4,
         '7': 5,
         '8': 6,
         '9': 7,
         '10': 8,
         '11': 9,
         '12': 10,
         '13': 11,
         '1': 12, }
ary = [table[i] for i in input().strip().split()]
if (ary[1] - ary[0]) > 0:
    print('Bob')
elif ary[1] == ary[0]:
    print('Draw')
else:
    print('Alice')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int a,b;
    int c;
    while(cin>>a>>b>>c&& a && b && c){
        int ans=0;
        rep(i,1,c){
            rep(j,1,c){
                int x=i*(100+a)/100;
                int y=j*(100+a)/100;
                if(x+y==c){
                    ans=max(ans,i*(100+b)/100+j*(100+b)/100);
                }
            }
        }
        cout<<ans<<endl;
    }
    
    return 0;
}


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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<set<int> > ichi(26);
    for (int i = 0; i < N; i++) ichi[S[i]-'a'].insert(i);
    for (auto& i : ichi) i.insert(N + 100);
    int Q; cin >> Q;
    for (int _ = 0; _ < Q; _++) {
        int o; cin >> o;
        if (o == 1) {
            int i; char c; cin >> i >> c; i--;
            if (S[i] != c) {
                ichi[S[i]-'a'].erase(i);
                S[i] = c;
                ichi[S[i]-'a'].insert(i);
            }
        } else {
            int l, r; cin >> l >> r; l--; r--;
            int ans = 0;
            for (const auto& i : ichi) {
                int hoge = *(i.lower_bound(l));
                if (l <= hoge && hoge <= r) ans++;
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 24324
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main() {
    long long N, A, B;

    cin >> N >> A >> B;

    if (A > B) {
        cout << 0 << endl;
    } else if (N == 1) {
        if (A != B) {
            cout << 0 << endl;
        } else {
            cout << 1 << endl;
        }
    } else {
        cout << (N-2) * (B-A) + 1 << endl;
    }
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int ret = 1;
	long long int by = x;
	while (n) {
		if (n & 1) {
			ret *= by;
			ret %= M;
		}
		by *= by;
		by %= M;
		n >>= 1;
	}
	return ret;
}

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

	cin >> N;
	string s;
	cin >> s;
	vector<long long int>by(N + s.size() + 1, 1);
	vector<long long int>rev(N + s.size() + 1, 1);
	for (int i = 2; i <= N + s.size(); i++) {
		by[i] = by[i - 1] * i%MOD;
	}
	rev[N + s.size()] = power(by[N + s.size()], MOD - 2, MOD);
	for (int i = N + s.size() - 1; i > 1; i--) {
		rev[i] = rev[i + 1] * (i + 1) % MOD;
	}
	long long int sum = 0;
	long long int ans = 0;
	for (int i = s.size(); i <= N + s.size(); i++) {
		long long int add = by[i] * rev[s.size()] % MOD*rev[i - s.size()] % MOD;
		long long int box = add;
		add += MOD - sum;
		add %= MOD;
		ans += add * power(26, N + s.size() - i, MOD) % MOD*power(25, N - (N + s.size() - i), MOD) % MOD;
		ans %= MOD;
		sum = box;
	}
	cout << ans << endl;
}

Measured memory_bytes: 35668
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, K;
    scan(N, K);
    writeln(N - K + 1);
}


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

typedef long long i64;
map <i64, int> sum;
i64 ans;

int main()
{
    int n;
    i64 sp(0);
    cin >> n;
    sum[0] = 1;

    while (n--) {
        int x;
        cin >> x;
        sp += x;
        ans += sum[sp];
        sum[sp]++;
    }
    cout << ans << '\n';
    return 0;
}


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

typedef long long ll;
const ll mod = 1000000000+7;
ll mod_pow(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = mod_pow(N, P/2, M);
        return t*t % M;
    }
    return N * mod_pow(N, P-1, M);
}

ll dp[100][4][4][4];
int main(){
    ll N;
    cin>>N;

    dp[0][3][3][3]=1;

    for(int len=0;len<N;len++){
        for(int c1=0;c1<4;c1++){
            for(int c2=0;c2<4;c2++){
                for(int c3=0;c3<4;c3++){
                    if(dp[len][c1][c2][c3]==0)continue;

                    for(int a=0;a<4;a++){
                        //agc
                        if(a==2&&c1==1&&c2==0)continue;
                        //acg
                        if(a==2&&c1==0&&c2==1)continue;
                        //gac
                        if(a==1&&c1==2&&c2==0)continue;
                        //a?gc
                        if(a==2&&c2==1&&c3==0)continue;
                        //ag?c
                        if(a==2&&c1==1&&c3==0)continue;

                        dp[len+1][a][c1][c2]+=dp[len][c1][c2][c3];
                        dp[len+1][a][c1][c2]%=mod;
                    }
                }
            }
        }
    }

    ll ans=0;
    for(int c1=0;c1<4;c1++)for(int c2=0;c2<4;c2++)for(int c3=0;c3<4;c3++){
        ans+=dp[N][c1][c2][c3];
        ans%=mod;
    }
    cout<<ans<<endl;
    


}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

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

int main() {
  double a, b, c;
  static const double pi = 3.141592653589793;
  double ans, y;
  cin >> a >> b >> c;
  // 体積を辺の長さに戻す
  double x = c/a/a;

  double s = a*b/2.0;
  // 水の面積
  double sa = x*a;
  //  cout << x << " " << s << " " << sa << endl;

  if(sa <= s){ // 三角形になる時
    y = sa*2.0/b;
    // cout << y <<" " <<  b <<" "<< atan(y/b) << endl;
    ans = 90.0 - atan(y/b)*180/pi;
  } else { // 四角形になる時
    y = sa*2.0/a - b;
    // cout << y << endl;
    ans = 90.0 - atan(a/(b-y))*180/pi;
  }
  
  cout << setprecision(7) << ans << endl;

}


Measured memory_bytes: 384