akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,x,y,a[222222]={0};
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>x>>y;
    if(x==1) a[y]++;
    if(y==n) a[x]++;
    if(a[x]==2 || a[y]==2){
      cout<<"POSSIBLE"<<endl;
      return(0);
    }
  }
  cout<<"IMPOSSIBLE"<<endl;
  return(0);
}


Measured memory_bytes: 1152
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] d = new int[N];
    for (int i=0;i<N;i++){
      d[i] = sc.nextInt();
    }
    int ans = 0;
    for(int i=0;i<N;i++){
      for(int j=i+1;j<N;j++){
        if (i==j){ continue; }
        ans = ans + (d[i]*d[j]);
      }
    }
    System.out.println(ans);
  }
}

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

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	
	vector<int> d(N);
	for (int i = 0; i < d.size(); i++)
	{
		cin >> d[i];
	}
	
	int answer = 0;
	
	// たこ焼きの2個を総当たりで選ぶ
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			answer += d[i] * d[j];
		}
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
ABCD = input().strip()
for i in range(8):
    ope = [{0:'+', 1:'-'}[(i>>j) & 1] for j in range(3)]
    fomula = ABCD[0] + ope[0] + ABCD[1] + ope[1] + ABCD[2] + ope[2] + ABCD[3]
    if eval(fomula) == 7:
        print(f'{fomula}=7')
        break

