akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin >> x;
    ll now = 100;
    int num = 0;
    while(now < x){
    	now += now/100;
    	num++;
    }
    cout<< num << endl;
    return 0;
}


Measured memory_bytes: 3612
import numpy as np
W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N 
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())

check = [[0]*W for _ in range(H)]

for i in range(N):
    if a[i] == 1:
        for j in range(H):
            k = 0
            while k != x[i]:
                check[j][k] = 1
                k += 1
    if a[i] == 2:
        for j in range(H):
            k = x[i]
            while k != W:
                check[j][k] = 1
                k += 1
    if a[i] == 3:
        k = 0
        while k != y[i]:
            for j in range(W):
                check[k][j] = 1
            k += 1
    if a[i] == 4:
        k = y[i]
        while k != H:
            for j in range(W):
                check[k][j] = 1
            k += 1


ans = 0

for i in range(H):
    tmp = check[i].count(0)
    ans += tmp

print(ans)



Measured memory_bytes: 12516
import math

def main():
  k = int(input())
  params = [1,1,0]
  count = 0
  
  while params[0] < k or params[1] < k or params[2] < k:
    if params[2] < k:
      params[2] = params[2]+1
    elif params[1] < k:
      params = [params[0],params[1]+1,1]
    elif params[0] < k:
      params = [params[0]+1,1,1]
      
    tmp = 0
    if 1 in params:
      tmp = 1
    else:
      tmp = math.gcd(params[0],params[1])
      if tmp > 1:
        tmp = math.gcd(tmp, params[2])
    
    count += tmp
    
  return count
 
def gcd(val1, val2):
  val3 = 0
  while True:
    val3 = val1 % val2
    val1 = val2
    if val3 == 0:
      break
    val2 = val3
  return val1

if __name__ == '__main__':
  print(main())

Measured memory_bytes: 67920
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define $(x) cout<<">>"<<#x<<":"<<x<<"\n"
const double eps = 1e-9;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	int res=0;
	int count=0;
	for(int i=0;i<3;++i)
	{
		if(s[i]=='R')
			++count;
		else
		{
			if(count>res)
				res=count;
			count=0;

		}
	}
	if(count>res)
		res=count;
	cout<<res;
	return 0;
}


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

int main(){
  int N,K;
  cin >>N>>K;
  vector<int> H(N);
  for(int i=0;i<N;i++){
    cin >>H.at(i);
  }
  int count=0;
  for(int i=0;i<N;i++){
    if(H.at(i)>=K){
      count ++;
    }
  }
  cout <<count<<endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int blue,red;
    cin >> blue;
    vector<string> blue_card(blue);
    int i,j;
    for(i=0;i<blue;i++){
        cin >> blue_card.at(i);
    }
    cin >> red;
    vector<string> red_card(red);
    for(i=0;i<red;i++){
        cin >> red_card.at(i);
    }
    int ans = 0;
    for(i=0;i<blue;i++){
        int plus = 0,minus = 0;
        for(j=0;j<blue;j++){
            if(blue_card.at(i) == blue_card.at(j)){
                plus++;
            }
        }
        for(j=0;j<red;j++){
            if(blue_card.at(i) == red_card.at(j)){
                minus++;
            }
        }
        if(ans < plus - minus){
            ans = plus - minus;
        }
    }
    if(ans < 0){
        cout << 0 << endl;
    }else{
        cout << ans << endl;
    }
    return 0;
}

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

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

    if (a >= k)
    {
        a = a - k;
    }
    else if (a < k)
    {
        b = b - (k - a);
        a = 0;
        if (b < 0)
        {
            b = 0;
        }
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,m,a,b,ans=0;
  int h[100005],cnt[100005]={};
  cin>>n>>m;

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

  for(int i=0; i<m; i++){
    cin>>a>>b;
    if(h[a]>h[b]){
      cnt[b]=1;
    }else if(h[a]<h[b]){
      cnt[a]=1;
    }else{
      cnt[a]=1;
      cnt[b]=1;
    }
  }
  for(int i=1; i<=n; i++){
    if(cnt[i]==0)ans++;
  }
  
  cout<<ans<<'\n';
  return 0;
}

  


Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

bool solve(const int& n, const int& m, const int& k) {
  if (k % n == 0 || k % m == 0 || k == 0) {
    return true;  
  }

  for (int i = 1; i <= n; i++) {
    int blk = m * i;
    if (blk == k) return true;
    for (int j = 0; j < m; j++) {
      blk += n - i * 2;
      if (blk == k) return true;  
    }
  }
  return false;
}

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

  int n, m, k;
  cin >> n >> m >> k;

  if (solve(n, m, k) || solve(m, n, k)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#pragma GCC optimze("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define ppp pair<ll,pp >
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
typedef tree<pp,null_type,less<pp>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define ld long double
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,a,b) for(ll i=a;i<b;i+=1)
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
ll t=1, tt;
const ll inf=1e18, N=3005;
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (1LL*x*y)%hell;}
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll powMod(ll base,ll expo){
	if(base==0)return 0;
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base); 
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n;
	cin>>n;
	vector<ll> a(n);
	for(auto &x : a)
		cin>>x;
	ll dp[n][n];
	rep(i,0,n)
		rep(j,0,n)
			dp[i][j]=-inf;
	rep(len,1,n+1){
		for(ll i=0;i+len-1<n;i++){
			if(len==1)dp[i][i]=a[i];
			else{
				dp[i][i+len-1]=max(dp[i][i+len-1],a[i]-dp[i+1][i+len-1]);
				dp[i][i+len-1]=max(dp[i][i+len-1],a[i+len-1]-dp[i][i+len-2]);
			}
		}
	}
	cout<<dp[0][n-1];
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   	//cin>>t;
   	tt=t;
    while(t--){
        solve();
        if(t)cout<<"\n";
    }
    return 0 ;
}


