akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> PY(M);
    map<int, vector<pair<int, int>>> MA;
    for (int i = 0; i < M; i++) {
        int p, y;
        cin >> p >> y;
        MA[p].push_back(make_pair(y, i));
    }

    for (auto &vec : MA) sort(vec.second.begin(), vec.second.end());

    vector<pair<int, int>> ans(M);
    for (auto vec: MA) {
        for (int i = 0; i < vec.second.size(); i++) {
            ans[vec.second[i].second] = make_pair(vec.first, i + 1);
        }
    }

    for(int i = 0;i<ans.size();i++) printf("%06d%06d\n", ans[i].first, ans[i].second);

    return 0;
}











































































Measured memory_bytes: 13952
#include<bits/stdc++.h>
using namespace std;
int main()

{
    int a,i=0;
    cin>>a;
    string s;
    string t;
    cin>>s>>t;
    while(s[i]!='\0')
    {
        cout<<s[i]<<t[i];
        i++;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <set>
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
using namespace std;
int main(){
    queue<char> a;
    queue<char> b;
    queue<char> c;

    string s,t,u;
    cin >> s>>t>>u;

    REP(i,s.size()){
        a.push(s[i]);
    }
    REP(i,t.size()){
        b.push(t[i]);
    }
    REP(i,u.size()){
        c.push(u[i]);
    }

    char k = 'a';

    while (true){
        if(k=='a'){
            if(a.empty()){
                cout << "A" <<endl;
                return 0;
            }
            k = a.front();
            a.pop();
        }
        else if(k=='b'){
            if(b.empty()){
                cout << "B" <<endl;
                return 0;
            }
            k=b.front();
            b.pop();
        }
        else{
            if(c.empty()){
                cout << "C" <<endl;
                return 0;
            }
            k= c.front();
            c.pop();
        }
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;

const int N = 2e5 + 5;
ll cnt[N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,0,n){
		cin >> a[i];
		++cnt[a[i]];
	}
	ll ans = 0;
	rep(i,1,N)ans += cnt[i] * (cnt[i] - 1)/2;
	rep(i,0,n){
		ll c = cnt[a[i]];
		cout << ans - c * (c - 1)/2 + (c-1) * (c-2)/2 << '\n';
	}
}


Measured memory_bytes: 3968
// 获得范围内的因数
#include <cstdio>
int main()
{
    int a, b, c;
    int sum = 0;
    scanf("%d%d%d", &a, &b, &c);
    for (int i = a; i <= b; i++)
    {
        if (c % i == 0)
            sum++;
    }
    printf("%d\n", sum);
    return 0;
}


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

using namespace std;
#define ll long long int
const int MAXN = 2 * 1e5 + 5;

void solve(){
    string s; cin >> s;
    bool poss = true;
    int n = s.size();
    if( n & 1){
        cout << "No\n";
        return ;
    } else {
        for(int i = 0; i < n; i += 2){
            if(s[i] == 'h' and s[i + 1] == 'i'){
                continue;
            }else{
                poss = false;
                break;
            }
        }
        if(poss) cout << "Yes\n";
        else cout << "No\n";
    }


}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while(t--)
		solve();
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

public class Main{

	Scanner sc=new Scanner(System.in);;

	int INF=1<<28;
	double EPS=1e-9;

	void run(){
		for(;;){
			int y1=sc.nextInt();
			int m1=sc.nextInt();
			int d1=sc.nextInt();
			int y2=sc.nextInt();
			int m2=sc.nextInt();
			int d2=sc.nextInt();
			if(y1<0||m1<0||d1<0||y2<0||m2<0||d2<0){
				break;
			}
			/*
			 * Calendar c1=Calendar.getInstance();
			 * Calendar c2=Calendar.getInstance();
			 * c1.set(y1, m1, d1);
			 * c2.set(y2, m2, d2);
			 * long diff=c2.getTime().getTime()-c1.getTime().getTime();
			 * println((diff/1000/60/60/24)+"");
			 */
			int a=day(y1, m1, d1);
			int b=day(y2, m2, d2);
			println((b-a)+"");
		}
	}

	int day(int y, int m, int d){
		int res=0;
		int[] days={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		int[] sum=new int[12];
		for(int i=1; i<12; i++){
			sum[i]=sum[i-1]+days[i-1];
		}
		res+=y*365+sum[m-1]+d-1;
		if((m==2&&d<=28)||m==1){
			y--;
		}
		if(y>=0){
			res+=y/4+1;
			res-=y/100+1;
			res+=y/400+1;
		}
		return res;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();
	}
}

Measured memory_bytes: 11000
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    ll n, m, tmp; cin >> n;
     
    vector<ll> a(n);
    map<int, int> mp;
    int x;
    rep(i,n) {
        cin >> x;
        mp[x]++;
    }
    cin >> m;
    rep(i,m) {
        cin >> x;
        if (mp[x] == 0) {
            cout << "NO" << endl;
            return 0;
        }

        mp[x]--;
    }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>
#define MAX 100
int main(){
  int num[MAX],a,i,j,k=0,m,n=0,p,minj;
    scanf("%d",&a);
    for(i=0;i<a;i++){
        scanf("%d",&num[i]);
    }
    for(i=0;i<a-1;i++){
      m=num[i];
      minj=i;
        for(j=i;j<a;j++){
	  if(num[minj]>num[j]){
	    minj=j;
	  }
        }
	if(num[i]>num[minj]){
        num[i]=num[minj];
        num[minj]=m;
	n++;
	}
    }
     for(i=0;i<a;i++){
       printf("%d",num[i]);
       if(i !=a-1){
           printf(" ");
       }
     }
        printf("\n%d\n",n);
    return 0;
}



Measured memory_bytes: 2108
#include<stdio.h>
int main(){
    int N,M,C,a[21],b[21],temp=0,j,i,co=0;
    scanf("%d%d%d",&N,&M,&C);
    for(int i=0;i<M;i++)scanf("%d",&b[i]);
    
    for(i=0;i<N;i++){
        for(j=0;j<M;j++){
            scanf("%d",&a[j]);
            temp+=a[j]*b[j];
            //printf("%d\n",temp);
        }
        if(temp+C>0)co++;
        temp=0;
    }
    printf("%d",co);
}


Measured memory_bytes: 128
#!/usr/bin/env python3
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
L = list(map(int , input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if i == j or j == k or k == i:
                continue
            a = L[i]
            b = L[j]
            c = L[k]
            if a == b or b == c or c == a:
                continue
            if a + b > c and b + c > a and c + a > b:
                # print(a, b, c)
                ans += 1
print(ans)

Measured memory_bytes: 9216
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**9)
from collections import deque, defaultdict
n, q = map(int, input().split())
#隣接リスト
G = defaultdict(lambda:[])
#################################
for _ in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    G[a].append(b)
    G[b].append(a)
    
#################################

#深さ優先探索でトポロジカル順序を決める
#右奥から調べていく
parent = [0]*n #p[i]:頂点iの親
order = [] #トポロジカル順序
def dfs():
    parent[0] = -1
    stack = []
    u = 0
    stack.append(u)
    while stack:
        x = stack.pop()
        order.append(x)
        for v in G[x]:
            if v == parent[x]:
                continue
            parent[v] = x
            stack.append(v)

dfs()
################################
point = [0]*n
for i in range(q):
    p, x = map(int, input().split())
    p -=1
    point[p] += x

for i in order:
    if parent[i] != -1:
        point[i] += point[parent[i]]

print(*point)

Measured memory_bytes: 110860
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<cstdlib>
#include<iostream>
#define INF 10000000
using namespace std;
int glid[21][21];
int kakutei[21],leng[21];
int main(void)
{
	//ios::sync_with_stdio(false);
	int i,j,k;
	int n,m,a,b,a_b,b_a;
	int start,finish,okane,value,mi,point;
	cin>>n>>m;
	for(i=0;i<n;i++) {
		for(j=0;j<n;j++) {
			glid[i][j]=INF;
		}
	}
	for(i=0;i<n;i++) glid[i][i]=0;
	for(i=0;i<m;i++) {
		scanf("%d,%d,%d,%d",&a,&b,&a_b,&b_a);
		a--;b--;
		glid[a][b]=a_b;
		glid[b][a]=b_a;
	}
	scanf("%d,%d,%d,%d",&start,&finish,&okane,&value);
	start--;finish--;
	for(i=0;i<n;i++) {leng[i]=INF;kakutei[i]=0;}
	leng[start]=0;
	for(i=0;i<n;i++) {
		mi=INF;
		for(j=0;j<n;j++) {
			if(kakutei[j]==0 && leng[j]<mi) {
				point=j;
				mi=leng[j];
			}
		}
		kakutei[point]=1;
		mi=INF;
		for(j=0;j<n;j++) {
			if(leng[point]+glid[point][j]<leng[j]) {
				leng[j]=leng[point]+glid[point][j];
			}
		}
	}
	okane-=leng[finish];
	for(i=0;i<n;i++) {leng[i]=INF;kakutei[i]=0;}
	swap(start,finish);
	leng[start]=0;
	for(i=0;i<n;i++) {
		mi=INF;
		for(j=0;j<n;j++) {
			if(kakutei[j]==0 && leng[j]<mi) {
				point=j;
				mi=leng[j];
			}
		}
		kakutei[point]=1;
		for(j=0;j<n;j++) {
			if(leng[point]+glid[point][j]<leng[j]) {
				leng[j]=leng[point]+glid[point][j];
			}
		}
	}
	okane-=leng[finish];
	cout<<okane-value<<endl;
	return 0;
}

Measured memory_bytes: 1240
import scala.io.StdIn.{readInt, readLine}

object Main extends App {

  val n  = readInt()
  val xs = readLine().split(" ").map { _.toInt }

  val cnt = MergeSort.sort(xs)

  println(xs.mkString(" "))
  println(cnt)
}

object MergeSort {
  val Max: Int      = 500000
  val Sentinel: Int = 2000000000

  def sort(xs: Array[Int]): Int = {

    val ls = new Array[Int](Max / 2 + 2)
    val rs = new Array[Int](Max / 2 + 2)

    def mergeSort(left: Int, right: Int): Int = {
      val m = right - left
      if (m <= 1) 0
      else {
        val mid  = (left + right) / 2
        val cnt1 = mergeSort(left, mid)
        val cnt2 = mergeSort(mid, right)
        merge(left, mid, right)
        cnt1 + cnt2 + m
      }
    }

    def merge(left: Int, mid: Int, right: Int): Unit = {
      val n1 = mid - left
      val n2 = right - mid
      Array.copy(xs, left, ls, 0, n1)
      Array.copy(xs, mid, rs, 0, n2)
      ls(n1) = Sentinel
      rs(n2) = Sentinel
      var i  = 0
      var j  = 0
      var k  = left
      while (k < right) {
        if (ls(i) <= rs(j)) {
          xs(k) = ls(i)
          i += 1
        } else {
          xs(k) = rs(j)
          j += 1
        }
        k += 1
      }
    }

    mergeSort(0, xs.length)
  }
}



Measured memory_bytes: 217944
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct{
    int b;
    int c;
} Node;

int cmp(const void *p, const void *q){
    return *(int *)p - *(int *)q;
}

int main(void){
    int ans=0, blen, i, j, N, a[100000];
    Node n[100000];

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

    qsort(a, N, sizeof(int), cmp);

    i = 0;
    j = 0;
    for (i = 0; i < N; i++){
        (n + j)->b++;
        //printf("(n+%d)->b = %d\n", j, (n + j)->b);
        (n + j)->c = a[i];
        //printf("(n+%d)->c = %d\n", j, (n + j)->c);
        if (a[i] != a[i + 1]){
            j++;
        }
    }

    blen = j;

    for (i = 0; i < blen; i++){
        if((n+i)->b == (n+i)->c){
            //printf("(n+%d)->b = %d , (n+%d)->c = %d\n", i,(n + i)->b,i,(n + i)->c);
        }
        else if ((n + i)->b > (n + i)->c){
            //printf("B\n");
            ans += (n + i)->b - (n + i)->c;
        } else {
            //printf("C\n");
            ans += (n + i)->b;
        }
    }

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

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

const ll MOD = 998244353;

ll sum (ll a, ll b) {
  return (a + b) % MOD;
}

struct segment_tree {
  vector <ll> t;
  segment_tree (int n) {
    t.resize(n << 2);
  }
  void update(int v, int tl, int tr, int l, int r, int val) {
    if (l > r) return;
    if (l == tl && r == tr) {
      t[v] = sum(t[v], val);
      return;
    }
    int tm = (tl + tr) / 2;
    t[v * 2] = sum(t[v * 2], t[v]);
    t[v * 2 + 1] = sum(t[v * 2 + 1], t[v]);
    t[v] = 0;
    update(v * 2, tl, tm, l, min(r, tm), val);
    update(v * 2 + 1, tm + 1, tr, max(l, tm + 1), r, val);
  }
  ll get (int v, int tl, int tr, int pos) {
    if (tl == tr)
      return t[v];
    int tm = (tl + tr) / 2;
    t[v * 2] = sum(t[v * 2], t[v]);
    t[v * 2 + 1] = sum(t[v * 2 + 1], t[v]);
    t[v] = 0;
    if (pos <= tm)
      return get(v * 2, tl, tm, pos);
    else
      return get(v * 2 + 1, tm + 1, tr, pos);
  }
};

int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector <pair <int, int>> a(k);
  for (int i = 0; i < k; i++)
    cin >> a[i].first >> a[i].second;
  segment_tree se(n);
  se.update(1, 0, n - 1, 0, 0, 1);
  for (int i = 0; i < n; i++) {
    ll val = se.get(1, 0, n - 1, i);
    for (auto &now : a)
      se.update(1, 0, n - 1, i + now.first, min(i + now.second, n - 1), val);
  }
  cout << se.get(1, 0, n - 1, n - 1);
  return 0;
}


Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
char str[maxn];
map<int, int>mi;
int get(int x)
{
    if(mi.count(x))
    {
        return mi[x];   
    }
    return maxn;
}
void add(int x, int val)
{
    if(!mi.count(x))
    {
        mi[x]=val;
    }
    else mi[x]=min(mi[x], val);
}
int main()
{
    scanf("%s", str);
    int i, j;
    int dp=0, mask=0;
    for(i=0; str[i]; i++)
    {
        add(mask, dp);    
        mask^=1<<(str[i]-'a');
        dp=get(mask)+1;
        for(j=0; j<26; j++)
        {
            dp=min(dp, get(mask^(1<<j))+1);
        }
    }
    printf("%d\n", dp);

}


Measured memory_bytes: 9856
#include <stdio.h>

int main(){
	int N;
	scanf("%d", &N);
	if(N == N / 100 + 10 * ((N /10) % 10) + (N % 10) * 100){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout<<i<<endl;
#define AS(i) cout<<i<<" ";
 
const int INF = 1001001001;
 
using namespace std;
 
ll dp[110][100010];
 
int main() {

    int pa[8][3] = {
        {0, 3, 6},
        {1, 4, 7},
        {2, 5, 8},
        {0, 1, 2},
        {3, 4, 5},
        {6, 7, 8},
        {0, 4, 8},
        {2, 4, 6}
    };

    int ca[9];
    rep(i, 9) 
        cin >> ca[i];

    int n;
    cin >> n;
    int hoge;
    rep(i, n) {
        cin >> hoge;

        rep(i, 9) {
            if (ca[i] == hoge)
                ca[i] = -1;
        }
    }

    rep(i, 8) {
        if (ca[pa[i][0]] == - 1 && ca[pa[i][1]] == - 1 && ca[pa[i][2]] == -1) {
            AA("Yes");
            return 0;
        }
    }

    AA("No");
}

Measured memory_bytes: 256
N, Ma, Mb = map(int, input().split())
items = []
for i in range(N):
    a, b, c = map(int, input().split())
    items.append((a, b, c))

a_sum = sum([item[0] for item in items])
b_sum = sum([item[1] for item in items])
inf = float("inf")
dp = [[[inf for _ in range(a_sum + 100)] for _ in range(b_sum + 100)] for i in range(N + 1)]
dp[0][0][0] = 0

for i in range(N):
    for a in range(a_sum + 1):
        for b in range(b_sum + 1):
            if dp[i + 1][a][b] > dp[i][a][b]:
                dp[i + 1][a][b] = dp[i][a][b]
            if dp[i + 1][a + items[i][0]][b + items[i][1]] > dp[i][a][b] + items[i][2]:
                dp[i + 1][a + items[i][0]][b + items[i][1]] = dp[i][a][b] + items[i][2]

ans = inf
for a in range(1, a_sum + 1):
    for b in range(1, b_sum + 1):
        if a * Mb == b * Ma:
            ans = min(ans, dp[N][a][b])
if ans != inf:
    print(ans)
else:
    print(-1)


Measured memory_bytes: 133724
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;
//--------------------

int main() {
	double W, H , x , y; cin >> W >> H >> x >> y;
	cout << W * H / 2 << " ";
	if (x * 2 == W && y * 2 == H) cout << 1 << endl; else cout << 0 << endl;
}

Measured memory_bytes: 256
var out = function(x)
{
  console.log(x);
  return x;
}

var judge = function(W,H,x,y,r)
{
  //
  if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H)
    return "Yes";
  else
    return "No";
}

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(input)
{
  var result = input.split(' ').map(Number)

  out(judge(result[0],result[1],result[2],result[3],result[4]));
});

Measured memory_bytes: 7648
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define y1 y_golabi
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll;
typedef map<int , int> mii;
typedef pair<int , int> pii;
typedef map<string , int> msi;
typedef pair<int , string> pis;
typedef pair<int , pair<int , int> > piii;
const int MAXN = 2e3 + 10;
int n , x , sum , ans , dp[MAXN][MAXN] , a[MAXN];
int32_t main()
{
	cin >> n >> x;
	///base
	for(int i = 0 ; i < n ; i ++)
		cin >> a[i] , dp[0][i] = a[i] , ans += a[i];
	///update
	for(int i = 1 ; i < n ; i ++)
	{
		sum = i * x , dp[i][0] = min(dp[i - 1][n - 1] , a[0]) , sum += dp[i][0];
		for(int j = 1 ; j < n ; j ++)
			dp[i][j] = min(dp[i - 1][j - 1] , a[j]) , sum += dp[i][j];
		ans = min(ans , sum);
	}
	return cout << ans << endl , 0;
}


Measured memory_bytes: 31744
#include<cstdio>
int main(){
int n,d,a[200005];
int mx=0,id,ms=0;
scanf("%d",&n);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
}
for(int i=1;i<=n;i++){
if(a[i]>mx){
mx=a[i];
id=i;
}
}
for(int i=1;i<=n;i++){
if(a[i]>ms&&i!=id)ms=a[i];
}
for(int i=1;i<=n;i++){
if(i!=id)printf("%d\n",mx);
else printf("%d\n",ms);
}
}

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

#define int long long int
#define ull unsigned long long int
#define for0(i, n) for (int i = 0; i < (int)(n); i++) // 0 based indexing
#define for1(i, n) for (int i = 1; i <= (int)(n); i++) // 1 based indexing
#define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); i++) // closed interver from l to r r inclusive
#define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; i--) // reverse 0 based.
#define forr1(i, n) for (int i = (int)(n); i >= 1; i--) // reverse 1 based


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

#define I_max (unsigned int)1e9
#define size6 (int)1e6


#define all(x) (x).begin(), (x).end() 
#define rall(x) (x).rbegin, (x).rend() 
#define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define sz(a) int((a).size())


using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef double ld;

//-----------------------------------------------------------------------------------END-------------------------------------------------------------------------------------//

int a[size6];


bool inc(vi vec){
	for1(i,vec.size()-1){
		if(vec[i]<vec[i-1])return 0;
	}
	return 1;
}


void solve(){
   float d,t,s;cin>>d>>t>>s;
   float sp = d/t;

   

   if(s<sp)cout<<"No"<<'\n';
   else cout<<"Yes"<<'\n';
}



int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout.precision(10);
	//cout << fixed;
	//int tt;cin>>tt;
	//while(tt--){
		solve();
	//}
	return 0;
}




Measured memory_bytes: 3668
import itertools
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

N = list(itertools.permutations(range(1, n+1)))


def f(val):
    for i, x in enumerate(N):
        if x == val:
            return i+1

print(abs(f(p) - f(q)))


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


typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpll;
typedef vector<vll> vvll;


#define F first
#define S second
#define pb push_back
#define mp make_pair

// don't edit before this line 



//const ll inf = (ll)1e9 + 7; 



ll n,k;
vll arr;
ll memo[100001][2];

ll func(int kk,int t){

	//cout<<kk<<"\n";
	bool yes=false;
	if(arr[0]<=kk)
		yes = true;

	if(!yes)
			return 1-t;

	if(memo[kk][t]!=-1)
		return memo[kk][t];
	for(int i=0;i<n;i++){
		if(arr[i]<=kk)
		{
			ll temp = func(kk-arr[i],1-t);
			if(temp == t)
				return memo[kk][t]=t;
		}
	}
	return memo[kk][t]=1-t;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cout.setf(ios::fixed), cout.precision(20);

	cin >> n >> k;
	arr.resize(n);

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

	for(int i=0;i<100001;i++)
		for(int j=0;j<2;j++){
			memo[i][j]=-1;
		}
	ll xx = func(k,0);
	if(xx==0)
		cout<<"First"<<"\n";
	else
	{
		cout<<"Second"<<"\n";
	}
	
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;

using lli = long long int;
using Vint = vector<int>;
using Vlli = vector<lli>;
using Wint = vector<Vint>;
using Wlli = vector<Vlli>;
using pii = pair<int, int>;
using pll = pair<lli, lli>;

constexpr int MOD = 1e9 + 7;
constexpr int INFi = 2e9 + 1;
constexpr lli INFl = (lli)(9e18) + 1;
const vector<pii> DXDY = {make_pair(1, 0), make_pair(-1, 0), make_pair(0, 1), make_pair(0, -1)};
constexpr char BR = '\n';

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define FOReq(i, a, b) for(int (i) = (a); (i) <= (b); (i)++)
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); i--)
#define FORstep(i, a, b, step) for(int (i) = (a); i < (b); i += (step))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define vREP(ele, vec) for(auto &(ele) : (vec))
#define vREPcopy(ele, vec) for(auto (ele) : (vec))
#define SORT(A) std::sort((A).begin(), (A).end())


template <class T> inline int argmin(vector<T> vec){return min_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline int argmax(vector<T> vec){return max_element(vec.begin(), vec.end()) - vec.begin();}
template <class T> inline void chmax(T &a, T b){a = max(a, b);}
template <class T> inline void chmin(T &a, T b){a = min(a, b);}
inline int toInt(string &s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline int toInt(const string s){int res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(string &s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
inline long long int toLong(const string s){lli res = 0; for(char a : s) res = 10 * res + (a - '0'); return res;}
template <class T> inline std::string toString(T n){
  if(n == 0) return "0";
  std::string res = "";
  if(n < 0){n = -n;while(n != 0){res += (char)(n % 10 + '0'); n /= 10;}
  std::reverse(res.begin(), res.end()); return '-' + res;}
  while(n != 0){res += (char)(n % 10 + '0'); n /= 10;} std::reverse(res.begin(), res.end()); return res;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


using indexs = queue<int>;

int main(void){
  int n; cin >> n;
  Vint A(n);
  REP(i, n){
    cin >> A.at(i);
  }
  stack<int> res;
  REP(j, n){
    int idx = -1;
    REP(i, n - j){
      if(A.at(i) == i + 1) idx = i;
    }
    if(idx != -1){
      A.erase(A.begin() + idx);
      res.push(idx + 1);
    }
    else{
      cout << -1 << BR;
      return 0;
    }
  }
  while(not res.empty()){
    cout << res.top() << BR;
    res.pop();
  }
  return 0;
}

Measured memory_bytes: 888
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut text :String = read();
    let last = text.chars().rev().next().unwrap();
    if last == 's' {
        text += "es";
    } else {
        text += "s";
    }
    print!("{}", text);
}


Measured memory_bytes: 2132
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <set>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N;
set <int> A;





int main()
{

	cin >> N;



	REP(i,N){
		int a;
		cin >> a;
		if(!A.erase(a))
			A.insert(a);
	}

	cout << A.size() << endl;
}




Measured memory_bytes: 4864
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<numeric>
#include<climits>
#include<queue>
#include<unordered_map>
 
using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int k;
	cin >> k;
	vector<long long> a(k);
	for (auto & e : a) cin >> e;
	long long mina = 2;
	long long maxa = 2;
	for (int i = k - 1; i >= 0; --i) {
		mina = ((mina - 1) / a[i] + 1)*a[i];
		maxa = (maxa / a[i]+1)*a[i]-1;
		if (mina > maxa) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << mina << " " << maxa << endl;
	return 0;
}

Measured memory_bytes: 1024
<?php

function getInput() {
    return trim(fgets(STDIN));
}

list ($numberOfPeople, $numberOffoods) = explode (' ', getInput());

$nullArray = [];
$countsOfAnswer = array_pad($nullArray, $numberOffoods, 0);

for ($i = 0; $i < $numberOfPeople; $i++){
    
    $inputData = explode (' ', getInput());
    array_shift($inputData);

    foreach ($inputData as $answer){
        $countsOfAnswer[$answer - 1] += 1;
    }
}


$result = (array_keys($countsOfAnswer, $numberOfPeople));

echo count($result);

Measured memory_bytes: 3828
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    ll h, w;
    cin >> h >> w;
    if (min(h, w) == 1) cout << 1 << endl;
    else if (h % 2 && w % 2) {
        cout << h * w / 2 + 1 << endl;
    }
    else cout << h * w / 2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<map>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1

#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const int INF = 2000000000;

    ll N,M;
    ll A,B,C;
    bool F=false;
    ll ans=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>A>>B>>C;
    REP(i,10){
        C=A*C-B;
        cout<<C<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
m = [0]
c = 0
for i in range(1, n):
    if (s[i-1] == "A") & (s[i] == "C"):
        c += 1
    m.append(c)

for j in range(q):
    l, r = map(int, input().split())
    print(m[r-1] - m[l-1])


Measured memory_bytes: 6100
N = int(input())
a = 0
b = 0
ab = 0
c = 0
for _ in range(N):
    s = input()
    if s[0] == 'B':
        b += 1
    if s[-1] == 'A':
        a += 1
    if s[0] == 'B' and s[-1] == 'A':
        c += 1
    for i in range(len(s) - 1):
        if s[i:i+2] == "AB":
            ab += 1
ans = ab + min(a, b)
if a == b and a == c and a > 0:
    ans -= 1
print(ans)

Measured memory_bytes: 3064
let n = Scanf.scanf "%d\n" (fun i -> i)
let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun i -> i))

let m = Array.fold_left max 1 a + 1

let b1 = Array.make m false
let b2 = Array.make m false


let rec f i =
  if i < n then (
    let ai = a.(i) in
    if not b1.(ai) then (
        if b2.(ai) then
          b1.(ai) <- true
        else (
          let rec g j =
            let x = ai * j in
            if x < m then (
                b1.(x) <- true;
                g (j + 1)
            ) in
          g 2;
          b2.(ai) <- true
        )
    );
    f (i + 1)
  )

let rec g i ans =
  if i = n then ans
  else if b1.(a.(i)) then g (i + 1) ans
  else g (i + 1) (ans + 1)

let () = f 0; Printf.printf "%d\n" (g 0 0)


Measured memory_bytes: 23492
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

struct UnionFind {
  std::vector<int> par;

  UnionFind(int n) : par(n, -1) {}
  void init(int n) {par.assign(n, -1);}

  int root(int x) {
    if (par[x] < 0) return x;
    else return par[x] = root(par[x]);
  }

  bool issame(int x, int y) {return root(x) == root(y);}

  void unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return;
    if (par[x] > par[y]) std::swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return;
  }

  int size(int x) {return -par[root(x)];}
};

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

  int64 n; int m; cin >> n >> m;
  vector<int> a(m), b(m);
  rep(i, m) {
    cin >> a[i] >> b[i];
    --a[i]; --b[i];
  }
  // 最後は 1 + 2 + ... + n - 1
  int64 huben = n * (n - 1) / 2;
  vector<int64> ans;
  ans.emplace_back(huben);

  UnionFind uf(n);

  for (int i = m - 1; i >= 1; --i) {
    if (uf.issame(a[i], b[i])) {
      ans.emplace_back(huben);
    } else {
      huben -= uf.size(a[i]) * uf.size(b[i]);
      uf.unite(a[i], b[i]);
      ans.emplace_back(huben);
    }
  }

  reverse(all(ans));
  for (int64 x : ans) {
    cout << x << '\n';
  }

  return 0;
}

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

template<class I, class BiOp = I (*) (I, I)>
class SegTree {
private:
  int n;
  std::vector<I> dat;
  BiOp op;
  I e;

public:
  SegTree(int n_, BiOp op, I e) : op(op), e(e) {
    n = 1;
    while (n < n_) n *= 2;
    dat.resize(2 * n - 1, e);
  }

  void update(int k, I v) {
    k += n - 1;
    dat[k] = v;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
    }
  }

  // return op[a..b)
  // k: node id, [l, r): node interval
  I query(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r == -1) r = n;
    if (r <= a || b <= l) return e;
    if (a <= l && r <= b) return dat[k];
    I vl = query(a, b, 2 * k + 1, l, (l + r) / 2);
    I vr = query(a, b, 2 * k + 2, (l + r) / 2, r);
    return op(vl, vr);
  }

  void print() {
    int j = 2;
    for (int i = 0; i < 2 * n - 1; i++) {
      cout << dat[i];
      if (i == j - 2) {
        cout << endl;
        j *= 2;
      }
      else {
        cout << " ";
      }
    }
  }
};

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

  int n, q;
  cin >> n >> q;
  SegTree<int> seg(n, [](int a, int b){ return std::min(a, b); }, INT_MAX);

  rep(i, q) {
    int t, x, y;
    cin >> t >> x >> y;
    if (t == 0) {
      seg.update(x, y);
    }
    else {
      cout << seg.query(x, y + 1) << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k,a,res=0;
  cin>>n>>m;
  map<int,int> M;
  for(int i=0;i<n;++i){
    cin>>k;
    for(int j=0;j<k;++j){
      cin>>a;
      M[a]++;
    }
  }
  cout<<count_if(M.begin(),M.end(),[&](pair<int,int> x){ return x.second==n;});
  return 0;
}


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

using namespace std;

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

    int A[5];
    cin >> A[0];
    cin >> A[1];
    cin >> A[2];
    cin >> A[3];
    cin >> A[4];

    int a[5];
    a[0] = A[0] % 10;
    a[1] = A[1] % 10;
    a[2] = A[2] % 10;
    a[3] = A[3] % 10;
    a[4] = A[4] % 10;

    int min_i = -1;
    for (int i = 0; i < 5; ++i)
    {
        if (min_i == -1)
        {
            min_i = i;
        }

        if (a[i] != 0 && a[min_i] > a[i])
        {
            min_i = i;
        }
    }

    int result = 0;
    for (int i = 0; i < 5; ++i)
    {
        if (i != min_i)
        {
            if (a[i] != 0)
            {
                result = result + A[i] + 10 - a[i];
            }
            else
            {
                result = result + A[i];
            }
        }
    }
    result += A[min_i];

    cout << result << endl;

    return 0;
}


Measured memory_bytes: 256
#[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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (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")
    };
}