Measured memory_bytes: 8820
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll h;
    cin>>h;
    ll n=1;
    ll ans=0;
    while(h>=1){
        ans+=n;
        if(h==1)break;
        h/=2;
        n*=2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def lscan; gets.split.map(&:to_i); end

n = gets.to_i
li = n.times.map{s,t=gets.chomp.split; [s, t.to_i]}
x = gets.chomp

xi = li.map{|s,t| s}.index(x)
t1 = li.map{|s,t| t}.reduce(:+)
t2 = li.map{|s,t| t}.to_a[0..xi].reduce(:+)

p t1-t2

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

int n;
string s;
vector<int> r, g, b;
vector<int> rf, gf, bf;
int64_t check(char x, char y, char z){
    int64_t res = 0;
    for(int i = 0; i < n; i++){
        if(s[i] != x) continue;
        for(int j = i + 1; j < n; j++){
            if(s[j] != y) continue;
            if(z == 'R') res += ((rf[n-1] - rf[j]) - (j+(j-i) > n-1 ? 0 : r[j+(j-i)]));
            if(z == 'G') res += ((gf[n-1] - gf[j]) - (j+(j-i) > n-1 ? 0 : g[j+(j-i)]));
            if(z == 'B') res += ((bf[n-1] - bf[j]) - (j+(j-i) > n-1 ? 0 : b[j+(j-i)]));
        }
    }
    return res;
}

int main() {
    cin >> n;
    cin >> s;
    r.resize(n);
    g.resize(n);
    b.resize(n);
    rf.resize(n);
    gf.resize(n);
    bf.resize(n);
    for(int i = 0; i < n; i++){
        if(s[i] == 'R') r[i]++;
        if(s[i] == 'G') g[i]++;
        if(s[i] == 'B') b[i]++;
    }
    partial_sum(begin(r), end(r), begin(rf));
    partial_sum(begin(g), end(g), begin(gf));
    partial_sum(begin(b), end(b), begin(bf));
    int64_t ans = 0;
    ans += check('R', 'G', 'B');
    ans += check('R', 'B', 'G');
    ans += check('G', 'R', 'B');
    ans += check('G', 'B', 'R');
    ans += check('B', 'G', 'R');
    ans += check('B', 'R', 'G');
    cout << ans << endl;
    return 0;
}

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

int main(){
    string s; cin >> s;
    int n=s.length(), j=0, ans=0;
    for(int i = 0; i < n; i++){
        if(!(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')){
            j = i+1;
            continue;
        }
        for(;s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T'; j++){
            ans = max(ans, j-i+1);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

int n;
int a[200000];
int sa[200000];

int Abs(int x) {
	if (x > 0) return x;
	return -x;
}

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) { cin >> a[i]; a[i] -= i + 1; sa[i] = a[i]; }
	sort(sa, sa + n);
	
	int b = sa[n / 2];
	int ans = 0;
	for (i = 0; i < n; i++) { ans += Abs(a[i] - b); }
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?2e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	reverse(all(s));
	int t=0;
	while(t!=s.size()){
		if(t<s.size()-4&&s[t]=='m'&&s[t+1]=='a'&&s[t+2]=='e'&&s[t+3]=='r'&&s[t+4]=='d')t+=5;
		else if(t<s.size()-6&&s[t]=='r'&&s[t+1]=='e'&&s[t+2]=='m'&&s[t+3]=='a'&&s[t+4]=='e'&&s[t+5]=='r'&&s[t+6]=='d')t+=7;
		else if(t<s.size()-4&&s[t]=='e'&&s[t+1]=='s'&&s[t+2]=='a'&&s[t+3]=='r'&&s[t+4]=='e')t+=5;
		else if(t<s.size()-5&&s[t]=='r'&&s[t+1]=='e'&&s[t+2]=='s'&&s[t+3]=='a'&&s[t+4]=='r'&&s[t+5]=='e')t+=6;
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
}







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

int main()
{
  int N;
  int a[100000];
  int count = 1, flag = 0;

  cin >> N;
  if (N == 1)
  {
    cout << 1 << endl;
    return (0);
  }
  for (int i = 0; i < N; i++)
    cin >> a[i];
  for (int i = 0; i < N; i++)
  {
    if (!flag)
    {
      if (i == N - 1)
        break;
      if (a[i] < a[i + 1])
        flag = 1;
      else if (a[i + 1] < a[i])
        flag = -1;
    }
    else if (flag * a[i] < flag * a[i - 1])
    {
      count++;
      if (i == N - 1)
        break;
      if (a[i] < a[i + 1])
        flag = 1;
      else if (a[i + 1] < a[i])
        flag = -1;
      else
        flag = 0;
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll =long long;
ll func(ll a,ll b){
  ll al=to_string(a).size();
  ll bl=to_string(b).size();
  return max(al,bl);
}
main(){
  ll n;
  cin>>n;
  ll ans=(1<<28);
  for(ll i=1;i*i<=n;++i){
    if(n%i!=0)continue;
    ll a=i,b=n/i;
    ans=min(ans,func(a,b));
  }
  cout<<ans<<endl;
}


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

ll mpow(ll x, ll n){ //x^n(mod mo) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % mo;
        x = x*x % mo;
        n = n >> 1;
    }
    return ans;
}

int main(){
    ll N,K;
    string S;
    cin >> N >> K;
    vector<ll> d(K+1);
    if(K == 1){
        cout << 1 << endl;
        return 0;
    }

    for(int i = 1;i<=K;i++){
        d[i] = mpow(K/i, N);
        //cout << d[i] << " ";     
    }
    //cout << endl;
    for(int i = K;0 < i;i--){
        for(int j = 2; i*j <= K; j++){
            d[i] -= d[i*j];
        }
    }

    ll ans = 0;
    for(int i = 1;i<=K;i++){
        ans += (d[i]*i) % mo;
        ans %= mo;
    }
    cout << ans << endl;
        /*
        auto v = factorize(i);
        sum += N;7 
        rep(j,v.size()){
            rep(k, v[j].second){
                sum += ((i / pow(v[j].first, k+1)))*v[j].first;
            }
        }
    }
    cout << sum <<endl;
*/
}

Measured memory_bytes: 4008
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    List<int>[] G;
    int[] A;
    int[] B;
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        G = new List<int>[N];
        for(int i=0;i<N;i++){
            G[i] = new List<int>();
        }
        for(int i=0;i<N-1;i++){
            string[] str = Console.ReadLine().Split(' ');
            int f = int.Parse(str[0])-1;
            int t = int.Parse(str[1])-1;
            G[f].Add(t);
            G[t].Add(f);
        }
        A = new int[N];
        B = new int[N];
        dfs1(0,-1,0);
        dfs2(N-1,-1,0);
        int count = 0;
        for(int i=0;i<N;i++){
            if(A[i] <= B[i]){
                count++;
            }
        }
        if(count > N-count){
            sb.Append("Fennec\n");
        }
        else{
            sb.Append("Snuke\n");
        }
    }
    void dfs1(int v,int f,int d){
        A[v] = d; 
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(f != t){
                dfs1(t,v,d+1);
            }
        }
    }
    void dfs2(int v,int f,int d){
        B[v] = d; 
        for(int i=0;i<G[v].Count;i++){
            int t = G[v][i];
            if(f != t){
                dfs2(t,v,d+1);
            }
        }
    }
}

Measured memory_bytes: 35340
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include <iostream>
//using namespace std;

//#define NIL NULL

struct node{
  int key;
  struct node *right, *left, *parent;
};

typedef struct node Node;

Node *NIL, *root;

Node *treeMinimum(Node *x){
  while(x->left!=NIL) x=x->left;
  return x;
}

Node *find(Node *u, int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key) u=u->left;
    else u=u->right;
  }
  return u;
}

Node *treeSuccessor(Node *x){
  Node *y;
  if(x->right!=NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y!=NIL&&x==y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z){
  Node *x, *y;
  if(z->left==NIL||z->right==NIL) y=z;
  else y=treeSuccessor(z);
  if(y->left!=NIL) x=y->left;
  else x=y->right;
  if(x!=NIL) x->parent=y->parent;
  if(y->parent==NIL) root=x;
  else{
    if(y==y->parent->left) y->parent->left=x;
    else y->parent->right=x;
  }
  if(y!=z) z->key=y->key;
  free(y);
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;
  z = (Node *)malloc(sizeof(struct node));
  z->key = k;
  z->right = NIL;
  while(x!=NIL){
    y = x;
    if(z->key<x->key) x=x->left;
    else x=x->right;
  }
  z->parent = y;
  if(y==NIL) root=z;
  else{
    if(z->key<y->key) y->left=z;
    else y->right=z;
  }
}

void inorder(Node *u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[10];

  scanf("%d", &n);

  for(i=0; i<n; i++){
    scanf("%s", com);
    if(com[0]=='f'){
      scanf("%d", &x);
      Node *t = find(root, x);
      if(t!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(!strcmp(com, "insert")){
      scanf("%d", &x);
      insert(x);
    }
    else if(!strcmp(com, "print")){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(!strcmp(com, "delete")){
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 25124
n = int(input())
p = list(map(int, input().split()))

count=0
for name in range(1, n-1):
  if ((p[name+1] > p[name]) and (p[name] > p[name-1])) or ((p[name-1] > p[name])and (p[name] > p[name+1])):
    count+=1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n;
    ll ans = 0;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, n) cin >> a.at(i);
    rep(i, n) cin >> b.at(i);
    rep(i, n) cin >> c.at(i);

    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    rep(i, n){
        int k = b.at(i);
        auto low_pos = lower_bound(a.begin(), a.end(), k);
        ll low_idx = distance(a.begin(), low_pos);
        ll num_A = (low_pos == a.end()) ? n : low_idx;

        auto upper_pos = upper_bound(c.begin(), c.end(), k);
        ll upper_idx = distance(c.begin(), upper_pos);
        ll num_C = (upper_pos == c.end()) ? 0 : n - upper_idx;

        ans += num_A * num_C;
    }

    cout << ans << endl;
}

Measured memory_bytes: 4564
a=list(map(int,input().split()))
N=a[0]
M=a[1]
t=max(N,M)
fact=[1,]*(t+1)
for i in range(1,t+1):
    fact[i]=fact[i-1]*i % (10**9+7)
if abs(N-M) > 1:
    print("0")
elif N == M:
    print(str(2*fact[N]*fact[M] % (10**9+7)))
else:
    print(str(fact[N]*fact[M] % (10**9+7)))

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

int main()
{
	int a[3][3], N;
	cin >> a[0][0] >> a[0][1] >> a[0][2];
	cin >> a[1][0] >> a[1][1] >> a[1][2];
	cin >> a[2][0] >> a[2][1] >> a[2][2];

	int f[3][3];
	for(int i=0; i<3; i++){
		for(int j=0; j<3; j++){
			f[i][j] = 0;
		}
	}

	cin >> N;

	for(int n=0; n<N; n++){
		int b;
		cin >> b;
		for(int i=0; i<3; i++){
			for(int j=0; j<3; j++){
				if(a[i][j] == b){
					f[i][j] = 1;
				}
			}
		}
	}

	if(
		(f[0][0] == 1 && f[0][1] == 1 && f[0][2] == 1)
		|| (f[1][0] == 1 && f[1][1] == 1 && f[1][2] == 1)
		|| (f[2][0] == 1 && f[2][1] == 1 && f[2][2] == 1)
		|| (f[0][0] == 1 && f[1][0] == 1 && f[2][0] == 1)
		|| (f[0][1] == 1 && f[1][1] == 1 && f[2][1] == 1)
		|| (f[0][2] == 1 && f[1][2] == 1 && f[2][2] == 1)
		|| (f[0][0] == 1 && f[1][1] == 1 && f[2][2] == 1)
		|| (f[2][0] == 1 && f[1][1] == 1 && f[0][2] == 1)
	){
		cout << "Yes";
	} else {
		cout << "No";
	}

	return 0;
}


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

int main() {
   int n;
   cin >> n;
   vector<int> a(n);
   rep(i, n) {
       cin >> a[i];
   }

   sort(a.begin(), a.end());

   rep(i, n-1) {
       if(a[i] == a[i+1]) {
           cout << "NO" << endl;
           return 0;
       }
   }

   cout << "YES" << endl;
}

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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

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

int main(){

    bool flag=false;

    ll ans=0,sum=0;
    
    int n;
    cin >>n;

    vector<int> d(n);

    for (int i = 0; i < n; i++){
        cin >>d[i];
    }
    
    
    for (int i = 0; i < n; i++){
        for (int j = i+1; j < n; j++){
            if(i == j)continue;
            ans += d[i]*d[j];
        }
        
    }
    

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

struct eds{
    long long a,b;

    bool operator<(const eds& another) const{
        if(a != another.a)return a < another.a;
        return b < another.b;
    }
};


int main(){
    int n,m;
    long long ans=0;
    cin >> n >> m;
    vector<eds> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec[i].a >> vec[i].b;
    }
    sort(vec.begin(), vec.end());
    int count=0;
    for(int i=0;i<n;i++){
        if(m-count>vec[i].b){ans += (vec[i].a)*(vec[i].b);count+=vec[i].b;
        }
        else{ans +=(vec[i].a)*(m-count);break;}
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
//const ll MOD = 1000000007;
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> B(N - 1);
    rep(i, 0, N - 1){
        cin >> B.at(i);
    }
    int ans = 0;
    rep(i, 0, N - 2){
        ans += min(B.at(i), B.at(i + 1));
    }
    ans += B.at(N - 2) + B.at(0);
    cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,tt,ht,tw,hw,s;
int main(){
	while(cin>>n>>m){
		if(n==0&&m==0) break;
		int t[n],h[m];
		tt=0;
		ht=0;
		s=201;
		for(int i=0;i<n;i++){
			cin>>t[i];
			tt=tt+t[i];
		}
		for(int i=0;i<m;i++){
			cin>>h[i];
			ht=ht+h[i];
		}
		if((tt-ht)%2==0){
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(t[i]-(tt-ht)/2==h[j]){
						s=min(s,t[i]+h[j]);
						if(s==t[i]+h[j]){
							tw=t[i];
							hw=h[j];
						}
					}
				}
			}
			if(s==201){
				cout<<-1<<endl;
			} else{
				cout<<tw<<" "<<hw<<endl;
			}
		} else{
			cout<<-1<<endl;
		}
	}
    return 0;
}

Measured memory_bytes: 1160
X,N = map(int,input().split())
if N==0:
    li = [-1]
else:
    li = list(map(int,input().split()))

mm = 200
for i in range(-10,110):
    for j in li:
        if i==j:
            break
    else:
        if abs(i-X)<abs(mm-X):
            mm = i
print(mm)


Measured memory_bytes: 63020
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N,ans=0ll;
  cin>>N;
  vector<ll>A(N+1),B(N);
  REP(i,N+1)cin>>A[i];
  REP(i,N)cin>>B[i];
  REP(i,N){
    if(A[i]>=B[i]){
      ans+=B[i];
    }else if(A[i]+A[i+1]<=B[i]){
      ans+=A[i]+A[i+1];
      A[i+1]=0;
    }else{
      ans+=B[i];
      A[i+1]-=B[i]-A[i];
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int a = stdin.nextInt();
        int b = stdin.nextInt();
        int c = stdin.nextInt();
        
        int[] d = IntStream.of(a, b, c).sorted().toArray();
        
        if (d[0] == 5 && d[1] == 5 && d[2] == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 27848
def c():
    N,M= list(map(int,input().split(" ")))
    shops = []
    for i in range(N):
        shop = list(map(int, input().split(" ")))
        shops.append(shop)

    shops.sort(key = lambda x:x[0])
    drinks  = 0
    money = 0
    for shop in shops:
        a = shop[0]
        b = shop[1]
        if drinks + b >=M:
            temp = M - drinks #足りない分
            money += temp * a
            break

        else:
            money += b * a
            drinks += b

    print(money)


if __name__ == '__main__':
    c()

Measured memory_bytes: 28980
def cin; gets.split.map(&:to_i) end
def cout(*x); puts x.join(" ") end

exit if $0 != __FILE__

n, = cin
cout Array.new(n).map {
  x,u = gets.split
  x = x.to_f
  next x if u == "JPY"
  next x * 380000.0  
}.inject(:+)

Measured memory_bytes: 3836
type tree = Nil | Node of int * tree * tree

let create () = Nil

let insert x t =
  let rec doit = function
    | Nil -> Node (x, Nil, Nil)
    | (Node (y, _, _)) as d when x = y -> d
    | Node (y, l, r) when x < y -> Node (y, doit l, r)
    | Node (y, l, r) -> Node (y, l, doit r)
  in
  doit t

let preorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (f x; doit l; doit r)
  in
  doit t

let inorder f t =
  let rec doit = function
    | Nil -> ()
    | Node (x, l, r) -> (doit l; f x; doit r)
  in
  doit t

let print t =
  let f e = print_string " "; print_int e in
  inorder f t;
  print_newline ();
  preorder f t;
  print_newline ()

let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  let m = read_int () in
  let rec read i t =
    if i < m then begin
      match split (read_line ()) ' ' with
      | ["insert"; n] -> read (i + 1) (insert (int_of_string n) t)
      | _ -> (print t; read (i + 1) t)
    end
  in
  read 0 (create ())

Measured memory_bytes: 31784
from collections import Counter
import sys

# sys.stdin = open("b1.in")

s = input()
n = len(s)

res = 'yes'
for i in range(0, n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            res = 'no'

print(res)

c = Counter(s)
res = 'yes'
for l, value in c.items():
    if value > 1:
        res = 'no'




Measured memory_bytes: 3316
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_A
  * Structured Program I - Print a Rectangle
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.split(" ").map(_.toInt).toSeq)
      .takeWhile { case Seq(h, w) => h > 0 && w > 0 }
      .map { case Seq(h, w) => createARectangle(h, w) }
      .foreach(_.foreach(println))
  }

  def createARectangle(h: Int, w: Int): Seq[String] = {
    (1 to h).map(_ => "#" * w) :+ ""
  }
}

Measured memory_bytes: 45344
// dile a la jardinera que traigo flores
// corner cases // int vs ll // cin vs scanf
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define sz(x) int(x.size())
#define fill(x,v) memset(x,v,sizeof(x))
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define N 100050
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int n;
ll dp[N][2];
vector<int> adj[N];

void sum(ll &a, ll b){ a += b; if(a > MOD) a -= MOD; }

ll go(int u, bool c, int p = -1){
	ll &ans = dp[u][c];
	if(ans != -1) return ans;
	ans = 1;
	for(int v : adj[u]) if(v != p){
		ll x = go(v,1,u);
		if(c) sum(x,go(v,0,u));
		ans = (ans * x) % MOD;
	}
	return ans;
}

int main(){

	fastio;
	fill(dp,-1);
	int a,b;
	cin >> n;
	FER(i,0,n-1){
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}

	cout << (go(1,0)+go(1,1))%MOD << endl;

	return 0;
}


Measured memory_bytes: 15616
import sys
import numpy as np
from collections import Counter, deque

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    red = s.count("0")
    blue = s.count("1")
    print(min(red, blue) * 2)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 12624
while(1):
  a,op,b = raw_input().split()
  a = int(a)
  b = int(b)
  if op == "+":
    print (a+b)
  elif op == "-":
    print (a-b)
  elif op == "*":
    print (a*b)
  elif op == "/":
    print (a/b)
  elif op == "?":
    break
 

Measured memory_bytes: 6428
import sys
import numpy as np
from numba import njit, i8
input = lambda: sys.stdin.readline().rstrip()

@njit(i8[:](i8[:]), cache=True)
def count(a):
    tmp = np.zeros_like(a)
    for index, num in enumerate(a):
        left = max(0, index-num)      
        right = min(len(a)-1, index+num)  
        tmp[left] += 1              
        if right + 1 < len(a):
            tmp[right + 1] -= 1
    tmp = np.cumsum(tmp)
    return tmp

def main():
    n, k = map(int, input().split())
    a = np.array(list(map(int, input().split())))
    for _ in range(k):
        a = count(a)
        if len(set(a)) == 1 and n in set(a):
            print(*a)
            return
    print(*a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 128804
#include <iostream>
#include <stdio.h>
#include <cctype>
#include <cmath>
#include <math.h>
using namespace std;

struct cubes {
  int n;
  int e;
  int w;
  int s;
  int t;
  int b;
};

void spin(cubes* cube){
  int tmp;
      tmp = cube->n;
      cube->n = cube->e;
      cube->e = cube->s;
      cube->s = cube->w;
      cube->w = tmp; 
}

void roll(cubes* cube, char dst){
  int tmp;
  switch(dst){
    case 'N' :
      tmp = cube->b;
      cube->b = cube->n;
      cube->n = cube->t;
      cube->t = cube->s;
      cube->s = tmp; 
      break;
    case 'E' :
      tmp = cube->b;
      cube->b = cube->e;
      cube->e = cube->t;
      cube->t = cube->w;
      cube->w = tmp; 
      break;
    case 'W' :
      tmp = cube->b;
      cube->b = cube->w;
      cube->w = cube->t;
      cube->t = cube->e;
      cube->e = tmp; 
      break;
    case 'S' :
      tmp = cube->b;
      cube->b = cube->s;
      cube->s = cube->t;
      cube->t = cube->n;
      cube->n = tmp; 
      break;
    default : break;
  }
}

int main(){
  cubes cube,cube2;
  int cnt=0;
  int a,b,n;
  bool same;
  string s = "SSSSWWW";
  cin >> cube.t >> cube.s >> cube.e >> cube.w >> cube.n >> cube.b;
  cin >> cube2.t >> cube2.s >> cube2.e >> cube2.w >> cube2.n >> cube2.b;
  same = 0;
  for(int i=0;i<s.size();i++){
    roll(&cube,s[i]);
    for(int j=0;j<4;j++){
      if((cube.t==cube2.t)&&(cube.b==cube2.b)&&(cube.n==cube2.n)&&(cube.e==cube2.e)&&(cube.w==cube2.w)&&(cube.s==cube2.s)){
        same = 1;
      }
      spin(&cube);
    }
  }
  if(same==1){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3216
R,G,B,N = map(int,input().split())
cnt = 0
R_1 = N//R
for i in range(R_1+1):
    G_1 = (N - i*R)//G
    for j in range(G_1+1):
        if (N - i*R - j*G)%B == 0:
            cnt += 1
print(cnt)

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

int n;
long long v[1000005],nxt[1000005],head[1000005];
long long rd[1000005],dis[1000005],maxn=-1;
bool vis[1000005];
queue<long long> q;

int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x,y;
		cin>>x;
		if(x<i) x=x*n-n+i; else x=i*n-n+x; 
		for(int j=2;j<n;j++)
		{
			cin>>y;
			if(y<i) y=y*n-n+i; else y=i*n-n+y;
			v[i*n-n+j]=y;
			nxt[i*n-n+j]=head[x];
			head[x]=i*n-n+j;
			x=y;
			rd[x]++;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(rd[i*n-n+j]==0)
			{
				vis[i*n-n+j]=1;
				dis[i*n-n+j]=1;
				q.push(i*n-n+j);
			}
		}
	}
//	cout<<endl;
	while(!q.empty())
	{
		long long u=q.front();
		q.pop();
//		cout<<u<<' '<<(u+n-1)/n<<' '<<(u-1)%n+1<<' '<<dis[u]<<endl;
		maxn=max(maxn,dis[u]);
		for(int i=head[u];i>0;i=nxt[i])
		{
			rd[v[i]]--;
			if(rd[v[i]]==0&&!vis[v[i]]) vis[v[i]]=1,dis[v[i]]=dis[u]+1,q.push(v[i]);
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(!vis[i*n-n+j])
			{
				cout<<-1<<endl;
				return 0;
			}
		}
	}
	cout<<maxn<<endl;
}

Measured memory_bytes: 40320
#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;
typedef unsigned int uint;
#define MAX_R 10
#define MAX_C 10000
int R, C;
int f[MAX_R][MAX_C];
int buf[MAX_R][MAX_C];

// fのpatに1が立っている行をひっくり返してbuf に入れる
void flip(uint pat) {
    memcpy(buf,f,sizeof(f));
    for(int i=0;i<R;i++) {
        if ((pat & (1 << i)) != 0) {
            for(int j=0;j<C;j++) {
                buf[i][j] = (buf[i][j]+1) % 2;
            }
        }
    } 

    //for(int i=0;i<R;i++) {
    //    for(int j=0;j<C;j++) {
    //        cout << buf[i][j] << " ";
    //    }
    //    cout << endl;
    //}

}

void solve() {
    int ans = 0;
    // 行についてすべてのパターンを試す
    int nums = pow(2,R);
    for(uint pat = 0; pat < nums; pat++) {
        flip(pat);
        // 列
        int cnt_b; // 黒の数
        int buf_ans = 0;
        for(int i=0;i<C;i++) {
            cnt_b = 0;
            for(int j=0;j<R;j++) {
               if(buf[j][i] == 1) cnt_b++;
            }
            if(cnt_b > R/2) {
                buf_ans += cnt_b; // ひっくり返す
            } else {
                buf_ans += R - cnt_b;
            }
        }
        ans = max(ans, buf_ans);
    }
    cout << ans << endl;
}

main() {
    while(cin>>R>>C, R!=0 && C!=0) {
        for(int i=0;i<R;i++) {
            for(int j=0;j<C;j++) {
                cin>>f[i][j];
            }
        }
        solve();
    }
}

Measured memory_bytes: 1980
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			scanner.nextLine();
			if ((a == b) && (a == c)) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

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

using namespace std;
const int N=1e5+10;
const int MOD=1e9+7;
typedef long long ll;
ll qpow(ll a,ll b){
    ll ans=1;
    while(b){
        if(b%2){
            ans=(ans*(a%MOD))%MOD;
        }
        b/=2;
        a=a*a%MOD;
    }
    return ans;
}
ll f[N];
int main()
{
    //cout<<qpow(2,4);
    ll n,k;
    cin >>n>>k;
    ll ans=0;
    for(int i=k;i>=1;i--){
            f[i]=qpow(k/i,n);
        for(int j=i*2;j<=k;j+=i){
            f[i]-=f[j];
        }
        ans=(ans+i*f[i]%MOD)%MOD;
    }
    cout<<(ans+MOD)%MOD<<endl;
}


Measured memory_bytes: 4384
#include<stdio.h>
int maxHeapify(int,int);
int a[500000];
int main()
{
  int h,i;
  scanf("%d",&h);
  for(i=1;i<=h;i++){
    scanf("%d",&a[i]);
  }
  
  for(i=h/2;i>0;i--){
    maxHeapify(i,h);
  }
  for(i=1;i<=h;i++){
    printf(" %d",a[i]);
  }
  printf("\n");
  return 0;
}
  
int maxHeapify(int i,int h){
  int l,r,m,k;
  l=2*i;
  r=2*i+1;
  k=0;
  if(l<=h&&a[l]>a[i]){
  m=l;
  }
  else m=i;
  if(r<=h&&a[r]>a[m]){
  m=r;
  }
  if(m!=i){
    k=a[i];
    a[i]=a[m];
    a[m]=k;
    return maxHeapify(m,h);
  }
  return 0;
}

Measured memory_bytes: 2552
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	string s, t, u;
	cin >> s;
	for(int i=0; i<s.size(); i++){
		if(s[s.size()-i-1]=='b'){
			t.push_back('d');
		} else if(s[s.size()-i-1]=='d'){
			t.push_back('b');
		} else if(s[s.size()-i-1]=='p'){
			t.push_back('q');
		} else {
			t.push_back('p');
		}
	}
	if(s==t){
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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

const int N = 2005;

int n, k;
vector<int> G[N];
vector< pair<int,int> > edges;
int dist[N][N];
int res[N];
int ans = 1e9;

void dfs(int u, int p, int r) {
	for (int v : G[u]) if (v != p) dist[r][v] = dist[r][u] + 1, dfs(v, u, r);
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n >> k;
	for (int i = 1; i < n; ++i) {
		int u, v; cin >> u >> v;
		G[u].push_back(v); G[v].push_back(u);
		edges.push_back(make_pair(u, v));
	}

	for (int i = 1; i <= n; ++i) dfs(i, i, i);

	if (k % 2 == 0) {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j <= n; ++j) if (dist[i][j] > k / 2) ++res[i];
		}
		for (int i = 1; i <= n; ++i) ans = min(ans, res[i]);
	} else {
		for (int i = 0; i < n - 1; ++i) {
			int u = edges[i].first, v = edges[i].second;
			for (int j = 1; j <= n; ++j) if (dist[u][j] > (k - 1) / 2 && dist[v][j] > (k - 1) / 2) ++res[i];
		}
		for (int i = 0; i < n - 1; ++i) ans = min(ans, res[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<29;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};



int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		int n;
		cin>>n;
		if(n==0) break;
		vl x(n),y(n),r(n),c(n);
		vvi a(4);
		for(int i=0;i<n;i++){
			cin>>x[i]>>y[i]>>r[i]>>c[i];
			c[i]--;
			a[c[i]].push_back(i);
		}
		vi b(n);
		for(int i=0;i<n;i++){
			bool B=1;
			for(int j=0;j<i;j++) if(i!=j&&(r[i]+r[j])*(r[i]+r[j])>(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])){
				b[i]+=1<<j;
			}
//			cout<<b[i]<<' ';
		}
//		cout<<endl;
		vi dp(1<<n);
		dp[0]=1;
		for(int i=0;i<1<<n;i++) if(dp[i]){
			for(int j=0;j<4;j++){
				int m=a[j].size();
				for(int k=0;k<m;k++) if(!(i&1<<a[j][k])&&(i&b[a[j][k]])==b[a[j][k]]) for(int l=k+1;l<m;l++) if(!(i&1<<a[j][l])&&(i&b[a[j][l]])==b[a[j][l]]){
//					cout<<a[j][k]<<' '<<a[j][l]<<endl;
					int I=i+(1<<a[j][k])+(1<<a[j][l]);
					dp[I]=1;
				}
			}
		}
		int res=0;
		for(int i=0;i<1<<n;i++) if(dp[i]){
			int tmp=0;
			for(int j=0;j<n;j++) if(i&1<<j) tmp++;
			res=max(res,tmp);
		}
		cout<<res<<endl;
	}
}


Measured memory_bytes: 68432
#include <iostream>
#include <bitset>
#include <string>
using namespace std;
int main(){
    string s;
    cin >> s;
    
    int n = s.size();
    
    long long ans = 0;
    
    
    for (int tmp = 0; tmp < (1 << (n-1)); tmp++) {
        bitset<15> S(tmp);
        
        long long temp_number = 0;
        
        for (int i = 0; i < n-1; i++){
            temp_number += s[i] - '0';
            if (S.test(i)){
                ans += temp_number;
                temp_number = 0;
            }
            else{
                temp_number = temp_number * 10;
            }
        }
        temp_number += s[n-1] - '0';
        ans += temp_number;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
// template<class t, class u>
// ostream& operator<<(ostream& os, const pair<t, u>& p) {
//   return os << "{" << p.first << ", " << p.second << "}";
// }
// template<class t> ostream& operator<<(ostream& os, const vector<t>& v) {
//   os << "{";
//   rep(i, v.size()) { if(i) os << ", "; os << v[i]; }
//   return os << "}";
// }
// template<class t> ostream& operator<<(ostream& os, const set<t>& se) {
//   os << "{";
//   auto itr = se.begin();
//   rep(i, se.size()) { if(i) os << ", "; os << *itr; itr++; }
//   return os << "}";
// }
// template<class t, class u>
// ostream& operator<<(ostream& os, const map<t, u>& mp) {
//   os << "{";
//   auto itr = mp.begin();
//   rep(i, mp.size()) { if(i) os << ", "; os << *itr; itr++; }
//   return os << "}";
// }
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int a, b;
  cin >> a >> b;
  rep(i, max(a, b))
    cout << min(a, b);
  cout << endl;
  return 0;
}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
int n;
cin>>n;
char C[n];
rep(i,n)
cin>>C[i];
int count=0;
map<char,int> m;
rep(i,n){
  if(m[C[i]]==0)
  count++;
m[C[i]]++;
//cout<<m[C[i]]<<endl; 
  }
//for(auto i:m)
//cout<<i.first<<" "<<i.second<<endl;



if(count==3)
cout<<"Three"<<endl;
else
cout<<"Four"<<endl;



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    double a;
	while(cin>>a){


	double v,t,y;
	t=a/9.8;
    y=4.9*t*t;
    for(int i=0;i<10000000;i++){
        if(y<=5*i-5){
            cout<<i<<endl;
            break;
        }
    }
	}
	return 0;
}

Measured memory_bytes: 1220
#include<stdio.h>
#define N 1000

int main(void){
  int i,num,j,spindle;
  int weight[N];
  int sp[10];
  int preweight;
  int digit,count;

  for(i=0;scanf("%d",&weight[i])==1;i++){}
  num=i;
  for(i=0;i<num;i++){
    for(j=0;j<10;j++){
      sp[j]=0;
    }
    for(j=9,spindle=512;j>=0;j--,spindle/=2){
      if(weight[i]>=spindle){
        weight[i]-=spindle;
        sp[j]=1;
      }
    }
    digit=0;
    for(j=0;j<10;j++){
      if(sp[j]==1){
        digit++;
      }
    }
    count=0;
    for(j=0,preweight=1;j<10;j++,preweight*=2){
      if(sp[j]==1){
        printf("%d",preweight);
        if(count<digit-1) printf(" ");
        count++;
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include<iostream>
using namespace std;
 
int main() {
    int ac,wa,tle,re,n;
    string s;
    cin >> n;
    ac = wa = tle = re = 0;
    for(int i = 0;i < n;i++){
        cin >> s;
        if(s == "AC"){
            ac++;
        }else if(s == "WA"){
            wa++;
        }else if(s == "TLE"){
            tle++;
        }else if(s == "RE"){
            re++;
        }
    }
    cout << "AC x "   << ac<< endl;
    cout << "WA x "   << wa<< endl;
    cout << "TLE x "   << tle<< endl;
    cout << "RE x "   << re<< endl;
}
   


Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  vector<int> v;
  int t;
  REP(i, 3) {
    scanf(" %d", &t);
    v.push_back(t);
  }
  sort(v.begin(), v.end());

  cout << v[0] * v[1] / 2 << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long
//cout << fixed << setprecision (10);   小数点以下１０桁まで

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

    cout <<(a-c)*(b-d)<< endl;
    
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
using namespace std;

const ll MAX =  1000 * 1000 ;
const int dx[] = { 1, -1 , 0 , 0  };
const int dy [] = { 0 ,0 , 1 , -1  };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 301 ;
const int INF = INT_MAX ;
const int M = 200005;
int main ( ){

ll h ; 
cin >> h ; 
// priority_queue<int>q ; 
// q.push( h ) ; 
// int cnt = 0 ; 
// while (!q.empty()){
// 	ll x = q.top() ;	
// 	++cnt ; 
// 	if ( x == 0 )
// 		break ; 
// 	q.pop();
// 	int  k = x / 2 ;  
// 	if ( k  !=  0 )
// 	{q.push(  k ) ; 
// 	q.push( k ) ;
// 	} 
// }

// cout << cnt  ; 
// br 

// ll res  = 0 ; 
// while ( ( 1ll << res ) < h ) res++ ;
// cout <<  ( res > 0 ? ( ( 1ll<<res) -1 ) : 1 ) ; 
// br   
ll  k = log2( h ) + 1  ; 
cout << ( 1ll<< k ) - 1  ; 




return 0 ;

}


Measured memory_bytes: 256
/*
Problem :
Algorithm :
Status :
*/
#include<bits/stdc++.h>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#define DEBUG printf("Passing Line %d in Function [%s].\n",__LINE__,__FUNCTION__);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const string S = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
const int L = 128;

int n;
vector<string> vec;

int Query(const string &s){
    cout << "? " << s << endl;
    int res;
    cin >> res;
    return res;
}

string dfs(int l,int r){
    if(l==r){
		return vec[l];
	}
	int mid=(l+r)>>1;
	string L=dfs(l,mid),R=dfs(mid+1,r),myh;
	int j=0;
	for(int i=0;i<(int)L.length();++i){
		while(j<(int)R.size()){
			string s=myh+R[j]+L.substr(i,L.length()-i);
			cout<<"? "<<s<<endl;
			int qwq;
			cin>>qwq;
			int o=L.length()+j+1;
			if(n-qwq!=o)break;
			myh+=R[j++];
		}
		myh+=L[i];
	}
	myh+=R.substr(j,R.length()-j);
	return myh;
}

int main(){
    // freopen("data.in","r",stdin);
    // freopen("data.out","w",stdout);
    for(char c : S){
        string s(128,c);
        int num = 128 - Query(s);
        if(num)
            vec.push_back(s.substr(0,num));
        n += num;
    }
    string ans = dfs(0,vec.size() - 1);
    cout << "! " << ans << endl;
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;
const LL mm = 1e9+7;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  int n,k; cin>>n>>k;
  vector<LL> pr(n+5,0),su(n+5,0);
  pr[0] = 0;
  for(int i=1;i<=n;i++){
  	pr[i] = pr[i-1]+i;
  }
  su[n+1]= 0;
  for(int i=n;i>=0;i--){
  	su[i] = su[i+1]+i;
  }
  LL an = 0;
  for(int i=k-1;i<=n;i++){
  	an =  (an - pr[i] + su[n-(i)] + 1LL)%mm;
  	an = (an+mm)%mm;
  	//cout<<pr[i]<<" "<<su[n+1-(i)]<<endl;
  }
  cout<<an%mm<<endl;
  return 0;
}



Measured memory_bytes: 6340
// source
// https://atcoder.jp/contests/abc175/submissions/15923583
#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for (auto &&e : p)
        cin >> e, --e;
    vector<int64_t> c(n);
    for (auto &&e : c)
        cin >> e;
    // 負のスコアを取る場合があるのでマイナスで初期化
    auto res = numeric_limits<int64_t>::min();
    for (int s = 0; s < n; ++s) {
        // 循環する要素を求める（Pi != i なので自分自身へループしない）
        vector<int64_t> v;
        for (int i = s;; i = p[i]) {
            v.push_back(c[i]);
            if (p[i] == s)
                break;
        }
        // 循環する要素の長さ
        int m = v.size();
        // 循環する要素の合計
        auto sum = accumulate(begin(v), end(v), 0LL);
        int64_t cur = 0;
        for (int r = 1; r <= m; ++r) {
            if (r > k)
                break;
            cur += v[r - 1];
            // 先頭からスコアを加算し、残りの長さに対して何回循環するか数える
            res = max(res, cur + (k - r) / m * max<int64_t>(sum, 0));
        }
    }
    cout << res << '\n';
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
    int d, t, s;
    cin >> d >> t >> s;
    if(d<=t*s){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int main() {
    string s; cin >> s;
    int n = (int)s.size();
    bool dp[n + 1];
    for (int i = 0; i <= n; ++i) {
      dp[i] = false;
    }
    dp[0] = true;
    for (int i = 0; i < n; ++i) {
        if (dp[i] == false) continue;
        if (i + 5 <= n and s.substr(i, 5) == "dream") dp[i + 5] = true;
        if (i + 7 <= n and s.substr(i, 7) == "dreamer") dp[i + 7] = true;
        if (i + 5 <= n and s.substr(i, 5) == "erase") dp[i + 5] = true;
        if (i + 6 <= n and s.substr(i, 6) == "eraser") dp[i + 6] = true;
    }
    cout << (dp[n] ? "YES" : "NO") << endl;
    return 0;
}



Measured memory_bytes: 640