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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define 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 SORT(c) sort((c).begin(),(c).end())

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

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

//main code

int main(int argc, char const* argv[])
{
	VL a(3);
	for (int i = 0; i < 3; i++) {
		cin >> a[i];
	}
	SORT(a);
	cout << a[0] * a[1] / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;


int main(void) {
	int N;
	long long A, B;
	cin >> N >> A >> B;
	long long ans = 0;
	long long pos, nextpos;
	cin >> pos;
	for (int i = 2; i <= N; i++) {
		cin >> nextpos;
		ans += std::min(A*(nextpos-pos), B);
		pos = nextpos;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

typedef struct {
  vector<pair<uint32_t, uint32_t>> Node;
} TreeType;

int main() {
  string S;
  cin >> S;
  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  } else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int X,Y;
    cin>>X>>Y;
    int ans=0;
    ans+=max(0,400000-100000*X);
    ans+=max(0,400000-100000*Y);
    if(X==1 && Y==1){ans+=400000;}
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
const int mod = 1000000007;
const int max_n = 200005;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    string s,t;cin >> s >>t;
    ll a,b;cin >>a >>b;
    string u;cin >> u;
    if(u==s)cout << a-1 <<" " <<b <<endl;
    if(u==t)cout << a <<" " <<b-1 <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main(){

  int N;
  cin >> N;

  vector<int> B(N);
  for(int i = 0; i < N-1; i++){
    int a;
    cin >> a;
    B[a - 1]++;
  }

  for(int i = 0; i < N;i++){
    cout << B[i] << "\n";
  }
  
  return 0;

}


Measured memory_bytes: 4044
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
struct edge {int to; ll cost;};
typedef pair<ll, int> pli;
int main(){
    int n; cin >> n;
    vector<vector<edge>> g(n);
    vector<ll> dist(n, 1e18);
    rep(i,n-1){
        int a,b; ll c; cin >> a >> b >> c; a--; b--;
        g[a].push_back((edge){b, c});
        g[b].push_back((edge){a, c});
    }
    int q, k; cin >> q >> k; k--;

    priority_queue<pli, vector<pli>, greater<pli>> que;
    dist[k] = 0;
    que.push(pli(0, k));

    while(!que.empty()){
        pli p = que.top(); que.pop();
        int v = p.second;
        if(dist[v] < p.first) continue;
        rep(i, (int)g[v].size()){
            edge e = g[v][i];
            if(dist[e.to] > dist[v] + e.cost){
                dist[e.to] = dist[v] + e.cost;
                que.push(pli(dist[e.to], e.to));
            }
        }
    }
    rep(i,q){
        int x, y; cin >> x >> y; x--; y--;
        cout << dist[x] + dist[y] << endl;
    }
}

Measured memory_bytes: 11120
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int bits[1000][1000] = {};
int main() {
	int n;
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		REP(q, n) {
			if (s[q] == '#') bits[i][q] = 1;
		}
	}
	for (int i = 0;i < n;++i) {
		for (int q = 0;q < n;++q) {
			if (bits[i][q] == 1) goto nywa;
		}
	}
	cout << -1 << endl;
	return 0;
nywa:;
	//ある1行をすべて真っ黒にすることだけを考えよう
	long long ans = 100000000;
	long long plus = n;
	for (int j = 0;j < n;++j) {
		for (int t = 0;t < n;++t) {
			if (bits[t][j] == 0) goto foo;
		}
		plus--;
	foo:;
	}
	for (int i = 0;i < n;++i) {
		long long temporary_ans = 0;
		int nya = 0;
		for (int j = 0;j < n;++j) {
			if (bits[j][i] == true) nya++;
		}
		if (nya == 0) temporary_ans++;
		for (int q = 0;q < n;++q) {
			if (bits[i][q] == 0) {
				temporary_ans++;
			}
		}
		ans = min(ans, temporary_ans + plus);
	}
	if (ans == 100000000) {
		cout << -1 << endl;
	}
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b,c; cin >> a >> b >> c;
	if(a+b<c){
		cout << "NA" << endl;
		return 0;
	}
	cout << max(0,c-a) << endl;
}



Measured memory_bytes: 3192
#include<stdio.h>

int main(){
	int n, a[100], i, target, mid, max, min, p, t = 0;
	while (1){
		scanf("%d",&n);
		if (n == 0) break;
		p = n;
		max = n - 1;
		min = 0;
		for (i = 0; i < n; i++){
			scanf("%d",&a[i]);
		}
		scanf("%d",&target);
		mid = (min + max) / 2;

		while (1){
			t++;
			if (a[mid] == target){
				break;
			}
			if (a[mid] < target){
				min = mid + 1;
				mid = (min + max) / 2;
			}
			else if (a[mid] > target){
				max = mid - 1;
				mid = (min + max) / 2;
			}
			if (min > max)break;
		}
		printf("%d\n",t);
		t = 0;
	}

	return 0;
}

Measured memory_bytes: 600
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  vector<vector<int>> v(100100);
  rep(i, m) {
    cin >> p[i] >> y[i];
    v[p[i]].push_back(y[i]);
  }
  rep(i, n + 1) sort(v[i].begin(), v[i].end());
  rep(i, m) {
    int pref = p[i];
    int year = y[i];
    int rank = lower_bound(v[pref].begin(), v[pref].end(), year) - v[pref].begin() + 1;
    printf("%06d%06d\n", pref, rank);
  }
}


Measured memory_bytes: 7808
N = int(input())
T, A = map(int, input().split())
H = [int(c) for c in input().split()]

temps = [T - h * 0.006 for h in H]
diff_min = float('inf')
ans = 0
for i in range(N):
    new_diff = abs(A - temps[i])
    if new_diff < diff_min:
        diff_min = new_diff
        ans = i + 1
print(ans)


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

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 105
int n,k;
char s[maxn],t[maxn];

int main(){
  scanf("%s",s + 1);
  n = strlen(s + 1);
  scanf("%d",&k);
  memcpy(t,s,sizeof(s));
  ll ans = 0;
  bool same = true;
  for(int i = 2;i <= n;i++) if(s[i] != s[i - 1]) same = false;
  for(int i = 2;i <= n;i++){
    if(s[i] == s[i - 1]){
      s[i] = '$';
      ans++;
    }
  }
  if(s[1] != s[n] || k == 1) printf("%lld\n",ans * k);
  else{
    if(same) printf("%lld\n",(ll)n * k / 2);
    else{
      ll tmp = 1;
      for(int i = 3;i <= n;i++){
        if(t[i] == t[i - 1]){
          t[i] = '$';
          tmp++;
        }
      }
      printf("%lld\n",tmp * (k - 1) + ans);
    }
  }
  return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, i321) => {
        read_value!($next, i32) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: i32, m: i32, ... }
//
// # array
// input! { n: i32, v: [i32; n], }
//
// # matrix
// input! { n: i32, m: i32, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: i32,
//     w: i32,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: i32, b: i32, c: i32,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input!{
        s: chars
    }
    let mut s = s.clone();
    s.sort();
    let s: String = s.into_iter().collect();
    if s == "abc" { println!("Yes"); } else { println!("No"); }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int g[10];
