akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
typedef pair<ii,int> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define eb emplace_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"LINE %d: (%s) = ",__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }

const ll MAXn=55,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;
const ll M = 21;

ll n,m;
ll dp[MAXn][1<<M];
ll edg[MAXn];
vector<ii> e[MAXn];
bool dfs(ll x,ll dst,ll id,ll p){
    if (x == dst) return true;
    for (auto i:e[x]) {
        if (i.X == p) continue;
        if (dfs(i.X,dst,id,x)) {
            edg[i.Y] |= (1<<id);
            return true;
        }
    }
    return false;
}
ll cal(ll x,ll msk){
    if (x == n-1) return msk == (1<<m)-1;
    if (dp[x][msk] != -1) return dp[x][msk];
    ll ret = cal(x+1,msk) + cal(x+1,msk | edg[x]);
    return dp[x][msk] = ret;
}
int main(){
    IOS();
    RST(dp,-1);
    cin >> n;
    REP (i,n-1) {
        int u,v;
        cin >> u >> v;
        u--, v--;
        e[u].eb(v,i);
        e[v].eb(u,i);
    }
    cin >> m;
    REP (i,m) {
        int u,v;
        cin >> u >> v;
        u--, v--;
        dfs(u,v,i,-1);
    }
    cout << cal(0,0) << endl;
}


Measured memory_bytes: 901500
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	int N,a[103];
	scan(N);
	int ans=0;
	rep(i,N){
		scan(a[i]);
		if(i%2==0&&a[i]%2==1) ans++;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 3644
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int N; cin >> N;
	vector<int>nums(6);
	for (int i = 0; i < N; ++i) {
		ld num; cin >> num;
		num += 0.001;
		
		for (int j = 0; j <6; ++j) {
			if (num < 165 + j * 5) {
				nums[j]++;
				break;
			}
		}

	}
	for (int i = 0; i < 6; ++i) {
		cout << i + 1 << ":";
		for (int j = 0; j < nums[i]; ++j) {
			cout << '*';
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
  string S;
  cin >> S;
  
  int N = S.length();
  int k = 0;
  int t = 0;
  
  int l = 0;
  
  while(k < N){
    if((S[k] == '0' && S[k+1] == '1')||(S[k] == '1' && S[k+1] == '0')){
      S.erase(k, 2);
      l += 2;
      k -= 1;
    }
    else{
      k += 1;
    }
  }
  
  cout << l << endl;
  
  
      
    
     
  return 0;
}
      

Measured memory_bytes: 512
n = int(input())
t, a = list(map(int, input().split()))
for _ in range(n-1):
    ti, ai = list(map(int, input().split()))
    mt = t // ti if t % ti == 0 else t // ti + 1
    ma = a // ai if a % ai == 0 else a // ai + 1
    m = max(mt, ma)

    t = m * ti
    a = m * ai

print(t + a)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    long n,k;
    cin>>n>>k;
    vector<pair<long,long>> pa(n);
    for(int i = 0; i < n; i++)
        cin>>pa[i].first>>pa[i].second;
    sort(pa.begin(),pa.end(),[](auto x,auto y){return x.first<y.first;});
    long sum = 0;
    for(auto x:pa){
        sum += x.second;
        if(k<=sum){
            cout<<x.first;
            return 0;
        }
    }
}

Measured memory_bytes: 1792
N = int(input())
As = list(map(int,input().split()))
As.sort()
M = 1000001
array = [0]*M
for a in As:
    if array[a] != 0:
        array[a] = 2
        continue
    for i in range(a,M,a):
        array[i] += 1

ans = 0
for a in As:
    if array[a] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 132760
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
const ll MOD = 1e9 + 7;
vector<vector<ll>> dp;
vector<vector<int>> m;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    m.assign(n, vector<int> (n, 0));
    F0R(i, n) F0R(j, n) cin >> m[i][j];
    dp.assign(n + 1, vector<ll>((1<<(n)), 0));
    dp[0][0] = 1;
    FOR(i, 1, (1<<(n)))
    {
        int x = 0;
        F0R(j, n)
        {
            if(((1<<j) & i))
            {
                x++;
            }
        }        
        F0R(j, n)
        {
            if(((1<<j) & i) && m[x - 1][j])
            {
                dp[x][i] += dp[x - 1][i - (1<<j)];
                dp[x][i] %= MOD;
            }
        }
    }
    // for(auto i : dp)
    // {
    //     for(auto j : i)
    //     {
    //         cout << j << " ";
    //     }
    //     cout << "\n";
    // }
    cout << dp[n][(1<<n) - 1];
    return 0;
}

