akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Problem C: Brave Princess Revisited
 */
public class Main {

	static final int INF = 1 << 29;

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			StringTokenizer st = new StringTokenizer(line);

			int N, M, L;
			N = parseInt(st.nextToken());
			M = parseInt(st.nextToken());
			L = parseInt(st.nextToken());
			if ((N | M | L) == 0) break;

			Map<Integer, List<Edge>> G = new HashMap<>();

			for (int i = 0; i < M; i++) {
				st = new StringTokenizer(br.readLine());
				int A, B, D, E;
				A = parseInt(st.nextToken());
				B = parseInt(st.nextToken());
				D = parseInt(st.nextToken());
				E = parseInt(st.nextToken());
				G.putIfAbsent(A, new ArrayList<>());
				G.putIfAbsent(B, new ArrayList<>());
				G.get(A).add(new Edge(B, D, E));
				G.get(B).add(new Edge(A, D, E));
			}

			//???????????¨ -> [?????´][????????????]
			int[][] D = new int[N + 1][L + 1];
			Queue<int[]> pq = new PriorityQueue<>((x, y) -> Integer.compare(x[2], y[2]));

			for (int i = 0; i < D.length; i++) Arrays.fill(D[i], INF);
			D[1][L] = 0;
			pq.offer(new int[]{1, L, 0});

			while (!pq.isEmpty()) {

				int s, l, min;
				s = pq.peek()[0];
				l = pq.peek()[1];
				min = pq.peek()[2];
				pq.poll();

				if (D[s][l] < min) continue;

				outer:
				for (Edge e : G.get(s)) {
					for (int i = 0; i <= L; i++) {
						if (D[e.to][i] > D[s][i] + e.enemy) {
							D[e.to][i] = D[s][i] + e.enemy;
							pq.offer(new int[]{e.to, i, D[e.to][i]});
						}
						if (i >= e.distance) {
							if (D[e.to][i - e.distance] > D[s][i]) {
								D[e.to][i - e.distance] = D[s][i];
								pq.offer(new int[]{e.to, i - e.distance, D[e.to][i - e.distance]});
							}
						}
					}
				}
			}

			int min = INF;

			for (int i = 0; i <= L; i++) {
				min = Math.min(min, D[N][i]);
			}

			System.out.println(min);
		}
	}
}

class Edge {

	int to, distance, enemy;

	public Edge(int to, int distance, int enemy) {
		this.to = to;
		this.distance = distance;
		this.enemy = enemy;
	}
}

Measured memory_bytes: 61284
import sys

sys.setrecursionlimit(1000000)

N, M = map(int, input().split())
A = []
ANS = []
for i in range(N + 10):
    ANS.append(None)

for _ in range(M):
    a = int(input())
    A.append(a)
    ANS[a] = 0


def f(x):
    # print(ANS)
    # if x in A:
    #     print('::::', x)
    #     d[x] = 0
    #     return 0
    if ANS[x] is not None:
        return ANS[x]

    if x > N:
        return 0
    if x == N:
        return 1

    # if d.get(x + 1):
    #     x1 = d.get(x + 1)
    # else:
    #     x1 = f(x + 1)
    #     d[x + 1] = x1
    #
    # if d.get(x + 2):
    #     x2 = d.get(x + 2)
    # else:
    #     x2 = f(x + 2)
    #     d[x + 2] = x2

    # ans = x1 + x2
    ans = f(x + 1) + f(x + 2)
    ANS[x] = ans
    return ans


print(f(0) % 1000000007)


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i < (n)i++)
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define abs(a) llabs(a)
#define int long long
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

bool bl[1000010];
long long x[10000010], y[10000010], z[100000010];
signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int n, a, b, c, cnt = 0, ans = 0;
   string s, v;

   cin >> n;
   if (n % 2 == 0)
      cout << n / 2 - 1 << '\n';
   else
      cout << n / 2 << '\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>
#define N 200005
#define fi(a, b, c) for(int a = (b); a < (c); a++)
#define FI(a, b, c) for(int a = (b); a <= (c); a++)
using namespace std;

int n, dp[N], best[1 << 26];
char s[N];

