akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  string s; cin >> s;
  ll n = s.size();
  vector<ll> cnt(26);
  rep(i,n) cnt[s[i]-'a']++;
  ll ans = n*(n-1)/2+1;
  rep(i,26) ans -= cnt[i]*(cnt[i]-1)/2;
  cout << ans;
  return 0;
}


Measured memory_bytes: 3772
//By TheOneYouWant
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i=0;i<e;++i)
#define forsn(i,s,e) for(int i=s;i<e;++i)
#define rforn(i,s) for(int i=s;i>=0;--i)
#define rforsn(i,s,e) for(int i=s;i>=e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime() cerr<<"Time = "<<((double)clock()/CLOCKS_PER_SEC)<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=2e5+5,MOD=1e9+7;
const ld EPS = 1e-9;

int read(){
    int xx=0,ff=1;char ch=getchar();
    while(ch>'9'||ch<'0'){if(ch=='-')ff=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){xx=(xx<<3)+(xx<<1)+ch-'0';ch=getchar();}
    return xx*ff;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main(){
	fastio;

	int x; cin>>x;
	if(x >= 30) cout<<"Yes"<<ln;
	else cout<<"No"<<ln;

	return 0;
}

Measured memory_bytes: 3660
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
struct Edge{
    ll from;
    ll to;
    ll cost;
};
vector<ll> dijkstra(int start, int n, vector<vector<Edge>> &g){
    vector<ll> dist(n, INF);
    priority_queue<pair<ll,ll>, vector<pair<ll,ll>>, greater<pair<ll,ll>>> q;
    q.push(make_pair(0, start));
    dist[start] = 0;
    while(!q.empty()){
        ll now = q.top().second;
        ll nowdist = q.top().first;
        q.pop();
        if(dist[now] < nowdist) continue;
        for(int i = 0; i < g[now].size(); i++){
            ll next = g[now][i].to;
            ll nextcost = g[now][i].cost;
            if(dist[next] <= nowdist + nextcost) continue;
            dist[next] = nowdist + nextcost;
            q.push(make_pair(dist[next], next));
        }
    }
 
    return dist;
   
}
int main(void){
    ll n, m;
    cin >> n >> m;

    vector<vector<Edge>> g(n);
    
    rep(i, m){
        ll l, r, c;
        cin >> l >> r >> c;
        l--, r--;
        Edge tmp;
        tmp.to = r;
        tmp.cost = c;
        g[l].push_back(tmp);
    }

    rep(i, n - 1){
        Edge tmp;
        tmp.to = i;
        tmp.cost = 0;
        g[i + 1].push_back(tmp);
    }

    vector<ll> dist = dijkstra(0, n, g);

    cout << (dist[n - 1]==INF?-1:dist[n - 1]) << endl;




}


Measured memory_bytes: 13496
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n,m,x,y int
	fmt.Scan(&n,&m,&x,&y)

	xs := make([]int,n)
	for i := 0; i < n; i++ {
		var xi int
		fmt.Scan(&xi)
		xs[i] = xi
	}

	ys := make([]int,m)
	for i := 0; i < m; i++ {
		var yi int
		fmt.Scan(&yi)
		ys[i] = yi
	}

	sort.IntSlice(xs).Sort()
	sort.IntSlice(ys).Sort()

	for z := x + 1; z <= y; z++ {
		if xs[len(xs) - 1] < z && ys[0] >= z{
			fmt.Println("No War")
			return
		}
	}

	fmt.Println("War")
}

