akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
typedef pair<int,int> pii;
int MOD = 998244353;
struct Data{
    int S;
    int T;
    int X;
};
#define MAX 1000000100

signed main(){
    int n,q;
    cin >> n >> q;
    vector<Data> data(n+1);
    priority_queue<pii,vector<pii>,greater<pii>> s;
    priority_queue<pii,vector<pii>,greater<pii>> x;
    rep(i,n){
        int ss,tt,xx;
        cin >> ss >> tt >> xx;
        data[i].S = ss;
        data[i].T = tt;
        data[i].X = xx;
        s.push(MP(ss-xx,i));
    }
    data[n].S = 0;
    data[n].T = 2*MAX;
    data[n].X = MAX;
    s.push(MP(0,n));

    rep(i,q){
        int d;
        cin >> d;
        while(s.size() > 0 && s.top().fi <= d){
            int j = s.top().se;
            x.push(MP(data[j].X,j));
            s.pop();
        }
        while(data[x.top().se].T - x.top().fi <= d){
            x.pop();
        }

        if(x.top().fi == MAX)cout << -1 << endl;
        else cout << x.top().fi << endl; 
    }



     
    return 0;
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://cf17-final-open.contest.atcoder.jp/tasks/cf17_final_a
// rm -r -f test;oj dl http://abc128.contest.atcoder.jp/tasks/abc128_e


Measured memory_bytes: 15724
from collections import deque

a = deque(list(input()))
b = deque(list(input()))
c = deque(list(input()))

turn = a.popleft()
while True:
    if turn == "a":
        try:
            turn = a.popleft()
        except:
            print("A")
            exit()
    elif turn == "b":
        try:
            turn = b.popleft()
        except:
            print("B")
            exit()
    else:
        try:
            turn = c.popleft()
        except:
            print("C")
            exit()



Measured memory_bytes: 38364
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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 factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> c(n-1), s(n-1), f(n-1);
    rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
    rep(i, n-1) {
        ll t = s[i] + c[i];
        for (int j=i+1; j<n-1; ++j) {
            if (t < s[j]) t = s[j];
            else if (t%f[j]==0);
            else t = t+f[j] - t%f[j];
            t += c[j];
        }
        cout << t << endl;
    }
    cout << "0" << endl;
    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
struct Edge{
    ll from;
    ll to;
    ll cost;
};
int main(void){
    ll n, m;
    cin >> n >> m;

    vector<Edge> e;

    for(int i = 0; i < m; i++){
        Edge tmp;
        cin >> tmp.from >> tmp.to >> tmp.cost;
        tmp.from--;
        tmp.to--;
        tmp.cost *= -1;
        e.push_back(tmp);
    }

    vector<ll> dist(n, INF);
    dist[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = 0; i < e.size(); i++){
            if(dist[e[i].to] > dist[e[i].from] + e[i].cost){
                dist[e[i].to] = dist[e[i].from] + e[i].cost;
            }
        }
    }

    vector<int> negative(n, 0);

    for(int i = 0; i <= n; i++){
        for(int j = 0; i < e.size(); i++){
            if(dist[e[i].to] > dist[e[i].from] + e[i].cost){
                dist[e[i].to] = dist[e[i].from] + e[i].cost;
                negative[e[i].to] = 1;

            }
        }
    }

    if(negative[n - 1]){
        cout << "inf" << endl;
    } else {
        cout << -dist[n - 1] << endl;
    }


}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[200005];
vector<P>vec;
int main(){
	cin>>n;
	repn(i,n){
		cin>>a[i];
		if(a[i]) vec.pb(mp(i,a[i]));
	}
	ll ans = 0;
	repn(i,n){
		P p = mp(i,-1);
		int x = POSL(vec,p);
		int cnt[22]={};
		while(x != vec.size()){
			int v = vec[x].sc;
			rep(j,22){
				cnt[j] += (((v>>j)&1));
				if(cnt[j] >= 2){
					ans += (vec[x].fi-i);
					goto nxt;
				}
			}
			x++;
		}
		ans += (n+1-i);
		nxt:;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2932
#include <iostream>
using namespace std;
#define POS "Possible"
#define IMP "Impossible"

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int b[200];
    fill_n(b, 200, 0);
    int R = 0;
    for(int i=0; i<N; i++){
        int a;
        cin >> a;
        R = max(R, a);
        b[a]++;
    }
    if(R % 2 == 0){
        for(int i=1; i<R/2; i++)
            if(b[i] != 0){
                cout << IMP << endl;
                return 0;
            }
        if(b[R/2] != 1){
            cout << IMP << endl;
            return 0;
        }
        for(int i=R/2+1; i<=R; i++)
            if(b[i] < 2){
                cout << IMP << endl;
                return 0;
            }
    }
    if(R % 2 == 1){
        for(int i=1; i<=R/2; i++)
            if(b[i] != 0){
                cout << IMP << endl;
                return 0;
            }
        if(b[R/2+1] != 2){
            cout << IMP << endl;
            return 0;
        }
        for(int i=R/2+2; i<=R; i++)
            if(b[i] < 2){
                cout << IMP << endl;
                return 0;
            }
    }
    cout << POS << endl;
	return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            string s = Console.ReadLine();
            char x = s[0];
            char y = s[2];
            if( x == y)
            {
                Console.WriteLine("=");
            }else if( x > y)
            {
                Console.WriteLine(">");
            }
            else
            {
                Console.WriteLine("<");
            }
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#define N 11111
typedef long long ll;
ll a[N], b[N];
int main(void)
{
	int n;
	scanf("%d", &n);
	int i;
	for (i = 0; i < n; ++i) scanf("%lld", a + i);
	for (i = 0; i < n; ++i) scanf("%lld", b + i);
	ll s1 = 0, s2 = 0;
	for (i = 0; i < n; ++i) {
		if (a[i] > b[i]) s1 += a[i] - b[i];
		if (a[i] < b[i]) s2 += (b[i] - a[i]) / 2;
	}
	printf("%s", s1 <= s2 ? "Yes" : "No");
}

Measured memory_bytes: 384
N = int(input())
H = list(map(int, input().split()))

hantei = True
max = H[0]
for i in range(N-1):
    if H[i] >= H[i+1]:
        H[i] -= 1
    if max < H[i]:
        max = H[i]
    if max > H[i+1]:
        hantei = False
        break

if hantei:
    print("Yes")
else:
    print("No")


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

using namespace std;

#define _for(i,j,N) for(int i = (j); i <(N);i++)

using namespace std;

int N;
int a;
vector<int> vi;


int main()
{
    scanf("%d",&N);
    _for(i,0,N){
        scanf("%d",&a);
        if(vi.empty()) vi.push_back(a);
        else{
            if(vi[vi.size()-1] < a) vi.push_back(a);
            auto k = lower_bound(vi.begin(),vi.end(),a);
            if(*k == a) continue;
            else *(k) = a;
        }
    }

    int sz = vi.size();
    printf("%d\n",sz);

    return 0;
}




Measured memory_bytes: 3400
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

signed main() 
{
        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
        int n;
        cin>>n;
        cout<<180*n-360;
        



        return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, X;
  cin >> N >> X;
  
  ll L[N];
  rep(i,N){
    cin >> L[i];  
  }
  ll here=0;
  int i=0;
  while(here <= X){
    here += L[i];
    i++;
  }

  cout << i << endl;

  return 0;
    

}


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

#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;

	vector<int> value;

	cin >> N;

	for (int i = 1; i <= N; i++)
	{
		int a;
		cin >> a;

		value.push_back(a);
	}

	sort(value.begin(), value.end(), greater<int>());

	int sum_alice = 0;
	int sum_bob = 0;

	for (int i = 0; i < N; i+=2)
	{
		sum_alice += value[i];
	}

	for (int i = 1; i < N; i += 2)
	{
		sum_bob += value[i];
	}

	cout << sum_alice - sum_bob << endl;

}

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

#define pb push_back

int main()
{
    int a,b,m,ar1[100005],ar2[100005],i,x,y,c;
    vector<int>v;
    cin>>a>>b>>m;
    for(i=0; i<a; i++)
        cin>>ar1[i];
    for(i=0; i<b; i++)
        cin>>ar2[i];
    for(i=0; i<m; i++)
    {
        cin>>x>>y>>c;
        v.pb(ar1[x-1]+ar2[y-1]-c);
    }
    sort(ar1,ar1+a);
    sort(ar2,ar2+a);
    v.pb(ar1[0]+ar2[0]);
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;
}


Measured memory_bytes: 1660
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC push_options
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#include <xmmintrin.h>
#include <immintrin.h>
using namespace::std;
__attribute__((constructor))void init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// typedef mp::number<mp::cpp_dec_float<0>> cdouble;
// typedef mp::cpp_int cint;
template<typename T>using pbds=__gnu_pbds::tree<T,__gnu_pbds::null_type,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T>using pbds_map=__gnu_pbds::tree<T,T,less<T>,__gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update>;
template<typename T,typename E>using hash_map=__gnu_pbds::gp_hash_table<T,E>;
template<typename T>using pqueue =__gnu_pbds::priority_queue<T, greater<T>,__gnu_pbds::rc_binomial_heap_tag>;
typedef long long lint;
#define INF (1LL<<60)
#define IINF (1<<30)
#define EPS (1e-10)
#define endl ('\n')
#define MOD 1000000007LL
//#define MOD 998244353LL
typedef vector<lint> vec;
typedef vector<vector<lint>> mat;
typedef vector<vector<vector<lint>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
template<typename T>inline void numout(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i<INF/2?i:"INF";f=1;}cout<<endl;}
template<typename T>inline void numout2(T t){for(auto i:t)numout(i);}
template<typename T>inline void output(T t){bool f=0;for(auto i:t){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}
template<typename T>inline void output2(T t){for(auto i:t)output(i);}
template<typename T>inline void _output(T t){bool f=0;for(lint i=0;i<t.size();i++){cout<<f?"":" "<<t[i];f=1;}cout<<endl;}
template<typename T>inline void _output2(T t){for(lint i=0;i<t.size();i++)output(t[i]);}
#define rep(i,n) for(lint i=0;i<lint(n);++i)
#define repi(i,a,b) for(lint i=lint(a);i<(lint)(b);++i)
#define rrep(i,n) for(lint i=lint(n)-1;i>=0;--i)
#define rrepi(i,a,b) for(lint i=lint(b)-1;i>=lint(a);--i)
#define irep(i) for(lint i=0;;++i)
#define all(n) begin(n),end(n)
#define dist(a,b,c,d) sqrt(pow(a-c,2)+pow(b-d,2))
inline lint gcd(lint A,lint B){return B?gcd(B,A%B):A;}
inline lint lcm(lint A,lint B){return A/gcd(A,B)*B;}
// inline cint cgcd(cint A,cint B){return B?cgcd(B,A%B):A;}
// inline cint clcm(cint A,cint B){return A/cgcd(A,B)*B;}
bool chmin(auto& s,const auto& t){bool res=s>t;s=min(s,t);return res;}
bool chmax(auto& s,const auto& t){bool res=s<t;s=max(s,t);return res;}
const vector<lint> dx={1,0,-1,0,1,1,-1,-1};
const vector<lint> dy={0,1,0,-1,1,-1,1,-1};
#define SUM(v) accumulate(all(v),0LL)
auto call=[](auto f,auto... args){return f(f,args...);};

int main(){
    lint n;
    cin>>n;
    lint ans=0;
    repi(i,1,n+1)repi(j,1,n+1)repi(k,1,n+1){
        ans+=gcd(i,gcd(j,k));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include <fstream>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <set>
#include <algorithm>
#include <time.h>
#include <vector>
#include <map>
#include <queue>

#define isNum(a) (a >= '0' && a <= '9')
#define pb push_back
#define ll long long
const ll INF32 = 1e9;
const ll INF64 = 1e17;
const int RANGE = 1e6 + 5;
using namespace std;

template <class T>
void read(T &Val)
{
	T tmp = 0;
    char ch = getchar();
    int flag = 1;
    while (!isNum(ch))
	{
        if (ch == '-')
        	flag = -1;
        ch = getchar();
    }
    while (isNum(ch))
	{
        tmp = tmp*10 + ch - '0';
        ch = getchar();
    }
    Val = flag * tmp;
}

#define TASKIN "input.in"
#define TASKOUT "output.out"
#define TEST2

int data[RANGE];
int main()
{
	#ifdef TEST
		freopen(TASKIN, "r", stdin);
 		freopen(TASKOUT, "w", stdout);
		long double time_checking = clock();
	#endif

	int sum = 0;
	int n; read(n);
	for (int i = 0; i < n*2; i++) read(data[i]);
	sort(data, data + n*2);
	for (int i = 1; i < n*2; i += 2)
	sum += min(data[i-1], data[i]);

	cout << sum << endl;
	#ifdef TEST
		cerr << "TIME = " << (long double) (clock() - time_checking)/1000 << endl;
	#endif
	return 0;
}


Measured memory_bytes: 256
if __name__ == "__main__":
    A = int(input())
    B = int(input())    
    C = int(input())        
    X = int(input())
    result = 0
    for a in range(A + 1):
        for b in range(B + 1):
            for c in range(C + 1):
                cost = a * 500 + b * 100 + c * 50
                if cost == X:
                    result += 1
    print (result)



Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int cnt;
	int[] kionsa = {1,2,3,4,5,6,7};
	
	public void keisan(){
		for (cnt=0;cnt<=6;cnt++){
			int saikou = sc.nextInt();
			int saitei = sc.nextInt();
			kionsa[cnt] = saikou-saitei;		
		}
	}
	
	public void hyouji(){
		for (cnt=0;cnt<=6;cnt++){
			System.out.println(kionsa[cnt]);
		}
	}
	
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Main yo = new Main();
		yo.keisan();
		yo.hyouji();
		
	}

}

Measured memory_bytes: 17360
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
G = [[] for i in range(n)]
F = [-1]*n
AB = []
for i in range(n-1):
  a,b = map(int,input().split())
  a-=1;b-=1
  G[a].append(b)
  G[b].append(a)
  AB.append((a,b))
C = sorted(map(int,input().split()),reverse = True)
for i in range(n):
  G[i].sort(key = lambda x:len(G[x]))
m = max(range(n),key = lambda x: len(G[x]))
count = 1
que = collections.deque()
que.append(m)
F[m] = C[0]
while que:
  node = que.popleft()
  for vi in G[node]:
    if F[vi] != -1: continue
    F[vi] = C[count]
    count += 1
    que.append(vi)

for a,b in AB:
  ans += min(F[a],F[b])
print(ans)
print(*F)
# print(C)



Measured memory_bytes: 49116
import sys
import math

S = input()
N = 3
ans = 0
for i in range(2 ** N):
    s = S[0]
    for j in range(N):
        if ((i >> j) & 1):
            s += "+"
        else:
            s += "-"
        s += S[j+1]
    if eval(s) == 7:
        print(s+'=7')
        break


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int N;
  int ans = 0;

  cin >> N;

  int zeroc = 0;
  int minnn = __INT_MAX__;
  vector<int> h(N);
  for(int i = 0; i < N; i++){
    cin >> h[i];
    if(h[i] == 0){
      zeroc++;
    }
    minnn = min(minnn, h[i]);
  }
  if(zeroc == 0){
    //zero が無い場合, 全体的に下げる
    for(int i = 0; i < N; i++){
      h[i] -= minnn;
    }
    ans += minnn;
  }
  // cout << "----1 " << endl;
  // for(int i = 0; i < N; i++){
  //   cout << "h[" << i << "] = " << h[i] << endl;
  // }
  // cout << "----1 " << endl;

  int zrflg = 0;
  int acnt = 0;
  int minn = __INT_MAX__;
  int allsum = 1;
  while(allsum != (N+1)){
    allsum = 1;
    for(int i = 0; i < N; i++){
      if(h[i] == 0) allsum++;

      if(h[i] > 0 && zrflg == 0){
        zrflg++;
        acnt = i;
        minn = min(minn, h[i]);
        // cout << "if1: minn = " << minn << ", i = " << i << ", h[] =" << h[i] << endl;

        // if(i == (N-1) && allsum == N){
        if(i == (N-1)){
          // cout << "if1: minn = fin"  << endl;
          // cout << "ans = " << ans << " + " << minn  << endl;
          ans+=minn;
          h[i] -= minn;
          zrflg= 0;
          // allsum = (N+1);
        }
      }else if(h[i] > 0 && zrflg > 0 && i != (N-1)){
        minn = min(minn, h[i]);
        // cout << "if2: minn = " << minn << ", i = " << i << endl;
      }else if((h[i] == 0 || i == (N-1)) && zrflg > 0){
        // cout << "if3: "<< ", i = " << i << endl;
        if(h[i] != 0) {
            minn = min(minn, h[i]);
            i++;
          }
        // cout << "i = " << acnt << " ~~ " << i  << endl;
        for(int j = acnt; j < i; j++){
          h[j] -= minn;
        }
        // cout << "ans = " << ans << " + " << minn  << endl;
        ans += minn;
        minn = __INT_MAX__;
        zrflg = 0;
      }
    }

      // cout << "----;lp " << endl;
      // for(int i = 0; i < N; i++){
      //   cout << "h[" << i << "] = " << h[i] << endl;
      // }
      // cout << "----;lp " << endl;
  }

  // for(int i = 0; i < N; i++){
  //   cout << "h[" << i << "] = " << h[i] << endl;
  // }
  // cout << "----2 " << endl;

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define iii tuple<int, int, int>
#define ii pair<int, int>
#define fi first
#define vi vector<int>
#define vvi vector<vector<int>>
#define se second

using namespace std;
using namespace __gnu_pbds;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

ll pair_count(vector<ll>& a, ll v) {
    ll n = a.size(), res = 0;
    for (int i = 0; i < n; ++i) {
        ll cnt = lower_bound(a.begin(), a.end(), v - a[i]) - a.begin();
        res += n - cnt;
    }
    return res;
}

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    for (auto& i : a) cin >> i;
    sort(a.begin(), a.end());

    ll lef = 0, rig = 2e9, val = 0, cnt = 0;

    while (lef <= rig) {
        ll mid = (lef + rig) >> 1;
        // cout << lef << ' ' << rig << ' ' << mid << '\n';
        ll cnt_mid = pair_count(a, mid);
        if (cnt_mid >= m) {
            lef = mid + 1;
            val = mid;
            cnt = cnt_mid;
        } else
            rig = mid - 1;
    }

    vector<ll> psum(n + 1);
    partial_sum(a.rbegin(), a.rend(), psum.rbegin() + 1);

    ll res = 1LL * val * (m - cnt);
    for (int i = 0; i < n; ++i) {
        ll pos = lower_bound(a.begin(), a.end(), val - a[i]) - a.begin();
        res += 1LL * (n - pos) * a[i] + psum[pos];
        // cout << i << ' ' << a[i] << ' ' << pos << ' ' << n - pos << ' ' << psum[pos] << ' ' << (n - pos) * a[i] + psum[pos] << '\n';
    }

    cout << res << '\n';
    // cout << val << ' ' << cnt << '\n';
    // for (int i = 0; i < n; ++i) cout << a[i] << " \n"[i == n - 1];
    // for (int i = 0; i <= n; ++i) cout << psum[i] << " \n"[i == n];
}

