akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll Mod=1e9+7;
int n;
ll f[3010][3010],g[3010][3010];
char s[3010];
int main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	f[1][1]=g[1][1]=1;
	for (int i=2;i<=n;i++)
	{
		for (int j=1;j<=i;j++)
		{
			if (s[i-1]=='<')
			{
				f[i][j]=g[i-1][j-1];
			}
			else
			{
				f[i][j]=(g[i-1][i-1]-g[i-1][j-1]+Mod)%Mod;
			}
			g[i][j]=(g[i][j-1]+f[i][j])%Mod;
		}
	}
	cout<<g[n][n]<<endl;
	return 0;
}


Measured memory_bytes: 139904
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    char b;
    cin >> b;
    
    if (b == 'A') cout << 'T' << endl;
    else if (b == 'T') cout << 'A' << endl;
    else if (b == 'C') cout << 'G' << endl;
    else cout << 'C' << endl;
}

Measured memory_bytes: 256
program main
  implicit none
  integer :: A,B,K
  integer :: ic
  integer :: i,j
  integer :: n
  
  read (*,*) A,B,K

  ic = min(A,B)
  n=0
  do  i = ic,1,-1
     if ( mod(A,i) == 0 .and. mod(B,i) == 0) then
        n = n+1
     end if
     if (n == K) then
        write(*,'(i0)') i
        stop  
     end if
  end do
  
end program main

Measured memory_bytes: 640
open Batteries
(* bitの数字の2真数の時の右からn番目の数字が0か1か *)
let is_bit_one bit n = if bit land (1 lsl n) = 0 then false else true

let int_to_list bit n =
  let rec get i =
    match i with 
    | i when i = n -> []
    | _ -> if is_bit_one bit i then i :: get (i+1) else get (i+1)
  in get 0

(* 文字列をcharのlistにする *)
let explode s = List.init (String.length s) (String.get s)

let abcd = read_line () |> explode |> List.map Char.escaped |> List.map int_of_string

let rec eval nums ops result =
  match nums with
  | [] -> result
  | first :: rest -> if List.length ops = 3 && result = min_int then eval rest ops first
    else 
    match ops with
    | [] -> result
    | f :: r -> if f = "+" then eval rest r (result+first) else eval rest r (result-first)

let rec get_eval_text nums ops =
  match nums with
  | [] -> ""
  | first :: rest -> 
    match ops with
    | [] -> string_of_int first
    | f :: r -> if f = "+" then string_of_int first ^ "+" ^ get_eval_text rest r else string_of_int first ^ "-" ^ get_eval_text rest r

let get_ops bit n =
  let rec get i =
    match i with 
    | i when i = n -> []
    | _ -> if is_bit_one bit i then "+" :: get (i+1) else "-" :: get (i+1)
  in get 0

let rec ans bit =
  match bit with
  | bit when bit >= 3 * 3 -> ""
  | _ -> if eval abcd (get_ops bit 3) min_int = 7 then get_eval_text abcd (get_ops bit 3) else ans (bit+1)

