akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::collections::HashSet;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn read_vec_char() -> Vec<char> {
    read::<String>().chars().collect()
}

fn read_mat<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_mat_char(n: usize) -> Vec<Vec<char>> {
    (0..n).map(|_| read_vec_char()).collect()
}

fn find(uf: &mut Vec<(usize,usize)>, x: usize) -> usize {
    let p = uf[x].0;
    if p != x {
        let r = find(uf, p);
        uf[x].0 = r;
    }
    uf[x].0
}

fn main() {
    let v = read_vec::<usize>();
    let (n,m) = (v[0],v[1]);
    let p: Vec<usize> = read_vec::<usize>().iter().map(|x| x-1).collect();

    let mut uf: Vec<(usize,usize)> = (0..n).map(|x| (x,0)).collect();

    for i in 0..m {
        let xy = read_vec::<usize>();
        let (x,y) = (xy[0]-1,xy[1]-1);
        let xr = find(&mut uf,x);
        let yr = find(&mut uf,y);
        if xr == yr { continue; }
        if uf[xr].1 < uf[yr].1 {
            uf[xr].0 = yr;
        } else {
            uf[yr].0 = xr;
            if uf[xr].1 == uf[yr].1 {
                uf[xr].1 += 1;
            }
        }
    }
    let mut ans = 0;
    for i in 0..n {
        if find(&mut uf, i) == find(&mut uf, p[i]) {
            ans += 1;
        }
    }
    println!("{}",ans);
}


Measured memory_bytes: 8444
// AOJ 0564: Bug Party
// 2018.1.27 bal4u

#include <stdio.h>

#define N	524288		// 2^19
int seg_i[1048576], seg_v[1048576];		// 2^20

void update(int k, int a)
{
	int k2;

	k += N;
	seg_v[k] = a, seg_i[k] = k - N;
	while (k > 0) {
		k = (k-1) >> 1, k2 = (k << 1) + 1;
		if (seg_v[k2] > seg_v[k2+1]) seg_v[k] = seg_v[k2  ], seg_i[k] = seg_i[k2  ];
		else                         seg_v[k] = seg_v[k2+1], seg_i[k] = seg_i[k2+1];
	}
}

int max_id()  { return seg_i[0]; }
int max_val() {	return seg_v[0]; }

typedef struct { int a, b; } T;
T tbl[300002], tbl2[300002];
int n;

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int f[100002];
void distsort()
{
	int i, x;

	for (i = 0; i < n; i++) f[tbl2[i].b]++;
	for (i = 100000; i > 0; i--) f[i-1] += f[i];
	for (i = 0; i < n; i++) {
		x = tbl2[i].b, tbl[--f[x]] = tbl2[i];
	}
}

int check(int k)
{
	int i;
	long long s;
	
	if (!k) return 1;
	s = 0;
	for (i = 0; i < k-1; i++) s += tbl[i].a, update(i, tbl[i].a);
	for ( ; i < n; i++) {
		if (s + tbl[i].a <= (long long)k*tbl[i].b) return 1;
		s += tbl[i].a,  update(i, tbl[i].a);
		s -= max_val(), update(max_id(), 0);
	}
	return 0;
}
	
int main()
{
	int i, lo, hi, m;
	
	n = in();
	for (i = 0; i < n; i++) tbl2[i].a = in(), tbl2[i].b = in();
	distsort();

	lo = 0, hi = n+1;
	while (lo + 1 < hi) {
		m = (lo + hi) >> 1;
		if (check(m)) lo = m; else hi = m;
	}
	printf("%d\n", lo);
	return 0;
}



Measured memory_bytes: 11560
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    cout<<(min(b,d) - max(a,c) > 0 ? min(b,d) - max(a,c) : 0)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,a,b,c,d;
    cin>>n>>a>>b>>c>>d;
    int A,B;
    if(n%a==0)  A=b*n/a;
    if(n%a!=0)  A=b*(n/a+1);
    if(n%c==0)  B=d*n/c;
    if(n%c!=0)  B=d*(n/c+1);
    if(A>B) cout<<B;
    else    cout<<A;
    cout<<endl;
}



Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

int main() {
    int n; cin >> n;
    vi vc1; vc1.resize(n);
    for (int i = 0; i < n; ++i) cin >> vc1[i];

    vi vc2 = vc1;
    sort(vc2.begin(), vc2.end());
    int mid = n / 2;

    for (int i = 0; i < n; ++i) {
        if (vc1[i] < vc2[mid]) cout << vc2[mid];
        else                   cout << vc2[mid - 1];
        cout << endl;;
    }

    return 0;
}