Measured memory_bytes: 377216
/*
Hokudai Practice Contest 2014
F - Differential Pulse Code Modulation

ティツァツ」テヲツウツ陛ッツシツ咼P
y_iテ」ツつ津」ツ?づ」ツつ凝・ツ?、pテ」ツ?ォテァツャツヲテ・ツ渉キテ・ツ個姪」ツ?凖」ツつ凝」ツ?ィテ」ツ?催」ツ?ョテ」ツつウテ」ツつケテ」ツδ暗」ツ?ッテ」ツ?【_{i-1}テ」ツつ津」ツ?ゥテ」ツ?ョテ・ツ?、テ」ツ?ォテァツャツヲテ・ツ渉キテ・ツ個姪」ツ?療」ツ?淌」ツ?凝」ツ??
テ」ツ?ォテ」ツ?療」ツ?凝、ツセツ敕・ツュツ佚」ツ?療」ツ?ヲテ」ツ??」ツ?ェテ」ツ??」ツ?づ」ツつ暗」ツ?」テ」ツ?ヲテ」ツ??
テ」ツ??P[i][p] := y_iテ」ツつ恥テ」ツ?ォテァツャツヲテ・ツ渉キテ・ツ個姪」ツ?療」ツ?淌」ツ?ィテ」ツ?催」ツ?ョテ」ツ?（テ」ツ?セテ」ツ?ァテ」ツ?ョテヲツ慊?・ツーツ湘、ツコツ古、ツケツ療・ツ陳?
テ」ツ?ィテ」ツ?凖」ツつ凝」ツ?ィテ」ツ??
  DP[i][p] := min{ DP[i-1][p-c_j] + (p-c_j)^2 | 0<=j<m}
テ」ツ?ィテヲツシツクテ・ツ個姪・ツシツ湘」ツ?古ァツォツ凝」ツ?ヲテ」ツつ嘉」ツつ古」ツつ凝」ツ??テヲツュツ」テァツ「ツコテ」ツ?ォテ」ツ?ッテ」ツ??テ」ツつ?55テ」ツ?ァテ」ツ?ョテ、ツクツクテ」ツつ?」ツつづィツ?εヲツ?ョテ」ツ?凖」ツつ凝・ツソツ?ィツヲツ?」ツ?古」ツ?づ」ツつ?

DPテ」ツδ?」ツδシテ」ツδ姪」ツδォテ」ツ?ョNテδ?56テ」ツ?ョテ」ツ?敕」ツつ古」ツ?榲」ツつ古」ツ?ョテァツ環カテヲツ?凝」ツ?ォテ」ツ?、テ」ツ??」ツ?ヲテ」ツ??
テ」ツ?ゥテ」ツ?ョテ」ツつウテ」ツδシテ」ツδ嘉」ツδ姪」ツδε」ツつッテ」ツつ津ァツ板ィテ」ツ??」ツつ凝」ツ?ョテ」ツ?凝」ツつ津」ツ?凖」ツ?ケテ」ツ?ヲティツゥツヲテ」ツ?崚」ツ?ーテ」ツつ暗」ツ??」ツ?淌」ツつ?」ツ??
テヲツ卍づゥツ鳴禿ィツィツ暗ァツョツ療ゥツ?湘」ツ?ッ256*N*Mテ」ツ?ァテヲツ環妥」ツ?暗」ツつ嘉」ツつ古」ツつ凝」ツ??
*/

#include<iostream>
#include<cstring>
using namespace std;
//テァツュツ氾」ツ?暗」ツ?ョテァツ青?ィツォツ姪ヲツ慊?ヲツつェテ・ツ?、テ」ツ?栗NT_MAXテ」ツ?ォティツソツ妥」ツ?湘ヲツ?ェテ」ツ?療」ツ??」ツ?淌」ツつ?」ツ??・ツソツオテ」ツ?ョテ」ツ?淌」ツつ〕ong longテ」ツつ津ァツ板ィテ」ツ??」ツつ?
typedef long long ll;

ll dp[20001][256];
ll code[20], x[20000];
const ll INF = 1e15;

int main(){
  int n,m;
  while(cin >> n >> m, n){
    for(int i=0;i<m;i++)cin >> code[i];
    for(int i=0;i<n;i++)cin >> x[i];

    //テ・ツ按敕ヲツ慊淌・ツ個?
    for(int i=0;i<=n;i++){
      for(int j=0;j<256;j++)dp[i][j] = INF;
    }
    dp[0][128] = 0;

    //DP
    for(int i=0;i<n;i++){
      for(int j=0;j<256;j++){
	for(int k=0;k<m;k++){
	  //テ・ツ可催」ツ?ョテ・ツ?、テ」ツ?桂テ」ツ?ァテ」ツ?づ」ツつ甘」ツ?〔テァツ閉ェテァツ崢ョテ」ツ?ョテ」ツつウテ」ツδシテ」ツδ嘉」ツδ姪」ツδε」ツつッテ」ツつ津、ツスツソテ」ツ??・ツ?エテ・ツ青暗」ツ?ョテ・ツ?、nxtテ」ツつ津ヲツアツづ」ツつ?」ツつ?
	  ll nxt = j+code[k];
	  if(nxt<0)nxt = 0;
	  if(nxt>255)nxt = 255;

	  //テ、ツコツ古、ツケツ療ィツェツ、テ・ツキツョテ」ツつ津ヲツアツづ」ツつ?」ツつ?
	  ll cost = (x[i]-nxt)*(x[i]-nxt);

	  //テヲツシツクテ・ツ個姪・ツシツ湘」ツ?ォテ・ツ淞コテ」ツ?・テ」ツ??」ツ?淌ィツィツ暗ァツョツ療」ツつ津ィツ。ツ古」ツ??
	  dp[i+1][nxt] = min(dp[i+1][nxt], dp[i][j] + cost);
	}
      }
    }

    ll ans = INF;
    //テヲツ慊?・ツセツ古」ツ?ョテ・ツ?、テ」ツ?ッテ」ツ??」ツ?湘」ツつ嘉」ツ?ァテ」ツ?づ」ツ?」テ」ツ?ヲテ」ツつづ」ツつ暗」ツ??」ツ?ョテ」ツ?ァテ」ツ??」ツ?凖」ツ?ケテ」ツ?ヲテ」ツ?ョテ、ツクツュテ」ツ?ョテヲツ慊?・ツーツ湘・ツ?、テ」ツつ津ヲツアツづ」ツつ?」ツつ?
    for(int i=0;i<256;i++)ans = min(ans, dp[n][i]);
    cout << ans << endl;
  }
}

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

