akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aoj_Learning2
{
    class Program
    {
        static void Main(string[] args)
        {
            Aoj_Learning16();
        }

        private static void Aoj_Learning16()
        {
            string[] str;
            int iLug, iTrack;
            //LinkedList<int>[] llTrack = new LinkedList<int>[100000];
            int[] iWeight = new int[100000];

            // 荷物の数とトラック台数の取得
            str = Console.ReadLine().Split(' ');
            iLug = int.Parse(str[0]);
            iTrack = int.Parse(str[1]);

            // 荷物の重さ取得
            for (int i = 0; i < iLug; i++)
            {
                iWeight[i] = int.Parse(Console.ReadLine());
            }

            // 連続した荷物の積み込みから最大積載量の最小値を探す
            // 二分探索をするための初期値を荷物の最大重さから取得
            int iWeightMax = 0;
            for(int i = 0; i < iLug; i++)
            {
                if(iWeightMax < iWeight[i])
                {
                    iWeightMax = iWeight[i];
                }
            }

            int first = 0, last = iWeightMax * iLug;
            int mid = 0;
            int iTemp1 = 0, iTemp2 = 0; ;
            while(last - first > 1)
            {
                mid = (last + first) / 2;
                iTemp1 = 0;
                for (int i = 0; i < iTrack; i++)
                {
                    iTemp2 = 0;
                    while(iTemp2 + iWeight[iTemp1] <= mid)
                    {
                        iTemp2 += iWeight[iTemp1];
                        iTemp1++;
                        if (iTemp1 == iLug) break;
                    }
                    if (iTemp1 == iLug)
                    {
                        break;
                    }
                }

                if(iTemp1 >= iLug)
                {
                    last = mid;
                }
                else
                {
                    first = mid;
                }
            }

            Console.WriteLine(last);
            
        }
    }
}


Measured memory_bytes: 20040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fastio() ios::sync_with_stdio(0);cin.tie(0);
#define nl "\n"
#define wi(x) cerr << #x << " is " << x << nl
const double eps = 1e-6;

void solve(){
	int a,b,c,k; cin>>a>>b>>c>>k;
	int cnt = 0;
	while(b <= a){b*=2; cnt++;}
	while(c <= b){c*=2; cnt++;}
	if(cnt <= k) cout<<"Yes";
	else cout<<"No";
} 

int main(){
	fastio()
	
	int T=1;
	//int T; cin>>T;
	while(T--) solve();

	return 0;
}



Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int INF = 100100100;
const double PI = 3.14159265358979323846;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0; i < (n); ++i)

int main() {
  ll n, a[100001] = {0};
  cin >> n;
  ll maxA = 0, countSum = 0, maxCountSum = 0;
  ll xCount[100005] = {0};
  REP(i, n) {
    cin >> a[i];
    xCount[a[i]]++;
    if (a[i] - 1 >= 0) xCount[a[i] - 1]++;
    if (a[i] + 1 < 100000) xCount[a[i] + 1]++;
    maxA = max(maxA, a[i]);
  }
  FOR(i, 0, maxA + 1) maxCountSum = max(maxCountSum, xCount[i]);
  cout << maxCountSum << endl;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	string S;
	cin >> S;

	if (S == "zyxwvutsrqponmlkjihgfedcba") {
		co(-1);
		return 0;
	}

	int C[26] = {};
	rep(i, S.size()) {
		C[S[i] - 'a'] = 1;
	}

	rep(i, 26) {
		if (C[i] == 0) {
			co(S + (char)(i + 'a'));
			return 0;
		}
	}

	char T[26];
	rep(i, 26) T[i] = S[i];
	next_permutation(T, T + 26);

	int dokomade = 0;
	rep(i, 26) {
		if (T[i] == S[i]) {
			dokomade++;
		}
		else break;
	}
	rep(i, dokomade + 1) {
		cout << T[i];
	}
	cout << endl;

	Would you please return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

struct edge
{
    int to;
    bool ok;
};

vector<edge> G[MAX_N];
bool white[MAX_N];
bool visit[MAX_N];
int deg[MAX_N];

bool dfs(int u,int p)
{
    bool res = white[u];
    deg[u] = len(G[u]);
    each(e,G[u]){
        if(e.to != p){
            if(dfs(e.to,u)){
                res = true;
            }else{
                deg[u]--;
                e.ok = false;
            }
        }
    }
    return res;
}

void dfs(int u,int p,int d,int& mx,int& mxid)
{
    visit[u] = true;
    if(p != -1){
        d += white[u]^(deg[u]%2);
        if(d >= mx){
            mx = d;
            mxid = u;
        }
    }
    each(e,G[u]){
        if(e.ok && e.to != p){
            dfs(e.to,u,d,mx,mxid);
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    rep(i,n-1){
        int a,b;
        cin >> a >> b;
        G[a-1].pb((edge){b-1,true}),G[b-1].pb((edge){a-1,true});
    }
    string s;
    cin >> s;
    int cnt = 0;
    int st = -1;
    rep(i,n){
        if(s[i] == 'W'){
            st = i;
            cnt++;
            white[i] = true;
        }
    }
    if(cnt == 0){
        cout << "0\n";
        return 0;
    }else if(cnt == 1){
        cout << "1\n";
        return 0;
    }
    dfs(st,-1);
    int d = 0,mx = 0, mxid = -1;
    dfs(st,-1,d,mx,mxid);
    int start = mxid;
    d = 0, mx = 0, mxid = -1;
    dfs(start,-1,d,mx,mxid);
    int al = 0;
    rep(i,n){
        if(visit[i]){
            al += (white[i]^(deg[i]%2))+2;
        }
    }
    cout << al - 2*(mx+1) << "\n";
    return 0;
}


Measured memory_bytes: 14288
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int[] p = new int[n];
            for (int i = 0; i < n; i++) {
                p[i] = scanner.nextInt();
            }
            int answer = 0;
            for (int i = 1; i < n - 1; i++) {
                if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
                    answer++;
                } else if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
                    answer++;
                }
            }
            System.out.println(answer);
        }
    }

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld h, n;
      lld i, s;
      cin >> h;
      cin >> n;
      lld A[n];
      s = 0;
      foi(i, n)
      {
      	cin >> A[i];
      	s += A[i];
      }
      if (s >= h)
      	cout << "Yes";
      else
      	cout <<  "No";
      return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(A: int, B: int, C: int, D: int):
    while A > 0 and C > 0:
        C -= B
        A -= D
    
    if C <= 0:
        print(YES)
    else:
        print(NO)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