Measured memory_bytes: 3712
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_DEEP_MAX		100005									// 最大深さ
#define D_ICNT_MAX		20000000000000							// 最大内部ノード数

// 内部変数
static FILE *szpFpI;											// 入力
static int si1LCnt[D_DEEP_MAX];									// 葉数
static long long sl1ICnt[D_DEEP_MAX];							// 内部ノード(葉以外のノード)の最大数
static int siDeep;												// 深さ

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最小値 - 取得
long long
fGetMinL(
	long long plVal1			// <I> 値１
	, long long plVal2			// <I> 値２
)
{
	if (plVal1 < plVal2) {
		return plVal1;
	}
	else {
		return plVal2;
	}
}

// 実行メイン
long long
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// データ - 初期化

	// 深さ - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siDeep);

	// 葉数 - 取得
	for (i = 0; i <= siDeep; i++) {
		fscanf(szpFpI, "%d", &si1LCnt[i]);
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	if (siDeep == 0) {
		if (si1LCnt[0] == 1) {
			return 1;
		}
		else {
			return -1;
		}
	}

	// 内部ノードの最大数 - セット
	long long llVCnt = 1;
	for (i = 0; i < siDeep; i++) {
		sl1ICnt[i] = llVCnt - (long long)si1LCnt[i];
		if (sl1ICnt[i] < 1) {
			return -1;
		}
		llVCnt = sl1ICnt[i] * 2;
		llVCnt = fGetMinL(sl1ICnt[i] * 2, D_ICNT_MAX);
	}

	// 最大頂点数 - 取得
	llVCnt = si1LCnt[siDeep];
	long long llVSum = llVCnt;
	for (i = siDeep - 1; i >= 0; i--) {

		// 内部ノード数
		if (llVCnt > sl1ICnt[i]) {
			if (llVCnt > sl1ICnt[i] * 2) {
				return -1;
			}
			llVCnt = sl1ICnt[i];
		}

		// 頂点数 - 加算
		llVCnt += (long long)si1LCnt[i];

		// 最大頂点数 - 加算
		llVSum += llVCnt;
	}

	return llVSum;
}

// １回実行
int
fOne(
)
{
	long long llRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	llRet = fMain();

	// 出力
	sprintf(lc1Buf, "%lld\n", llRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

ll gcd(ll p,ll q){
    if(p>q)swap(p,q);
    if(p==0)return q;
    return gcd(q%p,p);
}

int main(){
    ll A,B,C,D;
    cin>>A>>B>>C>>D;
    ll E=C*D/gcd(C,D);
    ll ans=B-A+1;
    A--;
    ans-=B/C-A/C;
    ans-=B/D-A/D;
    ans+=B/E-A/E;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int R = sc.nextInt();
		if(N >= 10) {
			System.out.println(R);
		}else {
			System.out.println(R + (100 * (10 - N)));
		}
	}
}

Measured memory_bytes: 35736
def cmbn2(n):
  #n>=2
  return int(n*(n-1)/2)

N=int(input())
A=list(map(int, input().split()))
R=[0]*(N+1)
D={0:1}
for i in range(N):
  R[i+1]=R[i]+A[i]
  if R[i+1] not in D.keys():
    D[R[i+1]]=1
  else:
    D[R[i+1]]+=1
  
#m=len(set(R[1:]))
#print((N-m)*m)
#print(R[1:10],)
#print(R.count(4))

ans=0
for b in D.values():
  
  if b>=2:
    ans+=cmbn2(b)
print(ans)
#print(D.values())

Measured memory_bytes: 40152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        long N=0, C=0, K=0;
        long[] ps = null;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String[] elems = br.readLine().split(" ");
            N = Long.parseLong(elems[0]);
            C = Long.parseLong(elems[1]);
            K = Long.parseLong(elems[2]);
            ps = new long[(int)N];
            for (int i = 0; i < ps.length; i++){
                elems = br.readLine().split(" ");
                ps[i] = Long.parseLong(elems[0]);;
            }
            Arrays.sort(ps);
        } catch (IOException e) {
            e.printStackTrace();
        }
        int ans = 0;
        int count = -1;
        int bassPass = 0;
        long oldTime = ps[0];
        while (++count < N) {
            if (bassPass == C || oldTime + K < ps[count]) {
                bassPass = 0;
                ans++;
                oldTime = ps[count];
            }
            bassPass++;
        }
        if (bassPass != 0)
            ans++;
        System.out.println(ans);
    }
}