Measured memory_bytes: 70656
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int ans = S.length() / 2;
    int mid = S.length() / 2;
    rep(i, mid + S.length() % 2) {
        //cout << mid + i << " " << S.length() - mid - i - 1<< endl;
        if (S[mid + i] == S[S.length() - mid - i - 1]) {
            if (i == 0 || (i > 0 && S[mid + i] == S[mid + i - 1]))
                ans++;
            else 
                break;
        } else 
            break;
        //cout << mid + i << " " << S.length() - mid - i - 1<< endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(){
  int i,j,a;
  int n,m;
  int count = 0;

  scanf("%d",&n);

  int S[n];
  
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  
  scanf("%d",&m);
  int T[m];
  
  for(i=0;i<m;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<m;i++){
    for(j=0;j<n;j++){
      if(S[j] == T[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2760
#include <stdio.h>

int main()
{
	int N, M;
	scanf("%d%d", &N, &M);

	int a[M], brk[N+1];
	long long int dp[N+1];
	int i;

	for (i = 0; i < N+1; i++) 
		brk[i] = 0;

	for (i = 0; i < M; i++) {
		scanf("%d", &a[i]);
		brk[a[i]] = 1;
	}
	
//	for (i = 0; i < M; i++)
//		printf("a[%d] = %d\n", i, a[i]);

//	for (i = 0; i < N + 1; i++)
//		printf("brk[%d] = %d\n", i, brk[i]);
	
	dp[0] = 1;
	brk[0] = 0;
	if (brk[1] == 1) 
		dp[1] = 0;
	else 
		dp[1] = 1;
//	printf("dp[%d] = %lld\n", 0, dp[0]);
//	printf("dp[%d] = %lld\n", 1, dp[1]);
//	printf("dp[%d] = %lld\n", 2, dp[2]);
	for (i = 2; i < N + 1; i++) {
		if (brk[i] == 1) {
			dp[i] = 0;
		} else {
			dp[i] = (dp[i-1] + dp[i-2]) % 1000000007;
		}
//		printf("dp[%d] = %lld\n", i, dp[i]);
	}

	printf("%lld\n", dp[i-1]);

	return 0;
}


Measured memory_bytes: 1664
N,K = (int(i) for i in input().split())

half = 0
zero = 0

if K%2==0:
	for i in range(1,N+1):
		if i%K==K/2:
			half+=1
		if i%K==0:
			zero+=1

else:
	for i in range(1,N+1):
		if i%K==0:
			zero+=1

print(half**3+zero**3)

Measured memory_bytes: 3060
n = int(input())
h = list(map(int, input().split()))
r = 0
m = 0
for i in range(1, n):
  if h[i] > h[i - 1]:
    r = max(r, m)
    m = 0
  else:
    m += 1

ans = max(r,m)
print(ans)

Measured memory_bytes: 14252
N = int(input())
number_list = [int(input()) for _ in range(N)]

sorted_num = sorted(number_list)
number_max = sorted_num[-1]
number_second_max = sorted_num[-2]

if number_max == number_second_max:
  output_always_max = True
else:
  output_always_max = False

for number in number_list:
  if output_always_max:
    print(str(number_max))
  else:
    if number == number_max:
      print(str(number_second_max))
    else:
      print(str(number_max))

Measured memory_bytes: 14068
class UF:
    def __init__(self, N):
        self.uf = [-1]*N
        self.n = N

    def find(self, x):
        if self.uf[x]<0: return x
        self.uf[x] = self.find(self.uf[x])
        return self.uf[x]

    def size(self, x):
        return -self.uf[self.find(x)]

    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x==y: return
        if self.size(x) > self.size(y): x, y = y, x
        self.uf[y] += self.uf[x]
        self.uf[x] = y
        self.n -= 1

N, K, L = list(map(int, input().split()))
uf1, uf2 = UF(N), UF(N)
for _ in range(K):
    p, q = list(map(int, input().split()))
    uf1.union(p-1, q-1)

for _ in range(L):
    r, s = list(map(int, input().split()))
    uf2.union(r-1, s-1)

keys = [(uf1.find(x), uf2.find(x)) for x in range(N)]
count = {}
for key in keys:
    if key in count: count[key]+=1
    else: count[key]=1

print(*[count[key] for key in keys])

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

using namespace std;

int main() {
	int s1 = 0, s2 = 0;
	for (int i = 0; i < 4; ++i) {
		int a; cin >> a;
		s1 += a;
	}
	for (int i = 0; i < 4; ++i) {
		int a; cin >> a;
		s2 += a;
	}
	cout << max(s1, s2) << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char X, Y;
  cin >> X >> Y;
  if(X < Y) {
    cout << '<' << endl;
  } else if(X == Y) {
    cout << '=' << endl;
  } else {
    cout << '>' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
s = input()
n = len(s)

l = [0] * n
maxr = 0
for i in range(n):
    if (s[i] == 'R'):
        maxr = i
    else:
        ind = maxr if (i - maxr) % 2 == 0 else maxr + 1
        l[ind] += 1
minl = n - 1
for i in range(n):
    if (s[n - i - 1] == 'L'):
        minl = n - i - 1
    else:
        ind = minl if (minl + i + 1 - n) % 2 == 0 else minl - 1
        l[ind] += 1

for i in range(n - 1):
    print(l[i], end=" ")
print(l[n - 1])


Measured memory_bytes: 4864
import math

N,A,B = map(int,input().split())
v = list(map(int,input().split()))

v.sort(reverse = True)
total = 0

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(A):
    total = total + v[i]
else:
    print(total / A)
    
count = 0
min = v[A-1]
number = v.count(min)

if(v.index(min) == 0):
    for i in range(A,number+1):
        if(i>B):
            break
        count = combinations_count(number,i) + count
    print(count)
else:
    print(combinations_count(number,A - v.index(min)))


Measured memory_bytes: 9212
//C:\Program Files(x86)\Dev-Cpp\MinGW64\lib\gcc\x86_64-w64-mingw32\4.9.2\include\c++\x86_64-w64-mingw32\bits\stdc++.h
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cstring>
#include<cstdlib>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<limits>
#include<list>
#include<map>
#include<math.h>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<sstream>
#include<string>
#include<time.h>
#include<utility>
#include<vector>

using namespace std;

int a,b,c;
long long k;
long long ans;

int main(){
	scanf("%d%d%d%lld",&a,&b,&c,&k);
	if(k%2) ans=b-a;
	else ans=a-b;
	if(ans>(int)1e18) puts("Unfair");
	else printf("%lld\n",ans);
	return 0;
}


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



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

    cout<< (a+b)%24 <<endl;

    return 0;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True, end="")


S=input()

"""
分割して、全部違うならおけ
前の分割と被らなければ良い。
まず、最小単位で切るのが正解
次に出てくる分割が、かぶっていればもう一文字伸ばして分割
それを繰り返す
これがダメなのは、
caa
これは、cの時点ではいい
ccccccなら
c cc c ccで4分割が正解
cccccなら
c cc c cはダメなので
c ccc cにする
-1すればいい
"""
previous=""
skip=False
K=0
for i in range(len(S)):
	if skip:
		skip=False
		continue
	
	if i == len(S)-1:
		if previous == S[i]:
			break

	if i==0:
		previous = S[i]
		K+=1
		continue
	
	if S[i] == previous:
		previous = S[i] + S[i+1]
		skip=True
		K+=1
	else:
		K+=1
		previous=S[i]
	
	
		
	

print(K)

Measured memory_bytes: 6988
#include <iostream>
#include <vector>
#include <cmath>
#include <stdio.h>
#include <time.h>
#include <set>
#include <cstring>
#include <algorithm>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#define F first
#define S second
#define MP make_pair
#define PB push_back
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7, maxn = 1e4 + 100;
ll a[maxn][5], dp[maxn][5];

int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    for (int i = 1; i <= 2; i++){
        for (int j = 1; j <= n; j++){
            cin >> a[j][i];
        }
    }
    memset (dp, 0, sizeof dp);
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= 2; j++){
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
        }
    }
    cout << dp[n][2] << endl; 
}        

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


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

    int ans = 0;
    multiset<int> s;
    for (int i = 0; i < N; i++) {
        multiset<int>::iterator it = s.upper_bound(-A[i]);
        if (it != s.end()) {
            s.erase(it);
            s.insert(-A[i]);
        } else {
            ans++;
            s.insert(-A[i]);
        }
    }
    cout << ans << endl;

    return 0;
}


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

#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >

const int mod=998244353;
const long double inf=1e14;
int power(int a,int b,int p)
{
    int ans=1;
    while(b)
    {
        if(b&1)
        {
            ans=(ans*a)%p;
        }
        a=(a*a)%p;
        b>>=1;
    }
    return ans;
}

int32_t main()
{
    string str;
    int n,k;
    cin>>n>>k;
    cin>>str;
    repa(i,1,n)
    {
        if(i!=k)
        {
            cout<<str[i-1];
        }
        else
        {
            char ch=str[i-1];
            if(ch=='A')
                cout<<'a';
            else if(ch=='B')
                cout<<'b';
            else
                cout<<'c';
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
typedef pair<int,mp> mmp;

int n,m,k;

int uni[10005];
int isb[10005];
mmp vs[10005];

int find(int p){
	if(uni[p] == p)return p;
	return (uni[p] = find(uni[p]));
}


bool mer(int to,int p){
	uni[find(p)] = find(uni[to]);
}


int main(void){
	int casen = 0;
	while(1){
		casen++;
		scanf("%d%d%d",&n,&m,&k);
		if(n==0)break;
		rep(i,n-1){
			int a,b,c;
			scanf("%d%d%d",&a,&b,&c);
			vs[i] = mmp(c,mp(a,b));
		}
		
		reg(i,1,n)uni[i] = i;
		memset(isb,0,sizeof(isb));
		
		rep(i,m){
			int a;
			scanf("%d",&a);
			isb[a] = 1;
		}
		
		sort(vs,vs+n-1,greater<mmp>());
	
		int canmn = m - k - 1;
		
		int ans = 0;
		
		rep(i,n-1){
			mmp pa = vs[i];
			int a = pa.sec.fir,
				b = pa.sec.sec,
				c = pa.fir;
			a = find(a); b = find(b);
			if(isb[a] == 1 && isb[b] == 1){
				if(canmn>0)canmn--;
				else ans+=c;
			}
			if(isb[a]==1)mer(a,b);
			else mer(b,a);
		}
		
		printf("Case %d: %d\n",casen,ans);
	}
		
	
	return 0;
}

Measured memory_bytes: 1236
n,m = map(int,input().split())
data = []
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    data.append((b,a))
data.sort()
cnt = 0
dis = -1
for i in range(m):
    b,a = data[i]
    if(dis < a):
        cnt += 1
        dis = b - 1
print(cnt)

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

using namespace std;
typedef long long ll;




int main(void)
{
    int n;
    cin>>n;
    map<string,int>m;
    string s;
    int x=INT_MIN;
    for(int i=0;i<n;i++)
    {
        cin>>s;
        m[s]++;
        x=max(x,m[s]);

    }
    map<string,int>::iterator it;
    for(it=m.begin();it!=m.end();it++)
    {
        if(it->second == x)
        {
            cout<<it->first<<endl;
        }
    }

}







Measured memory_bytes: 19180
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
main(){
  int max=0;
  int size;
  int banti=0;
  int renzoku[1000001]={0};
  char s[1000002];
  char renzokumozi[1000001];
  queue<int> q;
  cin>>s;
  size=strlen(s);
  renzoku[0]=1;
  renzokumozi[0]=s[0];
  if(s[0]=='J'){
    q.push(0);
  }
  for(int i=1;i<size;i++){
    if(s[i-1]==s[i]){
      renzoku[banti]=renzoku[banti]+1;
    }
    else{
      banti=banti+1;
      renzoku[banti]=1;
      renzokumozi[banti]=s[i];
      if(s[i]=='J'){
	q.push(banti);
      }
    }
  }
  while(!q.empty()){
    //cout<<q.front()<<" "<<renzoku[q.front()]<<" "<<renzoku[q.front()+1]<<" "<<renzoku[q.front()+2]<<" "<<renzokumozi[q.front()]<<" "<<renzokumozi[q.front()+1]<<" "<<renzokumozi[q.front()+2]<<endl;
    if(q.front()+2<=banti){
      int min;
      if(renzoku[q.front()]>=renzoku[q.front()+1]&&renzoku[q.front()+2]>=renzoku[q.front()+1]){
	min=renzoku[q.front()+1];
	if(renzokumozi[q.front()]=='J'&&renzokumozi[q.front()+1]=='O'&&renzokumozi[q.front()+2]=='I'&&max<min){
	  max=min;
	}
      }
    }
    q.pop();
  }
  cout<<max<<endl;
}

Measured memory_bytes: 9056
A = input()
st = [(0, 0, -1)]
cur = 0; ma = 0
for i, a in enumerate(A):
    if a == '/':
        cur += 1
        s = 0
        while st and st[-1][0] == cur-1 and cur <= ma:
            lev, su, j = st.pop()
            s += su
        if st and st[-1][0] == cur:
            s += i - st[-1][2] - 1
        ma = max(ma, cur)
        st.append((cur, s, i))
    elif a == '\\':
        cur -= 1
        st.append((cur, 0, i))
    elif a == '_':
        st.append((cur, 0, i))
ans = []
for lev, su, j in st:
    if su > 0:
        ans.append(su)
print(sum(ans))
print(len(ans), *ans)


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

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

int main(){
  int N,Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  int t[N],count=0;
  t[0]=0;
  for(int i=1;i<S.size();i++){
    if(S[i-1]=='A'&&S[i]=='C')
      count++;
    t[i]=count;
  }
  int l[Q],r[Q];
  rep(i,Q)
    cin>>l[i]>>r[i];
  rep(i,Q){
    cout<<t[r[i]-1]-t[l[i]-1]<<endl;

  }
  



  return 0;
}
  


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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() {
    int n, c; ll k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    rep(i, n) cin >> t[i];
    sort(all(t));

    ll ans = 0;
    for (int i = 0; i < n;) {
        int notteru = 0;
        for (int j = i; j < n; j++) {
            if (t[j] <= t[i] + k && notteru < c) notteru++;
            else break;
        }
        ans++;
        i += notteru;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
const ll mod = 1e9+7;

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

  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int f = 0;
  while(a>0 && c>0){
  if(f==0){
    c-=b;
  }else{
    a-=d;
  }
  f=1-f;
  }
  if(a<=0){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
    
  return 0;
  }


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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;

const int inf=1e+9;
const int mod=1e9+7;

int main(){
	string s;
	cin>>s;

	int Pa=0;
	int hand=s.size()/2;
	for (int i = 0; i < s.size(); ++i){
		if(s[i]=='p')Pa++;
	}

	cout<<hand-Pa<<endl;

}


Measured memory_bytes: 512
N,K=map(int,input().split())
AL=list(map(int,input().split()))
summ=0
for i in range(N):
  summ+=AL[i]
candidate=set()
for i in range(1,int(summ**0.5)+1):
  if summ%i==0:
    candidate.add(i)
    candidate.add(summ/i)
ans=0
for x in candidate:
  need=0
  r=[0]*N
  for i in range(N):
    r[i]=AL[i]%x
  r.sort()
  rsum=0
  for i in range(N):
    rsum=rsum+r[i]
  rindex=int(rsum/x)
  lindex=N-int(rsum/x)
  for i in range(lindex):
    need+=r[i]
  if need<=K:
    ans=max(ans,x)
print(int(ans))

Measured memory_bytes: 43612
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <set>
#include <vector>
#include <map>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <cassert>
#include <climits>
#include <numeric>
#include <sstream>
using namespace std;
typedef long long ll;
#define DEBUG
#ifdef DEBUG
	#define debug printf
#else
	#define debug(...)
#endif
const int maxn = 2e5 + 5;
ll a[maxn];
ll mp[maxn];
ll c(ll n)
{
	return (n * (n - 1)) >> 1;
}
int main(int argc, char const *argv[])
{
	ll n;
	scanf("%lld",&n);
	for(int i = 1;i <= n; ++i)
	{
		scanf("%lld",&a[i]);
		mp[a[i]]++;
	}
	ll ans = 0;
	for(int i = 1;i <= n; ++i)
	{
		ans += c(mp[i]);
	}
	for(int i = 1;i <= n; ++i)
	{
		printf("%lld\n",ans - c(mp[a[i]]) + c(mp[a[i]] - 1));
	}
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int main()
{
  int n;
  cin >> n;
  cout << pow(n, 3) << endl;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x(x % mod) {}

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }

    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }

    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
} comb(100005);

mint f(int n, int k) {
    if (n < 0) return 0;
    // nPk = nCk * k!
    mint res = comb(n, k);
    res *= comb.fact[k];
    return res;
}

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

    int ans = 0;
    if (N == M) {
        ans = ((f(N, N) * f(M, M)) * 2).x;
    } else if (abs(N - M) == 1) {
        ans = (f(N, N) * f(M, M)).x;
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    
    int x = 0;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (s[i] == 'I') {
            x++;
            ans = max(x, ans);
        } else {
            x--;
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)


ll get(ll now,ll tc,ll tn){
	ll res = now;
	ll c = now/tc;
	c = c%10LL;
	res -= c*tc;
	res += c*tn;
	return res;
}


int main(){

	queue<ll> p,dep,zero;
	ll now=0,k;
	ll f = 123456780;
	ll ten = 100000000LL;
	FOR(i,0,9){
		cin >> k;
		now += k*ten;
		if(k==0){
			zero.push(ten);
		}
		ten /= 10LL;
	}

	//cout << now << endl;
	ll minten = 1LL;
	ll maxten = 100000000LL;

	p.push(now);
	dep.push(0);
	set<ll> se;
	se.insert(now);

	while(p.size()){
		now = p.front(); p.pop();
		ll d = dep.front(); dep.pop();
		ll t = zero.front(); zero.pop();
		if(now==f){
			cout << d << endl;
			return 0;
		}
		if(t*1000<=maxten && !se.count(get(now,t*1000,t))){
			se.insert(get(now,t*1000,t));
			p.push(get(now,t*1000,t));
			dep.push(d+1);
			zero.push(t*1000);
		}
		if(t/1000>=minten && !se.count(get(now,t/1000,t))){
			se.insert(get(now,t/1000,t));
			p.push(get(now,t/1000,t));
			dep.push(d+1);
			zero.push(t/1000);
		}
		if(t*10<=maxten && t!=100 && t!=100000 && !se.count(get(now,t*10,t))){
			se.insert(get(now,t*10,t));
			p.push(get(now,t*10,t));
			dep.push(d+1);
			zero.push(t*10);
		}
		if(t/10>=minten && t!=1000 && t!=1000000&& !se.count(get(now,t/10,t))){
			se.insert(get(now,t/10,t));
			p.push(get(now,t/10,t));
			dep.push(d+1);
			zero.push(t/10);
		}
	}
}


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

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; }

using ll = long long;
using P = pair<ll,ll>;
using graph = vector<vector<int>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  string S;
  cin>>S;
  map<char,int> m;
  for(auto x:S) m[x]++;
  bool ok = true;
  if(m['N']==0&&m['S']!=0) ok = false;
  if(m['S']==0&&m['N']!=0) ok = false;
  if(m['E']==0&&m['W']!=0) ok = false;
  if(m['W']==0&&m['E']!=0) ok = false;
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	cin>>t;
	t=t%10;
	if(t==2 ||t==4 ||t==5 ||t==7 ||t==9){
		cout<<"hon\n";
	}
	else if(t==0 || t==1 ||t==6 ||t==8){
		cout<<"pon\n";
	}
	else{
		cout<<"bon\n";
	}
	return 0;
}


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

int pow10(int n){
  int ret =1;
  for (int i=0;i<n;i++)ret *=10;
  return ret;
}

int main(){
  int n,i;
  int ret,t;

  cin >>n;
  while (n!=0){
    ret =0;
    i=0;
    if (n<0){
      while (n<0){
	if (i%2==0){
	  t =n % 10+10;
	  if (t==10)t=0;
	  ret +=t*pow10(i);
	  n-=t;
        }else {
	  t =-(n % 10);
	  ret +=t*pow10(i);
	}
	n/=10;
	i++;
      }
    }else{
      while (n>0){
	if (i%2==1){
	  t =10-(n % 10);
	  if (t==10)t=0;
	  ret +=t*pow10(i);
	  n+=t;
	  n/=10;
	  i++;
	}else {
	  t =n % 10;
	  ret +=t*pow10(i);
	  n/=10;
	  i++;
	}
      }
    }
    cout<<ret<<endl;
    cin >>n;
  }
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#include <ctype.h>



int main()
{
	int  inp;
	while(1) {
		inp = getchar();

		if (inp == '\n') {
                        putchar(inp);
			break;
		}
		
		/*--??±?°???????? --*/
		if (islower(inp)!=0) {
			inp = toupper(inp);
		}
		else {
			/*--??±??§??????? --*/
			if (isupper(inp)!=0) {
				inp = tolower(inp);
			}
		}
		putchar(inp);
	}

	return 0;
}

Measured memory_bytes: 524
#include<stdio.h>
int main(void)
{
	int n,a,s,i,d,c,j,x,g,w,z,m;
	while(scanf("%d %d",&a,&s)!=EOF){
		w=a; z=s;
		if(a==0&&s==0) break;
		if(a<s){
			n=a;
			a=s;
			s=n;
		}
		while(s!=0){
			a=a%s;
			g=a;
			a=s;
			s=g;
		}
		m=(w/a)*(z/a)*a;
		printf("%d %d\n",a,m);	
	}
	return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var k int
	fmt.Scan(&k)
	var r, ans int
	m := make(map[int]bool)
	for {
		ans++
		r *= 10
		r %= k
		r += 7 % k
		r %= k
		if r == 0 {
			fmt.Println(ans)
			return
		}
		if m[r] {
			fmt.Println("-1")
			return
		}
		m[r] = true
	}
}


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


void solve(long long a){
  cout << (a + pow(a, 2) + pow(a, 3)) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
  scanf("%lld",&a);
    solve(a);
    return 0;
}


Measured memory_bytes: 4212
def getN():
    return int(input())

def getMN():
    a = input().split()
    b = [int(i) for i in a]
    return b[0],b[1]

def getlist():
    a = input().split()
    b = [int(i) for i in a]
    return b

n = input()
answer = 10000000000
for i in range(len(n)-2):
    number = 100*int(n[i]) + 10*int(n[i+1]) + int(n[i+2])
    if abs(number-753) < answer:
        answer = abs(number-753)

print(answer)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 100005
int N;
int A[MXN],B[MXN];
ll ans;

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

    cin>>N;
    FOR(i,1,N+1)cin>>A[i];
    FOR(i,1,N)cin>>B[i];

    FOR(i,1,N)
    {
        ll lf = min( A[i], B[i] );
        B[i]-=lf;
        ans+=lf;
        ll rt = min( A[i+1], B[i] );
        A[i+1]-=rt;
        ans+=rt;
    }
    cout<<ans<<'\n';

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;
LLi mod=998244353;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	LLi n, k, ans=0;
	vector<int> l, r;
	vector<LLi> dp, rdp;

	cin>> n >> k;
	l.resize(k);
	r.resize(k);
	dp.resize(n+1);
	rdp.resize(n+1);

	rep(i, k) cin >> l[i] >> r[i];

	dp[0]=0;
	dp[1]=1;
	rdp[0]=0;
	rdp[1]=1;

	for(int i=2;i<=n;i++) {
		for(int j=0;j<k;j++){
			dp[i]+=(mod+rdp[max(0, i-l[j])]-rdp[max(0, i-r[j]-1)])%mod;
		}
		dp[i]=dp[i]%mod;
		rdp[i]=(rdp[i-1]+dp[i])%mod;
		//cout<< dp[i] <<endl;
	}

	cout<< dp[n] << endl;
 
	return 0;
}

Measured memory_bytes: 6408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  int N; cin >> N;
  vector<tuple<int,int,int>> txy;
  for (int i = 0; i < N; i++) {
      int t, x, y; cin >> t >> x >> y;
      txy.push_back(make_tuple(t, x, y));
  }
  sort(txy.begin(), txy.end());

  int ct = 0, cx = 0, cy = 0;
  bool flag = true;
  for (tuple<int, int, int> T : txy) {
    int md = abs(cx - get<1>(T)) + abs(cy - get<2>(T));
    int tt = get<0>(T) - ct;
    if (tt < md) {
      flag = false;
      break;
    } else if (tt == md) {
      continue;
    } else {
      if ((tt - md) % 2 != 0) {
        flag = false;
        break;
      }
    }
    ct = get<0>(T);
    cx = get<1>(T);
    cy = get<2>(T);
  }

  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 1912
fn main() {
    let ab = read_vec::<usize>();
    let ret = if ab[0] >= 13 {
        ab[1]
    } else if 12 >= ab[0] && ab[0] >= 6 {
        ab[1] / 2
    } else {
        0
    };
    println!("{}", ret);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int S; 
  cin >> S;

  int x1, y1, x2, y2;
  x1 = (S+1000000000-1)/1000000000;
  y2 = 1000000000;
  S = x1*y2-S;

  for(int i = 1; i*i <= S; i++){
    if(S%i == 0){
      x2 = i;
      y1 = S/i;
    }
  }
  cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)

int main(void){
	int d, n;//??\??°??????????¨????
	cin >> d >> n;
	vector<int> t(d);
	rep(i, d) cin >> t[i];
	vector<int> a(n), b(n), c(n);//??????????????§????´???????
	rep(i, n) cin >> a[i] >> b[i] >> c[i];

	int dp[201][201];//dp[i][j] i(1~d)??\??????j(0~n)????????????????????????????????§???
	rep(i, 201)rep(j, 201) dp[i][j] = -1;//?????????
	//rep(j, d) dp[0][j] = 0;//?????????
	rep(j, d){
		if(a[j] <= t[0] && t[0] <= b[j]){
			dp[0][j] = 0;
		}
	}
	reps(i, 1, d){//??\
		rep(j, n){//????????????
			rep(k, n){//?????????????????¨??¢?´¢??§??¢????????????
				if(a[k] <= t[i] && t[i] <= b[k] && dp[i - 1][j] != -1){
					dp[i][k] = max(dp[i][k], dp[i - 1][j] + abs(c[k] - c[j]));
					// printf("hikizann %d\n", c[k] - c[j]);
					// printf("i %d j %d k %d dp%d\n", i, j, k, dp[i][k]);
				} 
			}
		}
	}


	int ans = 0;
	rep(i, n){
		ans = max(ans, dp[d - 1][i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,q,ans=0,a,b,c;
	cin>>n;
	map<ll,ll>m;
	while (n--)
	{
		cin>>a;
		ans+=a;
		m[a]++;
	}
	cin>>q;
	while (q--)
	{
		cin>>b>>c;
		ans+=m[b]*(c-b);
		m[c]+=m[b];
		m[b]=0;
		cout<<ans<<"\n";
	}
}

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

int main() {
  int n,m,ac,wa;
  cin>>n>>m;
  ac=0;
  wa=0;
  vector<bool>yet(n);
  vector<int>num(n);
  for(int i=0;i<n;i++) yet[i]=true;
  for(int i=0;i<m;i++){
    int p;
    string s;
    cin>>p>>s;
    if(s=="AC"){
      if(yet[p-1]){
        ac++;
        yet[p-1]=false;
      }
    }
    else{
      if(yet[p-1]) num[p-1]++;
    }
  }
  for(int i=0;i<n;i++){
    if(yet[i]==false) wa+=num[i];
  }
  cout<<ac<<" "<<wa<<endl;
}

Measured memory_bytes: 3744
#include <iostream>

using namespace std;

int main(){
    int N;
    int a[100];
    int cnt[101] = {0};
    int dist_max = 0;
    int dist_min = 1000;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> a[i];
        cnt[a[i]]++;
        dist_max = max(dist_max, a[i]);
        dist_min = min(dist_min, a[i]);
    }
    if(dist_max == 1){
        if(N != 2)cout << "Impossible" << endl;
        else cout << "Possible" << endl;
        return 0;
    }
    if(dist_min !=  (dist_max+1)/2){
        cout << "Impossible" << endl;
        return 0;
    }
    
    if(dist_max%2 == 0){
        if(cnt[dist_min] != 1){
            cout << "Impossible" << endl;
            return 0;
        }else{
            for(int i = dist_min+1; i <= dist_max; i++){
                if(cnt[i] <= 1) {
                    cout << "Impossible" << endl;
                    return 0;
                }
            }
            cout << "Possible" << endl;
            return 0;
        }
    }else{
        if(cnt[dist_min] != 2){
            cout << "Impossible" << endl;
            return 0;
        }
        for(int i = dist_min; i <= dist_max; i++){
            if(cnt[i] <= 1) {
                cout << "Impossible" << endl;
                return 0;
            }
        }
        cout << "Possible" << endl;
        return 0;
    }
}

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

using ll = long long;
using ld = long double;

int main()
{
    ll ans=0;
    string s;
    cin >> s;
    int n = s.length();
    
    for(int bit = 0; bit < (1<< (n-1)); bit++)
    {
        ll tmp = 0;
        
        for(int i = 0; i < n; i++)
        {
            if(i==n-1)
            {
                tmp = tmp*10 + s.at(i)-'0';
                ans+=tmp;
                tmp=0;
            }
            else
            {
                if((bit>>i)&1 == 1) // + ari
                {
                    tmp = tmp*10 + s.at(i)-'0';
                    ans+=tmp;
                    tmp=0;
                }
                else
                {
                    tmp = tmp*10 + s.at(i)-'0';
                }
            }
        }
        
    }
    

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
//19
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  static bool cmp[1000001]={true,true};
  for(int i=2;i<=1000000;i++){
    if(!cmp[i]){
      for(int j=2;i*j<=1000000;j++){
	cmp[i*j]=true;
      }
    }
  }
  for(int n,x;cin>>n>>x,n|x;){
    static bool ch[1000001];
    fill_n(ch,1000001,false);
    ch[0]=true;
    for(int i=0;i<n;i++){
      int p;
      cin>>p;
      for(int j=p;j<=x;j++){
	ch[j]|=ch[j-p];
      }
    }
    int ans;
    for(ans=x;ans;ans--){
      if(!cmp[ans]&&ch[ans])break;
    }
    if(ans){
      cout<<ans<<endl;
    }else{
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

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

int main() {
  int N;
  int count=0;
  cin >> N;
  vector<int> L(N);

  for(int i = 0; i < N; i++) {
    cin >> L.at(i);
  }

  sort(L.begin(), L.end());

  for(int i = 0; i < N;i++) {
    if(L.size()<3) break;
    for(int j = 1; j < L.size();j++){
      if(L.at(0)==L.at(j)) continue;
      for(int k = j+1; k < L.size(); k++){
      if(L.at(j)==L.at(k)) continue;
          if(L.at(0)+L.at(j)>L.at(k) && L.at(0)+L.at(k)>L.at(j) && L.at(j)+L.at(k)>L.at(0)) count++;
      }
    }
    L.erase(L.begin());
  }

  cout << count << endl;
}

Measured memory_bytes: 3628
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            int k = Integer.parseInt(sc.next());
            String s = sc.next();

            String ans = "";

            if(s.length() <= k){
                ans = s;
            }else{
                ans = s.substring(0, k) + "...";
            }

            System.out.println(ans);

        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

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

using LL = long long;
const int MAXN = 100100;

int N, M;
vector<int> g[MAXN];
int ans;
int dp[MAXN];
int dfs(int v) {
    if(dp[v]) return dp[v];
    for(int u=0; u<g[v].size(); u++) {
        dp[v] = max(dp[v], dfs(g[v][u])+1);
    }
    return dp[v];
}
int main() {
    scanf("%d%d", &N, &M);
    for(int i=0; i<M; i++) {
        int x, y;
        scanf("%d%d", &x, &y);
        g[x].push_back(y);
    }
    
    memset(dp, 0, sizeof(dp));
    ans = 0;
    for(int i=1; i<=N; i++) {
        ans = max(ans, dfs(i));
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 11616
#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 = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); 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(){
    int x1, x2, y1, y2; cin >> x1 >> y1 >> x2 >> y2;
    int a = x2 - x1, b = y2 - y1;
    int x3, x4, y3, y4;
    x3 = x2 - b, y3 = y2 + a,
    x4 = x3 - a, y4 = y3 - b;
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << ln;
}
    



Measured memory_bytes: 3612
//author: dazhong_feliks

#include <bits/stdc++.h>
using namespace std;

int main() {
  double N,A,B;
  cin >> N >> A >> B;
  
  if ( N < B / A )
  { cout << A * N << endl; 
  }
  
  else if ( N >= B / A )
  { cout << B << endl;
  }
}



Measured memory_bytes: 256
//
// C - Factors of Factorial
//

#include <iostream>
#include <cmath>

using namespace std;

const int MOD = 1000000007;
bool primes[1001] = {false};
int factors[1001] = {0};

bool *primeB(bool *p, int n) {

    int n_ = (int) sqrt(n) + 1;

    fill(p, p + n + 1, true);
    if (n >= 0) p[0] = false;
    if (n >= 1) p[1] = false;

    for (int i = 2; i <= n_; ++i) {
        if (p[i]) {
            for (int j = i + i; j <= n; j += i) {
                if (p[j]) p[j] = false;
            }
        }
    }

    return p;
}

int main() {

    int N;
    cin >> N;

    primeB(primes, N);

    for (int i = 1; i <= N; i++) {
        if (primes[i]) {
            for (int j = i; j <= N; j *= i) {
                factors[i] += N / j;
            }
        }
    }

    long ans = 1;

    for (int i = 0; i <= N; i++) {
        if (factors[i]) {
            ans *= factors[i] + 1;
            ans %= MOD;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256