int main() {
    // ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

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

    return 0;
}

Measured memory_bytes: 1792
s = list(input())
x = len(s)
seq = ""
for i in range(x):
	if s[i] == "0":
		seq += "0"
	elif s[i] == "1":
		seq += "1"
	else:
		if seq == "":
			pass
		else:
			seq = seq[0:-1]

print(seq)

Measured memory_bytes: 3060
N = int(input())


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    # return arr
    cnt = 0
    for l in arr:
        factor = l[0]
        i = l[1]
        if factor != 1:
            div = 0
            while 1:
                div += 1
                i -= div
                if i >= 0:
                    cnt += 1
                else:
                    break

    return cnt


print(factorization(N))

Measured memory_bytes: 9464
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    if (2 * c > a + b) {
        cout << x*a + y*b << endl;
    }
    else {
        if (x > y) {
            if (2*c < a) {
                cout << 2*c * x << endl;
            }
            else
                cout << 2*c*y + a*(x - y) << endl;
        }
        else {
            if (2*c < b) {
                cout << 2*c * y << endl;
            }
            else
                cout << 2*c*x + b*(y - x) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import numpy as np

a = np.array([list(map(int, input().split())) for _ in range(3)])

n = int(input())

b = [0]*n

for i in range(n):
    b[i] = int(input())
    a = np.where(a == b[i], 0, a)

if np.any((a==0).all(axis=0)):
    print('Yes')

elif np.any((a==0).all(axis=1)):
    print('Yes')

elif a[1,1] == 0:
    if (a[0,0]==0) or (a[2,2]==0):
        print('Yes')
    elif (a[0,2]==0) or (a[2,0]==0):
        print('Yes')

else:
    print('No')

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        
        int a[] = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = Integer.parseInt(sc.next());
        }

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

        System.out.println(sum);
        
        sc.close();
    }
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> l(n);
    REP(i,n)cin >> l[i];
    sort(ALL(l));
    int32 ans = 0;
    REP(i,n-2)FOR(j,i+1,n-1){
        ans += lower_bound(ALL(l), l[i] + l[j]) - (l.begin() + j) - 1;
    }
    ANS(ans);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int a[]={1,5,10,50,100,500};