Measured memory_bytes: 36144
//no one wants to die,yet death is the destination we all share 
// don't think you are,know you are!!

#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main(){
	ll n,x,t;
	cin>>n>>x>>t;
	ll a=n/x;
	if(n%x!=0) a++;
	cout<<a*t;
}

Measured memory_bytes: 3532
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include<iostream>
 
int main() {
	int locate[5];
	for (int i = 0; i < 5; i++) {
		int N = 0;
		scanf("%d", &N);
		locate[i] = N;
	}
	int K = 0;
	scanf("%d", &K);
	if (locate[4] - locate[0] <= K) {
		std::cout << "Yay!" << std::endl;
	}
	else {
		std::cout << ":(" << std::endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
int main(void) {
  std::string s;
  std::cin >> s;
 
  int64_t count = 0;
  int64_t chokuA = 0;
 
  if (s.length() <= 2) {
    std::cout << 0 << std::endl;
    return 0;
  }
 
  for (int i = 0, end = s.length() - 1; i < end; ++i) {
    // std::cout << i << " " << count << " " << chokuA << std::endl;
    if (s[i] == 'A') {
      ++chokuA;
    } else if ((s[i + 0] == 'B') && (s[i + 1] == 'C')) {
      // ++count;
      // --chokuA;
      count += chokuA;
      s[i + 1] = 'A';
      ++i;
    } else {
      chokuA = 0;
    }
  }
 
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 640
def solve(n,a,b):
    dp=[0]*(n+1)
    for w in range(n+1): dp[w]=max(w,dp[w-a[0]]+b[0]if w-a[0]>=0 else w,dp[w-a[1]]+b[1]if w-a[1]>=0 else w,dp[w-a[2]]+b[2]if w-a[2]>=0 else w)
    return dp[-1]
N,A,B=int(input()),list(map(int, input().split())),list(map(int, input().split()))
print(solve(solve(N,A,B),B,A))

Measured memory_bytes: 228508
using System;
using System.Collections.Generic;

namespace _20200328_ABC160A
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadStringList(1);

            char[] cArray = input[0].ToCharArray();

            string output = "No";
            if (cArray[2] == cArray[3])
            {
                if (cArray[4] == cArray[5])
                {
                    output = "Yes";
                }
            }

            Console.WriteLine(output);
        }

        private static List<string> ReadStringList(int numberOfLines)
        {
            var stringList = new List<string>();

            for (int lineIndex = 0; lineIndex < numberOfLines; lineIndex++)
            {
                stringList.Add(Console.ReadLine().Trim());
            }

            return stringList;
        }

    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

#define MOD (int)(1e9+7)

int N, M;
long long n, m, ans;

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

    n = m = 1;

    if (M == N || M-1 == N || M+1 == N) {
        for (int i = N; i >= 2; i--) {
            n = (n * i) % MOD;
        }

        for (int i = M; i >= 2; i--) {
            m = (m * i) % MOD;
        }

        if (N == M) ans = n * m * 2 % MOD;
        else ans = n * m % MOD;

        printf("%lld\n", ans);
    }
    else {
        puts("0");
    }


    return 0;
}

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

using namespace std;

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

	int maxsize = 0;
	for (int i = 0; i < str.size(); i++) {
		for (int j = i; j < str.size(); j++) {
			int counter = 0;
			for (int k = i; k <= j; k++) {
				if (str[k] == 'A' || str[k] == 'C' || str[k] == 'G' || str[k] == 'T') {
					counter++;
				}
				else {
					counter = 0;
					break;
				}
			}
			if (counter > maxsize) { maxsize = counter; }

		}
	}
	cout << maxsize << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long A,B,C,K,sum=0,count=0;
    
    cin >> A >> B >> C >> K;
    
    if(A>=K){
        sum=K;
    }else if(B>=(K-A)){
        sum=A;
    }else if(C>=(K-A-B)){
        count=K-A-B;
        sum=A-count;
    }
    
    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3632
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}

void solv() {
	while (true)
	{
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0) break;

		cout << string(w, '#') << endl;
		for (size_t i = 0; i < h - 2; i++)
		{
			cout << "#";
			cout << string(w - 2, '.');
			cout << "#" << endl;
		}
		cout << string(w, '#') << endl;
		cout << endl;
	}



}


