akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
int b[100002],md,sw,res=2000000000;
using namespace std;
int main()
{
  int N,h,H;
  cin>>N>>H;
  for (int i=0;i<N;i++)
  {
    int x;
    cin>>x;
    md=max(x,md);
    cin>>b[i];
  }
  sort(b,b+N);
  for (int i=0;i<=N;i++)
  {
    h=H-sw;
    if (h<=0) res=min(res,i);
    else res=min(res,i+(h+md-1)/md);
    if (i!=N) sw+=b[N-1-i];
  }
  cout<<res<<endl;
  //system("pause");
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    if (abs(b-a) <= d and abs(c-b) <= d) cout << "Yes" << endl;
    else if (abs(c-a) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t
 
#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 30
#define DIVISOR 1000000007

int get_int3(int *a1, int *a2, int *a3) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d %d", a1, a2, a3);
#else
#error
#endif
  return 0;
}
 
int get_int4(int *a1, int *a2, int *a3, int *a4) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d %d %d", a1, a2, a3, a4);
#else
#error
#endif
  return 0;
}
 
struct query {
    int v1;
    int v2;
    int dist;
    int point;
};
 
#define QUERY_MAX 50
#define NUM_MAX 10
 
int desc_by_point(const void *a1, const void *a2) {
    struct query *qa1 = (struct query*)a1;
    struct query *qa2 = (struct query*)a2;
    return qa2->point - qa1->dist;
}
 

int main(void) {
    int num, limit, qs;
    struct query queries[QUERY_MAX];
    get_int3(&num, &limit, &qs);
 
    int i;
    for(i = 0; i < qs; i++) {
        int v1, v2, dist, point;
        get_int4(&v1, &v2, &dist, &point);
        v1--; v2--;
        queries[i] = (struct query){v1, v2, dist, point};
    }
    qsort(queries, qs, sizeof(struct query), desc_by_point);

    int sum = num + limit - 1;
    int pat;
    int ans = 0;
    for(pat = 1; pat < (1<<sum); pat++) {
        int cnt = __builtin_popcount(pat);
        if(cnt != num) continue;
        int as[NUM_MAX] = {0};
        int aidx = 0; int bidx = 0;
        for(i = 0; i < sum; i++) {
            int flag = (pat & (1<<i));
            if(flag) {
                as[aidx++] = bidx;
            } else {
                bidx++;
            }
        }
        int res = 0;
        for(i = 0; i < qs; i++) {
            struct query q = queries[i];
            if(q.dist == as[q.v2] - as[q.v1]) res += q.point;
        }
        ans = max(res, ans);
    }
    printf("%d\n", ans);
 
    return 0;
}

Measured memory_bytes: 1768
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[] p = new int[m];
        String[] s = new String[m];
        HashSet<Integer> set = new HashSet<>();
        for (int i = 0; i < m; i++) {
            p[i] = sc.nextInt();
            s[i] = sc.next();
            set.add(p[i]);
        }
        if(m == 0) {
            System.out.println("0 0");
            return;
        }
        int size = Collections.max(set);
        boolean[] tmp = new boolean[size + 1];
        int[] tmp2 = new int[size + 1];
        int ac = 0;
        int wa = 0;
        for (int i = 0; i < m; i++) {
            int tmp3 = p[i];
            if(!tmp[tmp3]) {
                if(s[i].equals("WA")) {
                    tmp2[tmp3]++;
                } else {
                    ac++;
                    wa += tmp2[tmp3];
                    tmp[tmp3] = true;
                }
            }
        }
        System.out.println(ac + " " + wa);
    }
}

Measured memory_bytes: 70780
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define int long long

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)

using namespace std;

int N, A[200005];

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    cin >> N;
    REP(i, N) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A, A + N);

    int b = A[N / 2];

    int ans = 0;
    REP(i, N) { ans += abs(A[i] - b); }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner scanner = new Scanner(System.in);
    
    int x = scanner.nextInt(); //next(文字列), nextDouble, nextLine(1行)とか
	int y = scanner.nextInt();
    int ans = 0;
    for (int i  = 0; i < y;i++){
      ans += scanner.nextInt();
    }

      
    if (x - ans >= 0){
    System.out.println(x - ans);
    }
    else{
    System.out.println(-1);
    }
  }
}


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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

int n;cin>>n;
set<int> st;
for(int i=0;i<n;i++){
  int t;cin>>t;st.insert(t);
}
if(st.size()==n){
  puts("YES");
}else
{
    puts("NO");

}

  
  return 0;
}