int main(){
    int b[10];
    for(int i = 0; i < 6; i++){
        scanf("%d",&b[i]);
        b[i] *= a[i];
    }
    int sum =0;
    for(int i = 0; i< 6; i++){
        sum += b[i];
    }
    if(sum >= 1000)puts("1");
    else puts("0");
    return 0;
}

Measured memory_bytes: 1012
// SMPG2019 - D
function main(input) {
  var inputs = input.split('\n');
  var n = parseInt(inputs[0]);
  var s = inputs[1].split('').map((n) => parseInt(n, 10));

  var candidacies = [];
  for (var i = 0; i < 1000; i++) {
    candidacies.push(`00${i}`.slice(-3).split('').map((n) => parseInt(n, 10)));
  }

  var whereDisappear = [];
  for (var i = 0; i < 10; i++) {
    whereDisappear.push([]);
  }
  s.forEach((char, i) => {
    whereDisappear[char].push(i);
  });

  var counter = 0;
  candidacies.forEach((candidacy) => {
    var tempWhere = -1;
    var isOk = true;
    candidacy.forEach((cNumber) => {
      tempWhere = whereDisappear[cNumber].find((n) => n > tempWhere);
      if (typeof tempWhere === 'undefined') {
        isOk = false;
        return;
      } else {
        isOk = true;
      }
    });
    if (isOk) {
      counter += 1;
    }
  });
  console.log(counter);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 9956
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N;
    cin >> N;
    vector<int>a(N+1, 0);
    for(int i = 1; i < N+1; i++) {
        cin >> a.at(i);
    }
    
    int tmp = 1;
    
    int j = 0;
    for(; j < N; j++){
        tmp = a.at(tmp);
        if(tmp == 2) {
            cout << j+1 << endl;
            break;
        }
    }
    if(j == N) {
        cout << -1 << endl;
    }
}

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

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