int main() {
	//	COMinit();
	solv();

	return 0;
}



Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, answer;
  cin >> n;
  answer = 0;
  vector<int> A(n);
  vector<int> B(n);
  vector<int> C(n - 1);
  for (int i = 0; i < n; i++)
    cin >> A.at(i);
  for (int i = 0; i < n; i++)
    cin >> B.at(i);
  for (int i = 0; i < n - 1; i++)
    cin >> C.at(i);//入力完了
  /*ここから加算処理*/
  for (int i = 0; i < n - 1; i++){
    answer += B.at(A.at(i) - 1);
    if(A.at(i) + 1 == A.at(i + 1))
      answer += C.at(A.at(i) - 1);
  }
  answer += B.at(A.at(n - 1) - 1);
    
  cout << answer << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  bool flag = true;
  while(flag){
    int a, b;
    cin >> a >> b;
if( a == 0 && b ==0) break;
    for(int i = 0; i<a;i++){
       for(int j = 0; j<b; j++){
        if(i%2==0 && j %2 == 0)
           cout << '#';
        else if(i%2 == 0 && j%2 != 0)
           cout << '.';
        else if(i%2 != 0 && j%2 == 0)
           cout << '.';
        else if(i%2 != 0 && j%2 != 0)
           cout << '#';
}
cout << endl;
}
cout << endl;
}
}


Measured memory_bytes: 3116
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;
struct rest {
	string name;
	int v;
	int index;
};
typedef struct rest Rest;

int myCompare(Rest r1, Rest r2) {
	if (r1.name == r2.name) {
		return r1.v > r2.v;
	}
	return r1.name < r2.name;
}


int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	vector<Rest> v;
	for (int i = 0; i < n; i++) {
		Rest r;
		r.index = i + 1;
		int t;
		string s;
		cin >> s >> t;
		r.name = s;
		r.v = t;
		v.push_back(r);
	}
	sort(v.begin(), v.end(), myCompare);
	for (int i = 0; i < n; i++) {
		cout << v[i].index << endl;
	}
}



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

int main()
{


int i;
char moji[10];

scanf("%s",moji);

for(i=0;i<4;i++)
{
 switch(i)
 {

 case 0:
   moji[0]='2';
   break;
 case 1:
 moji[1]='0';
 break;
 case 2:
 moji[2]='1';
 break;
 case 3:
 moji[3]='8';
 break;
 }

}


printf("%s",moji);

}

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

using namespace std;

int main() {
	int a, b;
    cin >> a >> b;
    int ans = a + b;
    ans = max(ans, a - b);
    ans = max(ans, a * b);
    
    cout << ans << endl;
}


Measured memory_bytes: 888
def b167(a, b, c, k):

    ans = 0

    if k >= a:
        ans += a
        if (k-a) >= b:
            ans -= (k-a-b)
    else:
        ans = k
    return ans
def main():
    a, b, c, k = map(int, input().split())
    print(b167(a, b, c, k))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
import java.io.*;
import java.util.*;

public class Main {

	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() 
        { 
            br = new BufferedReader(new
                     InputStreamReader(System.in)); 
        } 
  