let _ = print_endline @@ (ans 0) ^ "=7"

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n];
  rep(i,n) R a[i];
  ll ans=MAXL;
  rep(t,1<<n) {
    if(__builtin_popcount(t)!=m) continue;
    ll b[n];
    rep(i,n) b[i]=a[i];
    ll sum=0;
    ll x=0;
    rep(i,n) {
      if((t&(1<<i))&&x>=b[i]) {
        sum+=x-b[i]+1;
        b[i]=x+1;
      }
      x=max(x,b[i]);
    }
    ans=min(ans,sum);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    string S;
    cin >> S;
    int now = S.size() - 5;
    while(now >= 0) {
        if(S.substr(now, 5) == "dream" || S.substr(now, 5) == "erase") {
            now -= 5;
            continue;
        }
        now--;
        if(now < 0) {
            cout << "NO" << endl;
        }
        if(S.substr(now, 6) == "eraser") {
            now -= 5;
            continue;
        }
        now--;
        if(now < 0) {
            cout << "NO" << endl;
        }
        if(S.substr(now, 7) == "dreamer") {
            now -= 5;
            continue;
        }
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
 
int main(void){
    cin.tie(0);ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    for (int i = 0; i < max(n,m); i++)
    {
        cout << min(n,m);
    }
    cout << endl;
    return 0;
}
/*
g++ test.cpp
./a.out

*/

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef array<char,17> A;

const LL M=1e9+7;
map<A,int> mem[41];
int N,X[3];
LL pw[41];
map<A,int> mem2[41];
int update(int e, A a){
	int s=0;
	while(s<e){
		int st=0;
		int sum=0;
		bool ok=true;
		for(int i=s;i<e&&st<3;i++){
			if(sum+a[i]==X[st]){
				st++;
				sum=0;
			}
			else if(sum+a[i]>X[st]){
				ok=false;
				break;
			}
			else{
				sum+=a[i];
			}
		}
		if(ok){
			if(st==3){
				s=-1;
			}
			break;
		}
		s++;
	}
	return s;
}
LL f(int s,int e,A pre){
	if(mem[s].count(pre)){
		return mem[s][pre];
	}

	if(e==N){
		return mem[s][pre]=0;
	}
	LL ret=0;
	for(int i=1;i<=10;i++){
		pre[e-s]=i;
		int t=update(e-s+1,pre);
		if(t==-1){
			ret+=pw[N-(e+1)];
			continue;
		}
		A q={{}};
		for(int i=0;i<e+1-(s+t);i++){
			q[i]=pre[t+i];
		}
		ret+=f(s+t,e+1,q);
	}
	pre[e-s]=0;
	ret%=M;
	return mem[s][pre]=ret;
}
int main() {
	cin >> N;
	for(int i=0;i<3;i++){
		cin >> X[i];
	}
	pw[0]=1;
	for(int i=1;i<=40;i++){
		pw[i]=pw[i-1]*10%M;

	}
	A a={{}};
	cout << f(0,0,a) << endl;

	return 0;
}



Measured memory_bytes: 35328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;


int main() {
    string s;
    cin >> s;
    int n = s.size();

    int k;
    scanf ("%d", &k);

    set<string> S;

    int m = min(10, n);

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            string t = s.substr(i, j + 1);

            if (S.find(t) == S.end()) {
                S.insert(t);

                if (S.size() > 5) {
                    S.erase(*(S.rbegin()));
                }
            }
        }
    }

    int idx = 1;
    for (auto it = S.begin(); it != S.end(); ++it) {
        if (idx == k) {
            printf ("%s\n", (*it).c_str());
            break;
        }
        ++idx;
    }
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        int N = int.Parse(inputs[0]);
        int Q = int.Parse(inputs[1]);
        var S = Console.ReadLine();
        var t = new int[N + 1];

        // あらかじめ0～i番目の数列を作成しておく
        t[0] = 0;
        for(int i = 1; i < N; i++)
        {
            int count = 0;
            if(i + 1 <= N &&
                S[i - 1] == 'A' &&
                S[i] == 'C')
            {
                count++;
            }
            
            t[i] = t[i-1] + count;
        }

        for (int i = 0; i < Q; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            int l = int.Parse(inputs[0]);
            int r = int.Parse(inputs[1]);
            int count = t[r - 1] - t[l - 1];
            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 16328
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 100050
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll visited[50];
ll N, M;
ll G[50][50]={0};

void dfs(ll u) {
    visited[u]=1;
    for(ll i=0; i<N; i++) {
        if(G[u][i] && visited[i]==0)
            dfs(i);
    }
    
}

int main(void) {
    cin >> N >> M;
    ll a[50], b[50];
    ll i, j;
    
    for(i=0; i<M; i++) {
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]][b[i]]=1;
        G[b[i]][a[i]]=1;
    }
    ll ans=0;
    for(i=0; i<M; i++) {
        G[a[i]][b[i]]=G[b[i]][a[i]]=0;
        for(j=0; j<N; j++)
            visited[j]=0;
        
        dfs(0);
        
        bool flag=0;
        for(j=0; j<N; j++) {
            if(visited[j]==0)
                flag=1;
        }
        
        if(flag) ans++;
        
        G[a[i]][b[i]]=G[b[i]][a[i]]=1;
    }
    
    
    prin(ans)
}



Measured memory_bytes: 256
#include<iostream>

using namespace std;

void shellSort(long int numbers[], long int array_size)
{
  int i, j, increment, temp;

  increment = 4;
  while (increment > 0)
  {
    for (i=0; i < array_size; i++)
    {
      j = i;
      temp = numbers[i];
      while ((j >= increment) && (numbers[j-increment] > temp))
      {
        numbers[j] = numbers[j - increment];
        j = j - increment;
      }
      numbers[j] = temp;
    }
    if (increment/2 != 0)
      increment = increment/2;
    else if (increment == 1)
      increment = 0;
    else
      increment = 1;
  }
}

int main()
{
  long int N,x;
  long int all=0;
  int i;
  int c=0;
  cin >> N >>x;
  long int a[N];
  for(int i=0;i<N;i++)
    cin>>a[i];

  shellSort(a,N);
  for(i=0;i<N-1;i++){
    if(x<=a[i])
      break;
    c++;
    x-=a[i];
  }
  if(x==a[i])
    c++;
  cout << c <<endl;
  return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))