n,k=map(int,input().split())
a=list(map(int,input().split()))
ng=0
ok=max(a)
while ng+1!=ok:
  mid=(ng+ok)//2
  ans=0
  for i in a:
    ans+=0--i//mid-1
  if ans<=k:ok=mid
  else:ng=mid
print(ok)

Measured memory_bytes: 30912
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=1000000000000000;
#define rep(i,l,r) for(ll i=l;i<=r;i++)

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

string memo[1000000];
string bina(ll i,ll j){
    if(memo[i]!=""){
        return memo[i];
    }
    ll ii=i;
    string ans="";
    while(i>0){
        if(i%2==1){
            ans='1'+ans;
            i=i/2;
        }else{
            ans='0'+ans;
            i=i/2;
        }
    }
    
    while(ans.size()<j){
        ans='0'+ans;
    }
    memo[ii]=ans;
    
    return ans;
}


int main(){
    ll n,a[4];cin>>n;
    rep(i,0,3){
        a[3-i]=n%10;
        n=n/10;
    }
    string b;
    ll sum;
    string ans=to_string(a[0]);
    rep(i,0,7){
        sum=a[0];
        b=bina(i,3);
        rep(j,0,2){
            if(b[j]=='0'){
                sum+=a[j+1];
            }else{
                sum-=a[j+1];
            }
        }
        if(sum==7){
            rep(j,0,2){
                if(b[j]=='0'){
                    ans=ans+'+';
                }else{
                    ans=ans+'-';
                }
                ans=ans+to_string(a[j+1]);
            }
            i=10;
        }
    }
    ans=ans+"=7";
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8064
#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() {
    int N, K;
    cin >> N >> K;
    ll mod0 = N / K;
    ll modhalf;
    if (K % 2 == 1) modhalf = 0;
    else {
        modhalf = mod0;
        if (N % K >= K / 2) ++modhalf;
    }
    ll ans = mod0*mod0*mod0 + modhalf*modhalf*modhalf;
    cout << ans << endl;
}


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