        String next() 
        { 
            while (st == null || !st.hasMoreElements()) 
            { 
                try
                { 
                    st = new StringTokenizer(br.readLine()); 
                } 
                catch (IOException  e) 
                { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() 
        { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() 
        { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() 
        { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
	public static List<Integer>[] edges;
	public static long[] fac,inv;
	public static int mod = (int) (1e9+7),MAX = (int) (1e5+1);
	public static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		FastReader sc = new FastReader();
	
		int n = sc.nextInt();
		int k = sc.nextInt();
		fac = new long[MAX];
		inv = new long[MAX];
		fac[0] = 1;
		for(int i=1;i<fac.length;++i) fac[i] = (i*fac[i-1])%mod;
		inv[MAX-1]=pow(fac[MAX-1],mod-2);
		for(int i=MAX-2;i>=0;i--){
			inv[i]=(inv[i+1]*(i+1))%mod;
		}
		
		for(int i=1;i<=k;++i) {
			long ans = (ncr(n-k+1,i)*ncr(k-1,i-1))%mod;
			out.println(ans);
		}
        out.close();
		
	}
	private static long ncr(int n, int r) {
		// TODO Auto-generated method stub
		if(r > n) return 0; 
		return ((fac[n]*inv[r])%mod*inv[n-r])%mod;
	}
	private static long pow(long a, int b) {
		if(b == 0) return 1;
		long p =pow(a,b/2);
		p = (p*p)%mod;
		if((b&1) == 1) p = (a*p)%mod;
		return p;
	}
	
}


Measured memory_bytes: 23636
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
using namespace std;
using ll = long long;
int main() {
	int n, m; cin >> n >> m;
	int p[m], y[m];
	vector<vector<int>>a(n + 1);
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> y[i];
		a[p[i]].emplace_back(y[i]);
	}
	for (int i = 0; i < n; i++) {
		sort(a[i + 1].begin(), a[i + 1].end());
	}
	for (int i = 0; i < m; i++) {
		printf("%012lld\n",
		ll(p[i]) * 1000000 +
		int(lower_bound(a[p[i]].begin(), a[p[i]].end(), y[i])
			- a[p[i]].begin()) + 1);
	}
}

Measured memory_bytes: 7808
#include <iostream>
using namespace std;
#define ll  long long  

void solve(){
  ll a,b;
  scanf("%lld",&a);
  b=360;
  while(b%a != 0)
    b+=360;
  printf("%lld",b/a);

}
int main()
{
    
     int t=1; 
     // cin >> t;
     while (t--) solve();
 
     return 0;
}


Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
    ios_base::sync_with_stdio(0);    
    cin.tie(0);
    int n;
    cin>>n;
    int z=n%10;
    if(z==0 || z==1 ||z==6 || z==8)
    {
    	cout<<"pon";
    }
    else if(z==3)
    {
    	cout<<"bon";
    }
    else
    {
    	cout<<"hon";
    }
    
  }		

Measured memory_bytes: 3652
n = gets.chomp.to_i
mm = (n ** 0.5).floor
ans = Float::INFINITY
    1.upto(mm) do |i|
        amari = n % i
        if amari == 0
            kazu = n / i
             ans = [ans,kazu].min
        end
    end
    puts ans.to_s.size

Measured memory_bytes: 14720
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++) cin>>a[i];
    bool dp[k+1]={};
    dp[0]=0;
    for(int sum=0;sum<=k;sum++)
    {
        for(int j=0;j<n;j++)
        {
            if(sum-a[j]>=0) dp[sum]|=!dp[sum-a[j]];
             
        }
    }
    if(dp[k]) cout<<"First"<<endl;
    else cout<<"Second"<<endl;
}

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

int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);

    for ( int i = 0 ; i < n ; i++ ){
        cin >> s.at(i);
    }
    sort(s.begin(),s.end());
    string ans;
    for ( int i = 0 ; i < n ; i++ ){
        ans += s.at(i);
    }
    cout << ans << endl;
}

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

namespace CSharpSample01
{


    class Program
    {
        
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');

            bool[] iro =new bool[4];
            for(int i = 0; i < n; i++)
            {
                if (str[i] == "P") iro[0] = true;
                else if (str[i] == "W") iro[1] = true;
                else if (str[i] == "G") iro[2] = true;
                else iro[3] = true;
            }

            int cnt = 0;
            for(int i = 0; i < iro.Length; i++)
            {
                if (iro[i]) cnt++;
            }

            if (cnt == 3) Console.WriteLine("Three");
            else if (cnt == 4) Console.WriteLine("Four");
        }
    }
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;
const ll MOD = 1e9 + 7;

template<class T> void chmax(T& a, T b) { if(a < b) a = b; }
template<class T> void chmin(T& a, T b) { if(a > b) a = b; }

// 約数列挙
vector<long long> enum_divisors(ll N){
    vector<ll> res;
    for(ll i = 1; i * i <= N; i++){
        if(N % i == 0){
            res.push_back(i);
            if(N / i != i) res.push_back(N / i);
        }
    }
    sort(res.begin(), res.end());
    return res;
}

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

    V<ll> v = enum_divisors(m);
    ll ans = 0;
    for(int i = 0; i < (int)v.size(); i++){
        if(v[i] * n <= m) chmax(ans, v[i]);
    }
    cout << ans << endl;
}


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

#define ll long long
#define ld long double
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
//#define int long long

using namespace std;
const int INF = 2e9;
const int MB = 20;
const int MOD = 1e9 + 7;
const int maxN = 2e6;

int up[maxN], was[26][maxN], to[26][maxN];
int id = 2, root = 1;
int ans = 0;

void add(string s) {
	int now = root;
	for (int i = 0; i < s.size(); i++) {
		if (!to[s[i] - 'a'][now]) {
			up[id] = now;
			to[s[i] - 'a'][now] = id++;
		}
		if (i == s.size() - 1) {
			ans += was[s[i] - 'a'][now];
		}
		now = to[s[i] - 'a'][now];
	}

	vector<char> q(26);
	for (int i = s.size() - 1; i >= 0; i--) {
		q[s[i] - 'a'] = true;
		now = up[now];
		for (int j = 0; j < 26; j++) {
			was[j][now] += q[j];
		}
	}
}