Measured memory_bytes: 512
/*
 * 0608.cc: Water Rate
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  int ta = a * p;

  int tb = b;
  if (p > c) tb += (p - c) * d;

  printf("%d\n", (ta < tb) ? ta : tb);
  return 0;
}

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

int soin2(int n){
  int count=0;
  while(n%2 == 0){
    n = n/2;
    count++;
  }
  return count;
}
 
int main(){
  int N;
  cin >> N;
  
  int ans = 1;
  int ans_count = 0;
  for(int i=2;i<=N;i++){
    int work = soin2(i);
    if(work > ans_count){
      ans = i;
      ans_count = work;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

# (int(x) for x in input().split())d.
n = int(input())
ans = 0
for a in xrange(1,n+1):
    for b in xrange(a, n+1):
        if (a*b < n):
            if (a==b):
                ans += 1
            else:
                ans += 2
        else:
            break
print(ans)


Measured memory_bytes: 85940
#include <stdio.h>

long f(long x, long y) {
	if (x < y) return f(y, x);
	if (y == 1L) return y;
	if (y == 0L) return x;
	return f(y, x % y);
}

int main(void) {
	long a, b;
	scanf("%ld %ld", &a, &b);
	printf("%ld\n", f(a, b));
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
  int a, b, sum = 0, i = 0;
  int c = 0;
  while (scanf("%d,%d", &a, &b) != EOF){
    sum += a * b;
    i++;
    c += b;
  }
  printf("%d\n%d\n", sum,(c + 1) / i);
  return (0);
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
using namespace std;
#define INF 1<<20+1

int main(){
  int N;
  cin>>N;
  int dp[N+1]={};
  dp[0]=0;
  dp[1]=1;
  dp[2]=2;
  dp[3]=3;
  dp[4]=4;
  dp[5]=5;

  if (N<=5){cout<<dp[N]<<endl;return 0;}
  int c=6;
  while (c!=N+1){
    dp[c]=INF;
    int i=1;
    while(round(pow(6,i))<=c){
      dp[c]=min(dp[c],dp[c-(int)round(pow(6,i))]+1);
      i++;
    }
    i=1;
    while(round(pow(9,i))<=c){
      dp[c]=min(dp[c],dp[c-(int)round(pow(9,i))]+1);//dp[i]+dp[c-i]);
      i++;//min(max(i-i%9,i-i%6),i-1);
    }

    c++;
  }
  cout<<dp[N]<<endl;
  return 0;
}


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

const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main() {
  int h, w;
  cin >> h >> w;
  int si, sj;
  cin >> si >> sj;
  int ti, tj;
  cin >> ti >> tj;
  --si; --sj; --ti; --tj;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  const int INF = 1e9;
  vector<vector<int>> dist(h,vector<int>(w,INF));
  deque<P> q;
  dist[si][sj] = 0;
  q.emplace_back(si,sj);
  while (!q.empty()) {
    int i = q.front().first;
    int j = q.front().second;
    int d = dist[i][j];
    q.pop_front();
    if (dist[i][j] != d) continue;
    rep(v,4) {
      int ni = i+di[v], nj = j+dj[v];
      if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
      if (s[ni][nj] == '#') continue;
      if (dist[ni][nj] <= d) continue;
      dist[ni][nj] = d;
      q.emplace_front(ni,nj);
    }
    for (int ei = -2; ei <= 2; ++ei) {
      for (int ej = -2; ej <= 2; ++ej) {
        int ni = i+ei, nj = j+ej;
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        if (dist[ni][nj] <= d+1) continue;
        dist[ni][nj] = d+1;
        q.emplace_back(ni,nj);
      }
    }
  }
  int ans = dist[ti][tj];
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9572
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector


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

int A, B, Q; cin >> A >> B >> Q;
VI s(A), t(B); invec(s), invec(t);
s.insert(s.begin(), -INF);
s.push_back(INF);
t.insert(t.begin(), -INF);
t.push_back(INF);

rep(_, 0, Q){
    i64 x;cin >> x;
    
    VI::iterator ar = lower_bound(ALL(s), x);
    VI::iterator br = lower_bound(ALL(t), x);
    i64 ans = INF;
    for (i64 a: {*ar, *(ar - 1)}) for (i64 b: {*br, *(br - 1)}){
        i64 d = abs(a - b);
        ans = min({ans, abs(a - x) + d , abs(b - x) + d});
    }
    cout << ans << "\n";
}

}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 2912
N = int(input())
alist1 = list(map(int, input().split()))
alist2 = list(map(int, input().split()))
sumlist1, sumlist2 = [], []
for a in alist1:
    if len(sumlist1) == 0:
        sumlist1.append(a)
    else:
        sumlist1.append(sumlist1[-1] + a)
for a in alist2:
    if len(sumlist2) == 0:
        sumlist2.append(a)
    else:
        sumlist2.append(sumlist2[-1] + a)
maxnum = 0
for k in range(N):
    num = sumlist1[k]
    if k == 0:
        num += sumlist2[N - 1]
    else:
        num += sumlist2[N - 1] - sumlist2[k - 1]
    maxnum = max(maxnum, num)
print(maxnum)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define print(x) cout<<(x)<<endl
#define INF10 1001001001 
#define INF5 100000
#define EPS 1e-10



vector<int> booked;


bool cmp(pair<int, int> a, pair<int, int> b) {
	if (a.first > b.first)return true;
	else if (a.first == b.first) {
		if (a.second >= b.second) return true;
		else return false;
	}
	else return false;
}


int main() {
	int N, M; cin >> N >> M;
	vector<pair<int, int>> task(N);
	booked.assign(M+1, 0);
	for (int i = 0; i <= M; i++) {
		booked[i] = -(M-i); // M, M-1, M-2, ... ,0
	}
	for (int i = 0; i < N; i++) {
		cin >> task[i].second >> task[i].first;
	}
	sort(task.begin(), task.end(), cmp);

	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (task[i].second > M)continue;
		int time = M - task[i].second;


		vector<int>::iterator p = lower_bound(booked.begin(),booked.end(), -time);
		if (p == booked.end())continue;
		if (*p == -time) {
			ans += task[i].first;
			booked.erase(p);
		}
		else {
			if (booked.size()>0 && *p >= -time) {
				ans += task[i].first;
				booked.erase(p);
			}
		}

	}
	cout << ans << endl;



	return 0;
}


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

int main(){
  int A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  int cost;
  if(A+B <= C*2){
    cost = A*X + B*Y;
  }else if(A+B > C*2){
    if(X < Y){
      if(B < C*2){
        cost = C*2*X + B*(Y-X);
      }else{
        cost = C*2*Y;
      }
    }else{
      if(A < C*2){
        cost = C*2*Y + A*(X-Y);
      }else{
        cost = C*2*X;
      }
    }
  }
  cout << cost << endl;
}

Measured memory_bytes: 256
import functools

n, m = map(int, input().split())
ls = [list(map(int, input().split())) for _ in range(m)]

ans = [-1] * n

flag = 0

for i in range(m):
    keta = ls[i][0] - 1
    if ls[i] == [1, 0] and n != 1:
        flag = 1
        break
    else:
        if ans[keta] == -1:
            ans[keta] = ls[i][1]
        elif ans[keta] == ls[i][1]:
            continue
        else:
            flag = 1
            break

if flag == 1:
    print(-1)
elif flag == 0:
    for j in range(n):
        if ans[j] == -1:
            if j == 0 and n != 1:
                ans[j] = 1
            else:
                ans[j] = 0
    ans_n = int(functools.reduce(lambda x, y: x + y, [str(x) for x in ans]))
    print(ans_n)

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

int main()
{

	int n, num;
	vector< int > a;

	while( 1 ) {
	
		cin >> n;
		if( n == 0 ) break;

		int Max = -100001;

		a.push_back( 0 );

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

			cin >> num;
			a.push_back( num );

		}

		for( int i = 1; i <= n; i++ ) {

			a[i] = max( a[i], a[i] + a[i - 1] );
			Max  = max( Max, a[i] );
		
		}

		cout << Max << endl;

		a.clear();
	
	}

	return 0;

}

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

#define sz(x) int(x.size())
#define Task "abc"
#define For(i, a, b) for(int i = (a), _b = (b); i <= b; ++i)
#define All(x) (x).begin(), (x).end()
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;

const int maxn = 2e5 + 10;
const int inf = 0x3f3f3f3f;
const ll mod = 2019;

char s[maxn];

ll Pow(ll a, ll b){
  if (b == 0) return 1;
  ll tmp = Pow(a, b / 2);
  tmp = (tmp * tmp) % mod;
  if (b % 2) return (tmp * a) % mod;
  return tmp;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
//  freopen(Task".inp", "r", stdin); freopen(Task".out", "w", stdout);
  cin >> s + 1;
  int n = strlen(s+1);
  vector<int> cnt(mod, 0);
  ll t = 0, ans = 0;
  cnt[0]++;
  for (int i = n; i > 0; --i){
    t = Pow(10, n - i) * (s[i] - '0') + t;
    t = t % mod;
    ans = ans + cnt[t];
    cnt[t]++;
  }
  cout << ans;
}



Measured memory_bytes: 3824
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}
func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}
func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}
func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}
	return string(str)
}

func round(f float64) float64 {
	return math.Floor(f + .5)
}

func main() {
	defer out.Flush()
	sc.Split(bufio.ScanWords)
	x := nextInt()
	var res float64 = 100
	for i := 1; ; i++ {
		res = math.Floor(float64(res * 1.01))
		if int(res) >= x {
			fmt.Fprintln(out, fmt.Sprint(i))
			return
		}
	}
}


Measured memory_bytes: 1760
#define KAKUSUKO

#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X, Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};


const int MAX_N = 2000;
int N;
int L[MAX_N];

int main() {

    cin >> N;
    rep(i, N) cin >> L[i];

    sort(L, L + N);

    rep(i, N) {
        cerr << L[i] << (i + 1 == N ? '\n' : ' ');
    }

    ll ans = 0;
    for (ll i = 0; i < N; ++i) {
        for (ll j = i+1; j < N; ++j) {
            ll a = L[i], b = L[j];
            ll mi = b - a;
            ll ma = a + b;

            ll lb = upper_bound(L, L + N, mi) - L;
            ll ub = lower_bound(L, L + N, ma) - L;
            lb = max(lb, j+1);
            ll count = max(0ll, ub - lb);
            ans += count;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
/*package whatever //do not write package name here */