minus = [-x for x in a if x < 0]
plus = [x for x in a if x >= 0]
minus.sort()
plus.sort()


def cnt(x):
    ans = 0
    if x < 0:
        r = 0
        x = -x
        for num in minus[::-1]:
            while r < len(plus) and plus[r] * num < x:
                r += 1
            ans += len(plus) - r
        return ans

    r = 0
    for num in minus[::-1]:
        if num * num <= x:
            ans -= 1
        while r < len(minus) and minus[r] * num <= x:
            r += 1
        ans += r
    r = 0
    for num in plus[::-1]:
        if num * num <= x:
            ans -= 1
        while r < len(plus) and plus[r] * num <= x:
            r += 1
        ans += r
    ans //= 2
    ans += len(minus) * len(plus)
    return ans

right = 10**18+1
left = -(10**18+1)

while left+1 < right:
    mid = (left + right)//2

    if cnt(mid) < k:
        left = mid
    else:
        right = mid

print(int(right))

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

int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	set<int> s;
	for(int i = 0; i < k; i++) {
		int len, x;
		scanf("%d", &len);
		while(len--) scanf("%d", &x), s.insert(x);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++) ans += !s.count(i);
	printf("%d\n", ans);
}


Measured memory_bytes: 3792
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
##listでqueの代用をするとO(N)の計算量がかかってしまうので注意
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率

def input(): return sys.stdin.readline()[:-1]
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え
    import random
    N = int(input())
    #N, K = map(int, input().split())
    A = list(map(int, input().split())) #1行ベクトル
    #A=[random.randrange(1,10**6) for _ in range(100)]
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    #A=[i+1 for i in range(1,200000)]
    A.sort()
    ma=A[-1]
    l=[0]*(ma+10)
    ca=Counter(A)
    count=0
    pa=0
    f=0
    for a in A:
        if l[a]==0:
            if ca[a]==1:
                count+=1
            i=a
            while i<ma+10:
                l[i]=1
                i+=a
        pa=a
    print(count)

    #print(A,ma)
if __name__ == "__main__":
    main()


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int a = 0;
    for (int i = 0; i < 4; i++)
        if (s[i] == '+')
            a++;
        else
            a--;

    cout << a << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MAX_N = 100100;
const double PI = 3.14159265358979323846;