bool cmp(const string& one, const string& two) {
	return one.size() > two.size();
}

void solve() {
	int n;
	cin >> n;
	vector<string> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		reverse(all(a[i]));
	}
	sort(all(a), cmp);
	for (auto s : a) {
		add(s);
	}
	cout << ans;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	srand(time(0));
	int t = 1;
	//int t;
	//cin >> t;
	while (t--) solve();
}

Measured memory_bytes: 211620
n=int(input())
t=[0]*n
a=[0]*n
for i in range(n):
    t[i],a[i]=map(int,input().split())
curt=t[0]
cura=a[0]
for i in range(1,n):
    if t[i]>=curt and a[i]>=cura:
        curt=t[i]
        cura=a[i]
    else:
        kt=curt//t[i]
        if curt%t[i]:
            kt+=1
        ka=cura//a[i]
        if cura%a[i]:
            ka+=1

        k=max(kt,ka)
        curt=t[i]*k
        cura=a[i]*k
print(curt+cura)



Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  int left = A + B;
  int right = C + D;
 
  if (left > right) {
    cout << "Left" << endl;
  }
  
  else if (left == right) {
    cout << "Balanced" << endl;
  }
  
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
main :: IO ()                                                                                                              
main = do                                                                                                                  
  s <- getLine                                                                                                             
  putStrLn $ reverse $ solve s []                                                                                          
                                                                                                                           
solve :: String -> String -> String                                                                                        
solve [] str = str                                                                                                         
solve (x:xs) ys                                                                                                            
  | x == '0' || x == '1' = solve xs (x:ys)                                                                                 
  | x == 'B' && not (null ys) = solve xs (drop 1 ys)                                                                       
  | x == 'B' && null ys = solve xs ys

Measured memory_bytes: 380
x1, y1, x2, y2 = map(int, input().split())
dx = x2 - x1
dy = y2 - y1
x3 = x2 - dy
y3 = y2 + dx
x4 = x3 -dx
y4 = y3 - dy
print("%d %d %d %d" % (x3, y3, x4, y4))

Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
	int s[3];
	s[0] = getchar();
	s[1] = getchar();
	s[2] = getchar();

	int i;
	int count=0;
	for (i = 0; i < 3; i++) {
		if (s[i] == '1') {
			count++;
		}
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;
     
public class Main {
    	
    private final static Scanner sc = new Scanner(System.in);
    	
    public static void main(String[] arg) {
    	String tipp = sc.next();
      	String real = sc.next();
      	int sum = 0;
      	for(int i = 0; i < 3; i++) {
        	char t = tipp.charAt(i);
          	char r = real.charAt(i);
          	if(r == t) {
              sum++;
            }
        } 
      	System.out.println(sum);
   	}
}

Measured memory_bytes: 23636
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num,init) vector<ll> name((num),(init));
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum,init); vector<vector<ll>> name((fnum),vector<ll>((snum),(init)));
#define debugP int debug_point; cin>>debug_point;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

void dfs(ll d){

}


