akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
typedef long long ll;
using namespace std;

const ll MAXN = 200000;
const ll INF = 1001001001;

ll A, B, C, D, E, F, ans1=0, ans2=0, tmp=0;
double rate=-1.0;

signed main(){
    cin >> A >> B >> C >> D >> E >> F;
    for(int i=0;100*A*i<=F;i++) {
        tmp = F-100*A*i;
        for(int j=0;100*B*j<=tmp;j++) {
            tmp = F-100*A*i-100*B*j;
            for(int l=0;l*C<=tmp;l++) {
                tmp = F-100*A*i-100*B*j-l*C;
                for(int k=0;k*D<=tmp;k++) {
                    if(E*(100*A*i+100*B*j+l*C+k*D)>=(100+E)*(l*C+k*D)) {
                        double v1 = (double)l*(double)C+(double)k*(double)D;
                        double v2 = 100.0*(double)A*(double)i+100.0*(double)B*(double)j+(double)l*(double)C+(double)k*(double)D;
                        if(rate<100.0*(double)v1/(double)v2) {
                            rate = 100.0*v1/v2;
                            ans1 = 100*A*i+100*B*j+l*C+k*D;
                            ans2 = l*C+k*D;
                        }
                    }
                }
            }
        }
    }
    cout << ans1 << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <climits>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define UMap        std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    llong power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    llong power ( llong x, llong n ) { return power( x, n, 1000000007 ); }
    llong gcd   ( llong x, llong y ) { return x % y ? gcd( y, x % y ) : y; }
    llong lcm   ( llong x, llong y ) { return ( x / gcd(x, y) * y ); }
    llong abs   ( llong n )          { return ( n < 0 ) ? -n : n; }
    template<class A, class B>inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B>inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    signed call_of_Cthulhu( signed datum ) {

        llong a, b, c, k;
        read a >> b >> c >> k;
        if ( 1 & k ) {
            echo (b - a) fin;
        }
        else {
            echo (a - b) fin;
        }

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); echo std::fixed << std::setprecision(8); int main_result = Rlyeh::call_of_Cthulhu(114514); return main_result;}


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

int main(void){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.rbegin(),a.rend());
    
    long long keep1=0, keep2=0;
    
    for(int i = 0; i < n; i++){
        int ni = i + 1;
        if(ni > n-1) continue;
        
        if(keep1 == 0 && a[ni] == a[i]) {
            keep1 = a[i];
            i++;
            continue;
        }
        if(keep2 == 0 && a[ni] == a[i]) {
            keep2 = a[i];
            break;
        }
    }
    cout  << keep1*keep2 << endl;
}

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

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

    int64_t N;
    std::cin >> N;

    std::vector<std::pair<int64_t, int64_t>> x;
    int64_t n=N;
    for(int64_t a=2; a*a <= n; ++a){
        if( n%a!=0 ){
            continue;
        }
        int64_t ex = 0;
        while (n % a == 0) {
            ++ex;
            n /= a;
        }
        x.push_back({a, ex});
    }
    if(n!=1){
        x.push_back({n, 1});
    }

    std::vector<int64_t> z;
    for(int64_t i=0; i<x.size(); i++){
        for(int64_t j=1; j<=x.at(i).second; j++){
            z.push_back(std::pow(x.at(i).first, j));
        }
    }

    int64_t ans=0;
    for(int64_t i=0; i<z.size(); i++){
        if(N%z.at(i)==0){
            N /= z.at(i);
            ans++;
        }
    }

    std::cout << ans;

    return 0;
}


Measured memory_bytes: 4052
def main():
    n, k = [int(x) for x in input().split()]
    teleporter = [int(x) - 1 for x in input().split()]
    route = []
    route_append = route.append
    seen = [False] * n
    traveled, now_i = 0, 0

    while True:
        if seen[now_i]:
            # テレポートがループしたら，ルート調査は終了する。
            break
        route_append(now_i)
        seen[now_i] = True
        now_i = teleporter[now_i]
        traveled += 1

    # 調査終了後，now_1 はループ部分の頭。ループ前にイントロがある。
    # ループ頭は何番目に尋ねるか？
    intro_length = route.index(now_i)
    loop_length = len(route) - intro_length
    if k >= intro_length:
        arriving_i = intro_length + (k - intro_length) % loop_length
    else:
        # k が イントロ内に収まる場合。ここを見落としてWA連発！
        arriving_i = k
    return route[arriving_i] + 1


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


Measured memory_bytes: 33340
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn calc_loop_len(s: usize, p: &Vec<usize>) -> usize {
    let mut pos = s;
    let mut ans: usize = 1;

    while s != p[pos] {
        ans += 1;
        pos = p[pos];
    }

    return ans;
}

fn calc_sum_score(s: usize, life: usize, c: &Vec<i64>, p: &Vec<usize>) -> i64 {
    let mut pos = s;
    let mut ans: i64 = 0;

    for _ in 0..life {
        pos = p[pos];
        ans += c[pos];
    }

    return ans;
}