import java.io.*;
import java.util.*;


public class Main {
    static int gcd(int a,int b,int c)
    {int d=gcdd(a,b);
    return gcdd(d,c);
    }
    static int gcdd(int a,int b)
    {if(b==0)
    return a;
    return gcdd(b,a%b);
    }
	public static void main (String[] args) {
	Scanner s=new Scanner(System.in);
	int n=s.nextInt();
	long ans=0;
	for(int i=1;i<=n;i++)
	{for(int j=1;j<=n;j++)
	{for(int k=1;k<=n;k++)
	{ans+=gcd(i,j,k);}}}
	System.out.println(ans);
	}
}

Measured memory_bytes: 35840
#include "bits/stdc++.h"
#define int long long

using namespace std;

signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    int t = c - a - b;
    if(t < 0) {
        cout << "No" << endl;
    }else if(4 * a * b < t * t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
a=[]
for i in range(10) :
    a.append(input())
j=0
while j<10 :
    k=0
    while k<9 :
        if int(a[k])<int(a[k+1]) :
            tmp=a[k]
            a[k]=a[k+1]
            a[k+1]=tmp
        k=k+1
    j=j+1
print(a[0])
print(a[1])
print(a[2])


Measured memory_bytes: 5600
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
#define ll long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 1e5 + 10;
int n, a[N];
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    sort(a+1, a+1+n, greater<int>());
    int s;
    for (int i = 1; i <= n; ++i) {
        if(i+1 > a[i+1]) {
            if((a[i]-i)%2) {
                s = 1;
                break;
            }
            s = 0;
            for (int j = i+1; j <= n; ++j) {
                if(a[j] == i) s ^= 1;
                else break;
            }
            break;
        }
    }
    if(s) puts("First");
    else puts("Second");
    return 0;
}


Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new A();
        }
    }

    class A
    {
        public A()
        {
            var str = Console.ReadLine();
            int cntS = 0;
            int cntT = 0;
            int amaruT = 0;
            foreach (var e in str)
            {
                if (e == 'S')
                    cntS++;
                else
                    cntT++;

                if (e == 'T' && cntS < cntT - amaruT)
                {
                    amaruT++;
                }
            }
            Console.WriteLine(amaruT * 2);
        }
    }
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split();
            var S = l[0];
            var T = l[1];

            Console.WriteLine(T + S);
        }
    }
}