Measured memory_bytes: 9600
import Data.List

data Dice = Dice {top :: Int,
                  south :: Int,
                  east :: Int,
                  west :: Int,
                  north :: Int,
                  bottom :: Int} deriving Eq
fromList :: [Int] -> Dice
fromList [t,s,e,w,n,b] = Dice t s e w n b

allState :: Dice -> [Dice]
allState d = nub $ [rotateAll d' direction |
                    d' <- map (rotateAll d) ["","N","S","W","E","NN"],
                    direction <- inits "ccc" ]

rotate :: Dice -> Char -> Dice
rotate d 'N' = d {bottom = north d,
                  north = top d,
                  top = south d,
                  south = bottom d}
rotate d 'S' = d {bottom = south d,
                  south = top d,
                  top = north d,
                  north = bottom d}
rotate d 'E' = d {bottom = east d,
                  east = top d,
                  top = west d,
                  west = bottom d}
rotate d 'W' = d {bottom = west d,
                  west = top d,
                  top = east d,
                  east = bottom d}
rotate d 'c' = d {north = west d,
                  west = south d,
                  south = east d,
                  east = north d}
rotate d 'C' = rotateAll d "ccc"

rotateAll :: Dice -> [Char] -> Dice
rotateAll d [] = d
rotateAll d (op:ops) = rotateAll (rotate d op) ops

main :: IO ()
main = do
  d1 <- getDice
  d2 <- getDice
  putStrLn $ if diceEq d1 d2 then "Yes" else "No"
    where
      getDice = fmap (fromList . map read . words) getLine
      diceEq d1 d2 = not . null $ intersect (allState d1) (allState d2)

Measured memory_bytes: 4000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+10;
ll A[maxn],dp[2][maxn];
int main()
{
	int n;scanf("%d",&n);
	ll d;scanf("%lld",&d);
	ll ret=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&A[i]);
		ret+=A[i];
	}
	ret+=d*(n-1);
	dp[0][0]=A[0];
	for(int i=1;i<n;i++)
		dp[0][i]=min(A[i],dp[0][i-1]+d);
	dp[1][n-1]=A[n-1];
	for(int i=n-2;i>=0;i--)
		dp[1][i]=min(A[i],dp[1][i+1]+d);
	for(int i=1;i<n-1;i++)
		ret+=min(dp[0][i],dp[1][i]);
	printf("%lld\n",ret);
	return 0;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 

#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pu push
#define pp pop_back
#define in insert
#define ld long double
#define endl '\n'
#define debug cout << "Hold right there sparky.....\n";
#define forn(low,high,i) for(i=low;i<high;i++)
#define forrev(high,low,i) for(i = high; i>= low;i--)
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef long long int ll;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;

ll power(ll x,ll y) 
{   
    x%=mod;
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % mod; 
    p = (p * p) % mod; 
  
    return (y%2 == 0)? p : (x * p) % mod; 
}

int main()
{
    IOS
 
  IOS
  ll n,k;
  cin>>n>>k;
  cout<<(n-1)/(k-1)+((n-1)%(k-1)!=0)<<endl;
    

}




    

    
 
    
    


Measured memory_bytes: 256
M=8**7
m,f,g,i,a,b=M*476+1,[1],[1]*M,1,0,1
while i<M:f+=f[-1]*i%m,;i+=1
g[-1]=pow(f[-1],m-2,m)
while i>1:i-=1;g[i-1]=g[i]*i%m
A,B=map(int,input().split())
if A<B:A,B=B,A
while i<=B:a+=b*f[A+B-i]*g[B-i];b=b*2%m;i+=1
print((a*f[B]*g[A+B]+A)%m)

Measured memory_bytes: 174608
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){
int l1,l2,d,n=0,m=0;

while(scanf("%d,%d,%d",&l1,&l2,&d)+1){
if(l1==l2)++n;
else if(l1*l1+l2*l2==d*d)++m;
}
cout<<m<<endl<<n<<endl;

}