fn calc_max_score(s: usize, life: usize, c: &Vec<i64>, p: &Vec<usize>) -> i64 {
    let mut pos = s;
    let mut score_list: Vec<i64> = Vec::new();
    let mut cur_score: i64 = 0;
    for _ in 0..life {
        pos = p[pos];
        cur_score += c[pos];
        score_list.push(cur_score);
    }

    return score_list.into_iter().max().unwrap();
}

fn main() {
    let line: Vec<usize> = read_as_vec();
    let (n, k) = (line[0], line[1]);
    let p: Vec<usize> = read_as_vec()
        .into_iter()
        .map(|x: usize| x - 1)
        .collect::<Vec<usize>>();
    let c: Vec<i64> = read_as_vec();

    let mut best_score: i64 = std::i64::MIN;
    for s in 0..n {
        let loop_len = calc_loop_len(s, &p);
        let loop_score = calc_sum_score(s, loop_len, &c, &p);

        if k <= loop_len || loop_score <= 0 {
            best_score = cmp::max(best_score, calc_max_score(s, cmp::min(k, loop_len), &c, &p));
            continue;
        }

        let mut final_score: i64 = 0;
        final_score += loop_score * (k / loop_len - 1) as i64;
        let rest_k = k - (k / loop_len - 1) * loop_len;
        final_score += calc_max_score(s, rest_k, &c, &p);
        best_score = cmp::max(best_score, final_score);
    }

    println!("{}", best_score);
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,data,m,h,w,x,y,xcmp,ycmp,sum=0;

string s;

vector<int> z;

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

       cin >> a >> b >> c;
       rrep(i,1,100000){
           if(a-b*i-c*(i+1)>=0){
               ans=i;
           }
       }
       Cout(ans);
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
deque<int> an;
deque<int> go(deque<int> s)
{
    int p=s.size()- 1;
    while(p>=0&&s[p]==9)
	{
        s[p]=0;
        p--;
    }
    if(p==-1)
    s.push_front(1);
    else
    s[p]++;
    while(1)
    {
        int b=-1;
        for(int i=0;i<s.size()-1;i++)
        if(abs(s[i]-s[i+1])>1)
		{
            b=i;
            break;
        }
        if(b==-1)
        break;
        if(s[b+1]>s[b])
        s[b]++;
        int sum=max(s[b]-1,0);
        for(int i=b+1;i<s.size();i++)
        {
        	s[i]=sum;
        	sum=max(sum-1,0);
		}
	}
	return s;
}
int main()
{
	int k;
    cin >>k;
    for(int i=0;i<k;i++)
    an=go(an);
    for(int i=0;i<an.size();i++)
    cout <<an[i];
    cout <<endl;;
	return 0;
}

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

#define deb(x) cerr<<"["#x<<" : "<<x<<" ]\n";

using ll = long long;
const ll MOD = 1e9+7 ;
 
ll power( ll base, ll exp ) {	
	if( exp == 0 ) {
		return 1ll ;
	}
 
	ll mid = power(base,exp/2)%MOD ;
	
	return ((mid*mid)%MOD*(( exp&1 ? base : 1 )%MOD))%MOD ;
}
 

int main()
{
	int n ;
	cin >> n ;
 
	bool parity = n%2 ;
 
	vector<int> v(n);
	map<int,int> cnt ;
	
	for( int i = 0 ; i < n ; ++i ) {
		cin >> v[i];
		cnt[v[i]]++;
		if( (v[i]&1) == parity ) {
			cout << 0;
			return 0;
		}
	}
 
	if( (parity && cnt[0] != 1) || (!parity && cnt[0]) ) {
		cout << 0;
		return 0;
	}
 
	for( int d : v ) {
		if( !d ) {
			continue;
		}
		if( cnt[d] > 2 || cnt[d] < 2 ) {
			cout << 0;
			return 0;
		}
	}
 
	cout << power(2ll,n/2);
}


Measured memory_bytes: 5788
#include<iostream>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a<b){
        cout<<"a < b"<<endl;
    }
    if(a==b){
        cout<<"a == b"<<endl;
    }
    if(a>b){
        cout<<"a > b"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3092
from sys import stdin
n, m = map(int, stdin.readline().split())
G = [-1] * n
def root(x):
    if G[x] < 0: return x
    G[x] = root(G[x])
    return G[x]
def uniteSet(x, y):
    x = root(x)
    y = root(y)
    if x == y : return
    if G[x] > G[y] : x, y = y, x
    G[y] = x
def findSet(x, y):
    return root(x) == root(y)
for i in range(0, m):
    s, t = map(int, stdin.readline().split())
    uniteSet(s, t)
q = int(stdin.readline())
for i in range(0, q):
    s, t = map(int, stdin.readline().split())
    print("yes" if findSet(s, t) else "no")

Measured memory_bytes: 9988
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    int l[N];
    for(int i=0;i<N;i++){
        cin>>l[i];
    }
    sort(l,l+N,greater<int>());
    int sum=0;
    for(int i=0;i<K;i++){
        sum+=l[i];
    }
    cout<<sum<<endl;
}

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