vector<int> s(10005) ;
vector<int> t(505) ;

int solve( int key, int n) {
  s.at(n) = key ;
  int i = 0 ;
  while (s.at(i) != key ){
    i++ ;
  }
  if ( i == n ) {
    return 0 ;
  }
  return 1 ;

}

int main()
{
  int n ;
  cin >> n ;
  rep(i,n){
    cin >> s.at(i) ;
  }

  int q ;
  cin >> q ;
  rep(i,q) {
    cin >> t.at(i) ;
  }

  int cnt = 0 ;

  rep(i,q) {
    int key = t.at(i) ;
    if ( solve( key, n ) ) {
      cnt++ ;
    }
  }

  cout << cnt << endl ;

  return 0 ;
}



Measured memory_bytes: 3160
// C - Lamps
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int main(){
	int N, K; cin>>N>>K;
	vi A(N); rep(i, N) cin>>A[i];
	rep(i, K){
		vi B(N+1);
		rep(j, N){
			int l = max(0, j - A[j]);
			int r = min(N, j + A[j] + 1);
			B[l]++, B[r]--;
		}
		rep(j, N-1) B[j+1] += B[j];
		B.pop_back();
		if(A == B) break;
		A = B;
	}
	rep(i, N) cout<< A[i] << (i+1==N? "\n":" ");
}


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

