akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++){
        cout<<"x";
    }
    cout<<endl;
    return 0;
    }


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  int R; cin >> R;
  if(R < 1200) cout << "ABC" << endl;
  else if(R < 2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;

  return 0;
}

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

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 10000

int main(void) {
  vll a;
  cin >> n;
  ll x;

  FOR(i, 0, n) {
	cin >> temp;
	a.push_back(temp);
  }

  x = 0;
  cnt++;

  FOR(i, 0, n - 1) {
	if (x == 0) {
	  if (a[i] == a[i + 1]) {
		x = 0;
	  }
	  else if (a[i] < a[i + 1]) {
		x = 1;
	  }
	  else {
		x = 2;
	  }
	}
	else if (x == 1) {
	  if (a[i] > a[i + 1]) {
		x = 0;
		cnt++;
	  }
	  else {
		x = 1;
	  }
	}
	else {
	  if (a[i] < a[i + 1]) {
		x = 0;
		cnt++;
	  }
	  else {
		x = 2;
	  }
	}
  }

  cout << cnt << endl;

  return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<long> A(N), B(N);
    vector<pair<long, long> > p(N);

    for(int i=0; i<N; i++){
        cin >> A.at(i) >> B.at(i);
        p.at(i).first = A.at(i);
        p.at(i).second = B.at(i);
    }
    sort(p.begin(), p.end());
    long long ans =0;
    int k=0;
    while (M > 0){
        if(M >= p.at(k).second){
            ans = ans + p.at(k).second*p.at(k).first;
            M = M - p.at(k).second;
            k++;
        }
        else{
            ans = ans + p.at(k).first * M;
            M = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
N = int(input())
L = list(map(int, input().split()))
L.sort()
count = 0
#print(L)

len = len(L)

for i in range(len):
    for j in range(i + 1, len):
        for k in range(j + 1, len):
            if (L[i] != L[j]) and (L[j] != L[k]) and (L[k] < L[i] + L[j]):
                #print(L[i], L[j], L[k])
                count += 1

print(count)


Measured memory_bytes: 9184
#include <stdio.h>

int main(void)
{
	int N, K, X, Y;
	scanf("%d%d%d%d", &N, &K, &X, &Y);

	int ans;
	if (N < K)
		ans = N * X;
	else
		ans = K * X + (N - K) * Y;
	
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n;
	cin >> n;
	int a[n];
	rep (i, n) cin >> a[i];
	sort(a, a + n);
	int pear = 0, berry = 0;
	rep (i, n) {
		if (i % 2 == 0) pear += a[i];
		else berry += a[i];
	}
	cout << abs(pear - berry) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,h,w;
	int a[11111]={},c[102][102]={};
	int dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
	cin>>h>>w>>n;
	int dir=1,x=1,y=1;
	FOR(i,0,102)FOR(j,0,102)c[i][j]=-1;
	FORQ(i,1,h)FORQ(j,1,w)c[i][j]=0;
	FOR(i,0,n){
		cin>>a[i];
		//cout<<a[i]<<" ";
	}
	//cout<<endl;
	int idx=0;
	FOR(i,0,h*w){
		c[x][y]=idx+1;
		a[idx]--;
		if(a[idx]==0)idx++;
		if(c[x+dx[dir]][y+dy[dir]]!=0){
			dir=(dir+1)%4;
			x+=dx[dir];
			y+=dy[dir];
		}else{
			x+=dx[dir];
			y+=dy[dir];
		}
	}
	FOR(i,0,h){
		FOR(j,0,w){
			cout<<c[i+1][j+1];
			if(j!=w-1)cout<<" ";
		}
		cout<<endl;
	}
    return 0;
}


Measured memory_bytes: 384
//Keep Working Hard
  // I__Like__Food  

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define tracel5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)

const int INF = (1LL << 30) - 1;

 const int N = 1e5 + 5;

 vector<int> adj[N];
 vector<bool> vis(N,false);

 vector<int> depth(N,INF);


void bfs(int s)
{
	queue<int> q;
	q.push(s);
	depth[s] = 0;
	vis[s] = true;

	while(!q.empty())
	{
		int k = q.front();
		q.pop();

		for(auto i : adj[k])
		{
			if(!vis[i])
			{
				vis[i] = true;
				q.push(i);
				depth[i] = min(depth[i],depth[k]+1);
			}
		}
	}
}

int32_t main()
{


    IOS

   	int n;
   	cin >> n;

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

   		adj[i].push_back(x);
   	//	trace2(i,x);

   	}

   	bfs(1);

   	if(!vis[2])
   	{
   		cout << -1;
   		return 0;
   	}


   	cout << depth[2];














    return 0;
}




Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int main(){
	string a,b;
	cin>>a>>b;
	if(a.size()>b.size())
	  cout<<"GREATER"<<endl;
	else if(a.size()<b.size())
	  cout<<"LESS"<<endl;
	else{
		bool eq=true;
		for(int i=0;i<a.size();i++)
		  if(a[i]>b[i]){
		  	eq=false;
		  	cout<<"GREATER"<<endl;
		  	break;
		  }
		  else if(a[i]<b[i]){
		  	eq=false;
		  	cout<<"LESS"<<endl;
		  	break;
		  }
		if(eq)
		  cout<<"EQUAL"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int n;
    cin>>n;
    int a[110][110]={0};
    int u,k,v;
    for(int i=0;i<n;i++){
        cin>>u>>k;
        if(k==0)continue;
        for(int j=0;j<k;j++){
            cin>>v;
            a[u-1][v-1]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout<<a[i][j];
            if(j<n-1)cout<<" ";
        }
        cout<<""<<endl;
    }
    return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>
#include <stdlib.h>

int main(void){
    char s[256];
    int i,count=0;
    for(i=0;i<3;i++){
        s[i] = getchar();
        count += s[i] - '0';
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
 
const int INF = 1<<28;
const double EPS = 1e-5;
const int MOD = 1000000007;
 
 
int a, b;
 
main(){
    while(cin >> a >> b){
        cout << (a+b?ceil(log10(a+b+EPS)):1.) << endl;
    }
    return 0;
}

Measured memory_bytes: 1268
class UnionFind(object):
    def __init__(self, N):
        self.parent = [-1] * N #parent[i] は(i+1)番目の要素が含まれる要素数の(-1)倍
    #要素が負-->その数を親とするグループに属する要素の数×(-1)
    #要素が正-->親のindex

    #Aがどのグループに属しているかを調べる
    def root(self, A):
        if self.parent[A-1] < 0: #負の数-->その数は親
            return A
        self.parent[A-1] = self.root(self.parent[A-1]) #負では無い時、親の場所が入っているから、親が属しているグループを、自分自身に入れる(一度確認したところは直接親を見れるようにする)
        return self.parent[A-1] #親の位置を返す

    #Aが含まれているグループに属している数を返す
    def size(self, A):
        return -1 * self.parent[self.root(A)-1]

    #AとBをくっ付ける
    def connect(self, A, B):
        A = self.root(A) #Aを含むグループの親を返す
        B = self.root(B) #Bを含むグループの親を返す
        if A == B: #親が同じならなにもしない
            return False
        
        #大きい方(A)に小さい方(B)をつなぎたい
        if self.size(A) < self.size(B): #大小関係が逆の時は入れ替える
            A, B = B, A
        
        self.parent[A-1] += self.parent[B-1] #大きい方に小さい方を加える　（負の数＋負の数 = 新しいグループに含まれる数×(-1)）
        self.parent[B-1] = A #加えられた親の値を、加えた先の親の位置に書き変える
        return True
    
    def same(self, A, B):
        if self.root(A) == self.root(B):
            return True
        else:
            return False
            
# N, Q = map(int, input().split())
# uni = UnionFind(N)
# for _ in range(Q):
#     P, A, B = map(int, input().split())
#     if P == 1:
#         if uni.root(A) == uni.root(B): #親が同じかどうか
#             print ('Yes')
#         else:
#             print ('No')
#     else:
#         uni.connect(A, B)

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
L1 = []
L1_append = L1.append

uni = UnionFind(M + 1)
for _ in range(N):
    KL = list(map(int ,input().split()))
    tmp = KL[1]
    L1_append(tmp)
    for i in KL[2:]:
        uni.connect(tmp, i)

tmp = uni.root(L1[0])
for i in L1[1:]:
    if tmp != uni.root(i):
        print ('NO')
        exit()

print ('YES')    
    


Measured memory_bytes: 10408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define ARRAY_LENGTH(array) sizeof(array)/sizeof(*array)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) {
    if(b == 0) {
        return a;
    }

    return gcd(b, a % b);
}

ll lcm2(ll a, ll b) {
    ll d = gcd(a, b);
    return a / d * b;
}

ll lcm(vector<ll> vec) {
    ll l = vec[0];
    REP(i, vec.size() - 1) {
        l = lcm2(l, vec[i + 1]);
    }
    return l;
}

int main() {
    ll N;
    cin >> N;

    vector<ll> T(N, 0);
    REP(i, N) {
        cin >> T[i];
    }

    cout << lcm(T) << endl;

    return 0;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = {"AC", "WA", "TLE", "RE"};
		int[] ans = new int[4];
		for (int N = sc.nextInt(); N > 0; N--) {
			String t = sc.next();
			for (int i = 0; i < 4; i++) {
				if (t.charAt(0) == s[i].charAt(0))
					ans[i]++;
			}
		}
		for (int i = 0; i < 4; i++) {
			System.out.println(s[i] + " x " + ans[i]);
		}
	}
}


Measured memory_bytes: 58644
n,k=gets.split
n=n.to_i
k=k.to_i

arr=gets.split.map(&:to_i)
ma=arr.max

if k>ma
    puts "IMPOSSIBLE"
    exit
end

ggg=arr[0]
i=1
(n-1).times{
    ggg=ggg.gcd(arr[i])
    
    
    if ggg==1
        puts "POSSIBLE"
        exit
    end
    
 i+=1   
    
}

if k%ggg==0
    puts "POSSIBLE"
else puts "IMPOSSIBLE"
end









Measured memory_bytes: 8452
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define MAX 100005
typedef pair<ll,ll> P;
typedef pair<ll, P > PP;
 
const ll INF = 10000000000000000LL;
 
struct segtree {
  vector<ll> data;
  vector<ll> delay;
 
  int n;
  void init(int _n){
    n = 1;
    while( n < _n ) n*=2;
    data.resize( 2 * n );
    delay.resize( 2 * n );
  }
 
  void delaycalc( int k ){
    data[k] = data[k] + delay[k];
    if( k + 1 < n )
      for(int i=1;i<=2;i++)
        delay[ 2 * k + i ] += delay[k];
    delay[k] = 0;
  }
 
  void add( int a, int b, ll x, int k, int l, int r ){
    delaycalc( k );
    if( r<=a  || b<=l ) return;
 
    else if( a <= l && r <= b ) {
      delay[k] = x;
      delaycalc( k );
    } else {
      add( a, b, x, 2 * k + 1, l, (l+r)/2 );
      add( a, b, x, 2 * k + 2, (l+r)/2, r );
      data[k] = min( data[ 2 * k + 1 ], data[ 2 * k + 2 ] );
    }
  }
 
  ll query( int a,int b,int k,int l, int r ){
    delaycalc( k );
    if( r<=a  || b<=l ) return INF;
    else if( a <= l && r <= b ) {
      return data[k] + delay[k];
    } else {
      ll vl = query( a, b, 2 * k + 1, l, (l + r)/2 );
      ll vr = query( a, b, 2 * k + 2, (l + r)/2, r );
      return min( vl, vr );
    }      
  }
 
  //[a, b)
  void add( int a, int b, ll x ,bool flg=false){
    if(flg)x*=-1LL;
    add( a, b, x, 0, 0, n );
  }
  //[a, b )
  ll query( int a, int b ,bool flg=false){
    ll res=query( a, b, 0, 0, n );
    if(flg)res*=-1LL;
    return res;
  }
  
};
 
 
segtree S,T;
ll N,L;
ll a[MAX],b[MAX];
ll c[MAX];
 
int search(ll x){
  int L=0,R=N,M;
  while(L<R){
    M=(L+R)/2;
    if(S.query(0,M,true) <x )L=M+1;
    else R=M;
  }
  return L;
}
 
int main(){
  cin>>N>>L;
  S.init(N+10);
  T.init(N+10);
 
  vector<PP> v;
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i];
    if(a[i]>=L){
      cout<<1<<endl;
      return 0;
    }
    v.push_back(PP(a[i]-b[i],P(a[i],b[i])));
  }
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(int i=0;i<N;i++){
    a[i]=v[i].second.first;
    b[i]=v[i].second.second;
  }
  for(int i=0;i<N;i++){
    ll num;
    cin>>num;
    c[i]=num;
    T.add(i,N,-num);
    T.add(i,N,a[i]-b[i]);
    S.add(i,N,a[i]-b[i],true);
  }
  
  ll ans=INF;
  for(int i=N-1;i>=0;i--){
    S.add(i,N,b[i]-a[i],true);
    T.add(i,N,b[i]-a[i]);
    if(i<N-1){
      T.add(i,N,c[i]);
      T.add(i+1,N,-c[i]);
    }
    /*    
    for(int j=0;j<N;j++){
      cout<<S.query(j,j+1,true)<<' '<<T.query(j,j+1)<<endl;
    }
    cout<<endl<<endl;
    */
    int id=search( L-a[i] );
 
 
    int si=0;
    if(i==0)si=1;
    if( T.query(si,id) > 0  && S.query(0,id,true) >= L-a[i] ){
      if(i<id)id--;
      ans=min(ans,(ll)id+1);
    }
 
    S.add(i,N,a[i]-b[i],true);
    T.add(i,N,a[i]-b[i]);
  }
  if(ans==INF)ans=-1;
  cout<<ans<<endl;  
  return 0;
  
}

Measured memory_bytes: 15984
#include <stdio.h>
#define MAX 100000

int A[MAX];

int partition(int p,int r){
    int x=A[r];
    int i=p-1;
    int j,store;
    for(j=p;j<r;j++){
        if(A[j]<=x){
            i+=1;
            store=A[i];
            A[i]=A[j];
            A[j]=store;
        }
    }
    store=A[i+1];
    A[i+1]=A[r];
    A[r]=store;
    return i+1;
}

int main(){
    int n,i;
    int prt;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    prt=partition(0,n-1);
    
    for(i=0;i<n;i++){
        if(i==prt) printf("[%d]",A[i]);
        else printf("%d",A[i]);
        if(i>=0&&i<n-1) printf(" ");
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 988
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set,multiset
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

void chmax(long long &a,long long b){if(a < b) a = b;}
void chmin(long long &a,long long b){if(a > b) a = b;}

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}



int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int N;cin >> N;
    vector<long long> A_sort(N),B_sort(N);
    for(int i = 0;i<N;i++) cin >> A_sort.at(i) >> B_sort.at(i);
    sort(A_sort.begin(),A_sort.end());
    sort(B_sort.begin(),B_sort.end());
    long long minMedian = -INF,maxMedian = INF;
    if(N % 2 == 1){
        minMedian = A_sort.at(N/2);
        maxMedian = B_sort.at(N/2);
        cout << maxMedian - minMedian + 1 << endl;
    }
    else{
        minMedian = A_sort.at(N/2-1) + A_sort.at(N/2);
        maxMedian = B_sort.at(N/2-1) + B_sort.at(N/2);
        cout << maxMedian - minMedian + 1 << endl;
    }
}


Measured memory_bytes: 6364
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

// AGC016 B

bool solve(const vs32& a, int num)
{
    const int n = a.size();

    int cnt = 0;
    rep (i, n)
    {
        if (a[i] != num)
        {
            ++cnt;
        }
    }

    return cnt + 1 == num || (cnt < num && (num - cnt) * 2 <= (n - cnt));
}

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

    int n;
    cin >> n;

    vs32 a(n);
    set<int> s;
    rep (i, n)
    {
        cin >> a[i];
        s.insert(a[i]);
    }

    if (s.size() >= 3)
    {
        cout << "No\n";
    }
    else if (s.size() == 2 && abs(*s.begin() - *s.rbegin()) >= 2)
    {
        cout << "No\n";
    }
    else if (s.size() == 2)
    {
        int num = *s.rbegin();
        if (solve(a, num))
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
    }
    else // all a are equal
    {
        int num = *s.begin();
        if (n == num + 1)
        {
            cout << "Yes\n";
        }
        else if (2 * num <= n)
        {
            cout << "Yes\n";
        }
        else
        {
            cout << "No\n";
        }
        
    }

    return 0;
}