int main(int argc, char *args[]) {
	int n;
	cin >> n;
	vector<pair<int, int>> A(n), B(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i].first;
		A[i].second = i;
	}
	for (int i = 0; i < n; i++) {
		cin >> B[i].first;
		B[i].second = i;
	}

	sort(A.begin(), A.end());
	sort(B.begin(), B.end());

	for (int i = 0; i < n; i++) {
		if (A[i].first > B[i].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	
	for (int i = 0; i < n - 1; i++) {
		if (A[i + 1].first <= B[i].first) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	vector<int> to(n);
	for (int i = 0; i < n; i++) {
		to[A[i].second] = B[i].second;
	}
	int cur = 0;
	int cnt = 0;
	do {
		cur = to[cur];
		cnt++;
	} while (cur != 0);
	cout << (cnt >(n - 1) ? "No\n" : "Yes\n");
	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
const int mx = 100005;
int n, a, m[mx], mi[mx], mlen, j = 1;
long long ms[mx], mr[mx];
int main(){
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a);
        if(a > m[mlen]){
            m[++mlen] = a;
            ms[mlen] = 1;
            mi[mlen] = i;
        }else if(a == m[mlen]) ms[mlen]++;
        else{
            int it = upper_bound(m, m+mlen+1, a) - m;
            mr[it] += a - m[it-1];
            ms[it-1]++;
        }
    }
    for(int i = mlen; i > 0; i--){
        mr[i] += ms[i] * (m[i] - m[i-1]);
        ms[i-1] += ms[i];
    }
    for(int i = 0; i < n; i++) printf("%lld\n", mi[j] - i ? 0 : mr[j++]);
}

Measured memory_bytes: 3456
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, k = na()

if n > k:
    n = n % k + k
mi = n
for i in range(10):
    n = abs(n-k)
    mi = min(n, mi)
print(mi)



Measured memory_bytes: 38384
#include <iostream>
using namespace std; 
int main(){
    ios::sync_with_stdio(false); 
    int nCount,iStart,iEnd; 
    register int i,nTotal=0; 
    cin >> nCount; 
    for (i = 1; i <= nCount; ++i){ 
        cin >> iStart >> iEnd; 
        nTotal += iEnd - iStart + 1; 
    }
    cout << nTotal << endl; 
    return 0; 
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from heapq import heapify, heappop, heappush
from sys import stdin

def main():
    n, y = map(int, input().split())
    for i in range(0, n+1):
        for j in range(0, n+1):
            k = n - i - j
            if k < 0: continue
            if 10000*i + 5000*j + 1000*k == y:
                print(i, j, k)
                exit(0)
    print(-1, -1, -1)

    #print(ans)

input = lambda: stdin.readline().rstrip()
main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define inf 100000000000000000
#define ll long long int
#define pb push_back
#define f first
#define s second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}

int main(){
	// mahakal();fast;
	string str;
	cin>>str;
	ll n=str.length();
	for(ll i=0;i<n;i++)cout<<"x";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
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 int64_t INF = 1LL << 60;

int main() {
  int N;
  cin>>N;
  vector<int64_t>A(N+2);
  vector<int64_t>B(N+2);
  for(int i=0;i<=N;i++){
    cin>>A[i];
  }
  for(int i=0;i<N;i++){
    cin>>B[i];
  }

  int64_t sum=0;int64_t ok=0;int64_t res=0;
  for(int i=0;i<=N;i++){
    if(i<N){sum+=min(A[i],B[i]+ok);}
    else{sum+=min(A[i],ok);}
    ok=max((int64_t)0,B[i]-max((A[i]-ok),(int64_t)0));
  }
  cout<<sum<<endl;
  return 0;}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <queue>
#include <list>
#include <cstdlib>
#include <cmath>

#define _USE_MATH_DEFINES
#define REP(i,n) for(i = 0;i<n;i++)

using namespace std;

int main() {
	
	string e, o;
	int i, len1, len2;

	cin >> o;
	cin >> e;

	len1 = o.length();
	len2 = e.length();
	
	REP(i, len2) {
		cout << o[i] << e[i];
	}

	if (len1 - len2 != 0)
		cout << o[i];

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,T;
int dp[3333];
main()
{
	cin>>N>>T;
	vector<pair<int,int> >A(N);
	for(int i=0;i<N;i++)
	{
		cin>>A[i].first>>A[i].second;
	}
	sort(A.begin(),A.end());
	int ans=0;
	for(int i=0;i<N;i++)
	{
		int a=A[i].first;
		int b=A[i].second;
		for(int j=T;j--;)
		{
			if(j+a>=T)ans=max(ans,dp[j]+b);
			else dp[j+a]=max(dp[j+a],dp[j]+b);
		}
	}
	for(int j=0;j<T;j++)ans=max(ans,dp[j]);
	cout<<ans<<endl;
}


Measured memory_bytes: 256
# Tenka1 Programmer Beginner Contest 2017: B – Different Distribution
N = int(input())
A, B = [], []
for _ in range(N):
    tmp = input().split()
    A.append(int(tmp[0]))
    B.append(int(tmp[1]))

idx = A.index(max(A))

print(A[idx] + B[idx])

Measured memory_bytes: 16972
import java.util.*;

public class Main {
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [] data = new int[n + 1];
			for(int i = 1; i <= n; i++){
				data[i] = sc.nextInt();
			}
			int m = 256;
			double ans = 1 << 24;
			int as=0, aa=0, ac=0;
			for(int s = 0; s <= 15; s++){
				for(int a = 0; a <= 15; a++){
					for(int c = 0; c <= 15; c++){
						int [] r = new int[n + 1];
						r[0] = s;
						for(int i = 1; i <= n; i++){
							r[i] = (a * r[i-1] + c) % m;
						}
						int [] freq = new int[m];
						for(int i = 1; i <= n; i++){
							freq[(r[i] + data[i]) % m]++;
						}
						double nowh = 0;
						for(int i = 0; i < m; i++){
							if(freq[i] == 0) continue;
							double value= ((double)freq[i] / n) * Math.log((double)freq[i] / n);
							nowh -= value;
						}
						if(ans  > nowh + 1.0e-08){
							ans = nowh;
							as = s;
							aa = a;
							ac = c;
						}
					}
				}
			}
			System.out.println(as + " " + aa + " " + ac);
		}
	}
	
	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 91768
#include<stdio.h>

int serch (int A[],int n, int key){
  int i = 0;
  A[n] = key;
  while (A[i] != key) i++;
  return i != n;
}

int main(){
  int i,n,q,A[10000],key,sum = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(serch(A,n,key))sum++;
  }
  
  printf("%d\n",sum);
  
  return 0;
}

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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  
  for(int i=0;i<K;i++){
	if(A%2==1){
	  A--;
	}
	B+=A/2;
	A/=2;
	int t=A;
	A=B;
	B=t;
  }

  if(K%2==1){
	int t=A;
	A=B;
	B=t;	
  }

  cout<<A<<" "<<B<<endl;  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 3e2+5;
double dp[L][L][L];

void solve()
{
    ll n = nxt();
    basic_string <ll> a(n, 0);
    generate(all(a), nxt);

    vector <ll> cnt(4, 0);

    for(ll i=0; i<n; i++)
    {
        cnt[a[i]]++;
    }

    for(ll c=0; c<=n; c++)
    {
        for(ll b=0; b<=n; b++)
        {
            for(ll a=0; a<=n; a++)
            {
                if(a+b+c > n)
                {
                    continue;
                }

                if(a + b + c == 0)
                {
                    continue;
                }

                dp[a][b][c] = 1;

                if(a)
                {
                    dp[a][b][c] += dp[a-1][b][c] * (double)a/n;
                }

                if(b)
                {
                    dp[a][b][c] += dp[a+1][b-1][c] * (double)b/n;
                }

                if(c)
                {
                    dp[a][b][c] += dp[a][b+1][c-1] * (double)c/n;
                }

                dp[a][b][c] *= (double)n/(a+b+c);
            }
        }
    }

    cout << fixed << setprecision(10) << dp[cnt[1]][cnt[2]][cnt[3]] << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 219392
#include<stdio.h>
int have[50];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a){
		int where=0;
		int cup=b;
		for(int i=0;i<a;i++)have[i]=0;
		while(1){
			if(cup>0){
				cup--;
				have[where%a]++;
				if(have[where%a]==b){
					printf("%d\n",where%a);
					break;
				}
			}else{
				cup=have[where%a];
				have[where%a]=0;
			}
			where++;
		}
	}
}

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

int main() {
	int64_t x=0, m = 0, a = 0, r = 0, c = 0, h = 0, D[5], i, N, d;
	int P[10] = { 0,0,0,0,0,0,1,1,1,2 };
	int Q[10] = { 1,1,1,2,2,3,2,2,3,3 };
	int T[10] = { 2,3,4,3,4,4,3,4,4,4 };

	cin >> N;
	vector<string> S(N);

	for (i = 0; i < N; ++i) {
		cin >> S[i];
		if (S[i][0] == 'M') ++m;
		if (S[i][0] == 'A') ++a;
		if (S[i][0] == 'R') ++r;
		if (S[i][0] == 'C') ++c;
		if (S[i][0] == 'H') ++h;
	}

	D[0] = m, D[1] = a, D[2] = r, D[3] = c, D[4] = h;

	for (d = 0; d < 10; ++d) {
		x += D[P[d]] * D[Q[d]] * D[T[d]];
	}

	cout << x << endl;
	return 0;
}

Measured memory_bytes: 6144
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scan(&k)

	mod := 0
	count := 0
	modMap := map[int]bool{}
	for {
		mod = (mod*10+7) % k
		count++
		if modMap[mod] {
			fmt.Println(-1)
			return
		}
		if mod == 0 {
			fmt.Println(count)
			return
		}
		modMap[mod] = true
	}
}