int main(){
	scanf("%s", s);
	n = strlen(s);
	
	int mask = 0;
	fi(i, 0, 1 << 26) best[i] = 1e9;
	best[0] = 0;
	
	fi(i, 0, n){
		mask ^= 1 << s[i] - 'a';
		
		dp[i] = best[mask] + 1;
		fi(j, 0, 26){
			dp[i] = min(dp[i], best[mask ^ 1 << j] + 1);
		}
		
		best[mask] = min(best[mask], dp[i]);
	}
	
	printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 263296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int weight = sc.nextInt();
		int[] w = new int[n];
		int[] v = new int[n];
		for(int i = 0; i < n; i++) {
			w[i] = sc.nextInt();
			v[i] = sc.nextInt();
		}
		long[][] dp = new long[n+1][100001];
		for(int i = 0; i < n + 1; i++) {
			for(int j = 0; j < 100001; j++) {
				dp[i][j] = 92233720368l;
			}
		}
		/*for(int i = 0; i < 100001; i++) {
			dp[0][i] = 0;
		}*/
		dp[0][0] = 0;
		//---------初期設定終了-----------
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < 100001; j++) {
				dp[i+1][j] = Math.min(dp[i+1][j], dp[i][j]);
				if(j + v[i] <= 100000)dp[i+1][j+v[i]] = Math.min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
			}
		}
		long ans = 0;
		for(int i = 0; i < 100001; i++) {
			if(dp[n][i] <= weight)ans = i;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 128176
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)
#define RREP(i, a, n) for(int i=n-1; i>=0; i--)
#define RANGE(a, low, high) (low<=a && a<high)
#define MP(a, b) make_pair(a, b)

int dy[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
char cake[2] = { 'o', 'x' };
char table[8][8];
bool mami[8][8], charlotte[8][8];

pair<int, int> check_mami() {
	int maxi = 0;
	pair<int, int> p = MP(-1, -1);

	REP(i, 0, 8) {
		REP(j, 0, 8) {
			if (table[i][j] != '.') continue;

			int cnt = 0;
			REP(k, 0, 8) {
				int y = i + dy[k];
				int x = j + dx[k];
				int chain = 0;
				
				bool flag = false;
				while (RANGE(y, 0, 8) && RANGE(x, 0, 8) && table[y][x] != '.') {

					if (table[y][x] == 'x') chain++;
					else if (table[y][x] == 'o') {
						flag = true;
						break;
					}

					y += dy[k];
					x += dx[k];
				}

				if (flag) cnt += chain;
			}

			if (cnt > maxi) {
				maxi = cnt;
				p = MP(i, j);
			}
		}
	}

	return p;
}

pair<int, int> check_charlotte() {
	int maxi = 0;
	pair<int, int> p = MP(-1, -1);

	RREP(i, 0, 8) {
		RREP(j, 0, 8) {
			if (table[i][j] != '.') continue;

			int cnt = 0;
			REP(k, 0, 8) {
				int y = i + dy[k];
				int x = j + dx[k];
				int chain = 0;

				bool flag = false;
				while (RANGE(y, 0, 8) && RANGE(x, 0, 8) && table[y][x] != '.') {
					if (table[y][x] == 'o') chain++;
					else if (table[y][x] == 'x') {
						flag = true;
						break;
					}

					y += dy[k];
					x += dx[k];
				}

				if (flag) cnt += chain;
			}

			if (cnt > maxi) {
				maxi = cnt;
				p = MP(i, j);
			}
		}
	}

	return p;
}

void change(int y, int x, bool idx) {
	table[y][x] = cake[idx];  // false:'o', true:'x'
	REP(k, 0, 8) {
		int ny = y + dy[k];
		int nx = x + dx[k];

		int cnt = 0;
		while (RANGE(ny, 0, 8) && RANGE(nx, 0, 8) && table[ny][nx] != '.') {
			if (table[ny][nx] == cake[true-idx]) cnt++;

			else if (table[y][x] == cake[idx]) {
				RREP(l, 0, cnt) {
					ny += dy[(k + 4) % 8];
					nx += dx[(k + 4) % 8];
					table[ny][nx] = cake[idx];
				}
				break;
			}

			ny += dy[k];
			nx += dx[k];
		}
	}

	return;
}

int main() {
	REP(i, 0, 8) REP(j, 0, 8) cin >> table[i][j];

	while (1) {
		pair<int, int> mami = check_mami();
		if (mami.first != -1) change(mami.first, mami.second, false);
		
		pair<int, int> charlotte = check_charlotte();
		if (charlotte.first != -1) change(charlotte.first, charlotte.second, true);

		if (mami.first == -1 && charlotte.first == -1) break;
	}

	REP(i, 0, 8) {
		REP(j, 0, 8) {
			cout << table[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int lcm(int a, int b) {
	return a / __gcd(a, b) * b;
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i] /= 2;
	}
	int l = a[0];
	for (int i = 0; i < n; ++i) {
		l = lcm(l, a[i]);
	}
	if (l > m) {
		cout << 0 << '\n';
		return 0;
	}
	for (int i = 0; i < n; ++i) {
		int x = l / a[i];
		if (x % 2 == 0) {
			cout << 0 << '\n';
			return 0;
		}
	}
	int x = m / l;
	cout << (x - 1 + 2) / 2 << '\n';
	return 0;
}


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

int main(){
  int K,S,count=0;
  cin >> K >> S;
  for(int x=0;x<K+1;x++){
    for(int y=0;y<K+1;y++){
        if(0<=S-x-y && S-x-y<K+1){
          count++;
        }
    }
  }
  cout << count << endl;
}

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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int (i) = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int (i) = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int (i) = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__ "yes"
#define FALSE__ "no"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#define INF 1e9


int main()
{
	int x, a, b;
	cin >> x >> a >> b;
	if (a >= b) cout << "delicious" << endl;
	else if (a + x >= b) cout << "safe" << endl;
	else cout << "dangerous" << endl;
}

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


int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
// Returns LCM of array elements 
ll findlcm(int arr[], int n) 
{ 
    // Initialize result 
    ll ans = arr[0]; 
  
    // ans contains LCM of arr[0], ..arr[i] 
    // after i'th iteration, 
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
  return ans;
}


void solve(){
	int n;
	cin >> n;
	int a[n];
	cout << fixed << setprecision(6);
	for(int i = 0; i<n; i++)
	cin >> a[i];
	
	ll lcm = findlcm(a, n);
	double ans = 0;
	for(int i = 0; i<n; i++)
	{
		ans += (double)lcm/(a[i]*1.0);
	}
	ans = (double)lcm/ans;
	cout << ans << endl;

}


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
		return 0;
}


Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int K = scanner.nextInt();

        Set<Integer> set = new HashSet<>();
        for(int i = 0; i < K; i++) {
            int d = scanner.nextInt();;
            for(int j = 0; j < d; j++) {
                int u = scanner.nextInt();
                set.add(u);
            }
        }
        System.out.println(N - set.size());
    }
}


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

