akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
using namespace std;

int main() {
  int n, m, s;
  scanf("%d %d %d", &n, &m, &s);
  vector<vector<tuple<int, int, int>>> e(n);
  int maxai = 0;
  for (int i = 0; i < m; i++) {
    int u, v, a, b;
    scanf("%d %d %d %d", &u, &v, &a, &b);
    e[u - 1].push_back({v - 1, a, b});
    e[v - 1].push_back({u - 1, a, b});
    if (a > maxai) maxai = a;
  }
  vector<int> c(n), d(n);
  for (int i = 0; i < n; i++)
    scanf("%d %d", &c[i], &d[i]);

  int max_silver_coins = maxai * (n - 1);
  if (s > max_silver_coins) s = max_silver_coins;
  priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> pq;
  pq.push({0, s});
  unordered_map<int, long long> v;
  while (!pq.empty()) {
    auto p = pq.top();
    while (v.count(p.second)) {
      pq.pop();
      if (!pq.empty())
        p = pq.top();
      else
        break;
    }
    if (!pq.empty())
      pq.pop();
    else
      break;

    v.insert({p.second, p.first});

    long long current_time = p.first;
    int current_city = p.second / (max_silver_coins + 1);
    int current_silver_coins = p.second % (max_silver_coins + 1);

    // Get more silver coins
    if (current_silver_coins < max_silver_coins) {
      long long new_time = current_time + d[current_city];
      int new_city = current_city;
      int new_silver_coins = current_silver_coins + c[current_city];
      if (new_silver_coins > max_silver_coins)
        new_silver_coins = max_silver_coins;
      pq.push({new_time, new_city * (max_silver_coins + 1) + new_silver_coins});
    }

    // Travel to another city
    for (size_t i = 0; i < e[current_city].size(); i++) {
      int silver_coins_needed = get<1>(e[current_city][i]);
      if (current_silver_coins >= silver_coins_needed) {
        long long new_time = current_time + get<2>(e[current_city][i]);
        int new_city = get<0>(e[current_city][i]);
        int new_silver_coins = current_silver_coins - silver_coins_needed;
        pq.push({new_time, new_city * (max_silver_coins + 1) + new_silver_coins});
      }
    }
  }

  vector<long long> ans(n, numeric_limits<long long>::max());
  for (auto p : v) {
    int city = p.first / (max_silver_coins + 1);
    if (p.second < ans[city])
      ans[city] = p.second;
  }

  for (int i = 1; i < n; i++)
    printf("%lld\n", ans[i]);

  return 0;
}

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

#ifndef _WIN32
    #define getchar getchar_unlocked
#endif

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

typedef long long int LLI;
typedef unsigned long long int LLU;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<int> vi;

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',') cerr<<*sdbg++;
  cerr<<"="<<h<<",";
  _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int t[107][107];
int pom[10007];

int32_t main()
{
	int H, W; scanf("%d%d", &H, &W);
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; ++i)
		scanf("%d", &pom[i]);
	int kol = 1;
	for(int i = 0; i < H; ++i){
		if(i % 2 == 0){
			for(int j = 0; j < W; ++j){
				if(pom[kol] == 0) ++kol;
				t[i][j] = kol;
				--pom[kol];
			}
		}
		else{
			for(int j = W - 1; j >= 0; --j){
				if(pom[kol] == 0) ++kol;
				t[i][j] = kol;
				--pom[kol];
			}
		}
	}	
	for(int i = 0; i < H; ++i){
		for(int j = 0; j < W; ++j)
			printf("%d ", t[i][j]);
		puts("");
	}
}



Measured memory_bytes: 384
def main():
    height, width, leave_black = [int(x) for x in input().split()]
    table = [input() for _ in range(height)]

    ans = 0
    for num_h in range(2 ** height):
        for num_w in range(2 ** width):
            black_count = 0
            for bit_h in range(height):
                for bit_w in range(width):
                    if num_h >> bit_h & 1 or num_w >> bit_w & 1:
                        continue
                    black_count += table[bit_h][bit_w] == '#'
            ans += black_count == leave_black

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] a = new int[M];
		int[] b = new int[M];
		ArrayList<Integer>[] g = new ArrayList[N];
		for (int i = 0; i < g.length; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 0; i < M; ++i) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			g[a[i]].add(b[i]);
			g[b[i]].add(a[i]);
		}
		int Q = sc.nextInt();
		int[] v = new int[Q];
		int[] d = new int[Q];
		int[] c = new int[Q];
		for (int i = 0; i < Q; ++i) {
			v[i] = sc.nextInt() - 1;
			d[i] = sc.nextInt();
			c[i] = sc.nextInt();
		}

		int[] color = new int[N];
		boolean[][] vis = new boolean[N][11];
		Arrays.fill(color, -1);
		for (int i = Q - 1; i >= 0; --i) {
			func(g, color, c[i], v[i], d[i], vis);
		}
		PrintWriter pw = new PrintWriter(System.out);
		for (int val : color) {
			if (val == -1) {
				pw.println(0);
			} else {
				pw.println(val);
			}
		}
		pw.close();
	}

	void func(ArrayList<Integer>[] g, int[] color, int c, int v, int d, boolean[][] vis) {
		if (vis[v][d])
			return;
		if (d == 0 && color[v] == -1)
			color[v] = c;
		else {
			func(g, color, c, v, d - 1, vis);
			for (int nei : g[v]) {
				func(g, color, c, nei, d - 1, vis);
			}
		}
		vis[v][d] = true;
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}