using namespace std;

int main(void){
    int n, m;
    cin >> n >> m;
    double A[n];
    double sum = 0;
    for(int i = 0; i < n; i++){
        cin >> A[i];
        sum += A[i];
    }
    double ander = sum / (4 * m);
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(A[i] >= ander){
            ans++;
        }
    }
    if(ans >= m){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  vector<int> R(N + 1);
  vector<int> G(N + 1);
  vector<int> B(N + 1);
  R[0] = G[0] = B[0] = 0;
  for (int i = 1; i <= N; i++) {
    R[i] = R[i - 1] + (s[i - 1] == 'R' ? 1 : 0);
    G[i] = G[i - 1] + (s[i - 1] == 'G' ? 1 : 0);
    B[i] = B[i - 1] + (s[i - 1] == 'B' ? 1 : 0);
  }

  long long ans = 0;
  for (int i = 0; i <= N - 3; i++) {
    for (int j = i + 1; j <= N - 2; j++) {
      if (s[i] != s[j]) {
        int n = j + j - i;
        if ((s[i] == 'R' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'R'))
          ans += B[N] - B[j + 1] - (n < N && s[n] == 'B' ? 1 : 0);
        if ((s[i] == 'R' && s[j] == 'B') || (s[i] == 'B' && s[j] == 'R'))
          ans += G[N] - G[j + 1] - (n < N && s[n] == 'G' ? 1 : 0);
        if ((s[i] == 'B' && s[j] == 'G') || (s[i] == 'G' && s[j] == 'B'))
          ans += R[N] - R[j + 1] - (n < N && s[n] == 'R' ? 1 : 0);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int K, N;
	cin >> K >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	int mx = -INF;
	rep(i, N) {
		int dist = abs(A[i] - A[(i + 1) % N]);
		int a = min(K - dist, dist);
		mx = max(mx, a);
	}
	int ans = K - mx;
	cout << ans;
}

Measured memory_bytes: 1792
N=int(input())
sum=0
name=[]
for _ in range(N):
    a,b=map(int,input().split())
    if(a==b):
        sum+=1
        if(sum==3):
            name.append("Yes")
    else:
        sum=0
    
if len(name)==0:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
using namespace std;
void solve()
{
		int a,b;
		cin>>a>>b;
		if(a>b)
		cout<<"safe";
		else
		cout<<"unsafe";
}
int main()
{
	//int t;cin>>t;
	//while(t--)
	solve();
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    vector<int> x(5);
    rep(i,0,5) cin>>x.at(i);

    rep(i,0,5){
        if(x.at(i)==0){
            cout<<i+1<<endl;
            break;
        }
    }
}

Measured memory_bytes: 3624
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int A, B, C, D;
        A = cin.nextInt();
        B = cin.nextInt();
        C = cin.nextInt();
        D = cin.nextInt();
        if (A + B == C + D) Console.WriteLine("Balanced");
        else if (A + B > C + D) Console.WriteLine("Left");
        else Console.WriteLine("Right");
    }




}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

int main(){
  int N, M;
  bool isinvalid = false;
  cin >> N >> M;
  
  vector<int> A(N, 0);
  
  vector<int> s(M), c(M);
  for(int i=0;i<M;i++){
    cin >> s.at(i) >> c.at(i);
  }
  
  if(M > 0){
    for(int i=0;i<M-1;i++){
      for(int j=i+1;j<M;j++){
        if(s.at(i) == s.at(j) && c.at(i) != c.at(j)){
          isinvalid = true;
        }
      }
    }
    for(int i=0;i<M;i++){
      if(s.at(i) == 1 && c.at(i) == 0 && N > 1){
        isinvalid = true;
      }
    }
  }

  if(!isinvalid){
    for(int i=0;i<M;i++){
      A.at(s.at(i)-1) = c.at(i);
    }
  }

  if(N > 1 && A.at(0) == 0){
    A.at(0) = 1;
  }
  

  if(isinvalid){
    cout << -1 << endl;
  }else{
    int ans = 0;
    for(int i=0;i<N;i++){
      ans = 10*ans + A.at(i);
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	static String Comp(String s, String t){
		if(s.length()>t.length())return"GREATER";
		else if(s.length()<t.length())return"LESS";
		else{
			for(int i=0; i<s.length(); i++){
				if(Character.getNumericValue(s.charAt(i))>Character.getNumericValue(t.charAt(i)))return "GREATER";
				else if(Character.getNumericValue(s.charAt(i))<Character.getNumericValue(t.charAt(i)))return "LESS";
			}
		return "EQUAL";
		}
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		System.out.println(Comp(a, b));
	}
}

Measured memory_bytes: 23124
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
inline long long read()
{
	char ch=getchar();
	while (ch<'0'||ch>'9') ch=getchar();
	long long ans=0;
	while (ch<='9'&&ch>='0') ans=ans*10+ch-48,ch=getchar();
	return ans;
}
int main()
{
	int n=read();
	bool flag=1;
	long long ans=0,s=1e12;
	for (int i=1; i<=n; i++) 
	{
		long long x=read(),y=read();
		if (x!=y) flag=0;
		if (y<x) s=min(s,y);
		ans+=x;
	}
	if (flag) puts("0");
	else printf("%lld\n",ans-s);
	return 0;
}

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

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a


L = [0] * N
R = [0] * N
L[0] = A[0]
R[-1] = A[-1]

for n in range(1, N):
    L[n] = gcd(L[n - 1], A[n])
    R[-n - 1] = gcd(R[-n], A[-n - 1])

max_gcd = 0
for n in range(N):
    if n == 0:
        max_gcd = max(max_gcd, R[1])
    elif n == N - 1:
        max_gcd = max(max_gcd, L[N - 2])
    else:
        max_gcd = max(max_gcd, gcd(L[n - 1], R[n + 1]))

print (max_gcd)


Measured memory_bytes: 14584
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF 1001001001001001001
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

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


Measured memory_bytes: 3628
"use strict"

function main(input) {
  //一部の正解がjsで扱う最大値を越えるため、文字列として扱う。
  //計算は配列を使った筆算（上の配列と下の配列を計算、桁上がりも対応）にて行う

  input = Number(input)

  let numbers = ["2", "1"]

  for (let i = 2; i <= input; i++) {
    const cal = (a, b) => {

      //左詰の配列だと計算しづらいのでreverse
      let aa = a
        .split("")
        .map(v => ~~v)
        .reverse()
      let bb = b
        .split("")
        .map(v => ~~v)
        .reverse()

      let cc = []
      let digit = 0
      //各配列の値についてaa[i] + bb[i]する=筆算 桁数の大きい方の回数
      for (let i = 0; i < bb.length; i++) {
        let tmp = Number(aa[i])
          ? Number(aa[i]) + Number(bb[i]) + digit
          : Number(bb[i]) + digit //
        digit = 0

        if (tmp >= 10) {
          digit = Math.floor(tmp / 10)
          tmp = tmp % 10
        } else {
          digit = 0
        }
        cc.push(tmp)

      }
      if (digit > 0) cc.push(digit)

      return cc.reverse().join("") //array -> recerse -> string
    }
    let tmp = cal(numbers[i - 2], numbers[i - 1])
    numbers.push(tmp)
  }
  console.log(numbers.pop()) //string

}
main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7612
import java.util.Scanner;

public class Main {
	static long f(long A , long B , long x){
		long Ax = A * x;
		long r = Ax / B;
		long Ax2 = A * (x / B);
		long res = r - Ax2;
		return res;
	}
	static long solve(long A , long B , long N){
		long ret = 0;
		long N2 = Math.min(3000000, N);
		for(long x = 0 ; x <= N2 ; ++x){
			long res = f(A , B , x);
			ret = Math.max(ret, res);
		}
		if(N > N2){
			long M = 1500000;
			long x = N2 - M;
			long a = f(A , B , x);
			while(x + M <= N){
				long b = f(A , B , x + M);
				if(a > b){
					break;
				}
				ret = Math.max(ret , b);
				x += M;
			}
			N2 = Math.min(N, x + M);
			for( ; x <= N2 ; ++x){
				ret = Math.max(ret, f(A , B , x));
			}
		}
		return ret;
	}
	public static void main(String[] args) {
		/*
		for(int A = 1 ; A <= 10 ; ++A){
			for(int B = 1 ; B <= 20 ; ++B){
				solve(A, B , 1);
			}
		}
		*/
		Scanner sc = new Scanner(System.in);
		long A = sc.nextLong();
		long B = sc.nextLong();
		long N = sc.nextLong();
		System.out.println(solve(A, B , N));
	}
}


Measured memory_bytes: 27080
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    string S;cin>>S;
    ll minima = INF;
    for(int i = 0; i < S.size()-2; i++)
    {
        string tmp = S.substr(i,3);
        ll t = stoi(tmp);
        ll ltmp = abs(t-753);
        minima = min(minima,ltmp);
    }
    cout<<minima<<endl;
}

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

int isACGT(char ch) {
    if(ch == 'A' || ch == 'C' || ch == 'G' || ch == 'T') {
        return 1;
    }
    return 0;
}

int isACGTstr(char str[], int length) {
    for(int i = 0; i < length; i++) {
        if(!isACGT(str[i])) return 0;
    }
    return 1;
}

int mysubstr(char *t, const char *s, int pos, int len){
    if(pos < 0 || len < 0 || len > strlen(s)) return -1;
    for(s += pos; *s != '\0' && len > 0; len--) *t++ = *s++;
    *t = '\0';
    return 0;
}

int main(void){
    char str[10];
    scanf("%s", str);
    int length = strlen(str), ans = 0;
    for(int i = 0; i < length; i++) {
        for(int j = i; j < length; j++) {
            char t[10];
            mysubstr(t, str, i, length - j);
            if(isACGTstr(t, strlen(t))) {
                if(ans < strlen(t)) ans = strlen(t);
            }
        }
    }
    printf("%d", ans);
}


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

int main() {
    string s;
    cin >> s;
    bool ok = true;
    if (s[0] != 'A') ok = false;
    int n = s.size();
    if (s.substr(2, n-3).find('C') == string::npos) ok = false;
    int cnt_uppercase_letter = 0;
    rep(i,n) {
        if (isupper(s[i])) cnt_uppercase_letter++;
    }
    if (cnt_uppercase_letter != 2) ok = false;
    string ans;
    if (ok) ans = "AC";
    else ans = "WA";
    cout << ans << endl;
}

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

int main() {
  int ans=0;
  int X = 0;
  int N = 0;
  string s;

  cin >> s;
  
  for(long i = 0; i < 4; i++){
    
    if(i > 0){
      if(s[i-1] == s[i]){
        ans++;
      }
    }
  }

  if(ans > 0){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
<?php
    fscanf(STDIN, "%d %d", $h, $w);
    $ar = array();
    for($i = 0; $i < $h; $i++){
        fscanf(STDIN, "%s", $ar[$i]);
    }
    
    for($i = 0; $i < $w+2; $i++){
        echo "#";
    }
    echo "\n";
    for($i = 0; $i < $h; $i++){
        echo "#$ar[$i]#\n";
    }
    for($i = 0; $i < $w+2; $i++){
        echo "#";
    }
    echo "\n";
?>


Measured memory_bytes: 3828
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
	let s: String = read();
	let s = s.trim();
	let s_half = s.len()/2;
	let first = &s[..s_half];
	let second = &s[s_half..];
	let second: String = s.chars().rev().collect();

	let mut count = 0;
	for (a, b) in first.chars().zip(second.chars()) {
		if a != b {
			count += 1;
		}
	}
	println!("{}", count);
}


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

int main()
{
	string s;
	cin>>s;
	int sum=0,i;
	
	for(i=0;i<s.size();i++)
	{
		sum+=s[i]-48; //-'0'
	}
	
	if(sum%9==0)
		cout<<"Yes";
	else
		cout<<"No";
		
	return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<cassert>
using namespace std;
main(){
int st = 0;
int b;
for ( int i = 0; i < 3; i++ ){
cin >> b;
if ( b == 1 ) st += (1<<i);
}
if ( st >= 3 ) cout << "Open" << endl;
else cout << "Close" << endl;
}

Measured memory_bytes: 1156
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.close();
		int ans = 0;
		if(n % 2 == 0)ans = (n / 2) - 1;
		else ans = n / 2;
		System.out.println(ans);
	}
}


Measured memory_bytes: 22740
// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n){
    --n;
    i64 p = 0;
    i64 pat = 1;
    for(int i = 1;; ++i){
        pat *= 26;
        p += pat;
        if(p > n){
            n -= (p - pat);
            string s;
            for(int j = 0; j < i; ++j){
                s += (n % 26 + 'a');
                n /= 26;
            }
            reverse(s.begin(), s.end());
            cout << s << endl;
            return;
        }
    }
}


signed main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = 1e9 + 7;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    while(cin >> n) 
    {
        int ans = 0;
        vector<vector<int>> dp(5, vector<int>(n+5, 0));
        dp[0][0] = 1;
        REP(i, 4)
        {
            REP(j, n+1)
            {
                REP(k, 1001)
                {
                    if(j - k >= 0 && dp[i][j-k] != -1) dp[i+1][j] += dp[i][j-k];
                }
            }
        }
        cout << dp[4][n] << endl;
    }
    
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main()
{
	int k,n;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		int l;
		cin>>l;
		mp[l]++;
	}
	vector<int>v;
	for(auto i:mp)
	{
		v.push_back(i.second);
	}
	sort(v.begin(),v.end());
	int sum=0;
	if((int)(v.size())-k<=0)
	{
		puts("0");
		return 0;
	}
	for(int i=0;i<(int)(v.size())-k;i++)
	{
		sum+=v[i];
	}
	cout<<sum<<"\n";


}