Measured memory_bytes: 8264
package main

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

var (
	readString func() string
	stdout     *bufio.Writer
)

func init() {
	readString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = readInt()
	}
	return b
}

func readLengthAndSlice() (int, []int) {
	n := readInt()
	return n, readIntSlice(n)
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdout, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdout, args...)
}

func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// readString() string
// readInt() int
// readIntSlice(n int) []int
// readLengthAndSlice() []int

// -----------------------------------------------------------------------------

func main() {
	defer stdout.Flush()

	N := readInt()
	A := readInt()
	B := readInt()
	if A > B {
		println(0)
		return
	}
	if A == B {
		println(1)
		return
	}
	if N < 2 {
		println(0)
		return
	}

	println((N-2)*(B-A) + 1)
}

// -----------------------------------------------------------------------------


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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int N = 1e+5;
const int Q = 50000;
int n, q;
int s[N], t[Q];

int binary_search(int x) {
  int l = -1;
  int r = n-1;
  int m;
  while (r-l > 1) {
    m = (l+r)/2;
//   if (s[m] == x)
//      return m;
//    else if (x < s[m])
    if (x <= s[m])
      r = m;
    else
      l = m;
//printf("(l, r] = (%d %d]\n", l, r);
  }

  if (s[r]==x)
    return r;
  else
    return -1;
}