int main(){
int i = 0;
int data = 0;
int V = 0;
int j = 0;
int *insert;
int k;

scanf("%d",&data);
insert = (int *)malloc(sizeof(int)*data);

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

for(i = 0; i < data ; i++){
V = insert[i];
j = i - 1;

while(j >= 0 && insert[j] > V){
  insert[j + 1] = insert[j];
  j--;
  insert[j + 1] = V;

}
for(k=0; k<data; k++){
 if(k!=data-1)printf("%d ",insert[k]);
 else printf("%d",insert[k]);
}
printf("\n");
}
return 0;
}


Measured memory_bytes: 2124
//////////////////////////////////////////
// Name : 
//
// about : 
//
// Usage : 
//
// Author : 
// Date : 
//////////////////////////////////////////
#define DEBUG 0

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>


int main(){
	char p;
	int l;
	int n=0;
	int W=0;
	int w=0;
	
	for(l = 0;l < 20;l++){
		scanf("%c",&p);
		
		if(p=='\n'){
			break;
		}
		else if('A' <= p && p <= 'Z'){
			W++;
		}
		else if('a' <= p && p <= 'z'){
			w++;
		}
		else if('0' <= p && p <= '9'){
			n++;
		}
	}
	
	if(1 <= n && 1 <= w && 1 <= W && 6 <= l){
		printf("VALID\n");
	}
	else{
		printf("INVALID\n");
	}
	
	
	return 0;
}