Measured memory_bytes: 10748
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  int ans = 1001001001;
  rep(i,1<<n){
    int now = 1;
    rep(j,n){
      if(i>>j&1) now *= 2;
      else now += k;
    }
    ans = min(ans,now);
  }
  cout << ans << endl;
  return 0;
}
    
    

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

void tracelog(const int A[], int N);
void insertionSort(int A[], int N);

int main()
{
    int n = 0;
    int* pArray = NULL;

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

    tracelog(pArray, n);
    insertionSort(pArray, n);

    delete[] pArray;
}

void tracelog(const int A[], int N)
{
    for (int i = 0; i < N; i++) {
        i > 0 ? cout << " " << A[i] : cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N)
{
    for (int i = 1; i < N; i++) {
        int v = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--; 
            
        }
        A[j + 1] = v;
        
        tracelog(A, N);
    }
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int N,H,W;
    Scd3(H,W,N);
    int R,C;
    Scd2(R,C);

    char s[200002];
    char t[200002];
    Scs(s);
    Scs(t);

    bool ans = true;
    int l,r;
    r=0;
    l=0;
    for (int i = N-1; i >= 0; i--){
        if( t[i] == 'L' ) r--;
        if( t[i] == 'R' ) l--;
        if( r < 0 ) r= 0;
        if( l < 0 ) l= 0;
        if( s[i] == 'R' ) r++;
        if( s[i] == 'L' ) l++;
        if( r+l >= W ) ans = false;
        // printf("%d<->%d\n", l, r );
    }
    if( l >= C ) ans = false;
    if( r > W-C ) ans = false;
    r=0;
    l=0;
    for (int i = N-1; i >= 0; i--){
        if( t[i] == 'U' ) r--;
        if( t[i] == 'D' ) l--;
        if( r < 0 ) r= 0;
        if( l < 0 ) l= 0;
        if( s[i] == 'D' ) r++;
        if( s[i] == 'U' ) l++;
        if( r+l >= H ) ans = false;
        // printf("%d<->%d\n", l, r );
    }
    if( l >= R ) ans = false;
    if( r > H-R ) ans = false;

    printf ("%s\n", ans ? "YES" : "NO" );


    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr ll mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    friend ostream &operator<<(ostream& os,const mint& a){
        return os << a.x;
    }

    friend istream &operator>>(istream& is,mint& a){
        ll t;
        is >> t;
        a = mint(t);
        return (is);
    }

    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<int> A(N);
    for(auto& x:A) cin >> x;
    mint ans = 0;
    mint sum = accumulate(A.begin(),A.end(),(mint) 0);
    for(int i=0;i<N;i++){
        sum -= A[i];
        ans += sum*A[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3988
// IO library
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>

// container library
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>

// namespace
using namespace std;

// typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VB> VVB;

// conversion
#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)

// container
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define SORT(c) sort((c).begin(), (c).end())
#define GSORT(c) sort((c).begin(), (c).end(), greater<decltype((c).front())>())
#define SZ(x) (INT((x).size()))
#define MEMSET(c, v) memset((c), v, sizeof(c))

// repetition
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define NREP(i, n) FOR(i, 1, n + 1)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define RREP(i, n) RFOR(i, n, 0)
#define RNREP(i, n) RFOR(i, n, 1)

// constant
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const int dx[4] = {0, -1, 1, 0};
// const int dy[4] = {-1, 0, 0, 1};
// const int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
// const int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};

// debug
#define test(x) cout << #x << " = " << x << endl

// answer output
#define Yes(c) cout << ((c) ? "Yes" : "No") << endl;
#define YES(c) cout << ((c) ? "YES" : "NO") << endl;
#define yes(c) cout << ((c) ? "yes" : "no") << endl;

#define possible(c) cout << ((c) ? "possible" : "impossible") << endl;
#define POSSIBLE(c) cout << ((c) ? "POSSIBLE" : "INPOSSIBLE") << endl;


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

VL fact(100010), inv(100010);

ll calc_pow(ll n, ll k) {
  if (k == 1) {
    return n;
  }

  if (k % 2 > 0) {
    return calc_pow(n, k - 1) * n % MOD;
  } else {
    ll sub = calc_pow(n, k / 2);
    return sub * sub % MOD;
  }
}

void precalc() {
  inv[0] = fact[0] = 1;
  NREP(i, 100001) {
    fact[i] = fact[i - 1] * i % MOD;
    inv[i] = calc_pow(fact[i], MOD - 2);
  }
  return;
}

ll comb(ll a, ll b) {
  if (a < b) return 0;
  if (a == 0) return 1;

  return fact[a] * inv[a - b] % MOD * inv[b] % MOD;
}


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

  precalc();

  ll n;
  cin >> n;

  VL place(n + 2, 0);
  ll from, to;

  NREP(i, n + 1) {
    ll a;
    cin >> a;
    if (place[a] > 0) {
      from = place[a];
      to = i;
    } else {
      place[a] = i;
    }
  }

  NREP(k, n + 1) {
    ll ans = comb(n + 1, k);
    ans -= comb(n + from - to, k - 1);
    if (ans < 0) {
      ans += MOD;
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3584
n,m,x,y=gets.split.map(&:to_i)
a=gets.split.map(&:to_i)
b=gets.split.map(&:to_i)
i,j=a.max+1,b.min
flag=false
(x+1..y).each do |k|
  flag=true if  (i..j).cover? k
end
puts flag ? "No War" : "War"


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

int main()
{
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if(S == U)
        cout << A - 1 << " " << B << endl;
    else
        cout << A << " " << B - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;

struct UnionFind {
    int N;
    vector<int> parents;

    UnionFind(int _N) : N(_N),parents(N,-1) {}

    int find(int x) { //xの親を返す
        if (parents[x] < 0) return x;
        return parents[x] = find(parents[x]);
    }
    
    void unite(int x, int y) {  //xとyの含むグループを併合
        int px = find(x);
        int py = find(y);
        if (parents[px] > parents[py]) swap(px,py); 
        if (px != py) {
            parents[px] += parents[py];
            parents[py] = px;
        }     
    }

    bool same(int x, int y) { //x,yが同じグループにいるか判定
        return find(x) == find(y);
    }

    int size(int x) { //xと同じグループのメンバーの個数
        return -parents[find(x)];
    }
    
    vector<int> root() {//ufの根を列挙
        vector<int> res;
        for (int i = 0; i < N; i ++) {
            if (parents[i] < 0) res.push_back(i);
        }
        return res;
    }

    int group_count() { //ufのグループの数を数える
        int cnt = 0;
        for (int i = 0; i < N; i ++) {
            if (parents[i] < 0) cnt++;
        }
        return cnt;
    }
};

void solve(int N,int M) {
    vector<pair<int,P>> edges(M);
    rep(i,M) cin >> edges[i].second.first >> edges[i].second.second >> edges[i].first;
    sort(edges.begin(),edges.end());


    if (M < N - 1) {
        cout << -1 << endl;
        return;
    }
    int ans = INF;
    rep(i,M) {
        UnionFind uf(N);
        int maximum = 0;
        for (int j = i;j < M; ++j) {
            int a = edges[j].second.first - 1,b = edges[j].second.second - 1;
            if (uf.same(a,b)) continue;
            else {
                uf.unite(a,b);
                maximum = edges[j].first;
            }
        }
        if (uf.group_count() != 1) break;
        ans = min(ans,maximum - edges[i].first);
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return;
}

int main() {
    while (true) {
        int N,M; cin >> N >> M;
        if (N == 0 && M == 0) return 0;
        solve(N,M);
    }
    return 0;
}


Measured memory_bytes: 3112
#include <iostream>
using namespace std;
 
int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
 
    long long ans_mat[c][d];
    for (int i = 0; i < c; i++){
        for (int j = 0; j < d; j++){
            ans_mat[i][j] = 0;
        }
    }
    
    ans_mat[a - 1][b - 1] = 1;
    for (int i = a-1; i < c; i++){
        for (int j = b-1; j < d; j++){
            if(i != a-1 || j != b - 1){
                if (i == 0){
                    ans_mat[i][j] = 1;
                }else if (j == 0){
                    ans_mat[i][j] = 1;
                }else{
                    ans_mat[i][j] = (ans_mat[i][j - 1] * (i + 1) % 998244353 + ans_mat[i - 1][j] * (j + 1) % 998244353- ans_mat[i - 1][j - 1] * i % 998244353 * j) % 998244353;
                    if (ans_mat[i][j] < 0){
                        ans_mat[i][j] += 998244353;
                    }

                }
            }
        }    
    }
    long ans = ans_mat[c - 1][d - 1]%998244353;
    cout << ans << endl;
}

Measured memory_bytes: 73932
#include <iostream>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <float.h>
#include <limits>
#include <vector> 
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long
#define asort(a) sort(a.begin(),a.end());

using namespace::std;

int jo(ll int jxo, ll int jyo){//累乗
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){//char大文字化
  return (toxbig-0x20);
}
char tolow(char toxlow){//char小文字化
  return (toxlow+0x20);
}
int ctoi(char cctoi){//char->int
  if('0' <= cctoi && cctoi <= '9') return (cctoi-'0');
  return -1;
}
int gcd(int gcad, int gcbd) {//最大公約数
  if(gcad < gcbd) return gcd(gcbd, gcad);
  int gcrd;
  while ((gcrd=gcad%gcbd)) {
    gcad = gcbd;
    gcbd = gcrd;
  }
  return gcbd;
}
int lcm(int lcam, int lcbm){//最小公倍数
 return (lcam*lcbm)/gcd(lcam,lcbm);
}


int main(){
  int a,b;
  cin>>a>>b;
  if(b-(a-1)<-1000000){
    rep(i,-1000000,b+a) cout<<i<<" ";
  }else if(b+a-1>1000000){
    rep(i,b-(a-1),1000001) cout<<i<<" ";
  }else{
    rep(i,b-(a-1),b+a) cout<<i<<" ";
  }
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
	int i = 0, ans = 0;
	char S[4] = {0}, T[4] = {0};
	scanf("%s", S);
	scanf("%s", T);
	for (i = 0; i < 3; i++) {
		if (S[i] == T[i]) {
			ans++;
		}
	}
	printf("%d\n",ans);
    return 0;
}


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

int n, t, a, h;

int main()
{
    while(cin >> n >> t >> a)
    {
        long double diff = INT_MAX;
        int res = -1;
        for(int i = 0; i < n; i++)
        {
            cin >> h;
            if(abs(a - (t - h * 0.006)) < diff)
            {
                res = i;
                diff = abs(a - (t - h * 0.006));
            }
        }

        cout << res + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define int long long
#define pb push_back
#define mod 1000000007
#define pll pair<long long,long long>
using namespace std;
long long power(long long a,long long b){
    long long ans=1;
    while(b>0){
        if(b&1){ans=(ans*a)%mod;}
                a=(a*a)%mod;
                b>>=1;
        }
    return ans;
        
}
bool prime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return false;
    }
    return true;
}
int dp[100005][3];
int fun(int i,int j,int a[],int b[],int c[],int n){
	if(i==n)return 0;
	if(dp[i][j]!=-1)return dp[i][j];
	int ans=0;
    for(int k=0;k<3;k++){
		if(k==j)continue; // here we make sure that the same activity doesn’t happen on two consecutive day
		else if(k==0)ans=max(ans,a[i]+fun(i+1,k,a,b,c,n));
		else if(k==1)ans=max(ans,b[i]+fun(i+1,k,a,b,c,n));
		else ans=max(ans,c[i]+fun(i+1,k,a,b,c,n));
    }
	return dp[i][j]=ans;
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
	cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++){
    	cin>>a[i]>>b[i]>>c[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<max(a[0]+fun(1ll,0,a,b,c,n),max(b[0]+fun(1ll,1ll,a,b,c,n),c[0]+fun(1ll,2ll,a,b,c,n)));
    return 0;
}


Measured memory_bytes: 20756
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
ll wf[210][210];
int main( ){
    ll N,M,R;
    cin>>N>>M>>R;
    vi r(R);
    rep(i,0,R)cin>>r[i],r[i]--;
    sort(r.begin(),r.end());
    rep(i,0,210){
        rep(j,0,210){
            if(i==j)wf[i][j]=wf[j][i]=0;
            else wf[i][j]=INF;
        }
    }
    rep(i,0,M){
        int a,b;
        ll c;
        cin>>a>>b>>c;
        a--,b--;
        wf[a][b]=c;
        wf[b][a]=c;
    }
    rep(i,0,N){
        rep(j,0,N){
            rep(k,0,N){
                chmin(wf[j][k],wf[j][i]+wf[i][k]);
            }
        }
    }
    ll ans=INF;
    int x=0;
    do{
        x++;
        ll res=0;
        rep(i,0,r.size()-1)res+=wf[r[i]][r[i+1]];
        chmin(ans,res);
    }while(next_permutation(r.begin(),r.end()));
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const ll MOD = (ll) (1e9 + 7);
const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

void finish() {
    cout << -1 << endl;
    exit(0);
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20) << setiosflags(ios::fixed);
    int n;
    cin >> n;
    int a[200010], s[200010];

    rep(i, n) {
        cin >> a[i];
        s[i] = a[i];
    }
    sort(s, s + n);
    reverse(s, s + n);

    rep(i, n) {
        if (a[i] == s[0]) cout << s[1] << endl;
        else cout << s[0] << endl;
    }

    return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>

using namespace std;

int main() {
    int N; scanf("%d", &N);
    vector<int> s(N);
    int sum = 0, ans = 0;
    for(int i = 0; i < N; i++)  {
      scanf("%d", &s[i]);
      sum += s[i];
    }
    //cout << "Sum=" << sum << endl;
    if(sum % 10 != 0) {
      ans = sum;
    } else {
      sort(s.begin(), s.end());
      for(int i = 0; i < N; i++) {
      //  cout << s[i] << endl;
        if(s[i] % 10 != 0) {
          ans = sum - s[i];
          break;
        }
      }
    }
    cout << ans << endl;
  return 0;
}


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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    ll n;
    cin>>n;
    vector<ll> v(n);
    for(ll i=0;i<n;i++) cin>>v[i];

    ll mx=INT_MIN,cnt=0;
    for(ll i=0;i<n-1;i++){
        if(v[i]>=v[i+1]) cnt++;
        else{
            mx=max(mx,cnt);
            cnt=0;
        }
    }
    mx=max(mx,cnt);
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 1024
n=gets.to_i
s=gets.chomp
a=[0]
n.times{|i|a.push a[-1]+(s[i]==?W ? 1 : 0)}
b=[0]
n.times{|i|b.unshift b[0]+(s[n-i-1]==?E ? 1 : 0)}
p (n+1).times.map{|i|a[i]+b[i]}.min

Measured memory_bytes: 10244