int main(){
    ll n,m;
    cin>>n>>m;
    vec(l,n,0);
    l=getv<ll>(n);
    sort(all(l));
    ll ans=0;
    for(int i=n-1;i>n-1-m;i--){
        ans+=l[i];
    }
    op(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
typedef long long int LLI;
 
int main()
{
	LLI a, b, c, x, save, sum = 0;
	cin >> a >> b >> c >> x;
	for(int i = 0; i <= a and 500*i <= x; i++)
		for(int j = 0; j <= b and 500*i + 100*j <= x; j++)
			if( ( x - 500*i - 100*j ) / 50 <= c )
				sum++;
	cout << sum;
}

Measured memory_bytes: 3496
import sys
sys.setrecursionlimit(10 ** 7)

MOD = 10**9 + 7

def MOD_inv(a):
    b = MOD
    u = 1
    v = 0
    while b > 0:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    u = u % MOD
    if u < 0:
        u += MOD
    return u

def init_Graph(G):
    for _ in range(len(G)-1):
        a, b = map(int, input().split())
        a, b = a-1, b-1
        G[a].append(b)
        G[b].append(a)

def dfs(G, dp, t, perm, crr, pre):
    tmp = 1
    f = False
    for nxt in G[crr]:
        if nxt == pre:
            continue
        dfs(G, dp, t, perm, nxt, crr)
        t[crr] += t[nxt]
        tmp *= dp[nxt]
        f = True
    if f:
        dp[crr] = perm[t[crr]-1]
        for nxt in G[crr]:
            if nxt == pre:
                continue
            dp[crr] *= MOD_inv(perm[t[nxt]]) * dp[nxt]
            dp[crr] %= MOD
    else:
        dp[crr] = 1

def solve(G, dp, t, perm, crr, pre, mul):
    dp[crr] *= MOD_inv(perm[t[crr]-1]) * perm[len(G)-1] * mul
    dp[crr] %= MOD
    for nxt in G[crr]:
        if nxt == pre:
            continue
        crr_t = len(G)
        crr_t -= t[nxt]
        crr_dp = dp[crr]
        crr_dp *= perm[t[nxt]] * MOD_inv(perm[len(G)-1]) * perm[len(G)-t[nxt]-1] * MOD_inv(dp[nxt])
        crr_dp %= MOD
        tmp = MOD_inv(perm[crr_t]) * crr_dp % MOD
        solve(G, dp, t, perm, nxt, crr, tmp)

def main():
    n = int(input())
    G = [[] for _ in range(n)]
    init_Graph(G)
    t = [1]*n
    dp = [0]*n
    perm = [1]*(2 * 10**5 + 10)
    for i in range(2, 2 * 10**5 + 10):
        perm[i] = perm[i-1] * i % MOD
    dfs(G, dp, t, perm, 0, -1)
    solve(G, dp, t, perm, 0, -1, 1)
    for v in dp:
        print(v)

if __name__ == "__main__":
    main()

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

using namespace std;

using ll = long long;

const int MOD = 1e9 + 7;

template<typename T>
void min_self(T& a, T b)
{
    a = min(a,b);
}

template<typename T>
void max_self(T& a, T b)
{
    a = max(a,b);
}

const int Nax=1000 + 5;

char matrix[Nax][Nax];

void add_self(int& dpTo, int dtFrom)
{
    dpTo += dtFrom;
    dpTo %= MOD;
}

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    int H, W;
    scanf("%d%d",&H,&W);
    
    for(int i=0; i<H; ++i)
    {
        scanf("%s",matrix[i]);
    }

    vector<vector<int>> dp(H,vector<int>(W));
    
    dp[0][0] = 1;
    
    vector<pair<int,int>> nn = {{0,1},{1,0}};

    for(int i=0; i<H; ++i)
    {
        for(int j=0; j<W; ++j)
        {
            for(auto& n: nn)
            {
                if(i+n.first < H && j+n.second < W && matrix[i+n.first][j+n.second] == '.')
                {
                    add_self(dp[i+n.first][j+n.second],dp[i][j]);
                }
            }
        }
    }
    
    cout << dp[H-1][W-1];
    
}


Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define int long long
using namespace std;
typedef vector<int> vi;
#define y1 abacaba
#define left sefude
#define db(x) cerr << #x <<" == "<<x << endl;
#define db2(x,y) cerr<<#x <<" == "<<x<<", "<<#y<<" == "<<y<<endl;
#define db3(x,y,z) cerr << #x<<" == "<<x<<", "<<#y<<" == "<<y<<", "<<#z<<" == "<<z<<endl; 
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 3030;

int n,m;
ll val[N][N];
ll dp[N][N][4];
const ll inf = 1e18;
ll solve(int i,int j,int k){
  if(i >n || j>m)return -inf;
  ll &x = dp[i][j][k];
  if(x!=-1)return x;
  x=0;
  if(i == n and j == m){
    if(k<3)x = max(x,val[i][j]);
    return x;
  }
  if(k < 3)x = max(x,val[i][j] + solve(i,j+1,k+1));
  if(k < 3)x = max(x,val[i][j] + solve(i+1,j,0));
  x = max(x,solve(i,j+1,k));
  x = max(x,solve(i+1,j,0));
  return x;
}

int32_t main(){
  fastio;
  int k;
  cin >> n >> m >> k;
  ms(dp,-1);
  for(int i=0;i<k;i++){
    int r,c,v;
    cin >> r >> c >> v;
    val[r][c] = v;
  }
  cout << solve(1,1,0) << endl;
  // math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 361868
S = input()
origin = ['', 'K', 'I', 'H', '', 'B', '', 'R', '']
idx = [0, 4, 6, 8]
candidate = []
for state in range(1 << 4):
    tmp = origin[:]
    for i in range(4):
        if state >> i & 1:
            tmp[idx[i]] = 'A'
    candidate.append(''.join(tmp))
print("YES" if S in candidate else "NO")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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 namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n; cin >> n;
    vector<pair<lli, lli>> a(n);
    rep(i, n){
        cin >> a[i].first;
        a[i].second = i+1;
    }
    sort(all(a));
    rep(i, n){
        cout << a[i].second;
        cout << ((i == n-1) ? endl : " "); 
    }
}

Measured memory_bytes: 2432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int study = 0;

        for (int i = 0; i < M; i++) {
            study += scanner.nextInt();
        }
        scanner.close();

        System.out.println(N >= study ? N - study : -1);

    }
}