using namespace std;

bool allvisited(bool visited[], int n){
	for(int i=1;i<=n;i++){
		if(visited[i] == false){
			return false;
		}
	}
	return true;
}

int main(void){
	int n,m;
	
	while(cin >> n >> m){
		if(n == 0 && m == 0) break;
		bool visited[n+1]; //numbers are 1-origin
		fill(visited, visited+n+1, false);
		
		int place = n;
		while(!allvisited(visited, n)){
			int cnt=0;
			while(cnt != m){
				place++;
				if(place > n) place -= n;
				if(visited[place] == true) continue;
				cnt++;
			}
			visited[place] = true;
		}
		cout << place << endl;
	}
}

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

int main(){
  char str[20];
  char tmp;
  int wcount,i;

  scanf("%s",&str);

  wcount=(strlen(str)-1);

  for(i=0;i<wcount;i++){
    tmp=str[wcount];
    str[wcount]=str[i];
    str[i]=tmp;
    wcount--;
  }

  printf("%s\n",str);

  return 0;
}

Measured memory_bytes: 524
from collections import deque


que = deque()

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

for i in range(n):
    if i%2 == 0:
        que.append(seq[i])
    else:
        que.appendleft(seq[i])

if n%2 != 0:
    que.reverse()



print(*que)



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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(N),b(N),c(N);
    ll sum_a=0, sum_b=0, sum=0;
    rep(i,N){
        cin >> a[i];
        sum_a += a[i];
    }
    rep(i,N){
        cin >> b[i];
        sum_b += b[i];
    }
    sum = sum_b - sum_a;
    ll cnt1 = 0, cnt2=0;
    rep(i,N){
        if(b[i]-a[i] > 0){
            cnt1 += ((b[i] - a[i] + 1)/2);
        }else if(b[i] - a[i] < 0){
            cnt2 += (a[i] - b[i]);
        }
    }
    if(cnt1 <= sum && cnt2<=sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" <<endl;
    }
    
    /*
    priority_queue<ll,vector<ll>,greater<ll>> que;
    rep(i,N){
        c[i] = b[i] - a[i];
        que.push(c[i]);
    }
    while(que.top() < 0){


    }
    
    sort(c.begin(),c.end());
    bool flag = true;
    while(flag){
        flag = false;
        rep(i,N){
            if(c[i] == 0)continue;
            flag = true;
            if(c[i] < 0){
                c[i]++;
                c[N-1] -=2;
                if(c[N-1] < 0 ){
                    cout << "No" << endl;
                    return 0;
                }
            }else{
//                c[N-1] -= 2;
 //               if(c[N-1] < 0){
                    cout << "Yes" << endl;
                    return 0;
 //               }
            }
            i = -1;
            sort(c.begin(),c.end());
        }
    }
    //priority_queue<ll,vector<ll>,greater<ll>> quea;
    cout << "Yes" << endl;*/
}
/*
-1 0 4
0 0 2


0 0 
99 -98

98 0
99 -49

98 40
99 -29

*/

Measured memory_bytes: 512
using static System.Math;using static System.Console;using System.Collections.Generic;using System.Linq;using System;using System.Collections;
using System.Runtime.Serialization;
using System.Collections.Specialized;
using System.Security.Cryptography;
using System.Globalization;