template<typename T>
struct BIT {
	int n;
	vector<T> d;
	BIT(int n=0) : n(n),d(n+1) {
	}
	void add(int i, T x=1) {
		for (i++; i <= n; i += i& -i) {
			d[i] += x;
		}
	}
	T sum(int i) {
		T x = 0;
		for (i++; i; i -= i& -i) {
			x += d[i];
		}
		return x;
	}
	T sum(int l, int r) {
		return sum(r-1) - sum(l-1);
	}
};

#define max_N 200010

int k;
vector<int> edges[max_N];
vector<int> color_vertex[max_N];

int in[max_N];
int out[max_N];

long comb2(int x){
	return (long) x * (x-1) / 2 + x;
}

void dfs(int v, int p = -1){
	in[v] = k++;
	for(auto x: edges[v]) {
		if(x == p) continue;
		dfs(x, v);
	}
	out[v] = k;
}

int main(){
	int n;
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		int c;
		scanf("%d", &c);
		color_vertex[c-1].push_back(i);
	}
	for(int i = 0; i < n-1; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		edges[x-1].push_back(y-1);
		edges[y-1].push_back(x-1);
	}

	long total = comb2(n);

	BIT<int> prefix(n);
	for(int i = 0; i < n; i++)
		prefix.add(i, 1);

	dfs(0);
	// 色をすべて見る
	for(int i = 0; i < n; i++) {
		long ans = total;

		sort(color_vertex[i].begin(), color_vertex[i].end(), [&](int a, int b){
			return in[a] > in[b];
		});

		vector<pair<int, int> > history;
		for(auto v: color_vertex[i]) {
			int vsub_size = 1;
			for(auto u: edges[v]) {
				if(in[u] < in[v]) continue;
				int usub_size = prefix.sum(in[u], out[u]);
				ans -= comb2(usub_size);
				vsub_size += usub_size;
			}
			prefix.add(in[v], -vsub_size);
			history.emplace_back(in[v], vsub_size);
		}
		ans -= comb2(prefix.sum(0, n));

		for(auto p: history)
			prefix.add(p.first, p.second);

		printf("%ld\n", ans);
	}
}

Measured memory_bytes: 34440
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 36
int main()
{
  int i, j, n, minj, value, a, b, flag = 0; 
  char *C[N],  *out1[N], *out2[N], *temp, str[3];
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++)
    {
      scanf("%s",str);
      C[i] =(char *)malloc(3);
      out1[i] =(char *)malloc(3);
      out2[i] =(char *)malloc(3);
      strcpy(C[i],str);
      strcpy(out1[i],str);
      strcpy(out2[i],str);
    }

  for(i = 0 ; i < n ; i++)
    {
      for(j = n - 1 ; j > i ; j--)
	{
	  if(out1[j][1] < out1[j-1][1])
	    {
	      temp = out1[j];
	      out1[j] = out1[j-1];
	      out1[j-1] = temp;
	     
	    }
	}
    }

  for(i = 0 ; i < n ; i++)
    {
      if(i == n - 1){
	printf("%s\n",out1[i]);
      } else{
	printf("%s ",out1[i]);
      }
    }
  for(i = 0 ; i < n ; i++)
    {
      for(j = i + 1 ; j < n ; j++)
	{
	  for(a = 0 ; a < n ; a++)
	    {
	      for(b = a + 1 ; b < n ; b++)
		{
		  if(C[i][1] == C[j][1] && strcmp(C[i],out1[b]) == 0 && strcmp(C[j],out1[a]) == 0)
		    {
		      flag = 1;
		    }
		}
	    }
	}
    }
  if(flag == 0){ printf("Stable\n");
  } else{ 	printf("Not stable\n");
  }
  flag = 0;
  for(i = 0 ; i < n ; i++ )
    {
      minj = i;
      for(j = i ; j < n ; j++)
	{
	  if(out2[j][1] < out2[minj][1]){
	    minj = j;
	  }
	} 
      temp = out2[i];
      out2[i] = out2[minj];
      out2[minj] = temp;
    }
  for(i = 0 ; i < n ; i++)
    {
      if(i == n - 1){
	printf("%s\n",out2[i]);
      } else{
	printf("%s ",out2[i]);
      }
    }
  for(i = 0 ; i < n ; i++)
    {
      for(j = i + 1 ; j < n ; j++)
	{
	  for(a = 0 ; a < n ; a++)
	    {
	      for(b = a + 1 ; b < n ; b++)
		{
		  if(C[i][1] == C[j][1] && strcmp(C[i],out2[b]) == 0 && strcmp(C[j],out2[a]) == 0)
		    {
		      flag = 1;
		    }
		}
	    }
	}
    }
  if(flag == 0){ printf("Stable\n");
  }else{ 	printf("Not stable\n");
  }
  return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
#define N 10000000
using namespace std ;
long long int SOD[N+1] ;
long long int NOD[N+1] ;
void generateSOD() {

   for(long long int i = 1; i <= N; i++) {

       for(long long int j = i; j <= N; j += i) {
           SOD[j] += 1;
       }
   }
}
int main()
{
    generateSOD() ;
    long long int n , sum = 0;
    cin >> n ;

    for(long long int i = 1 ; i <= n ; i++)
    {
        sum += i * SOD[i] ;
    }
    cout << sum ;

}