// vim: se noet ts=4 sw=4 sts=0 ft=c :

Measured memory_bytes: 524
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdint>
#include <cmath>
#include <numeric>
#include <functional>
#include <queue>
#include <stack>
#include <limits>
#include <type_traits>

using namespace std;

int gcd(int a, int b) {
  if(b == 0)
    {
      return a;
    }
  else
    {
      return gcd(b, a%b);
    }
}

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


  if(n == 2)
    {
      cout << std::max(a[0],a[1])  << endl;
      return 0;
    }

  int gcd_pre[n];
  int gcd_suf[n];

  gcd_pre[0] = a[0];
  gcd_suf[n - 1] = a[n - 1];

  for(int i = n - 2;
      i >= 0;
      --i)
    {
      gcd_suf[i] = gcd(gcd_suf[i + 1],a[i]);
    }

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

  int max2 = gcd_suf[0];

  max2 = std::max(gcd_suf[0],gcd_suf[1]);

  for(int i = 0;
      i < n - 2;
      ++i)
    {
      max2 = std::max(max2, gcd(gcd_pre[i], gcd_suf[i + 2]));
    }

  max2 = std::max(max2, gcd_pre[n - 2]);

  cout << max2 << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
#define INF INT_MAX 
using namespace std;
int main(){
	string s;
	cin >> s;
	int flag=0;
	if((s[0]-'0')-(s[1]-'0')-(s[2]-'0')-(s[3]-'0')==7){
		cout << s[0] << "-" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')+(s[1]-'0')-(s[2]-'0')+(s[3]-'0')==7){
		cout << s[0] << "+" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')+(s[1]-'0')+(s[2]-'0')-(s[3]-'0')==7){
		cout << s[0] << "+" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')+(s[1]-'0')-(s[2]-'0')-(s[3]-'0')==7){
		cout << s[0] << "+" << s[1] << "-" << s[2] << "-" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')-(s[1]-'0')-(s[2]-'0')+(s[3]-'0')==7){
		cout << s[0] << "-" << s[1] << "-" << s[2] << "+" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')-(s[1]-'0')+(s[2]-'0')-(s[3]-'0')==7){
		cout << s[0] << "-" << s[1] << "+" << s[2] << "-" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')-(s[1]-'0')+(s[2]-'0')+(s[3]-'0')==7){
		cout << s[0] << "-" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
		return 0;
	}
	if((s[0]-'0')+(s[1]-'0')+(s[2]-'0')+(s[3]-'0')==7)cout << s[0] << "+" << s[1] << "+" << s[2] << "+" << s[3] << "=7" << endl;
}


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

int fact(int n)
{
    if (n == 0)
        return 1;
    return fact(n - 1) * n;
}

int Count(vector<int> &p)
{
    int res = 0;
    vector<int> memo;
    for (int i = 0; i < p.size(); i++)
    {
        memo.push_back(p[i]);
        int count = 0;
        for (auto &&m : memo)
        {
            if (m < p[i])
                count++;
        }
        res += (p[i] - count - 1) * fact(p.size() - i - 1);
    }
    return res;
}