Measured memory_bytes: 172380
using System;
using System.Collections.Generic;
using System.Linq;

class Class1
{
    static void Main(string[] args)
    {
        List<int> HKW = Console.ReadLine().Split(' ').Select(_ => int.Parse(_)).ToList();
        int H = HKW[0];
        int W = HKW[1];
        int K = HKW[2];
        var ct = new char[H][];

        for (int i = 0; i < H; i++)
        {
            ct[i] = Console.ReadLine().ToCharArray();
        }

        int result = 0;
        // 最大は2^(6+6) = 2^12で 4096通りなので計算量は大したことない
        for (int i = 0; i < (1 << H); i++)
        {
            for (int j = 0; j < (1 << W); j++)
            {
//                Console.WriteLine($"START: i={i},j={j}");

                int blakcs = 0;
                for (int x = 0; x < H; x++)
                {
                    if ((i >> x & 1) == 1)
                    {
//                        Console.WriteLine($"SKIP_X: x={x}");
                        continue;
                    }

                    for (int y = 0; y < W; y++)
                    {
//                        Console.WriteLine($"LOOP: x={x},y={y}");

                        if ((j >> y & 1) == 1)
                        {
//                            Console.WriteLine($"SKIP_Y: y={y}");
                            continue;
                        }

                        if (ct[x][y] == '#')
                        {
                            blakcs++;
                        }
                    }
                }


                if (blakcs == K)
                {
//                    Console.WriteLine($"i={i},j={j}, result++");
                    result++;
                }
            }
        }


        Console.WriteLine(result);
    }
}

Measured memory_bytes: 28180
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {if ((x+=a.x)>=MOD) x-=MOD; return *this;}
    mint& operator-=(const mint a) {if ((x+=MOD-a.x)>=MOD) x-=MOD; return *this;}
    mint& operator*=(const mint a) {(x*=a.x)%=MOD; return *this;}
    mint operator+(const mint a) const {mint res(*this); return res+=a;}
    mint operator-(const mint a) const {mint res(*this); return res-=a;}
    mint operator*(const mint a) const {mint res(*this); return res*=a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(MOD-2);}
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator/(const mint a) const {mint res(*this); return res/=a;}
};

const int cmax = 500010;
mint fac[cmax],finv[cmax],inv[cmax];