// 1,	2,	 3,   4,   5
// 101, 202, 303, 404, 505 => 101n
// 7, 77, 777, 7777, 77777 => (10^n - 1)/7
// 101m = (10^n - 1)/7
// m = (10^n - 1)/7k
// m = (10^n - 1)/707

// km = (10^n - 1)/7
// 7km = 10^n - 1
// 7km + 1 = 10^n




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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T,class U>
istream& operator >> (istream&is, P<T,U>&p){
  is >> p.first >> p.second;
  return is;
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v){
    is >> e;
  }
  return is;
}

int main(){
  int a,b; cin >> a >> b;
  string s[100];
  for(int i = 0; i < 100; ++i){
    if(i < 50)s[i] = string(100,'.');
    else s[i] = string(100,'#');
  }
  int r = 0, c = 0;
  for(int i = 0; i < b-1; ++i){
    if(c >= 100){
      c = 0;
      r += 2;
    }
    s[r][c] = '#';
    c+=2;
  }
  r = 99; c = 0;
  for(int i = 0; i < a-1; ++i){
    if(c >= 100){
      c = 0;
      r -= 2;
    }
    s[r][c] = '.';
    c+=2;
  }
  cout << 100 << ' ' << 100 << endl;
  for(int i = 0; i < 100; ++i)cout << s[i] << endl;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main(){
  int N, K, P, i;
  scanf("%d",&N);


  for(i = 0; i < N; i++ ){
    scanf("%d %d",&K,&P);
       
    if(K%P == 0){
      printf("%d\n",P);  
    } else{
      printf("%d\n",K%P);    
    }

  }
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int n, m, x;
vector<int> c;
vector<vector<int>> a;

int dfs(int mincost, int book, vector<int> und);

int main()
{ 
    cin >> n >> m >> x;
    rep(i, n)
    {
        int cost;
        cin >> cost;
        c.push_back(cost);
        vector<int> tmp;
        rep(j, m)
        {
            int A;
            cin >> A;
            tmp.push_back(A);
        }
        a.push_back(tmp);
    }
    vector<int> und(m, 0);
    int ans = dfs(0, 0, und);
    if(ans!=INT32_MAX) cout << ans;
    else cout << -1;
    cout << endl;
    return 0;
}

int dfs(int mincost, int book, vector<int> und){
    if(book==n){
        bool flag = true;
        rep(i, m){
            if(und[i]<x){
                flag = false;
                break;
            }
        }
        if(flag) return mincost;
        return INT32_MAX;
    }
    int nocost = dfs(mincost, book+1, und);
    rep(i, m){
        und[i] += a[book][i];
    }
    int buycost = dfs(mincost+c[book], book+1, und);
    return min(nocost, buycost);
}

Measured memory_bytes: 3620
#include <stdio.h>

int main() {
	long long int k, ans = -1;
	long long int x=7;
	scanf("%lld", &k);
	for (int i = 1; i <= k; i++) {
		if (x % k == 0) {
			ans = i;
			break;
		}
		x = (x * 10 + 7) % k;
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1732
#include<stdio.h>
#include<string.h>
#include<limits.h>
#include<stdlib.h>

int dif;

int maxdif(){
    char row[1000];
    char *tok;
    int max;
    int min;
    fgets(row, 1000, stdin);
    tok = strtok(row, " ");
    max = atoi(tok);
    min = atoi(tok);
    int i = 0;
    int pointer;
    //printf("%s\n", tok);
    while(tok != NULL){
        pointer = atoi(tok);
        if(max < pointer){
            max = pointer;
        }
        if(min > pointer){
            min = pointer;
        }
        tok = strtok(NULL, " ");
        i++;
        //printf("%s\n", tok);
    }
    dif = max - min;
    if(i == 1 || i == 0 || i > 100){
        dif = maxdif();
    }
    return dif;
}

int main(void){
    maxdif();
    printf("%d\n", dif);
    return 0;
}

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

#define _GLIBCXX_DEBUG

//vector<int> A(M), B(M);
//vector<vector<char>> answer(N, vector<char>(N, '-'));

int main() {
  int a, b;
  int ans;
  
  cin >> a >> b;
  
  ans = 6 - a - b;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
function Main(input) {
  const data = input.trim().split("");
  var N = data.length;

  function jan(me, tki) {
    if (me == tki) {
      return 0;
    }
    if (me == "g" && tki == "p") {
      return -1;
    }
    if (me == "p" && tki == "g") {
      return 1;
    }
  }
  var count = 0;
  var goo = 0;
  var paa = 0;
  for (i = 0; i < N; i++) {
    if (i === 0) {
      count += jan("g", data[0]);
      goo++;
    } else {
      if (data[i] === "g" && goo > paa) {
        count += jan("p", data[i]);
        paa++;
      } else if (data[i] === "p" && goo > paa) {
        count += jan("p", data[i]);
        paa++;
      } else {
        count += jan("g", data[i]);
        goo++;
      }
    }
  }
  console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 8396
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	ll x=n*a;
	ll ans=min(x,b);
	cout<<ans<<endl;
}

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

int main() {
  int score[100];
  int N;
  cin >> N;
  fill(score,score+N,0);
  int num = N*(N-1)/2;
  for(int i = 0; i < num; ++i) {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    --A;--B;
    if(C > D) {
      score[A] += 3;
    } else if(C < D) {
      score[B] += 3;
    } else {
      ++score[A];
      ++score[B];
    }
  }
  vector<pair<int,int> > v;
  for(int i =0; i < N; ++i) {
    v.push_back(make_pair(score[i],i));
  }
  sort(v.begin(), v.end(), greater<pair<int,int> >());
  int s = 1;
  int output[100];
  output[v[0].second] = 1;
  for(int i = 1; i < v.size(); ++i) {
    if(v[i].first != v[i-1].first) s = i+1;
    output[v[i].second] = s;
  }
  for(int i = 0; i < N; ++i) {
    cout << output[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

N = k()
A = l()
Cnt = [0] * (N+1)
for a in A:
    Cnt[a] += 1
for c in Cnt:
    ans += c * (c-1) // 2
Ans = [ans - Cnt[a] + 1 for a in A]
print("\n".join(map(str, Ans)))


Measured memory_bytes: 48704
import heapq
v,e=map(int,input().split())
adj=[[] for _ in range(v)]
for _ in range(e):
  a,b,c=map(int,input().split())
  adj[a].append((b,c))
  adj[b].append((a,c))

visit=[0]*v
pq=[]
for next,w in adj[0]:
  heapq.heappush(pq,(w,next))
visit[0]=1
ans=0
while pq:
  w,next=heapq.heappop(pq)
  if visit[next]:
    continue
  visit[next]=1
  ans+=w
  for next,w in adj[next]:
    if not visit[next]:
      heapq.heappush(pq,(w,next))
print(ans)



Measured memory_bytes: 37264
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ll  long long
#define PI  acos(-1)
#define pb  push_back
#define ins insert
#define INF 5000000000000000007 //1e18+7
#define mk  make_pair
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x)  upper_bound(all(v),x)
#define ff  first
#define ss  second
#define rev reverse
#define endl "\n"
#define max3(x,y,z)  max(x,max(y,z))
#define min3(x,y,z)  min(x,min(y,z))
#define sz(a) (ll)a.size()
#define double long double
#define coud(a,b) cout<<fixed << setprecision((b)) << (a)
#define mset(x,y)  memset(x,y,sizeof(x))
#define all(x)   (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bp(n)  __builtin_popcountll(n)
#define mxt(a)  *(max_element(a.begin(),a.end()))
#define mnt(a)  *(min_element(a.begin(),a.end()))
#define unique_sort(c) (sort(all(c)), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define rep(i,a,b) for(ll i=(a);i<=(b);++i)
#define trav(a, x)    for(auto &a : x)
#define re(i,n)       for(ll i=0;i<n;++i) 
#define int2Bin(x,y)  bitset <y> z=x; cout<<z.to_string()<<endl;
const double eps=1e-7;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
// int dx[8]={+1, +1, +1, 0, 0, -1, -1, -1};
// int dy[8]={+1, 0, -1, +1, -1, +1, 0, -1};
int dx[4]={1, 0, 0, -1};
int dy[4]={0, -1, 1, 0};
ll power(ll x,ll y){ll ans=1;x=x;while(y>0){if(y&1)ans=(ans*x);y=y>>1;x=(x*x);}return ans;}
ll sqr(ll x) { return x * x;}
template <typename T> T gcd(T a,T b){ if(a==0) return b; return gcd(b%a,a); }
template <class T> inline void chmax(T &x,T y){ x = max((x), (y));}
template <class T> inline void chmin(T &x,T y){ x = min((x), (y));}
template <class T> T abs(T x) { return x>0 ? x : -x;}
template <typename T> T powm(T a,T b, ll m){T cnt=1; while(b>0){ if(b%2==1) cnt=(cnt*a)%m; b/=2; a=(a*a)%m; }return cnt%m;}
typedef pair<int,int>  pii;
typedef pair<ll,ll>  pll;
typedef vector<pll>  vpll;
typedef vector<pii>  vpii;
typedef vector<ll>   vll;
typedef vector<int>  vii;
#define minpq priority_queue<T,vector<T>,greater<T> >;
// #define T int
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
//*X.find_by_order(k) returns the kth largest element (0-based).
//X.order_of_key(val) returns the no. of values less than val.
ll ncr(ll n,ll r){ll ans=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){ans*=(n-i);ans/=(i+1);}return ans;}
const int MOD=1000000007;   
const int N=100000;
struct compare{
    bool operator() (const int &a,const int &b) const{
        return a>b;
    }
};
void prec(){

}
void run(){ 
    ll n,d;cin>>n>>d;
    d=sqr(d);
    int cnt=0;
    while(n--) {
        ll x,y;cin>>x>>y;
        ll now=sqr(x)+sqr(y);
        if(now<=d) cnt++;
    }
    cout<<cnt;
}   
int32_t main(){
    cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    int tc=1;
    //cin>>tc;
    prec();
    re(i,tc)
        run();
    return 0; 
}
/* 
    stuff you should look for
    * int overflow,array bounds.
    * special cases (n=1?).
    * N,MOD value.
*/


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

const int Inf = 0x3f3f3f3f;
const int MN = 105;

int N, M, A[MN][MN], f[MN][MN];

int main() {
	scanf("%d%d", &N, &M);
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j) {
			char ch[3];
			scanf("%1s", ch);
			if (*ch == '#') A[i][j] = 1;
		}
	f[1][1] = A[1][1];
	for (int i = 1; i <= N; ++i)
		for (int j = 1; j <= M; ++j) {
			if (i == 1 && j == 1) continue;
			f[i][j] = Inf;
			if (i > 1) f[i][j] = std::min(f[i][j], f[i - 1][j] + (!A[i - 1][j] && A[i][j]));
			if (j > 1) f[i][j] = std::min(f[i][j], f[i][j - 1] + (!A[i][j - 1] && A[i][j]));
		}
	printf("%d\n", f[N][M]);
	return 0;
}

Measured memory_bytes: 256
import bisect
from collections import deque
N = int(input())
my_max = deque([10 ** 9 + 1])
prev = -1
ans = 0
for _ in range(N):
    a = int(input())
    x = bisect.bisect_left(my_max, a) # a未満
    if x == 0: # どれよりも小さい
        my_max.appendleft(a)
        ans += 1
    else:
        my_max[x - 1] = a # a未満の中で最も大きいものと貪欲に同じ色にする
print(ans)

Measured memory_bytes: 47448
#include<bits/stdc++.h>
#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 fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int r, D, x;
    cin >> r >> D >> x;
    rep(i, 0, 10)
    {
        x = r * x - D;
        cout << x << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#include <map>
#include <climits>
#include <vector>
#include <set>
#include <string>
#include <numeric>

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int>> vii;
const int N = 2 * (1e5 + 1);
const int INF = 1e9 + 5;
const long long MOD = 1e9 + 7;

int32_t main() {
    FAST_IO;
    int x;
    cin >> x;
    cout << (800*x) - ((x/15)*200);
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		char[] s = sc.next().toCharArray();
		int red = 0, blue = 0;
		for(int i = 0; i < s.length; i++) {
			if(s[i] == '0') red++;
			else blue++;
		}
		if(s.length == 1) {
			System.out.println(0);
		}else {
			System.out.println(2*Math.min(red, blue));
		}
	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}


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

int main(){
  long long N,M;
  cin>>N>>M;
  vector<long long>A(N,0);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  
  vector<pair<long long,long long>>vec(M);
  for(int i=0;i<M;i++){
    cin>>vec[i].second>>vec[i].first;
    //cout<<i<<" "<<vec[i].first<<" "<<vec[i].second<<endl;
  }
  
  sort(vec.begin(),vec.end());
  
  //cout<<A[0]<<A[1]<<A[2]<<endl;
  
  int temp1=0;
  int temp2=0;
  int temp3=0;
  while(1){
    if(A[temp1]<vec[M-1-temp2].first && vec[M-1-temp2].second-temp3>0){
      A[temp1]=vec[M-1-temp2].first;
      temp1++;
      temp3++;
      continue;
    }
    if(A[temp1]<vec[M-1-temp2].first && vec[M-1-temp2].second-temp3==0){
      temp2++;
      temp3=0;
      continue;
    }
    break;
  }
      
  //cout<<vec[M-1].first<<" "<<A[0]<<endl;
  long long sum=0;
  for(int i=0;i<N;i++){
    sum=sum+A[i];
      //cout<<A[i]<<"#"<<endl;
  }
  cout<<setprecision(18)<<sum<<endl;
  return 0;
}

 

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

bool check(long a, long b, long c) {
    long d = c - a - b;
    return d > 0 && d * d > 4 * a * b;
    //     if (d <= 0) {
    //         return false;
    //     }
    //     if (4 * a * b >= d * d) {
    //         return false;
    //     }
    //     return true;
}

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

    cout << (check(a, b, c) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using Graph = std::vector<std::vector<int>>;
using WGraph = std::vector<std::vector<std::pair<int, long long>>>;
using ll = long long;
using namespace std;

bool is_prime(long long n) {
    if (n == 1) {
        return false;
    }
    for (long long i=2; i*i<=n; i++) {
        if (n%i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int n = 0; cin >> n;
    ll a = 11;
    for (int i=0; i<n; i++) {
        while (!is_prime(a)) {
            a += 10;
        }
        cout << a;
        a += 10;
        if (i == n-1) cout << endl;
        else cout << " ";
    }
    return 0;
}
 

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

int main(){
  int N;
  cin >> N;
  
  vector<int> buttom(N, 0);
  
  for (int i = 0; i < N; i++){
    cin >> buttom.at(i);
  }
  
  int a = 1;
  int b = -1;
  for (int i = 0; i < N; i++){
    a = buttom.at(a - 1);
    if (a == 2){
      b = i + 1;
      break;
    }
  }
  
  cout << b << endl;
}

Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	if S == "A" {
		fmt.Println("T")
	} else if S == "T" {
		fmt.Println("A")
	} else if S == "C" {
		fmt.Println("G")
	} else if S == "G" {
		fmt.Println("C")
	}
}


Measured memory_bytes: 1768
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans = []
for rem_ix in range(0, N-K):
    remove = A[rem_ix]
    insert = A[K+rem_ix]
    # print("rem: ", remove)
    # print("ins: ", insert)
    if remove < insert:
        ans.append("Yes")
    else:
        ans.append("No")

print(*ans, sep='\n')

Measured memory_bytes: 31604