int main() {
	int s;
	cin >> s;
	int count = 1;

	if (s == 2 || s == 1) {
		s = 4;
	}

	while(s != 4) {
		if (s % 2 == 0) {
			s = s / 2;
			count++;
		}
		else {
			s = 3 * s + 1;
			count++;
		}
	}
	
	cout << count + 3 << endl;
	
	return 0;
}


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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    string s;
    cin >> s;
    string t;
    for(ll i = 0;i < s.size();i++){
        if(s[i] != 'x'){
            t.push_back(s[i]);
        }
    }
    for(ll i = 0;i < t.size() / 2;i++){
        if(t[i] != t[t.size() - 1 -i]){
            cout << -1;
            return 0;
        }
    }
    ll r = 0, l = s.size() - 1, ans = 0;
    while(r != l && r < l){
        if(s[r] == s[l]){
            r++;
            l--;
        }
        else if(s[r] == 'x'){
            ans++;
            r++;
        }
        else{
            ans++;
            l--;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <unordered_map>
#include <deque>
#include <list>
#include <set>
#include <random>
#include <deque>

using namespace std;
using ll = long long;
const int BIG = 100000007;


int main() {
    ll n;
    cin >> n;
    ll ac = 0;
    ll wa = 0;
    ll tle = 0;
    ll re = 0;
    for(ll i = 0;i < n;++i){
        string s;
        cin >> s;
        if(s == "AC")++ac;
        else if(s == "WA")++wa;
        else if(s == "TLE")++tle;
        else if(s == "RE")++re;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

}




Measured memory_bytes: 3232
#include<bits/stdc++.h>
//cervello|Phoenix
using namespace std;
#define ll long long int
#define eb emplace_back
#define mk make_pair
#define all(x) x.begin(),x.end()
#define mod 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n; cin>>n;
  n=n%10;
  if(n==3)
    return cout<<"bon\n", 0;
  if(n==0||n==1||n==6||n==8)
    return cout<<"pon\n", 0;
  cout<<"hon\n";
  return 0;
}

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

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	map<pair<string, string>, long> m;
	for (int i = 0; i < 1 << n; i++) {
		string t1, t2;
		for (int j = 0; j < n; j++) {
			if (i & 1 << j) t1 += s[j];
			else t2 += s[j];
		}
		m[make_pair(t1, t2)]++;
	}
	long r = 0;
	for (int i = 0; i < 1 << n; i++) {
		string t1, t2;
		for (int j = 0; j < n; j++) {
			if (i & 1 << j) t1 += s[n * 2 - j - 1];
			else t2 += s[n * 2 - j - 1];
		}
		auto it = m.find(make_pair(t2, t1));
		if (it != m.end())
			r += it->second;
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 46080
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    [r, D, x] = string_to_int(inputs[0])

    ret = deque([x])
    for _ in range(0, 10):
        ret.append(r * ret[-1] - D)

    ret.popleft()
    ret_str = ""
    for i in ret:
        ret_str += "{:d}\n".format(i)
    ret_str.strip()

    return ret_str


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3316
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int n = sc.nextInt();
		String S = sc.next();

		char[] chars = S.toCharArray();
		StringBuilder sb = new StringBuilder();
		int counter = 0;
		for (char c : chars) {
			if (c == '(') {
				counter++;
			} else if (counter <= 0) {
				sb.append('(');
			} else counter--;
		}
		sb = new StringBuilder(sb + S);
		for (int i = 0; i < counter; i++) {
			sb.append(')');
		}

		System.out.println(sb);
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

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

int main()
{
    char c;

    cin >> c;

    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    {
        cout << "vowel" << endl;
    }
    else
    {
        cout << "consonant" << endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    long long a[5];
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+4);
    if(a[1]==5&&a[2]==5&&a[3]==7)
    {
        cout<<"YES"<<endl;
    }
    else
    {
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;

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

int main() {
  int n,ans=1;
  cin >> n;
  vector<int> v(n),l(n,0),q(n,0);
  r(i,n)cin>>v[i];
  r(i,n-1)l[i+1]=gcd(l[i],v[i]);
  r(i,n-1)q[n-i-2]=gcd(q[n-i-1],v[n-i-1]);
  r(i,n)ans=max(ans,gcd(l[i],q[i]));
  cout << ans << endl;
}


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

int main() {
int x,fx;
cin>>x;
fx=0;
int t=x;
string ans="No";
while(t>0){
  fx+= t%10;
  t/=10;
  }
if(x%fx==0) ans="Yes";
cout<<ans<<endl;
return 0;
}
 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
int main()
{
  int K, S, ans = 0;
  cin >> K >> S;

  K++;
  rep(i, K) {
    rep(j, K) {
      int z = S - i - j;
      if (z >= 0 && z < K) ans++;
    }
  }

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

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
int main() {
	int isp[100000] = {};
	for (int i = 2; i < 100000; i++) {
		if (!isp[i]) {
			for (int j = 2 * i; j < 100000; j += i) {
				isp[j] = 1;
			}
		}
	}
	int n, a, b;
	while (cin >> n >> a >> b, n) {
		int p, q;
		int t = 0.0001 + sqrt(n);
		int ma = 0;
		for (int i = t; i >= 2; i--) {
			if (!isp[i]) {
				int sup = min(i * b / a, n / i);
				while (isp[sup])sup--;
				if (ma < i*sup) {
					p = i; q = sup;
					ma = i * sup;
				}
			}
		}
		cout << p << " " << q << endl;
	}
	return 0;
}


Measured memory_bytes: 3392
#include <iostream>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
 
ll i,j,k,ii,jj;
ll n,m,sum,num;
ll a,b,c,d,e,ans[500005];
ll x[500005],y[500005],z[100005];
ll dp[100],ma,mi;
char s[100005];

int main(){
	cin>>n;
	a=n;
	while(n>0){
		b+=n%10;
		n/=10;
	}
	if(a%b==0){
		p("Yes");
	}else{
		p("No");
	}

}

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

//0107
int main(){
	int n, x, y, z, r, x2, y2, z2;
	while(cin >> x >> y >> z, x+y+z){
		x2=x*x;
		y2=y*y;
		z2=z*z;

		cin >> n;
		while(n--){
			cin >> r;
			cout << ((4*r*r > min(x2+y2, min(y2+z2, z2+x2))) ? "OK" : "NA");
			cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<functional>
#define MAX 11
using namespace std;
class Team{
public:
  char name;
  int wins;
  int loses;
  int id;
  Team():id(0),wins(0),loses(0){}
  bool operator>(const Team &t)const{
    if( wins == t.wins ){
      if( loses == t.loses ){
	return id < t.id;
      }else return loses < t.loses;
    }else return wins > t.wins;
  }
};
int main()
{
  while(true){
    int n;
    cin >> n;
    if( n == 0 ) break;
    Team teams[n];
    for(int i = 0; i < n; ++i){
      teams[i].id = i;
      char name;
      cin >> name;
      teams[i].name=name;
      for(int j = 0; j < n-1; ++j){
	int r;cin>>r;
	if(r==0)teams[i].wins++;
	if(r==1)teams[i].loses++;
      }
    }
    sort(teams,teams+n,greater<Team>());
    for(int i = 0; i < n; ++i){
      cout << teams[i].name << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

int main() {
    int n, count = 0;
    std::cin >> n;

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

    bool flag = true;
    while (flag) {
        flag = false;
        for (int j = n-1; j >= 0; j--) {
            if (A[j] < A[j-1]) {
                std::swap(A[j], A[j-1]);
                flag = true;
                count++;
            }
        }
    }

    for (int k = 0; k < (n-1); k++) std::cout << A[k] << " ";
    std::cout << A[n-1] << std::endl;
    std::cout << count << std::endl;

    return 0;
    
}


Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <set>
#include <string>
#define int long long
#define pii pair<int, int>
using namespace std;

void fast() {
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
}

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

int a[9];
const int N = 1e4 + 10;
int dp1[N], dp2[N];
int cc[10] = {
0
,
2
,
5
,
5
,
4
,
5
,
6
,
3
,
7
,
6};
int b[6];
bool used[10];
bool c2[10];
vector<int> tt(10);
int m = 0;

bool check(int x, int k) {
	int d = x - k * b[0];
	//cout << d << '\n';
	//cout << b[0] << '\n';
	if (d < 0) return false;
	int s = 0;
	for (int j = m - 1; j > 0; j--) {
		s += d / b[j];
		d %= b[j];
		//cout << s << '\n';
	}
	//cout << d << ' ' << s << '\n';
	return d == 0 && s <= k;
}

signed main() {
	fast();
	int n, mm;
	cin >> n >> mm;
	for (int i = 0; i < mm; i++) {
		cin >> a[i];
		c2[a[i]] = true;
		if (!used[cc[a[i]]]) {
			used[cc[a[i]]] = true;
			b[m++] = cc[a[i]];
		}
	}
	sort(b, b + m);
	for (int i = 1; i < m; i++) {
		b[i] -= b[0];
		//cout << b[i] << ' ';
	}
	//cout << '\n';
	int l = -1;
	//cout << check(11, 3);
	for (int i = n; i >= 0; i--) {
		if (check(n, i)) {
			l = i; break;
		}
	}
	//cout << l << '\n';
	for (int i = 0; i < l; i++) {
		//cout << n << '\n';
		for (int j = 9; j >= 1; j--) {
			if (!c2[j]) continue;
			if (check(n - cc[j], l - i - 1)) {
				n -= cc[j];
				cout << j; break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
// たぶんTLEしにくいし短くて良い
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for (int i = 1; i <= n; i += 2) {
        cnt++;
    }
    if (cnt >= k) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
# V: 頂点数
# g[v] = [w, ...]:
#    有向グラフ上の頂点vから到達できる頂点w
# deg[v]:
#    頂点vに到達できる頂点の数

n,m = map(int, input().split())
V,E = n, n-1+m
g = [[] for i in range(V)]
u = [[] for i in range(V)]
deg = [0]*V
for i in range(E):
    s, t = map(int, input().split())
    s-=1
    t-=1
    g[s].append(t)
    u[t].append(s)
    deg[t] += 1

from collections import deque
ans = list(v for v in range(V) if deg[v]==0)
deq = deque(ans)
used = [0]*V

while deq:
    v = deq.popleft()
    for t in g[v]:
        deg[t] -= 1
        if deg[t]==0:
            deq.append(t)
            ans.append(t)

# ans: トポロジカル順序に並べた頂点

nrank = dict((n, r) for r, n in enumerate(ans))

for i in range(n):
    r = 0
    if u[i]:
        r = sorted(u[i], key=lambda x:-nrank[x])[0]
        print(r+1)
    else:
        print(0)

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

 int main(){
  char X,Y;
  char A,B,C,D,E,F;
  int x, y;
  
  cin >> X >> Y;
  
  if (X=='A') x = 10;
   else if (X == 'B') x = 11;
   else if (X == 'C') x = 12;
   else if (X == 'D') x = 13;
   else if (X == 'E') x = 14;
   else if (X == 'F') x = 15;
  
  if (Y == 'A') y = 10;
   else if (Y == 'B') y = 11;
   else if (Y == 'C') y = 12;
   else if (Y == 'D') y = 13;
   else if (Y == 'E') y = 14;
   else if (Y == 'F') y = 15;


  if(x<y) cout << "<" << endl;
   else if(x==y) cout << "=" << endl;
   else if(x>y) cout << ">" << endl;


 return 0;
}

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

int main() {
	// your code goes here
	int b,g,r,k;
	cin>>r>>g>>b>>k;//b>g>>r
    while(g<=r)
     {
     	g*=2;
     	k--;
     }
    while(b<=g)
     {
     	b*=2;
     	k--;
     }
     if(k>=0)
      cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
	return 0;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

vector<vector<int>> c(10, vector<int>(10));

int dfs(int i, int sum, vector<int> memo) {

	memo[i] = 1;
	int tmp = sum + c[i][1];
	rep (j, 0, 10) {
		if (j == 1)
			continue;
		if (memo[j] != 1) {
			tmp = min(tmp, dfs(j, sum + c[i][j], memo));
		}
	}

	return tmp;
}

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

	int h, w;
	cin >> h >> w;

	rep (i, 0, 10)
		rep (j, 0, 10)
		cin >> c[i][j];

	vector<vector<int>> a(h, vector<int>(w));
	rep (i, 0, h)
		rep (j, 0, w)
		cin >> a[i][j];

	vector<int> route(10, INF);
	/*
	rep (i, 0, 10) {
		vector<int> memo(10, 0);
		if (i == 1)
			continue;
		route[i] = dfs(i, 0, memo);
	}
	*/
	rep (k, 0, 10) {
		rep (i, 0, 10) {
			rep (j, 0, 10) {
				c[i][j] = min({c[i][j], c[i][k] + c[k][j]});
			}
		}
	}

	int res = 0;
	rep (i, 0, h) {
		rep (j, 0, w) {
			if (a[i][j] != -1 && a[i][j] != 1)
				res += c[a[i][j]][1];
		}
	}

	cout << res << endl;
	return 0;
}


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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    
    for (int i = 0; i < 1000; ++i) {
        string t = to_string(i);
        if (t.size() == 1) t = "00" + t;
        else if (t.size() == 2) t = "0" + t;
        int start = 0;
        // 0文字目の探索
        for (int j = 0; j < n; ++j) {
            if (s[j] == t[0]) {
                start = j + 1;
                break;
            }
        }
        if (start == 0) continue;
        bool test = true;
        for (int k = start; k < n; ++k) {
            if (s[k] == t[1]) {
                test = false;
                start = k + 1;
                break;
            }
        }
        if (test) continue;
        test = true;
        for (int l = start; l < n; ++l) {
            if (s[l] == t[2]) {
                ans++;
                test = false;
                break;
            }
        }
        if (test) continue;
    }
    cout << ans << endl;
}


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

int main()
{
    int n, m;
    std::cin >> n >> m;

    std::vector<int> arr_a(n), arr_b(n), arr_c(m), arr_d(m);
    for (int i = 0; i < n; ++i)
    {
        int a, b;
        std::cin >> a >> b;
        arr_a[i] = a;
        arr_b[i] = b;
    }
    for (int i = 0; i < m; ++i)
    {
        int c, d;
        std::cin >> c >> d;
        arr_c[i] = c;
        arr_d[i] = d;
    }

    for (int i = 0; i < n; ++i)
    {
        const int a = arr_a[i], b = arr_b[i];
        int dist = std::numeric_limits<int>::max();
        int index = -1;
        for (int j = 0; j < m; ++j)
        {
            const int c = arr_c[j], d = arr_d[j];
            const int tmp = std::abs(a - c) + std::abs(b - d);
            if (tmp < dist)
            {
                dist = tmp;
                index = j;
            }
        }
        std::cout << index + 1 << std::endl;
    }
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll LINF = 1ll << 55;
const ll MOD = 1e9 + 7;
const ll MAXN = 400 + 5;
const ll MAXK = 1e5 + 10;

const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

template<typename T>
ostream& operator<< (ostream& out, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        out << *it << " ";
    }
    return out;
}

template<typename T>
istream& operator>> (istream& in, vector<T>& vec) {
    for (auto it = vec.begin(); it != vec.end(); ++it) {
        in >> *it;
    }
    return in;
}

int main() {
    char c;
    vb nums(3);
    for (int i = 0; i < 3; ++i) {
        cin >> c;
        if (c == 'a' || c == 'b' || c == 'c') {
            nums[c - 'a'] = true;
        }
    }
    if (nums[0] && nums[1] && nums[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
while (square_count = gets.to_i) != 0 do
  orders = []
  (square_count-1).times do
    target_square, direction =gets.split.map(&:to_i)
    orders.push([target_square, direction])
  end

  positions = [[0, 0]]
  orders.each do |order|
    #p 'order', order
    ref_position = positions[order[0]]
    case order[1]
      when 0
        positions.push([ref_position[0] -1, ref_position[1]])
      when 1
        positions.push([ref_position[0], ref_position[1] -1])
      when 2
        positions.push([ref_position[0] +1, ref_position[1]])
      when 3
        positions.push([ref_position[0], ref_position[1] +1])
    end

  end

  max_x = min_x = max_y = min_y = 0

  positions.each do |position|
    max_x = position[0] if position[0] >= max_x
    min_x = position[0] if position[0] <= min_x

    max_y = position[1] if position[1] >= max_y
    min_y = position[1] if position[1] <= min_y
  end
  
  width =max_x-min_x+1
  height = max_y-min_y + 1

  puts width.to_s + ' ' + height.to_s

end

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

#define pb     push_back
#define mp     make_pair
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
#define forc(c,it) for(__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
const ll INF =  0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int MAX = 1e5+5;

long double a, b;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
	cin >> a >> b;
	int len = 0;
	while(a <= b){
		len++;
		a = a * 2;
	}
	cout << len;
	return 0;
}


Measured memory_bytes: 256
N,M,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = 'War'
for i in range(X+1, Y+1):
  if max(x) < i and i <= min(y):
    ans = 'No War'

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int x[n],y[n],t[n];
  for(int i=0;i<n;i++)cin>>t[i]>>x[i]>>y[i];
  int nowx=0,nowy=0,nowt=0;
  for(int i=0;i<n;i++){
    int dx=abs(nowx-x[i]),dy=abs(nowy-y[i]),dt=abs(nowt-t[i]);
    if(dx+dy<=dt&&(dx+dy)%2==dt%2){
      nowx=x[i];nowy=y[i];nowt=t[i];
      continue;
    }
    else{
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 1408
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    ll x,a,b;cin>>x>>a>>b;
    if(b<=a)
        cout<<"delicious"<<endl;
    else if(b<=a+x)
        cout<<"safe"<<endl;
    else
        cout<<"dangerous"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  while(true){
    int n,m,j;
    cin>>n>>m;
    if(!n&&!m)break;
    char seat[n+2];
    int len[n];
    bool sit = false;
    for(int i=0;i<n+2;i++){
      seat[i] = '#';
    }
    for(int i=0;i<m;i++){
      char p;
      cin>>p;
      if(p=='A'){
	for(j=1;j<n+1;j++){
	  if(seat[j]=='#'){
	    seat[j] = 'A';
	    break;
	  }
	}
	sit = true;
      }
      if(p=='B'){
	for(j=n;j>0;j--){
	  if(seat[j]=='#'&&seat[j-1]!='A'&&seat[j+1]!='A'){
	    seat[j] = 'B';
	    break;
	  }
	}
	if(j<0){
	  for(j=1;j<n+1;j++){
	    if(seat[j]=='#'){
	      seat[j] = 'B';
	      break;
	    }
	  }
	}
	sit = true;
      }
      if(p=='C'){
	if(!sit){
	  seat[n/2+1] = 'C';
	}
	else{
	  for(j=1;j<n;j++){
	    if(seat[j]!='#'){
	      if(seat[j+1]=='#'){
		seat[j+1] = 'C';
		break;
	      }
	      else if(j!=1&&seat[j-1]=='#'){
		seat[j-1] = 'C';
		break;
	      }
	    }
	  }
	}
	sit = true;
      }
      if(p=='D'){
	if(!sit){
	  seat[1] = 'D';
	}
	else{
	  int l=1000;
	  for(int j=1;j<n+1;j++){
	    if(seat[j]!='#')l = 0;
	    else l++;
	    len[j] = l;
	  }
	  l=1000;
	  int lenmax = 0,maxseat;
	  for(int j=n;j>0;j--){
	    if(seat[j]!='#')l = 0;
	    else l++;
	    len[j] = min(len[j],l);
	    if(lenmax<=len[j]){
	      lenmax=len[j];
	      maxseat=j;
	    }
	  }
	  seat[maxseat] = 'D';
	}
	sit = true;
      }
    }
    for(int i=1;i<n+1;i++)
      cout<<seat[i];
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main(void) {
	int W, H, x, y, r;

	cin >> W >> H >> x >> y >> r;

	if ((W < (2 * r)) || (H < (2 * r))) {
		cout << "No" << endl;
	}
	else if ((y - r < 0) || (y + r > H) || (x - r < 0) || (x + r > W)) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

Measured memory_bytes: 3104
#include <cstdio>
#include <iostream>
#include <algorithm>
#define oo 987654321
#define INT long long
#define MOD 1000000007
#include <vector>
using namespace std;

INT k, a, b, a0;

int main()
{
    ios::sync_with_stdio(0);
    cin>>k;
    a = k/50;
    if( k%50 == 0 ) b = 100;
    else b = ((50*a+49)-k), a++, a0 = a-1;
    cout<<50<<endl;
    for(int i = 0 ; i < 50 ; i++, a++ )
        if( i == b ) cout<<a0<<" ";
        else cout<<a<<" ";
    return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll n, m;
  cin >> n >> m;
  vector<set<ll>> to(n);
  rep(i, m) { ll a, b;
    cin >> a >> b;
    a--, b--;
    to[a].insert(b);
    to[b].insert(a);
  }
  vll arr;
  rep(i, n-1) arr.push_back(i+1);
  ll ans = 0;
  do {
    bool ok = true;
    ll cur = 0;
    rep(i, n - 1) {
      auto nxt = to[cur].find(arr[i]);
      if (nxt != to[cur].end()) {
        cur = *nxt;
      } else {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  } while (next_permutation(arr.begin(), arr.end()));

  cout << ans << endl;

  return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n); for(auto&i:a)cin>>i;
	sort(a.begin(),a.end(),[](auto a,auto b){return a>b;});
	int i=1;
	while(i<n&&a.at(i-1)!=a.at(i))++i;
	int mx;if(i>=n)mx=0;else mx=a.at(i);
	++i;
	while(i+1<n&&a.at(i)!=a.at(i+1))++i;
	int mx2;if(i>=n)mx2=0;else mx2=a.at(i);
	cout<<(int64_t)mx*mx2<<"\n"s;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"

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

  int H,W,K;
  cin>>H>>W>>K;
  vector<string>c(H);
  for(int i=0;i<H;i++)cin>>c[i];
  int bitH=pow(2,H),bitW=pow(2,W);
  ll ans=0;
  for(int i=0;i<bitH;i++){
    for(int j=0;j<bitW;j++){
      int count=0;
      for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
          if(!((i>>h)&1)&&!((j>>w)&1)&&c[h][w]=='#')count++;
        }
      }
      if(count==K)ans++;
    }
  }

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


Measured memory_bytes: 4084
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string s;
    cin >> s;

    if(s[0] == '0' || s.back() == '1') {
        print("-1");
        return 0;
    }

    REP(i, s.size() - 1) {
        if (s[i] != s[s.size() - i - 2]) {
            print("-1");
            return 0;
        }
    }

    vector<pair<int, int>> ans;
    int prev = 1;
    REP(i, s.size() - 1) {
        int cur = i + 2;
        ans.eb(prev, cur);
        if (s[i] == '1') prev = cur;
    }

    for (auto &e: ans) {
        cout << e.fi << " " << e.se << endl;
    }
}


Measured memory_bytes: 4504
#include "bits/stdc++.h"
#define readInt(x) scanf_s("%d", &x)
#define readStr(x) scanf("%s", x)
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmax(x, y) (x > (y) ? x : x = (y))
#define chmin(x, y) (x < (y) ? x : x = (y))
#define write(x) cout << (x) << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = INT32_MAX / 2;
const int MAX = 1e5 + 10;

int N;
int num[MAX];

int main()
{
    cin >> N;
    rep(i, N) {
        int a;
        cin >> a;
        num[a]++;
    }
    int ans = 0;
    for (int X = 1; X < 100000 - 1; X++) {
        int sum = num[X - 1] + num[X] + num[X + 1];
        chmax(ans, sum);
    }
    write(ans);
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MOD = 1000000007;

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

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
ll ma,mb;
vector<ll> a,b,c;

ll dp[51][510][510];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> ma >> mb;
    a.resize(N); b.resize(N); c.resize(N);
    rep(i,N) cin >> a[i] >> b[i] >> c[i];
    for (int i = 0; i < 51; ++i) for (int j = 0; j < 510; ++j) for (int k = 0; k < 510; ++k) dp[i][j][k] = LLINF;
    dp[0][0][0] = 0;
    rep(i,N){
      rep(wa,500){
        rep(wb,500){

          chmin(dp[i+1][wa][wb], dp[i][wa][wb]);
          chmin(dp[i+1][wa+a[i]][wb+b[i]], dp[i][wa][wb] + c[i]);
        }
      }
    }
    ll ans = LLINF;
    REP(wa,1,500){
      REP(wb,1,500){
        if (wa * mb != wb * ma) continue;
        chmin(ans, dp[N][wa][wb]);
      }
    }
    if (ans < LLINF) cout << ans << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 103936
from functools import reduce
INF = int(1e9 + 7)


def modmulti(a, b):
    # aとbを掛けた値をmodする(a * b mod p)
    return a * b % INF


def factorial(x):
    FCT = 1
    FCT = reduce(modmulti, range(2, x + 1), FCT)
    return FCT


def main():
    N, M = map(int, input().split())
    if N == M or N + 1 == M or N == M + 1:
        print(modmulti(2, modmulti(factorial(N), factorial(M)))
              if N == M else modmulti(factorial(N), factorial(M)))
    else:
        print(0)

    return


main()


Measured memory_bytes: 3572
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>

using namespace std;

int main(){

  long double a,b,x;

  cin >> a >> b >> x;

  long double  t;
  if(x>=a*a*b/2)t= atan(2*(a*a*b-x)/(a*a*a))*180/3.1415926535 ;
  else t= 90.0000000-atan(2*x/(a*b*b))*180/3.1415926535;

  printf("%.12Lf",t);

}

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

int main(){
    int N,T;
    cin >> N >> T;
    vector <pair<int,int> > AB;
    vector <int> last(N);
    vector <vector<int> > dp(N+1,vector<int> (T,0) );

    int A,B;
    for(int i=0; i<N; i++){
        cin >> A >> B;
        AB.push_back(make_pair(A,B));
    }

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

    int bmax=0;
    for(int i=0; i<N; i++){
        int btmp = AB[N-i-1].second;
        if( btmp > bmax ){
            bmax = btmp;
        }
        last[N-i-1] = bmax;
    }

    int ans = 0;
    int dpMn;
    for(int i=1; i<=N; i++){
        A = AB[i-1].first;
        B = AB[i-1].second;

        //cout << "i A B " << i << " " << A << " " << B << endl;
        for(int j=0; j<T; j++)  dp[i][j] = dp[i-1][j];

        if( i==N ){
            int dpM=0;
            for(int j=0; j<T; j++){
                if(dp[i][j]>dpM){
                    dpM = dp[i][j];
                }
            }

            dpM = dpM + B;

            if( ans < dpM ){
                ans = dpM;
            }
            break;         
        }

        for(int j=0; j<T; j++){
            if( j + A >= T ) continue;
            if( dp[i][j+A] < dp[i-1][j] + B ){
                dp[i][j+A] = dp[i-1][j] + B;
                //cout << "i j j+A dp[i][j+A] " << i << " " << j << " " << j+A << " " << dp[i][j+A] << endl;
            }
        }
        int dpM=0;
        for(int j=0; j<T; j++){
            if(dp[i][j]>dpM){
                dpM = dp[i][j];
            }
        }
        //cout << "i dpM " << i << " " << dpM << endl;
        dpM = dpM + last[i];

        if( ans < dpM ){
            ans = dpM;
        }

    }




    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define endl "\n"
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define DEC(x) fixed<<setprecision(x)
#define FAST ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
const int M=1000000007;
const int MM=998244353;
const long double PI = acos(-1);
const long long INF=2e18;

template<typename T,typename T1>void amax(T &a,T1 b){if(b>a)a=b;}
template<typename T,typename T1>void amin(T &a,T1 b){if(b<a)a=b;}

ll power( ll b, ll e)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b,e/2);
    return power(b*b,e/2);
}
ll power(ll b,ll e,ll m)
{
    if(e==0) return 1;
    if(e&1) return b*power(b*b%m,e/2,m)%m;
    return power(b*b%m,e/2,m);
}
ll modinv(ll a,ll m)
{
    return power(a,m-2,m);
}

// #define _NCR_
vector<set<ll>>adj;
vector<bool>vis;
ll c=0;
void dfs(ll x)
{
	vis[x]=true;
	c++;
	for(auto it=adj[x].begin();it!=adj[x].end();it++)
	{
		if(!vis[(*it)])
			dfs((*it));
	}

}
int TLE_TERROR()
{
 	ll n,m,l,r,ans=-2e18;
 	cin>>n>>m;
 	adj.resize(n+1);
 	vis.resize(n+1);
 	for(ll int i=0;i<m;i++)
 	{
 		cin>>l>>r;
 		adj[l].insert(r);
 		adj[r].insert(l);
 	}
 	for(ll int i=1;i<=n;i++)
 	{
 		if(!vis[i])
 		{
 			c=0;
 			dfs(i);
 			ans=max(ans,c);
 		}
 	}
 	cout<<ans;
 	return 0;   
}

int main()
{
    FAST
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    ll int TESTS=1;
    // cin>>TESTS;
    #ifdef _NCR_
        initialvalues();
    #endif
    while(TESTS--)
        TLE_TERROR();
    return 0;
}

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

int main() {
  string S;
  int w;
  cin >> S >> w;
  int iter = 0;

  while (iter < S.size()) {
    cout << S[iter];
    iter += w;
  }
  cout << endl;
  return 0;
}



Measured memory_bytes: 256