int main() {
  int i;
  scanf("%d ", &n);
  for (i=0; i<n; i++)
    scanf("%d ", s+i);
  scanf("%d ", &q);
  for (i=0; i<q; i++)
    scanf("%d ", t+i);

  int res = 0;
  for (i=0; i<q; i++)
    if (binary_search(t[i]) != -1) {
//      printf("%d\n", t[i]); 
      res++;
    }

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

	return 0;
}

Measured memory_bytes: 1776
n, m = map(int, input().split())
sa = set()
sb = set()
for _ in range(m):
    a, b = map(int, input().split())
    if a == 1:
        sb.add(b)
    if b == n:
        sa.add(a)

print('POSSIBLE' if len(sa&sb) != 0 else 'IMPOSSIBLE')


Measured memory_bytes: 19024
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
#include<cmath>
#include<vector>
#include<utility>
#include<algorithm>
#include<ctype.h>
using namespace std;


int main() {
	int x,c=0;
	cin >> x;
	while (c==0) {
		for (int i = 2;i<=x;i++) {
			if (x%i==0&&i<x) {
				break;
			}
			if (i==x) {
				cout << x << endl;
				c = 1;
			}
		}
		x++;
	}
}

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

namespace A
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            var n = Cint();
            if (n.ToString().Contains('7'))
            {
                Cout("Yes");
            }
            else
            {
                Cout("No");
            }
        }

        #region Input and Output

        private static readonly List<string> Buffer = new List<string>();

        private static string Cin()
        {
            ReadBuffer();

            var str = Buffer.First();
            Buffer.RemoveAt(0);

            return str;
        }

        private static IEnumerable<string> CinA() => Console.ReadLine()?.Split();
        private static int Cint() => int.Parse(Cin());
        private static int[] CintA() => CinA().Select(int.Parse).ToArray();
        private static void Cout(object obj) => Console.WriteLine(obj);

        private static void ReadBuffer()
        {
            if (Buffer.Any()) return;

            var line = Console.ReadLine();
            if (line != null && line.Contains(' '))
            {
                Buffer.AddRange(line.Split());
            }
            else
            {
                Buffer.Add(line);
            }
        }

        #endregion

        #region Loops

        private static void Loop(int count, Action<int> action) => Loop(0, count, action);

        private static void Loop(int init, int count, Action<int> action, int step = 1)
        {
            for (var i = init; i < count + init; i += step)
            {
                action(i);
            }
        }

        #endregion
    }
}