Measured memory_bytes: 81720
#include<iostream>

using namespace std;

int main() {
	int N;
	char Q[100];
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> Q[i];
		if (Q[i] == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}

	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
// AOJ ALDS1_3_B Queue
// 2018.4.30 bal4u
 
#include <stdio.h>
 
#define MAX_N 100002
 
typedef struct { char *p; int tm; } Q;
Q que[(MAX_N<<1)+2]; int top, end;
char name[MAX_N][20];
 
char buf[20], *p;
int in()
{
    int n = 0;
    while (*p >= '0') n = 10*n + (*p++ & 0xf);
    p++;
    return n;
}
 
int main()
{
    int  n, q, tm, i;
    Q  t;
 
    fgets(p=buf, 20, stdin);
    n = in(), q = in();
    for (i = 0; i < n; i++) {
        fgets(p=name[i], 20, stdin);
        while (*p > ' ') p++; *p++ = 0;
        que[i].p = name[i], que[i].tm = in();
    }
 
    tm = 0, top = 0, end = n;
    while (top != end) {
        t = que[top]; if (++top == MAX_N) top = 0;
        if (t.tm <= q) {
            printf("%s %d\n", t.p, tm+t.tm);
            tm += t.tm;
        } else {
            t.tm -= q;
            que[end] = t; if (++end == MAX_N) end = 0;
            tm += q;
        }
    }
    return 0;
}


Measured memory_bytes: 4220
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let a_ss = Array.init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s
let s = String.make (w + 2) '#'
let _ =
  print_endline s;
  for i = 0 to h - 1 do print_char '#'; print_string a_ss.(i); print_endline "#" done;
  print_endline s

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>

using namespace std;

struct pkt
{
    int x, y;
};

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<pkt> a(n);
    set< pair<int, int> > S;
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i].x >> a[i].y;
        S.insert(make_pair(a[i].x, a[i].y));
    }
    int odp = n;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            if (i != j)
            {
                int p = a[j].x - a[i].x;
                int q = a[j].y - a[i].y;
                int il = 0;
                for (int k = 0; k < n; ++k)
                    if (S.find(make_pair(a[k].x - p, a[k].y - q)) == S.end())
                        ++il;
                odp = min(odp, il);
            }
        }
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Stuple {
    int s; int t; int c;
    using type = tuple<int, int, int>;
    Stuple(int s, int t, int c): s(s), t(t), c(c){ }
    operator tuple<int, int, int> () const { return make_tuple(s, t, c); }
    bool operator < (const Stuple& e) const { return type(*this) < type(e); }
    ostream& operator >> (ostream& out) const { prints(type(*this)); return out; }
    // bool operator < (const Stuple& e) const { return tie(s, t, c) < tie(e.s, e.t, e.c); }
    // ostream& operator >> (ostream& out) const { prints(tie(s, t, c)); return out; }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, c;
    cin >> n >> c;
    // set<tuple<int, int, int>> stcs;
    set<Stuple> stcs;
    for(int i = 0; i < n; i++){
        int s, t, c;
        cin >> s >> t >> c;
        stcs.emplace(s, t, c);
    }
    int ans = 0;
    prints(stcs);
    while(stcs.size()){
        ans++;
        auto next = stcs;
        int time = -1, channel = -1;
        for(auto& stc : stcs){
            // if(time + (channel != get<2>(stc)) <= get<0>(stc)){
            //     time = get<1>(stc);
            //     channel = get<2>(stc);
            //     next.erase(stc);
            // }
            // get<0>(stc.data) = 1;
            // decltype(auto) a = get<0>(stc.data);
            // a = 1;
            // stc.t = 1;
            if(time + (channel != stc.c) <= stc.s){
                time = stc.t;
                channel = stc.c;
                next.erase(stc);
            }
        }
        next.swap(stcs);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 9600
#include <stdio.h>

int main(void)
{

  int x,y;
  scanf("%d %d", &x,&y);
  if(x < y)
    printf("a < b\n");
  if(x > y)
    printf("a > b\n");
  if(x == y)
    printf("a == b\n");
  return 0;
}

Measured memory_bytes: 580
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

#define INF 999999999

struct ye{
	string ge;
	long long int nu, ad;
	
	bool operator<(const ye& a) const{
		if(ad != a.ad) return ad < a.ad;
	}
};

int main(){
	long long int i, j, n ,q, x;
	ye ans;
	ye s;
	vector<ye> a;
	while(1){
		cin >> n >> q;
		if(!n) break;
		a.clear();
		for(i=0;i<n;i++){
			cin >> s.ge >> s.nu >> s.ad;
			a.push_back(s);
		}
		sort(a.begin(),a.end());
		/*for(i=0;i<a.size();i++){
			cout << a[i].ad << " ";
		}
		cout << endl;*/
		
		for(i=0;i<q;i++){
			cin >> x;
			int z = 0;
			for(j=a.size()-1;j>=0;j--){
				if(x <= a[j].ad){
					if(a[j].nu - (a[j].ad - x) > 0){
						ans.ad=x;
						ans.nu=a[j].nu - (a[j].ad - x);
						ans.ge=a[j].ge;
						z++;
					}
				}
			}
			if(z==1) cout << ans.ge << " " << ans.nu << endl;
			else cout << "Unknown" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1292
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct Edge
{
	int from,to;
	int len;
}e[1000005];
int n,m,q,MOD,edgenum,pa[300005];
bool flag[2][1000005];
int find(int x)
{
	return x==pa[x]?x:pa[x]=find(pa[x]);
}
void merge(int u,int v)
{
	u=find(u);
	v=find(v);
	pa[u]=v;
}
int main()
{
	scanf("%d%d%d%d",&n,&m,&q,&MOD);
	for(int i=0;i<=6*n;i++)pa[i]=i;
	int g=0;
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d%d",&e[i].from,&e[i].to,&e[i].len);
		g=__gcd(g,abs(e[i].len-e[1].len));
	}
	MOD=__gcd(MOD,3*g);
	if(!g)g=1;
	int z=e[1].len%MOD;
	for(int i=1;i<=m;i++)
	{
		int u=e[i].from,v=e[i].to;
		int t=e[i].len-e[1].len;
		t/=g;
		t%=3;
		if(t<0)t+=3;
		for(int x=0;x<=1;x++)
		  for(int y=0;y<=2;y++)
		    merge((u-1)*6+x*3+y,(v-1)*6+(1-x)*3+(2*y+t)%3),
		    merge((v-1)*6+x*3+y,(u-1)*6+(1-x)*3+(2*y+t)%3);
	}
	for(int i=0;i<2;i++)
	  for(int v=i?2*z%MOD:z%MOD;flag[i][v]==0;v=v*4%MOD)
		flag[i][v]=1;
	while(q--)
	{
		int u,v,l;
		scanf("%d%d%d",&u,&v,&l);
		bool ff=0;
		for(int i=0;i<=1;i++)
		  for(int j=0;j<=2;j++)
		    if(flag[i][(z+l-j*g%MOD+MOD)%MOD]&&find((v-1)*6)==find((u-1)*6+i*3+j))
		      ff=1;
		if(ff)printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

int main(){
  int N,a,b,c,d;
  //Nは入力された整数、aは1000の位、bは100の位、cは10の位、dは1の位//
  cin >> N;
  d = N % 10;
  c = N % 100 - d;
  b = N % 1000 - 10*c - d;
  a = N % 10000 - 100*b -10*c - d;
  if(a == b && a == c && a == d){
    cout << "Yes" << endl;
  }
  else if(a == b && a == c){
    cout << "Yes" << endl;
  }
  else if (b == c && c == d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}
    
  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

ll dp[51][2501];

ll f(ll N, ll b) {
	return N ? f(N / b, b) + N % b : 0;
}

int main() {
	ll N, S; cin >> N >> S;
	for (ll b = 2; b <= 400000; b++)
		if (f(N, b) == S) {
			cout << b << endl;
			return 0;
		}
	ll ans = LLONG_MAX;
	if (N == S) ans = N + 1;
	for (ll x = 1; x <= 400000; x++) {
		ll z = N - S + x;
		if (z % x) continue;
		ll b = z / x;
		if (b < 2) continue;
		if (f(N, b) == S) ans = min(ans, b);
	}
	if (ans == LLONG_MAX) ans = -1;
	cout << ans << endl;
}


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


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

    string S, T;
    cin >> S >> T;

    string ans = "";
    for (int i = 0; i < S.size(); i++) {
    	ans.push_back(S.at(i));
    	ans.push_back(T.at(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  int a, b;
  cin >> a >> b;
  if (a+b == 15)
    cout << '+' << endl;
  else if (a*b == 15)
    cout << '*' << endl;
  else
    cout << 'x' << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<bits/stdc++.h>
#pragma GCC optimize(2)
#define LOVE ios::sync_with_stdio(0)
#define Foru(i,a,b) for(int i=(a);i<=(b);++i)
#define File ifstream fin("G:\\QtCode\\data\\in.txt")
using namespace std;
//void slove(int question_num)
//{
//    while(question_num--)
//    {
//        int sum[200002]={0};
//        int n;
//        cin>>n;
//        set<int>ans;
//        int num[200002]={0};
//        for(int i=1;i<=n;i++)
//        {
//            cin>>num[i];
//            sum[i]+=sum[i-1]+num[i];
//        }
//        for(int i=2;i<n;i++)
//        {
//            set<int>temp;
//            for(int j=i;j<=n;j++)
//            {
//                temp.insert(sum[j]-sum[j-i]);
//            }
//            if(temp.count((1+i)*i/2))
//                ans.insert(i);
//        }
//        cout<<1;
//        for(int i=2;i<n;i++)
//        {
//            if(ans.count(i))
//                cout<<1;
//            else cout<<0;
//        }
//        cout<<1<<endl;

//    }
//    return;
//}
//void slove(int question_num)
//{
//    while(question_num--)
//    {
//        unsigned int n;cin>>n;
//        map<int,int,greater<int> >temp;
//        for(unsigned int i=1;i<=n;i++)
//        {
//            int kkk;cin>>kkk;
//            temp[kkk]++;
//        }
//        if(temp.size()==1)
//            cout<<0<<' '<<0<<' '<<0<<endl;
//        else
//        {
//            int medalnum=n/2;
//            int tot=0;
//            int ans[5]={0};
//            auto pos=temp.begin();
//            ans[1]=temp.begin()->second;
//            int flage=1;
//            for(;pos!=temp.end();pos++)
//            {
//                tot+=pos->second;
//                if(tot>medalnum)
//                {
//                    tot-=pos->second;
//                    break;
//                }
//            }
//            for(auto it=++temp.begin();it!=pos;it++)
//            {
//                if(ans[2]<=ans[1])
//                    ans[2]+=it->second;
//                else flage=0;
//                if(!flage)
//                {
//                    ans[3]+=it->second;
//                }
//            }
//            if(ans[3]<=ans[1])
//                cout<<0<<' '<<0<<' '<<0<<endl;
//            else
//                cout<<ans[1]<<' '<<ans[2]<<' '<<ans[3]<<endl;
//        }
//    }
//    return;
//}
void slove(int question_num)
{
    while (question_num--) {
        int n;cin>>n;
        int r=0,b=0;
        for(int i=1;i<=n;i++)
        {
            char x;cin>>x;
            if(x=='R')
                r++;
            else b++;
        }
        if(r>b) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}
int main()
{
    LOVE;
    //int n;cin>>n;
    slove(1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

int main(){
    std::ios_base::sync_with_stdio(false);

    int c[3][3];
    rep(i,3) rep(j,3) cin >> c[i][j];

    int ans_u[3];
    int ans_l[3];


    rep(n,101){
        ans_u[0] = n;
        ans_l[0] = c[0][0]-ans_u[0];
        ans_l[1] = c[1][0]-ans_u[0];
        ans_l[2] = c[2][0]-ans_u[0];
        ans_u[1] = c[0][1]-ans_l[0];
        ans_u[2] = c[0][2]-ans_l[0];

        bool ok = true;

        rep(i,3) rep(j,3){
            if(ans_l[i]+ans_u[j] != c[i][j]) ok = false;
        }

        if(ok){cout << "Yes" << endl; return 0;}
    }

    cout << "No" << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void) {
    int N, K;
    int P[1000];
    int sum = 0;

    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; i++) {
        scanf("%d", &P[i]);
    }

    for(int i = 0; i < N; i++) {
        for(int j = i + 1; j < N; j++) {
            if(P[i] > P[j]) {
                int tmp = P[i];
                P[i] = P[j];
                P[j] = tmp;
            }
        }
    }

    for(int i = 0; i < K; i++) {
        sum += P[i];
    }

    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 1712
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, n) for (int i = 1; i < (int)(n); ++i)
using namespace std;
using lint = int64_t;

constexpr int Med = 12800;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<int>> S(H, vector<int>(W, 0));
    rep(i, H) rep(j, W) {
        int A;
        cin >> A;
        S[i][j] += A;
    }
    rep(i, H) rep(j, W) {
        int B;
        cin >> B;
        S[i][j] -= B;
    }
    
    vector<vector<vector<int>>> dp(H, vector<vector<int>>(W, vector<int>(2 * Med, 0)));
    dp[0][0][S[0][0] + Med] = 1;
    dp[0][0][-S[0][0] + Med] = 1;
    rep(i, H) rep(j, W) rep(k, 2 * Med) {
        if (!dp[i][j][k]) continue;
        if (i + 1 < H) {
            dp[i + 1][j][k + S[i + 1][j]] = 1;
            dp[i + 1][j][k - S[i + 1][j]] = 1;
        }
        if (j + 1 < W) {
            dp[i][j + 1][k + S[i][j + 1]] = 1;
            dp[i][j + 1][k - S[i][j + 1]] = 1;
        }
    }
    int ans = 1000000000;
    rep(i, 2 * Med) {
        if (dp[H - 1][W - 1][i]) ans = min(ans, abs(Med - i));
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 650624
import math
def main():
    A, B = map(int, input().split())
    find = False
    price = 0
    for i in range(1, 10001):
        if math.floor(i*0.08) == A and math.floor(i*0.1) == B:
            price = i
            find = True
            break
    if find:
        print(i)
    else:
        print(-1)
if __name__ == "__main__":
    main()

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

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[100002];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] /= 2;
    }
    ll l = 1;
    for(int i = 0; i < n; i++){
        l = lcm(l, a[i]);
        if(l > m){
            cout << 0 << endl;
            return 0;
        }
    }
    for(int i = 0; i < n; i++){
        if((l / a[i]) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << ((m / l) + 1) / 2 << endl;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<vector<int>>theval(n+1,vector<int>(3,0));
    for(int i=0;i<n;i++){
        cin>>theval[i][0]>>theval[i][1]>>theval[i][2];
    }
    vector<vector<int>>dp(n+1,vector<int>(3,0));//pos last
    for(int i=0;i<n;i++){
        if(i==0){
            dp[i][0]=theval[i][0];
            dp[i][1]=theval[i][1];
            dp[i][2]=theval[i][2];
            continue;
        }
        dp[i][2]+=theval[i][2]+max(dp[i-1][0],dp[i-1][1]);
        dp[i][1]+=theval[i][1]+max(dp[i-1][0],dp[i-1][2]);
        dp[i][0]+=theval[i][0]+max(dp[i-1][1],dp[i-1][2]);
        
    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;;
}

Measured memory_bytes: 11136
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <iostream>
using namespace std;

void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B)
{

    map<int, set<int>> m;

    for (int i = 0; i < M; i++)
    {

        m[A[i]].insert(B[i]);
        m[B[i]].insert(A[i]);
    }

    int ans = 0;

    for (auto p : m)
    {
        //   cout << p.first << ":";

        int count = 0;

        for (int i : p.second)
        {
            //  cout << " " << i << " ";

            if (H[p.first - 1] <= H[i - 1])
            {
                break;
            }
            count++;
        }

        if (count == p.second.size())
        {
            // cout << "ok" << endl;
            ans++;
        }

        //   cout << endl;
    }
    //  cout << m.size() << endl;

    ans += N - m.size();

    cout << ans << endl;
}

// Generated by 1.1.6 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 N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> H(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &H[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &A[i]);
        scanf("%lld", &B[i]);
    }
    solve(N, M, std::move(H), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 23068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n, m;
    cin >> n >> m;
    vector<PII> a(n);
    REP(i, n) cin >> a[i].first >> a[i].second;
    a.push_back({INF, 0});
    sort(ALL(a));

    // XOR差分取っておくと2点に対する更新
    vector<ll> x(n+1);
    REP(i, n+1) x[i] = a[i].second ^ (i==0 ? 0 : a[i-1].second);

    vector<vector<PII>> g(n+1);
    REP(i, m) {
        ll l0, r0;
        cin >> l0 >> r0;
        // [l[i], r[i]) の爆弾に作用する
        ll l = lower_bound(ALL(a), PII(l0, 0)) - a.begin();
        ll r = upper_bound(ALL(a), PII(r0, 1)) - a.begin();
        if(l < r) {
            g[l].emplace_back(r, i);
            g[r].emplace_back(l, i);
        }
    }

    vector<ll> ans;
    vector<bool> used(n);
    function<ll(ll,ll)> dfs = [&](ll v, ll p) {
        used[v] = true;
        ll ret = x[v];
        for(auto to: g[v]) {
            if(to.first != p && !used[to.first]) {
                ll val = dfs(to.first, v);
                if(val%2) {
                    // (v,to.first) は使用する
                    ans.push_back(to.second);
                    ret ^= 1;
                }
            }   
        }
        return ret;
    };
    bool ok = true;
    REP(i, n) if(!used[i] && dfs(i, -1)==1) ok = false;
    
    if(!ok) cout << -1 << endl;
    else {
        sort(ALL(ans));
        cout << ans.size() << "\n";
        REP(i, ans.size()) cout << ans[i]+1 << (i+1==ans.size() ? '\n' : ' ');
        cout << flush;
    }

    return 0;
}

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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

signed main () {
  cin.tie(0);
  cout << setprecision(10);
  int n, h; cin >> n >> h;
  vector<int> a(n), b(n);
  REP(i, n) {
    cin >> a[i] >> b[i];
  }

  sort(a.begin(), a.end(), greater<int>());
  sort(b.begin(), b.end(), greater<int>());
  int count = 0;
  REP(i, n) {
    if(b[i] > a[0]) {
      count++;
      h -= b[i];
    } else {
      break;
    }
    if(h <= 0) break;
  }

  if(h > 0) count += h / a[0] + ((h % a[0] == 0) ? 0 : 1);
  cout << count << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C;
    cin >> A >> B >> C;
    if(A+B>=C) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
p = [int(_) for _ in input().split()]

# p = [9, 6, 3, 2, 5, 8, 7, 4, 1]
# n = len(p)

ans = 0
for i in range(1, n-1):
    if (p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]):
        ans += 1

print(ans)

Measured memory_bytes: 3060
from math import sqrt
Number_of_data, Distance = map(int,input().split())
data = [list(map(int,input().split())) for i in range(Number_of_data)]
counter = 0

for i in data:
    if sqrt((i[0]**2)+i[1]**2) <= Distance:
        counter += 1
print(counter)


Measured memory_bytes: 45444
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  string s;
  cin >> s;

  int minv = INF;
  rep(i,sz(s) - 2)
  {
    string ss = s.substr(i, 3);
    minv = min(minv, abs(stoi(ss) - 753));
  }

  cout << minv << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

ll f(ll x) {
    return (x%2 == 0) ? x/2 : x*3+1;
}

int main(void){
    ll cur;
    cin >> cur;
    map<ll, int> mp;
    mp[cur] = 1;
    int i = 1;
    while(true){
        i++;
        ll nxt = f(cur);
        if (mp[nxt]) {
            cout << i << endl;
            return 0;
        }
        mp[nxt] = i;
        cur = nxt;
    }

    return 0;
}


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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int K;
	
	cin>>K;
	
	for(int i = 0; i < K; i++){
		cout<<"ACL";
	}
	cout<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
  while( 1 ) {
    int n;
    bool state = false;
    bool lstate = false;
    bool rstate = false;
    int counter = 0;
    cin >> n;
    if( !n ) {
      break;
    }
    for( int i = 0; i < n; i++ ) {
      string s;
      cin >> s;
      if( s[ 0 ] == 'l' ) {
        if( s[ 1 ] == 'u' ) {
          lstate = true;
          if( !state && rstate ) {
            counter++;
            state = true;
          }
        } else {
          lstate = false;
          if( state && !rstate ) {
            counter++;
            state = false;
          }
        }
      } else { // r
        if( s[ 1 ] == 'u' ) {
          rstate = true;
          if( !state && lstate ) {
            counter++;
            state = true;
          }
        } else {
          rstate = false;
          if( state && !lstate ) {
            counter++;
            state = false;
          }
        }
      }
    }
    cout << counter << endl;
  }

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    if a.iter().any(|&x| x == 0) {
        println!("0");
    } else {
        let mut res = 1i64;
        for a in a {
            res = res.saturating_mul(a);
            if res > 1_000_000_000_000_000_000 {
                println!("-1");
                return;
            }
        }
        println!("{}", res);
    }
}


Measured memory_bytes: 4540
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b){if(a < b){ a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b){if(a > b){ a = b; return 1;} return 0;}

const ll INF = 1000000000;
const int MAX_N = 1000;

int main(){
    int x[3];
    for(int i = 0; i < 3; i++){
        cin >> x[i];
    }

    sort(x, x+3);

    if(x[0] == x[1] && x[0] != x[2]){
        cout << "Yes" << endl;
        return 0;
    }

    if(x[1] == x[2] && x[0] != x[1]){
        cout << "Yes" << endl;
        return 0;
    }
    
    cout << "No" << endl;

    


    return 0;
}


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

using namespace std;

char to_upper(char c) {
  return c + 'A' - 'a';
}

#define N 3

int main()
{
  string s;
  for (int ii=0; ii<N; ++ii) {
    cin >> s;
    cout << to_upper(s[0]);
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mp make_pair
#define pb push_back
#define ldb long double
#define mt meke_tuple
template<typename T> bool ckmn(T &a, T b){ T c=a;a=min(a,b);return a!=c;}
template<typename T> bool ckmx(T &a, T b){ T c=a;a=max(a,b);return a!=c;}
const int N=200050;
char s[N];
int main()
{
	int n,a,b,c,d;
	scanf("%i %i %i %i %i",&n,&a,&b,&c,&d);
	scanf("%s",s+1);
	bool ok1=1,ok2=1,ok3=0;
	for(int i=a;i<c;i++) if(s[i]=='#' && s[i+1]=='#') ok1=0;
	for(int i=b;i<d;i++) if(s[i]=='#' && s[i+1]=='#') ok2=0;
	for(int i=b;i<=d;i++) if(s[i-1]=='.' && s[i]=='.' && s[i+1]=='.') ok3=1;
	if(c<d)
	{
		if(ok1 && ok2) printf("Yes\n");
		else printf("No\n");
	}
	else
	{
		if(ok1 && ok2 && ok3) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<string.h>
#include<set>
#include<algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

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

    int c[b*2+5];
    rep(i,b*2)cin>>c[i];

    int d[a+5]={0};
    rep(i,b*2)++d[c[i]];

    rep(i,a)cout<<d[i+1]<<endl;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    string s; cin >> s;
    ll n = s.size();

    vl dp(2);
    dp[0] = 0;
    dp[1] = INFL;
    rep(i,n){
        ll c = s[i] - '0';
        ll x = min(dp[0] + c, dp[1] + c);
        ll y = min(dp[0] + 1 + 10 - c, dp[1] + 10 - c - 1);
        dp[0] = x;
        dp[1] = y;
    }
    cout << min(dp[0], dp[1]) << endl;
    return 0;
}

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

const int maxv = 100 + 15;
char maze[maxv][maxv];
struct po{
	int x, y;
};
stack<po> nxt;
int r, c, ans;
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
bool judge(int x, int y){
	return (x>=1)&&(x<=r)&&(y>=1)&&(y<=c);
}
void dfs(po ori, char ch){
	nxt.push(ori);
	maze[ori.x][ori.y] = '0';
	while(!nxt.empty()){
		po tem = nxt.top();
		nxt.pop();
		for(int i = 0; i < 4; i++){
			po now=po{tem.x+dx[i],tem.y+dy[i]};
			if(judge(now.x,now.y)&&maze[now.x][now.y]==ch)
			maze[now.x][now.y]='0',nxt.push(now);
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	while(cin >> r >> c, (r|| c)){
		for(int i = 1; i <= r; i++)
		for(int j = 1; j <= c; j++) cin >> maze[i][j];
		ans = 0;
		for(int p = 1; p <= r; p++)
		for(int q = 1; q <= c; q++) if(maze[p][q] != '0')
		ans++, dfs(po{p, q}, maze[p][q]);
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 3100