class Program
{
    #region Reader
    static string ReadStr => Console.ReadLine();
    static string[] ReadStrs => Console.ReadLine().Split(' ');
    static int ReadInt => Convert.ToInt32(Console.ReadLine());
    static int[] ReadInts => Console.ReadLine().Split(' ').Select(s => Convert.ToInt32(s)).ToArray();
    static long ReadLong => Convert.ToInt64(Console.ReadLine());
    static long[] ReadLongs => Console.ReadLine().Split(' ').Select(s => Convert.ToInt64(s)).ToArray();
    #endregion
    #region Method
    const int mod = 1000000007;
    public static int Mod(int a,int mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    public static long Mod(long a, long mod = mod) { return a % mod >= 0 ? a % mod : a % mod + mod; }
    #endregion


    static void Main()
    {
        int N = ReadInt;
        int[] As = ReadInts;
        long ans = 1;

        int[] d = { 0, 0, 0 };

        for (int i = 0; i < N; i++)
        {
            int options = 0;
            int color = -1;

            if(As[i] == d[0])
            {
                options++;
                color = 0;
            }
            if (As[i] == d[1])
            {
                options++;
                color = 1;
            }
            if (As[i] == d[2])
            {
                options++;
                color =2;
            }
            if (color == -1)
            {
                WriteLine(0);
                return;
            }

            ans *= options;
            ans %= mod;
            d[color]++;
        }
        WriteLine(ans);

    }

}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > S(m);
  vector<int> P(m);
  rep(i,m) {
    int k;
    cin >> k;
    rep(j,k) {
      int s;
      cin >> s;
      s--;
      S[i].push_back(s);
    }
  }
  rep(i,m) cin >> P[i]; 
  int ans = 0;
  for (int bit = 0; bit < (1<<n); ++bit) {
    bool ok = true;
    rep(i,m) {
      int count = 0;
      for (auto x : S[i]) {
        if (bit & (1<<x)) count++; //x番目のスイッチON
      }
      if (count % 2 != P[i]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long int
#define ulli unsigned long long int
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
long long int adj[1000][1000];
long long int h[100000+10];
map<long long int,long long int>mp;
long long int val;
long long int answe1,res;
vector<lli>vect[400];
//set<lli>s;
/*void primeFactors(int n)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0)
    {
        s.insert(2);
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            s.insert(i);
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        s.insert(n);
}
*/
int main()
{

    fast;


    lli n,m;
    cin>>n;
    lli INF=1e9+5;
    lli a[n],b[n],c[n];
    vector<lli>dp(3);
    for(lli i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    vector<lli>dpnew(3);
    dp[0]=max(b[0],c[0]);
    dp[1]=max(a[0],c[0]);
    dp[2]=max(b[0],a[0]);
    for(lli i=1;i<n;i++)
    {
        dpnew[0]=max(dp[1],dp[2])+a[i];
        dpnew[1]=max(dp[0],dp[2])+b[i];
        dpnew[2]=max(dp[1],dp[0])+c[i];
        dp=dpnew;

    }
    cout<<max(dp[0],max(dp[1],dp[2]));


    return 0;

}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

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

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	vector<ll> count(4, 0);
	REP(i, 3){
		ll a, b;
		cin >> a >> b;
		a--;b--;
		count[a]++;
		count[b]++;
	}
	sort(count.begin(), count.end());
	bool flag = (count[0]==1&&count[1]==1&&count[2]==2&&count[3]==2);
	cout << (flag?"YES":"NO") << endl;
    return 0;
}

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

int main(){
    string s, t; cin >> s >> t;
    int n = s.length(), m = t.length();
    vector<vector<int>> is(26);
    for(int i = 0; i < n; i++) is[s[i] - 'a'].push_back(i);
    for(int i = 0; i < n; i++) is[s[i] - 'a'].push_back(i + n);
    long long ans = 0;
    int p = 0;
    for(int i = 0; i < m; i++){
        int c = t[i] - 'a';
        if(is[c].size() == 0){
            cout << -1 << endl;
            exit(0);
        }
        p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
        if(p >= n){
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;
}

Measured memory_bytes: 1724
def check(p):
    j = 0 # 積んだ荷物の個数
    for i in range(k):
        track = 0
        while track + w[j] <= p:
            track += w[j]
            j += 1
            if j == n:
                return n
    return j

def solve():
    right = 100000 * 10000
    left = 0
    mid = (right + left) // 2
    while right - left > 0:
        cnt = check(mid)
        if cnt == n:
            right = mid
            mid = (right + left) // 2
        else:
            left = mid + 1
            mid = (right + left) // 2

    return mid

n, k = map(int, input().split())
w = []
for _ in range(n):
    w.append(int(input()))

print(solve())



Measured memory_bytes: 9552
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){


    bool cards[4][13];

    for(int i=0;i<13;i++){
        for(int j=0;j<4;j++){
            cards[j][i] = false;
        }
    }

    int Count;
    scanf("%d",&Count);

    for(int i=0;i<Count;i++){
        char Mark;
        int Num;
        scanf(" %c %d",&Mark,&Num);
        switch (Mark)
        {
        case 'S':
            cards[0][Num-1] = true;
            break;
        case 'H':
            cards[1][Num-1] = true;
            break;
        case 'C':
            cards[2][Num-1] = true;
            break;
        case 'D':
            cards[3][Num-1] = true;
            break;
        }       
    }
    for(int i=0;i<13;i++){
        if(cards[0][i] == false){
            printf("S %d\n",i+1);
        }
    }
    for(int i=0;i<13;i++){
        if(cards[1][i] == false){
            printf("H %d\n",i+1);
        }
    }
    for(int i=0;i<13;i++){
        if(cards[2][i] == false){
            printf("C %d\n",i+1);
        }
    }
    for(int i=0;i<13;i++){
        if(cards[3][i] == false){
            printf("D %d\n",i+1);
        }
    }
    return 0;
}



Measured memory_bytes: 2676
#include <fstream>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    //ifstream cin("/Volumes/env1/work/aoj/1378/a");
    int l, k;
    cin >> l >> k;

    vector<vector<int>> memo(10, vector<int>(2, 10));
    // ??????????????????
    // w -> bs or bt
    // bin -> bin - 1
    // b -> w
    // function<int(int, int)> f = [&f, &memo, l](int h, int c) {

    //};

    vector<vector<long>> dp(l + 2, vector<long>(k + 1, 0));

    auto p = [&dp] {
        for (auto &&i : dp) {
            for (auto &&j : i) {
                cout << j << ' ';
            }
            cout << endl;
        }
    };
    dp[1][1] = 1;
    dp[1][k] = 1;
    for (int h = 1; h <= l; ++h) {
        for (int i = 0; i < k; ++i) {
            dp[h + 1][i] += dp[h][i + 1];
        }
        if (dp[h][0] > 0) {
            dp[h + 1][1] += dp[h][0];
            dp[h + 1][k] += dp[h][0];
        }
        //cout << "end of " << h << endl;
        //p();
        //cout << endl;
    }

    long sum_ = 0;
    for (int h = 1; h <= l; ++h) {
        sum_ += dp[h][1];
    }
    cout << sum_ << endl;

    // dp[1][1] = 1;
    // dp[1][k] = 1;
    // for (int h = 2; h <= l; ++h) {
    //    for (int i = 0; i < k; ++i) {
    //        dp[h][i] = dp[h - 1][i + 1];
    //    }

    //    //if (dp[h][0] > 0) {
    //    //    dp[h][1] = dp[h][0] + 1;
    //    //    dp[h][k] = dp[h][0] + 1;
    //    //}
    //    cout << h << endl;
    //    p();
    //}
    //p();
    //cout << dp[l][1] << endl;
}

Measured memory_bytes: 3164
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 55
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////
class Solution {
public:
	vector <int> solve(int N) {
		vector <int> perm(N);
		for (int i = 0; i < N; i++) perm[i] = i + 1;
		map <int, int> M;
		int maxx = 0;
		do {
			int oddness = 0;
			for (int i = 0; i < N; i++) oddness += abs(perm[i] - (i + 1));
			M[oddness]++;
			maxx = max(maxx, oddness);
		} while (next_permutation(perm.begin(), perm.end()));
		vector <int> res;
		for (int k = 0; k <= maxx; k+=2) res.push_back(M[k]);
		return res;
	}
};
int64 dp[MAX_N][MAX_N][MAX_N * MAX_N];
inline int64 ADD(int64 x, int64 y) {
	x += y;
	x %= MOD;
	return x;
}
/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	int N, K;
	scanf("%d %d", &N, &K);
	dp[0][0][0] = 1LL;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			for (int k = 0; k <= N * N; k += 2) {
				int64 val = dp[i - 1][j][k];
				if (j > 0) dp[i][j - 1][k + 2 * j] = ADD(dp[i][j - 1][k + 2 * j], val * j * j);
				dp[i][j + 1][k + 2 * j] = ADD(dp[i][j + 1][k + 2 * j], val);
				dp[i][j][k + 2 * j] = ADD(dp[i][j][k + 2 * j], val * (2 * j + 1));
			}
		}
	}
	printf("%lld\n", dp[N][0][K]);
	return 0;
}

Measured memory_bytes: 65792
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,x,y=map(int, readline().rstrip().split())
    ans = [0] * (n-1)
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            d1 = abs(i-x) + abs(j-y) + 1
            d2 = abs(i-y) + abs(j-x) + 1
            d3 = abs(i-j)
            d=min(d1,d2,d3)
            ans[d-1]+=1
    for a in ans:
        print(a)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 16124
#include<bits/stdc++.h>
using namespace std ;
#define rep(i,a,n) for(int i =a;i<n;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);
	int a[100000];
int main(){
	ios;
    int n,cur=0,cnt=0,m=0;
    cin>>n;
    rep(i,0,n)
    {cin>>a[i];
	}
	while(cur!=n-1)
	{if(a[cur]>=a[cur+1])
	{cnt++;
	 cur++;
	}
	else if(a[cur]<a[cur+1])
	{cnt=0;
	 cur++;
	}
	if(cnt>=m)
	{m=cnt;
	}
	}
	cout<<m<<endl;
	return 0;
	
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int n, k;
ll ans;
vector<ll> logs;
void binary(ll l, ll r){
    if(l > r) return;
    ll m = (l + r) / 2, ck = k;
    for(int i=n-1;i>=0;i--){
        if(logs[i] <= m) break;
        ck -= (logs[i] / m -1);
        if(logs[i] % m) ck--;
    }
    if(ck < 0){
        binary(m+1, r);
    }else{
        ans = min(ans, m);
        binary(l, m-1);
    }
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>k;
    logs = vector<ll>(n);
    for(int i=0;i<n;i++){
        cin>>logs[i];
    }
    sort(logs.begin(), logs.end());
    ans = logs.back();
    binary(1, logs.back());
    cout<<ans;
}

Measured memory_bytes: 4344
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (scanner.hasNext()) {
			int n = scanner.nextInt() % 39;
			System.out.println(String.format("3C%02d", n == 0 ? 39 : n));
		}
	}
}

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