Measured memory_bytes: 28192
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin >> s[i];
  sort(s.begin(),s.end());
  string t;
  for(int i=0;i<n;i++) t+=s[i];
  cout << t << endl;  
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
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(){
    VI array(5);
    ll ans = 0;
    int minNum = 10;
    rep(i,5){
        cin >> array[i];
        if(array[i] % 10 != 0 ) minNum = min(array[i]%10,minNum);
    }

    rep(i,5){
        if(array[i] % 10 != 0) ans += array[i]/10 * 10 + 10;
        else ans += array[i];
    }


    cout << ans - (10-minNum)<< endl;
    return 0;
}


Measured memory_bytes: 764
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
a,b,k=gsmi

if a>=k
  puts [a-k,b].join(" ")
else
  puts [0,max(b-(k-a),0)].join(" ")
end

Measured memory_bytes: 1788
#include <climits>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

struct edge {
	int to, dist, num;
	edge(int t, int d, int n):to(t), dist(d), num(n){}
};

struct state {
	int pos, num, money;
	state(int p, int n, int m):pos(p), num(n), money(m){}
	bool operator>(const state& s) const {
		return num > s.num;
	}
};

vector<vector<edge> > es;

int dijkstra(int s, int t, int l) {
	priority_queue<state, vector<state>, greater<state> > que;
	vector<vector<int> > nums(es.size(), vector<int>(l + 1, INT_MAX));
	que.push(state(s, 0, l));
	nums[s][l] = 0;
	
	while(!que.empty()) {
		state s = que.top();
		que.pop();
		if(nums[s.pos][s.money] < s.num)
			continue;

		if(s.pos == t)
			return s.num;

		for(int i = 0; i < es[s.pos].size(); ++i) {
			const edge& e = es[s.pos][i];
			if(nums[e.to][s.money] > nums[s.pos][s.money] + e.num) {
				nums[e.to][s.money] = nums[s.pos][s.money] + e.num;
				que.push(state(e.to, nums[e.to][s.money], s.money));
			}

			if(s.money >= e.dist && nums[e.to][s.money - e.dist] > nums[s.pos][s.money]) {
				nums[e.to][s.money - e.dist] = nums[s.pos][s.money];
				que.push(state(e.to, nums[e.to][s.money - e.dist], s.money - e.dist));
			}
		}
	}
}

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

	for(int n, m, l; cin >> n >> m >> l, n;) {
		es.clear();
		es.resize(n);
		for(int i = 0; i < m; ++i) {
			int a, b, d, e;
			cin >> a >> b >> d >> e;

			--a;
			--b;
			es[a].push_back(edge(b, d, e));
			es[b].push_back(edge(a, d, e));
		}

		cout << dijkstra(0, n - 1, l) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1464
A, B, C = map(int, raw_input().split())
[A, B, C] = sorted([A, B, C])
ans = 0
while A%2==0 and B%2==0 and C%2==0:
	ans += 1
	new1, new2, new3 = B/2 + C/2, A/2 + C/2, A/2 + B/2
	if new1 == new3:
		ans = -1
		break
	else:
		A, B, C = new1, new2, new3
print ans


Measured memory_bytes: 2568
#include <stdio.h>

#define HEIGHT 12
#define WIDTH 6

enum { YET, ALREADY };

int calcChain( void );
int deleteBlock( void );
int findGroup( int, int );
int findGroup_body( int, int, char, int );
void deleteGroup( int, int );
void deleteGroup_body( int, int, char, int );
void fallBlock( void );

typedef struct {
	char color;
	int state;
} FIELD;

FIELD field[ HEIGHT ][ WIDTH ];
const int dx[ 4 ] = { -1, 0, 1, 0 };
const int dy[ 4 ] = { 0, -1, 0, 1 };

int main( void ) {
	int i, j, n;

	scanf( "%d%*c", &n );
	while ( n-- ) {
		for ( i = 0; i < HEIGHT; i++ ) {
			for ( j = 0; j < WIDTH; j++ ) {
				scanf( "%c", &field[ i ][ j ].color );
				field[ i ][ j ].state = YET;
			}

			scanf( "%*c" );
		}

		printf( "%d\n", calcChain() );
	}

	return 0;
}

int calcChain( void ) {
	int chain;

	for ( chain = 0; ; chain++ ) {
		if ( !deleteBlock() )
			break;

		fallBlock();
	}

	return chain;
}

int deleteBlock( void ) {
	int i, j, deleted;

	deleted = 0;
	for ( i = 0; i < HEIGHT; i++ )
		for ( j = 0; j < WIDTH; j++ )
			if ( field[ i ][ j ].color != '.' && field[ i ][ j ].color != 'O' && field[ i ][ j ].state == YET )
				if ( findGroup( i, j ) >= 4 ) {
					deleted = 1;
					deleteGroup( i, j );
				}

	return deleted;
}

int findGroup( int i, int j ) {
	field[ i ][ j ].state = ALREADY;

	return findGroup_body( i, j + 1, field[ i ][ j ].color, 0 ) + findGroup_body( i + 1, j, field[ i ][ j ].color, 1 ) + 1;
}

int findGroup_body( int i, int j, char color, int comeDir ) {
	int tmp, d;

	if ( i < 0 || i >= HEIGHT || j < 0 || j >= WIDTH || field[ i ][ j ].state == ALREADY || field[ i ][ j ].color != color )
		return 0;

	field[ i ][ j ].state = ALREADY;

	tmp = 0;
	for ( d = 0; d < 4; d++ )
		if ( d != comeDir )
			tmp += findGroup_body( i + dy[ d ], j + dx[ d ], color, d + 2 & 3 );
	
	return tmp + 1;
}

void deleteGroup( int i, int j ) {
	int color = field[ i ][ j ].color, d;

	field[ i ][ j ].color = '.';

	for ( d = 0; d < 4; d++ )
		deleteGroup_body( i + dy[ d ], j + dx[ d ], color, d + 2 & 3 );
}

void deleteGroup_body( int i, int j, char color, int comeDir ) {
	int d;

	if ( i < 0 || i >= HEIGHT || j < 0 || j >= WIDTH )
		return;

	if ( field[ i ][ j ].color != color ) {
		if ( field[ i ][ j ].color == 'O' )
			field[ i ][ j ].color = '.';

		return;
	}

	field[ i ][ j ].color = '.';

	for ( d = 0; d < 4; d++ )
		if ( d != comeDir )
			deleteGroup_body( i + dy[ d ], j + dx[ d ], color, d + 2 & 3 );
}

void fallBlock( void ) {
	int i, j, cnt;

	for ( j = 0; j < WIDTH; j++ ) {
		cnt = 0;
		for ( i = HEIGHT - 1; i >= 0; i-- )
			if ( field[ i ][ j ].color == '.' )
				cnt++;
			else {
				field[ i + cnt ][ j ].color = field[ i ][ j ].color;
				field[ i + cnt ][ j ].state = YET;
			}

		for ( i = cnt - 1; i >= 0; i-- )
			field[ i ][ j ].color = '.';
	}
}

Measured memory_bytes: 596
import sys
input = sys.stdin.readline
max_n = 10**5
ans = 0
n = int(input())

class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.sizea = [1 if _ < n//2 else 0 for _ in range(n)]
        self.sizeb = [0 if _ < n//2 else 1 for _ in range(n)]
        self.sizec = [1 for _ in range(n)]
        self.rank = [0] * (n)
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def is_root(self, x):
        if self.par[x] == x:
            return True
        else:
            return False
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.sizea[x] += self.sizea[y]
            self.sizeb[x] += self.sizeb[y]
            self.sizec[x] += self.sizec[y]
        else:
            self.sizec[x] += 1          

    def get_size(self, x):
        x = self.find(x)
        return self.sizea[x],self.sizeb[x],self.sizec[x]

uf = UnionFind(2*max_n)

for _ in range(n):
  x,y = map(int, input().split())
  x -= 1
  y += max_n - 1
  uf.union(x, y)

for i in range(max_n):
  if uf.is_root(i):
    a,b,c = uf.get_size(i)
    if a*b > 1:
      ans += a*b -(c-1)
print(ans)

Measured memory_bytes: 17332
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int r,d,x2000,t=10;
    cin>>r>>d>>x2000;
    while (t--)
    {
        x2000=r*x2000-d;
        cout<<x2000<<'\n';
    }   
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	int x=Integer.parseInt(str[0]);
            	int y=Integer.parseInt(str[1]);

            	if(x==0&&y==0){
            		break;
            	}
            	for(int i=0;i<x;i++){
            		for(int j=0;j<y;j++){
            			if((i+j)%2==0){
            				System.out.print("#");
            			}else{
            				System.out.print(".");
            			}
            		}
            		System.out.println();
            	}
            	System.out.println();
            }
        }
    }

}

