akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <list>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(d) string(1,d)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
  ll n,d;
  cin>>n>>d;
  ll c = 0;
  rep(i,0,n){
    ll a;
    cin>>a;
    if(a>d){
      c += a-d;
    }
  }
  if(c==0){
    cout << "kusoge" << endl;
  }
  else{
    cout << c << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


a,b,n = m()

if a > b:
    print((a*n)//b - a*(n//b))
else:
    po = min(b-1,n)
    print((a*po)//b - a*(po//b))

"""


a,b,n = m()


po = min(b-1,n)
print((a*po)//b - a*(po//b))


Measured memory_bytes: 67300
#include <iostream>
#include <set>
#include <unordered_map>
using namespace std;
set<string> strs;
// s1 > s2 then true
bool compare(string s1, string s2) {
    for (int i=0;i<min(s1.size(), s2.size());i++) {
        if (s1[i] > s2[i]) {
            return true;
        } else if (s1[i] < s2[i]) {
            return false;
        }
    }
    return s1.size() > s2.size();
}

string ith(int x) {
    auto itr = strs.begin();
    for (int i=0;i<x-1;i++)itr++;
    return *itr;
}

int main () {
    string s;
    int k;
    cin >> s;
    cin >> k;
    for (int i=0;i<s.size();i++) {
        if (strs.size() > k) {
            string t = ith(k);
            if (compare(s.substr(i), t)) continue;
        }
        for (int j=0;i+j<s.size();j++) {
            strs.insert(s.substr(i, j+1));
        }
    }
    cout << ith(k) << endl;
}


Measured memory_bytes: 181632
#define _CRT_SECURE_NO_WARINGS
#include<iostream>
#include<iomanip>
#include<map>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<deque>
#include<stack>
#include<bitset>
#include<fstream>
#include<map>
#include<unordered_map>
using namespace std;
typedef int me;
typedef long long ll;
typedef unsigned long long ull;
#define andrew  ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl '\n'
#define sz(v)(int)(v.size())
#define all(v) v.begin(),v.end()
#define PI 3.1415926535
#define sin(i) (long double)sin(i*PI/180.0);
#define OO 1e18;
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ull lcm(ll x, ll y) { return x / gcd(x, y) * y; }
void the_end() {
#ifndef ONLINE_JUDGE;
    system("pause");
#endif
}
int dy8[] = { 0,0,1,-1,1,-1,-1,1 };
int dx8[] = { 1,-1,0,0,1,-1,1,-1 };
int id8[] = { 0, 1,2,3,4, 5,6, 7 };
// you can be specialist 
// soon will be (Cyain)
ll n, m;
vector<pair<ll,ll>>v;
ll mm[101][100001];
ll solve(int i,ll w)
{
    if (i == n)
        return 0;
    if (mm[i][w] != 0)
        return mm[i][w];
    mm[i][w] = solve(i + 1, w);
    if (w - v[i].first >= 0) {
        mm[i][w] = max(mm[i][w], solve(i + 1, w - v[i].first) + v[i].second);
    }
    return mm[i][w];
}
int main()
{
    andrew;
    cin >> n >> m;
    v.resize(n);
    for (int i = 0; i < n; i++)cin >> v[i].first >> v[i].second;
    cout << solve(0, m) << endl;
    the_end();
}


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

int main(){
    char number[1001];
    
    while(1){
        scanf("%s", number);
        int sum=0;
        if(number[0]=='0') {
            break;
        }    
        for(int i=0; i<strlen(number); i++){
            
            sum += number[i]-'0';
        }
    
    printf("%d\n", sum);
    
    }
    
    return 0;
    
}


Measured memory_bytes: 2700
N, M = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort.push(1<<20)
#p a
k = 0
$<.read.split.map(&:to_i).each_slice(2).to_a.sort_by{|x|-x[1]}.each do |b, c|
#	k = a.bsearch_index{ |x| c <= x }
	break if k == N
	b.times do
		if a[k] < c
			a[k] = c
		else
			break
		end
		k+=1
		break if k==N
	end	
#break if k.nil?
#	(k-1).downto(0 > k-b ? 0 : k-b).each do |i|
#		a[i] = c
#		p [i,a]
#	end

#	p [a,b,c]
#	p [k,c,a[k]]

end
a.pop
p a.inject(:+)


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

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

using namespace std;

typedef long long ll;

int n, m;
ll q[100001];
ll r[100001];
ll c[100001];

int main(){
	cin >> n >> m;
	q[0] = n;
	rep(i, m){
		cin >> q[i + 1];
	}

	vector<ll> v = {q[m]};
	for(int i = m - 1; i >= 0; --i){
		if(v.back() > q[i]){
			v.push_back(q[i]);
		}
	}
	m = v.size();
	rep(i, m){
		q[i] = v[m - i - 1];
	}

	r[m - 1] = 1;
	for(int i = m - 1; i >= 0; --i){
		ll k = q[i];
		while(1){
			int p = upper_bound(q, q + i, k) - q - 1;
			if(p == -1){
				c[0] += r[i];
				c[k] -= r[i];
				break;
			}
			r[p] += k / q[p] * r[i];
			k %= q[p];
		}
	}
	for(int i = 1; i < n; ++i){
		c[i] += c[i - 1];
	}

	rep(i, n){
		cout << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 4980
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy";
	}
	else if (s == "Cloudy") {
		cout << "Rainy";
	}
	else {
		cout << "Sunny";
	}
	// your code goes here
	return 0;
}

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

int main()
{
    long N;
    std::cin >> N;
    std::vector<std::string> W;
    for(long i=0; i<N; i++){
        std::string S;
        std::cin >> S;
        W.push_back(S);
    }

    std::string TF = "Yes";
    for(long i=1; i<N; i++){
        std::string mae = W[i-1];
        long mae_length=mae.length();
        std::string ima = W[i];

        if(mae[mae_length-1] != ima[0]){
            TF = "No";
        }

        for(long j=0; j<i;j++){
            if(W[j]==ima){
                TF="No";
                break;
            }
        }
        if(TF=="No"){
            break;
        }
    }
    std::cout << TF << std::endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    string = input()
    q = int(input())
    for _ in range(q):
        command = input().split()
        a = int(command[1])
        b = int(command[2])
        if command[0] == 'print':
            print(string[a:b+1])
        elif command[0] == 'reverse':
            if a == b:
                reversed_string = string[a]
            else:
                c = a-1 if a is not 0 else None
                reversed_string = string[b:c:-1]
            string = string[:a] + reversed_string + string[b+1:]
        elif command[0] == 'replace':
            string = string[:a] + command[3] + string[b+1:]


if __name__ == '__main__':
    main()



Measured memory_bytes: 5612
import sys
N, Y = map(int, input().split())

for x in range(N + 1):
    if 10000 * x > Y:
        break
    for y in range(N - x + 1):
        if 10000 * x + 5000 * y > Y:
            break
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            sys.exit()

print('-1 -1 -1')

Measured memory_bytes: 3064
n, m = map(int, input().split())
if m == 0: print("{0} {1}".format(0, 0))
else:
    ps, ans = {}, [0, 0]
    for _ in range(m):
        p, s = map(str, input().split())
        if p not in ps.keys():
            ps[p] = 0
        if ps[p] == "AC": continue
        elif ps[p] != "AC":
            if s == "WA":
                ps[p] += 1
            else:
                ans[1] += ps[p]
                ans[0] += 1
                ps[p] = "AC"
    print(*ans)

Measured memory_bytes: 17104
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int P,Q,R;
	cin>>P>>Q>>R;
	cout<<min(P+Q,min(Q+R,P+R));
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val str = readLine()!!
    val base = "abcdefghijklmnopqrstuvwxyz"

    // アルファベット配列からSをminusして、余った文字配列の先頭を出力、サイズが0ならばNone
    val result = base.toCharArray().asList().minus(str.toCharArray().asList())
    if (result.isEmpty())
    // サイズ0評価はisEmpty
        println("None")
    else
    // kotlinのリストはgetせずに配列のようにアクセス可能
        println(result[0])
}

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

int main(){
  char A[1],B[1];
  cin>>A[0];
  if(A[0]=='A') cout<<"T"<<endl;
  else if(A[0]=='T') cout<<"A"<<endl;
  else if(A[0]=='C') cout<<"G"<<endl;
  else if(A[0]=='G') cout<<"C"<<endl;
  
}


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

using namespace std;

int ti[101];
int ra[101];

main(){
  int i,j;
  int n,a,b,c,d;
  scanf("%d",&n);
  for(i=0;i<n*(n-1)/2;i++){
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(c>d) ti[a]+=3;
    else if(c<d) ti[b]+=3;
    else{ti[a]++; ti[b]++;}
  }
  for(i=1;i<=n;i++){
    ra[i]=1;
    for(j=1;j<=n;j++){
      if(ti[i]<ti[j]) ra[i]++;
    }
    printf("%d\n",ra[i]);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, W;
    cin >> n >> W;
    int w[n+1];
    int v[n+1];
    for(int i = 1; i <= n; i++) cin >> w[i] >> v[i];
    ll d[n+1][W+1];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= W; j++){
            if(i == 0 || j == 0) d[i][j] = 0;
            else if(w[i] > j) d[i][j] = d[i-1][j];
            else d[i][j] = max(d[i-1][j], v[i] + d[i-1][j - w[i]]);
        }
    }
    cout << d[n][W];
}

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

int main()
{
	int n, c, m = 0;

	cin >> n >> c;

	for (int i = 0; i < c; i++) {
		int p;
		cin >> p;
		m += p;
	}

	cout << (m + n) / (n + 1) << endl;

	return 0;
}


Measured memory_bytes: 3112
def main():
    from itertools import combinations
    import sys
    input = sys.stdin.readline

    inf = 1000 * 100 + 10

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

    dist = [[[inf, 0] for _ in range(N)] for _ in range(N)]
    for j in range(N):
        dist[j][j] = [0, 0]

    for idx in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        dist[a][b][0] = dist[b][a][0] = c
        dist[a][b][1] = dist[b][a][1] = 1 << idx  # weight,edge_idx

    for k in range(N):
        for i in range(N):
            for j in range(N):
                nd = dist[i][k][0] + dist[k][j][0]
                if dist[i][j][0] > nd:
                    dist[i][j][0] = nd
                    dist[i][j][1] = dist[i][k][1] | dist[k][j][1]
                elif dist[i][j][0] == nd:
                    dist[i][j][1] |= dist[i][k][1] | dist[k][j][1]

    used_edge = 0
    for frm, to in combinations(range(N), r=2):
        used_edge |= dist[frm][to][1]

    print(M - bin(used_edge).count('1'))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N;
	cin >> N;
	vi L(N);
	int sum = 0;
	REP(i, N) {
		cin >> L[i];
		sum += L[i];
	}
	
	sort(ALL(L));
	int nl = L[N - 1];
	sum -= nl;
	if (nl < sum) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

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

typedef struct{
  int parent;
  int left;  //?????????
  int right; //?????????
}Node;

void preorder(Node **, int);
void inorder(Node **, int);
void postorder(Node **, int);

main(){
  int n, i, id, root;
  Node **tree;

  scanf("%d", &n);
  tree = (Node**)malloc(sizeof(Node*)*n);
  for(i=0; i<n; i++){
    tree[i] = (Node*)malloc(sizeof(Node));
    tree[i]->parent = -1;
  }

  for(i=0; i<n; i++){
    scanf("%d", &id);
    scanf("%d%d", &tree[id]->left, &tree[id]->right);
    if(tree[id]->left != -1){
      tree[tree[id]->left]->parent = id;
    }
    if(tree[id]->right != -1){
      tree[tree[id]->right]->parent = id;
    }
  }

  for(i=0; tree[i]->parent != -1; i++);
  root = i;

  printf("Preorder\n");
  preorder(tree, root);
  printf("\nInorder\n");
  inorder(tree, root);
  printf("\nPostorder\n");
  postorder(tree, root);
  printf("\n");

  return 0;
}

void preorder(Node **nodes, int root){
  if(root == -1) return;

  printf(" %d", root);
  preorder(nodes, nodes[root]->left);
  preorder(nodes, nodes[root]->right);
}

void inorder(Node **nodes, int root){
  if(root == -1) return;

  inorder(nodes, nodes[root]->left);
  printf(" %d", root);
  inorder(nodes, nodes[root]->right);
}

void postorder(Node **nodes, int root){
  if(root == -1) return;

  postorder(nodes, nodes[root]->left);
  postorder(nodes, nodes[root]->right);
  printf(" %d", root);
}

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

int main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int n;
   cin >> n;

   if (n % 2 == 0)
      cout << n << '\n';
   else
      cout << n * 2 << '\n';
}

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

int main() {
  int N;
  cin >> N;

  string* s = new string[N];
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }

  int ACNum = 0;
  int WANum = 0;
  int TLENum = 0;
  int RENum = 0;

  for (int i = 0; i < N; i++) {
    if (s[i] == "AC") {
      ACNum++;
    } else if (s[i] == "WA") {
      WANum++;
    } else if (s[i] == "TLE") {
      TLENum++;
    } else if (s[i] == "RE") {
      RENum++;
    }
  }

  cout << "AC x " << ACNum << endl;
  cout << "WA x " << WANum << endl;
  cout << "TLE x " << TLENum << endl;
  cout << "RE x " << RENum << endl;
}

Measured memory_bytes: 6720
import java.util.*;
 
class Main {
    public static void main(String[] args) {
         Scanner scan = new Scanner(System.in);
         int a = scan.nextInt();
         int b = scan.nextInt();
         int c = scan.nextInt();
 
         if (a<b && b<c) System.out.println("Yes");
         else System.out.println("No");
    }
}

Measured memory_bytes: 26284
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    int n;
    cin>>n;
    vector<pair<int,int>> v;
    
    rep(i,n){
        int k;
        cin>>k;
        v.push_back({k,i+1});
    }
    sort(v.begin(),v.end());
    rep(i,n){
        cout<<v[i].second<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1780
from collections import deque

def bfs(grid, queue, wall):
    ans = 0
    dxy = [(1,0), (-1,0), (0,1), (0,-1)]
    while queue:
        cnt,y,x = queue.popleft()
        for dy, dx in dxy:
            y_,x_ = y+dy,x+dx
            if grid[y_][x_] == wall:
                continue
            queue.append([cnt+1,y_,x_])
            grid[y_][x_] = wall
            ans = max(ans, cnt+1)
    return ans

H,W = map(int, input().split())
wall = '#'
queue = deque([])
edges = [wall for i in range(W+2)]
grid = [edges]

for i in range(1,H+1):
    S = [wall]+list(input().strip())+[wall]
    for j in range(1,W+1):
        if S[j] == wall:
            queue.append([0,i,j])
    grid.append(S)
grid.append(edges)
print(bfs(grid, queue, wall))


Measured memory_bytes: 157948
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    string s;
    bool flg[2];
    flg[0] = false;
    flg[1] = false;
    cin >> s;

    tmpi = stoi(s);
    int front = tmpi/100;
    int end = tmpi-front*100;

    if(front > 0 && front <= 12){
        flg[0] = true;
    }
    if(end > 0 && end <= 12){
        flg[1] = true;
    }

    if(flg[0] && flg[1]){
        cout << "AMBIGUOUS" << endl;
    }else if(flg[0]){
        cout << "MMYY" << endl;
    }else if(flg[1]){
        cout << "YYMM" << endl;
    }else{
        cout << "NA" << endl;
    }

    return 0;
}

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

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll euclidean_gcd(ll a, ll b) {
  if(a < b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
ll euclidean_lcm(ll a, ll b) {
  return a/euclidean_gcd(a,b)*b;
}

ll binary(ll bina){
    ll ans = 0;
    for (ll i = 0; bina>0 ; i++)
    {
        ans += bina%2;
        bina = bina/2;
    }
    return ans;
}
void revStr(char* str){
	int size = strlen(str);
	int i,j;
	char tmp = {0};
	
	for(i = 0, j = size - 1; i < size / 2; i++, j--){
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
	return;	
}
int main(void){
  int x;
  cin >> x;
  if(x>=30)cout << "Yes";
  else cout << "No";
}

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

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();
        int count = 0;
        for(int i = 0; i < S.Length; i++)
        {
            if (S[i] == T[i]) count++;
        }
        Console.WriteLine(count);
    }
}


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

int main() {
    ll l,r;
    cin >> l >> r;
    if(l+4038 < r) r = l+4038;
    ll ans = 2018;
    for(ll i = l;i < r;i++){
        for(ll j = i+1;j <= r;j++){
            ans = min(ans,(i*j)%2019);
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
def diff(i):
    cp, np = points[i:i + 2]
    return np - cp


def cross(a, b):
    return a.real * b.imag - a.imag * b.real


def diameter(i, j):
    return abs(points[i] - points[j])


n = int(input())
t_points = [tuple(map(float, input().split())) for _ in range(n)]
i = min(range(n), key=lambda x: t_points[x])
j = max(range(n), key=lambda x: t_points[x])
points = [re + 1j * im for re, im in t_points]
points.append(points[0])
tentative_diameter = diameter(i, j)

it, jt = i, j
while True:
    if cross(diff(it), diff(jt)) >= 0:
        jt = (jt + 1) % n
    else:
        it = (it + 1) % n
    tentative_diameter = max(tentative_diameter, diameter(it, jt))

    if it == i and jt == j:
        break

print(tentative_diameter)

Measured memory_bytes: 20460
//verma_ankit484

#include<bits/stdc++.h>
typedef long long ll;
ll mod = 1e9+7;
using namespace std;

ll n,m;
vector<string> str;
ll pre[1002][1002];
int rec(ll i, ll j) {
	if(pre[i][j] != -1) return pre[i][j];
	if(i == n-1 && j == m-1) {
		return pre[i][j] = 1;
	}
	if(i+1 < n && str[i+1][j] != '#') {
		pre[i][j] = rec(i+1, j);
		pre[i][j] %= mod;
	}
	if(j+1 < m && str[i][j+1] != '#') {
		if(pre[i][j] != -1)
		pre[i][j] += rec(i, j+1);
		else pre[i][j] = rec(i, j+1);
		pre[i][j] %= mod;
	}
	return max(0ll,pre[i][j]);
}

void doit() {
	for(ll i = 0; i < 1002; i++) {
		for(ll j = 0; j < 1002; j++) {
			pre[i][j] = -1;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	#ifdef AV
	freopen("int.txt", "r", stdin);
	#endif
	cin >> n >> m;
	str.resize(n);
	doit();
	for(ll i = 0; i < n; i++) {
		cin >> str[i];
	}
	cout << rec(0, 0) << '\n';
	return 0;
}


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

typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
typedef vector<vector<lli> > vvi;
typedef vector<ii> vii;

#define EB emplace_back
#define PB push_back
#define MP make_pair
#define FF first
#define SS second

const int mod = 1e9 +7;
lli a[16][16], n, dp[131072];
int abc, cnt;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=0; i<n; i++)
		for(int j=0; j<n; j++)
			cin>>a[i][j];
	for(int m=1; m<(1LL<<n); m++)
	{
		for(int i=0; i<n; i++)
		{
			if((m>>i)&1)
			{
				for(int j=i; j<n; j++)
					if((m>>j)&1) dp[m]+=a[i][j];
			}
		}
		abc = (1LL<<__builtin_popcount(m)), cnt=0;
		for (int s=m; s&&cnt<=abc; s=(s-1)&m)
			dp[m] = max(dp[m], dp[s]+dp[m^s]), cnt++;
	}
	cout << dp[(1LL<<n)-1];
}

Measured memory_bytes: 4152
import sys
import math

n = int(sys.stdin.readline())

Q = set()
out_edge = [set() for _ in range(n)]
weight = [[0] * n for _ in range(n)]

for _ in range(n):
    ll = list(map(int, sys.stdin.readline().split()))
    sn = ll[0]
    Q.add(sn)
    for j in range(ll[1]):
        en = ll[2+2*j]
        cn = ll[2+2*j+1]
        out_edge[sn].add(en)
        weight[sn][en] = cn

d = [0] + [math.inf for _ in range(n-1)]
prev = [None] * n

while len(Q)>0:
    minval = math.inf
    u = -1
    for q in Q:
        if minval > d[q]:
            minval = d[q]
            u = q
    if minval==math.inf:  break
    Q.remove(u)

    for v in out_edge[u]:
        if weight[u][v]>0:
            if d[v] > d[u] + weight[u][v]:
                d[v] = d[u] + weight[u][v]
                prev[v] = u

for i in range(n):                
    print(i, d[i])


Measured memory_bytes: 6056
while 1:
	n=input()
	if n==0:break
	dic={}
	for i in range(n):
		msg=raw_input().split()
		for word in msg:
			if word in dic:
				dic[word]+=1
			else:
				dic[word]=1
	alpha=raw_input()
	ans=[]
	for k,v in sorted(sorted(dic.items()),key=lambda x:x[1],reverse=True):
		if k[0]==alpha:ans.append(k)
	print " ".join(map(str,ans)) if len(ans)>0 else "NA"

Measured memory_bytes: 4240
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e9
#define MOD 1000000007
typedef long long ll;
//------------------------------------------------------------------------

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

  ll a,b,c; cin >> a >> b >> c;

  ll ab = a * b;
  ll s = c - a - b;
  long double tmp = sqrt((long double)ab);
  if(s>2*tmp) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = g*r*b

for i in range(n-1):
    for j in range(i+1,n):
        if 2*j-i >= n:
            break
        if s[i] != s[j] and s[i] != s[2*j-i] and s[j] != s[2*j-i]:
            ans -= 1

print(ans)

Measured memory_bytes: 9200
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

static const ll MAX=1e5+1;
ll N,A,B;
ll h[MAX];

bool enough(ll x){
    ll num=0;
    for(int i=0;i<N;i++){
        if(h[i]-B*x>0){
            num+=(h[i]-B*x+(A-B-1))/(A-B);
        }
    }
    if(num<=x) return true;
    else return false;
}

int main(){
    cin >> N >> A >> B;
    ll mx=0;
    for(int i=0;i<N;i++){
        cin >> h[i];
        mx=max(mx,h[i]);
    }
    ll left=0;
    ll right=mx+1;
    while(right-left>0){
        ll mid=(left+right)/2;
        if(enough(mid)){
            right=mid;
        }else{
            left=mid+1;
        }
    }
    cout << right << endl;
}


Measured memory_bytes: 1024
// 2013/11/08 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int N;
	cin >> N;

	int cnt[101][3];
	for(int i=0; i<=100; i++){
		for(int j=0; j<3; j++){
			cnt[i][j] = 0;
		}
	}

	int M[200][3];
	for(int i=0; i<N; i++){
		for(int j=0; j<3; j++){
			cin >> M[i][j];

			cnt[M[i][j]][j]++;
		}
	}

	for(int i=0; i<N; i++){
		for(int j=0; j<3; j++){
			if(cnt[M[i][j]][j]>=2){
				M[i][j] = 0;
			}
		}

		cout << M[i][0]+M[i][1]+M[i][2] << endl;
	}

	return 0;
}

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

using ll = int64_t;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;
inline int madd(int x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  return x;
}
inline int msub(int x, int y) {
  x -= y;
  if (x < 0) x += mod;
  return x;
}
inline int mmul(int x, int y) { return 1ll * x * y % mod; }

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

  int n; std::cin >> n;
  vector<ll> a(n);
  ll ma = 0;
  rep(i, n) {
    std::cin >> a[i];
    chmax(ma, a[i]);
  }

  ll ans = 0;
  rep(i, 60) {
    ll cnt = 0;
    rep(j, n) cnt += (a[j] >> i) & 1;
    ans = madd(ans, mmul(mmul(cnt, (n - cnt)), (1ll << i) % mod));
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
using Graph = vector<vector<int>>;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

int main(){
    fastcin();

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    vector<LL> tp(a), tq(b), r(c);
    rep(i, a) cin >> tp[i];  
    rep(i, b) cin >> tq[i];  
    rep(i, c) cin >> r[i]; 
    sort(all(tp)); reverse(all(tp));
    sort(all(tq)); reverse(all(tq));
    sort(all(r)); reverse(all(r));

    vector<LL> p(x), q(y);
    rep(i, x) p[i] = tp[i];
    rep(i, y) q[i] = tq[i];

    reverse(all(p));
    reverse(all(q));
    p.push_back(LLINF);
    q.push_back(LLINF);

    vector<LL> sa(x+1, 0), sb(y+1, 0), sc(c+1, 0);
    rep(i, x) sa[i+1] = sa[i]+p[i];
    rep(i, y) sb[i+1] = sb[i]+q[i];
    rep(i, c) sc[i+1] = sc[i]+r[i];


    int ia=0, ib=0, ic=0;
    while(1){
        if(p[ia]==LLINF && q[ib]==LLINF) break;
        if(p[ia] < q[ib]){
            if(p[ia] > r[ic] || sa[ia+1]+sb[ib] > sc[ic+1]) break;
            ia++; ic++;
        }else{
            if(q[ib] > r[ic] || sa[ia]+sb[ib+1] > sc[ic+1]) break;
            ib++; ic++;
        }
        if(ic == c) break;
    }

    LL ans = sa[x]+sb[y];
    ans -= sa[ia]+sb[ib];
    ans += sc[ic];
    cout << ans << endl;
    // cout << ia << " " << ib << " " << ic << endl;


}

Measured memory_bytes: 6272
program main
    implicit none
    integer k, a, b, c
    integer :: total = 0
    read *, k

    do a=1, k
        do b = 1, k
            do c = 1, k
                total = total + euclid(a, euclid(c, b))
            enddo
        enddo
    enddo
    print *, total

contains
    integer function euclid(a, b)
        integer, intent(in) :: a,b
        integer bigger, smaller, rem

        if ( a < b ) then
            bigger = b
            smaller = a
        else
            bigger = a
            smaller = b
        endif

        do
            rem = mod(bigger, smaller)
            if ( rem == 0 ) then
                euclid = smaller
                exit
            else
                bigger = smaller
                smaller = rem
            endif
        enddo
    end function
end program main


Measured memory_bytes: 2856
#include <climits>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;
constexpr LL kMax = 1e16;

int main() {
  LL N; std::cin >> N;

  LL min_v = kMax;
  for (int i = 0; i < 5; ++i) {
    LL v; std::cin >> v;
    min_v = std::min(v, min_v);
  }

  LL ans = 4 + (N + min_v - 1) / min_v;
  std::cout << ans << std::endl;
}



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

long long fun_sum(int &i, vector<long long> &num) {

}

int main() {
    long long N, Q;
    cin >> N;
    vector<long long> A(N);
    for (int i; i < N; i++) cin >> A.at(i);
    cin >> Q;
    vector<long long> B(Q), C(Q);
    for (int i; i < Q; i++) cin >> B.at(i) >> C.at(i);
    vector<long long> num(100001, 0);

    long long sum = 0;
    for (int x: A) {
        num.at(x)++;
        sum += x;
    }
    for (int i = 0; i < Q; i++) {
        sum += ((C.at(i) - B.at(i)) * num.at(B.at(i)));
        num.at(C.at(i)) += num.at(B.at(i));
        num.at(B.at(i)) = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 6348
#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;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef gp_hash_table<int, int> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<pii> vii;

#define inf 200000000000000
#define mod 1000000007
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()
#define sz(x) (int)(x).size()

#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (int i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fil(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
int gcd(int a, int b){ return b==0 ? a : gcd(b, a%b); }
ll modpow(ll b, ll e) {
	ll ans=1; for(;e;b=b*b%mod,e/=2) if(e&1) ans=ans*b%mod; return ans;}

const int maxn = 1000005;

void solve(){
	ld n,d; cin>>n>>d;
	int ans = ceil(n/(2*d + 1));
	cout<<ans;
}

signed main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    solve();
    end_routine();
}

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

int main()
{
    long n, m;
    cin >> n >> m;
    vector<long> a(m);
    vector<long> ans(n + 2);
    rep(i, m) cin >> a[i];
    rep(i, n + 2) ans[i] = 0;
    rep(i, m) ans[a[i]] = -1;
    ans[n] = 1;
    int k = m - 1;
    for (int i = n - 1; i >= 0; i--)
    {
        if (ans[i] == -1)
            ans[i] = 0;
        else
            ans[i] = (ans[i + 1] + ans[i + 2]) % mod;
    }
    cout << ans[0] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int N;
int search(vector<vector<int>> &data,vector<vector<int>> &k)
{
    int ans = 0;
    vector<vector<int>> damage(N,vector<int>(N,0));
    for(int i = 0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(data[i][j] == 1)
            {
                for(int t = 0; t<N;t++)
                {
                    damage[i][t] ++;
                }
                for(int t = 0; t<N;t++)
                {
                    damage[t][j]++;
                }
                damage[i][j] -= 2;
            }
            else
            {
                damage[i][j] -= 100000;
            }
        }
    }
    
    int temp = INT_MAX;
    for(int i = 0;i<N;i++)
    {
        for(int j = 0;j<N;j++)
        {
            if(damage[i][j] >= 0)
            {
                temp = min(temp,damage[i][j]);
            }
        }
    }
    
    if(temp > 1000)
    {
        return 0;
    }
    
    bool find = false;
    
    for(int i = 0;i<N;i++)
    {
        for(int j = 0;j<N;j++)
        {
            if(damage[i][j] == temp)
            {
                for(int t = 0; t<N;t++)
                {
                    data[i][t] =0;
                }
                for(int t = 0; t<N;t++)
                {
                    data[t][j]=0;
                }
                ans = search(data,damage) + 1;
                find = true;
                break;
            }
        }
        if(find)
        {
            break;
        }
    }
    
    return ans;
}



int main()
{
    
    cin >> N;
    vector<vector<int>> red(N);
    for(int i = 0;i<N;i++)
    {
        int a,b;
        cin >> a >> b;
        red[i].push_back(a);
        red[i].push_back(b);
    }
    vector<vector<int>> blue(N);
    for(int i = 0;i<N;i++)
    {
        int a,b;
        cin >> a >> b;
        blue.at(i).push_back(a);
        blue.at(i).push_back(b);
    }
    
    vector<vector<int>> data(N,vector<int>(N,0));
    
    for(int i = 0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(red[i][0] < blue[j][0] && red[i][1] < blue[j][1])
            {
                data[i][j] = 1;
            }
        }
    }
    
    vector<vector<int>> damage(N,vector<int>(N,0));
    
    for(int i = 0;i<N;i++)
    {
        for(int j=0;j<N;j++)
        {
            if(data[i][j] == 1)
            {
                for(int t = 0; t<N;t++)
                {
                    damage[i][t] ++;
                }
                for(int t = 0; t<N;t++)
                {
                    damage[t][j]++;
                }
                damage[i][j] -= 2;
            }
            else
            {
                damage[i][j] -= 100000;
            }
        }
    }
    
    vector<bool> used(N,false);
    
    int ans = search(data,damage);
    
    cout << ans << endl;
    
    return 0;
    
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    int k;cin >> k;
    int l, amari=1;
    if(k%7 == 0) l = 9*k/7;
    else l = 9*k;
    for(int i=1; i<9000000; i++){
        amari = amari*10%l;
        if(amari == 1){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

int main() {
    int N,K;
    cin >> N >> K;
    int ans = 1;
    for (int i = 0; i < N; ++i){
        if (i==0) {
            ans *= K;
        } else {
            ans *= K - 1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ins insert
#define vi vector<int>
const int mxN=1e6;

int main()
{
    int n;
    cin >> n;
  	if(n%1000==0)
      	cout << 0;
 	else
    cout << 1000-n%1000;
}

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

using namespace std;
 
const int MOD=1e9+7;


//const int MOD=998244353;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n;
    cin>>n;
    
    vector<int> v(n);
    for(int &i:v) cin>>i;
    sort(v.begin(),v.end());
    
    int ans=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if(v[k]<v[i]+v[j] && v[i]!=v[j] && v[j]!=v[k]) ans++;
            }
        }
    }
    cout<<ans;
    
    return 0;
}

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

typedef long long llong;


class MinimumCapacitySolver {

public:
    static const int MAX = 100000;

    MinimumCapacitySolver (int cCnt, int tCnt, llong weights[]) {
        for (int i = 0; i < cCnt; i++) {
            cargoWeights[i] = weights[i];
        }
        cargoCnt = cCnt;
        trackCnt = tCnt;
    }

    int check(llong trackCapacity) {
        auto i = 0;
        for (int j = 0; j < trackCnt; j++) {
            llong s = 0;
            while(s + cargoWeights[i] <= trackCapacity) {
               s += cargoWeights[i];
               i++;
               if (i == cargoCnt) {
                   return cargoCnt;
               }
            }
        }
        return i;
    }

    int solve() {
        llong left = 0;
        llong right = MAX * 10000;
        llong mid;

        while(right - left > 1) {
            mid = (left + right) / 2;
            auto v = check(mid);
        
            if (v >= cargoCnt) {
                right = mid;
            } else {
                left = mid;
            }
        }

        return right;
    }

private: 
    llong cargoWeights[MAX];
    int cargoCnt;
    int trackCnt;
};


int main() {
    int cargoCnt, trackCnt;
    llong cargoWeights[MinimumCapacitySolver::MAX];
    cin >> cargoCnt >> trackCnt;

    for (int i = 0; i < cargoCnt; i++) {
        cin >> cargoWeights[i];
    }   
    unique_ptr<MinimumCapacitySolver> solver(new MinimumCapacitySolver(cargoCnt, trackCnt, cargoWeights));

    llong ans = solver->solve();
    cout << ans << endl;
}



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

int N, M, X;
vector<vector<int>> A;
vector<int> C;

int check(vector<int> R, int X){
    for (int i=0; i<R.size(); i++){
        if (R[i] < X){
            return 0;
        }
    }
    return 1;
}


// 再帰で解く
int solve(vector<int> R, int cost, int i){
    // printf("R ");
    // for (int i=0; i<M; i++){
    //     printf("%d ", R[i]);
    // }
    // printf("\n");
    if (i == N){
        if (check(R, X) == 0){
            cost = 100000000;
        }
        return cost;
    }
    // i 番目を買うか買わないかを判断する
    vector<int> new_R1(R.size());
    for (int j=0; j<M; j++){
        new_R1[j] = R[j];
    }
    int not_buy = solve(new_R1, cost, i+1);
    vector<int> new_R2(R.size());
    for (int j=0; j<M; j++){
        new_R2[j] = R[j] + A[i][j];
        // printf("new_R2[%d] = %d\n", j, R[j] + A[i][j]);
    }
    int buy = solve(new_R2, cost + C[i], i+1);
    // printf("i = %d, n: %d y: %d\n", i, not_buy, buy);
    return min(not_buy, buy);
}


int main(){
    cin >> N >> M >> X;
    for (int i=0; i<N; i++){
        int c;
        cin >> c;
        C.push_back(c);
        vector<int> a_i;
        for (int j=0; j<M; j++){
            int a;
            cin >> a;
            a_i.push_back(a);
        }
        A.push_back(a_i);
    }

    vector<int> R(M, 0);
    int ans = solve(R, 0, 0);
    if (ans == 100000000){
        ans = -1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
/*vector<Type> v;
vector<Type> v();
vector<Type> v(n);
vector<Type> v(n, d);
vector<vector<Type>> vv;
vector<vector<Type>> vv();
vector<vector<Type>> vv(n);
vector<vector<Type>> vv(n, vector<Type>(m));
vector<vector<Type>> vv(n, vector<Type>(m, d));*/

int main() {
  int x;
  rep(i,5){
    cin >> x;
    if(x==0){
      cout << i+1;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3584
N=int(input())
A,B=map(int,input().split())
for i in range(N-1):
  a,b=map(int,input().split())
  if a==b:
    if A<B:
      A=B
    else:
      B=A
    
  else:
    if a/b > A/B:
      # Bに対していく
      if B%b!=0:
        plus=b-(B%b)
        B+=plus
      A=(B*a)//b
    else:
      # Aに足していく
      if A%a!=0:
        plus=a-(A%a)
        A+=plus
      B=(A*b)//a

print(A+B)  

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;

vector<vec> E;
bool used[10000];
vec vs;

void dfs(int v){
    used[v] = true;
    for(int i=0;i<E[v].size();i++){
        if(!used[E[v][i]]) dfs(E[v][i]);
    }
    vs.push_back(v);
}

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

    E.assign(n, vec());
    for(int i=0;i<m;i++){
        int s, t;
        cin >> s >> t;
        E[s].push_back(t);
    }

    fill(used, used+n, false);
    vs.clear();
    for(int i=0;i<n;i++){
        if(!used[i]) dfs(i);
    }

    for(int i=0;i<n;i++){
        cout << vs[n-1-i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1952
a = 0
b = 0
o = 0
ab = 0
while True:
    try:
        n, bt = input().split(",")
        if bt =="A":
            a += 1
        elif bt =="B":
            b += 1
        elif bt =="O":
            o += 1
        elif bt =="AB":
            ab += 1
    except:
        break
print(a, b, ab, o, sep="\n")



Measured memory_bytes: 5560