string l(string s){
  for(int i = 0; i < s.length(); i++){
    if(s[i] == '?') s[i] = 'a';
  }
  return s;
}

bool f(string s, string t){
  int num = 0;
  for(int i = 0; i < t.length(); i++){
    if(s[i] == '?') num++;
    else if(s[i] == t[i]) num++;
  }
  if(num == t.length()) return true;
  else return false;
}

int main(void){
  bool flag = false;
  string s, t;
  cin >> s >> t;
  int sub = s.length() - t.length();
  string sc, sf, se;
  while(sub >= 0){
    sf = s.substr(0, sub);
    sc = s.substr(sub, t.length());
    se = s.substr(sub + t.length());
    if(f(sc, t)){
      s = sf + t + se;
      flag = true;
      break;
    }
    sub--;
  }
  
  s = l(s);
  if(flag)
    cout << s << endl;
  else cout << "UNRESTORABLE" << endl;
  return 0;
}


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

char in[13];
int hash[10000000];
int n;

void insert(void);
void find(void);
int gethash(void);
int Getchar(char);


int main(){

	char ins[7];

	scanf("%d",&n);

	while(n--){
		scanf("%s%s",ins,in);
		if(ins[0]=='i'){
			insert();
		}else{
			find();
		}
	}

	return 0;
}