Measured memory_bytes: 13140
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split();
            var n = double.Parse(line[0]);
            var k = int.Parse(line[1]);

            double total = 0;
            var num = 0;
            var count = 0;

            var array = new int[(int)n];

            for (var i = 0; i < n; i++)
            {
                num = i + 1;
                while (num < k)
                {
                    num *= 2;
                    count++;
                }
                if (count == 0) break;
                array[i] = count;
                count = 0;

            }

            for (var i = 0; i < n; i++)
            {
                if (array[i] > 0)
                {
                    total += 1 / n * Math.Pow((1.0 / 2), array[i]);
                }
                else
                {
                    total += 1 / n;
                }
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 11232
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdlib.h>

typedef long long u64_t;

#define SIZE 5

u64_t width[SIZE];

int main()
{
  int cnt;
  int i;
  u64_t total = 4;
  u64_t min = 0;
  u64_t N = 0;
  int min_saved = 0;
    
  cnt = scanf("%lld", &N);
  
  for (i=0; i<SIZE; i++) {
    cnt = scanf("%lld", &width[i]);
    if (min_saved == 0) {
      min = width[i];
      min_saved = 1;
    }
    if (min > width[i]) {
      min = width[i];
    }
  }

  total += (N / min);
  if ((N%min) != 0) {
    total += 1;
  }

  printf("%lld", total);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int i, j, N, K, m, tmp;
    int a[200000];
    int h[200000] = {0};
    int s[200000] = {0};
    int max = 0;
    int c=0, k=0, ans;

    scanf("%d%d", &N, &K);

    for (i=0; i<N; i++) {
        scanf("%d", &a[i]);
        h[a[i]]++;
        if (a[i]>max)   max=a[i];
    }

    for (i=1; i<=max; i++) {
        if (h[i]>0) {
            s[k++] = h[i];
        }
    }

    if (k>K) {
        for(i=0; i<K; i++) {
            m = i;
            for (j=i+1; j<k; j++) {
                if (s[j]>s[m]) m=j;
            }
            tmp=s[i];
            s[i]=s[m];
            s[m]=tmp;
        }

        for (i=0; i<K; i++) c += s[i];

        ans = N-c;
    }

    else {
        ans = 0;
    }

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

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define ppb push_back
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;
typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;
typedef vector<vector<int>> vvi; typedef vector<vbool> vvb;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vint a(n); fori(n) cin >> a[i];
	sort(a.begin(), a.end());
	for(int i= 1; i < n; i++) {
		if (a[i] == a[i-1]) {
			cout << "NO" << nl; return 0;
		}
	}
	cout << "YES" << nl;
	
	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 1024
n = 0
ans = 0
def dfs(s):
    ret = 0
    if int(s) <= n:
        if '7' in s and '5' in s and '3' in s:
            ret += 1
        ret += dfs(s+'7')
        ret += dfs(s+'5')
        ret += dfs(s+'3')
    return ret

n = int(input())
print(dfs('0'))

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

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;

const int N = 10;
const double eps = 1e-6;

int n, a, b, c;
int s[N];

int dfs(int u, int sa, int sb, int sc, int m)
{
    if(u == n)
    {
        if(!sa || !sb || !sc) return 0x3f3f3f3f;
        else return abs(a - sa) + abs(b - sb) + abs(c - sc) + 10 * (m - 3);
    }

    int res = 0x3f3f3f3f;
    res = min(res, dfs(u + 1, sa + s[u], sb, sc, m + 1));
    res = min(res, dfs(u + 1, sa, sb + s[u], sc, m + 1));
    res = min(res, dfs(u + 1, sa, sb, sc + s[u], m + 1));
    res = min(res, dfs(u + 1, sa, sb, sc, m));
    return res;
}

int main()
{
    cin >> n >> a >> b >> c;
    for(int i = 0; i < n; i++) cin >> s[i];
    cout << dfs(0, 0, 0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		System.out.println(a < b && b < c ? "Yes" : "No");
	}
}


Measured memory_bytes: 26024
#include <iostream>
using namespace std;
long long n, k, ans, c[200005];
int main() {
	cin>>n>>k;
	for (int i=0; i<k; i++) {
		c[i] = n / k;
		if (i>=1 && i<=n%k) c[i]++;
	}
	for (int i=0; i<k; i++) {
		if (2*i%k == 0)
			ans += c[i] * c[i] * c[(k-i)%k];
	}
	cout<<ans;
	return 0;
}

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

int main(){
	int x,y;
	while(cin>>x>>y,x){
		int D[16][16],P[16][16],ans=0;
		for(int i=0;i<256;i++)P[i/16][i%16]=0;
		for(int i=0;i<y;i++)for(int j=0;j<x;j++)cin>>D[i][j];
		for(int i=0;i<x;i++)if(!D[0][i])P[0][i]=1;
		for(int i=0;i<y-1;i++){
			for(int j=0;j<x;j++){
				if(!D[i][j]){
					P[i+1][j]+=P[i][j];
					if(j>0&&D[i+1][j-1]!=2)P[i+1][j-1]+=P[i][j];
					if(j<x-1&&D[i+1][j+1]!=2)P[i+1][j+1]+=P[i][j];
				}
				if(D[i][j]==2){
					if(i+2>y-1)ans+=P[i][j];
					else P[i+2][j]+=P[i][j];
				}
			}
		}
		for(int i=0;i<x;i++){
			if(D[y-1][i]!=1)ans+=P[y-1][i];
		}
		cout<<ans<<endl;
	}
}

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

using namespace std;


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

	bool dis[10] = { };
	for (int i = 0; i < K; i++) {
		int D;
		cin >> D;
		dis[D] = true;
	}
	int num[4];
	int dig = 0;
	int Ntmp = N;
	while (Ntmp > 0) {
		num[dig++] = Ntmp % 10;
		Ntmp /= 10;
	}
	int min = 0;
	for (int i = 1; i < 10; i++) {
		if (!dis[i]) {
			min = i;
			break;
		}
	}
	int max= 9;
	for (int i = 9; i >= 0; i--) {
		if (!dis[i]) {
			max = i;
			break;
		}
	}
	int maxnum = 0;
	for (int i = 0; i < dig; i++) {
		maxnum *= 10;
		maxnum += max;
	}
	int ans = 0;
	if (maxnum < N) {
		ans = min;
		for (int i = 0; i < dig; i++) {
			ans *= 10;
			if (dis[0]) ans += min;
			else ans += 0;
		}
	} else {
		bool same = true;
		dig--;
		for (int i = dig; i >= 0; i--) {
			if (same) {
				for (int j = num[i]; j < 10; j++) {
					if (!dis[j]) {
						ans *= 10;
						ans += j;
						break;
					}
					same = false;
				}
			} else {
				ans *= 10;
				if (dis[0]) ans += min;
				else ans += 0;
			}
		}
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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 INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
 if(!b)return 1; if(b&1)return modpow(a,b-1,m)*a%m;
 int memo = modpow(a,b>>1,m);
 return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a,b;
  cin>>a>>b;
  string c;
  cin>>c;
  bool d=1;
  rep(i,c.size()){
  if(i+1<=a&&!('0'<=c[i]&&c[i]<='9'))
    d=0;
    else if(i+1==a+1&&c[i]!='-')
      d=0;
    else if(a+1<i+1&&!('0'<=c[i]&&c[i]<='9'))
      d=0;
  }
  YesNo(d);
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
res = H[0] - 1
for i in range(1, N):
    if res > H[i]: #単調非減少に出来ない
        print ('No')
        exit()
    else:
        res = max(res, H[i] - 1)
print ('Yes')

Measured memory_bytes: 14396
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>
#include <iomanip>
#include <limits>
#include <map>

using namespace std;

const int CMax = 100002;
const int CVMax = 102;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, A[CMax], tmp;

long long gcd(long long a, long long b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}

int main()
{
    int k, x;
    scanf("%d %d", &k, &x);

    for (int i = max(-1000000, x - k + 1); i <= min(1000000, x + k - 1); i++) {
        printf("%d ", i);
    }

    printf("\n");

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h.at(i);
    }
    int ans = 0, cnt = 0;
    for (int i = 1; i < n; i++) {
        if (h.at(i - 1) >= h.at(i)) cnt++;
        else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {

	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);

	if (b - a == c - b) {
		printf("YES");
	}
	else {
		printf("NO");
	}






}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define ld long double
#define ff first
#define ss second
const ll mod =   998244353 ;
ll multiply(ll a, ll b ){ return ((a % mod) * (b % mod)) % mod; }
ll add(ll a, ll b) {     return ((a % mod) + (b % mod)) % mod; }
ll sub(ll a, ll b) { return ((a%mod) - (b % mod)+ mod) % mod ; }
////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////
void solve(){
   string s ;
   cin >> s ;
   int n = s.size() ;
   int m ;
   cin >> m ;
   deque<char> q ;
   for(int i = 0 ; i < n ; i++) q.push_back(s[i]);
   int start = 0 , end = n-1;
   while(m--){
        int t ;
        cin >> t ;
        if(t==1){
            swap(start,end);
        }
        else{
            int k ;
            char c ;
            cin >> k >> c ;
            if(k==1){
                if(start>end)
                   q.push_back(c),start++;
                else
                    q.push_front(c),start--;

            }
            else{
                if(end>start)
                    q.push_back(c),end++;
                else
                    q.push_front(c) , end--;
            }
        }
   }
   if(start>end){
        while(!q.empty()){
            cout << q.back() ;
            q.pop_back();
        }
        return ;
   }
   while(!q.empty()){
        cout << q.front() ;
        q.pop_front() ;
   }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t ;
    t = 1 ;
    //cin >> t ;
    while(t--){
        solve( );
    }
}
// number of subset having xor in 2ki ow


Measured memory_bytes: 976
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

int main(){
    int N,K;
    cin>>N>>K;
    int ans=pow(K-1,N-1);
    cout<<ans*K<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n ;
    ll a[100001], x;
    memset(a, 0, sizeof(a));
    ll ans = 0;
    for(int i=0;i<n;i++){
    	cin >> x;
    	a[x]++;
    	ans += x;
    }
    ll q;
    cin >> q;
    ll b, c;
    vector<ll> v;
    while(q--){
    	cin >> b >> c;
    	ll sum = ( c - b) * a[b];
    	a[c] += a[b];
    	a[b] = 0;
    	ans += sum;
    	v.pb(ans);
    }
    for(auto& i: v) cout << i << endl;
    return 0;
}


Measured memory_bytes: 4984
try:   
    N = int(input())
    num = [i for i in range(N+1) if i%2==0]
    ans = 1
    __ = 0
    for i in num:
        _ = format(i, 'b')[::-1].find("1")
        if __ < _:
            ans = i
            __ = _
    print(ans)
except EOFError:
    pass

Measured memory_bytes: 2940
#include<bits/stdc++.h>                          
using namespace std;
int n,d[105],ans=1;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>d[i];
    sort(d+1,d+1+n);
    for(int i=2;i<=n;i++)
        if(d[i]!=d[i-1]) ans++;
    cout<<ans;
	return 0;
}
//68871358
//76140264
//25446011
//200841159
//914174775

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }

int h(int x, int y){
	return x * x + 2 * x * y + x + 1;
}

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

	int n, a;
	cin >> n >> a;
	n %= 500;
	if(a >= n)puts("Yes");
	else puts("No");
	return 0;
}