Measured memory_bytes: 46380
def main2():
    strbuf = input("");
    strbufs = strbuf.split();
    buf = [];
    for i in range(2):
        buf.append(int(strbufs[i]));
    sa = buf[1] - buf[0];
    takasa = sa * (sa + 1) / 2;
    result = takasa - buf[1];
    print(int(result));


if __name__ == '__main__':
    main2()

Measured memory_bytes: 3060
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n; cin >> n;
	
	bool f = false;
	while (n > 0) {
		if (n % 10 == 7)f = true;
		n /= 10;
	}

	if (f) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#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 FOR(i,n,m) for(int i=n;i<=(int)(m);i++)
#define RFOR(i,n,m) for(int i=(int)(n);i>=m;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI=3.14159265358979323846;
using namespace std;
vector<int> dx={1,0,-1,0};
vector<int> dy={0,1,0,-1};
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    int A,B,C,D,E,F;
    cin>>A>>B>>C>>D>>E>>F;
    A*=100;
    B*=100;
    double now=0;
    pair<int,int> ans={0,0};
    for(int a=0; A*a<=F; a++) {
        for(int b=0; A*a+B*b<=F; b++) {
            for(int c=0; A*a+B*b+C*c<=F; c++) {
                for(int d=0; A*a+B*b+C*c+D*d<=F; d++) {
                    if((A*a+B*b)/100*E<C*c+D*d) continue;
                    if(now<=(double)100*(C*c+D*d)/(A*a+B*b+C*c+D*d)) {
                        now=(double)100*(C*c+D*d)/(A*a+B*b+C*c+D*d);
                        ans={A*a+B*b+C*c+D*d,C*c+D*d};
                    }
                }
            }
        }
    }
    cout<<ans.first<<" "<<ans.second<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string s;
    cin>>s;
    int S=0,ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='T'){
            if(S==0)ans++;
            else S--;
        }
        else {
            S++;
        }
    }
    cout<<ans*2<<endl;
}


Measured memory_bytes: 640
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
inline int getintA() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}
char dn[1300000], *di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}
int N;
int A[200001];
int E[400001], ne[400001], he[200001], it[200001];
int V[200001], v;
int S[200001], s;

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

	N = getint();
	rep1(i, N) A[i] = getintA();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		E[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		E[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	V[v++] = 2000000000;
	S[s++] = 1;
	while (s) {
		int p = S[s - 1];
		if (p > 0) {
			S[s - 1] = -p;
			if (V[v - 1] < A[p]) {
				it[p] = v;
				swap(V[v++], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			else {
				it[p] = lower_bound(V, V + v, A[p]) - V;
				swap(V[it[p]], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			he[p] = -v;
		}
		else {
			s--;
			p = -p;
			V[it[p]] = A[p];
			v -= !A[p];
		}
	}

	rep1(i, N) putint(-he[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 8772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
ll N;
vector<ll> A;
vector<ll> cnt;
ll mod=1e9+7;
int main(void){
    // Your code here!
    cin>>N;
    A.resize(N);
    cnt.resize(N);
    rep(0,i,N)cin>>A[i];
    cnt[0]=3;
    ll ans=1;
    rep(0,i,N){
        if(cnt[A[i]]>0){
            ans*=cnt[A[i]];
            ans%=mod;
            --cnt[A[i]];
            ++cnt[A[i]+1];
        }else{
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1920
#include <string>
#include <iostream>
#include <vector>
 
int main(){
  std::string strN, strK;
  long long N, K;
  
  std::cin >> strN;
  std::cin >> strK;
  N = std::stol(strN);
  K = std::stol(strK);
  
  long long counter_3 = 0;
  // a > b > cを家庭
  
  // Kの倍数の数を調べる
  long long countK = 0;
  for (long long a=1; a<=N; a++){
      if (a % K == 0)
	      countK++;
  }
  
    	counter_3 += countK * countK * countK;
 
  
  countK = 0;
  if (K%2 == 0){
    for (long long a=1; a<=N; a++){
      if (a % K == K/2)
	      countK++;
    }
    
    	counter_3 += countK * countK * countK;
  }
 
  
  std::cout << counter_3 << std::flush;
}

Measured memory_bytes: 256