void insert(){
	hash[gethash()] = 1;
}


void find(){
	if(hash[gethash()]==1)
		printf("yes\n");
	else
		printf("no\n");
}

int gethash(void){
	int hash=0,i,p=1;
	for(i=0;i<strlen(in);i++){
		hash += p*(Getchar(in[i]));
		p *= 4;
	}
	return hash;
}

int Getchar(char in){

	if(in=='A')return 1;
	else if(in=='C')return 2;
	else if(in=='G')return 3;
	else return 4;

}

Measured memory_bytes: 7156
#include <algorithm>
#include <iostream>
#define rep(i, n) for (int i = 0; i < n; i++)

int main() {
    int n, m;
    while (std::cin >> n >> m && n && m) {
        std::pair<int, int> res[m];
        rep(i, m) res[i].second = i + 1, res[i].first = 0;
        rep(i, n) rep(j, m) {
            int v;
            std::cin >> v;
            res[j].first += v;
        }
        std::sort(
            res, res + m,
            [](const std::pair<int, int> p1, const std::pair<int, int> p2) {
                return p1.first > p2.first
                           ? true
                           : p1.first < p2.first ? false
                                                 : p1.second < p2.second;
            });
        int c = 0;
        rep(i, m) {
            if (c++) std::cout << ' ';
            std::cout << res[i].second;
        }
        std::cout << std::endl;
    }
}

Measured memory_bytes: 3076
import collections

n = int(input())
Ali = list(map(int,input().split()))
q = int(input())
BCli = [list(map(int,input().split())) for _ in range(q)]

Ali_counter = collections.Counter(Ali)

sum_ans = sum(Ali)
for b, c in BCli:
    sum_ans = sum_ans + (Ali_counter[b] * (c-b))
    print(sum_ans)
    Ali_counter[c] = Ali_counter[c] + Ali_counter[b]
    Ali_counter[b] = 0

Measured memory_bytes: 40288
import numpy as np
n,d =map(int,input().split())
l=[]
ans=0
for i in range(n):
    l.append(list(map(int,input().split())))
for i in range(n):
    for j in range(i):
        z=0
        for k in range(d):
            z+=(l[i][k]-l[j][k])**2
        if float(np.sqrt(z)).is_integer():
            ans+=1
print(ans)

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }


/**
 *  @brief SとS[i:|S|-1](i=0,1,...,|S|-1)の
 *         最長共通接頭辞(LCP: Longest Common Prefix)を導出する
 *  @note  Z-Algorithm 計算量O(|S|)
 */