Measured memory_bytes: 256
n = int(input())
d = dict()

for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

M = max(d.values())

ans_list = []
for k,v in d.items():
    if v == M:
        ans_list.append(k)

ans_list.sort()
for i in ans_list:
    print(i)

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

int main(void){
    int N;
    cin >> N;
    string s;
    int check[4];

    for(int i = 0; i < 4; i++)
        check[i] = 0;

    for(int i = 0; i < N; i++){
        cin >> s[i];
        if(s[i] == 'P')
            check[0] = 1;
        if(s[i] == 'W')
            check[1] = 1;
        if(s[i] == 'G')
            check[2] = 1;
        if(s[i] == 'Y')
            check[3] = 1;
    }
    int sum = check[0] + check[1] + check[2] + check[3];

    if(sum == 3)
        cout << "Three" << endl;
    else if(sum == 4)
        cout << "Four" << endl;
    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,k;
		n=sc.nextInt();
		k=sc.nextInt();
		if(n%k!=0)
			System.out.println(1);
		else
			System.out.println(0);
	}
}

Measured memory_bytes: 23636
#include<iostream>
using namespace std;
int p[350000], n, q, a;
int main() {
	cin >> n >> q;
	for (int i = 0; i < n; i++) { cin >> a; p[a] = 1; }
	for (int i = 0; i < q; i++) {
		cin >> a;
		for (int j = a - 1; j >= 0; j--) {
			int cnt = j;
			while (true) {
				if (p[cnt] == 1) {
					cout << j << endl;
					goto E;
				}
				cnt += a;
				if (cnt > 300000) { break; }
			}
		}
	E:;
	}
	return 0;
}

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

