akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>


int main(){

int A[100000];
  int j,i,num,temp,x;

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


  x = A[num-1];
  i=-1;
  for(j = 0;j<num-1;j++){
    if( A[j] <= x){
      i = i + 1;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
}
  temp = A[i+1];
  A[i+1] = A[num-1];
  A[num-1] = temp;


  for(j=0;j<num-1;j++){
    if(j == i+1) printf("[%d] ",A[j]);
    else printf("%d ",A[j]);
  }
  printf("%d\n",A[num-1]);
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc138/abc138_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  vector<double> c(N);
  rep(i, N) {
    int n;
    cin >> n;
    c[i] = (double)1 / n;
  }

  double ans = 0;
  rep(i, N) { ans += c[i]; }

  printf("%.16f", 1 / ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int64 gcd(int64 a, int64 b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
		int n, k; cin >> n >> k;
		vector<int> v(n);
		rep (i, n) {
			cin >> v[i];
		}
		int ans = 0;
		for (int l = 0; l <= k; ++l) {
			for (int r = 0; r <= k - l; ++r) {
				if (l + r > n) break;
				int d = k - l - r;
				int now = 0;
				vector<int> s;
				for (int i = 0; i < l; ++i) {
					now += v[i];
					s.push_back(v[i]);
				}
				for (int i = n - r; i < n; ++i) {
					now += v[i];
					s.push_back(v[i]);
				}
				sort(all(s));
				for (int i = 0; i < d; ++i) {
					if (i >= s.size()) break;
					if (s[i] > 0) break;
					now -= s[i];
				}
				ans = max(ans, now);
			}
		}
		cout << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li n;
li a[200200];

int main() {
    cin >> n;
    rin{
        cin >> a[i];
    }
    li res = 0;

    map<li, li> l;
    rin{
        // a[0] + a[i] == i
        res += l[i - a[i]];
        l[a[i] + i]++;
    }
    cout << res << endl;


    return 0;
}

Measured memory_bytes: 27800
#include<bits/stdc++.h>
#define to edge[i].v
#define mp make_pair
#define rint register int
#define debug(x) cerr<<#x<<"="<<x<<endl
#define fgx cerr<<"-------------"<<endl
#define N 2000000
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int a[N],b[N]; vector<int> A,B;
struct node
{	int s,w;node *pre,*nxt;
	node(int _s=0,int _w=0):s(_s),w(_w){pre=nxt=0;}
}*S,*T;
inline void ins(node *p,int s,int w)
{node *x=new node(s,w);p->nxt->pre=x;x->nxt=p->nxt;p->nxt=x;x->pre=p;}
inline void del(node *x){x->pre->nxt=x->nxt;x->nxt->pre=x->pre;}
inline void work(int x,int k)
{	int la=x;
	for(node *i=S->nxt,*j=i->nxt;i!=T;i=j->nxt)
	{	if(i->s-la>k) break; k-=i->s-la; 
		int cur=3&i->w,gg=i->s; i->w=(i->w==2?1:2);
		if(i->nxt!=T&&i->nxt->s!=i->s+1){ins(i,i->s+1,cur);return;}
		for(j=i->nxt;j!=T;j=j->nxt)
		if(j->s==gg+1){del(j);gg=j->s;if(j->w!=cur){la=j->s;break;}}
		else{ins(j->pre,gg+1,cur);return;}
		if(j==T){ins(T->pre,gg+1,cur);return;}
	}
	A.push_back(la+k),B.push_back(la+k);
}
int main()
{	int n,m,k; cin>>n>>m>>k; S=new node(0,0); T=new node(0,0); S->nxt=T; T->pre=S;
	for(rint i=n;i>=1;i--) scanf("%1d",&a[i]);
	for(rint i=m;i>=1;i--) scanf("%1d",&b[i]);
	for(rint i=max(n,m);i>min(n,m);i--) if(a[i]||b[i]) ins(S,i,a[i]<<1|b[i]);
	for(rint i=min(n,m);i;i--)
	if(a[i]&b[i]) work(i,k);
	else if(a[i]||b[i]) ins(S,i,a[i]<<1|b[i]);
	for(node *i=S->nxt;i!=T;i=i->nxt)
	if(i->w==1) B.push_back(i->s); else A.push_back(i->s);
	sort(A.begin(),A.end(),greater<int>());
	for(rint i=0;i<A.size();i++)
	{	putchar('1');
		for(rint j=A[i]-1;j>(i+1<A.size()?A[i+1]:0);j--) putchar('0');
	}
	cout<<endl; sort(B.begin(),B.end(),greater<int>());
	for(rint i=0;i<B.size();i++)
	{	putchar('1');
		for(rint j=B[i]-1;j>(i+1<B.size()?B[i+1]:0);j--) putchar('0');
	}
	return 0;
}


Measured memory_bytes: 46404
al = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())
print(al[k-1])

Measured memory_bytes: 38384
package main

import "fmt"

func abs(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func main() {
	var a, b int
	var l, s int
	fmt.Scan(&a, &b)
	if a > b {
		l, s = a, b
	} else {
		l, s = b, a
	}

	k := abs(l+s) / 2
	if abs(l+s) % 2 == 0  && l > k && k > s {
		fmt.Println(k)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

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

public class Main
{

public static void main( String[] args ) throws Exception
{
	final Scanner sc = new Scanner( System.in );
	final int N = sc.nextInt();//総数
	final int K = sc.nextInt();//バッファサイズ
	
	//そのhにたどり着くまでの最低コストを記録するLinkedList
	final LinkedList<Integer> costList = new LinkedList<>();
	
	//それぞれのhを記録するLinkedList
	final LinkedList<Integer> heightList = new LinkedList<>();
	
	//初期化
	int firstH = sc.nextInt();
	for( int i = 0; i < K; ++i )
	{
		costList.add( 0 );
		heightList.add( firstH );
	}
	
	while( sc.hasNext() )
	{
		//次に調べるべき足場の高さを取得
		final int h = sc.nextInt();
		
		//直近のK個の足場それぞれから、今回の足場にたどり着く際の最低コストを探す
		final Iterator<Integer> cost = costList.iterator();
		final Iterator<Integer> height = heightList.iterator();
		int minCost = Integer.MAX_VALUE;
		for( int i = 0; i < K; ++i )
		{
			int costOfI = cost.next() + Math.abs( height.next() - h );
			if( costOfI < minCost )
			{
				minCost = costOfI;
			}
		}
		
		//今回の足場へ到達する最低コストが確定
		
		//不要となったK個前の情報を捨てる
		costList.remove( 0 );
		heightList.remove( 0 );
		
		//今回の足場の情報を追記する
		costList.add( minCost );
		heightList.add( h );
	}
	
	p( costList.getLast() );
}

public static void p( Object o )
{
	System.out.println( o );
}

}

Measured memory_bytes: 66108
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

class UnionFind:
    # n: 要素数
    def __init__(self, n):
        # par[i] < 0 ならば根（初期状態では全て根）
        # 根の場合、(集合サイズ * -1) を表す
        self.parents = [-1 for i in range(n)]

    # 要素iの根を求める
    def root(self, i):
        pi = self.parents[i]
        if pi < 0:
            return i
        else:
            ri = self.root(pi)
            self.parents[i] = ri
            return ri

    # 同じ集合か否か
    def issame(self, i, j):
        return self.root(i) == self.root(j)

    # 集合を併合
    def merge(self, i, j):
        ri = self.root(i)
        rj = self.root(j)
        if ri == rj:
            return
        if ri > rj:
            ri, rj = rj, ri
        self.parents[ri] += self.parents[rj]
        self.parents[rj] = ri

    # 属する集合サイズ
    def size(self, i):
        return -self.parents[self.root(i)]

def main():
    N, M = i2nn()
    AB = ii2nnn(M)
    n = N * (N-1) // 2  # 不便さの初期値
    nn = [n] * (M)
    uf = UnionFind(N)
    for i in range(len(AB)-1, 0, -1):
        a, b = AB[i]
        a -= 1
        b -= 1
        if uf.root(a) != uf.root(b):
            n -= uf.size(a) * uf.size(b)
            uf.merge(a, b)
        nn[i-1] = n

    for n in nn:
        print(n)

main()


Measured memory_bytes: 108892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

template<class T>
struct Dijkstra {
    const T inf = numeric_limits<T>::max() / 2 - 1;
    vector<T> dist;
    
    Dijkstra() {}
    Dijkstra(int n) {
        resize(n);
    }
    
    void resize(int n) {
        g.resize(n);
        dist.resize(n);
        used.resize(n);
    }
    
    void add_edge(int a, int b, T c) {
        g[a].emplace_back(c, b);
    }
    
    void get_distance(int a) {
        priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> pq;
        fill(dist.begin(), dist.end(), inf);
        fill(used.begin(), used.end(), false);
        pq.push(make_pair(0, a));
        while(!pq.empty()) {
            T d;
            int t;
            tie(d, t) = pq.top();
            pq.pop();
            if (used[t]) continue;
            used[t] = true;
            dist[t] = d;
            for (auto e : g[t]) {
                if (dist[e.second] <= (d + e.first)) continue;
                pq.push(make_pair(d + e.first, e.second));
            }
        }
    }
    
private:
    vector<vector<pair<int, T>>> g;
    vector<bool> used;
};

struct S {
    ll u, v, a, b;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    const ll inf = LONG_LONG_MAX / 2 - 1;
    ll n, m, s, t;
    cin >> n >> m >> s >> t;
    s--; t--;
    vector<S> uvab(m);
    rep(i, m) {
        cin >> uvab[i].u >> uvab[i].v >> uvab[i].a >> uvab[i].b;
        uvab[i].u--; uvab[i].v--;
    }
    Dijkstra<ll> yen(n);
    rep(i, m) {
        yen.add_edge(uvab[i].u, uvab[i].v, uvab[i].a);
        yen.add_edge(uvab[i].v, uvab[i].u, uvab[i].a);
    }
    yen.get_distance(s);
    Dijkstra<ll> snuke(n);
    rep(i, m) {
        snuke.add_edge(uvab[i].u, uvab[i].v, uvab[i].b);
        snuke.add_edge(uvab[i].v, uvab[i].u, uvab[i].b);
    }
    snuke.get_distance(t);
    priority_queue<pair<ll, ll>, vector<ll>, greater<ll>> pq;
    vector<ll> ans(n);
    rrep(i, n) {
        pq.push(yen.dist[i] + snuke.dist[i]);
        ans[i] = 1e15 - pq.top();
    }
    rep(i, n) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 23796
a=[]
for _ in[0]*int(input()):
 X,z=input(),[]
 for y in input():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=[len(z)]
print(*a,sep='\n')


Measured memory_bytes: 5620
#include <stdio.h>
int main(){
  while(1){
    int n,x,d;
    int i,j;
    int count;
    scanf("%d%d",&n,&x);
    if(n==0 && x==0) break;
    count=0;
    for(i=1;i<=n;i++){
      for(j=i+1;j<=n;j++){
	d=x-i-j;
    if(d<=n && d>j) {count++;}
      }
    }

    printf("%d\n",count);
  }
    return 0;
  
}



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

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

using namespace std;

int l, n;

int main(){
  cin >> l >> n;
  int s = 0;
  rep(i, n){
    int x, w;
    cin >> x >> w;
    s -= x * w;
  }
  if(s == 0){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
    if(s > 0){
      cout << 1 << ' ' << s << endl;
    }
    else{
      cout << -1 << ' ' << -s << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3084
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val W = sc.nextInt()
    val H = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()
    val r = sc.nextInt()
    println(if (x+r in (r..W) && y+r in (r..H)) "Yes" else "No")
}


Measured memory_bytes: 27416
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <set>
#include <bitset>
#include <regex>
#include <random>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exout(x) printf("%.10f\n", x)
const double pi = acos(-1.0);
const ll MOD = 1000000007;
const ll INF = 1e10;
const ll MAX_N = 1010;

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

bool dp[1010101];
ll dx[4] = { 0,0,-1,1 };
ll dy[4] = { -1,1,0,0 };
ll a[303];

//long longしか使わない
//素数は1より大きい
int main() {
	ll n, k;
	cin >> n >> k;
	rep(i, n) {
		cin >> a[i];
	}
	for (ll i = 0;i <= k;++i) {
		rep(j, n) {
			if (dp[i] == false) {
				dp[i + a[j]] = true;
			}
		}
	}
	if (dp[k])puts("First");
	else {
		puts("Second");
	}
	return 0;
}



Measured memory_bytes: 3748
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
int main(){
	int a;scanf("%d",&a);
	int G=0;
	int K=0;
	for(int i=0;i<a;i++){
		int p;scanf("%d",&p);
		if(p%2)K++;else G++;
	}
	if(K%2)printf("NO\n");else printf("YES\n");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000007
using namespace std;

int main(){
  int n;
  cin >> n;
  if(n%1000!=0) cout << 1000-n%1000 << endl;
  else cout << "0" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
using namespace std;
int main(){
	int n,a,b,c,d;
	while(cin >> n){
		int count=0;
		for(a=0;a<10;a++){
			for(b=0;b<10;b++){
				for(c=0;c<10;c++){
					for(d=0;d<10;d++){
						if(n==a+b+c+d)count++;
					}
				}
			}
		}
		cout << count<<endl;
	}
	return 0;
}

Measured memory_bytes: 2924
m,n=map(int,input().split())
a =[]
for _ in range(m):
    a.append(list(map(int,input().split())))
for index in range(m):
    a[index].append(sum(a[index]))
for a_column in a:
    print(' '.join(map(str, a_column)))
a.append([0]*(n+1))
for row_index in range(n+1):
    for a_column in a[:-1]:
        a[-1][row_index] += a_column[row_index]
print(' '.join(map(str, a[-1])))



Measured memory_bytes: 5688
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Convert;
using static System.Console;
using static System.Math;
class MainClass
{
	static void Main(string[] args)
	{
		Answer();
	}
	public static void Answer()
	{
		    var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var answer = input[0] - input[1];
      		if(answer < 0)
              answer = 0;
            Console.WriteLine(answer);
	}
}

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

int main(){
	int tri[3];
	int e[3];
	
	for(int i = 0; i < 3; i++) tri[i] = 0;
	while(true){
		scanf("%d %d %d", &e[0], &e[1], &e[2]);
		sort(e, e + 3);
		
		
		if(e[0] + e[1] > e[2]){
			if(e[0]*e[0] + e[1]*e[1] == e[2]*e[2]){
				tri[0]++;
			}
			else if(e[0]*e[0] + e[1]*e[1] > e[2]*e[2]){
				tri[1]++;
			}
			else if(e[0]*e[0] + e[1]*e[1] < e[2]*e[2]){
				tri[2]++;
			}
		}
		else break;
	}
	
	printf("%d %d %d %d\n", tri[0]+tri[1]+tri[2], tri[0], tri[1], tri[2]);
	
	return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int f = 0;
    int tmp = n;
    while(tmp){
        f = f + tmp%10;
        tmp = tmp/10;
    }
    if(n % f == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX = 123456*2;
int Sosuu[MAX] = {0};

void make_Sosuu() {
    for (int i=2; i<MAX; i++)
        Sosuu[i]=1;
    for (int i=2; i<MAX; i++) {
        if(Sosuu[i]) {
            for (int j=i*2; j<MAX; j+=i) {
                Sosuu[j] = 0;
            }
        }
    }
}

int main() {
    make_Sosuu();
    int n;
    while(scanf("%d", &n), n) {
        int count=0;
        for (int i=n+1; i<=n*2; i++) {
            if (Sosuu[i])
                count++;
        }
        printf("%d\n", count);
    }
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;


using namespace std;

#define debug(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(int i=0;i<(int)(n);i++)
#define foi(i,k,n) for(int i=(k); i<(int)(n); i+=1)
#define fod(i,n,k) for(int i=k; i>=(int)n; i-=1)
#define fast_io ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define endl "\n"

#define int long long
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007

#define fir first
#define sec second
#define pb push_back
#define mp make_pair

typedef long long llint;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<llint> VL;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MII;
typedef set<int> SI;
string tostr(int n) {stringstream rr;rr<<n;return rr.str();}
llint toint(string s) {stringstream ss(s); llint x; ss >> x; return x;}
//typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
//gp_hash_table<string, llint> table;


//int mpow(llint base, llint exp) {
  //base %= MOD;
  //llint result = 1;
  //while (exp > 0) {
    //if (exp & 1) result = ((llint)result * base) % MOD;
    //base = ((llint)base * base) % MOD;
    //exp >>= 1;
  //}
  //return result;
//}


//void makegraph(int n, int m){
	//int i, u, v;
	//while(m--){
		//cin>>u>>v;
		//u--, v--;
		//g[u].pb(v);
		//g[v].pb(u);
	//}
//}

//void dfs(int u, int par){
	//for(int v:g[u]){
		//if (v == par) continue;
		//dfs(v, u);
	//}
//}


// ------------------------------------------------------------------ILB----------------------------------------------------------------  //

const int MX = 1e6 + 100;

bool vis[MX];
int m[MX];

void solve(){
	int n;
	cin >> n;
	
	VI v(n);
	loop(i, n) { cin >> v[i]; m[v[i]]++; }
	
	sort(all(v));
	int ans = 0;
	
	loop(k, n){
		int num = v[k];
		if(m[num] > 1){ vis[num] = 1; continue; }
		bool div = 0;
		for(int i = 1; i <= sqrt(num); ++i){
			if(num % i == 0 && (vis[i] == 1 || vis[num / i] == 1)){
				div |= 1;
			}
		}
		if(!div) ans++;
		vis[num] = 1;
	}
	
	//for(auto i : v) { debug(vis[i]); ans += (vis[i] == 0); }
	
	cout << ans;
}




int32_t main() {
	fast_io;
    int t = 1;
    //cin >> t;
    //int xx = 0
    while(t--) {
		//xx++;
		//cout << "Case ";
      solve();
    }
    return 0;
}



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

using namespace std;

int main()
{
    size_t sum = 0;
    string s;
    while( cin >> s ) {
        for( auto it=s.cbegin(); it<s.cend(); ++it )
        {
            if ( *it >= '0' && *it <= '9' ) {
                string t;
                t += *it;
                for( it=it+1; it < s.cend() && *it >= '0' && *it <= '9'; ++it )
                    t += *(it);

                sum += atoi( t.c_str() );
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 1192
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    string s,t;
    cin>>s>>t;
    ll m=s.length();
    for(int i=0;i<=s.length()-t.length();i++)
    {
        ll c=0;
        for(int j=i;j<=i+t.length()-1;j++)
        {
            if(s[j]!=t[j-i])
            c++;
        }
        m=min(m,c);
    }
    cout<<m;}

Measured memory_bytes: 3660
#include "bits/stdc++.h"

using ll = long long;
using namespace std;

void solve() {
   int n;
   cin >> n;
   vector <ll> a(n);
   vector <int> b(n);
   for(int i = 0; i < n; i++) {
      cin >> a[i] >> b[i];
   }

   ll ans = 0;
   for(int i = n - 1; i >= 0; i--) {
      a[i] += ans;
      ans += (b[i] - (a[i] % b[i])) % b[i];
   }
   cout << ans << endl;
}


int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solve();
   }
 
   return 0;
}

Measured memory_bytes: 4528
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<ll,ll> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j
// map 初期値0 for(auto itr=mp.begin();itr!=mp.end();++itr) itr->fi itr->se で全探索
// for(auto u:mp) u.fi u.se も可能
//n個のgcd,lcmは一つずつみて更新していく
//大きな数を扱うときは素因数分解した形で持っておく
// (l/a[i]) = l*powmod(a[i],MOD-2)%MOD;
//auto itr=lower_bound(ALL(a),key) a[itr-a.begin()]

int main(){
    int n; cin >> n;
    vector<P> v;
    rep(i,n){
        int a; cin >> a;
        v.pb({a,i});
    }
    sort(ALL(v));
    int ans=0;
    rep(i,n){
        if(abs(i-v[i].se)%2==1) ans++;
    }
    ans/=2;
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 2420
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    s[3] = '8';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    
    rep(i,3){
        rep(j,3){
            char c;cin>>c;
            if(j==i){
                cout<<c;
            }
        }
    }
    
    cout<<endl;



return 0;
}


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

#define INF 1e9
#define MAX 1005
#define xx first
#define yy second
#define pb push_back
#define mp make_pair
#define ull long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define nl '\n'
#define zai <<' '<<
#define all(a) a.begin(),a.end()
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int MOD=1000000007;

bool a[MAX][MAX];
int dp[MAX][MAX];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int n,m;
	char tmp;
	cin >> n >> m;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin >> tmp;
			if(tmp=='#')a[i][j]=1;
		}
	}
	if(!a[0][0])dp[0][0]=1;
	else{
		cout << 0;
		return 0;
	}
	for(int i=1;i<m;i++){
		if(!a[0][i] && dp[0][i-1]!=INF)dp[0][i]=1;
		else dp[0][i]=INF;
	}
	for(int i=1;i<n;i++){
		if(!a[i][0] && dp[i-1][0]!=INF)dp[i][0]=1;
		else dp[i][0]=INF;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(a[i][j]==0){
				if(dp[i-1][j]==INF && dp[i][j-1]==INF){
					dp[i][j]=INF;
				}
				else{
					if(dp[i-1][j]==INF && dp[i][j-1]!=INF){
						dp[i][j]=(dp[i][j-1])%MOD;
					}
					else if(dp[i-1][j]!=INF && dp[i][j-1]==INF){
						dp[i][j]=(dp[i-1][j])%MOD;
					}
					else if(dp[i-1][j]!=INF && dp[i][j-1]!=INF){
						dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
					}
				}
			}
			else{
				dp[i][j]=INF;
			}
		}
	}
	if(dp[n-1][m-1]!=INF)cout << dp[n-1][m-1];
	else cout << 0;
	return 0;
}

Measured memory_bytes: 5248
int zeller(int Y,int M,int D){if(++M<4)Y-=1,M+=12;int y=Y/100,z=y%100;return (21*y/4+5*z/4+13*M/5+D)%7;}
char *W[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
main(m,d){for(;scanf("%d%d",&m,&d),m;)puts(W[zeller(2004,m,d)]);exit(0);}

Measured memory_bytes: 1648
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	char a;
	cin >> a;
	if(a == 'a' || a == 'i' || a == 'u' || a == 'e' || a == 'o')
		cout << "vowel" << endl;
	else cout << "consonant" << endl;
	return 0;
}


Measured memory_bytes: 256
<?php

$dirs = array(
	array(1, 0),
	array(-1, 0),
	array(0, 1),
	array(0, -1)
);

while(TRUE) {
	$map = array();
	for ($i = 0; $i < 12; $i++) {
		$line = trim(fgets(STDIN));
		$map[] = $line;
	}
	// マップのロード完了
	$count = 0;
	for ($i = 0; $i < 12; $i++) {
		for ($j = 0; $j < 12; $j++) {
			if ($map[$i][$j] == 1) {
				$count++;
				bfs($i, $j);
			}
		}
	}
	echo $count . "\n";
	$line = fgets(STDIN);
	if ($line === false) {
		break;
	}
}

function bfs($i, $j) {
	global $map, $dirs;
	$que = array(array($i, $j));
	while (!empty($que)) {
		$point = array_shift($que);
		$x = $point[0];
		$y = $point[1];
		// 探索済み
		$map[$x][$y] = 0;
		foreach ($dirs as $d) {
			$dx = $d[0];
			$dy = $d[1];
			if (isset($map[$i + $dy][$j + $dx]) && $map[$i + $dy][$j + $dx] == 1) {
				$que[] = array($i + $dy, $j + $dx);
				bfs($i + $dy, $j + $dx);
			}
		}
	}
}

Measured memory_bytes: 7000
#include <iostream>
#include <stack>
#include <string>   // stoi
using namespace std;

int main() {
    string operators = "+-*";
    stack<int> st;
    string word;
    while (cin >> word) {
        if (operators.find(word) != string::npos) {
            int r = st.top(); st.pop();
            int l = st.top(); st.pop();
            if (word == "+") st.push(l + r);
            if (word == "-") st.push(l - r);
            if (word == "*") st.push(l * r);
        } else {
            st.push(stoi(word));
        }
    }
    cout << st.top() << endl;
    return 0;
}


Measured memory_bytes: 3140
n, m = map(int, input().split())
a = []
for i in range(m):
    a.append(list(map(int, input().split())))
haba = a[0]
for i in a:
    if haba[0] <= i[0] <= haba[1]:
        haba[0] = i[0]
    elif haba[1] < i[0]:
        print(0)
        exit()
    if haba[0] <= i[1] <= haba[1]:
        haba[1] = i[1]
    elif i[1] < haba[0]:
        print(0)
        exit()
if n < haba[0]:
    ans = 0
elif haba[0] <= n <= haba[1]:
    ans = n - haba[0] + 1
else:
    ans = haba[1] - haba[0] + 1
print(ans)

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


int main()
{
  int n, m;
  ll k;
  cin >> n >> m >> k;
  vector<ll> a(n+1), b(m+1);
  rep(i,n) cin >> a[i+1];
  rep(i,m) cin >> b[i+1];
  rep(i,n) a[i+1] += a[i];
  rep(i,m) b[i+1] += b[i];
  
  int ans = 0;
  rep(i,n+1)
  {
    if(a[i] > k) break;
    int j = (int)(upper_bound(b.begin(), b.end(), k - a[i]) - b.begin());
    j--;
    ans = max(ans, i + j);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 6348
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#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(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  string s;
  cin >> s;

  bool f = true;
  REP(i,3) if(s[i] == s[i+1]) f = false;

  if(f) cout << "Good" << endl;
  else cout << "Bad" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
   int n,i,highest=0,highest_pos=0,tmp=0;
   scanf("%d",&n);

   int l[n];
   for(i=0;i<n;i++){
      scanf("%d",&l[i]);
      if(highest<l[i]){highest=l[i]; highest_pos=i;}
   }

   for(i=0;i<n;i++){
      if(i!=highest_pos)tmp+=l[i];
   }

   if(highest<tmp) printf("Yes\n");
   else printf("No\n");
   return 0;
}

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

int n, temp;
int ans1, ans2;
int koho1, koho2;
vector<int> ary;
int main() {
	cin >> n;
	for(int i=0; i<n; i++) {
		cin >> temp;
		ary.push_back(temp);
	}

	// ソートする
	sort(ary.begin(), ary.end());
	ans1 = ary[n-1];
	// 答えの候補2つ
	if(ans1 % 2 == 1) {
		koho1 = ans1 / 2;
		koho2 = koho1 + 1;
	}
	else {
		koho1 = ans1 / 2;
		koho2 = koho1;
	}
	int lower1, upper1, lower2, upper2;
	lower1 = ary[lower_bound(ary.begin(), ary.end(), koho1) - ary.begin()];
	upper1 = ary[lower_bound(ary.begin(), ary.end(), koho1) - ary.begin() - 1];
	lower2 = ary[lower_bound(ary.begin(), ary.end(), koho2) - ary.begin()];
	upper2 = ary[lower_bound(ary.begin(), ary.end(), koho2) - ary.begin() - 1];

	int x, y, z, w;	
	x = abs(lower1 - koho1);
	y = abs(upper1 - koho1);
	z = abs(lower2 - koho2);
	w = abs(upper2 - koho2);
	if(lower1 == ans1) {
		x = 1000000000;
	}
	if(upper1 == ans1) {
		x = 1000000000;
	}
	if(lower2 == ans1) {
		x = 1000000000;
	}
	if(upper2 == ans1) {
		x = 1000000000;
	}
	ans2 = lower1;
	if(x > y) {
		x = y;
		ans2 = upper1;
	}
	if(x > z) {
		x = z;
		ans2 = lower2;
	}
	if(x > w) {
		x = w;
		ans2 = upper2;
	}
	cout << ans1 << ' ' << ans2 << endl;

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s,w;cin>>s>>w;
    if(w>=s){
        cout<<"unsafe"<<endl;
    }else{
        cout<<"safe"<<endl;
    }
}

Measured memory_bytes: 3640
k, n = map(int, input().split())
a = list(map(int, input().split()))

d = [0] * n
for i in range(n-1):
    d[i] = a[i+1] - a[i]
d[n-1] = k - a[n-1] + a[0]

print(sum(d) - max(d))

Measured memory_bytes: 26444
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iomanip>

using namespace std;

typedef pair<int, int> P_;
typedef pair<double, P_> P;

const double PI = 3.1415926535897932384526;

vector<P> p;



int main(){
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        double x, y;
        cin >> x >> y;
        double t = atan2(y, x);
        p.push_back(P(t, P_(x, y)));
    }
    
    double ans = 0.0;
    sort(p.begin(), p.end());
    for(int i = 0; i < N; i++){
        double sx = 0.0, sy = 0.0;
        for(int j = 0; j < N; j++){
            int k = (i+j)%N;
            sx += p[k].second.first;
            sy += p[k].second.second;
            ans = max(ans, sqrt(sx*sx+sy*sy));
        }
    }
    cout << fixed << setprecision(10);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
#define pii pair<int,int>
#define pll pair<long long,long long>
#define usi unordered_set<int>
#define usl unordered_set<long long>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umll unordered_map<long long,long long>
#define fi first
#define sec second
#define pub push_back
#define pob pop_back
#define B begin
#define E end
#define mp make_pair
#define vi vector<int>
#define vl vector<long long>
#define vii vector<pii>
#define vll vector<pll>
#define deb(x) cout<<#x<<": "<<x<<"\n"
#define endl '\n'
#define PIE 3.141592653
#define MOD 1000000007
#define f(i,a,b,c) for(ll i=a;i<=b;i+=c)
#define frev(i,n,b,c)  for(ll i=n;i>=b;i-=c)
const ll inf = 1000000000000000000;
using namespace std;
 
//            < = = = = =    GCD     = = = = = >
 
ll gcd(ll a,ll b)
{
    if(a<b) gcd(b,a);
    if(b==0)    return a;
    return gcd(b,a%b);
}
 
//            < = = = = =    LCM     = = = = = >
 
ll lcm(ll a,ll b) 
{ 
    ll x=(a/gcd(a,b))*b; 
    return x;
}
 
//            < = = = = =    power  x^n     = = = = = >
 
ll power(ll x , ll n , ll m=inf){
    if(x==0){
        return 0;
    }
    if(n==0){
        return 1;
    }
    ll ans;
    if(n%2==0){
        ll smallAns = power(x,n/2,m);
        ans = (smallAns*smallAns)%m;        
    } else {
        ll smallAns = power(x,n-1,m);
        ans = x;
        ans = (ans*smallAns)%m;
    }
    // for negative values also
    return (ans+m)%m;
    
}
 
//            < = = = = =    CHECK FOR PRIME     = = = = = >
 
bool isprime(int n){
   if(n==2){
        return true;
    }
    else if(n%2==0){
        return false;
    }
    else{
        for(int i=3;i*i<=n;i+=2){
            if(n%i==0){
                return false;
            }
        }
        return true;
    }
}
 
//            < = = = = =    SOLVE    = = = = = >
 
// bool cmp(pll x, pll y){
//     ll dx = min(2*(x.first),x.second)-min(x.first,x.second);
//     ll dy = min(2*(y.first),y.second)-min(y.first,y.second);
//     return dx>dy;
// }
 
// void rec(int n){
//     if(){
//         return;
//     }
    
//     return;
// }
 
int solve() {fastio
    
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
    

    return 0;
}
    
//            < = = = = =    MAIN     = = = = = >
 
int main() {fastio

    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif

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

    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main()
{
  int h1, h2, m1, m2, k;
  scanf("%d%d%d%d%d", &h1, &m1, &h2, &m2, &k);
  int result = (h2*60+m2)-(h1*60+m1) - k; 


  printf("%d\n", result);
  return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    string s1,s2;
    while(cin>>s1>>s2)
    {
        if(s1.size()>s2.size())puts("GREATER");
        else if(s1.size()==s2.size())
        {
            if(s1>s2)puts("GREATER");
            else if(s1==s2)puts("EQUAL");
            else puts("LESS");
        }
        else puts("LESS");
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
//written by: rishav2416
#include <bits/stdc++.h>
#define ll long  long
#define lli long long int
#define ld long double
#define mod 1000000007
#define max_char 128
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define lbd lower_bound
#define ubd upper_bound
#define PI 3.141592653589793238
#define pf push_front
#define all(x) x.begin(),x.end()
#define input(arr,n) for(ll c1=0;c1<n;c1++)cin>>arr[c1];
#define arrinit(arr,n,k) for(ll c1=0;c1<n;c1++) arr[i]=k;
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define revrep(i,a,n) for(ll i=a; i>=n ; i--)
#define mems(x, y) memset(x, y, sizeof(x))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define INF 1e18a



ll power(ll base,ll pow, ll mo)
{
   ll res=1;
   while(pow)
   {
        if (pow%2!=0)  res=(res*base)%mo;
        base=(base*base)%mo;
        pow/=2;
   }
   return res;
}


std::string str="All Good Till Here";

/////////////////////////////////////////////////////////////////////////////////

int32_t main()
{
    fastio
	ll tt,i,j,x=0;
	//cin>>tt;
  tt=1;
	while(tt--)
	{
    ll n,k;
    cin>>n>>k;
    ll d, a[n]={0};
    rep(i,0,k)
    {
      cin>>d;
      ll p[d];
      input(p,d);
      rep(j,0,d)
      a[p[j]-1]++;
    }
    rep(i,0,n)
    {
      if(a[i]==0)x++;
    }
    cout<<x<<"\n";
	}
    return 0;
}


Measured memory_bytes: 3612
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    M=13
    S=input()[::-1]
    n=len(S)
    dp=[0]*M
    dp[0]=1
    for i in range(n):
        ndp=[0]*M
        s=S[i]
        d=pow(10,i,M) # d=10^i mod 13
        if(s=='?'):
            for j in range(10):
                for m in range(M):
                    ndp[(m+j*d)%M]+=dp[m]
                    ndp[(m+j*d)%M]%=MOD
        else:
            s=int(s)
            for m in range(M):
                ndp[(m+s*d)%M]+=dp[m]
        dp=ndp
    print(dp[5])
resolve()

Measured memory_bytes: 43244
#include<stdio.h>

int main(){
	int x,y,c;
	int cnt=0;
	scanf("%d %d %d",&x,&y,&c);
	for(int i=x;i<=y;i++){
		if(c%i==0)cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#include <atcoder/lazysegtree>

using namespace std;

#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif


inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };

struct S
{
    long long int zero, one, inv;
};

using F = bool;
S op(S x, S y){return S{x.zero + y.zero, x.one + y.one, x.inv + y.inv + x.one*y.zero};}
S e(){return S{0,0,0};}
S mapping(F f, S x){
    if(!f) return x;
    else return S{x.one, x.zero, x.zero*x.one - x.inv};
}
F composition(F f, F g){ return f^g;}
F id(){return false;}

int N,Q;
vector<S> A;
inline void input(){
    fast_io();
    cin >> N >> Q;
    A.resize(N);
    for (int i = 0; i < N; i++)
    {
        int a; cin >> a;
        if(a==0){
            A[i] = S{1,0,0};
        }
        else{
            A[i] = S{0,1,0};
        }
    }
}

inline int solve(){
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(A);
    for (int i = 0; i < Q; i++)
    {
        int type, l, r;
        cin >> type >> l >> r;
        l--;
        if(type==1){
            seg.apply(l, r, true);
        }
        else{
            cout << seg.prod(l, r).inv << endl;
        }
    }
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 20352
package main

import (
	f "fmt"
)

func main() {
	a := [...]string{"a", "b", "c", "d", "e", "f", "g",
		"h", "i", "j", "k", "l", "n", "m", "o",
		"p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"}

	var str string
	f.Scanf("%s", &str)

	for i := 0; i < 26; i++ {
		if a[i] == str {
			f.Printf("%s\n", a[i+1])
			break
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <map>
#include <cmath>

using namespace std;

#define mod 998244353
map<long long, long long> a;

long long quickpow(long long a, long long b){
    long long ans = 1;
    a = a % mod;
    while(b){
        if(b % 2) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}


int main() {
    long long n, t, flag = 1, maxn = 0;
    long long ans = 1;
    cin >> n;
    for (long long i = 0; i < n; i++) {
        cin >> t;
        a[t]++;
        maxn = max(maxn, t);
        if((i == 0 and t != 0) or (i != 0 and t == 0)) flag = 0;
    }
    if (flag) {
        for (long long i = 1; i <= maxn; i++) {
            ans = (ans % mod * quickpow(a[i - 1], a[i]) % mod) % mod;
        }
        cout << ans % mod << endl;
    } else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>

/* <m, n> が <p, q> の約数であるか判定する */
int isDivisor(int p, int q, int m, int n) {
	int x = m * m + n * n;
	/* ゼロ除算 */
	if (x == 0) return 0;
	/* <1, 0>, <0, 1>, <-1, 0>, <0, -1>, <m, n>, <-n, m>, <-m, -n>, <n, -m> */
	if (x == 1 || x == p * p + q * q) return 0;
	/* 判定 */
	return (m * p + n * q) % x == 0 && (m * q - n * p) % x == 0;
}

int main(void) {
	int l, p, q; /* 入力 */

	/* データセット毎の処理 */
	for (scanf("%d", &l); l > 0 ; l--) {
		scanf("%d%d", &p, &q);

		/*
			与えられたイチョウ数 <p, q> が任意のイチョウ数 <m, n> で割り切れるかを調べる。
			<m, n> * <x, y> = <p, q> なら (m^2 + n^2)(x^2 + y^2) = p^2 + q^2 である。
			x^2 + y^2 > 0 なので <m, n> は m^2 + n^2 <= p^2 + q^2 を満たす。
		*/
		int prime = 1;
		int m, n;
		for (m = 0; m <= p * p + q * q; m++) for (n = 0; n <= p * p + q * q - m * m; n++) {
			if (isDivisor(p, q, m, n)) {
				prime = 0;
				goto _break;
			}
		}
		_break:;

		if (prime) printf("%c\n", 'P');
		else printf("%c\n", 'C');
	}

	return 0;
}

Measured memory_bytes: 600