class LCPCulculator {
public:
    /**
     *  @param (S)    対象の文字列
     *  @param (dupl) falseの場合、max_lcp_length_を
     *                S[0:i-1]とS[i:|S|-1](i=1,...,|S|-1)の最長共通接頭辞の最大値とする
     */
    explicit LCPCulculator(const string& S,
                           const bool&   dupl = true) :
        dupl_(dupl), S_(S) { createTable(); }
    ~LCPCulculator() { }

    const string& getString() const { return S_; }
    const std::vector<int>& getTable() const { return table_; }
    const int& getMaxLCPLength() const { return max_lcp_length_; }

    void rerun(const string& S) { S_ = S; createTable(); }

private:
    const bool       dupl_;
    std::string      S_;
    std::vector<int> table_;           // table_[i] : SとS[i:|S|-1]の最長共通接頭辞の長さ
    int              max_lcp_length_;  // 求まる最長共通接頭辞の最大値

    void createTable() {
        table_    = std::vector<int>(S_.size(), 0);
        table_[0] = S_.size();
        max_lcp_length_  = 0;
        size_t i = 1, j = 0, k = 0;
        while(i < S_.size()) {
            while(i + j < S_.size() && S_[j] == S_[i + j]) j++;
            table_[i]       = j;
            max_lcp_length_ = max(max_lcp_length_, (int)(dupl_ ? j : min(j, i)));
            if(j == 0) { i++; continue; }
            k = 1;
            while(i + k < S_.size() && k + table_[k] < j) {
                table_[i + k] = table_[k];
                k++;
            }
            i += k; j -= k;
        }
    }
};

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

    int N;
    std::cin >> N;
    string S;
    std::cin >> S;

    int ans = 0;
    REP(i, N - 1) {
        LCPCulculator lcp(S.substr(i), false);
        chmax(ans, lcp.getMaxLCPLength());
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;
 
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int p[] = new int[n];
        int p_copy[] = new int[n];

        for (int i = 0; i < n; i++) {
            p[i] = sc.nextInt();
        }

        if (isIncrease(p)) {
            System.out.println("YES");
        } else {
            boolean canSwap = false;
            for (int i = 0; i < n-1; i++) {
                for (int j = 0; j < n; j++) {
                    for (int k = 0; k < n; k++) {
                        p_copy[k] = p[k];
                    }
                    int dummy = p_copy[i];
                    p_copy[i] = p_copy[j];
                    p_copy[j] = dummy;
                    if (isIncrease(p_copy)) {
                        canSwap = true;
                    }
                }
            }
            if (canSwap) {
                System.out.println("YES");
            } else {
                System.out.println("NO");
            }
        }
    }
    
    static boolean isIncrease(int p[]) {
        for (int i = 0; i < p.length - 1; i++) {
            if (p[i] > p[i+1]) {
                return false;
            }
        }
        return true;
    }

}


Measured memory_bytes: 21972
//Tue Dec 22 22:01:34 JST 2009
#include<set>
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  int path[8];
  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//
    return false;
  }
  
  void make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	S.insert(*this);
	Q.push(*this);
	cnt--;
      }
      return;
    }

    //don't move
    
    if (can_good_pos(now) ){
      path[now]=-1;
      make_next(now+1,Q,S,CANMOVE,NG);
    }

    if ( flag == CANNOTMOVE)return;//

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];

      path[now]=i;

      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	make_next(now+1,Q,S,CANNOTMOVE,NG);//
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
        
  }
  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  queue<state> Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    Q.pop();
if (60<now.cnt+(max(now.x[0],dx)-min(now.x[0],dy)+
max(now.y[0],dy)-min(now.y[0],dy))*2)continue;
    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    now.make_next(0,Q,S,CANMOVE,NG);
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(cin>>n && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)cin>>ini.x[i]>>ini.y[i];
    cin>>m;
    rep(i,m){
      int f,s;
      cin>>f>>s;
      NG.insert(mp(f,s));
    }
    cin>>dx>>dy;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Measured memory_bytes: 30000
#include <stdio.h>
int main(void)
{

char a;

	scanf("%c",&a);

	if     (a=='A') printf("T\n");
	else if(a=='C') printf("G\n");
	else if(a=='G') printf("C\n");
	else if(a=='T') printf("A\n");


return 0;
}


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