int main()
{
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for (auto &&i : p)
    {
        cin >> i;
    }
    for (auto &&i : q)
    {
        cin >> i;
    }

    int ans = abs(Count(p) - Count(q));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define N 10000

int main(void){
	int x[N],y[N],num=0;
	while(1){
		cin>>x[num]>>y[num];
		if(x[num]==0&&y[num]==0)break;
		if(x[num]<=y[num])cout<<x[num]<<" "<<y[num]<<endl;
		else cout<<y[num]<<" "<<x[num]<<endl;
                num++;
	}
}


Measured memory_bytes: 3108
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;

        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var nums = new long[N];
            for (var i = 0L; i < M; ++i)
            {
                var ab = Sarray();
                var a = ab[0] - 1;
                var b = ab[1] - 1;
                ++nums[a];
                ++nums[b];
            }
            if (nums.Any(n => n % 2 == 1))
                WriteLine("NO");
            else
                WriteLine("YES");
            Out.Flush();
        }
    }
}

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

int main() {
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	cin>>a[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
    {
        dp[i]=min((dp[i-1]+abs(a[i]-a[i-1])),(dp[i-2]+abs(a[i]-a[i-2])));
    }
    cout<<dp[n-1];
	
	
	return 0;
}


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

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

  int ans = 1;
  while (s.size() >= 2) {
    if (s[0] == s[1]) {
      if (s.size() >= 3) {
        s.erase(s.begin()+1);
        s.erase(s.begin()+1);
        ans += 2;
        if (s.size() == 1) ans--; 
      }
    } else {
      ans++;
    }
    s.erase(s.begin());
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

int a[5];

int main(){
	for(int i=0;i<3;i++){
		cin>>a[i];
	}
	sort(a,a+3);
	int m=unique(a,a+3)-a;
	if(m==2){
		puts("Yes");
	}else{
		puts("No");
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,d,l,r;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	l=a+b;
	r=c+d;
	if(l<r){
		printf("Right\n");
	}
	else if(l>r){
		printf("Left\n");
	}
	else if(l==r){
		printf("Balanced\n");
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = input()
B = input()
C = input()

cnt =0
for i in range(N):
    if A[i] == B[i] == C[i]:
        pass
    elif A[i] == B[i]:
        cnt += 1
    elif B[i] ==  C[i]:
        cnt += 1
    elif C[i] == A[i]:
        cnt += 1
    
    else:
        cnt += 2
    

print(cnt)

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

using namespace std;

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

namespace tree {
struct union_find {
  static const int Max = 22;
  int par[Max], rank[Max], size[Max], compnum;

  union_find(int N) {
    compnum = N;
    for(int i=0; i<N; i++) {
      par[i] = i;
      rank[i] = 0;
      size[i] = 1;
    }
  }

  int root(int x) {
    return par[x] == x ? x : par[x] = root(par[x]);
  }

  void unite(int x, int y) {
    x = root(x), y = root(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y, size[y] += size[x];
    } else {
      par[y] = x, size[x] += size[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
    compnum--;
  }

  int operator[](int x) { return root(x); }
  void operator()(int x, int y) { return unite(x, y); }

  bool same(int x, int y) { return root(x) == root(y); }
  int size_of(int x) { return size[root(x)]; }
  int num_of_comps() { return compnum; }
};
}

int N, M;
unordered_map<string, int> idmap;
vector<string> langs;
bool speaks[23][33];

void input() {
  langs.clear(); langs.resize(N);
  rep(i, N) {
    cin >> langs[i];
    idmap[langs[i]] = i;
  }
  memset(speaks, 0, sizeof speaks);
  rep(i, M) {
    int k; cin >> k;
    rep(_, k) {
      string s; cin >> s;
      speaks[i][idmap[s]] = 1;
    }
  }
}

bool next_combination(int& comb, int const BitSize) {
  int x = comb & -comb, y = comb + x;
  comb = ((comb & ~y) / x >> 1) | y;
  return comb < 1 << BitSize;
}

void solve() {

  REP(K, 1, min(N + 1, 6)) {
    int comb = (1 << K) - 1;
    do {
      vector<int> uselangs;
      rep(i, N) {
        if(!(comb & 1 << i)) continue;
        uselangs.push_back(i);
      }

      tree::union_find uf(M);

      rep(i, M) REP(j, i + 1, M)
        for(auto langid: uselangs)
          if(speaks[i][langid] && speaks[j][langid])
            uf(i, j);

      if(uf.num_of_comps() == 1) {
        printf("%d\n", (int)uselangs.size());
        for(auto e: uselangs) printf("%s\n", langs[e].c_str());
        return;
      }
    } while(next_combination(comb, N));
  }
  puts("Impossible");
}

int main() {
  bool first = 0;
  for(; cin >> N >> M && (N|M);) {
    if(first) cout << endl;
    first = 1;
    input();
    solve();
  }
  
  return 0;
}

Measured memory_bytes: 3364
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int a[100005];

int main() {
  int n;
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  sort(a+1,a+n+1);
  reverse(a+1,a+n+1);
  for(int i=1;i<=n;i++)
    if (i+1>a[i+1]) {
    	bool ok=1;
    	for(int j=i;a[j]>=i;j++) ok^=1;
    	ok|=(a[i]-i)&1;
    	printf("%s\n",(ok)?"First":"Second");
    	break;
	}
  return 0;
}

Measured memory_bytes: 640
s = input()
n = len(s)
power = [0]*(n+1)
power[-1] = 1
x = 1
for i in range(n-1,-1,-1):
	x = (x*10) % 2019
	power[i] = x
mod19 = [0]*(n+1)
cnt = [0]*2020
x=0
for i in range(n, 0,-1):
	x = (x+int(s[i-1])*power[i])%2019
	mod19[i] = x
	cnt[x]+=1
ans = 0
for i in range(2020):x = cnt[i];	ans+= x*(x-1)//2
print(ans+cnt[0])

Measured memory_bytes: 23572
#include <bits/stdc++.h>
#define FOR(i, k, n) for(int i = (k); i < (n); i++)
#define FORe(i, k, n) for(int i = (k); i <= (n); i++)
#define FORr(i, k, n) for(int i = (k); i > (n); i--)
#define FORre(i, k, n) for(int i = (k); i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
using ll = long long;

const int INF = 1001001001;
const int mod = 1000000007;

int main(void){
  string s;
  cin >> s;
  map<char, int> mp;
  REP(i, 4) mp[s[i]]++;
  for(auto p : mp){
    if(p.second != 2){
      cout << "No" << endl;
      return 0;
    } 
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	ll h;
	cin >> h;

	ll a = (ll)log2(h);

	cout << (ll)powl(2,a+1) - 1 << endl;

	return 0;

}

Measured memory_bytes: 384
int a[7];
main(n,i){
  for(scanf("%d",&n);n--;a[i]++)
    scanf("%f",&f),i=f<165?1:f<170?2:f<175?3:f<180?4:f<185?5:6;
  for(i=1;i<7;puts(""),i++)
    for(printf("%d:",i);a[i]--;putchar('*'));
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int n;
int a[20];
int q;
int m[2000];
int d[2001][20]={};
int j;
int main()
{
	cin >> n;
	for(int i=0; i<n; i++)
	{
		cin >> a[i];
	}
	cin >> q;
	for(int i=0; i<q; i++)
	{
		cin >> m[i];
	}
	for(int i=0; i<=n; i++)
	{
		d[0][i]=1;
	}
	for(int i=n-1; i>=0; i--)
	{
		for(int j=0; j<2001; j++)
		{
			if((d[j][i+1]==1)||((j>=a[i])&&(d[j-a[i]][i+1]==1)))
			{
				d[j][i]=1;
			}
		}
	}
	for(int i=0; i<q; i++)
	{
		if(d[m[i]][0]==1)
		{
			cout << "yes" << endl;
		}
		else
		{
			cout << "no" << endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 1220
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, x;
    scan(n, x);
    long[] m = new long[n];
    foreach (ref e; m)
    {
        e = lread();
    }
    foreach (e; m)
    {
        x -= e;
    }
    long min_cost = m[0];
    foreach (e; m)
    {
        min_cost = min(e, min_cost);
    }
    writeln(n + x / min_cost);
}

Measured memory_bytes: 256
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define mp make_pair
#define ff first
#define ss second
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	for(int i=1;i<10;i++){
		if(n%i==0){
			if(n/i<=9){
				cout<<"Yes";
				return 0;
			}
		}
	}
	cout<<"No";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_M = 1e5+10;

int main(int argc, char const *argv[])
{
    int n, m, l[MAX_M], r[MAX_M];
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &l[i], &r[i]);
    }

    int max_l=l[0], min_r=r[0];

    for (int i = 0; i < m; ++i) {
        max_l = max(max_l, l[i]);
        min_r = min(min_r, r[i]);
    }
    
    cout << max(0,min_r-max_l+1) << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;

namespace _0004
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) 
                {
                    break;
                }

                string[] inputs = input.Split(' ');
                int[] coefficients = new int[6];
                for (int i = 0; i < 6; i++)
                {
                    coefficients[i] = int.Parse(inputs[i]);
                }

                double x = (double)(coefficients[2] * coefficients[4] - coefficients[1] * coefficients[5]) / (coefficients[0] * coefficients[4] - coefficients[1] * coefficients[3]);
                double y = (double)(coefficients[0] * coefficients[5] - coefficients[2] * coefficients[3]) / (coefficients[0] * coefficients[4] - coefficients[1] * coefficients[3]);

                Console.WriteLine("{0:f3} {1:f3}", x, y);
            }
        }
    }
}

Measured memory_bytes: 5656