void com_init() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2; i<cmax; i++) {
        fac[i]=fac[i-1]*i;
        inv[i]=-inv[MOD%i]*(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

ll com(int n, int k) {
    if (n<k) return 0;
    if (n<0||k<0) return 0;
	mint ret=fac[n]*finv[k]*finv[n-k];
    return ret.x;
}

void solve() {
    ll n, m;
    cin >> n >> m;
    com_init();
    mint ans = 0, sign = 1;
    for(ll k = 0; k <= n; k++) {
        ans += sign * com(n, k) * fac[m - k] * finv[m - n];
        sign *= mint(-1);
    }
    ans *= fac[m] * finv[m - n];
    cout << ans.x << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

int main() {
	int n; cin >> n;
	
	long long cnt = 0;
	for (int i = 1; i <= n; ++i) {
		if (i%3 != 0 && i%5 != 0) {
			cnt += i;
		}
	}
	
	cout << cnt << endl;
	
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>

#define MAX 101

using namespace std;

int visited[MAX],d[MAX],f[MAX];
int tt=0;
vector<int> G[MAX];

void dfs(int u){
  d[u]=++tt;
  visited[u]=1;
  for(int i=0;i<G[u].size();i++){
    if(visited[G[u][i]]==0) dfs(G[u][i]);
  }
  f[u]=++tt;
}

int main(){
  int n; cin >> n;
  for(int i=1;i<=n;i++) visited[i]=0;
  for(int i=0;i<n;i++){
    int u,k; cin >> u >> k;
    for(int i=0;i<k;i++){
      int v; cin >> v;
      G[u].push_back(v);
    }
  }
  for(int i=1;i<=n;i++){
    if(visited[i]==0) dfs(i);
  }
  for(int i=1;i<=n;i++){
    cout << i << " " << d[i] << " " << f[i] << endl;
  }
}

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ll n; cin >> n;
	ll a[n],ans[n];
	map<ll,ll>v;
	for(int i=0; i<n; i++){
		cin >> a[i];
		v[a[i]]++;
		ans[i]=0;
	}
	ll total = 0;
	for(auto& x:v){
		total += x.se*(x.se-1)/2;
	}
	for(int i=0; i<n; i++){
		cout << max(ll(0),total-v[a[i]]+1) << endl;
	}
}	
/* Benq's
	stuff you should look for
	* ll, int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


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

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

    if (x < 1200)
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
    return 0;
}


Measured memory_bytes: 3636
l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

#print([chr(i) for i in range(97, 97+26)])

def adder(n, s, index):
    if (n == 0):
        print(s)
    else:
        #if(n == 1):
        for i in range(index +2):
            adder(n-1, s+l[i],max(i,index))


n = int(input())
#base =
if (n == 1):
    print("a")
elif (n == 2):
    print("aa")
    print("ab")
else:
    adder(n-1,"a",0)



Measured memory_bytes: 4412
import math

s = input()

N = len(s)
s = "#" + s
possible = 1
if s[-1] == "1" or s[1] == "0":
  possible = 0
for i in range(1,math.floor(N/2)):
  if s[i] != s[N - i]:
    possible = 0

if not possible:
  print(-1)
elif N == 2:
  if s[1] == "1" and s[2] == "0":
    print(1, 2)
  else:
    print(-1)
elif N == 3:
  if s[1] == "1" and s[2] == "1":
    print(1,2)
    print(2,3)
  else:
    print(-1)
else:
  destination = [1] * (N+1)
  dest_change = [0] * (N+1)
  root = 2
  max_bit = math.floor(N/2)
  for i in range(max_bit, -1, -1):
    if s[i] == "1":
      #destination = destination[:root+1] + [root]*(i-1) + destination[root+i:]
      dest_change[root + 1] = dest_change[root + 1] + 1
      dest_change[root + i] = dest_change[root + i] - 1
      root += 1
  for i in range(1,N+1):
    destination[i] = destination[i - 1] + dest_change[i]
  for i in range(2,N+1):
    print(i, destination[i])

Measured memory_bytes: 7724
#include<bits/stdc++.h>
using namespace std;
struct node{
long long d,g;
bool operator<(const node &w)
{
	if(d!=w.d)
		return d<w.d;
}
};
bool func(node k,int n)
{
if(k.d<=n)
	return false;
else return true;
}
int main()
{
int n,a,b;cin>>n>>a>>b;
if(n*a<b)
	cout<<n*a;
else cout<<b;
return 0;
}


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

using namespace std;

int main(){
  string s,t;
  int count=0;
  cin>>s>>t;
  int max=0;
  int s_size=s.size();
  int t_size=t.size();
  int icchi[s_size-t_size+1]={};
  for(int i=0;i<s_size-t_size+1;i++){
    for(int j=0;j<t_size;j++){
      if(s[j+count]==t[j]){
        icchi[i]+=1;
      }
    }
    count+=1;
  }
  for(int i=0;i<s_size-t_size+1;i++){
    if(icchi[i]>max){
      max=icchi[i];
    }
  }
  cout<<t_size-max<<endl;
  return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    int ans = 0;
    for(int i = 0; i < k; i++) ans += a[n-1-i];
    cout << ans;
}


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

int main() {
  int n;
  cin >> n;
  int sum = 0;
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    cin >> t.at(i);
    sum += t.at(i);
  }
  int m;
  cin >> m;
  vector<int> p(m);
  vector<int> x(m);
  for (int i = 0; i < m; i++) {
    cin >> p.at(i) >> x.at(i);
  }
  
  for (int i = 0; i < m; i++) {
    cout << sum - t.at(p.at(i) - 1) + x.at(i) << endl;
  }
}

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

int main(){
  int N, Q;
  string S;
  int l, r;
  cin >> N >> Q >> S;
  vector<int> acstock(N);
  int j=0;
  for(int i=0; i<N-1; i++){
    if(S[i]=='A' && S[i+1]=='C'){
      j++;
      acstock.at(i+1)=j;
    }
    else{
      j=j;
      acstock.at(i+1)=j;
    }
  }
  
 
  for(int i=0; i<Q; i++){
    cin >> l >> r;
    cout << acstock.at(r-1)-acstock.at(l-1) << endl;
  }
}


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

int main(){
  	int N, K;
  	cin >> N >> K;
  	int L[100];
  	int sum = 0;
  	for (int i = 0; i < N; i++){
      	cin >> L[i];
    }
  	sort(L, L + N, greater<int>());
  	for (int i = 0; i < K; i++){
      	sum += L[i];
    }
  	cout << sum << endl;
}


Measured memory_bytes: 256
//============================================================================
// Name        : ITP_1_3_D.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
	int a,b,c,div=0;
	cin >> a >> b >> c;
	for(int i=a;i<=b;++i) {
		if (c%i==0) ++div;
	}
	cout << div << endl;
	return 0;
}

Measured memory_bytes: 3092
import java.util.*;

class Main{

    public static void main(String args[]) throws Exception{
        Main main = new Main();
    }

    public Main(){
        Scanner scanner = new Scanner(System.in);
        int N,M;
        N = Integer.parseInt(scanner.next());
        M = Integer.parseInt(scanner.next());

        if(N == M){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define LL long long
#define R register int
using namespace std;
const int YL=1e9+7;
inline void M(R&x){if(x>=YL)x-=YL;}
int main(){
	R n;cin>>n;
	R f2=0,f1=n,f=(LL)n*n%YL,t=(LL)(n-1)*(n-1)%YL,s=0;
	for(R i=n-2;i>0;--i)
		M(s+=f2),f2=f1,f1=f,M(f+=t),M(f+=s+i+1);
	return cout<<f<<endl,0;
}

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

int main() {
    ll n;
    cin >> n;
    priority_queue<double, vector<double>, greater<double>> v;
    for(ll i = 0; i < n; i++){
        double vi;
        cin >> vi;
        v.push(vi);
    }
    for(ll i = 0; i < n - 1; i++){
        double temp = v.top();
        v.pop();
        double temp2 = v.top();
        v.pop();
        temp = (temp + temp2) / 2;
        v.push(temp);
    }
    printf("%.10f\n", v.top());
    

    
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
//#include <vector>
//#include <iostream>

typedef long long ll;
typedef unsigned long long ull;
double dp[601];
int N, M, blocked;
std::vector<int> s, t;
std::vector<std::vector<int>> pathes, inv_pathes;

#define MOD 1000000007
ll modinv(ll a, ll m) {
	ll b = m, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; std::swap(a, b);
		u -= t * v; std::swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

double dfs(int n) {
	if (dp[n] != -1)
		return dp[n];
	std::vector<int> out_pathes = pathes[n];

	int num_candidate = out_pathes.size();

	double temp_max=0.0;
	int argmax;
	if (n == blocked && num_candidate > 1) {
		for (int i = 0; i < num_candidate; i++) {
			if (temp_max < dp[out_pathes[i]]) {
				temp_max = dp[out_pathes[i]];
				argmax = i;
			}
		}
		out_pathes.erase(out_pathes.begin()+argmax);
	}
	double temp = 0.0;
	for (int i = 0; i < out_pathes.size(); i++) {
		//printf("n:%d, caindidate:%d\n", n, out_pathes[i]);
		temp += (dfs(out_pathes[i]) + 1.0) / out_pathes.size();
	}
	dp[n] = temp;
	return dp[n];
}

void Main()
{
	std::cin >> N >> M;
	s.resize(M);
	t.resize(M);
	pathes.resize(N+1);
	inv_pathes.resize(N+1);
	for (int i = 0; i < N; i++) {
		pathes[i].resize(0);
		inv_pathes[i].resize(0);
	}
	for (int i = 0; i < M; i++) {
		std::cin >> s[i] >> t[i];
		pathes[s[i]].push_back(t[i]);
		inv_pathes[t[i]].push_back(s[i]);
	}
	double ans = 100000000000;
	for (blocked = N - 1; blocked >= 1; blocked--)
	{
		for (int i = 0; i < N; i++)
			dp[i] = -1;

		dp[N] = 0;
		for (int i = N; i >= 1; i--)
		{
			dfs(i);
		}
		ans = std::min(ans, dp[1]);
	}
	std::cout << ans << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 3968
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int solve(){
    ll x, cur = 0, i = 0;
    cin >> x;
    while(cur < x){
        cur += ++i;
    }
    return i;
}

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

    cout << solve() << "\n";
    
    return 0;
}

Measured memory_bytes: 256
def main():
    L, R, d = input_ints()

    print(len([True for i in range(L, R+1) if i % d == 0]))




def input_ints():
    line_list = input().split()

    if len(line_list) == 1:
        return int(line_list[0])
    else:
        return map(int, line_list)


def input_int_list_in_line():
    return list(map(int, input().split()))


def input_int_tuple_list(n: int):
    return [tuple(map(int, input().split())) for _ in range(n)]


main()


Measured memory_bytes: 9096
from itertools import combinations as comb
from collections import Counter


def main():
    n = int(input())
    ss = [input()[0] for _ in range(n)]
    marchs = ['M', 'A', 'R', 'C', 'H']
    ssc = Counter(ss)

    Counts = []
    for march in marchs:
        if march in ssc:
            Counts.append(ssc[march])

    ans = 0
    for a, b, c in comb(Counts, 3):
        ans += a*b*c
    print(ans)


if __name__ == "__main__":
    main()


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

int main(){
  int n,u,k,v;
  int A[101][101];

  cin>>n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++) A[i][j]=0;
  }
  
  for(int i=0;i<n;i++){
    cin>>u;
    cin>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      A[u-1][v-1]=1;
    }
  }

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j!=0) cout<<" ";
      cout<<A[i][j];
    }
    cout<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 1200
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define LLD "%I64d"
#else
#define LLD "%lld"
#endif
#define fu(a,b,c) for(int a=b;a<=(int)c;++a)
#define fd(a,b,c) for(int a=b;a>=(int)c;--a)
#define cu(a,b,c) for(int a=b;a<(int)c;++a)
#define cd(a,b,c) for(int a=(b)-1;a>=(int)c;--a)
#define gcd(a,b) __gcd(a,b) 
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pf push_front
#define uint unsigned int
#define MOD 998244353
#define MAXN 200005
#define MAXH 4
#define MAXM 100
#define INF 1LL << 30
#define ll long long
#define ull unsigned long long
#define RNG mt19937
#define udist(a,b) uniform_int_distribution<uint32_t> distribution(a,b)
#define max3(a,b,c) max(a, max(b, c))
#define min3(a,b,c) min(a, min(b, c))
#define gmax(a,b) a = max(a, b)
#define gmin(a,b) a = min(a, b)
#define whatis(x) cerr << #x << " is " << x << endl;
#define fast_io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define PI 3.1415926535897932384626433
using namespace std;

int main(){
	fast_io();
	string s;cin >> s;
	int n = s.length();
	bool valid = s[n-1] == '0' && s[0] == '1';
	cu(i,0,n-1){
		if(s[i] != s[n-2-i])valid = false;
	}
	if(valid){
		int cur = 1, mx = 1, pri = n;	
		vector<pii> edges;
		cd(i,n,0){
			if(s[i] == '1'){
				int ones = pri - (i + 1) - 1;
				while(ones--){
					edges.pb({cur, ++mx});	
				}
				edges.pb({cur,++mx});
				cur = mx;
				pri = i + 1;
			}
		}
		cu(i,0,edges.size()){
			cout << edges[i].F << ' ' << edges[i].S << '\n';
		}
	}
	else{
		cout << -1 << '\n';
	}
}


Measured memory_bytes: 2372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i< (n) ; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main(){
  int n,m,ans;
  cin >> n >> m;
  ans=n%2+m%2;
  if(ans<2) {
    printf("Even");
  }
  else{
    printf("Odd");
  }
  //cout << n <<endl;
    return 0;
}


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

#include<stdio.h>

int main() {
	int a,b=0;
	int d,r=0;
	double f=0.0;

	cin >> a >>b;
	d = a / b;
	r = a % b;
	f = (1.0 * a) / b;

	
	cout << d <<" "<< r <<" ";
	printf("%lf\n",f);
  return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	int n,t;
	cin>>n>>t;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<int> mis(n);
	mis[n-1] = a[n-1];
	for(int i=n-2;i>=0;i--){
		mis[i] = max(mis[i+1],a[i]);
	}
	int mx = 0;
	for(int i=0;i<n-1;i++){
		mx = max(mx, mis[i+1] - a[i]);
	}
	int cnt =0;
	for(int i=0;i<n-1;i++){
		if(mx == mis[i+1] - a[i]) cnt += 1;
	}

	cout<<cnt<<endl;

	
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;	
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
//vector<int> is passed by &
#define maxstones 100000

int dp[maxstones];
vector<int> heights;

int getMinCost(int S, int K)
{
	if(S==0)
		return 0;

	if(dp[S]!=-1)
		return dp[S];

	//you are on the stone S
	//you can reach here only from maximum K left to this position. Since you have reached here 
	//you must have taken the least cost path.
	int cost=INT_MAX;
	for(int i=1;i<=K;i++)
	{
		int t = getMinCost(S-i,K) + abs(heights[S]-heights[S-i]);
		if(t<cost)
			cost=t;
		if(S==i)
			break;
	} 
	return dp[S]=cost;
}


int main()
{
    for(int i=0;i<maxstones;i++)
        dp[i]=-1;

    int n,k;
    cin >> n >> k;
    int t;
    for(int i=0;i<n;i++)
    {
        cin >> t;
        heights.push_back(t);
    }
    
    cout << getMinCost(n-1,k) <<endl;
    return 0;
}

Measured memory_bytes: 12012
S = input()
work=list(S)
i=0
o_cout=0
z_cout=0
for x in work:
    if(x=='1'):
        o_cout+=1
    else:
        z_cout+=1
    
if(o_cout>z_cout):
    cout=z_cout
else:
    cout=o_cout
    

print(cout*2)

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


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"  //インタラクティブで消す！！！！！！！！！！！！！！！！！！！！！
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            //cout<<x<<"/"<<y;
            cout<<setprecision(5)<<(dd)x/(dd)y;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////



int main(){fastio
    ll a;cin>>a;
    cout<<a+a*a+a*a*a;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 1e16
#define mod 1000000007LL

typedef vector<ll> vec;
typedef vector<vec> mat;

mat operator*(const mat& a,const mat& b){
  mat res(4,vec(4,0));
  const ll modl=8*mod*mod;
  rep(i,4){
    rep(k,4){
      rep(j,4){
        res[i][j]+=a[i][k]*b[k][j];
        if(res[i][j]>=modl)res[i][j]-=modl;
      }
    }
    rep(j,4)res[i][j]%=mod;
  }
  return res;
}

mat mpow(mat a,ll n){
  mat res(4,vec(4,0));
  rep(i,4)res[i][i]=1;
  while(n>0){
    if(n&1)res=res*a;
    a=a*a;
    n>>=1;
  }
  return res;
}

ll pls[4][4]={
  {1, 0, 1, 0},
  {0, 0, 0, 1},
  {0, 0, 0, 0},
  {0, 0, 0, 1},
};

ll mns[4][4]={
  {1, 0, 1, 0},
  {0, 0, 0, mod-1},
  {0, 0, 0, 0},
  {0, 0, 0, 1},
};

ll mul[4][4]={
  {1, 0, 0, 0},
  {0, 0, 1, 0},
  {0, 0, 0, 0},
  {0, 0, 0, 1},
};

ll num[4][4]={
  {1, 0, 0, 0},
  {0, 1, 0, 0},
  {0, 0, 10, 0},
  {0, 0, 0, 1},
};

int N;

int main(){
  scanf("%d",&N);
  vector<int> ps(N);
  vector<string> rs(N);
  rep(i,N){
    cin>>ps[i]>>rs[i];
  }
  ps.push_back(1); rs.push_back("+"); N++;
  mat crt(4,vec(4,0));
  rep(i,4)crt[i][i]=1;

  rep(i,N){
    mat m(4,vec(4,0));
    rep(j,4)m[j][j]=1;
    rep(j,rs[i].size()){
      mat op(4,vec(4,0));
      if(rs[i][j]=='+'){
        rep(k,4)rep(l,4)op[k][l]=pls[k][l];
      }
      if(rs[i][j]=='-'){
        rep(k,4)rep(l,4)op[k][l]=mns[k][l];
      }
      if(rs[i][j]=='*'){
        rep(k,4)rep(l,4)op[k][l]=mul[k][l];
      }
      if(isdigit(rs[i][j])){
        rep(k,4)rep(l,4)op[k][l]=num[k][l];
        op[2][1]=rs[i][j]-'0';
      }
      m=op*m;
    }
    m=mpow(m,ps[i]);
    crt=m*crt;
  }

  cout<<(crt[0][1]+crt[0][3])%mod<<endl;
  return 0;
}



Measured memory_bytes: 3952
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten53 300005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;

vector<ll> vll[11];
ll num[ten52];

int main(void)
{
    ll m,n,i,j,k=1,d=0,sum=0,judge;
    string s,s1;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>k;
        for(j=0;j<k;j++)
        {
            cin>>d;
            d--;
            vll[i].pb(pow(2,d));
        }
    }
    for(i=0;i<m;i++)
        cin>>num[i];
    for(i=0;i<pow(2,n);i++)
    {
        for(j=0;j<m;j++)
        {
            d=judge=0;
            for(k=0;k<vll[j].size();k++)
                if((i&vll[j][k])==vll[j][k])
                    d++;
            //cout<<i<<'-'<<j<<'-'<<d<<endl;
            if((d&1)!=num[j])
            {
                judge=1;
                break;
            }
        }
        if(!judge)
            sum++;
    }
    cout<<sum;
    return 0;
}


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

int main() {
    string s;
    cin >> s;
    auto judge = [&]() {
        int n = s.size();
        if (n % 2 == 1) return false;
        return s.substr(0, n / 2) == s.substr(n / 2);
    };
    while (!s.empty()) {
        s.pop_back();
        if (judge()) {
            cout << s.size() << endl;
            break;
        }
    }
}


Measured memory_bytes: 256
import sys
import time

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    import numpy as np
    l, a, b, m = list(map(int, readline().split()))
    d_min = len(str(a))
    d_max = len(str(a + (l - 1) * b))
    count_d = [-1] * 19

    prev = -1
    for i in range(d_min, d_max + 1):
        power = 10 ** i
        ok = 0
        ng = l + 1
        while abs(ng - ok) > 1:
            mid = (ok + ng) // 2
            x = a + mid * b
            if x < power:
                ok = mid
            else:
                ng = mid
        ok = min(ok, l - 1)
        count_d[i] = ok - prev
        prev = ok

    res = np.array([0, a, 1], dtype="int64")
    res = np.mod(res, m)

    for i in range(19):
        count = count_d[i]
        if count == -1:
            continue
        mat = np.array([[10 ** i, 0, 0],
                        [1, 1, 0],
                        [0, b, 1]], dtype="int64")
        mat = np.mod(mat, m)
        cur = np.eye(3, dtype="int64")
        count_bit = format(count, "b")
        for bit in count_bit[::-1]:
            if bit == "1":
                cur = np.dot(cur, mat)
                cur = np.mod(cur, m)
            mat = np.dot(mat, mat)
            mat = np.mod(mat, m)
        res = np.dot(res, cur)
        res = np.mod(res, m)

    print(res[0])


if __name__ == '__main__':
    main()


Measured memory_bytes: 22156
string = input()

moji_list = [0 for _ in range(4)]
for i in range(4):
    moji_list[i] = string[i]

ue = ''
sita = ''
for j in range(2):
    ue += moji_list[j]
    sita += moji_list[j+2]

int_ue = int(ue)
int_sita = int(sita)

sw_ue = 0
sw_sita = 0
if 1<=int_ue and int_ue<=12:
    sw_ue += 1

if 1<=int_sita and int_sita<=12:
    sw_sita += 1

if sw_ue == 1 and sw_sita == 1:
    print('AMBIGUOUS')
elif sw_ue == 1 and sw_sita == 0:
    print('MMYY')
elif sw_ue == 0 and sw_sita == 1:
    print('YYMM')
elif sw_ue == 0 and sw_sita == 0:
    print('NA')

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

void up(pair<int, int> &a, pair<int, int> b) { if (a.first * b.second <= a.second * b.first)a = b; }

int main(){
	int a, b, c, d, e, F;
	scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &F);
	pair<int, int> an(0, 100);
	f(i, 0, 31)f(j, 0, 31)f(k, 0, 3001){
		int wsz = i * a * 100 + j * b * 100;
		int s = k * c;
		if (wsz * e < s * 100)continue;
		if (wsz + s > F)continue;
		int lft = min(F - wsz - s, wsz / 100 * e - s);
		int ns = lft / d * d;
		pair<int, int> z(s + ns, s + ns + wsz);
		up(an, z);
	}
	printf("%d %d\n", an.second, an.first);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int[] C = new int[N];
		int[][] A = new int[N][M];
		int[] S = new int[M];
		int ans = 0;
		for (int j = 0; j < M; j++) {
			S[j] = 0;
		}
		for (int i = 0; i < N; i++) {
			C[i] = sc.nextInt();
			for (int j = 0; j < M; j++) {
				A[i][j] = sc.nextInt();
				S[j] += A[i][j];
			}
			ans += C[i];
		}

		if (!overX(S, X)) {
			System.out.println("-1");
			return;
		}

		for (int i = 0; i < Math.pow(2, N); i++) {
			for (int j = 0; j < M; j++) {
				S[j] = 0;
			}
			String bin = Integer.toBinaryString(i);
			bin = String.format("%" + N + "s", bin).replace(" ", "0");
			int cost = 0;
			for (int j = 0; j < N; j++) {
				if (bin.charAt(j) == '1') {
					for (int k = 0; k < M; k++) {
						S[k] += A[j][k];
					}
					cost += C[j];
				}
			}
			if (overX(S, X) && cost < ans) {
				ans = cost;
			}
		}
		System.out.println(ans);
	}

	public static boolean overX(int[] S, int X) {
		for (int i = 0; i < S.length; i++) {
			if (S[i] < X) {
				return false;
			}
		}
		return true;
	}

}


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

int main(){
char a,b,c;
cin>>a>>b>>c;
if(a=='A'&&b=='A'&&c=='A'){
  cout<<"No"<<endl;
}else{
  if(a=='B'&&b=='B'&&c=='B')
  cout<<"No"<<endl;
else{
  cout<<"Yes"<<endl;
}
}
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Char8 as B
import Control.Monad
import Data.List
import qualified Data.Vector.Unboxed as UV

main=do
    [h,w] <- map read.words<$>getLine
    bx <- B.lines <$> B.getContents
    print $ f w bx

f w !bx = UV.last $ foldl' p (UV.cons 1 $ UV.replicate (w-1) (0::Int)) bx where
    p !v0 bl = UV.constructN w m where
        m v1
            | B.index bl l == '#' = 0
            | l == 0 = UV.head v0
            | otherwise = (UV.last v1 + v0 UV.! l) `mod` (10^9+7)
            where l = UV.length v1

Measured memory_bytes: 2940
#include  <cmath>
#include  <fstream>
#include  <iostream>
#include <algorithm>

using namespace std;

int main(void)
{
    // count the number of i, which is the minimum value among values from P_1 to P_i

    int tmp_i;
    cin >> tmp_i;
    const int N = tmp_i;
    int value;

    //define min
    cin >> value;
    int min = value;
    int N_minimum = 1; // P_1

    for(int i=1; i<N; i++)
    {
        cin >> value;
        if(min > value)
        {
            min = value;
            N_minimum ++;
        }
    }

    cout << N_minimum << endl;



    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

template<class T, class S>
bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S>
bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}


int main(){
    int A, B, N; cin >> N >> A >> B;
    cout << (((B-A)%2) ? "Borys" : "Alice") << endl;
    return 0;
}


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

ct=[list(map(int,input().split())) for i in range(N)]

LIST=[]
for i in ct:
    if i[1]<=T:
        LIST.append(i[0])

if LIST==[]:
    print("TLE")

else:
    LIST.sort()
    print(LIST[0])

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

int ans,n,cur;
vector <int> w;

int main(){
    scanf ("%d\n",&n);
    w.resize(n);
    cur = 0;
    ans = 1000000000;
    for (int i = 0; n > i; i++){
        scanf ("%d",&w[i]);
        if (i != n-1) scanf (" ");
        cur += w[i];
    }
    ans = min(ans,cur);
    for (int i = 0; n > i; i++){
        cur -= 2*w[i];
        ans = min(ans,abs(cur));
    }
    printf ("%d",ans);
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    private static class Data {
        public int key;
        public Data next;
        public Data prev;
     
        public Data(int key) {
            this.key = key;
            this.next = null;
            this.prev = null;
        }
    }
 
    private static class DoublyLinkedList {
        private Data dummy;
        private Data last;
         
        public DoublyLinkedList() {
            this.dummy = new Data(-1);
            this.dummy.next = this.dummy;
            this.dummy.prev = this.dummy;
            this.last = this.dummy;
        }
         
        public void print() {
            Data data = this.dummy.next;
            StringBuilder sb = new StringBuilder();
            sb.append(data.key);
 
            data = data.next;
            while(data.key!= this.dummy.key) {
                sb.append(" ");
                sb.append(data.key);
                data = data.next;
            }
            System.out.println(sb.toString());
        }
         
        public void insert(int key) {
            Data data = new Data(key);
            data.next = this.dummy.next;
            data.prev = this.dummy;
            data.next.prev = data;
            this.dummy.next = data;
        }
         
        public void delete(int key) {
            for(Data data = this.dummy.next; data.key != this.dummy.key; data = data.next) {
                if(data.key == key) {
                    data.prev.next = data.next;
                    data.next.prev = data.prev;
                    break;
                }
            }
        }
         
        public void deleteFirst() {
            Data newFirst = this.dummy.next.next;
            this.dummy.next = newFirst;
            newFirst.prev = this.dummy;
        }
 
        public void deleteLast() {
            Data newLast = this.last.prev.prev;
            this.last.prev = newLast;
            newLast.next = this.last;
        }
    }
 
    public static void main(String[] args) throws Exception {
        // Here your code !
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        DoublyLinkedList list = new DoublyLinkedList();
         
        for(int i = 0; i < n; i++) {
            String[] commands = br.readLine().split(" ");
 
            if(commands[0].equals("insert")) {
                int x = Integer.parseInt(commands[1]);
                list.insert(x);
 
            } else if(commands[0].equals("delete")) {
                int x = Integer.parseInt(commands[1]);
                list.delete(x);
 
            } else if(commands[0].equals("deleteFirst")) {
                list.deleteFirst();
 
            } else if(commands[0].equals("deleteLast")) {
                list.deleteLast();
            }
        }
         
        list.print();
    }
}

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

typedef long long ll;
const int N = 2e5;
int mod[N+100],cnt[10010];
char str[N+100];
ll ans;

int main()
{
	int n,p;
	scanf("%d%d%s",&n,&p,str);
	if(p==2){
		for(int i=n-1;i>=0;i--){
			if(((str[i]-'0')&1)==0){
				ans += (i+1);
			}
		}
	}
	else if(p==5){
		for(int i=n-1;i>=0;i--){
			if((str[i]-'0')==0||(str[i]-'0')==5){
				ans += (i+1);
			}
		}
	}
	else{
		mod[0] = 1;
		for(int i=1;i<=N;i++){
			mod[i] = (mod[i-1]*10)%p;
		}
		int cur = 0;
		cnt[0] = 1;
		for(int i=n-1;i>=0;i--){
			int t1 = (mod[n-1-i]*(str[i]-'0'))%p;
			cur = (cur+t1)%p;
			//printf("%d %d\n",i,cur);
			ans += cnt[cur];
			cnt[cur]++;
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 4728
package main

import "fmt"

func gcd(x, y int64) int64 {
	for y != 0 {
		r := x % y
		x = y
		y = r
	}
	return x
}

func lcm(x, y int64) int64 {
	return x / gcd(x, y) * y
}

func main() {
	var n, i, ans int64
	fmt.Scan(&n)

	ans = 1

	for i = 0; i < n; i++ {
		var t int64
		fmt.Scan(&t)
		ans = lcm(ans, t)
	}
	fmt.Println(ans)
}

Measured memory_bytes: 512
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_C
#include <iostream>
using namespace std;

bool isEven(int n){
  if(n % 2 ==0) return true;
  else return false;
}

void write_sh(int n){
  //#???????§???????
    for(int i = 0; i< n/2; i++){
      cout << "#.";
    }
    if(isEven(n)){
      cout << endl;
    }
    else{
      cout << "#" << endl;
    }
}

void write_dot(int n){
  //.???????§???????
    for(int i = 0; i < n/2; i++){
      cout << ".#";
    }
    if(isEven(n)){
      cout << endl;
    }
    else{
      cout << "." << endl;
    }
}

int main(){
  int H, W;
  while (cin >> H >> W) {
    if(H == 0 && W == 0){
      break;
    }
    else{
        for(int i = 0; i < H/2; i++){
          write_sh(W);
          write_dot(W);
        }
        if(isEven(H+1)){
          write_sh(W);
        }
      }
      cout << endl;
    }
}

Measured memory_bytes: 1152