int main() {
  
  int n, sum, ave;
  while (cin >> n) {
    vector<int> vec(n);
    for (int i=0; i < vec.size(); i++) {
      cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    if (vec.size() > 2) {
      for (int i=1; i<n-1; i++) {
        sum += vec[i];
      }
      ave = sum / (n-2);
    cout << ave << endl;
    }
    sum = 0;
    ave = 0;

  }
}


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

#+++++
		
def main():
	n,x = map(int, input().split())
	ll=[]
	min_ll=2*x
	sum_ll=0
	count_ll=0
	for i in range(n):
		m=int(input())
		ll.append(m)
		min_ll = m if m < min_ll else min_ll
		sum_ll+=m
		count_ll+=1
	
	add_c = (x-sum_ll) // min_ll
	ret = count_ll + add_c
	
	print(ret)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define VI vector<int>
#define PII pair<int, int>
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7 ;
///////////////////


int main(){
    int a,b,c; cin >> a >> b >> c;
    int ans = 0;
    while(true){
        if(ans == c){
            break;
        }
        if(b < a) break;
        if(b >= a){
            ans += 1;
            b -= a;
        }
    }

    cout << ans;
    return 0;
}


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

int main(){
    int A[3]; cin>>A[0]>>A[1]>>A[2];
    int sum=A[0]+A[1]+A[2];

    if(sum<22){
        cout<<"win"<<endl;
    }else{
        cout<<"bust"<<endl;
    }
}


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

int main(){
    int x,t,n;
    cin >> n >> x >> t;
    int s_t = n / x;
    if(n % x >= 1)s_t++;
    s_t *= t;
    cout << s_t << endl;
    return 0;
}

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

int N;
ll a[int(1e5 + 10)];

// n の素因数2の個数
int factor2(int n)
{
  int cnt = 0;
  while (n % 2 == 0) {
    ++cnt;
    n /= 2;
  }
  return cnt;
}

int main()
{
  cin >> N;
  REP(i,0,N) cin >> a[i];

  ll ans = 0;
  REP(i,0,N) {
    ans += factor2(a[i]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;

int main(){
    int n;
    double s;
    double array[1001];
    cin>>n;
    while(n !=0){
        double sum = 0.0;
        for(int i = 0;i<n;i++){
            cin>>s;
            sum = sum +s;
            array[i] = s;
        }
        double avg = sum/n;
        sum = 0.0;
        for(int i = 0;i<n;i++){
            sum = sum +((array[i] - avg)*(array[i] - avg));
        }
        sum = sum/n;
        sum = sqrt(sum);
        cout<<setiosflags(ios::fixed)<<setprecision(6)<<sum<<endl;
        cin>>n;
    }
    return 0;
}


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

namespace ProgramingStudying2
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            
            long ten = 1;
            long nine = 1;
            long eight = 1;
            const long INF = 1000000000 + 7;
            for(int i = 0; i < n; i++)
            {
                ten = (ten * 10) % INF;
                nine = (nine * 9) % INF;
                eight = (eight * 8) % INF;
            }

            var ans = ten - 2 * nine + eight;
            if(ans >= 0)
            {
                Console.WriteLine(ans);
            }
            else
            {
                while(ans < 0)
                {
                    ans += INF;
                }
                Console.WriteLine(ans);
            }
        }
    }
}


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

int main(){
    string w; 
    bool a = true;
    cin >> w;
    for(int i = 0; i < w.size(); i++){
        if (i%2 == 1) {
            if (w[i] != 'R')
            {

            }
            else
            {
                a = false;   
            }
        }
        else{
            if (w[i] != 'L')
            {

            }
            else
            {
                a = false;
            }
            
        }
    
    }
    if (a){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e5+7;
const int maxm=19;
typedef long long ll;
typedef pair<string,int> psi;
vector<psi> v;
map<psi,int> mp;
int n;
bool cmp(psi a,psi b)
{
	if(a.first==b.first)
	{
		return a.second>b.second;
	}
	else return a.first<b.first;
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{
		string s;int q;
		cin>>s>>q;
		psi tmp=make_pair(s,q);
		v.push_back(tmp);
		mp[tmp]=i+1;
	}
	sort(v.begin(),v.end(),cmp);
	for(int i=0;i<n;i++)
	{
		cout<<mp[v[i]]<<endl;
	 } 
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>
#include <numeric>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> a(n);
	rep(i, n) cin >> s[i] >> a[i];

	vector<int> ord(n);
	iota(allof(ord), 0);
	sort(allof(ord), [&](int x, int y) {
		if (s[x] == s[y]) return a[x] > a[y];
		return s[x] < s[y];
	});
	rep(i, n) {
		cout << ord[i] + 1 << endl;
	}
	return 0;
}


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

#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);

int main()
{
    unsigned ll h, w;

    cin >> h >> w;
    if(h==1||w==1){cout<<1<<endl;return 0;}
    ll one = (h / 2) + (h % 2);
    ll two;
    if (h % 2 == 0) { two = 2 * one; }
    else
    {
        two =( 2 * one) - 1;
    }

    if (w % 2 == 0)
    {
        cout << two * (w / 2) << endl;
        return 0;
    }
    if (h % 2 == 0)
    {
        cout << one * w << endl;
        return 0;
    }
    cout << (two * (w / 2)) + one << endl;


    return 0;
}

/*author  https://qiita.com/drken/items/0c88a37eec520f82b788*/
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


Measured memory_bytes: 3580
#include <stdio.h>

int main(void) {
	int n=1,x;
	for(;;) {
		scanf("%d",&x);
		if(x==0||x<1||x>10000||n>10000) break;
		printf("Case %d: %d\n",n,x);
		n++;
	}
	return 0;
}



Measured memory_bytes: 2044