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

int main(void) {
    int w, h, i, j, x, y;
    char current_tile;
    
    for(;;) {
        
        scanf("%d %d", &h, &w);
    
        if(h==0 && w==0) break;
        
        char tiles[h][w];
        int flags[h][w];
    
        for(i=0; i<h; i++) {
            scanf("%s", tiles[i]);
        }
        for(i=0; i<h; i++) {
            for(j=0; j<w; j++) {
                flags[i][j] = 0;
            }
        }
        
        x = 0, y = 0;
    
        while(1) {
            current_tile = tiles[y][x];
            
            if(current_tile == '>') {
                x+=1;
            } else if(current_tile == '<') {
                x-=1;
            } else if(current_tile == '^') {
                y-=1;
            } else if(current_tile == 'v') {
                y+=1;
            } else if(current_tile == '.') {
                printf("%d %d\n", x, y);
                break;
            }
            
            if(flags[y][x]==1) {
                printf("LOOP\n");
                break;
            } else {
                flags[y][x] = 1;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 664
#include<stdio.h>
int main(void)
{
	int a,b,k,cnt=0,ans=0,i;
	scanf("%d %d %d",&a,&b,&k);
	for(i=100;i>=1;i--){
		if(a%i==0 && b%i==0){
			cnt=cnt+1;
			ans=i;
		}
		if(cnt==k){
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
from collections import Counter

n = int(input().rstrip())
counter = Counter(map(int, input().rstrip().split(' ')))

x = y = 0
for k, v in counter.items():
    if v >= 2 and k > y:
        if k >= x:
            if v >= 4:
                x = y = k
            else:
                x, y = k, x
        else:
            y = k

print(x * y)

Measured memory_bytes: 24104
#include <bits/stdc++.h>
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define debug(var) std::cout << #var << " : " << var;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;

int main(){


	int A, B, C, D; std::cin >> A >> B >> C >> D;
	int ans = std::min(A, B) + std::min(C, D);

	std::cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    sort(a, a + n);
    if (a[0] == 0)
        cout << "0"
             << "\n";
    else
    {
        int mul = 1;
        for (int i = 0; i < n; ++i)
        {

            if (a[i] > 1000000000000000000 / mul)
            {
                mul = -1;
                break;
            }
            mul *= a[i];
        }
        cout << mul << "\n";
    }
}

Measured memory_bytes: 4424
package main

import "fmt"

func main() {
	var (
		n, k int
		s    string
	)
	fmt.Scan(&n, &k, &s)

	for i := 0; i < n; i++ {
		if i == k-1 {
			switch s[i] {
			case 'A':
				fmt.Printf("%s", "a")
			case 'B':
				fmt.Printf("%s", "b")
			case 'C':
				fmt.Printf("%s", "c")
			}
		} else {
			fmt.Printf("%s", string(s[i]))
		}
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;


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

  int ans = 0;
  if(s == "SUN") ans = 7;
  if(s == "MON") ans = 6;
  if(s == "TUE") ans = 5;
  if(s == "WED") ans = 4;
  if(s == "THU") ans = 3;
  if(s == "FRI") ans = 2;
  if(s == "SAT") ans = 1;

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

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    int n,a,b,tmp;
    cin >> n;
    set<int> edges[n];
    vector<pair<int,int>> num_edges;
    int c[n] = {};
    for(int i=0;i<n-1;++i)
    {
        cin >> a >> b;
        a--;
        b--;
        edges[a].insert(b);
        edges[b].insert(a);
    }

    for(int i=0;i<n;++i){
        cin >> c[i];
    }
    sort(c, c+n);
    int res_max = 0;
    int res[n] = {};
    for(int i=0;i<n-1;++i)
    {
        int score = c[i];
        //dump(score)
        int min_num_edges = 1 << 30;
        int id_node = -1;
        for(int j=0;j<n;++j)
        {
            if(edges[j].size() == 0) continue;
            if(edges[j].size() < min_num_edges)
            {
                min_num_edges = edges[j].size();
                id_node = j;
            }
        }

        res_max += score * min_num_edges;
        //dump(id_node);
        //dump(min_num_edges);
        res[id_node] = score;
        for(int dst: edges[id_node])
        {
            edges[dst].erase(id_node);
        }
        edges[id_node].clear();
    }
    cout << res_max << endl;
    for(int i=0;i<n;++i)
    {
        cout << (res[i] == 0 ? c[n-1] : res[i]) << (" \n")[i==(n-1)];
    }
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    for(int i=1;i<=5;i++){
        int tmp;cin>>tmp;
        if(tmp==0){co(i);return 0;}
    }
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <math.h>
 
int main()
{
    int i, n;
    int x[100], y;
    int d1=0, di=0;
    double d2=0, d3=0;
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%d", &x[i]);
    }
    for(i=0; i<n; i++) {
        scanf("%d", &y);
        y=abs(y-x[i]);
        d1+=y;
        d2+=y*y;
        d3+=y*y*y;
        if(di<y) di=y;
    }
    printf("%d\n%f\n%f\n%d\n", d1, sqrt(d2), pow(d3, 1.0/3.0), di);
    return 0;
}

Measured memory_bytes: 672
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
const int INF=2147483647;
const int maxn=100000;
const int maxm=500000;
int n,m,s;
int fir[maxn],nxt[maxm],to[maxm],val[maxm],cnt;
void add_edge(int u,int v,int w)
{
    nxt[++cnt]=fir[u];fir[u]=cnt;to[cnt]=v;val[cnt]=w;
}
int dis[maxn],inq[maxn];
void SPFA(int s)
{
    for(int i=0;i<n;i++) dis[i]=INF; dis[s]=0;
    queue<int>Q;Q.push(s);
    while(!Q.empty()) {
        int u=Q.front(); Q.pop();
        for(int e=fir[u];e;e=nxt[e]) {
            int v=to[e],w=val[e];
            if(dis[u]+w<dis[v]) {
                dis[v]=dis[u]+w;
                if(!inq[v]) Q.push(v);
            }
        }
    }
}
int main()
{
    scanf("%d%d%d",&n,&m,&s);
    for(int u,v,w,i=0;i<m;i++) {
        scanf("%d%d%d",&u,&v,&w);
        add_edge(u,v,w);
    }
    SPFA(s);
    for(int i=0;i<n;i++){
	if (dis[i] == INF) {
		printf("INF\n");
	}else{
		printf("%d\n",dis[i]);
	}
}
    return 0;
}

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

int b[3];
int min = INT_MAX;

int calc(std::vector<int> l, std::vector<int> v)
{
    int mp[4] = {};
    int ll[4] = {};
    for (size_t i = 0; i < v.size(); i++) {
        if (ll[v[i]] != 0)
            mp[v[i]] += 10;
        ll[v[i]] += l[i];
    }

    int now = 0;
    for (int i = 0; i < 3; i++) {
        if (ll[i] == 0)
            return -1;
        now += abs(ll[i] - b[i]) + mp[i];
    }

    if (min > now) {
        min = now;
    }
    return 0;
}

int dfs(int d, std::vector<int> l, std::vector<int> v)
{
    if (d == -1)
        return calc(l, v);

    for (int i = 0; i < 4; i++) {
        v[d] = i;
        dfs(d-1, l, v);
    }

    return 0;
}

int main()
{
    int n;
    std::cin >> n >> b[0] >> b[1] >> b[2];
    std::vector<int> l(n);
    for (int i = 0; i < n; i++) { std::cin >> l[i]; }

    std::vector<int> v(n);
    dfs(n-1, l, v);

    std::cout << min << std::endl;
    return 0;
}


Measured memory_bytes: 256
#pragma region Header

#include <iostream>
#include <iomanip>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <numeric>
#include <bitset>
#include <cstdint>
#include <stdexcept>
using namespace std;

// 整数型

using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;

// [0,n)を昇順/降順でループ

#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)

// [a,b)を昇順/降順でループ

#define FOR(i, a, b) for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define FORD(i, a, b) for (int i = static_cast<int>(b) - 1; i >= static_cast<int>(a); --i)

template <typename T>
int SZ(T x)
{
    return static_cast<int>(x.size());
}

#pragma endregion

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    int n, r;
    cin >> n >> r;
    cout << r + max(100 * (10 - n), 0) << endl;

    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

signed main(){
  vector<int> b(26,INF);
  int n;
  cin>>n;
  rep(i,n){
    vector<int> a(26);
    string s;cin>>s;
    rep(i,s.size())a[s[i]-97]++;
    rep(i,26)if(a[i]<b[i])b[i]=a[i];
  }
  rep(i,26)if(b[i]==INF)b[i]=0;
  rep(i,26)if(b[i]>0)rep(j,b[i])cout<<(char)(i+'a');
  cout<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int main(){
    while( true ){
        int n;
        cin >> n;

        if(n == 0){
            break;
        }

        int a[n];

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

        sort(a,a+n);

        for(int i = 2;i < n-1;i++){
            a[1]+=a[i];
        }

        cout << a[1]/(n-2) << endl;
    }   
 
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int d[11][11];
bool used[11][11];
vector<int> route;
int ans,ns,nl;
void dfs(int ds,int c,vector<int> v){
    int cnt=0;
    FOR(i,1,ns+1){
        if(!used[ds][i]){
            ++cnt;continue;
        }
        used[ds][i]=used[i][ds]=false;
        vector<int> v2=v;
        v2.pb(i);
        dfs(i,c+d[ds][i],v2);
        used[ds][i]=used[i][ds]=true;
    }
    if(cnt==ns&&ans<c){
        ans=c;route=v;
    }
}
int main(){
    while(cin>>ns>>nl,ns){
        ans=0;
        memset(used,0,sizeof(used));
        int src,dst,dis;
        rep(i,nl){
            cin>>src>>dst>>dis;
            used[src][dst]=used[src][dst]=true;
            d[src][dst]=d[dst][src]=dis;
        }
        FOR(i,1,ns+1){
            vector<int> vi2;
            vi2.pb(i);
            dfs(i,0,vi2);
        }
        cout<<ans<<endl;
        rep(i,route.size()-1) cout<<route[i]<<" ";
        cout<<route.back()<<endl;
    }
    return 0;
}

Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
template <typename T,typename E>
struct SegmentTree{
  typedef function<T(T,T)> F;
  typedef function<T(T,E)> G;
  int n;
  F f;
  G g;
  T d1;
  E d0;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int n_,F f,G g,T d1,
	      vector<T> v=vector<T>()):
    f(f),g(g),d1(d1){
    init(n_);
    if(n_==(int)v.size()) build(n_,v);
  }
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,d1);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[i+n-1]=v[i];
    for(int i=n-2;i>=0;i--)
      dat[i]=f(dat[i*2+1],dat[i*2+2]);
  }
  void update(int k,E a){
    k+=n-1;
    dat[k]=g(dat[k],a);
    while(k>0){
      k=(k-1)/2;
      dat[k]=f(dat[k*2+1],dat[k*2+2]);
    }
  }
  inline T query(int a,int b){
    T vl=d1,vr=d1;
    for(int l=a+n,r=b+n;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,dat[(l++)-1]);
      if(r&1) vr=f(dat[(--r)-1],vr);
    }
    return f(vl,vr);
  }

};
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n,q;
  cin>>n>>q;
  SegmentTree<int,int> rmq(n,
			   [](int a,int b){return a+b;}, //F to parents
			   [](int a,int b){return a+b;}, //G update num b to a
			   0);
  for(int i=0;i<q;i++){
    int c,x,y;
    cin>>c>>x>>y;
    if(c) cout<<rmq.query(x,y+1)<<endl;
    else rmq.update(x,y);
  }
  return 0;
}


Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll> 
#define inf 100000000000
#define mod 1000000007


int main()
{
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++)cin >> a[i];
    ll hash[n+1];
    for(ll i=1;i<=n;i++)hash[i] = -1;
    ll cnt1 = 1;
    for(ll i=0;i<n;i++)
    {
        if(a[i] == cnt1)
        {
            hash[cnt1] = i;
            cnt1++;
        }
    }

    
    ll cnt = -1 , sum = 0;
    for(ll i=1;i<=n;i++)
    {
        if(hash[i] == -1)
        {
            sum += (n-cnt-1);
            break;
        }
        else
        {
            sum += (hash[i]-cnt-1);
            cnt = hash[i];
        }
        
    }
    if(sum < n)
    cout << sum << endl;
    else cout << -1;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

const int mxN = 1e5+1;

int n, m;
vector<int> adj[mxN];
bool vis[mxN];
deque<int> t;

void topo(int u) {
    vis[u] = true;
    for (auto& v : adj[u]) {
        if (vis[v]) continue;
        topo(v);
    }
    t.push_front(u);
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }

    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        adj[x].push_back(y);
    }

    for (int i = 1; i <= n; i++) if (!vis[i]) topo(i);

    vector<int> dp(n+1, 0);

    dp[t[0]] = 0;
    for (auto& u : t) {
        for (auto& v : adj[u]) {
            dp[v] = max(dp[v], dp[u]+1);
        }
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) ans = max(ans, dp[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8704
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<set>
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 int MOD = 1000000007;
const int INF = 2000000000;

    string S[101],T;
    ll N,ans=0;
    ll A[110];
    bool F=true;
int main(){
    ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){cin>>S[i];}
    REP(i,N){
        if(S[i]=="Y"){
            cout<<"Four";
            return 0;
        }
    }
    cout<<"Three"<<endl;
    return 0;
}


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

using namespace std;

char solve(char c){
	if(c == 'A')return 'T';
	if(c == 'T')return 'A';
	if(c == 'C')return 'G';
	return 'C';
}

int main(){
	#ifdef EVAL 
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	char c;
	cin >> c;
	cout << solve(c);
}

Measured memory_bytes: 256
int main()
{
  int t[14];
  int a,b,c,d,e,i,x;
  for(;i=~scanf("%d,%d,%d,%d,%d",&a,&b,&c,&d,&e);)
    {
      if(i==0)
	break;
      for(i=0;i<14;i++)
	t[i]=0;
      t[a]++;
      t[b]++;
      t[c]++;
      t[d]++;
      t[e]++;
      for(x=i=0;i<14;i++)
	if(t[i]>3)
	  x=1,puts("four card");
      if(x!=0)
	continue;
      for(x=i=0;i<14;i++)
	{
	  if(t[i]==3)
	    x+=3;
	  if(t[i]==2)
	    x+=2;
	}
      if(x==5)
	{
	  puts("full house");
	  continue;
	}
     if (t[1]==1&&t[10]==1&&t[11]==1&&t[12]==1&&t[13]==1)
       {
	 puts("straight");
	 continue;
       }
       for(x=i=0;i<10;i++)
	if(t[i]==1&&t[i+1]==1&&t[i+2]==1&&t[i+3]==1&&t[i+4]==1)
	  x=1,puts("straight");
     if(x!=0)
       continue;
      
      for(x=i=0;i<14;i++)
	if(t[i]>2)
	  x=1,puts("three card");
      if(x!=0)
	continue;

      for(x=i=0;i<14;i++)
	if(t[i]>1)
	  x++;
      if(x==1)
	{
	  puts("one pair");
	    continue;
	}
      if(x==2)
	{
	  puts("two pair");
	  continue;
	}
      puts("null");
    }
  exit(0);
}

Measured memory_bytes: 580
N = int(input())
A = list(map(int, input().split()))

while True:
    MOD = min(A)
    for i in range(N):
        A[i] = A[i]%MOD if A[i]%MOD != 0 else A[i]
    if MOD == min(A):
        break
print(MOD)

Measured memory_bytes: 62704
#include<bits/stdc++.h>
    using namespace std;
     
    int main(void)
    {
        int M,N;
        int money;
     
        cin >> M;
        vector<string> s(M);
        for(int i=0;i<M;i++){
            cin >> s.at(i);
        }
        cin >> N;
        vector<string> t(N);
        for(int i=0;i<N;i++){
            cin >> t.at(i);
        }
     
        vector<string> b = {s.at(M-1)};
        vector<int>    b_count = {1};
        s.pop_back();
        bool flag;
        for(int i=M-2;i>=0;i--)
        {
     
            flag = true;
            for(int l=0;l<b.size();l++)
            {
                if(b.at(l) == s.at(i))
                {
                    b_count[l]++;
                    s.pop_back(); 
                    flag = false;
                    break;
                }
            }
            if(flag)
            {
                b.push_back(s.at(i)); 
                b_count.push_back(1);
                s.pop_back();
            }
        }
     
        for(int i=0;i<N;i++)
        {
            for(int l=0;l<b.size();l++)
            {
                if(b.at(l) == t.at(i))
                {
                    b_count[l]--;
                }
            }
        }
     
        int max = 0;
        for(int i=0;i<b_count.size();i++)
        {
            if(max < b_count.at(i)) max = b_count.at(i);
        }
        cout << max;
     
        return 0;
    }

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string S;
	int k, win = 0;

	cin >> S;
	k = S.length();

	rep(i, k) {
		if (S[i] == 'o') win++;
	}
	win += 15 - k;

	cout << (win >= 8 ? "YES" : "NO") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <sstream>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

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

  if( a < b && b < c ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define SZ(c)       int(c.size())
#define FOR(i,a,b)  for (int i=a; i<(b); ++i)
#define DOWN(i,a,b) for (int i=(a)-1; i>=(b); --i)
using namespace std;
using i64 = long long;

const int MAXN=100010;


int n;
int m;
i64 l;
int nx[MAXN][2];

i64 getf(i64 x) {
  if (x==0) return 0;
  int i=0;
  while (!(x>>i&1)) i+=1;
  return i64(1)<<i;
}

i64 dfs(int v,i64 d) {
  i64 res=0;
  if (nx[v][0]==-1) res^=getf(d); else res^=dfs(nx[v][0],d-1);
  if (nx[v][1]==-1) res^=getf(d); else res^=dfs(nx[v][1],d-1);  
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout<<fixed<<setprecision(10);

  cin>>n>>l;
  memset(nx,~0,sizeof(nx));
  FOR(i,0,n) {
    string s;
    cin>>s;
    int v=0;
    FOR(j,0,SZ(s)) {
      int t=s[j]-'0';
      if (nx[v][t]==-1) nx[v][t]=++m;
      v=nx[v][t];
    }
  }

  i64 res=dfs(0,l);
  // cerr<<res<<endl;
  if (res==0) cout<<"Bob"; else cout<<"Alice";
  cout<<endl;

  return 0;
}


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

using namespace std;

int main()
{
	int N;
	vector<int> v;
	cin>> N;
	for(int i=0;i<N;i++)
	{
		int X;
		cin>> X;
		v.push_back(X);
	}

	vector<int> t;
	for(int i=0;i<N;i++)t.push_back(v[i]);
	sort(t.begin(),t.end());
	int s=t.size()+1;
	int c=t[s/2];
	for(int i=0;i<N;i++)
	{
		int ret;
		if(c>v[i])ret=t[s/2];
		else ret=t[s/2-1];
		cout<< ret<< endl;
	}

	return 0;
}

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

namespace ABC_Training
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            HashSet<int> vs = new HashSet<int>();
            var flg = true;
            for (int i = 0; i < n; i++)
            {
                if (vs.Contains(a[i]))
                {
                    flg = false;
                    break;
                }
                vs.Add(a[i]);
            }
            Console.WriteLine(flg ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 36944
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
    cout << fixed << setprecision(10);
    
    int K; cin >> K;
    int ans = 0;
    repr(i, 1, K+1) {
        repr(j, 1, K+1) {
            int gcd_ij = gcd(i, j);
            repr(k, 1, K+1) {
                ans += gcd(k, gcd_ij);
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll n,k;
	cin>>n>>k;
	ll z=n/k;
	ll res=n;
	n=n-z*k;
	res=min(res,n);
	n-=k;
	n=abs(n);
	res=min(res,n);
	cout<<res<<"\n";
	return 0;
}

Measured memory_bytes: 256
from queue import Queue

N,M = map(int,input().split())
graph = {}
for i in range(M):
    A,B = map(int,input().split())
    try:
        graph[A].append(B)
    except KeyError:
        graph[A] = [B]
    try:
        graph[B].append(A)
    except KeyError:
        graph[B] = [A]

q = Queue()
q.put(1)

distance = [pow(10,9) for i in range(N+1)]
distance[1] = 0
visited = [False for x in range(N+1)]
ans = [None for i in range(N+1)]
while q.qsize() > 0:
    cur = q.get()
    if visited[cur]:
        continue
    for v in graph[cur]:
        if distance[v] > distance[cur] + 1:
            distance[v] = distance[cur] + 1
            ans[v] = cur
        if not visited[v]:
            q.put(v)
    visited[cur] = True

print("Yes")
for i in range(2,N+1):
    print(ans[i])

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

/* N! が　p で何回割れるかを求めよ　*/
ll solve1(ll N, int p){
  ll res = 0;
  while(N){
    res += N/p;
    N /= p;
  }
  return res;
}

int main(){
  ll N; cin>>N;
  if(N%2){
    cout<<0<<endl;
    return 0;
  }
  N/=2;
  cout<<solve1(N,5)<<endl;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
    int a[100];
    int i, N;
    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &a[i]);
    }
    printf("%d", a[N - 1]);
    for(i = N - 2; i > -1; i--){
        printf(" %d", a[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2100
import sys

N = int(input())

for h in range(1,3501):
    for n in range(1,3501):
        if  (4 * h * n) - N * (n + h) > 0 and (N * h * n) % ((4 * h * n) - N * (n + h)) == 0:
            print(h, n, (N * h * n) // ((4 * h * n) - N * (n + h)))
            sys.exit()
    

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

int main(){
    int a,b;
    cin >> a >> b;

    int count = 1,ans = 0;

    while(count < b){
        count--;
        count += a;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    static long total = 0;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long tAll = sc.nextInt();
		long aAll = sc.nextInt();
		for (int i = 1; i < n; i++) {
		    int t = sc.nextInt();
		    int a = sc.nextInt();
		    if (t / (double)a == tAll / (double)aAll) {
		        continue;
		    } else if (t / (double)a > tAll / (double)aAll) {
		        if (aAll % a != 0) {
		            aAll += a - aAll % a;
		        }
		        tAll = aAll / a * t;
		    } else {
		        if (tAll % t != 0) {
		            tAll += t - tAll % t;
		        }
		        aAll = tAll / t * a;
		    }
		}
		System.out.println(tAll + aAll);
	}
}


Measured memory_bytes: 23400
#include <stdio.h> 
#include <ctype.h>   
int main(void) 
{     
	char string[1200];     
	int i=0;     
	gets(string);           
	while(string[i]!='\0')     
	{         
		if(islower(string[i]))                 
			printf("%c",toupper(string[i++]));                   
		else if(isupper(string[i]))
	             printf("%c",tolower(string[i++]));         
		else
		     printf("%c",string[i++]);
                }     
                printf("\n");
                return 0; 
} 

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18L + 5;
int main(){
    int n;
    cin >> n;
    vector<int>a(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    vector<vector<long long>> dp(n + 1, vector<long long>(n + 1, INF));
    vector<long long> pre_sum(n + 1, 0);
    for (int i = 1; i <= n; i++) pre_sum[i] = pre_sum[i-1] + a[i];

    for (int i = 1; i <= n; i++) dp[i][i] = 0;

    for (int k = 2; k <= n; k ++){
        for (int i = 1; i <= n - k + 1; i++){
            for (int it = i; it < i + k -1; it ++){
                dp[i][i + k - 1] = min(dp[i][i + k - 1], dp[i][it] + dp[it + 1][i + k - 1] + pre_sum[i + k - 1] - pre_sum[i - 1]);
            }
        }
    }
    //cout << dp[1][2] << endl;
    cout << dp[1][n];
}


Measured memory_bytes: 1536
#include <bits/stdc++.h> 
#define f(i,a,b) for(int i=a;i<b;i++)
using namespace std;
typedef long long int ll;
ll dp[100010][2], mod=1e9 +7;
vector<int> adj[100010];
void dfs(int u,int p){
	int r=0;
	for(int i=0;i<adj[u].size();i++){
		int v=adj[u][i];
		if(v!=p){
			r++;
			dfs(v,u);
			dp[u][0]*=((dp[v][0]+dp[v][1])%mod);
			dp[u][1]*=dp[v][0];
			dp[u][0]=dp[u][0]%mod;
			dp[u][1]=dp[u][1]%mod;
		}
	}
}
int main(){
	int n,a,b;
	cin>>n;
	f(i,1,n){
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	f(i,1,n+1) dp[i][0]=dp[i][1]=1LL;
	dfs(1,0);
	cout<<(dp[1][0]+dp[1][1])%mod;
}

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

int main()
{
	string className[11] = {"light fly", "fly", "bantam", "feather", "light", "light welter", "welter", "light middle", "middle", "light heavy", "heavy"};
	int c;
	double weight;

	while (cin>>weight) {
		if (weight <= 48.0) c = 0;
		else if (weight <= 51.0) c = 1;
		else if (weight <= 54.0) c = 2;
		else if (weight <= 57.0) c = 3;
		else if (weight <= 60.0) c = 4;
		else if (weight <= 64.0) c = 5;
		else if (weight <= 69.0) c = 6;
		else if (weight <= 75.0) c = 7;
		else if (weight <= 81.0) c = 8;
		else if (weight <= 91.0) c = 9;
		else c = 10;
		cout<<className[c]<<endl;
	}
	return 0;
}

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

int main() {
  int N, X;
  cin >> N >> X;
  int n = N;
  int g = X;
  for (int i = 0; i < N; i++) {
    int m;
    cin >> m;
    X -= m;
    g = min(m, g);
  }
  n += X / g;
  
  cout << n << endl;
}


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

int main(void) {
	char s[200];
	scanf("%s", s);
	int n = strlen(s);
	for(int i = n-2; i; i-=2) {
		if(strncmp(s, s+i/2, i/2) == 0) {
			printf("%d\n", i);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll n,i;
cin>>n;
ll aux[n+1],a[n];
memset(aux,0,sizeof(aux));
for(i=0;i<n;i++){
    cin>>a[i];
    aux[a[i]]++;
}
ll ans=0;
for(i=1;i<=n;i++){
    ans+=(aux[i]*(aux[i]-1))/2;
}
for(i=0;i<n;i++){
    ll x=ans;
    x-=aux[a[i]]-1;
    cout<<x<<endl;
}
}


Measured memory_bytes: 5760
#include <iostream> 
#include <vector>

using namespace std;

struct card{
	int taro;
	int hanako;
	int sum;
	card(int x,int y){
		taro = x;
		hanako = y;
		sum = x + y;
	}
	card()
		{
		}
	
/*	int getTaro(){
		return taro;
	}
	int getHanako(){
		return hanako;
	}
	int getSum(){
			return sum;
			}*/
};

	

int main(void){
	int n,m,num,sum1,sum2;
	while(1){
		cin >> n;
		cin >> m;
		int cou = 0;
		sum1 = sum2 = 0;
		if(n==0&&m==0){ break; }
		vector<int> vec1;
		vector<int> vec2;
		vector<card*> vec3;
		for(int i=0;i<n;i++){
			cin >> num;
			vec1.push_back(num);
			sum1 += num;
		}
		for(int i=0;i<m;i++){
			cin >> num;
			vec2.push_back(num);
			sum2 += num;
		}

		num = (sum1-sum2);

		for(int i=0;i<vec1.size();i++){
			for(int j=0;j<vec2.size();j++){
				if((vec1[i]-vec2[j])*2 == num){
					vec3.push_back(new card(vec1[i],vec2[j]));
						cou++;
					}
				}
			}
		for(int j=0;j<cou-1;j++){
			for(int i=0;i<cou-1;i++){
				if(vec3[i]->sum > vec3[i+1]->sum){
					card *c = new card();
					c = vec3[i];
					vec3[i] = vec3[i+1];
					vec3[i+1] = c;
				}
			}
		}
		if(cou == 0){
			cout << -1 << endl;
		}else{
			cout << vec3[0]->taro << " " << vec3[0]->hanako << endl;
		}
			
			for(int i=0;i<cou;i++){ delete vec3[i] ; }
		}
	
	return 0;
}

Measured memory_bytes: 1116
w = str(input())
alp =[]
judge = "True"
for i in w:
    if i not in alp:
        alp.append(i)
for x in alp:
    if w.count(x)%2 ==1:
        judge = "False"
if judge == "True":
    print("Yes") 
else:
    print("No")

Measured memory_bytes: 2940
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long;
#define mass 1000000007
using namespace std;



int main(){
	
	int n;
	cin>>n;
	int *a,*b;
	a=new int[n];
	b=new int[n];
	rep(i,n){
		cin>>a[i];
		b[i]=0;
	}
	int i=1;
	int c=0;
	while(b[i-1]==0){
		c++;
		b[i-1]=1;
		if(a[i-1]==2){
			cout<<c<<endl;
			return 0;
		}
		i=a[i-1];
	}
	cout<<-1<<endl;
	return 0;

}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int ans=1e9;
int a[1000];
int store[1000];
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		store[i]=store[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
	{
		ans=min(ans,abs(store[i]-(store[n]-store[i])));
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();++itr)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(long long &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
long long n,m,i,j,a,b,c,d,t;
map<long long,long long> dp;
long long dfs(long long x)
{
	if(x==0) return 0;
	if(dp.count(x)) return dp[x];
	long long t=0x3f3f3f3f3f3f3f3fll,i;
	if(t/x>=d) t=x*d;
	for(i=x-5;i<=x+5;i++){
		if(i<0) continue;
		if(i%2==0&&i/2<x) t=min(t,dfs(i/2)+a+d*abs(x-i));
		if(i%3==0&&i/3<x) t=min(t,dfs(i/3)+b+d*abs(x-i));
		if(i%5==0&&i/5<x) t=min(t,dfs(i/5)+c+d*abs(x-i));
	}
	return dp[x]=t;
}
int main()
{
	read(t);
	while(t--)
	{
		read(n);read(a);read(b);read(c);read(d);
		dp.clear();
		printf("%lld\n",dfs(n));
	}
	return 0;
}

Measured memory_bytes: 6772
cnt = 0
while a = gets
  break if a == "\n"
  flag = true

  a = a.chomp.split("")
  (a.length / 2).times do |i|
    unless a[i] == a[-1 * (i+1)]
      flag = false
      break
    end
  end
  cnt += 1 if flag
end
puts cnt

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

int main() {
  int N;
  cin >> N;
  vector<int> X(N), Y(N), H(N);
  for (int i = 0; i < N; i++) cin >> X.at(i) >> Y.at(i) >> H.at(i);
  for (int Cx = 0; Cx <= 100; Cx++) {
    bool B = false;
    for (int Cy = 0; Cy <= 100; Cy++) {
      int T;
      for (int i = 0; i < N; i++) {
        if (H.at(i) != 0) {
          T = abs(X.at(i) - Cx) + abs(Y.at(i) - Cy) + H.at(i);
          break;
        }
      }
      bool A = true;
      for (int i = 0; i < N; i++) {
        if (max(T - abs(X.at(i) - Cx) - abs(Y.at(i) - Cy), 0) != H.at(i)) {
          A = false;
          break;
        }
      }
      if (A) {
        cout << Cx << " " << Cy << " " << T << endl;
        B = true;
        break;
      }
    }
    if (B) break;
  }
}

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

using namespace std;

typedef unsigned long long ull;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    char t;
    cin >> t;
    if (t >= 'A' && t <= 'Z')
        cout << "A";
    else if (t >= 'a' && t <= 'z')
        cout << "a";

    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int a=N/1000;
  int ans;
  if(N%1000==0){
    ans = 0;
  }
  else{
    ans = (a+1)*1000-N;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

typedef struct{

  double x;
  double y;

}TEN;

void KOHHO(int,TEN,TEN); //コッホ関数

int main()
{
  int n;
  
  TEN O,L; //最初と最後の点

  O.x=0;
  O.y=0;
  
  L.x=100;
  L.y=0;
  
  scanf("%d",&n); //nに数値いれる

  printf("%f %f\n",O.x,O.y);
  KOHHO(n,O,L);
  printf("%f %f\n",L.x,L.y);
  
  return 0;
}

void KOHHO(int n,TEN p,TEN q)
{
  TEN s,t,u;

  if(n==0)return;
  
  s.x=( (2*p.x) + q.x )/3;
  s.y=( (2*p.y) + q.y )/3;
  t.x=( p.x + (2*q.x) )/3;
  t.y=( p.y + (2*q.y) )/3;
  u.x=(t.x-s.x)*cos(M_PI/3) - (t.y-s.y)*sin(M_PI/3) + s.x;
  u.y=(t.x-s.x)*sin(M_PI/3) + (t.y-s.y)*cos(M_PI/3) + s.y;
  
  KOHHO(n-1,p,s);
  printf("%f %f\n",s.x,s.y);
  KOHHO(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  KOHHO(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  KOHHO(n-1,t,q);
  
}
  



Measured memory_bytes: 2108
#include<stdio.h>

int main(){
	int N;	//要素数
	
	scanf("%d",&N);
	
	int A[N];
	
	for(int i = 0;i < N;i++){
		scanf("%d",&A[i]);
	}
	
	//最初の出力（未ソートの状態）
	for(int i = 0;i < N;i++){
		//最後の数字は後ろにスペースなしで出力
		if(i == (N - 1)){
			printf("%d",A[i]);
		}
		//それ以外はスペースあり
		else{
			printf("%d ",A[i]);
		}
	}
	//改行
	printf("\n");
	
	for(int i = 1;i < N;i++){
		int v = A[i];
		int j = i - 1;
		
		while(j >= 0 && A[j] > v){
			A[j + 1] = A[j];
			j--;
		}
		A[j+1] = v;
		
		//ソートされた状態の出力
		for(int i = 0;i < N;i++){
			//最後の数字は後ろにスペースなしで出力
			if(i == (N - 1)){
				printf("%d",A[i]);
			}
			//それ以外はスペースあり
			else{
				printf("%d ",A[i]);
			}
		}
		//改行
		printf("\n");
	}
	
	return 0;
}



Measured memory_bytes: 2056
n = int(input())

robots = []

for _ in range(n):
    x, l = map(int, input().split())
    left, right = x-l, x+l
    robots.append([left, right])

robots.sort()

count = 0
now = -float('INF')

for left, right in robots:
    if left >= now:
        count += 1
        now = right

    else:
        if right < now:
            now = right
        else:
            continue

print(count)

Measured memory_bytes: 20104
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 200005
#define P 1000000007
#define INV 500000004
#define G 3
#define INF 0x3f3f3f3f
#define rint register int
#define LL long long
#define LD long double
#define fuck printf("FUCK!!\n");
using namespace std;

int n, m, ipow[MAXN], fac[MAXN], ifac[MAXN];

void init()
{
    ifac[0]=fac[0]=ifac[1]=fac[1]=ipow[0]=1;
    for(rint i=1; i<=n+m; ++i) ipow[i]=1LL*ipow[i-1]*INV%P;
    for(rint i=2; i<=n+m; ++i) ifac[i]=1LL*ifac[P%i]*(P-P/i)%P;
    for(rint i=2; i<=n+m; ++i)
    {
        ifac[i]=1LL*ifac[i-1]*ifac[i]%P;
        fac[i]=1LL*fac[i-1]*i%P;
    }
}

inline int comb(int x, int y)
{
    if(y>x) return 0;
    return 1LL*fac[x]*ifac[y]%P*ifac[x-y]%P;
}

int main()
{
    scanf("%d%d", &n, &m);
    init();
    int sum1=0, sum2=1;
    for(rint i=1; i<=n+m; ++i)
    {
        printf("%lld\n", ((2LL*sum1+sum2)*ipow[i]%P+P)%P);
        sum1=(2LL*sum1+comb(i-1, m-1))%P;
        sum2=(2LL*sum2-comb(i-1, m-1)-comb(i-1, n-1))%P;
    }
    return 0;
}

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

class Program{
  static void Main(){
    string[] NM = Console.ReadLine().Split(' ');
    int N = int.Parse(NM[0]);
    int M = int.Parse(NM[1]);
    
    // A を受け取り、降順にソート
    long[] A = Console.ReadLine().Split(' ')
      .Select(long.Parse)
      .ToArray();
    A = A.OrderBy(a => a).ToArray();
    
    // B,C を受け取る; B,Cの組をDとし, C の降順にソート
    Card[] D = new Card[M];
    for (int i = 0; i < M; i++){
      string[] BC = Console.ReadLine().Split(' ');
      D[i] = new Card(int.Parse(BC[0]),
                         long.Parse(BC[1]));
    }
    Array.Sort(D);
    
    // i 個入れ替えるとする, i = 0のとき
    long s = A.Sum();
    long s_max = s;
    int d_index = 0;
    int d_count = 0;
    for (int i = 0; i < N; i++){
      
      long d;
      if (d_count < D[d_index].B){
        d = D[d_index].C;
        d_count++;
      }
      else if (d_index == D.Length -1)
        break;
      else{
        d_index++;
        d = D[d_index].C;
        d_count = 1;
      }
      
      s = s - A[i] + d;
      s_max = Math.Max(s, s_max);
    }
    Console.WriteLine(s_max);
  }
}

public class Card:IComparable {
  public int B {get; set;}
  public long C {get; set;}
  
  public Card(int bb, long cc){
    this.B = bb;
    this.C = cc;
  }
  
  public int CompareTo(object obj){ // 降順
    Card obj_ = (Card)obj;
    return - (int)this.C + (int)obj_.C;
  }
}

Measured memory_bytes: 34652
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ans = 0
for i in range(N):
  if B[i] < A[i]:
    ans += B[i]
  else:
    ans += A[i]
    rest = B[i] - A[i]
    if rest < A[i+1]:
      ans += rest
      A[i+1] -= rest
    else:
      ans += A[i+1]
      A[i+1] = 0
print(ans)

Measured memory_bytes: 19244
lst = ['+', '-']
S = raw_input()
oplst = []
for i in range(0, 8):
	op = []
	n = i
	for i in range(0, 3):
		op.append(n%2)
		n = n/2
	oplst.append(op)
for i in range(0, 8):
	sum = int(S[0])
	for j in range(0, 3):
		if oplst[i][j] == 0:
			sum += int(S[j+1])
		else:
			sum -= int(S[j+1])
	if sum == 7:
		ans = S[0]
		for j in range(0, 3):
			ans = ans + lst[oplst[i][j]] + S[j+1]
		ans = ans + '=7'
		print ans
		break

Measured memory_bytes: 2696
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
typedef long long ll;
const int INF = 1001001001;

int main() {
    int N, ans=0;
    string S;

    cin >> N >> S;

    rep(i, N-2) {
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C') {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s;
  cin>>s;
  int n=s.size();//10以下
  
  long long dp[n]={};
  long long cnt[n]={};
  dp[0]=(long long)(s[0]-'0');
  cnt[0]=1;
  //cout<<dp[0]<<endl;
  REP(i,n){
    cnt[i+1]=cnt[i]*2;
  }
  
  long long d;
  long long last_num;
  REP(i,n){
    if(i==0)continue;
    d = 1;
    for(int j=i;j>=0;j--){
      dp[i] += d*(long long)(s[j]-'0');
      d *= 10;
    } 
    REP(j,i){
      dp[i] += dp[j];
      d = 1;
      last_num = 0;
      for(int k=i;k>=j+1;k--){
        last_num += d*(long long)(s[k]-'0');
        d *= 10;
      }
      dp[i] += last_num*cnt[j];
    }
  }
  
  cout<<dp[n-1]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;
    vector<int> a_1;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        a_1.push_back(a);
    }
    if(accumulate(a_1.begin(),a_1.end(),0)%2==0){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;


    return 0;
}

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

int main() {
  string S;
  cin >> S;
  int count = 0, num;
  bool ans = true;
  if (S[0] != 'A') {
    ans = false;
  }
  for (int i = 2; i < S.length() - 1; i++) {
    if (S[i] == 'C') {
      count++;
      num = i;
    }
  }
  if (count != 1) {
    ans = false;
  }
  for (int i = 1; i < num; i++) {
    if (islower(S[i]) ==  0) {
      ans = false;
    }
  }
  for (int i = num + 1; i < S.length(); i++) {
    if (islower(S[i]) ==  0) {
      ans = false;
    }
  }
  if (ans) {
    cout << "AC";
  }
  else {
    cout << "WA";
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import math
import itertools

debug = False

def log(text):
    if debug:
        print(text)


def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        # error?
        # for line in sys.stdin:
        #     lines.append(line)
        lines.append(input())

    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    x = [int(e) for e in lines[0].split(" ")][0]

    return (x, )


def solve(x):

    primes = set()

    def is_prime(n):
        
        if n in primes:
            return True

        if n == 1:
            return False

        for k in range(2, int(math.sqrt(n)) + 1):
            if n % k == 0:
                return False
        
        primes.add(n)

        return True

    y = x
    result = 0
    while True:
        if is_prime(y):
            result = y
            break
        else:
            y = y + 1

    return result

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    vint a(N);
    REP(i,N) cin>>a[i];

    int sum=0;
    map<int,int> cnt;
    cnt[sum%M]++;
    REP(i,N){
        sum+=a[i];
        cnt[sum%M]++;
    }
    
    int ans=0;
    for(pint p:cnt){
        ans+=p.second*(p.second-1)/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4992