akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    long int allsum = 0;
    long int sum3 = 0;
    long int sum5 = 0;
    long int sum15 = 0;
    int n3 = n / 3;
    int n5 = n / 5;
    int n15 = n / 15;
    int i = 0;
    int j = 0;
    int k = 0;
    int l = 0;
    while (i <= n){
        allsum = allsum + i;
        i++;
    }
    while (j <= n3){
        sum3 = sum3 + j * 3;
        j++;
    }
    while (k <= n5){
        sum5 = sum5 + k * 5;
        k++;
    }
    while (l <= n15){
        sum15 = sum15 + l * 15;
        l++;
    }
    cout << allsum - sum3 - sum5 + sum15 << endl;
    return 0;
}

Measured memory_bytes: 3632
N = int(input())
info = []
for k in range(N):
    s, p = input().split()
    info.append([k, s, int(p)])

info = sorted(info, key=lambda x: x[2], reverse=True)
info = sorted(info, key=lambda x: x[1])
#ソートの優先度が市名→評価順となっているので、評価でソートした後、市名でソートする。
#sorted(【リストor辞書】, key=lambda x: 【keyにしたい要素】)
for i in range(N):
    print(info[i][0]+1)

Measured memory_bytes: 38512
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define lla(s) s.rbegin(),s.rend()
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m,sum=0;
    cin>>n>>m;
    vector<int>a(n);
    rep(i,0,n){
        cin>>a[i];
        sum+=a[i];
    }
    sort(lla(a));
    cout<<(sum<=4*m*a[m-1]?"Yes":"No")<<endl;
}

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

vector<int> divisor(int n){
 vector<int> res;
 for(int i=1;i*i<=n;i++){
 if(n%i==0){
 res.push_back(i);
 if(i*i!=n)res.push_back(n/i);
 }
 }
 return res;
}

int check(int x){
	int i,ans=0;
	vector<int> res = divisor(x*2);
	sort(res.begin(), res.end(), greater<int>());
	for(i=0;i<(int)res.size();i++){
		if(res[i]%2==0 && (x%res[i])==0) continue;
		if(res[i]%2 && (x%res[i])) continue;
		double n = res[i];
		double m = (double)x / n;
		if(m-(n-1)/2 < 1) continue;
		ans ++;
	}
	return ans-1;
}