Measured memory_bytes: 1208
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int k = stdIn.nextInt();
    int count = 0;
    for(int i = 1;i<=n;i++) {
      if(i+k-1<=n) {
        count += 1;
      }
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 24276
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int MAXN = 100005;
pair<int,int> t[MAXN*9];
int tot,n,h,w;
inline bool bound(int x,int y)
{
	return x>1 && x<h && y>1 && y<w;
}
int cnt[15];
int main()
{
	scanf("%d%d%d",&h,&w,&n);
	for(int i=1;i<=n;++i){
		int a,b;
		scanf("%d%d",&a,&b);
		for(int j=-1;j<=1;++j)
			for(int k=-1;k<=1;++k)
				if(bound(a+j,b+k))t[++tot]=make_pair(a+j,b+k);
	}
	sort(t+1,t+tot+1);
	int p=1,sum=0;
	while(p<=tot){
		int now=1;
		while(t[p+1]==t[p])++p,++now;
		++cnt[now];
		++p;
		++sum;
	}
	cout<<(long long)(h-2)*(w-2)-sum<<endl;
	for(int i=1;i<=9;++i){
		cout<<cnt[i]<<endl;
	}
	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  vvll c(3,vll(3));
  rep(i,3) rep(j,3) cin>>c[i][j];
  
  rep(a1,101){
    rep(a2,101){
      rep(b1,101){
        rep(b2,101){
          ll a3=c[2][0]-b1;
          ll b3=c[0][2]-a1;
          if(a1+b1==c[0][0]
          && a1+b2==c[0][1]
          && a2+b1==c[1][0]
          && a2+b2==c[1][1]
          && a2+b3==c[1][2]
          && a3+b2==c[2][1]
          && a3+b3==c[2][2]
          ){
            cout<<"Yes"<<endl;
            return 0;
          }
        }
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
// C++ program to find Excel
// column name from a given
// column number
#include <bits/stdc++.h>
#define MAX 100
#define int long long int
using namespace std;

// Function to print Excel column name for a given column number
void printString(int n)
{
	char str[MAX]; // To store result (Excel column name)
	int i = 0; // To store current index in str which is result

	while (n > 0) {
		// Find remainder
		int rem = n % 26;

		// If remainder is 0, then a 'Z' must be there in output
		if (rem == 0) {
			str[i++] = 'Z';
			n = (n / 26) - 1;
		}
		else // If remainder is non-zero
		{
			str[i++] = (rem - 1) + 'A';
			n = n / 26;
		}
	}
	str[i] = '\0';

	// Reverse the string and print result
	reverse(str, str + strlen(str));
	for(int i=0;i<strlen(str);i++)
    {
        cout<<char(str[i]+32);
    }
	//cout << str << endl;

	return;
}

// Driver program to test above function
int32_t main()
{
    int n;
    cin>>n;
    printString(n);
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;

int main(){
    string s;cin>>s;
    sort(s.begin(),s.end());
    if(s[0]=='1')cout<<3;
    else if(s[1]=='1')cout<<2;
    else if(s[2]=='1')cout<<1;
    else cout<<0;
}

Measured memory_bytes: 256
#encoding: utf-8

n, q = map(int, input().split())
s = input()

t = [0] * (n + 1)

for i in range(n):
    t[i + 1] = t[i] + (1 if s[i: i + 2] == "AC" else 0)

for i in range(q):
    l, r = list(map(int, input().split()))

    print(t[r - 1] - t[l - 1])


Measured memory_bytes: 7748
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int nr = 0;
    vector<int> ad;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'R'){
            nr++;
            ad.push_back(i);
        }
    }
    for(int i = 0; i < nr; i++){
        if(s[i] == 'W'){
            s[i] = 'R';
            int a = ad.back();
            ad.pop_back();
            s[a] = 'W';
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4368
#include <cstdio>
#include <algorithm>

#define MAXN 500000

char s[MAXN + 1];
int pi[MAXN + 1], ip[MAXN + 1];

inline void calcPi(int n, char s[], int pi[]) {
    int r = 0;
    for (int i = 2; i <= n; i++) {
        while (r && s[i] != s[r + 1])
            r = pi[r];
        if (s[i] == s[r + 1])
            r++;
        pi[i] = r;
    }
}

int main() {
    char ch = fgetc(stdin);
    int n = 0;
    while (ch != '\n') {
        s[++n] = ch;
        ch = fgetc(stdin);
    }

    calcPi(n, s, pi);
    if (pi[n] == n - 1) printf("%d\n1\n", n);
    else if (pi[n] == 0 || n % (n - pi[n]) != 0) printf("1\n1\n");
    else {
        int ans = 0;
        for (int i = 1, j = n; i < j; i++, j--)
            std::swap(s[i], s[j]);
        calcPi(n, s, ip);
        for (int i = 1; i < n; i++)
            if ((pi[i] == 0 || i % (i - pi[i]) != 0) && (ip[n - i] == 0 || (n - i) % (n - i - ip[n - i]) != 0))
                ans++;
        printf("2\n%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
#define INF 10000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
	int n;
	cin>>n;
	cout<<(n-2)*180<<endl;
	return 0;
}


Measured memory_bytes: 256
import re

n = int(input())
a = input()
a = re.split(" ",a)

count = 0
ans = 0
while(count == 0):
    for i in range(len(a)):
        if(int(a[i])%2 == 1):
            count = 1
    if(count == 0):
        ans += 1
        for i in range(len(a)):
            a[i] = int(a[i])/2
print(ans)

Measured memory_bytes: 3188
local a = {}
a[1] = io.read("*n")

local function f(n)
    local x
    if n%2==0 then
        return n/2
    else
        return 3*n+1
    end
end

for i = 1, 1000000 do
    if i>=2 then
        a[i] = f(a[i-1])
    end
    if a[i]==1 or a[i]==2 or a[i]==4 then
        print(i+3)
        break
    end
end

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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    if(fopen("input.in", "r")){
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int a, b, c;
    cin >> a >> b >> c;
    swap(a, b);
    swap(a, c);
    cout << a << ' ' << b << ' ' << c << endl;
    return 0;
}

Measured memory_bytes: 256
// G++ MACRO.CPP -STD=C++14
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;

#define dump(x)  cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])

#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) if(1){for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl;}

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

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define EN(x) if(1){cout<<#x<<endl;return 0;}
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template <class T = ll>
T IN(){T x;cin>>x;return (x);}

template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
    seco.resize(head);
    VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
  VECCIN(head);
  VT2(move(tail)...);
}

template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
  seco[head]=IN();
  VT3(head,move(tail)...);
}

#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision; // cpp_int

#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>

#define pb(a) push_back(a)
#define mp make_pair

int main(){
  CIN(a,b,c);
  Yes(a+b>=c);
 
 
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    if(c%max(a,b)!=0)
    {
      cout<<c/max(a,b)+1;
    }
    else cout<<c/max(a,b);

  }


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,p[20002],a[20002],b[20002];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		a[i]=20002*i,b[i]=20002*(n-i+1);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		a[p[i]]-=(n-i+1);
	}
	for(int i=1;i<=n;i++)
		printf("%d ",a[i]);
	printf("\n");
	for(int i=1;i<=n;i++)
		printf("%d ",b[i]);
}

Measured memory_bytes: 768
from sys import stdin

def interval(l, e):
    left = 0
    right = len(l)
    while left < right:
        mid = (left + right) // 2
        if l[mid] < e:
            left = mid + 1
        else:
            right = mid
    return left

def LIS(n, a):
    l = [a[0]]
    for e in a[1:]:
        if l[-1] < e:
            l.append(e)
        else:
            l[interval(l, e)] = e
    return len(l)


def main():
    n = int(input())
    a = list(map(int, stdin.readlines()))
    print(LIS(n, a))


main()


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

#define VIC ios::sync_with_stdio(0);cin.tie(0);ios_base::sync_with_stdio(0);
#define wtf(s) freopen((s), "w", stdout)
#define rff(s) freopen((s), "r", stdin)
#define pi (2 * acos(0))
typedef long double ld;
typedef long long ll;
typedef complex<ld> point;
#define endl '\n'
#define matrix vector<vector<ll>>
#define EPS 1e-9
#define X real()
#define Y imag()
#define vec(a, b) ((b) - (a))
#define dot(a, b) ((conj(a) * (b)).real())
#define cross(a, b) ((conj(a) *(b)).imag())
#define lengthsqr(v) (dot(v, v))
#define length(v) ((ld)hypot((v).Y, (v).X))
#define same(a, b) (lengthsqr(vec(a, b)) < EPS)

const int N = 15 + 5, inf = 2e9, mod = 1e9 + 7;

int main()
{
    VIC
    int a[102][102];
    int n, m, c, x = 0;
    cin >> n >> m >> c;
    int i = 0, j = 0, cur = 0;
    while (true)
    {
        if (j == m)
            j = m - 1,
            i++;
        else if (j == -1)
            j = 0,
            i++;
        if (i == n)
            break;
        if (x == 0)
            cur++,
            cin >> x;
        x--;
        if (i % 2 == 0)
            a[i][j++] = cur;
        else
            a[i][j--] = cur;
    }
    for (int i = 0; i < n; i++, cout << endl)
        for (int j = 0; j < m; j++)
            cout << a[i][j] << ' ';
    return 0;
}


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

int main() {
    ll N , ans = 0;
    cin >> N;
    N++;
    while(N >= 10){
		ans += 9;
		N /= 10;
	}
    ans += N - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
const ll INF = 1e14;
const ll MOD = 1e9 + 7;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) { cin >> a[i]; }
    ll ans = INF;
    rep(i, 2)
    {
        ll sum = 0;
        ll cnt = 0;
        rep(j, n) {
            sum += a[j];
            if (j % 2 == i && sum <= 0) { // make sum plus
                cnt += 1 - sum;
                sum = 1;
            } else if (j % 2 == 1 - i && sum >= 0) { // make sum minus
                cnt += 1 + sum;
                sum = -1;
            }
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import bisect
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort()
b.sort()
c.sort()
ans=0

for elem in b:
    id_a=bisect.bisect_left(a,elem)
    id_c=bisect.bisect(c,elem)
    ans+=id_a*(n-id_c)

print(ans)

Measured memory_bytes: 99328
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
const int MOD = 998244353;
// const int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	
	string s;
	cin >> s;
	int cnt[26] = {};
	for(auto c:s){
		cnt[c-'a']++;
	}
	rep(i,26){
		if(cnt[i]%2 == 1){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	
	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://abc044.contest.atcoder.jp/tasks/abc044_b

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N;
vector< vector<int> > A;

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

    cin >> N;
    A.assign(N, vector<int>(N, 0));
    REP(i, N) {
        REP(j, N-1) {
            cin >> A[i][j];
            A[i][j]--;
        }
    }

    // 各 A がどれだけ進んでいるか
    vector<int> prog(N, 0);
    // 最後までたどり着いたものの数
    int cnt = 0;
    // i の指し先
    // first: i の指し先 second: 情報の新しさ (ans と同じ値)
    vector< pair<int, int> > node_to(N, make_pair(-1, 1));

    int ans = 0;
    bool isChange = true;
    while(isChange) {
        isChange = false;
        ans++;

        REP(i, N) {
            if(prog[i] >= N - 1) { continue; }

            node_to[i] = make_pair(A[i][prog[i]], ans);
            if(node_to[node_to[i].first].second != ans) {
                node_to[node_to[i].first] = make_pair(-1, ans);
            }
            else if(node_to[node_to[i].first].first == i) {
                prog[i]++;
                if(prog[i] >= N - 1) { cnt++; }
                prog[node_to[i].first]++;
                if(prog[node_to[i].first] >= N - 1) { cnt++; }

                node_to[node_to[i].first] = make_pair(-1, ans);
                node_to[i] = make_pair(-1, ans);
                isChange = true;
            }
        }
    }

    ans--;
    if(cnt < N) {
        ans = -1;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 10240
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(2_000_000)

def solve(H, W, CH, DH, CW, DW, S):
    from collections import deque
    costs = [[float("inf")] * W for _ in range(H)]
    
    def bfs():
        q = deque([(CH-1, CW-1, 0)])
        while q:
            h, w, c = q.popleft()
            if h == (DH-1) and w == (DW-1):
                return c
            if costs[h][w] < c:
                continue
            costs[h][w] = c
            for dh, dw in zip((0, 0, 1, -1), (1, -1, 0, 0)):
                nh, nw = h + dh, w + dw
                if not (0 <= nh < H and 0 <= nw < W):
                    continue
                if S[nh][nw] == "#":
                    continue
                if costs[nh][nw] <= c:
                    continue
                costs[nh][nw] = c
                q.appendleft((nh, nw, c))
            for dh in range(-2, 3):
                for dw in range(-2, 3):
                    nh, nw = h + dh, w + dw
                    if not (0 <= nh < H and 0 <= nw < W):
                        continue
                    if S[nh][nw] == "#":
                        continue
                    if costs[nh][nw] <= (c + 1):
                        continue
                    costs[nh][nw] = c+1
                    q.append((nh, nw, c+1))
        return -1
    
    return bfs()

    
# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    H, W = map(int, input().split())
    CH, CW = map(int, input().split())
    DH, DW = map(int, input().split())
    S = [input() for _ in range(H)]
    print(solve(H, W, CH, DH, CW, DW, S))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


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

using namespace std;

int main(){
  int a = 0, b = 0, c = 0;
  string s;
  cin >> s;
  
  for(int i = 0; i < 3; i++){
    if(s[i] == 'a')a++;
    else if(s[i] == 'b')b++;
    else if(s[i] == 'c')c++;
  }
  if(a == 1 && b == 1 && c == 1) cout << "Yes";
  else cout << "No";
}


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

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  for (int i = 0; i < 101010; i++) {
    int x = i * 8 / 100;
    int y = i * 1 / 10;
    if (a == x && b == y) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 256
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
rows = [list(map(int,input().split())) for _ in range(N)]

pos = [0,0]
time = 0
for row in rows:
    t,x,y = row
    tt = t - time
    xx = abs(x-pos[0])
    yy = abs(y-pos[1])
    num = tt-(xx+yy)
    if num>=0 and num%2==0:
        pos = [x,y]
        time = t
    else:
        print("No")
        exit()

print("Yes")
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


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

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

    int n;
    cin >> n;

    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int min_v = 1e9;
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(a[i] <= min_v){
            ans++;
            min_v = a[i];
        }
    }
    cout << ans << endl;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//main code
LL gcd(LL a,LL b) {
	LL bigger = max(a,b);
	LL smaller = min(a,b);
	if (smaller == 0) return bigger;
	if (smaller < 0) {
		cerr << "smaller of gcd is negative number" << endl;
		return 1;
	}
	if (bigger % smaller != 0) {
		return gcd(smaller,(bigger % smaller));
	}
	return smaller;
}

int main(int argc, char const* argv[])
{
	LL a,b;
	cin >> a >> b;
	cout << a*b/(gcd(a,b)) << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void f(int n,int64_t x,vector<int64_t> &l,vector<int64_t> &p,int64_t &ans){
  if(x==1) return;
  else if(x<l.at(n-1)+1) f(n-1,x-1,l,p,ans);
  else if(x==l.at(n-1)+1) ans+=p.at(n-1);
  else if(x==l.at(n-1)+2) ans+=p.at(n-1)+1;
  else if(x<2*l.at(n-1)+2){
    ans+=p.at(n-1)+1;
    f(n-1,x-l.at(n-1)-2,l,p,ans);
  }
  else if(x>=2*l.at(n-1)+2) ans+=p.at(n);
}
int main(){
  int n,i;
  int64_t x,ans=0;
  cin>>n>>x;
  vector<int64_t> l(n+1),p(n+1);
  l.at(0)=1;
  p.at(0)=1;
  for(i=1;i<=n;i++){
    l.at(i)=2*l.at(i-1)+3;
    p.at(i)=2*p.at(i-1)+1;
  }
  f(n,x,l,p,ans);
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
using namespace std;
constexpr long long INF = (long long)1<<60;
int main() {
	struct edge { long long from, to, cost; };
	int V, E, r;
	cin>>V>>E>>r;
	vector<edge> es(E);
	for (auto i = 0; i < E; i++) {
		int s, t, d;
		cin>>s>>t>>d;
		es[i] = {s,t,d};
	}
	vector<long long> d(V, INF);
	d[r] = 0;
	int cnt = V;
	bool neg_loop = false;
	while (true) {
		if (!cnt--) {
			neg_loop = true;
			break;
		}
		bool flag = false;
		for (auto& i : es) {
			if (d[i.from] != INF && d[i.to] > d[i.from]+i.cost) {
				flag = true;
				d[i.to] = d[i.from]+i.cost;
			}
		}
		if (!flag) break;
	}
	if (neg_loop) cout << "NEGATIVE CYCLE" << endl;
	else {
		for (auto& i : d)
			cout << (i == INF ? "INF" : to_string(i)) << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int ans,k,s;
   ans=0;
   cin >> k >> s;
   for (int x=0;x <= k;x++){
      for (int y=0; y <= k;y++){
         if (s-x-y <= k && 0 <= s-x-y) ans++;
      }
   }
   cout << ans << endl;   
   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main(){
	string str;
	while(getline(cin,str)){
		for(int i=0;i<str.length();i++){
			if(isalpha(str[i]))
				str[i] = toupper(str[i]);
		}
		cout<<str<<endl;
	}
	return 0;
}

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

int gcd(int p,int q){
    if(p%q == 0){
        return q;
    }
        return gcd(q,p%q);
}

int main() {
double a, b, h, m, rad,x; cin >> a >> b >> h >> m;
x = 60*h+m;
rad = M_PI * 5.5*x / 180;

double ans = a * a + b * b - 2 * a * b * cos(rad);

ans = sqrt(ans);

cout << fixed << setprecision(30);
cout << ans << endl;
}


Measured memory_bytes: 4224
import heapq
# 単一始点最短経路。2地点間ではなく、始点が一つで各点へのコストを計算する
# eは隣接リストでe[v] = [(u1,cost1), (u2,cost2)]みたいな形を想定
# 辺の重みは正である必要がある
# O(ElogV)
def dijkstra(e,n,s):
    inf = 10**18
    d = [inf]*n
    d[s] = 0

    q = [(d[s],s)] # priority queueのソートキーが第一要素
    heapq.heapify([q])
    while len(q)>0:
        _,v = heapq.heappop(q)
        for u,c in e[v]:
            if d[v]+c>=d[u]:
                continue
            d[u] = d[v] + c
            heapq.heappush(q, (d[u],u))
    return d

n,x,y = map(int, input().split())

g = [[] for _ in range(n)]
for i in range(n-1):
    g[i].append((i+1,1))
    g[i+1].append((i,1))
g[x-1].append((y-1,1))
g[y-1].append((x-1,1))
    

res = [0]*n
for i in range(n):
    d = dijkstra(g,n,i)
    for j in range(i+1,n):
        res[d[j]] += 1

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

Measured memory_bytes: 72284
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
    int n, AC = 0, WA = 0, TLE = 0, RE = 0;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        if (s[i] == "AC") {
            AC++;
        } else if (s[i] == "WA") {
            WA++;
        } else if (s[i] == "TLE") {
            TLE++;
        } else if (s[i] == "RE") {
            RE++;
        }
    }
    cout << "AC x " << AC << endl
         << "WA x " << WA << endl
         << "TLE x " << TLE << endl
         << "RE x " << RE << endl;
    return 0;
}

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

using namespace std;

int s[100010],t[50010];
int n, q, ans = 0;

bool binary_search(int x) {
	int l = 0, r = n-1;
	ans = 0;
	while (r - l >= 0) {
		int m = (l + r) / 2;
		if (s[m] == x) {
			ans++;
			return true;
		}
		else if (s[m] > x) {
			r = m-1;
			ans++;
		}
		else if (s[m] < x) {
			l = m+1;
			ans++;
		}
	}
	
	return false;
}
int main() {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> s[i];
		}
		cin >> t[0];
		binary_search(t[0]);
		for (int i = 0; i < n; i++) {
			s[i] = 0;
		}
			cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n[1500];
char c[1500][100];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int l=0;
    while(true){
    cin >> n[l];
    if(n[l]==0)break;
    for (int i = 0; i < n[l]; i++){
        cin >> c[l][i];
    }
    l++;
    }
    for(int i=0;i<l;i++){
        vector<pair<int,char> > count;
        for(int j=0;j<n[i];j++){
            bool ch=false;
            for(int k=0;k<count.size();k++){
                if(c[i][j]==count[k].second){
                    count[k].first++;
                    
                    ch=true;
                }
            }
            if(ch==false){
                count.push_back(make_pair(1,c[i][j]));
                
            }
            sort(ALL(count));
            if(count.size()==1){
            if(count[0].first*2>n[i]){
                cout<<count[0].second<<" "<<j+1<<"\n";
                break;
            }
            }
            else{
                if(count[count.size()-1].first>count[count.size()-2].first+n[i]-j-1){
                    cout<<count[count.size()-1].second<<" "<<j+1<<"\n";
                    break;
                }
            }
        }
        if(count[count.size()-1].first==count[count.size()-2].first)
        cout<<"TIE"<<"\n";
    }
}


Measured memory_bytes: 3292
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}


signed main(){
  int n,K;
  cin>>n>>K;
  
  int ans = 1;
  for(int i=0;i<n;i++) ans = min(ans*2,ans+K);
  cout<<ans<<endl;

  return 0;
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	vector<VI> d(m, VI(3));
	rep(i, m){ cin >>d[i][0] >>d[i][1]; d[i][2]=i;}
	VI sq(m); iota(all(sq), 0);
	VI zm(n+1, 1) ;

	sort(all(sq), [&](auto l, auto r){ return d[l][1] < d[r][1];});
	for(auto& x: sq) d[x][2] = zm[d[x][0]]++;
	
	for(auto& x: d) printf("%06d%06d\n", x[0], x[2]);
	
	return 0;
}


Measured memory_bytes: 7808
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String b = sc.next();
    switch(b){
      case "A":
        System.out.println("T"); break;
      case "T":
        System.out.println("A"); break;
      case "C":
        System.out.println("G"); break;
      case "G":
        System.out.println("C"); break;
    }
  }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,k,sum=0;
	cin>>a>>b>>c>>k;
	if(a>=k)
	cout<<k;
	else
	{
		sum+=a;
		k-=a;
		if(b<k)
		{
			k-=b;
			if(b>=k)
			sum-=k;
			else
			sum-=k;
		}
	cout<<sum;	
	}
	
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"sort"
	"strconv"
)

type IntListForSort []int

func (s IntListForSort) Len() int           { return len(s) }
func (s IntListForSort) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s IntListForSort) Less(i, j int) bool { return s[i] < s[j] }

func sortIntList(intList []int) {
	sort.Sort(IntListForSort(intList))
}

type IntListForSortDesc []int

func (s IntListForSortDesc) Len() int           { return len(s) }
func (s IntListForSortDesc) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s IntListForSortDesc) Less(i, j int) bool { return s[i] > s[j] }

func sortIntListDesc(intList []int) {
	sort.Sort(IntListForSortDesc(intList))
}

// ASC前提
func binarySearchInt(intList []int, key int, iMin int, iMax int) int {
	if iMax < iMin {
		return -1
	} else {
		iMid := iMin + (iMax-iMin)/2
		if intList[iMid] > key {
			return binarySearchInt(intList, key, iMin, iMid-1)
		} else if intList[iMid] < key {
			return binarySearchInt(intList, key, iMid+1, iMax)
		} else {
			return iMid
		}
	}
}

func input() string {
	var s string
	_, _ = fmt.Scan(&s)
	return s
}

func inputLn() string {
	var s string
	_, _ = fmt.Scanln(&s)
	return s
}

func inputByScanner(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func convListStrToInt(strList []string) []int {
	intList := make([]int, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = intV
	}
	return intList
}

func convListStrToFloat(strList []string) []float64 {
	intList := make([]float64, len(strList))
	for k, v := range strList {
		intV, _ := strconv.Atoi(v)
		intList[k] = float64(intV)
	}
	return intList
}

func main() {
	l, _ := strconv.Atoi(input())
	r, _ := strconv.Atoi(input())

	res := 9999999999
	flg := false
	for i := l; i <= r; i++ {
		if flg {
			break
		}
		for j := l; j <= r; j++ {
			if i == j {
				continue
			}
			mod := i * j % 2019
			if mod == 0 {
				res = 0
				flg = true
				break
			}
			if mod < res {
				res = mod
			}
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
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; }

int main(){
    string s; cin >> s;
    int stk = 0, t = 0;
    for(char c: s){
        if(c == 'T'){
            if(stk == 0) t++;
            else{
                stk--;
            }
        }else{
            stk++;
        }
    }
    int res = stk + t;
    cout << res << ln;
}

Measured memory_bytes: 640
N = int(input())

ok = 0
aa = 0
for i in range(N):
    A, B = map(int, input().split())
    if A == B:
        aa += 1
    else:
        aa = aa*0
    if aa == 3:
        ok = 1


if ok == 1:
    print("Yes")
else:
    print("No")

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

int solve(string s,int n){
    
}


int main(){
    string s;
    cin >> s;
    int n = s.size();
    int zero = 0, one = 0;
    for(int i=0;i<n;i++){
        if(s.at(i) == '1') one++;
        else zero ++ ;
    }
    int delta = abs(one - zero);
    cout << n - delta << endl;

}

Measured memory_bytes: 3760
a,b,c,d = map(int,input().split())

i=0
for i in range(100):
  c=c-b
  
  if c<=0:
    print('Yes')
    break
    
  else:
    a=a-d
    
    if a<=0:
      print('No')
      break
    else:
      continue
              

Measured memory_bytes: 9176
#include <iostream>
#include <cmath>
bool prime[1000001];
using namespace std;
int main(){
	int i,j,n;

	for (i = 3; i <= 1000000; i += 2){
		prime[i] = true;
	}
	prime[2] = true;

	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				prime[i * j] = false;
			}
		}
	}
	while(cin >> n && n){
		int count = 0;
		for(i=2;i<=n;i++){
			if(prime[i] == true) count++;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#m = int(input())
h1, m1, h2, m2, k = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

a = h2 - h1
b = m2 - m1

print(60 * a + b - k)


        


Measured memory_bytes: 9564