int a,b,c;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>a>>b>>c;

g[a]++;
g[b]++;
g[c]++;

if(g[5]==2&&g[7]==1){
	cout<<"YES"<<endl;
}else{
	cout<<"NO"<<endl;
}

}



Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};

const MOD: u64 = 1_000_000_007;

fn main() {
    proconio::input! {
        s: usize
    }
    let mut dp: Vec<Vec<u64>> = vec![vec![0; s + 1]; s / 3 + 2];

    dp[0][0] = 1;
    for i in 1..dp.len() {
        let mut sum = 0;
        for j in 3..dp[i].len() {
            sum += dp[i-1][j-3];
            sum %= MOD;
            dp[i][j] = sum;
        }
    }

    let mut ans = 0;
    for i in 1..dp.len() {
        ans += dp[i][s];
    }
    print!("{}", ans % MOD);
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

bool is_valid_ym(int y, int m) {return 0<=y&&y<=99&&1<=m&&m<=12;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    string S; cin >>S;

    int fi = stoi(S.substr(0,2));   
    int se = stoi(S.substr(2,2));   
    //cout << FMT2(fi,se) << endl;

    string ans;
    if (is_valid_ym(fi,se)) {
        if (is_valid_ym(se,fi)) {
            ans = "AMBIGUOUS";
        } else {
            ans = "YYMM";
        }
    } else if (is_valid_ym(se,fi)) {
        ans = "MMYY";
    } else {
        ans = "NA";
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <list>
#include <math.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  
  ll max = sqrt(N);
  
  ll sum = -1;
  for(ll i = 1; i <= max; i++) {
    if (N % i == 0) {
       if(sum == -1 || (sum > (i+N/i))) {
         sum = (i-1) + (N / i-1);
       }
    }
  }
  
  cout << sum;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/rope>
#define ll long long
#define ld long double
#define ull unsigned long long
#define sc(x) scanf("%d",&x)
using namespace std;
using namespace __gnu_cxx;
const int N = 1e7 + 5;
const int mod = 998244353;
const ld pi = acos(-1.0);
int t,n,m,l,r,x,Case;
string s;
void run(){
//    cin>>n>>x>>t;
//    cout<<((n+x-1)/x)*t;
    cin>>s;
    n=s.size();
    int ans=0;
    for(int i=0;i<n;i++)ans=(ans+s[i]-'0')%9;
    if(ans)cout<<"No\n";
    else cout<<"Yes\n";
}
int main(){
#ifdef haosao
freopen("main.h", "r", stdin);
//freopen("out.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
//    while()
        run();
    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <vector>
#include <sstream>
#include <bitset>

using namespace std;

typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef pair<int, int> P;

int main() {
    int p,q,r;

    cin >> p >> q >> r;
    vector<int> v;

    v.PB(p);
    v.PB(q);
    v.PB(r);

    sort(ALL(v));
    int sum = v[0] + v[1];

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int N,i,j,UNKO;
	int a[1000];
	int max=0;
	int min=1001;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}
	for(j=0;j<N;j++){
		if(max<=a[j]){
			max=a[j];
		}
		if(min>a[j]){
			min=a[j];
		}
	}
	UNKO=max-min;
	printf("%d",UNKO);

	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
//#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
//#include<list>
#include<queue>
#include<deque>
#include<algorithm>
//#include<numeric>
#include<utility>
//#include<memory>
#include<functional>
#include<cassert>
#include<set>
#include<stack>
#include<random>

const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

pii same[15][15];
char ans[200], tmp[200];
int asize = 0;

// s < t ????????????
bool comp(const char*s, int ssize, const char* t, int tsize) {
	if (ssize < tsize) return true;
	if (ssize > tsize) return false;
	for (int i = 0; i < ssize; i++) {
		if (s[i] < t[i]) return true;
		if (s[i] > t[i]) return false;
	}
	return true;
}

int main() {
    int N;
    while (cin >> N) {
    	if (N==0) break;
    	vector<string> ss(N);
    	for (int i = 0; i < N; i++)
    		cin >> ss[i];
    	for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
    		int sz = min(ss[i].size(), ss[j].size());
    		int maxi = 0;
    		for (int k = 1; k <= sz; k++) {
    			if (ss[i].substr(ss[i].size()-k, k) == ss[j].substr(0, k)) maxi = k;
    		}
    		same[i][j] = pii(maxi, j);
    		for (int k = 0; k < ss[i].size(); k++) {
    			if (ss[i].substr(k, ss[j].size()) == ss[j]) same[i][j] = pii(ss[j].size(), i);
    		}
    	}
    	vector<int> perm(N);
    	for (int i = 0; i < N; i++) 
    		perm[i] = i;
    	bool first = true;
    	do {
    		int sz = 0;
    		for (int i = 0; i < ss[perm[0]].size(); i++) 
    			tmp[i] = ss[perm[0]][i];
    		sz = ss[perm[0]].size();
    		int now = perm[0];
    		for (int i = 0; i < N-1; i++) {
    			int next = perm[i+1];
    			pii p = same[now][next];
    			int len = p.first;
    			for (int j = len; j < ss[next].size(); j++)
    				tmp[sz++] = ss[next][j];
    			now = p.second;
    		}
    		if (first || !comp(ans, asize, tmp, sz)) {
    			asize = sz;
    			for (int i = 0; i < sz; i++)
    				ans[i] = tmp[i];
    		}
    		first = false;
    	} while (next_permutation(perm.begin(), perm.end()));
    	for (int i = 0; i < asize; i++)
    		printf("%c", ans[i]);
    	printf("\n");
    }
    return 0;
}

Measured memory_bytes: 3132
import bisect
n = int(input())
*L, = map(int, input().split())
# n = 4
# L = [3, 4, 2, 1]
# n = 7
# L = [218, 786, 704, 233, 645, 728, 389]
L.sort()
c = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        c += bisect.bisect_left(L, L[i]+L[j])-(j+1)
print(c)


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

int main(){
  int n;
  string s;
  cin >> n >> s;
  
  int k=0;
  
  for(int i=0;i<n-2;i++){
    if(s.at(i)=='A'&&s.at(i+1)=='B'&&s.at(i+2)=='C')
      k++;
  }
  cout << k << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.List

main = do
  getLine
  input <- reverse . concat . filter ((> 1) . length) . group . sort <$> getIntListBC
  if length input < 4 then print 0
                      else let (x:y:z:w:ws) = input
                               a = if z == w then z else w
                           in print $ x * a

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

ll A[100100];
int H[50];
int main(){
    ll N, K;
    cin >> N >> K;
    REP(i, N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    int keta = 0;
    ll tmpK = K;
    while(tmpK > 0){
        tmpK /= 2;
        keta++;
    }

    for(int k = 0; k < 50; k++){
        int hbit = 0;
        for(int i = 0; i < N; i++){
            ll a = A[i];
            int bit = (a >> k) & 1;
            hbit += bit;
        }
        H[k] = hbit;
    }

    ll X = 0;
    for(int k = keta-1; k >= 0; k--){
        if(X + (1LL << k) > K) continue;
        if(H[k] <= N/2){
            X += (1LL << k);
        }
        else{
            continue; 
        }
    }
    //cout << X << endl;

    ll ans = 0;
    for(int i = 0; i < N; i++){
        ans += X ^ A[i];
    }

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


Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;
int n, w[310], R[101000], RC;
void Rotate(int K){
	R[RC++] = K;
	for (int i = K; i < n; i++)swap(w[i - K], w[i]);
}
int main() {
	int i, j;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &w[i]);
	}
	for (i = 1; i < n; i++) {
		for (j = 0; j < n - i; j++) {
			if (w[0] < w[n - 1]) Rotate(n-1);
			Rotate(1);
		}
		for (j = 0; j < i - 1; j++)Rotate(1);
		if (i != n - 1)Rotate(1);
	}
	printf("%d\n", RC);
	for (i = 0; i < RC; i++)printf("%d\n", R[i]);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<pii> v;
    REP(i,n) {
        int x, y;
        cin >> x >> y;
        v.push_back(make_pair(x,y));
    }
    int fact = 1;
    FOR(i,2,n+1) fact *= i;
    double distsum = 0;

    vector<int> p(n);
    iota(ALL(p),0);

    do {
        FOR(i,1,n) {
            distsum += sqrt(pow(abs(v[p[i]].first - v[p[i-1]].first),2) + pow(abs(v[p[i]].second - v[p[i-1]].second),2));
        }
    } while (next_permutation(ALL(p)));
    double ans = distsum / fact;

    cout << fixed << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
vector<int> dx = {-1, -1, -1, 0, 0, 1, 1, 1};
vector<int> dy = {-1, 0, 1, -1, 1, -1, 0, 1};

int main () {
    int x, y; cin >> x >> y;
    bool flag = false;
    rep(i, 200) rep(j, 200) {
        if (i*2 + j*4 == y && i+j == x) flag = true;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define N 100005
#define LL long long
using namespace std;

LL read(){
	char c=getchar();
	LL t=0,f=1;
	while(c>'9'||c<'0') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') t=t*10+c-'0',c=getchar();
	return t*f;
}

int n,op[N],st;
LL sum[N],absum[N]; 
char ch[2];

int main(){
	n=read(),sum[1]=absum[1]=read(),st=op[1]=1;
	for(int i=2,x;i<=n;i++){
		scanf("%s",ch),op[i]=(ch[0]=='-')?-1:1;
		x=read(),sum[i]=sum[i-1]+x*op[i],absum[i]=absum[i-1]+x;
	}
	LL ans=sum[n];
	while(op[st]>0) st++;
	for(int i=st,j=st+1;i<=n;i=j,j++){
		if(op[i]>0) continue;
		LL tmp=sum[i-1];
		while(op[j]>0&&j<=n) j++;
		tmp+=(absum[n]-absum[j-1])-(absum[j-1]-absum[i-1]);
		ans=max(ans,tmp);
	}
	printf("%lld\n",ans);
}
/*
3
5 - 1 - 3
5
1 - 20 - 13 + 14 - 5
6
3 - 5 + 1 + 6 - 11 - 13
*/

Measured memory_bytes: 2176
eval'A,B,*C=#'+`tr ' ' ,`
z=x=0
C.map{x^=_1}
999.times{45.downto(0){|i|x[i]!=(A^B)[i]&&(z+=t=[A[0,i]+1,2**i-B[0,i]].min
A-=t
B+=t)}}
p A>0?z:-1

Measured memory_bytes: 14880
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
#include <map>
using namespace std;
int main(){
	int x, y, z;
	y <= 100, x >= 1;
	if (y % 2 == 0);{
	scanf("%d %d" ,&x, &y);
	z = x + (y/2);
	printf("%d" ,z);
	} 
		return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[100001];
        long instance=0;
        for (int i=0;i<n;i++){
            int b = sc.nextInt();
            instance+=b;
            a[b]++;
        }
        int q = sc.nextInt();
        long[] ans = new long[q];
        for (int i=0;i<q;i++){
            int b = sc.nextInt();
            int c = sc.nextInt();
            instance+=((long)(c-b))*a[b];
            a[c]+=a[b];
            a[b]=0;
            ans[i]=instance;
        }
        for (int i=0;i<q;i++)System.out.println(ans[i]);
    }
}


Measured memory_bytes: 60452
#include <stdio.h>
int main(void){
    int a,i,b,c;
    scanf("%d",&a);
    int ans,max=0;
    for(i=0;i<a;i++){
        scanf("%d %d",&b,&c);
        if(max<b){
            max=b;
            ans=b+c;
        }
    }
    printf("%d",ans);
}

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

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

/*#include <ext/pb_ds/assoc_container.hpp>   // Policy_based_Data_Structure 
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define fbo find_by_order
#define ook order_of_key*/


#define ll long long int
#define bigint int64_t
#define pll pair<ll, ll>
#define vll vector<ll>
#define vpll vector<pll>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf push_front
#define ins insert
#define mp make_pair
#define MOD 1000000007
#define w(t) cin >> t;while(t--)
#define bitcount __builtin_popcount
#define endl "\n"
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define deb(x) cout << #x << " " << x << endl;
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(ll i = a; i <= b; i++)
#define ffo(i, a, b) for(ll i = a; i >= b; i--)
#define ffi(i,a,b,c) for(ll i = a ; i <= b ; i += c)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}
set < ll > s;
ll a[100005];
void sieve(){
  ll i, j;
  for(i = 2; i*i <= 100005; i++){
    if(!a[i]){
      for(j = 2*i; j < 100005; j += i){
        a[j] = 1;
      }
    }
  }
  fo(i, 2, 100004){
    if(!a[i]){
      s.ins(i);
    }
  }
}

int main(){
    IOS;
    //io_set();
    sieve();
    ll n;
    cin >> n;
    cout << *s.lob(n) << endl;
    return 0;
} 

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

int MAX_PRICE = 100 / 0.08;

int main()
{
  int A, B;
  cin >> A >> B;
  int ans = -1;
  for (int i = 1; i <= MAX_PRICE; i++)
  {
    if (floor(i * 0.08) == A && floor(i * 0.10) == B)
    {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cctype>
#include <cstdio>
#include <cstring>
#include <algorithm>

inline int read() {
    char c; int x; for (c = getchar(); !isdigit(c); c = getchar());
    for (x = 0; isdigit(c); c = getchar()) { x = x * 10 + c - '0'; } return x;
}

const int N = 4e5 + 5, E = 1e7 + 5;

int n, _n, m, rt, p, a[N], siz[N], ss[N], anc[N];
long long ans, dis[N];
bool vis[N];

struct Edge {
    int u, v;
    long long w;
} edg[E];

bool operator <(const Edge &i, const Edge &j) {
    return i.w < j.w;
}

struct List {
    int tot, fst[N], nxt[N], to[N], val[N];

    List() { memset(fst, -1, sizeof(fst)); }
    inline void insert(int u, int v, int w) {
        nxt[tot] = fst[u]; to[tot] = v; val[tot] = w; fst[u] = tot++;
    }
    inline void link(int u, int v, int w) {
        insert(u, v, w); insert(v, u, w);
    }
} e;

void getSize(int u, int fa) {
    siz[u] = 1;
    for (int i = e.fst[u]; ~i; i = e.nxt[i]) {
        int v = e.to[i];
        if (v == fa || vis[v]) { continue; }
        getSize(v, u);
        siz[u] += siz[v];
    }
}
void findRoot(int u, int fa) {
    ss[u] = _n - siz[u];
    for (int i = e.fst[u]; ~i; i = e.nxt[i]) {
        int v = e.to[i];
        if (v == fa || vis[v]) { continue; }
        findRoot(v, u);
        ss[u] = std::max(ss[u], siz[v]);
    }
    if (ss[rt] > ss[u]) { rt = u; }
}
int getRoot(int u) {
    rt = 0; getSize(u, 0);
    _n = siz[u]; findRoot(u, 0);
    return rt;
}

void dfs1(int u, int fa) {
    if (dis[p] + a[p] > dis[u] + a[u]) { p = u; }
    for (int i = e.fst[u]; ~i; i = e.nxt[i]) {
        int v = e.to[i], w = e.val[i];
        if (v == fa || vis[v]) { continue; }
        dis[v] = dis[u] + w;
        dfs1(v, u);
    }
}
void dfs2(int u, int fa) {
    edg[m++] = (Edge) {u, p, dis[u] + a[u] + dis[p] + a[p]};
    for (int i = e.fst[u]; ~i; i = e.nxt[i]) {
        int v = e.to[i];
        if (v == fa || vis[v]) { continue; }
        dfs2(v, u);
    }
}

void solve(int u) {
    u = getRoot(u); vis[u] = true;
    p = 0; dis[u] = 0; dfs1(u, 0); dfs2(u, 0);
    for (int i = e.fst[u]; ~i; i = e.nxt[i]) {
        int v = e.to[i];
        if (vis[v]) { continue; }
        solve(v);
    }
}

int find(int u) {
    return anc[u] == u ? u : anc[u] = find(anc[u]);
}

int main() {
    n = read(); ss[0] = 1e9; dis[0] = 1e18;
    for (int u = 1; u <= n; u++) { a[u] = read(); }
    for (int i = 1; i < n; i++) {
        int u = read(), v = read(), w = read();
        e.link(u, v, w);
    }
    solve(1);
    for (int u = 1; u <= n; u++) { anc[u] = u; }
    std::sort(edg, edg + m);
    for (int i = 0; i < m; i++) {
        int u = edg[i].u, v = edg[i].v;
        u = find(u); v = find(v);
        if (u != v) { anc[u] = v; ans += edg[i].w; }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 79104
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    string s; cin >> s;

    if (N < 3200) print("red");
    else print(s);
    
}


Measured memory_bytes: 3648
import bisect
n = int(input())
l = list(map(int,input().split()))
cnt = 0
l.sort()

for i in range(n):
    for j in range(i+1,n):
        k = bisect.bisect_left(l,l[i]+l[j])
        if k > j:
            cnt += k - j - 1
        else:
            pass
            
print(cnt)

Measured memory_bytes: 3188
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush


n = int(input())
array = [0]*(n+1)

def prime_factor(n):
    for i in range(2, int(n**0.5)+1):
        while n%i == 0:
            array[i] += 1
            n //= i
    if n != 1:
        array[n] += 1

def main():
    for i in range(1, n+1):
        prime_factor(i)
    ans = 1
    for i in range(len(array)):
        ans *= array[i]+1
    print(ans%(10**9+7))


if __name__ == '__main__':
    main()


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll h, n;
    cin >> h >> n;
    ll sum = 0;
    NREP() {
        ll a;
        cin >> a;
        sum += a;
    }
    Yn(sum >= h)
}


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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;
typedef pair<int, int> ii;
typedef long long ll;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    double r; cin >> r;

    cout << fixed << setprecision(15) << r * 2 * acos(-1) << endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <string>
#include <map>
using namespace std;

int main () {
  map<string, int> box;
  box["SUN"] = 7;
  box["MON"] = 6;
  box["TUE"] = 5;
  box["WED"] = 4;
  box["THU"] = 3;
  box["FRI"] = 2;
  box["SAT"] = 1;
  string h;
  cin >> h;
  cout << box[h] << endl;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")

//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//INT_MAXなど
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

// clang++ main.cc -std=c++11 -stdlib=libc++

/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/

signed main(){
  int A, B, C;
  cin >> A >> B >> C;

  int count = 0;
  while (1) {
    if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
      cout << count << endl;
      return 0;
    }
    if (A == B && B == C) {
      cout << -1 << endl;
      return 0;
    }
    int new_A = B / 2 + C / 2;
    int new_B = A / 2 + C / 2;
    int new_C = A / 2 + B / 2;
    A = new_A;
    B = new_B;
    C = new_C;
    count++;
  }

  return 0;
}

Measured memory_bytes: 3580
mod=7+10**9
n,a,b=map(int,input().split())
def comb(n,c,mod):
  s=1
  t=1
  for i in range(1,c+1):
    s=s*i%mod
  for j in range(n-c+1,n+1):
    t=t*j%mod
  return (t*pow(s,mod-2,mod))%mod
ans=(pow(2,n,mod)-comb(n,a,mod)-comb(n,b,mod)-1)%mod
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<pair<int,int>> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].first;
        a[i].second=i;
    }
    sort(All(a));
    reverse(All(a));
    int dp[2020][2020];
    //dp[i][j]:活動度の高い順にi+j人を既に配置し、i人を左に、j人を右に寄せた時のスコア
    for(int i=0;i<2020;i++){
        for(int j=0;j<2020;j++){
            dp[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            int act=a[i+j].first;
            int idx=a[i+j].second;
            dp[i+1][j]=max(dp[i+1][j],dp[i][j]+abs(idx-i)*act);
            dp[i][j+1]=max(dp[i][j+1],dp[i][j]+abs(idx-(n-1-j))*act);
        }
    }
    int res=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i+j==n)res=max(res,dp[i][j]);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 35572
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,M=get_i
input=array(M)
pref=array(N)
M.times do|i|
  input[i]=get_i
  p,y=input[i][0],input[i][1]
  p-=1
  pref[p]=[] if pref[p].nil?
  pref[p].push(y)
end
ans={}
pref.each_with_index do|arr,i|
    next if arr.nil?
    arr.sort!
    arr.each_with_index do|y_,j|
        ans[y_]=(i+1).to_s.rjust(6,"0")+(j+1).to_s.rjust(6,"0")
    end
end
input.each do|p,y|
    puts ans[y]
end

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

typedef long long ll;

int main() {
	int n; cin >> n;
	vector<int>a(3 * n);
	for (auto&& x : a)cin >> x;
	sort(a.begin(), a.end());
	
	ll ans = 0;
	for (int i = 3 * n - 2, cnt = 0; i < 3 * n, cnt < n; i -= 2, cnt++) {
		ans += a[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4572
h,w,k=map(int,input().split())
mat=[]
cake=[[0 for _ in range(w)]for _ in range(h)]
straw=[]
for i in range(h):
    s=list(input())
    mat.append(s)
    for k in range(w):
        if s[k]=='#':
            straw.append([i,k])
cnt=1
for g in straw:
    r=g[0]
    c=g[1]
    cake[r][c]=cnt
    for ii in range(r-1,-1,-1):
        if mat[ii][c]=='#':
            break
        if cake[ii][c]==0 :
            cake[ii][c]=cnt
    for ii in range(r +1, h,1):
        if mat[ii][c] == '#':
            break
        if cake[ii][c] == 0:
            cake[ii][c] = cnt
    cnt+=1

for i in range(h):
    for j in range(w-2,-1,-1):
        if cake[i][j]==0:
            cake[i][j]=cake[i][j+1]

for i in range(h):
    for j in range(1,w):
        if cake[i][j] == 0:
            cake[i][j] = cake[i][j -1]
for i in range(h):
    print(*cake[i])


Measured memory_bytes: 63580
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n; cin >> n;
    vector<int> d(n+1);
    rep1(i, n) cin >> d[i];
    sort(all(d));

    vector<int> t(n+1);
    rep(i, n+1) {
        if (d[i] == 0) t[i] = 0;
        else {
            if (i % 2 == 0) t[i] = d[i];
            else t[i] = 24 - d[i];
        }
    }

    int ans = INF;
    rep(i, n+1) rep(j, n+1) {
        if (i >= j) continue;
        chmin(ans, min(abs(t[i] - t[j]), 24 - abs(t[i] - t[j])));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric> // 最大公約数が使える
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

int main()
{
    ll X;
    cin >> X;
    ll A=100;
    ll ans=0;
   while (A<=X)
    {
        A*=1.01;
        
        ans++;
        if (A>=X)
        {
            break;
        }
    }

    cout << ans << endl;
    
    
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k;
  cin>>k;
  string s,s1="";
  cin>>s;
  if(s.length()<=k) cout<<s;
  else
  {
    for(int i=0;i<k;i++)
    {
      s1+=s[i];
    }
    s1+="...";
    cout<< s1;
  
  }
  return 0;

}

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    ll N2 = (N << 1);
    string S; cin >> S;
    if(S[0] == 'W') cout << 0 << endl;
    else{
        vector<int> flg(N2, 0); //0 -> o, 1 -> x
        for(int i = 1; i < N2; i++){
            if(S[i] == S[i-1]) flg[i] = !flg[i-1];
            else flg[i] = flg[i-1];
        }
        if(flg[N2-1] != 1){
            cout << 0 << endl;
        }
        else{
            ll fac[N+1]; fac[0] = 1;
            for(int i = 1; i <= N; i++) fac[i] = fac[i-1]*i % mod;
            ll ans = 1;
            vector<int> O(N2+1), X(N2+1);
            O[N2-1] = 0; X[N2] = 0;
            for(int i = N2-1; i >= 0; i--){
                if(flg[i] == 1) X[i] = X[i+1] + 1;
                else X[i] = X[i+1];
            }
            for(int i = N2-1; i >= 1; i--){
                if(flg[i] == 0) O[i-1] = O[i] + 1;
                else O[i-1] = O[i];
            }
            //rep(i, N2+1) cout << X[i]; cout << endl;
            //rep(i, N2+1) cout << O[i]; cout << endl;
            for(int i = 0; i < N2; i++){
                if(flg[i] == 0) ans = (ans * max(0, X[i]-O[i])) % mod;
            }

            int bitcnt = 0;
            rep(i, N2) if(flg[i]) bitcnt++;
            if(bitcnt*2 != N2) cout << 0 << endl;
            else cout << ans*fac[N] % mod << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3732
S = list(input())
max_count = 0
count = 0
for i in range(len(S)):
	if S[i] == "A" or S[i] == "T" or S[i] == "G" or S[i] == "C":
		count += 1
	else:
		if count > max_count:
			max_count = count
			count = 0
		else:
			count = 0
			
if count >= max_count:
	print(count)
else:
	print(max_count)

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

int main()
{
    int k, a, b;
    string d;
    cin >> k;
    cin >> a >> b;
    d = "NG";
    while (a <= b) {
        if (a % k == 0) {
            cout << "OK" << endl;
            d = "OK";
            break;
        }
        a = a + 1;
    }
    if (d == "NG") {
        cout << "NG" << endl;
    }
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<(n);i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
  int x;
  cin >> x;
  if(x==0){
    cout << "1" << endl;
  }
  else{
    cout << "0" << endl;
  }
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#define rep(i, a, n) for(int i = int(a);i < int(n);++i)
#define repe(i, a, n) for(int i = int(a);i <= int(n);++i)
#define repr(i, a, n) for(int i = int(a);i > int(n);--i)
#define reper(i, a, n) for(int i = int(a);i >= int(n);--i)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using namespace std;


int D, N;


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

	if(N == 100) cout << 101*(int)pow(100, D) << endl;
	else cout << N*(int)pow(100, D) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll X, T;
  cin>>X>>T;
  ll zero = 0;
  cout<<max(zero, X-T)<<endl;
}



Measured memory_bytes: 3564
x1,y1,x2,y2 = map(int,input().split())
 
side_x=x2-x1
side_y=y2-y1
 
pattern = [[side_x,side_y],[-side_y,side_x],[-side_x,-side_y],[side_y,side_x]]*2
 
i = pattern.index([side_x,side_y])
x3,y3 = x2+pattern[i+1][0],y2+pattern[i+1][1]
x4,y4 = x3+pattern[i+2][0],y3+pattern[i+2][1]
print(x3,y3,x4,y4)

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#define ll long long int
using namespace std;

int main() {
    ll n,t,i,k,sum=0;
    cin>>n;
    ll a[n],b[n-1];
    for(i=0;i<n-1;i++)
    {
        cin>>b[i];
    }
    a[0]=b[0];
    for(i=1;i<n-1;i++)
    {
        if(b[i]>=b[i-1])
        {
            a[i]=b[i-1];
        }
        else
        {
            a[i]=b[i];
        }
    }
    a[n-1]=b[n-2];
    for(i=0;i<n;i++)
    {
       sum+=a[i];
    }
    cout<<sum;
    

	return 0;
}

Measured memory_bytes: 256