Measured memory_bytes: 31680
def main():
    n = int(input())
    x_s = list(map(int,input().split()))
    mn = 10 ** 14

    for i in range(101):
        #print("ポイント：",i,"のとき")

        sm = sum([((x-i)**2) for x in x_s])
        if sm < mn:
            mn = sm
    print(mn)




def distance(p,x):
    return (x - p) ** 2

main()


Measured memory_bytes: 2940
#include <iostream>
#include <map>

using namespace std;

map< int64_t, int > prime_factor(int64_t n) {
    map< int64_t, int > ret;
    for(int64_t i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}


int main(void) {
    int64_t N;
    cin >> N;

    auto p = prime_factor(N);
    int64_t ans = 0;
    for(auto [key,val]: p) {
        int64_t ok = 0;
        int64_t ng = 1'000'000'000;
        while(ok + 1 < ng) {
            int64_t mid = (ok + ng) / 2;
            if(mid*(mid+1)/2 <= val) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        ans += ok;
    }

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


Measured memory_bytes: 3644
#include<stdio.h>
#include<string.h>
int main(void){
  int i;
  char s[100001];
  char t[50001];
  
  scanf("%s",s);
  
  int l;
  l=strlen(s);
    
  for(i=0;i<l;i+=2){
      t[(int)(i/2)]=s[i];
  }
  
  printf("%s",t);
  return 0;
}

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

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

    vector<int> res(s.size());
    int p = 0;
    rep(i, s.size() - 1){
        if (s[i] == 'R' && s[i + 1] == 'R') p++;
        if (s[i] == 'R' && s[i + 1] == 'L'){
            p++;
            res[i] = p;
            p = 0;
        }
    }
    p = 0;
    for (int i = s.size() - 1; i > 0; i--){
        if (s[i] == 'L' && s[i - 1] == 'L') p++;
        if (s[i] == 'L' && s[i - 1] == 'R'){
            p++;
            res[i] = p;
            p = 0;
        }
    }
    vector<int> ans(s.size());
    rep(i, s.size() - 1){
        if (s[i] == 'R' && s[i + 1] == 'L'){
            ans[i + 1] = res[i] / 2 + (res[i + 1] + 1) / 2;
            ans[i] = res[i + 1] / 2 + (res[i] + 1) / 2;
        }
    }
    rep(i, ans.size()) cout << ans[i] << " ";
}

Measured memory_bytes: 4264
n,x=map(int,input().split(" "))
l=list(map(int,input().split()))
list.sort(l)
count=0
for i in range(n):
    x-=l[i]
    if x >= 0:
        count+=1
        pass
    else:
        break
else:
    if x > 0:
        count-=1
    else:
        pass
print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

#if 0
所用時間:

感想:

#endif

int N; int A[30];

int main(){
  while(cin >> N && N){
    A[0] = 1;
    A[1] = 1;
    A[2] = A[1] + A[0];
    if(N > 2){
      for(int i = 3; i <= N; ++i){
        A[i] = A[i-1] + A[i-2] + A[i-3];
      }
    }
    cout << (A[N]/10)/365 + 1 << endl;
  }
}



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

using namespace std;
int main(void){
    int N;
    cin >> N; cin.ignore();
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    cin.ignore();
    
    vector<int> count(100002, 0);
    for (int v: A) {
        if (v > 0) count[v-1]++;
        count[v]++;
        count[v+1]++;
    }
    
    int ans = 0;
    for (int v: count) {
        if (v > ans) ans = v;
    }
    
    cout << ans << endl;
}


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

int main() {
	string cipher;

	while (getline(cin, cipher)) {
		for (int i = 0; i < 26;i++) {
			for (unsigned int n = 0;n < cipher.length();n++) {
				if (cipher.at(n) == 'z') {
					cipher.at(n) = 'a';
				}
				else if (cipher.at(n) >= 'a'&&cipher.at(n) <= 'y') {
					cipher.at(n)++;
				}
			}

			if (cipher.find("the") != string::npos ||
				cipher.find("this") != string::npos ||
				cipher.find("that") != string::npos) {
				cout << cipher << endl;
			}
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 1180
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
 
int t1[400010],t2[400010],a[200010],st[10000010],ed[10000010],n,tot;
 
struct node
{
    int from,mn;
    node() {}
    node(int x,int y):from(x),mn(y) {}
};
 
inline bool operator <(node x,node y) { return a[x.mn]>a[y.mn]; }
 
priority_queue<node> q;
 
inline int rd()
{
    int x=0;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar());
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x;
}
 
inline void gao(int &x,int y) { if (a[y]<a[x]) x=y; }
 
inline void build1(int x,int l,int r)
{
    if (l==r) { t1[x]=l*2-1;return; }
    int mid=(l+r)>>1;
    build1(x<<1,l,mid);
    build1(x<<1|1,mid+1,r);
    t1[x]=(a[t1[x<<1]]<a[t1[x<<1|1]])?t1[x<<1]:t1[x<<1|1];
}
 
inline int query1(int o,int l,int r,int x,int y)
{
    if (l>=x&&r<=y) return t1[o];
    int mid=(l+r)>>1,res=0;
    if (x<=mid) gao(res,query1(o<<1,l,mid,x,y));
    if (y>mid) gao(res,query1(o<<1|1,mid+1,r,x,y));
    return res;
}
 
inline void build2(int x,int l,int r)
{
    if (l==r) { t2[x]=l*2;return; }
    int mid=(l+r)>>1;
    build2(x<<1,l,mid);
    build2(x<<1|1,mid+1,r);
    t2[x]=(a[t2[x<<1]]<a[t2[x<<1|1]])?t2[x<<1]:t2[x<<1|1];
}
 
inline int query2(int o,int l,int r,int x,int y)
{
    if (l>=x&&r<=y) return t2[o];
    int mid=(l+r)>>1,res=0;
    if (x<=mid) gao(res,query2(o<<1,l,mid,x,y));
    if (y>mid) gao(res,query2(o<<1|1,mid+1,r,x,y));
    return res;
}
 
int main()
{
    n=rd();a[0]=2123333333;
    for (int i=1;i<=n;i++) a[i]=rd();
    st[tot=1]=1;ed[1]=n;
    build1(1,1,n>>1);
    build2(1,1,n>>1);
    q.push(node(1,t1[1]));
    for (int hhhh=1;hhhh<=(n>>1);hhhh++)
    {
        node hh=q.top();q.pop();
        int x=hh.from,id=hh.mn;
        int l=st[x],r=ed[x],now;
        if (id&1) now=query2(1,1,n>>1,(id+1)>>1,r>>1);
        else now=query1(1,1,n>>1,(id>>1)+1,(r+1)>>1);
        printf("%d %d ",a[id],a[now]);
        if (id>l)
        {
            st[++tot]=l;ed[tot]=id-1;
            int hhh=(l&1)?query1(1,1,n>>1,(l+1)>>1,id>>1):query2(1,1,n>>1,l>>1,(id-1)>>1);
            q.push(node(tot,hhh));
        }
        if (now<r)
        {
            st[++tot]=now+1;ed[tot]=r;
            int hhh=(now&1)?query2(1,1,n>>1,(now+1)>>1,r>>1):query1(1,1,n>>1,(now>>1)+1,r>>1);
            q.push(node(tot,hhh));
        }
        if (now-id>1)
        {
            st[++tot]=id+1;ed[tot]=now-1;
            int hhh=(id&1)?query2(1,1,n>>1,(id+1)>>1,(now-1)>>1):query1(1,1,n>>1,(id>>1)+1,(now-1)>>1);
            q.push(node(tot,hhh));
        }
    }
    puts("");
    return 0;
}

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

int main() {
  int N, M, X, Y;
  scanf("%d%d%d%d", &N, &M, &X, &Y);

  int max_x = -101;
  for (int i = 0; i < N; i++) {
    int x;
    scanf("%d", &x);
    max_x = max(max_x, x);
  }

  int min_y = 101;
  for (int i = 0; i < M; i++) {
    int y;
    scanf("%d", &y);
    min_y = min(min_y, y);
  }

  if (max_x < min_y && X <= max_x && Y >= min_y) {
    printf("No War");
  } else {
    printf("War");
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<sstream>
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define lb(v,n) lower_bound(v.begin(),v.end(),n)
#define ub(v,n) upper_bound(v.begin(),v.end(),n)
#define mae(v) max_element(v.begin(),v.end())
#define mie(v) min_element(v.begin(),v.end())
////////////////////////////////////////////////////////////

int main(){
	vector<long> v(10);
	rep(i,0,10)
		cin >> v[i];
	rvsort(v);
	rep(i,0,3){
		P(v[i]);
	}
	ret 0;
}


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

typedef long long ll;

using namespace std;

int main() {
    int N; string S;
    cin >> N >> S;
    if (N < 3) {
        cout << 0 << endl;
        return 0;
    }
    ll r = 0, g = 0, b = 0, x = 0;
    for (int i = 0; i < N; i++) {
        if (S[i] == 'R') {
            r++;
        } else if (S[i] == 'G') {
            g++;
        } else if (S[i] == 'B') {
            b++;
        }
    }
    for (int i = 0; i < N - 2; i++) {
        for (int j = i + 1; j < N - 1; j++) {
            int k = 2 * j - i;
            if (k >= N) continue;
            if (S[i] != S[j] && S[i] != S[k] && S[j] != S[k]) {
                x++;
            }
        }
    }
    cout << r * g * b - x << endl;
    return 0;
}



Measured memory_bytes: 3596
#include<stdio.h>
#include<stdlib.h>
void isort(int*, int);
main()
{
    int *a, n, i;
    scanf("%d", &n);
    a = (int*)malloc(sizeof(int) * n);
    for(i = 0; i < n - 1; i++){
        scanf("%d ", &a[i]);
    }
    scanf("%d", &a[i]);
    for(i = 0; i < n - 1; i++){
            printf("%d ", a[i]);
        }
        printf("%d\n", a[i]);
    isort(a, n);
    free(a);
}
void isort(int *a, int n)
{
    int i,j, temp;
   for(i = 1; i < n; i++){
        temp = a[i];
        j = i - 1;
        while(j >= 0 && a[j] > temp){
            a[j + 1] = a[j];
            j--;
        }
        a[j + 1] = temp;
        for(j = 0; j < n - 1; j++){
            printf("%d ", a[j]);
        }
        printf("%d\n", a[j]);
    }
}

Measured memory_bytes: 1852
import functools
import fractions
N = int(input())
A = [int(i) for i in input().split()]
S = set(A)


mod = 10**9 + 7


def multiple(a, b):
    return a*b // fractions.gcd(a, b)


def lcm(nums):
    return functools.reduce(multiple, nums)


lcm = lcm(S)

ans = 0
for a in A:
    ans += lcm//a
    # ans %= mod
print(ans % mod)


Measured memory_bytes: 6592
import java.util.*;
import java.math.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger a = new BigInteger(sc.next());
		BigInteger b = new BigInteger(sc.next());
		int x = a.compareTo(b);
		if (x > 0) {
			System.out.println("GREATER");
		} else if (x < 0) {
			System.out.println("LESS");
		} else {
			System.out.println("EQUAL");
		}
	}
}


Measured memory_bytes: 22996