main(){
	int i,j;
	int n;
	while(cin >> n, n){
		cout << check(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 1216
#include <cstdio>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

map<long long, long long> res;
int p[3] = { 2, 3, 5 }, c[3], d;

long long go(long long n)
{
	auto I = res.find(n);
	if (I != res.end()) return I->second;
	auto& r = res[n];

	r = 9e18;
	if (9e18 / d >= n) r = d * n;

	for (int k = 0; k < 3; k++){
		long long np = n / p[k];
		long long nq = (n + p[k] - 1) / p[k];
		r = min(r, go(np) + (n % p[k]) * d + (np ? c[k] : 0));
		if (nq < n){
			r = min(r, go(nq) + (p[k] - (n % p[k])) * d + c[k]);
		}
	}
	return r;
}
int main()
{
	int T; scanf ("%d", &T); while (T--){
		long long n; scanf ("%lld %d %d %d %d", &n, c, c + 1, c + 2, &d);
		res.clear();
		priority_queue<pair<long long, long long> > Q;
		Q.push({ 0,0 }); res[0] = 0;
		while (!Q.empty()){
			long long n = -Q.top().first, x = Q.top().second, r = res[x]; Q.pop();
			if (r < n) continue;
			for (int k = 0; k < 3; k++){
				long long u = x * p[k];
				long long v = r + c[k];
				if (u < -100 || u > 100) continue;
				if (!res.count(u) || res[u] > v){
					Q.push({ -v,u }); res[u] = v;
				}
			}
			for (int p = -1; p <= 1; p += 2){
				long long u = x + p;
				long long v = r + d;
				if (u < -100 || u > 100) continue;
				if (!res.count(u) || res[u] > v){
					Q.push({ -v,u }); res[u] = v;
				}
			}
		}
		printf ("%lld\n", go(n));
	}
	return 0;
}

Measured memory_bytes: 4124
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

#define MAX 2000000
#define N 2000000001

int T[MAX];

int n=0;

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}

void heapIncreaseKey(i, key){
  int x;
  if(key < T[i]) printf("new kry is smaller than current key");
  T[i] = key;
  while( i > 1 && T[parent(i)] < T[i]){
    x = T[i];
    T[i] = T[parent(i)];
    T[parent(i)] = x;
    i = parent(i);
  }
}

void maxHeapInsert(key){
  n++;
  T[n] = INT_MIN;
  heapIncreaseKey(n, key);
}

void maxHeapify(int i){
  int h, l, r, largest;
  l = left(i);
  r = right(i);
  if(l <= n && T[l] > T[i]) largest = l;
  else largest = i;
  if(r <= n && T[r] > T[largest]) largest = r;
  if(largest != i){
    h = T[i];
    T[i] = T[largest];
    T[largest] = h;
    maxHeapify(largest);
  }
}

int heapExtractMax(void){
  int max;
  if(n < 1) printf("heap underflow");;
  max = T[1];
  T[1] = T[n];
  n--;
  maxHeapify(1);
  return max;
}

void buildMaxHeap(){
  int i;
  for(i=n/2; i>0; i--) maxHeapify(i);
}

int main(){
  int i=1, k=0, j;
  char com[10];
  int p[MAX];

  while(1){
    scanf("%s", com);
    if(com[2] == 's'){
      scanf("%d", &T[i]);
      maxHeapInsert(T[i]);
      i++;
    }
    else if(com[2] == 't'){
      p[k] = heapExtractMax();
      k++;
    }
    else if(com[2] == 'd'){
      for(i=0; i<k; i++) printf("%d\n",p[i]);
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;

void printvec(vector<long> v) {
    REP(i,v.size()-1) {
        cout << v[i] << " ";
    }
    cout << v.back() << endl;
}

int main() {
    int n;
    long a;
    vector<long> as;
    cin >> n;
    REP(i,n) {
        cin >> a;
        as.push_back(a);
    }
    
    vector<long> ans;
    
    for (int i = n - 1; i >= 0; i-=2) {
        ans.push_back(as[i]);
    }
    for (int i = n % 2; i < n; i+=2) {
        ans.push_back(as[i]);
    }
    
    printvec(ans);
}


Measured memory_bytes: 7024
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long int ld;
typedef unsigned long long int lu;
typedef vector< int > vi;
typedef vector < ld > vd;
typedef set <ld> sd;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef pair< int,int > ii;
typedef pair< ld,ld > id;
#define sz(a) ld((a).size())
#define test(t) ll t;cin>>t;while(t--)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Vi vector
#define pr pair
#define mpr make_pair
#define fi first
#define se second
#define isnum(a) (a>=48 && a<=57)
#define isS(a) (a>='a' && a<='z')
#define isU(a) (a>='A' && a<='Z')
#define toS(a) (isU(a)?a+32:a)
#define toU(a) (isS(a)?a-32:a)
#define toC(a) a&15

set <ld> s[100005];
ld d[100005];

vector<char> prime (100000+1, true);
void sieve(ld n)
{	
	//O(nloglogn) time
	prime[0] = prime[1] = false;
	for (ld i=2; i<=n; ++i)
	{
		if (prime[i])
		{
			s[i].insert(i);			
			for (ld j=2*i; j<=n; j+=i)
			{
				prime[j] = false;
				s[j].insert(i);
			}
		}
	}
}
#define forn(i,e) for(int i = 0; i < e; i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define reprev(i,a,b) for(i=a;i>=b;i--)

#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
ld gcd(ld a, ld b) { if(b == 0) return a; return gcd(b, a % b); }
ld fastpowMOD(ld a, ld p,ld MOD){ if(p==0) return 1; ld z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
ld fastpow(ld a, ld p){ if(p==0) return 1; ld z = fastpow(a,p/2); z = (z*z); if(p%2) z = (z*a); return z; }
ld a,b;

ld search1(ld a[], ld f,ld n)
{
	ld left=1;
	ld right=n+1;
	while(right-left>1)
	{
		ld mid = left + (right-left)/2;
		if(a[mid]<f)
		{
			left=mid;
		}
		else right=mid;
	}
	return a[left];
}
ld  p = 1e9+7;
ld dp[3000000];

int main(){
	ld n,d;
	cin >> n;
	ld ar[n][n];
	ld i,j,k;
	rep(i,0,n)
	{
		rep(j,0,n)
		{
			scanf("%lld",&ar[i][j]);
		}
	}
	
	memset(dp,0,sizeof(dp));
	dp[0]=1;
	rep(i,0,(1<<n)-1)
	{
		ld a = __builtin_popcount(i);
		rep(j,0,n)
		{
			if(!(i&(1<<j)) && ar[a][j])
			{
				dp[i|(1<<j)] = (dp[i|(1<<j)]+dp[i])%p;
			}
		}
	}
	cout << dp[(1<<n)-1] << endl;
	return 0;
}

Measured memory_bytes: 29820
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        if(input.charAt(0) == input.charAt(2)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int

using namespace std;

signed main()
{
	int n, ans = 0;
	cin >> n;
	int a[n];

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

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

	cout << ans;

	return 0;
}

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

using namespace std;

int main() {
    long n;
    cin >> n;

    vector<long> a(n);
    for(auto &x: a) cin >> x;

    long prev = -1;
    for(int i=0; i<n; i++) {
        if(a[i] > prev) a[i]--;
        if(prev > a[i]) {
            cout << "No" << endl;
            return 0;
        }
        prev = a[i];
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1024
n=int(input())
a=list(map(int,input().split()))

ans='No'
from collections import Counter

c=Counter(a)
keys = list(c.keys())
values =list(c.values())

if keys==[0]:
    ans='Yes'
elif len(keys)==3 and values[0]==n/3 and values[1]==n/3 and keys[0]^keys[1]==keys[2]:
    ans='Yes'
elif len(keys)==2 and c[0]==n/3:
    ans='Yes'

print(ans)

Measured memory_bytes: 14116
type t = { v : int; w : int }

let () =
  let (n, w) = Scanf.scanf "%d %d " (fun n w -> n, w) in
  let z = (100*n + 1) in
  let dp = Array.make z (w + 1) in
  dp.(0) <- 0;
  for _ = 0 to n - 1 do
    let a = Scanf.scanf "%d %d " (fun v w -> { v; w }) in
    for j = z - 1 downto a.v do
      if dp.(j - a.v) + a.w < dp.(j) then dp.(j) <- dp.(j - a.v) + a.w
    done
  done;
  let rec print i =
    if i < 0 then assert false
    else if dp.(i) <= w then Printf.printf "%d\n" i
    else print (i - 1) in
  print (z - 1)

Measured memory_bytes: 2492
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();

		int ans = 1;
		int hmax = sc.nextInt();

		for (int i = 2; i <= N; i++) {
			int h = sc.nextInt();
			if (hmax <= h) {
				ans++;
				hmax = h;
			}
		}
		out.println(ans);
		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


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

long long X;

int main()
{
    scanf("%lld",&X);
    for(int i = 0; i < 10000000000; i++)
    {
        if(i * (i + 1) / 2 >= X){printf("%d\n",i);return 0;}
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();

int main() {
    int n, a, b;
    cin >> n;
    if (n == 1)
        cout << "Hello World" << endl;
    else {
        cin >> a >> b;
        cout << a + b << endl;
    }
    return 0;
}



Measured memory_bytes: 256
a,b = map(int,input().split())

a1 = 0
b1 = 0
l = []
if a % 2 != 0:
   a1 = 1
if b % 2 == 0:
   b1 = 1
if a1 == 1:
   l.append(a)
one = b - a + 1 - a1 -b1
if one // 2 % 2 == 0:
   l.append(0)
if one // 2 % 2 == 1:
   l.append(1)
if b1 == 1:
   l.append(b)

if len(l) == 1:
   print(l[0])
if len(l) == 2:
   print(l[0]^l[1])
if len(l) == 3:
   print(l[0]^l[1]^l[2])






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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int a,b,c;
    cin >> a >>b>>c;
    int ans=0; // 最初に一枚は必ず食べれる

    if(c>b){
        ans += 2*b;
        c-=b;
    }else{
        cout<<b+c<<endl;
        return 0;
    }

    if(c>a){
        ans +=a+1;
    }else{
        ans+=c;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3572
//cod2016_qualA_b.cpp
//Sat Nov 10 18:45:48 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;

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

	int ans = 0;
	for (int i=0;i<n;i++){
		if (i == a[a[i]]){
			ans++;
		}
	}

	cout << ans/2 << endl;
}

Measured memory_bytes: 640
/****************************************************************************************************
                                        SUBMITTED BY-

                                                AISH_07

****************************************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define ll long long
#define sl set<ll>
#define vs vector<string>
#define pb push_back
#define vl vector<ll>
#define vi vector<int>
#define PI  3.14159265
#define mod 998244353
ll a[51];
ll p[51];
ll f(ll n,ll x)
{
    if(x==0)
        return 0;
    else if(n==0)
        return 1;
    else if(x<=1+a[n-1])
        return f(n-1,x-1);
    else
        return p[n-1]+1+f(n-1,x-a[n-1]-2);
}
int main()
{
 ll n,x;
 cin>>n>>x;
 a[0]=1;
 a[1]=5;
 p[0]=1;
 p[1]=3;

 for(int i=2;i<=n;i++)
 {
     a[i]=2*a[i-1]+3;
     p[i]=2*p[i-1]+1;
 }
 cout<<f(n,x)<<"\n";

return 0;
}


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

using namespace std;

//typedef pair<int,int> P;
typedef long long ll; 

#define int ll


main(){
	int num[100]={0};

	int k,n;
	cin >> k >> n;
	
	int a[2*n];
	for(int i=0;i<n;i++) cin >> a[i];
	
	for(int i=0;i<n;i++) a[i+n] = a[i]+k;

	int ans = 1e9;
	for(int i=0;i<n;i++){
		ans = min(ans,a[i+n-1]-a[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = in.nextLongArray(n);
			Arrays.sort(a);
			Map<Long,Integer> map = new HashMap<>();
			for (long i : a) {
				map.merge(i, 1, Integer::sum);
			}

			long len1 = 0, len2 = 0;
			boolean isSquere = true;
			boolean isFirst = true;

			for (int i = a.length-1; i >= 0; i--) {
				int count = map.get(a[i]);
				if (count >= 2) {
					if (count >= 4 && isSquere) {
						out.println(a[i]*a[i]);
						return;
					}
					isSquere = false;
					if (isFirst) {
						len1 = a[i];
						isFirst = false;
					} else if (a[i] < len1) {
						len2 = a[i];
						break;
					}
				}
			}
			out.println(len1 * len2);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}
}


Measured memory_bytes: 45492
#include<stdio.h>
int main()
{
    int W, H, N;
	int x[100];
	int y[100];
	int a[100];
	int i;
    scanf("%d %d %d", &W, &H, &N);
	for (i = 0; i < N; i++) {
		scanf("%d %d %d", &x[i], &y[i], &a[i]);
	}
	int maxx1 = 0;
	int minx2 = W;
	int maxy3 = 0;
	int miny4 = H;
	for (i = 0; i < N; i++) {
		if (a[i] == 1) {
			if (x[i] > maxx1) maxx1 = x[i];
		} else if (a[i] == 2) {
			if (x[i] < minx2) minx2 = x[i];
		} else if (a[i] == 3) {
			if (y[i] > maxy3) maxy3 = y[i];
		} else {
			if (y[i] < miny4) miny4 = y[i];
		}
	}
	if ( (minx2 - maxx1) < 0 || (miny4 - maxy3) < 0) {
		printf("0");
	}
	else printf("%d", (minx2 - maxx1) * (miny4 - maxy3));
	
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int main(){
	static int n;
	static int a[200010];
	static bool b[200010];
	scanf("%d",&n);
	rep1(i,2*n-1)scanf("%d",&a[i]);
	
	int l = 2 , r = 2*n-2 ;
	while(l<r){
		int m = (l+r)/2;
		rep1(i,2*n-1){
			b[i] = a[i] <= m;
		}
		int x,y;
		x = n-1;
		while(x >= 1 && b[x] != b[x+1])x --;
		y = n+1;
		while(y <= 2*n-1 && b[y] != b[y-1])y ++;
		if(x == 0 && y == 2*n){
			if(b[1])r = m;
			else l = m+1;
		}
		else {
			if(n-x > y-n)swap(x,y);
			if(b[x])r = m;
			else l = m+1;
		}
	}
	cout << l << endl;
}



Measured memory_bytes: 1280
#include<iostream> 
#include<vector> 
#include<string> 
#include<algorithm> 
using namespace std; 
int main()
{
	int a, b, c; 
	cin >> a >> b >> c; 
	int d = 0; 
	for (int i = 1; i < b; i++)
	{
		if (a*i%b == c)
		{
			d = 1; 
			break; 
		}
	} 
	if (d==1) 
	{
		cout << "YES" << endl; 

	} 
	else
	{
		cout << "NO" << endl;
	}

}

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

typedef long long ll;
typedef pair<ll, ll> i_i;
typedef pair<ll, ll> l_l;
 
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

struct UnionFind {
    // 根を保存する（根のみ負値で木の大きさが保存される）
    vector<ll> Parent;
 
    // 要素数Nで初期化
    UnionFind(ll N) { Parent = vector<ll>(N, -1); }

    // 根を求める
    ll root(ll A) {
        if (Parent[A] < 0) return A;
        else return Parent[A] = root(Parent[A]);
    }

    // 属する木の大きさ
    ll size(ll A) { return -Parent[root(A)]; }
 
    // 統合
    void unite(ll A, ll B) {
        A = root(A);
        B = root(B);
        if (A == B) return;
 
        if (size(A) < size(B)) swap(A, B);
 
        Parent[A] += Parent[B];
        Parent[B] = A;
    }
 
    // 同値類判定
    bool same(ll A, ll B) { return root(A) == root(B); }
};

int main() {
    ll n,m;
    
    cin >> n >> m;
    ll ans_r[m];
    ll a[m],b[m];
    const ll c = n*(n-1)/2;

    for (ll i=0;i<m;i++) {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
    }
    reverse(a,a+m);
    reverse(b,b+m);

    UnionFind vil(n);
    ll upd = 0;
    for (ll i=0;i<m;i++) {
        if (vil.root(a[i]) != vil.root(b[i])) upd += vil.size(a[i])*vil.size(b[i]);
        ans_r[i] = c - upd;
        vil.unite(a[i],b[i]);
    }

    reverse(ans_r,ans_r+m);
    for (ll i=1;i<m;i++) {
        cout << ans_r[i] << endl;
    }
    cout << c << endl;
}


Measured memory_bytes: 4480
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(h:usize w:usize){h;list:[i64]});
    let mut res = Vec::new();
    let mut list = list;
    for i in 0..h {
        for j in 0..w {
            if j != w - 1 {
                //奇数なら右側に移動
                if list[i][j] % 2 != 0 {
                    list[i][j] -= 1;
                    list[i][j + 1] += 1;
                    res.push((i, j, i, j + 1));
                }
            } else {
                if i != h - 1 {
                    //奇数なら下に移動
                    if list[i][j] % 2 != 0 {
                        list[i][j] -= 1;
                        list[i + 1][j] += 1;
                        res.push((i, j, i + 1, j));
                    }
                }
            }
        }
    }
    let n = res.len();
    let res = res
        .into_iter()
        .map(|(a, b, c, d)| format!("{} {} {} {}\n", a + 1, b + 1, c + 1, d + 1))
        .collect::<String>();
    format!("{}\n{}", n, res).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "2 3\n1 2 3\n0 1 1" => "3\n2 2 2 3\n1 1 1 2\n1 3 1 2",
    test2: "3 2\n1 0\n2 1\n1 0" => "3\n1 1 1 2\n1 2 2 2\n3 1 3 2",
    test3: "1 5\n9 9 9 9 9" => "2\n1 1 1 2\n1 3 1 4",
}


Measured memory_bytes: 14576
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	ll a,b;
	cin>>a>>b;

	if(a*b<=0) print("Zero");
	else{
		if(a>0) print("Positive");
		else{
			if((-a+b+1)%2) print("Negative");
			else print("Positive");
		}
	}
	return 0;

}


Measured memory_bytes: 256
import java.util.*;
 
class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
      int b = sc.nextInt();
		
	    
	        if(a == b) {
	        	System.out.println("Yes");
	        } else {
              System.out.println("No");
            }
	  
 
 
 
		sc.close();
	}
}

Measured memory_bytes: 21844
n,t[999];int main(i){
	for(;n*=scanf("%d",&n);puts("")){
memset(t,0,999*4);
	for(;n--;t[i]=*t)scanf(" %c %c",&i,t);
	for(scanf("%d",&n);n--;putchar(!t[i]*i+t[i]))scanf(" %c",&i);
	}
return 0;
}

Measured memory_bytes: 592
#include <cstdio>
#include <cstring>
int main() {
	int a,b,count[100]={0};
	while(scanf("%d %d",&a,&b)!=EOF) {
		if(a==0 && b==0) {
			if(!(count[0]&1)&&!(count[1]&1)) {printf("NG\n");continue;}
			bool OK=true;
			for(int i=2;i<100;i++) {
				OK&=!(count[i]&1);
			}
			printf("%s\n",OK?"OK":"NG");
			memset(count,0,sizeof(count));
		}else {
			count[a-1]++,count[b-1]++;
		}
	}
}

Measured memory_bytes: 1012
/**
 *      ABC 100 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/22
**/

#include <bits/stdc++.h>
using namespace std;

int main(){
    int D, N;
    cin >> D >> N;

    if (D == 0){
        if (N == 100){
            cout << 101;
        }
        else {
            cout << N;
        }
    }
    else if (D == 1){
        if (N == 100){
            cout << 10100;
        }
        else {
            cout << 100 * N;
        }
    }
    else {
        if (N == 100){
            cout << 1010000;
        }
        else {
            cout << 10000 * N;
        }
    }
    
    return 0;
}


Measured memory_bytes: 256
N = int(input())
us = []
vs = []
ws = []

for i in range(N-1):
    u,v,w = map(int, input().strip().split(" "))
    us.append(u)
    vs.append(v)
    ws.append(w)

class Node:
    def __init__(self, i):
        self.id = i
        self.friends = []
        self.color = -1
nodes = [Node(i) for i in range(N+1)]
nodes[0] = None
for u,v,w in zip(us, vs, ws):
    nodes[u].friends.append((v,w))
    nodes[v].friends.append((u,w))

nodes[1].color = 0

stack = [(1,-1)]
while len(stack):
    node_id, parent_id = stack.pop()
    node = nodes[node_id]
    node_color = node.color
    children = [(f,w) for f,w in node.friends if f != parent_id]
    for child_id, w in children:
        child_node = nodes[child_id]
        child_node.color = (node_color + w) % 2
        stack.append((child_id, node_id))

for n in nodes[1:]:
    print(n.color)


Measured memory_bytes: 60916
#include <iostream>
#include <algorithm>

#define INF 0x3fffffff

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

using namespace std;

int main(){
	int n, m, c, s, g;
	while(cin>>n>>m>>c>>s>>g, n|m|c|s|g){
		int x, y, d, cm, p[25];
		int w[25][105][105];
		int road[105][105];
		fill(w[0][0], w[0][0]+25*105*105, INF);
		fill(road[0], road[0]+105*105, INF);
		for(int i=0; i<m; i++){
			cin >> x >> y >> d >> cm;
			w[cm-1][x][y] = min( w[cm-1][x][y], d);
			w[cm-1][y][x] = min( w[cm-1][y][x], d);
		}
		// ???????????£???????????????
		REP(l, c) REP(k, n+1) REP(i, n+1) REP(j, n+1){
			w[l][i][j] = min(w[l][i][j], w[l][i][k] + w[l][k][j]);
		}
		// ??????
		REP(i, c) cin >> p[i];
		REP(i, c){
			int q[50]={0}, r[50];
			REP(j, p[i]-1) cin >> q[j+1];
			REP(j, p[i]) cin >> r[j];
			int now=0, rlas=r[p[i]-1], cha[10000]={0};
//			cout << "?¨????" << endl;
			REP(j, 10000){
				if( now+1 < p[i] && j >= q[now+1] ){
					now++;
				}
				cha[j+1] = cha[j] + r[now];
			}
			REP(j, n+1) REP(k, j){
				int len = w[i][j][k];
				if( len == INF ) continue;
				int sum = (len>10000)?(cha[10000]+rlas*(len-10000)):(cha[len]);
				road[j][k] = min(road[j][k], sum);
				road[k][j] = min(road[k][j], sum);
			}
		}
		// ???????????£???????????????
		REP(k, n+1) REP(i, n+1) REP(j, n+1){
			road[i][j] = min(road[i][j], road[i][k] + road[k][j]);
//			road[j][i] = min(road[j][i], road[i][k] + road[k][j]);
		}
		// ??????
		if( road[s][g] >= INF )
			cout << -1 << endl;
		else
			cout << road[s][g] << endl;
	}
	return 0;
}

Measured memory_bytes: 2324
// {{{
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
// }}}

using ll = long long;

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

int INF = 1 << 28;

struct state {
    char ch;
    int x, y, cost;
    state() {}
    state(char ch, int x, int y, int cost): ch(ch), x(x), y(y), cost(cost) {}
};

int H, W;
char S, T;
string G[50];

int sx, sy, gx, gy;

int main() {
    cin >> H >> W >> S >> T;
    for (int j = 0; j < H; ++j) {
        cin >> G[j];
    }

    for (int j = 0; j < H; ++j) {
        for (int k = 0; k < W; ++k) {
            if (G[j][k] == S) {
                sx = j; sy = k;
            }
            if (G[j][k] == T) {
                gx = j; gy = k;
            }
        }
    }

    queue<state> que;
    que.emplace(S, sx, sy, 0);

    int ans[26]; fill(ans, ans+26, INF);
    ans[S-'A'] = 0;

    while (!que.empty()) {
        state st = que.front(); que.pop();

        for (int d = 0; d < 4; ++d) {
            int nx = st.x + 2*dx[d], ny = st.y + 2*dy[d];
            if (nx < 0 || H <= nx || ny < 0 || W <= ny) { continue; }
            if ((d % 2 == 0 && G[nx][ny] == '|') || (d % 2 == 1 && G[nx][ny] == '-')) {
                while (!('A' <= G[nx][ny] && G[nx][ny] <= 'Z')) {
                    nx += dx[d];  ny += dy[d];
                }

                char nch = G[nx][ny];

                if (st.cost + 1 < ans[nch - 'A']) {
                    ans[nch - 'A'] = st.cost + 1;
                    que.emplace(nch, nx, ny, ans[nch-'A']);
                }
            }
        }
    }

    cout << ans[T-'A'] << endl;

    return 0;
}



Measured memory_bytes: 3204
import java.util.Scanner;
import java.util.Map;
import java.util.HashMap;

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

        Map<String, Integer> s = new HashMap<>();
        for(int i=0; i<n; i++) {
            String str = sc.nextLine();
            if(s.containsKey(str)) {
                s.put(str, s.get(str)+1);
            } else {
                s.put(str, 1);
            }
        }

        int m = sc.nextInt();
        sc.nextLine();

        Map<String, Integer> t = new HashMap<>();
        for(int i=0; i<m; i++) {
            String str = sc.nextLine();
            if(t.containsKey(str)) {
                t.put(str, t.get(str)+1);
            } else {
                t.put(str, 1);
            }
        }
        sc.close();

        int tmpAns = 0;
        int ans = 0;
        for(String str: s.keySet()) {
            if(!t.containsKey(str)) {
                tmpAns = s.get(str);
            } else {
                tmpAns = s.get(str) - t.get(str);
            }
            if(ans < tmpAns) {
                ans = tmpAns;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21588
import sys
from string import digits

k = int(sys.stdin.readline().rstrip())

def main():
    r = k
    if r <= 9:
        print(digits[r])
        return
    res = list(digits[1:])
    r -= 9
    d = set(digits)
    while True:
        nex = []
        for n in res:
            o = ord(n[-1])
            for i in range(-1, 2):
                tail = chr(o+i)
                if tail in d:
                    nex.append(n+tail)
                    r -= 1
                    if r == 0:
                        print(nex[-1])
                        return
        res = nex.copy()    

if __name__ ==  '__main__':
    main()

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

class CExceptionHandling {
public:
	void solve(std::istream& cin, std::ostream& cout) {
	    int N;
        cin >> N;
        vector<int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }
        vector<int> s;
        s = A;
        sort(s.begin(),s.end());
        for (int i = 0; i < N; ++i) {
            if(A[i]==s[s.size()-1]){
                cout << s[s.size()-2]<<endl;
            }else{
                cout << s[s.size()-1]<<endl;
            }
        }
	}
};


int main() {
	CExceptionHandling solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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


int main() {
	int N, fN, firstN;
    cin >> N;
 	firstN = N;
     
  	while(N>0){
      fN += N % 10;
      
 	  N = floor(N / 10 );        
   }
  
  if((firstN % fN) == 0){
    cout << "Yes" << endl;
  }else{
  	cout << "No" << endl;
  }
  
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long 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 forr(i,a,b) for(ll i=(a);i<=(b);i++)
#define ford(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define size(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)



int main(void) {
    int N,i,j;
    cin >> N;
    int n[201510];
    int m[201510];
    for(i=0;i<N-1;++i){
       cin >> n[i];
      
    }
     for(i=0;i<N-1;++i){
     
       m[n[i]-1]++;
    }
    for (j=0;j<N;++j){
        
         cout << m[j] << "\n";
    

    }   
    
  return 0;
}

Measured memory_bytes: 5200
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k % 2 == 0) {
		cout << a - b << "\n";
	}
	else {
		cout << b - a << "\n";
	}
	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define int long long
#define F(i,L,R) for(int i=L;i<R;++i)
#define FE(i,L,R) for(int i=L;i<=R;++i)
#define getI(a) scanf("%lld",&a)
#define getII(a,b) scanf("%lld%lld",&a,&b)
#define getIII(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define VgetI(n) int (n); scanf("%lld",&(n))
#define VgetII(n,m) int (n),(m); scanf("%lld%lld",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%lld%lld%lld",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define INF 2000000000
main(){
	int a,b,c;
	while(~getIII(a,b,c)){
		VgetI(k);
		int ans=0;
		ans+=min(a,k);
		k-=ans;
		k-=b;
		if(k>0) ans-=min(k,c);
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 3828
function move(yx){
   var arr=[];
   for(var y=0;y<8;y++)arr[y]=[];
   for(var y=0;y<8;y++){
      for(var x=0;x<8;x++){
         arr[y][x]=yx[7-x][y];
      }
   }
   return arr;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var yx=[];
for(var i=0;i<8;i++)yx.push(Arr[i].split(""));
yx=move(yx);
console.log("90\n"+yx.join("\n").replace(/\,/g,""));
yx=move(yx);
console.log("180\n"+yx.join("\n").replace(/\,/g,""));
yx=move(yx);
console.log("270\n"+yx.join("\n").replace(/\,/g,""));

Measured memory_bytes: 7640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007



n, m = LI()
G = [[] for _ in range(n)]
for a, b, c in LIR(m):
    G[a - 1] += [(b - 1, c)]

# 負の閉路がなかったら高々n-1回で更新は終わるはずn回目に更新が起こったとしたら負の閉路がある。
def bellman_ford(G, s=0):
    n = len(G)
    dist = [-INF] * n
    dist[s] = 0
    v_nows = {s}
    for _ in range(n):
        v_changeds = set()
        for u in v_nows:
            for v, c in G[u]:
                if dist[u] + c > dist[v]:
                    dist[v] = dist[u] + c
                    v_changeds.add(v)
        v_nows = v_changeds
    if not v_changeds:
        return dist[n - 1]
    for i in v_nows:
        dist[i] = INF
    dq = deque(v_nows)
    while dq:
        u = dq.popleft()
        if u == n - 1:
            return "inf"
        for v, c in G[u]:
            if v == n - 1:
                return 'inf'
            if dist[v] != INF:
                dist[v] = INF
                dq += [v]
    return dist[n - 1]



print(bellman_ford(G))



Measured memory_bytes: 84144
string=['a','b','c','d','e','f','g','h','i','j']
N=int(input())
res=[]
def dfs(ss):
  if len(ss)==N:
    ss=''.join(ss)
    res.append(ss)
  else:
    for i in range(string.index(max(ss))+2):
      a=ss+[string[i]]
      dfs(a)
  return res
ans=dfs(['a'])
for i in range(len(ans)):
  print(ans[i])

Measured memory_bytes: 64988
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

int N;

bool comp(pair<string,int> p,pair<string,int> q){
    if(p.first!=q.first) return p.first<q.first;
    else return p.second>q.second;
}

vector<pair<string,int>> v;
map<pair<string,int>,int> m;

int main(){
    cin >> N;
    string S;
    int P;
    for(int i=1;i<=N;i++){
        cin >> S >> P;
        v.push_back({S,P});
        m[{S,P}] = i;
    }
    sort(v.begin(),v.end(),comp);
    for(auto x:v) cout << m[x] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define fi first
#define se second
#define pii pair<int, int>
const int N = 2e5 + 10;

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = INT64_MAX;
    for(int i = 0; i < n - k + 1; i++) {
        int j = i + k - 1;
        if(a[i] >= 0) {
            ans = min(ans, a[j]);
        }else if(a[i] < 0 && a[j] <= 0) {
            ans = min(ans, -a[i]);
        }else {
            ans = min(ans, min(-2 * a[i] + a[j], -a[i] + 2 * a[j])); 
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1024
roop_num = int(input())

xy = [map(int, input().split()) for _ in range(roop_num)]
x, y = [list(i) for i in zip(*xy)]

z_counter = 0
flg = False

for i in range(roop_num):
  if(x[i] == y[i]):
    z_counter = z_counter +1
  else:
    z_counter = 0
  if(z_counter == 3):
    flg = True
    break

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


Measured memory_bytes: 9076
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nm[0];
			int m = nm[1];

			var xyz = new XYZ[n];
			for (int i = 0; i < n; i++) {
				var temp = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
				xyz[i] = new XYZ { X = temp[0], Y = temp[1], Z = temp[2] };
			}

			long ans = long.MinValue;
			for (int i = 0; i < 1 << 3; i++) {
				var temp = xyz
					.OrderByDescending(v => {
						long val = 0;
						val += v.X * (((i & 1) != 0) ? 1 : -1);
						val += v.Y * (((i & 2) != 0) ? 1 : -1);
						val += v.Z * (((i & 4) != 0) ? 1 : -1);
						return val;
					})
					.ToArray();

				long sum1 = 0;
				long sum2 = 0;
				long sum3 = 0;
				for (int j = 0; j < m; j++) {
					sum1 += temp[j].X;
					sum2 += temp[j].Y;
					sum3 += temp[j].Z;
				}

				long tempAns = Math.Abs(sum1) + Math.Abs(sum2) + Math.Abs(sum3);
				ans = Math.Max(ans, tempAns);
			}


			Console.WriteLine(ans);
		}
	}

	public struct XYZ
	{
		public long X { get; set; }
		public long Y { get; set; }
		public long Z { get; set; }
	}
}

Measured memory_bytes: 14176
package main

import (
	"fmt"
)

func main() {
	var a, b, n int
	fmt.Scan(&a, &b, &n)
	x := min(b-1, n)
	fmt.Println(int(a*x/b) - a*int(x/b))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 1752
using System;
class Program { 
  static void Main(string[] args) {
    int[] anntenas = new int[5];
    int k;
    
    for (int i=0; i<5; i++) {
      anntenas[i] = int.Parse(Console.ReadLine());
    }
    k = int.Parse(Console.ReadLine());
    
    for (int i=0; i<4; i++) {
      for (int j=i+1; j<5; j++) {
        if (anntenas[j] - anntenas[i] > k) {
          Console.WriteLine(":(");
          return;
        }
      }
    }
    
    Console.WriteLine("Yay!");
    return;
  }
}

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

int main() {
    string S; cin >> S;
    int q; cin >> q;
    bool reversed = false;

    string front, back;

    for (int i = 0; i < q; ++i) {
        int query; cin >> query;
        if (query == 1) reversed = !reversed;
        else {
            int F; char C; cin >> F >> C;
            if ((F == 1 && !reversed) || (F == 2 && reversed)) front += C;
            if ((F == 1 && reversed) || (F == 2 && !reversed)) back += C;
        }
    }

    if (!reversed) {
        reverse(front.begin(), front.end());
        cout << front << S << back << "\n"s;
    } else {
        reverse(back.begin(), back.end());
        reverse(S.begin(), S.end());
        cout << back << S << front << "\n"s;
    }

    return 0;
}


Measured memory_bytes: 1088
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

double ans = 0;

int main(void){
	double l; cin >>l;
	ans = (l/3)*(l/3)*(l/3);
	printf("%.10lf", ans);
	return 0;
}

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

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

typedef std::pair<ll, ll> pi;

using namespace std;


int main() {
    int n,m; cin >> n >> m;
    ll f,s;
    priority_queue<pi, vector<pi>, greater<pi>> a;
    rep(i, n) {
        cin >> f >> s;
        a.push(make_pair(f,s));
    }

    ll ans = 0;
    while(!a.empty()) {
        pi p = a.top();
        if(m-p.second > 0) {
            m -= p.second;
            ans += p.first * p.second;
        } else {
            ans += p.first * m;
            cout << ans << endl;
            return 0;
        }
        a.pop();
    }

    return 0;
}


Measured memory_bytes: 2420
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
#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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N, M, X;
	cin >> N >> M >> X;

	int C[12];
	int A[12][12];
	rep(i, N) {
		cin >> C[i];

		rep(j, M) {
			cin >> A[i][j];
		}

	}

	int owari = (1 << N);
	int saishou = 2e9;
	rep(x, owari) {
		int tmp[12] = {};
		int cost = 0;
		rep(i, N) {
			if (x >> i & 1) {
				rep(j, M) {
					tmp[j] += A[i][j];
				}
				cost += C[i];
			}
		}

		int OK = 1;
		rep(i, M) {
			if (tmp[i] < X) OK = 0;
		}
		if (OK) chmin(saishou, cost);
	}

	if (saishou > 1e9) {
		co(-1);
	}
	else co(saishou);

	Would you please return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
const int N=1e5+5;
int n,tot,dis[N],head[N],nex[N<<1],to[N<<1],wi[N<<1];
void add(int u,int v,int w){to[++tot]=v;nex[tot]=head[u];head[u]=tot;wi[tot]=w;}
bool vis[N];
struct node
{
    int x,v;
    node(int x=0,int v=0):x(x),v(v){}
    bool operator<(const node&o)const
    {
        return v>o.v;
    }
};
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n;i++) add(i%n,(i+1)%n,1),add(i%n,i*10%n,0);
    priority_queue<node>q;
    q.push(node(1,0));
    memset(dis,inf,sizeof(dis));
    dis[1]=0;
    while(!q.empty())
    {
        int u=q.top().x;q.pop();
        if(vis[u]) continue;
        vis[u]=true;
        for(int i=head[u];i;i=nex[i])
        {
            int v=to[i];
            if(dis[v]>dis[u]+wi[i])
            {
                dis[v]=dis[u]+wi[i];
                q.push(node(v,dis[v]));
            }
        }
    }
    printf("%d\n",dis[0]+1);
}


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

Ndiv3 = N // 3
Ndiv5 = N // 5
Ndiv15 = N // 15

ans = (N*(N + 1) - 3*Ndiv3*(Ndiv3 + 1) - 5*Ndiv5*(Ndiv5 + 1) + 15*Ndiv15*(Ndiv15 + 1))//2
print(ans)

Measured memory_bytes: 9104