fn main() {
    input! {
        n: usize,
        ds: [i64; n],
    }
    let mut count = 0i64;
    for i in 0..n {
        for j in i + 1..n {
            count += ds[i] * ds[j];
        }
    }
    println!("{}", count);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
#include<ctime>
#include<algorithm>
#include<iomanip>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
#include<set>
#include<map>
using namespace std;
#define MAXN 10010
#define MAXM 1010
#define eps 1e-8
#define ll long long
#define MOD 1000000007
#define INF 1000000000
int n;
int f[MAXN];
int main(){
	int i,j,x;
	scanf("%d",&n);
	f[0]=1;
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		for(j=10000;j>=x;j--){
			f[j]|=f[j-x];
		}
	}
	for(j=10000;j;j--){
		if(f[j]&&j%10){
			printf("%d\n",j);
			return 0;
		}
	}
	printf("0\n");
	return 0;
}

/*

*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n, m;
	cin >> n >> m;
	if(n==1 || m==1) cout << "1" << endl;
	else cout << ((n+1)/2)*((m+1)/2) + (n/2)*(m/2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <cctype>
#include <fstream>

using namespace std;

#define ll long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define du(x) cout<<#x<<'='<<x<<endl
#define du2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define du3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


string nu[12] = {
    "01","02","03","04","05","06","07","08","09","10","11","12"
};

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

    bool f1 = false, f2 = false;
    rep(i, S.size()) {
        rep(j, 12) {
            if (S[i] == nu[j][0] && S[i + 1] == nu[j][1]) {
                if (i == 0)f1 = true;
                if (i == 2)f2 = true;
            }
        }
        i++;
    }
    if (f1 && !f2) {
        cout << "MMYY" << endl;
        return 0;
    }
    if (f2 && !f1) {
        cout << "YYMM" << endl;
        return 0;
    }
    if (f1&&f2) {
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    cout << "NA" << endl;
}

Measured memory_bytes: 256
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>  
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vl vector<ll>
#define N 100005
#define mod 1000000007


int main()
{
    double d,t,s;cin>>d>>t>>s;
    if((d/s)<=t)
    cout<<"Yes"<<"\n";
    else
    cout<<"No"<<"\n";
    return 0;
}

Measured memory_bytes: 3572
a=input().split()

ls=[]
ln=len(a)

for i in range(ln):
    if a[i]=="+":
        ls[-2]+=ls[-1]
        ls.pop()
    elif a[i]=="-":
        ls[-2]-=ls[-1]
        ls.pop()
    elif a[i]=="*":
        ls[-2]*=ls[-1]
        ls.pop()
    else:
        ai=int(a[i])
        ls.append(ai)
        
print(ls[-1])


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define MAX 100002
 
int n;
int k;
 
vector<int> ret;
set<int> ss;
 
vector<pair<int,int> > v1;
 
int main(){
	cin>>n>>k;
	for(int i=2*n;i<3*n;i++){
		ret.push_back(i);
	}
	for(int i=0;i<2*n;i++)ss.insert(i);
	int x=0;
	int y=2*n-1;
	while(x<y){
		if(x+y>(3*n-1)-k)break;
		cerr<<x<<" "<<y<<endl;
		ss.erase(x);
		ss.erase(y);
		v1.push_back(make_pair(x,y));
		x+=2;
		y--;
	}
	while(ss.size()){
		int a=(*ss.begin());
		int b=(*ss.rbegin());
		ss.erase(a);
		ss.erase(b);
		v1.push_back(make_pair(a,b));
	}
	auto cmp=[&](auto a,auto b){return a.first+a.second<b.first+b.second;};
	sort(v1.begin(),v1.end(),cmp);
	for(int i=0;i<v1.size();i++){
		if(v1[i].first+v1[i].second<=ret[i]-k){
			
		}
		else{
			puts("-1");
			return 0;
		}
	}
	for(int i=0;i<v1.size();i++){
		cout<<v1[i].first+k<<" "<<v1[i].second+k<<" "<<ret[i]+k<<endl;
	}
	return 0;
}


Measured memory_bytes: 10612
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int inf = 1e17;
const int mod = 998244353;
typedef pair<int, int> P;
typedef pair<int,P> PP;
int rwa[2005];
int dp[4004][4004];

signed main() {
	string s; cin >> s;
	int n = s.size();
	rep(i, n) {
		if (s[i] == '0')rwa[i + 1] += 2;
		if (s[i] == '1')rwa[i + 1]++;
		rwa[i + 1] += rwa[i];
	}
	dp[0][0] = 1;
	rep(i, 2 * n) {
		rep(j, i+1) {
			int r = j, b = i - j;
			int br = rwa[min(n, i + 1)], bb = min(n, i + 1) * 2 - br;
			if (br >= r + 1 && bb >= b)dp[i + 1][j + 1] += dp[i][j];
			if (br >= r&&bb >= b + 1)dp[i + 1][j]+= dp[i][j];
			dp[i + 1][j + 1] %= mod;
			dp[i + 1][j] %= mod;
		}
	}
	int sum = 0;
	rep(i, 2 * n + 1)sum += dp[2 * n][i];
	cout << sum%mod << endl;
}

Measured memory_bytes: 123648
def gcd(a,b)
    if(a%b==0)
        return b
    end
    gcd(b,a%b)
end

n,x = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)

g = (x-nums[0]).abs

nums.each do |i|
    g = gcd(g,(x-i).abs)
end

puts g

Measured memory_bytes: 8452
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int[] e = new int[n + 1];
			e[1] = 1;
			for (int i = 2; i <= n; i++) {
				int j = i;
				int p = 2;
				while (p <= j) {
					if (j % p == 0) {
						e[p]++;
						j /= p;
					} else {
						p++;
					}
				}
			}
			//System.Diagnostics.Debug.WriteLine($"{string.Join(" ", e)}");

			int ans = 0;
			for (int i = 0; i < e.Length; i++) {
				for (int j = 0; j < e.Length; j++) {
					if (i != j && e[i] >= 2 && e[j] >= 4) {
						for (int k = j + 1; k < e.Length; k++) {
							if (i != k && e[k] >= 4) {
								//System.Diagnostics.Debug.WriteLine($"2<=e[{i}]={e[i]} 4<=e[{j}]={e[j]} 4<=e[{k}]={e[k]}");
								ans++;
							}
						}
					}
					if (i != j && e[i] >= 2 && e[j] >= 24) {
						//System.Diagnostics.Debug.WriteLine($"2<=e[{i}]={e[i]} 24<=e[{j}]={e[j]}");
						ans++;
					}
					if (i != j && e[i] >= 14 && e[j] >= 4) {
						//System.Diagnostics.Debug.WriteLine($"14<=e[{i}]={e[i]} 4<=e[{j}]={e[j]}");
						ans++;
					}
				}
				if (e[i] >= 74) {
					//System.Diagnostics.Debug.WriteLine($"74<=e[{i}]={e[i]}");
					ans++;
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long LL;

int main () {
	LL h,w;
	while (scanf("%lld %lld",&h,&w) != EOF) {
		LL ans = min(h,w);
		if (h%3 ==0 || w%3 ==0) {
			puts("0");
			continue;
		}
		for (LL i=1;h>i;i++) {
			//first block is i*w
			LL s1=i*w;
			//left (h-i) * w
			//if s1 is max, then s2 should near s3
			LL s2=((h-i))*(w/2);
			LL s3=(h-i)*w-s2;
			ans = min(ans,max(max(s1,s2),s3) - min(s1,(min(s2,s3))));
			//s1 = (h-i) *~
			s2 = (h-i) * (s1/(h-i));
			s3 = (h-i)*w-s2;
			ans = min(ans,max(max(s1,s2),s3) - min(s1,(min(s2,s3))));
			s2 += (h-i);
			s3 -= (h-i);
			ans = min(ans,max(max(s1,s2),s3) - min(s1,(min(s2,s3))));
			;
		}
		swap(h,w);
		for (LL i=1;h>i;i++) {
			//first block is i*w
			LL s1=i*w;
			//left (h-i) * w
			//if s1 is max, then s2 should near s3
			LL s2=((h-i))*(w/2);
			LL s3=(h-i)*w-s2;
			ans = min(ans,max(max(s1,s2),s3) - min(s1,(min(s2,s3))));
			//s1 = (h-i) *~
			s2 = (h-i) * (s1/(h-i));
			s3 = (h-i)*w-s2;
			ans = min(ans,max(max(s1,s2),s3) - min(s1,(min(s2,s3))));
			s2 += (h-i);
			s3 -= (h-i);
			ans = min(ans,max(max(s1,s2),s3) - min(s1,(min(s2,s3))));
			;
		}
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 256