int main() {
  int N,M;
  cin>>N>>M;
  vector<int> p(N,1);
  vector<int> r(N);
  r.at(0)=1;
  for(int i=0;i<M;i++){
int a,b;
    cin>>a>>b;
    a--,b--;
    if(r.at(a)==1){
r.at(b)=1;
    }
p.at(a)--;
    p.at(b)++;
    if(p.at(a)==0){
r.at(a)=0;
    }
  }
int Z=0;
for(int i=0;i<N;i++){
Z+=r.at(i);
}
cout<<Z<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int h, w;
    cin >> h >> w;
    string s[51];
    for(int i = 0; i < h; i++){
        cin >> s[i];
    }
    queue<int> task;
    int field[50][50];
    for(int i = 0; i < 50; i++){
        for(int j = 0; j < 50; j++){
            field[i][j] = INF;
        }
    }
    int total = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(s[i][j] == '.'){
                total++;
            }
        }
    }
    field[0][0] = 1;
    task.push(0 * 50 + 0);
    while(!task.empty()){
        int in = task.front();
        task.pop();
        int i = in / 50;
        int j = in % 50;
        if(i > 0){
            if(s[i - 1][j] == '.'){
                if(field[i - 1][j] > field[i][j] + 1){
                    field[i - 1][j] = field[i][j] + 1;
                    task.push((i - 1) * 50 + j);
                }
            }
        }
        if(j > 0){
            if(s[i][j - 1] == '.'){
                if(field[i][j - 1] > field[i][j] + 1){
                    field[i][j - 1] = field[i][j] + 1;
                    task.push(i * 50 + (j - 1));
                }
            }
        }
        if(i < h - 1){
            if(s[i + 1][j] == '.'){
                if(field[i + 1][j] > field[i][j] + 1){
                    field[i + 1][j] = field[i][j] + 1;
                    task.push((i + 1) * 50 + j);
                }
            }
        }
        if(j < w - 1){
            if(s[i][j + 1] == '.'){
                if(field[i][j + 1] > field[i][j] + 1){
                    field[i][j + 1] = field[i][j] + 1;
                    task.push(i * 50 + (j + 1));
                }
            }
        }
    }
    if(field[h - 1][w - 1] < INF){
        cout << total - field[h - 1][w - 1] << endl;
        return 0;
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll base = 1e6;
int D;
int C[30];
int S[400][30];
int last[400][30];

ll score(vector<int>& t)
{
  ll s = 0LL;
  REP(i,D){
    s += S[i][t[i]];
    REP(j,26) last[i+1][j] = last[i][j];
    last[i+1][t[i]] = i+1;
    REP(j,26){
      s -= C[j] * (i+1-last[i+1][j]);
    } 
  }
  return s;
}

ll score_2(vector<int>& t, ll before, int d, int old, int q)
{
  ll s = before;
  s += S[d][q] - S[d][old];
  FOR(i,d,D){
    if(t[i]==old) break;
    s += C[old] * ((i+1) - last[i+1][old]);
    s -= C[old] * ((i+1) - last[d][old]);
  }
  FOR(i,d,D){
    if(i!=d && t[i]==q) break;
    s += C[q] * ((i+1) - last[i+1][q]);
    s -= C[q] * ((i+1) - (d+1));
  }

  return s;
}

vector<int> init(int sub)
{
  vector<int> t(D);
  REP(i,D) t[i] = (i+sub)%26;
  return t;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  random_device rnd;
  mt19937 mt(rnd());
  uniform_int_distribution<> rand365(0, 364);
  uniform_int_distribution<> rand26(0, 25);

  cin >> D;
  REP(i,26) cin >> C[i];
  REP(i,D) REP(j,26) cin >> S[i][j];

  auto T = init(0);
  ll max_score = 0LL;
  REP(sub,26){
    auto tmp = init(sub);
    ll sc = max(base+score(tmp), 0LL);
    if(max_score<sc){
      max_score = sc;
      T = tmp;
    }
  }
  int ti = clock();
  while(clock() - ti < 190 * CLOCKS_PER_SEC / 100){ 
    int d = rand365(mt);
    int q = rand26(mt);
    int old = T[d];
    T[d] = q;
    ll tmp = max(base + score_2(T, max_score, d, old, q), 0LL);
    if(max_score<tmp){
      max_score = tmp;
      FOR(i,d,D){
        if(T[i]==old) break;
        last[i+1][old] = last[d][old];
      }
      FOR(i,d,D){
        if(T[i]==q) break;
        last[i+1][q] = (d+1);
      }
    }else{
      T[d] = old;
    }
  }
  REP(i,D) cout << T[i]+1 << '\n';
  return 0;
}


Measured memory_bytes: 3792
import itertools

n, m, q = map(int, input().split())
query = []
for i in range(q):
    query.append(list(map(int, input().split())))

choices = list(itertools.combinations_with_replacement([i for i in range(1, m+1)], n))
ans = -1
for choice in choices:
    score = 0
    for q in query:
        if choice[q[1]-1] - choice[q[0]-1] == q[2]:
            score += q[3]
    ans = max(ans, score)
print(ans)

Measured memory_bytes: 84468
import sys
import numpy as np

# input = sys.stdin.readline

a, b = map(int, input().split())

a_tax = a * 100 // 8

b_tax = b * 100 // 10

for money in range(a_tax, 1250):
    if (b == money // 10) and (a == money * 8 // 100):
        print(money)
        break
else:
    print("-1")

Measured memory_bytes: 21248
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
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)*}
    };
}
 
#[allow(unused_macros)]
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)*}
    };
}
 
#[allow(unused_macros)]
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, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
fn gcd(a: i64,b: i64) -> i64{
    if b==0{
        a
    } else {
        gcd(b,a%b)
    }
}
fn main(){
    input!{
        n: usize,
        x: i64,
        a: [i64; n]
    }
    let mut ans = 0;
    for a in a.iter(){
        ans = gcd(ans, (a-x).abs())
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352