akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<pair<int,int>>>;
int dij(int a,int b,Graph G){
  vector<ll>dist(G.size(),101640100165);
  dist[a] = 0;
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>pq;
  pq.push({0,a});
  while(!(pq.empty())){
    int now = pq.top().second,now_cost = pq.top().first;
    pq.pop();
    for(auto i : G[now]){
      if(dist[i.first] <= now_cost + i.second)continue;
      dist[i.first] = now_cost + i.second;
      pq.push({dist[i.first],i.first});
    }
  }
  return dist[b];
}
int main(){
  while(true){
    int n,m;
    cin >> n >> m;
    if(n == 0 && m == 0)return 0;
    Graph cost(m),time(m);
    rep(i,n){
      int a,b;
      cin >> a >> b;
      a--,b--;
      int c,t;
      cin >> c >> t;
      cost[a].push_back({b,c});
      cost[b].push_back({a,c});
      time[a].push_back({b,t});
      time[b].push_back({a,t});
    }
    int cnt;
    cin >> cnt;
    rep(i,cnt){
      int a,b,c;
      cin >> a >> b >> c;
      a--,b--;
      if(c)cout << dij(a,b,time) << endl;
      else cout << dij(a,b,cost) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll n;
vector<pair<ll, ll>> xy(n);

double f(double x, double y) {
    double ans = 0;
    rep(i, n) {
        double dx = x - xy[i].first;
        double dy = y - xy[i].second;
        ans = max(ans, sqrt(dx * dx + dy * dy));
    }
    return ans;
}

double g(double x) {
    double l = 0, r = 1000;
    rep(i, 80) {
        double lm = (l * 2 + r) / 3;
        double hm = (l + 2 * r) / 3;
        if (f(x, lm) > f(x, hm)) l = lm;
        else r = hm;
    }
    return f(x, l);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n;
    xy.resize(n);
    rep(i, n) cin >> xy[i].first >> xy[i].second;
    double l = 0, r = 1000;
    rep(i, 80) {
        double lm = (l * 2 + r) / 3;
        double hm = (l + 2 * r) / 3;
        if (g(lm) > g(hm)) l = lm;
        else r = hm;
    }
    double ans = g(l);
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        if(a+b==c || a+c==b || c+b==a){
            System.out.println("Yes");
        } 
        else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21844
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
    
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        int z = scanner.nextInt();

        int[] foo = {x, y, z};
        Arrays.sort(foo);
        System.out.print(foo[0]);
        System.out.print(" ");
        System.out.print(foo[1]);
        System.out.print(" ");
        System.out.println(foo[2]);
    }
}


Measured memory_bytes: 26232
fun main(args: Array<String>) {
    val n = readLine()!!.split(" ").map { it.toInt() }[0]
    val a = readLine()!!.split(" ").map { it.toInt() }
    val suma = a.sum()
    val ans = n - suma
    if (ans >= 0){
        println(ans)
    } else {
        println(-1)
    }

}

Measured memory_bytes: 39348
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s;

  int s_c = 0, t_c = 0;

  REP(i, s.length()) {
    if(s[i] == 'S') {
      s_c++;
    } else {
      if(s_c > 0) s_c--;
      else t_c++;
    }
  }

  cout << s_c + t_c << endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define all(a) a.begin(),a.end()
#define endl '\n'
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ull unsigned long long
#define int long long
#define iter vector<int>::iterator
using namespace std;
using namespace __gnu_pbds;

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

template<class T>
using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rnd1(chrono::steady_clock::now().time_since_epoch().count());

//find_by_order
//order_of_key

const int N=2e5+7;
const int inf=1e18+5;
const int mod=2520;

string a[N];

main ()
{
    ios;
    int n;
    cin>>n;
    for (int i=1;i<=n;++i){
        cin>>a[i];
        sort(all(a[i]));
    }
    int ans=0;
    int cnt=0;
    sort(a+1,a+n+1);
    for (int i=1;i<=n;++i){
        if (a[i]!=a[i-1]){
            ans+=cnt*(cnt-1)/2;
            cnt=1;
        }
        else {
            ++cnt;
        }
    }
    ans+=cnt*(cnt-1)/2;
    cout<<ans<<endl;
}


Measured memory_bytes: 6528
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const int INF = (1LL<<30);
#else
const ll INF = (1LL<<60);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

int a[100010], cnt[100010], l[100010], ans[100010];

// xx, yy, zzにそれぞれ座圧する元の配列を突っ込むとx, y, zが座圧された配列で返ってくる
// zip[座圧前] = 座圧後、unzip[座圧後] = 座圧前
VL xx, x, unzip(100010);
unordered_map<int, int> zip;
void compress() {
  x = xx;
  sort(ALL(xx));
  xx.erase(unique(ALL(xx)), xx.end());
  REP(i, xx.size()) {zip[xx[i]] = i; unzip[i] = xx[i];}
  REP(i, x.size()) x[i] = zip[x[i]];
}

signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    cin >> a[i];
    xx.PB(a[i]);
  }
  compress();

  memset(l, -1, sizeof(l));
  int ma = 0;
  REP(i, n) {
    chmax(ma, (int)x[i]);
    cnt[x[i]]++;
    if(l[x[i]] == -1) l[x[i]] = i;
  }
  for(int i=ma; i>=1; --i) cnt[i-1] += cnt[i];
  int mi = INF;
  for(int i=ma; i>=0; --i) {
    chmin(mi, l[i]);
    l[i] = mi;
  }
  // REP(i, n) cout << x[i] << " "; cout << endl;
  // REP(i, ma+1) cout << cnt[i] << " "; cout << endl;
  REP(i, ma+1) {
    int tmp;
    if(i == 0) tmp = xx[i];
    else tmp = xx[i] - xx[i-1];
    ans[l[i]] += cnt[i] * tmp;
    // cout << cnt[i] << " " << tmp << endl;
    // REP(j, n) cout << ans[j] << " "; cout << endl;
  }

  REP(i, n) cout << ans[i] << endl;

  return 0;
}


Measured memory_bytes: 10612
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

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

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 5e3 + 20;

void solve() {

    int k;
    cin >> k;

    queue<char> q;

    string s;
    cin >> s;
    if (s.size() <= k){
        cout << s;
    } else {
        for (int i = 0; i < k; ++i) {
            cout << s[i];
        }
        cout << "...";
    }

}

#else

void solve() {

}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++) << ": ";
        solve();
        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);


#ifdef multi
    multisolve();
#else
    solve();
    //    gen();
#endif

}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=1e17;
const long double PI=acos(-1);



void solve(int T){
   int n;
   cin>>n;
   if(n==1){
    cout<<0<<"\n";
   }
   else cout<<1<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3616
using static System.Console;
class Z { static void Main() => new K(); }
class K
{
	const int MOD = 1000000007;
	public K()
	{
		const int M = 10;
		var N = int.Parse(ReadLine());
		var dfa = new int[M, 4] {
			{ 3, 4, 1, 1 },
			{ 2, 2, 2, 2 },
			{ 3, 5, 6, 7 },
			{ 8, 4, 1, 1 },
			{ 8, 9, 2, 10 },
			{ 3, 2, 1, 1 },
			{ 3, 9, 1, 1 },
			{ 3, 5, 2, 7 },
			{ 8, 4, 2, 1 },
			{ 3, 4, 2, 1 } };
		for (var i = 0; i < M; i++) for (var j = 0; j < 4; j++) dfa[i, j]--;
		// start = 0, accepted = {1}
		var dp = new long[N + 1, M];
		dp[0, 0] = 1;
		for (var i = 0; i < N; i++)
			for (var s = 0; s < M; s++)
				for (var c = 0; c < 4; c++)
				{
					var t = dfa[s, c];
					dp[i + 1, t] = (dp[i + 1, t] + dp[i, s]) % MOD;
				}
		WriteLine((Pow(4, N) - dp[N, 1] + MOD) % MOD);
	}
	public static long Pow(long a, long b)
	{
		var p = 1L;
		var x = a;
		while (b > 0)
		{
			if ((b & 1) == 1) p = p * x % MOD;
			b >>= 1;
			x = x * x % MOD;
		}
		return p;
	}
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int64> cnt(n+1,0);
    vector<int64> a(n);
    REP(i,n){
        cin >> a[i];
        cnt[a[i]]++;
    }
    vector<int64> comb(n+1,0);
    int64 sum = 0;
    REP(i,n+1){
        comb[i] = cnt[i] * (cnt[i] - 1) / 2;
        sum += comb[i];
    }
    REP(i,n){
        ANS(sum - comb[a[i]] + (cnt[a[i]] - 1) * (cnt[a[i]] - 2) / 2);
    }
    return 0;
}

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

int main(void){
	int n, m;
	cin >> n >> m;
	vector<long long> a(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	vector<pair<long long, long long>> d;
	long long b, c;
	for(int i = 0; i < m; ++i){
		cin >> b >> c;
		d.push_back(make_pair(c,b));
	}
	sort(d.rbegin(), d.rend());
	// for(auto x : d){
	// 	cout << x.first << x.second << " ";
	// }
	int k = 0;
	for(int i = 0; i < n; ++i){
		if(a[i] < d[k].first){
			a[i] = d[k].first;
			d[k].second--;
			if(d[k].second==0)k++;	
		}else{
			k++;
		}
		if(k==m)break;
	}
	long long ans = 0;
	for(int i = 0; i < n; ++i){
		ans += a[i];
		//cout << a[i] << " ";
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline

K,N = map(int,input().split())

if K % 2 == 0:
    L = K // 2
    R = L + 1
    # 先頭の文字が L のものの最後、R のものの最初、で境界
    arr = [L] + [K] * (N-1)
else:
    """
    [3,3,3,3,3] だと 手前に3 33 333 3333 が余分。2歩戻る。
    """
    arr = [(K+1)//2] * N
    x = N//2# x歩 戻る
    for i in range(x):
        arr[-1] -= 1
        if arr[-1] == 0:
            arr.pop()
            continue
        L = len(arr)
        if L < N:
            arr += [K] * (N-L)

answer = ' '.join(map(str,arr))
print(answer)

Measured memory_bytes: 26532
#include<bits/stdc++.h> 
using namespace std; 
#define x first
#define y second
#define forn(i, n) for(int i = 0; i < int(n); ++i)
typedef pair<int, int> pii;
const int MAXN = 200000+23;
int A[MAXN];
int N;
long long K;

void solve(){
	cin>>N>>K;
	forn(i,N){
		cin>>A[i];
		A[i]--;
	}	
	set<int> ro;
	ro.insert(0);
	int curr = 0;
	vector<int> places(N,-1);
	places[0] = 0;
	int pl = 0;
	while(1){
		curr = A[curr];
		if(ro.count(curr)){
			int cyc = ro.size() - places[curr];
			int fin;
			if(K<=places[curr]){
				fin = K;
			}
			else{
				long long d = (K-places[curr])%cyc;
				fin = (int) d + places[curr];
			}
			int sts = 0;
			forn(u,fin){
				sts = A[sts];	
			}
			cout<<sts+1<<endl;
			return;
		}
		else{
			ro.insert(curr);
			places[curr] = ++pl;
		}
	}
}
int main(){
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	solve();
	
	return 0;	
}

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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    long long i, j, k, n, m, t, x=0, y=0, z=0, s=0, w=0, c=0, l;
    cin >> n;
    while (n--)
    {
        string a;
        cin >> a;
        if(a[0]=='A')
            x++;
        else if(a[0]=='W')
            y++;
        else if(a[0]=='T')
            z++;
        else 
            w++;
    }
    cout << "AC x " << x << endl << "WA x " << y << endl << "TLE x " << z << endl << "RE x " << w << endl;
}


Measured memory_bytes: 3564
from itertools import product

n, a, b, c = map(int, input().split())
l = []
for i in range(n):
    l.append(int(input()))

def sum_ks(k_1, k_2, k_3):
    return abs(k_1-a) + abs(k_2-b) + abs(k_3-c)

min_ = 999999
for per in product([0, 1, 2, 3], repeat=n):
    if 1 in per and 2 in per and 3 in per:
        count = 0
        k_1 = 0
        k_2 = 0
        k_3 = 0
        for i in range(n):
            if per[i] == 0:
                count += 1
            if per[i] == 1:
                k_1 += l[i]
            if per[i] == 2:
                k_2 += l[i]
            if per[i] == 3:
                k_3 += l[i]
        cost = 10 * (n - 3 - count)
        min_ = min(min_, cost+sum_ks(k_1, k_2, k_3))
print(min_)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main() {
long long M, N;
cin >> N >> M;
if (2*N <=  M) {
long long  tmp = (M-(2*N));
tmp = tmp / 4;
cout << N + tmp << endl;
}
else {
cout << M/2 << endl;
}
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    int N;
    cin >> N;
    int prev = 0;
    int ans = 0;
    FOR(i, 1, N+1){
        int now = 0;
        int n = i;
        while(n % 2 == 0 && n != 1){
            n =  n/2;
            now++;
        }
        if(prev <= now){
            prev = now;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILL(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};




int main(){

  string s;
  cin >> s;
  sort(ALL(s));
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[3])cout << "Yes";
  else cout << "No";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdio.h>
#include <iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main()
{
    int x,y,z;
    scanf("%d",&x);
    scanf("%d",&y);
    
    if(x%y==0){
    	printf("-1");
    }
    else{
    	
    
    rep(i,y){
    	if((x*i)%y==0){
    		;
    	}else{
    		z=x*i;
    		break;
    	}
    }
    printf("%d",z);
    }
    
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

const double EPS = 1e-10;


int main() {
	int n;
	vs button(10, "");
	vi buttonnum(10, 0);

	button[0] = "";
	button[1] = ".,!? ";
	button[2] = "abc";
	button[3] = "def";
	button[4] = "ghi";
	button[5] = "jkl";
	button[6] = "mno";
	button[7] = "pqrs";
	button[8] = "tuv";
	button[9] = "wxyz";

	cin >> n;
		REP(k, n) {
			string input;
			cin >> input;
			string output = "";
			int size = input.size();
			int lastnum = 0;

			REP(i, size) {
				switch(input[i]) {
				case '0':
					if(lastnum) {
						output += button[lastnum][(buttonnum[lastnum]-1)%button[lastnum].size()];
						buttonnum[lastnum] = 0;
						lastnum = 0;
						break;
					}
				case '1':
				case '2':
				case '3':
				case '4':
				case '5':			
				case '6':			
				case '7':			
				case '8':			
				case '9':
					++buttonnum[input[i]-'0'];
					lastnum = input[i]-'0';
					break;
				}
			}

			cout << output << endl;
	
		
	}
}

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

int main(){
  long long N;
  cin >> N;
  long long mm = pow(10,12)+1;
  for(int i=1;i<=(int) sqrt(N);i++){
    if(N%i == 0){
      mm = min(mm, i-1 + N/i - 1);
    }
  }
  cout << mm << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int isPoor = 0;
    if (a == b && b != c) isPoor = 1;
    if (b == c && c != a) isPoor = 1;
    if (c == a && a != b) isPoor = 1;

    if (isPoor) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <cmath>

using namespace std;

int digit(long long n) {
	long long m = 10;
	for (int i = 0; i < 100; i++) {
		if (abs(n) / m < 1) {
			return i + 1;
			break;
		}
		m *= 10;
	}
}

int main() {
	long long N, F, F0;
	cin >> N;
	vector<long long> D;
	F = 100;
	for (long long i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			F0 = max(digit(i), digit(N / i));
			if (F0 < F) {
				F = F0;
			}
		}
	}

	cout << F << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = li()

for i in range(N):
    A[i] -= i + 1

A = sorted(A)

if not N % 2:
    num = int((A[N//2] + A[N//2-1]) // 2)
else:
    num = A[N//2]
ans = 0
for i in range(N):
    ans += abs(num - A[i])

print(ans)

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

int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if(b<c) cout << 0<<endl;
  else if(a>d) cout <<0 << endl;
  else cout << min(b,d)-max(a,c) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  bool ans = true;
  if( max(c,a)-min(c,a) > d){
    if( max(b,a)- min (b,a) > d){
      ans = false;
    }
    if(max(c,b)-min(c,b)>d){
        ans = false;
    }
  
  }
  if(ans){
    cout <<"Yes";
  }
  else{
    cout << "No";
  }
          
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >>c;
    string ans = "No";
    if(c>=a&&c<=b){
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
s = [0] * (n)
for i in range(n):
    s[i] = int(input())
dp = [[False for i in range(10010)] for j in range(n+5)]
dp[0][0] = True
for i in range(0, n):
    for j in range(0, 10010):
        if(dp[i][j]):
            dp[i+1][j] = True
            dp[i+1][j+s[i]] = True

ans = 0
for i in range(1, 10010):
    if(dp[n][i] and i % 10 != 0):
        ans = i
print(ans)

Measured memory_bytes: 11636
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
#include <cassert>
#include <random>

int main() {
	int n, k; std::cin >> n >> k;
	std::vector<long long int> numbers; numbers.reserve(n + 1); numbers.push_back(0);
	for (auto i = 0; i < n; ++i) {
		int a; std::cin >> a;
		numbers.push_back((numbers.back() + a) % k);
	}
	std::unordered_map<long long int, int> map;
	long long int result = 0;
	for (auto i = 0; i < numbers.size(); ++i) {
		if (i >= k) {
			auto v = ((numbers[i - k] - (i - k)) % k + k) % k;
			map[v]--;
		}
		auto val = ((numbers[i] - i) % k + k) % k;
		result += map[val]++;
	}
	std::cout << result << '\n';
}

Measured memory_bytes: 12796
#include<cstdio>
#include<iostream>
using namespace std;
const int MAXN=50+5;

int n,m;
int a[MAXN],b[MAXN],gra[MAXN][MAXN];

bool vis[MAXN];
void clean(){
	for(int i=1;i<=n;i++){
		vis[i]=0;
	}
}

void dfs(int x){
	vis[x]=1;
	for(int i=1;i<=n;i++){
		if(gra[x][i]==0||vis[i]==1)
			continue;
		dfs(i);
	}
}

int main()
{
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		scanf("%d %d",&a[i],&b[i]);
		gra[a[i]][b[i]]=gra[b[i]][a[i]]=1;
	}	
	int ans=0;
	for(int i=1;i<=m;i++){
		gra[a[i]][b[i]]=gra[b[i]][a[i]]=0;//删除这条边 
		
		clean();
		dfs(1);//遍历整个图 
		
		for(int j=1;j<=n;j++){//如果删除这条边之后图上有点没有被访问到，说明这条边是 桥 
			if(vis[j]==0){
				ans++;
				break;
			}
		}
		
		gra[a[i]][b[i]]=gra[b[i]][a[i]]=1;//还原这条边 
	}
	cout<<ans<<endl;
	return 0;
} 
	
	
	

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    VL a(n);
    REP(i,n)cin>>a[i];
    VL b = a;
    SORT(b);
    LL max1 = b[n-1];
    LL max2 = b[n-2];
    REP(i,n){
        PUTS(a[i] == max1 ? max2 : max1);
    }
}

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

const int mod = 1e9 + 7;
const int MN = 1010;

int exp(int x, int n) {
    int ret = 1;
    while(n) {
        if(n & 1) ret = 1LL * ret * x % mod;
        x = 1LL * x * x % mod;
        n >>= 1;
    }
    return ret;
}
int inv(int x) {
    return exp(x, mod - 2);
}
int comb[MN][MN], fact[MN], invf[MN];

int N, A, B, C, D;

int cc[MN][MN];
int dp(int m, int n) {
    if(m == B + 1) return n == 0;
    int &ret = cc[m][n];
    if(ret != -1) return ret;

    ret = dp(m + 1, n);
    int tmp = 1;
    for(int i = 1; i <= min(n / m, D); i++) {
        tmp = 1LL * tmp * comb[n - (i - 1) * m][m] % mod;
        if(i >= C) {
            ret += 1LL * tmp * invf[i] % mod * dp(m + 1, n - i * m) % mod;
            ret %= mod;
        }
    }
    return ret;
}

int main() {
    for(int i = 0; i < MN; i++) {
        comb[i][0] = 1;
        for(int j = 1; j <= i; j++) {
            comb[i][j] = (comb[i - 1][j - 1] + comb[i - 1][j]) % mod;
        }
    }
    fact[0] = 1;
    for(int i = 1; i < MN; i++) {
        fact[i] = 1LL * fact[i - 1] * i % mod;
    }
    for(int i = 0; i < MN; i++) {
        invf[i] = inv(fact[i]);
    }

    cin >> N >> A >> B >> C >> D;

    memset(cc, -1, sizeof(cc));
    cout << dp(A, N);
}


Measured memory_bytes: 8320
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int H,W;
	while(true){
		scanf("%d %d",&H,&W);
		if(H == 0 && W == 0) break;
		for(int i = 0; i < W; i++) printf("#");
		printf("\n");

		for(int i = 1; i < H-1; i++){
			printf("#");
			for(int j = 1; j < W-1; j++) printf(".");
			printf("#\n");
		}

		if(H > 1){
			for(int i = 0; i < W; i++) printf("#");
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2540
N, M = map(int, input().split())
 
l_list = []
r_list = []
for i in range(M):
  l, r = map(int, input().split())
  l_list.append(l)
  r_list.append(r)
  
l = max(l_list)
r = min(r_list)
 
if r < l:
  print(0)
else:
  print(r-l+1)

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

using namespace std;


multiset<int> s;

int main(){
	
	int N,L;
	scanf("%d%d", &N,&L);
	
	int arr[N];
	
	for(int i =0; i < N; i++) {
		
		scanf("%d", &arr[i]);
		if(i < L)
			s.insert(arr[i]);
	}
	
	
	for(int i = L; i <= N; i++){
		
		printf("%d", *s.begin());
		
		s.erase(s.find(arr[i-L]));
		
		s.insert(arr[i]);
		
		if(i < N) printf(" ");
	}
	
	printf("\n");
	return 0;
}



Measured memory_bytes: 11812
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i;
    cin >> n;
    for(i = 0; (1 << i) <= n; i++)
    {
        if((1 << i) == n)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    for(i = 2; i < n + n % 2; i += 2)
    {
        cout << "1 " << i << endl;
        cout << "1 " << n + i + 1 << endl;
        cout << i << ' ' << i + 1 << endl;
        cout << n + i + 1 << ' ' << n + i << endl;
    }
    cout << "3 " << n + 1 << endl;
    if(n % 2 == 0)
    {
        for(i = 2; i < n; i++)
        {
            ll val = (i ^ 1) ^ n;
            if(val < n)
            {
                cout << n << ' ' << (i % 2 == 0 ? i : n + i) << endl;
                cout << 2 * n << ' ' << (val % 2 == 0 ? val : n + val) << endl;
                break;
            }
        }
    }
    return 0;
}

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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.rbegin(), t.rend());
  if (s < t) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int n;
    cin >> n;
    multiset<int> ms;
    for(int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        ms.insert(a);
    }
    int h = *ms.rbegin();
    if(h % 2 == 0)
    {
        if(ms.count(h/2) != 1)
        {
            cout << "Impossible" << endl;
            return 0;
        }
        ms.erase(h/2);
        for(int i = h/2 + 1; i <= h; i++)
        {
            if(ms.count(i) < 2)
            {
                cout << "Impossible" << endl;
                return 0;
            }
            ms.erase(i);
        }
        if(ms.empty()) cout << "Possible" << endl;
        else cout << "Impossible" << endl;
    }
    else
    {
        if(ms.count(h/2+1) != 2)
        {
            cout << "Impossible" << endl;
            return 0;
        }
        ms.erase(h/2+1);
        for(int i = h/2 + 2; i <= h; i++)
        {
            if(ms.count(i) < 2)
            {
                cout << "Impossible" << endl;
                return 0;
            }
            ms.erase(i);
        }
        if(ms.empty()) cout << "Possible" << endl;
        else cout << "Impossible" << endl;
    }
}




Measured memory_bytes: 3616
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

// Created by White Knife on 15/04/20.
// doot diddly donger cuckerino Hahahahahah

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")


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

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

// @formatter:off
#define F               first
#define S               second
#define all(x)          (x).begin(), (x).end()
#define sz(x)           (long long) (x).size()
#define sim             template<typename T
#define ris             return *this
#define dor             > debug & operator <<
#define eni(x)          sim > typename enable_if<sizeof dud<T>(0) x 1, debug&>::type operator<<(T i)
sim> struct rge { T b, e; };
sim> rge<T> rang(T i, T j) { return rge<T>{i, j}; }
sim> auto dud(T *x) -> decltype(cerr << *x, 0);
sim> char dud(...);
struct debug {
#ifdef LOCAL
  ~debug() { cerr << endl; }
  eni(!=) { cerr << boolalpha << i; ris; }
  eni(==) { ris << rang(all(i)); }
  sim, typename U dor(pair<U, T> d) { ris << "(" << d.first << ", " << d.second << ")"; }
  sim dor(rge<T> d) { *this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]"; }
#else
  sim dor(const T&) { ris; }
#endif
};
#define pr(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ull = unsigned long long;
using ld = long double;
//using li = __int128;
//using uli = unsigned __int128;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vb = vector<bool>;

using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template<typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template<typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
template <typename T> T rand(T x, T y) { return rand() % (y - x + 1) + x; }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

// @formatter:on


class CRepsept {
public:
  
  void solveOne(istream& cin, ostream& cout) {
    int k;
    cin >> k;
    vector<bool> vis(k + 1, false);
    int x = 7 % k;
    int i = 1;
    while (x != 0) {
      x = (10 * x + 7) % k;
      i++;
      if (vis[x]) {
        cout << -1 << '\n';
        return;
      }
      vis[x] = true;
    }
    cout << i << '\n';
  }
  
  void solve(std::istream& cin, std::ostream& cout) {
    int t = 1;
    for (int tc = 1; tc <= t; ++tc) {
      //	cout << "Case #" << tc << ": ";
      solveOne(cin, cout);
    }
  }
};

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	CRepsept solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define ppb pop_back
#define INF 1e18
typedef long long ll;

using namespace std;

int main(int argc,char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n,m;
    cin >> n >> m;
    //    vector<int>a(n),b(m);
    vector<pair<ll, ll> > p;
    rep(i,n)
    {
        ll a,b;cin>>a>>b;
        p.pb(make_pair(a,b));
 //       cin>>a[i]>>b[i];
    }

    sort(all(p));

    ll sum = 0;
    int i = 0;
    while (m > 0 && i < n)
    {
        sum += p[i].first * min(m, p[i].second);
        m -= p[i].second;
        i++;
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 2420
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

x,y=MI()
if 2*x<=y<=4*x and y%2==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9480
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val b = sc.next.charAt(0)
  val result = if (b == 'A') {
    'T'
  } else if (b == 'T') {
    'A'
  } else if (b == 'C') {
    'G'
  } else if (b == 'G') {
    'C'
  }
  println(result)
}

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

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

    vector<int> hp;
    vector<int> wp;

    for(int i=0;i<n;i++){
        int sum=0;
        for(int j=i;j<n;j++){
            sum+=h[j];
            hp.push_back(sum);
        }
    }

    for(int i=0;i<m;i++){
        int sum=0;
        for(int j=i;j<m;j++){
            sum+=w[j];
            wp.push_back(sum);
        }
    }

    sort(hp.begin(),hp.end());
    sort(wp.begin(),wp.end());

    int res=0;

    for(int i=0;i<hp.size();i++){
        res+=distance(lower_bound(wp.begin(),wp.end(),hp[i]),upper_bound(wp.begin(),wp.end(),hp[i]));


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

}

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

using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset

typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;

#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'

char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
// end of Template

int f[120][20],n,p[120][20],depth[20],c;
priority_queue <int> ans;
void count_p(){
    int profit = 0;
    for(int i=1;i<=n;i++){
        int fr = 0;
        for(int j=1;j<=10;j++){
            if(f[i][j]==1 && depth[j]==1){fr++;}
        }
        profit += p[i][fr];
    }
    ans.push(profit);
}
void comb(int x){
    for(int i=0;i<=1;i++){
        depth[x] = i;
        if(x < 10)comb(x+1);
        else{
            if(c==0)c++;
            else{count_p();}
        }
    }
}
int main(){

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=10;j++)cin>>f[i][j];
    }
    for(int i=1;i<=n;i++){
        for(int j=0;j<=10;j++)cin>>p[i][j];
    }
    comb(1);
    cout<<ans.top()<<newl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 200005;

int n, k;
int a[N];

int b[N];

int q[N];

void solv()
{
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    for (int i = 1; i <= k; ++i)
    {
        for (int i = 1; i <= n; ++i)
            q[i] = 0;
        for (int i = 1; i <= n; ++i)
        {
            q[max(1, i - a[i])]++;
            q[min(n + 1, i + a[i] + 1)]--;
        }
        for (int i = 1; i <= n; ++i)
            q[i] += q[i - 1];
        for (int i = 1; i <= n; ++i)
            a[i] = q[i];
        bool z = true;
        for (int i = 1; i <= n; ++i)
        {
            if (a[i] != n)
            {
                z = false;
                break;
            }
        }
        if (z)
            break;
    }
    for (int i = 1; i <= n; ++i)
        printf("%d ", a[i]);
    printf("\n");
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    //ios_base::sync_with_stdio(false), cin.tie(0);
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 5400
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n) ;i++)

using namespace std;
using p=pair<int,int>;
typedef long long ll;
const ll mod = 1000000007;

int main(){
  string s;
  cin >> s;
  if(s[s.size()-1]!='s'){
    cout << s + 's' << endl;
  }
  else if(s[s.size()-1]=='s'){
    cout << s + "es" << endl;
  }
  
  
    
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int a, b, c, e, f = 1, g = 1;
	char d;
	cin >> a >> b >> c;
	for (int h = 1; h <= a; h++) {
		cin >> d;
		if (d == 'a') {
			if (f <= b + c) {
				cout << "Yes" << endl;
				f++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else if (d == 'b') {
			if (f <= b + c && g <= c) {
				cout << "Yes" << endl;
				f++;
				g++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			cout << "No" << endl;
		}
	}
	cin >> e;
}

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

int main(){
  int N;
  cin >> N;
  int count = 0;
  for (int i = 0; i < N; i++){
    for (int j = 0; j < N; j++){
      for (int k = 0; k < N; k++){
        count++;
      }
    }
  }
  
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
from itertools import accumulate

N, K = map(int, input().split())
A = list(map(int, input().split()))

A_acc = [0]+list(accumulate(A))
cand = []

for l in range(N):
    for r in range(l+1, N+1):
        cand.append(A_acc[r]-A_acc[l])
cand = sorted(cand)
ans = 0
for i in reversed(range(41)):
    k_candidates = []
    for c in cand:
        if c & (1 << i):
            k_candidates.append(c)
    if len(k_candidates) >= K:
        ans += 1 << i
        cand = k_candidates
print(ans)


Measured memory_bytes: 73724
package main

import "fmt"

func main() {
	// Code for B - Great Ocean View
	var N int
	fmt.Scanf("%d", &N)

	H := make([]int, N)
	var answer int
	var max int = 0
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &H[i])
		if max <= H[i] {
			answer++
			max = H[i]
		}
	}
	fmt.Println(answer)
}


Measured memory_bytes: 1836
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,l;
  cin >> n >> l;
  vector<string> s(n);
  for(int i=0;i<n;i++) cin >> s.at(i);
  sort(s.begin(),s.end());
  for(int j=0;j<n;j++) cout << s.at(j);
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
from sys import exit

def eratosthenes(n):
    '''
    n以下の整数の素数判定/列挙 (n > 1)
    O(NloglogN)
    '''
    for i in range(2, int(n**0.5) + 1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False

    return [i for i in range(n+1) if is_prime[i]]


def factorization(n):
    '''
    素因数分解
    O(√N)
    '''
    res = []
    m = 2
    while m ** 2 <= n:
        if n % m == 0:
            cnt = 0
            while n % m == 0:
                cnt += 1
                n //= m
            res.append([m, cnt])
        m += 1

    if n > 1:
        res.append([n, 1])

    return res


n = int(input())
a = list(map(int, input().split()))

is_prime = [True] * (10**6+1)
is_prime[0] = False
is_prime[1] = False
judge = [False] * (10**6+1)
l1 = eratosthenes(10**6)

flag1 = True
for v1 in a:
    for v2 in l1:
        if is_prime[v1]:
            if judge[v1]:
                flag1 = False
            else:
                judge[v1] = True
            break

        if v1 % v2 == 0:
            if judge[v2]:
                flag1 = False
            else:
                judge[v2] = True
            
            while v1 % v2 == 0:
                v1 //= v2
        
        if v1 == 1:
            break
        
if flag1:
    print('pairwise coprime')
    exit()

l2 = factorization(a[0])
for i, j in l2:
    flag2 = True
    for v in a:
        if v % i != 0:
            flag2 = False
            break
    if flag2:
        print('not coprime')
        exit()

print('setwise coprime')

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

int main() {
  	int N = 5;
 	int dat[N];
  	for (int i = 0; i < N; ++i) {
      cin >> dat[i];
    }
  	sort(dat, dat+N);
  	for (int i = 0; i < N; ++i) {
      if (i != dat[i]) {
        cout << i << '\n';
        return 0;
      }
    }
  	cout << 5 << '\n';
  	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <cstdio>
#include <cmath>
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
using namespace std;
int n,d;
int ldig[500],rdig[500],t[500];
double x,y,prex,prey,r,theta;
double lrad,rrad;
double rad,alpha;
double dir;
int main() {
  while(true){
    cin >> n >> d;
    if(n==0&&d==0) return 0;
    rep(i,n) cin >> ldig[i] >> rdig[i] >> t[i];
    x = 0;
    y = 0;
    dir = 0;
    rep(i,n){
      lrad = (double)ldig[i]*M_PI*(double)t[i]/180;
      rrad = (double)rdig[i]*M_PI*(double)t[i]/180;
      if(lrad==rrad){
        x += lrad*cos(M_PI/2-dir);
        y += lrad*sin(M_PI/2-dir);
        continue;
      }
      alpha = (lrad-rrad)/(double)(2*d);
      rad = rrad/alpha;
      prex = (double)(d+rad)*(1-cos(alpha));
      prey = (double)(d+rad)*sin(alpha);
      r = sqrt(prex*prex+prey*prey);
      theta = atan2(prey,prex);
      theta -= dir;
      x += r*cos(theta);
      y += r*sin(theta);
      dir += alpha;
    }
    printf("%.5f\n%.5f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 1280
import itertools

h, w, m = map(int,input().split(' '))
x = [0] * 300001
y = [0] * 300001
z = []
mx, my = 0, 0
for i in range(m):
    a, b = map(int,input().split(' '))
    x[a] += 1
    y[b] += 1
    mx = max(mx, x[a])
    my = max(my, y[b])
    z.append((a, b))
x1 = x.count(mx)
y1 = y.count(my)
z1 = x1 * y1
for i, j in z:
    if x[i] == mx and y[j] == my:
        z1 -= 1
if z1: print (mx + my)
else: print (mx + my - 1)

Measured memory_bytes: 54180
#include <iostream>

using namespace std;

int get_digit(int val)
{
    int res = 0;
    while (val > 0) {
	val /= 10;
	res++;
    }
    return res;
}

int main()
{
    int a, b;
    while (cin >> a >> b) {
	int sum = a + b;
	cout << get_digit(sum) << endl;
    }
    return 0;
}

Measured memory_bytes: 3120
# そのまま入力文字列の入力
n = int(input())

# 空白区切りの数値をリスト化
an = list(map(int, input().split()))

ans = 0

target = 1
has_ans = False
for i in range(0, n):
    if an[i] == target:
        has_ans = True
        target += 1
    else:
        ans += 1

print(ans if has_ans else "-1")

Measured memory_bytes: 24872