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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  ll ans=k;
  rep(i,n-1) ans*=(k-1);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
int main(){
	char a[5];
	scanf("%c%c%c\n",&a[0],&a[1],&a[2]);
    scanf("%c%c%c",&a[3],&a[4],&a[5]);
    if (a[0]==a[5]&&a[1]==a[4]&&a[2]==a[3])
    	printf("YES\n");
    	else
    		printf("NO\n");
	
	
	return 0;
	
	}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		System.out.println(LIS(a));
	}
	//Longest Increasing Sequence
	//?????????:LIS?????????
	//??????????¢??????°?????§???????????¨?????¨????????????
	int LIS(int[] a){
		int n=a.length;
		ArrayList<Integer> list=new ArrayList<>();
		for(int i=0;i<n;i++){
			if(list.isEmpty()||a[i]>list.get(list.size()-1)){
				list.add(a[i]);
			}else if(list.get(list.size()-1)==a[i]){
				continue;
			}else{
				//a[i]????????§?????????????????°???????????????(???????????¨)???
				int first=0;
				int last=list.size()-1;
				while(first+1!=last&&!(first==0&&last==0)){
					int mid=(first+last)/2;
					if(list.get(mid)>a[i]){
						last=mid;
					}else{
						first=mid;
					}
				}
				if(list.get(first)>a[i]){
					list.set(first, a[i]);
				}else if(list.get(first)!=a[i])
					list.set(last, a[i]);
			}
		}
		return list.size();
	}
}

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

int m, d;
int res;

int main()
{
    cin >> m >> d;
    for (int i = 1; i <= m; i++)
        for (int a = 2; a <= 9; a++)
            for (int b = 2; b <= 9; b++)
                if (10 * a + b <= d && a * b == i)
                    res++;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll test,i,j,n;
    cin>>n;
    j=0;
    while(n>0)
    {
        if(n%10==7)j=1;
        n/=10;
    }
    if(j)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3632
N = int(input())
A = list(map(int, input().split()))

def simulate_operation(tgt_list):
  answer = 0
  N = len(tgt_list)
  previous_sum = tgt_list[0] # total to i - 1
  for i in range(1, N):
    # if prev_sum is plus and tgt_lis[i] is more minus than prev_sum, no action.
    # if prev_sum is plus and minus of tgt_lis[i] is larger than or equal to prev_sum.
    if previous_sum > 0 and previous_sum + tgt_list[i] >= 0:
      # the number that need to be subtracted to meet the requirements.
      require_subtraction = previous_sum + tgt_list[i] + 1
      # correcting the current number.
      tgt_list[i] -= require_subtraction
      answer += require_subtraction
    # if prev_sum is minus and tgt_lis[i] is more plus than prev_sum, no action.
    # if prev_sum is minus and minus of tgt_lis[i] is more smaller than or equal to prev_sum.
    elif previous_sum < 0 and previous_sum + tgt_list[i] <= 0:
      # the number that need to be added to meet the requirements.
      require_addition = -(previous_sum + tgt_list[i] - 1)
      # correcting the current number.
      tgt_list[i] += require_addition
      answer += require_addition
    previous_sum += tgt_list[i]
  return answer

ans_list = []
# simulate two options of starting with a positive or negative.
# positive, the first item is 1.
ans_pos = 0
A_pos = A[:]
init_cost = A_pos[0] - 1
ans_pos += abs(init_cost)
A_pos[0] -= init_cost
ans_pos += simulate_operation(A_pos)
ans_list.append(ans_pos)
# negative, the first item is -1.
ans_neg = 0
A_neg = A[:]
init_cost = A_neg[0] + 1
ans_neg += abs(init_cost)
A_neg[0] -= init_cost
ans_neg += simulate_operation(A_neg)
ans_list.append(ans_neg)
# simulate straight
ans_straight = 0
if A[0] != 0:
  ans_straight = simulate_operation(A)
  ans_list.append(ans_straight)

print(min(ans_list))

Measured memory_bytes: 14468
n = int(input())
s = input()
t = input()
cnt = 0
# for i in range(len(s)):
#     if s[-i-1] == t[i]:
#         #print(s[-i],t[i])
#         cnt += 1
#     else:
#         break
ans = 0
for i in range(len(s)):
    if s[i] == t[cnt]:
        cnt += 1
    elif s[i] != t[cnt] and s[i] == t[0]:
        ans = max(ans,cnt)
        cnt = 1
    else:
        ans = max(ans,cnt)
        cnt = 0
print(n + n - cnt)


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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s; cin >> s;
    int n = s.length();

    ll ans = 0;
    for (int S = 0; S < (1 << (n - 1)); S++) {
        ll res = s[0] - '0';
        for (int i = 0; i < n - 1; i++) {
            if (S & (1 << i)) {
                ans += res;
                res = s[i + 1] - '0';
            } else {
                res = res * 10 + (s[i + 1] - '0');
            }
        }
        ans += res;
    }

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


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

int main() {
  	ll N, W;
	cin >> N >> W;
  	vector<pair<ll,ll> > items;
  	ll vsum = 0;
  
  	for(ll i=0;i<N;i++) {
      	ll w, v;
      	cin >> w >> v;
  		items.push_back({w, v});  
      	vsum += v;
    }
  	
  	vector<vector<ll> > dp(N+1, vector<ll>(vsum+1, -1));
  	for(ll i=0 ; i<=N ; i++)
      	dp[i][0] = 0;
  	
  	for(ll i = 1 ; i <= N ; i++){
    	for(ll j = 1 ; j <= vsum ; j++) {
          	ll cur_wt = items[i-1].first;
          	ll cur_val = items[i-1].second;
          
        	if(j - cur_val >= 0
              	and dp[i-1][j - cur_val] != -1) { // valid index
              
            	dp[i][j] = dp[i-1][j - cur_val]
                  				+ cur_wt;
            }
          	else {
            	dp[i][j] = dp[i-1][j];
            }
          	
          	if(dp[i][j]!=-1 and dp[i-1][j]!=-1)
              	dp[i][j] = min(dp[i][j], dp[i-1][j]);
        }
    }
  	
  	//for(auto row: dp){
    	//for(auto i:row)
          //	cout<<i<<"\t";
      	//cout<<endl;
    //}
  
	for(ll i =  dp[0].size()-1 ; i>=0 ; i--) {
    	if(dp[N][i] <= W and dp[N][i] !=-1 ) {
          	cout<< i <<endl;
          	return 0;
        }
    }
  
  	cout<<0<<endl;
  
  	return 0;
}

Measured memory_bytes: 80256
import numpy as np
H=input()
H=int(H)

def count(H):
	count=1
	while True:
		if int(H/2)==0:
			break
		else:
			H=int(H/2)
			count+=1
			continue
	return count

A=0
for i in range(int(count(H))):
	A+=2**i
			
print(A)

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

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

using namespace std;

typedef long long ll;

int main()
{
    string S;
    cin >> S;
    int front = 0, back = 0;
    string cpFront = S, cpBack = S;
    for (int i = 1; i < S.size(); ++i)
    {
        if (cpFront[i] == cpFront[i - 1])
        {
            front++;
            if (cpFront[i] == '0') cpFront[i] = '1';
            else cpFront[i] = '0';
        }
    }
    for (int i = S.size() - 2; i >= 0; --i)
    {
        if (cpBack[i] == cpBack[i + 1])
        {
            back++;
            if (cpBack[i] == '0') cpBack[i] = '1';
            else cpBack[i] = '0';
        }
    }
    cout << min(front, back) <<endl;
}


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

struct Benri {
    Benri() {
        std::cin.tie(0); ios::sync_with_stdio(false);
        cout << fixed << setprecision(12);
    }
} benri;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define MOD 1000000007
#define MOD2 998244353
const int INF = 1 << 28;


int main() {
    int N,T; cin >> N >> T;
    bool can = false;
    set<int> S;
    rep(i,N){
        int c,t; cin >> c >> t;
        if(t <= T){
            can = true;
            S.insert(c);
        }
    }

    if(can) cout << *S.begin() << endl;
    else cout << "TLE" << endl;

}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string S;cin>>S;
    vector<string>vec;
    int K;cin>>K;
    rep(i,S.size()){
        for(int j=1;j<=5&&i+j<=S.size();j++)vec.pb(S.substr(i,j));
    }
    sort(all(vec));vec.erase(unique(all(vec)),vec.end());
    cout<<vec[K-1]<<endl;
    return 0;
}


Measured memory_bytes: 1660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		boolean[] p = new boolean[31];
		while ((line = br.readLine()) != null) {
			p[Integer.parseInt(line)] = true;
		}
		for (int i = 1; i < 31; i++) {
			if (!p[i])
				System.out.println(i);
		}
	}
}

Measured memory_bytes: 16864
import java.util.BitSet;
import java.util.LinkedList;
import java.util.Scanner;

public class Main{
	public static String[] token;
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int n = in.nextInt();
			if(n == 0) return;
			int depth = 1;
			token = new String[n];
			token[0] = in.next();
			Node[] node = new Node[n];
			node[0] = new Node(0, null, 0);
			Node parent = node[0];
			for(int i=1; i<n; i++){
				token[i] = in.next();
				int dot = parse(i);
				if(depth < dot){
					parent = parent.edge.getLast();
					depth++;
				}
				while(depth > dot){
					parent = parent.parent;
					depth--;
				}
				parent.createEdge(new Node(i, parent, depth));
			}
			dfs(node[0], new BitSet(n));
		}
	}
	
	public static void dfs(Node parent, BitSet bs){
		parent.out(bs);
		bs.set(parent.depth);
		for(Node v: parent.edge){
			if(v == parent.edge.getLast()){
				bs.clear(parent.depth);
			}
			dfs(v, bs);
		}
	}
	
	public static int parse(int id){
		int dot = 0;
		while(token[id].charAt(dot) == '.') dot++;
		token[id] = token[id].substring(dot, token[id].length());
		return dot;
	}
}

class Node{
	int id;
	Node parent;
	LinkedList<Node> edge;
	int depth;
	public Node(int id, Node parent, int depth){
		edge = new LinkedList<Node>();
		this.id = id;
		this.parent = parent;
		this.depth = depth;
	}
	
	public void createEdge(Node nd){
		edge.add(nd);
	}
	
	public void out(BitSet bs){
		StringBuilder sb = new StringBuilder();
		for(int i=0; i<depth; i++){
			if(i==depth-1){
				sb.append('+');
			}else if(bs.get(i)){
				sb.append('|');
			}else sb.append(' ');
		}
		sb.append(Main.token[id]);
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 75380
#include<stdio.h>

int main()
{
	int n;
	int iData[1000];
	int iCount;

	scanf("%d", &n);
	for (iCount = 0; iCount < n; iCount++)
	{
		scanf("%d", &iData[iCount]);
	}

	for (iCount = n - 1; iCount > 0; iCount--)
	{
		printf("%d ",iData[iCount]);
	}

	printf("%d", iData[0]);

	printf("\n");
}


Measured memory_bytes: 2040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <iomanip>
#include <cassert>
#include <random>


int main() {
    int L; std::cin >> L;
    std::vector<long long> a(L + 2);
    for (int i = 1; i <= L; i++) std::cin >> a[i];
    std::vector<std::vector<long long>> dp(5, std::vector<long long>(L + 2));
    for (int i = 1; i <= L; i++) dp[0][i] = dp[0][i - 1] + a[i];
    for (int i = 1; i < 4; i++) {
        for (int j = 1; j <= L; j++) {
            int r = i & 1 ? (a[j] & 1) + 2 * (a[j] == 0) : ~a[j] & 1;
            dp[i][j] = std::min(dp[i - 1][j], dp[i][j - 1] + r);
        }
    }
    for (int i = 1; i <= L; i++) {
        dp[4][i] = std::min(dp[3][i], dp[4][i - 1] + a[i]);
    }
    std::cout << dp[4][L] << std::endl;
    return 0;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int a, b;
    cin >> a >> b;
    if((a + b) % 2) cout << "IMPOSSIBLE";
    else cout << (a + b) / 2;
    return 0;
}


Measured memory_bytes: 256
def 解():
    iN = int(input())
    iD = 10**9 + 7

    if iN < 3:
        print(iN)
        exit()

    aS = [1]*(iN+1)
    dP={}
    for i in range(2,iN+1):
        if aS[i]:
            dP[i] = 1
            for j in range(i*2,iN+1,i):
                aS[j] = 0

    for i in range(2,iN+1):
        for iP in dP:
            while i % iP == 0:
                dP[iP]+=1
                i //= iP
            if i == 1:
                break
    iAns = 1
    for iP in dP:
        iAns *= dP[iP]
        iAns %= iD
    print(iAns)
解()


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

int main() {
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};
    string s;
    cin >> s;

    reverse(s.begin(), s.end());
    for(int i=0;i<4;i++) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for(int i=0;i<s.size();){
        bool can2 = false;
        for(int j=0;j<4;j++){
            string d = divide[j];
            if(s.substr(i, d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }
    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long a = Long.parseLong(in.next());
            long b = Long.parseLong(in.next());
            long n = Long.parseLong(in.next());
            long ans = 0;
            if (n >= b) {
                ans = f(a, b, b - 1);
            } else {
                ans = f(a, b, n);
            }

            out.println(ans);

        }

        public static long f(long a, long b, long x) {
            long res = 0;
            res = (long) (Math.floor(a * x / b) - a * Math.floor(x / b));
            return res;
        }

    }
}



Measured memory_bytes: 35760
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto A = new long[][][](N);
	foreach (i; 0..N)
	{
		auto M = RD;
		foreach (j; 0..M)
		{
			auto x = RD-1;
			auto y = RD;
			A[i] ~= [x, y];
		}
	}

	long ans;
	foreach (i; 0..2^^N)
	{
		bool ok = true;
		long cnt;
		(){
		foreach (j; 0..N)
		{
			auto bit = 1L << j;
			if ((i & bit) == 0) continue;
			++cnt;
			foreach (e; A[j])
			{
				auto x = e[0];
				auto y = e[1];
				auto state = (i >> x) & 1; 
				if (state != y)
				{
					ok = false;
					return;
				}
			}
		}}();
		if (ok)
		{
			debug writeln("i:", i);
			ans.chmax(cnt);
		}
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

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

#define Pi 3.14159265358979323846

int main()
{
    float a, b, h, m;

    cin >> a >> b >> h >> m;
    cout << setprecision(16);
    cout << fixed;
    cout << sqrt(a*a + b*b - 2*a*b*cos(abs(11*m -60*h)*Pi/360.0));


 return 0;
}


Measured memory_bytes: 4192
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

int main(){
  ll n,ans = 0;
  cin >> n;
  for(ll i=1;i<=n;i++){
    if(i%3 != 0 && i%5 != 0){
      ans += i;
    }
  }

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


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<long long> a(N);
	for (int i = 0; i < N; i++){
		cin >> a[i];
	}
	long long S = 0;
	for (int i = 0; i < N; i++){
		S ^= a[i];
	}
	vector<long long> b(N);
	for (int i = 0; i < N; i++){
		b[i] = a[i] ^ (a[i] - 1);
	}
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	bool ok = true;
	int cnt = 0;
	for (int i = 0; i < N; i++){
		if (S > b[i]){
			ok = false;
			break;
		} else if (S >= (b[i] + 1) / 2){
			cnt++;
			S ^= b[i];
		}
	}
	if (!ok || S != 0){
		cout << -1 << endl;
	} else {
		cout << cnt << endl;
	}
}

Measured memory_bytes: 4836
import java.util.*;

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

        int x = sc.nextInt();
        int n = sc.nextInt();

        HashMap<Integer,Integer> map = new HashMap<Integer, Integer>();

        int min = Integer.MAX_VALUE;
        int ans = 0;

        for(int i = 0; i < n; i++){
            map.put(sc.nextInt(), 1);
            //map.put(i + 1, 1);
        }

        for(int i = 0; i < 102; i++){
            if(!map.containsKey(i)){
                if(min >  Math.abs(x - i)){
                    min = Math.abs(x - i);
                    ans = i;
                }
            }
        }

        System.out.println(ans);

    }
}


Measured memory_bytes: 36040
import math
r, g, b, n = map(int, input().split())
ans = 0
for r_num in range(math.floor(n/r)+1):
    for g_num in range(math.floor(math.floor(n - r*r_num)/g)+1):
        if ((n - (r_num * r) - (g_num * g)) % b == 0):
            ans += 1
print(ans)

Measured memory_bytes: 3060
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static double q;
    public static void main(String[] args) {
        while(read()){
            solve();
        }
    }

    static boolean read(){
        q = sc.nextDouble();
        if(q == -1.0)return false;
        return true;
    }

    static void solve(){
        double x = q/2;
        while(Math.abs(x*x*x - q) > 0.00001*q){
            x = x - ((x*x*x) - q)/(3*x*x);
        }
        System.out.printf("%.6f\n", x);
    }
}

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N, x; cin >> N >> x;
	vi arr (N);
	F0R(i, N) cin >> arr[i];

	ll ans = 0;

	if (arr[0] > x) {
		ans += arr[0] - x;
		arr[0] = x;
	}
	
	FOR(i, 1, N) {
		if (arr[i] + arr[i - 1] > x) {
			ans += arr[i] - (x - arr[i-1]);
			arr[i] = x - arr[i - 1];
		}
	}
	print(ans);
}

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

using namespace std;

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

	// 1, 4, 9, ... (400 * 2) の配列
	// これが長さの2乗と一致すれば長さは整数
	int maxSqrtLength = 400;
	int squareNums[400];
	for (int i = 1; i <= maxSqrtLength; i++)
		squareNums[i - 1] = i * i;

	int pos[10][10];
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < d; j++)
		{
			cin >> pos[i][j];
		}
	}

	int answer = 0;

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			// 重複計算は除外
			if (i < j)
				continue;

			// 二乗距離の計算
			int sqLength = 0;
			for (int k = 0; k < d; k++)
			{
				int diff = abs(pos[i][k] - pos[j][k]);
				sqLength += (diff * diff);
			}

			// 二乗距離とが整数の二乗かどうかの確認
			for (int l = 0; l < maxSqrtLength; l++)
			{
				if (sqLength == squareNums[l])
					answer += 1;
			}
		}
	}

	cout << answer;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mm(a,b) memset(a,b,sizeof(a))
#define ACCELERATE (ios::sync_with_stdio(false),cin.tie(0))
#define pii pair<int,int>
#define pdd pair<double,double>
#define pll pair<long long,long long>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define pf(x) printf("%d\n",x)
#define pf2(x,y) printf("%d %d\n",x,y)
#define pf3(x,y,z) printf("%d %d %d\n",x,y,z)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
#define E exp(1.0)
#define db double
#define ll long long
#define ld long double
#define ull unsigned long long
//#define io
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
//#define gc getchar
//char buf[1<<21],*p1=buf,*p2=buf;
//inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
//inline int read()
//{
//    int ret=0,f=0;char c=gc();
//    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
//    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
//    if(f)return -ret;return ret;
//}
int a;
string s;
int main()
{
    #ifdef io
    freopen("in.txt","r",stdin);
    #endif
    cin>>a>>s;
    if(a<3200)puts("red");
    else cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
char shops[] = {'A', 'B', 'C', 'D', 'E'};

int main () {
	int a, b, maxTotal;
	char maxShop;
	while (maxShop = shops[0], cin >> a >> b, a || b) {
		maxTotal = a + b;
		for (int i = 1; i < 5; i++) {
			cin >> a >> b;
			if (a + b > maxTotal) {
				maxTotal = a + b;
				maxShop = shops[i];
			}
		}
		cout << maxShop << ' ' << maxTotal << endl;
	}
	return 0;
}

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

int main(){
	int m, f, r;
	char c;
	while (1){
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		if (m + f >= 80){
			c = 'A';
		}
		else if (m + f >= 65){
			c = 'B';
		}
		else if (m + f >= 50){
			c = 'C';
		}
		else if (m + f >= 30){
			c = 'D';
			if (r >= 50){
				c = 'C'; 
			}
		}
		else{
			c = 'F';
		}
		if (m == -1 || f == -1) c = 'F';
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
S = input()

# bit全探索で解く
def solve():
    ans = 0

    for i in range(2**(len(S)-1)):
        value = list(S)
        bit = list(str(bin(i))[2:].zfill(len(S)-1))
        for i, p in enumerate(bit):
            if int(p):
                value[i] = value[i] + '+'
        values = ''.join(value).split('+')
        values = list(map(int, values))
        ans += sum(values)
    print(ans)

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3064
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

void
east(int dice[6])
{
	int t = dice[2];
	dice[2] = dice[0]; /* 3 ??? 1 */
	dice[0] = dice[3]; /* 1 ??? 4 */
	dice[3] = dice[5]; /* 4 ??? 6 */
	dice[5] = t;       /* 6 ??? 3 */
}

void
south(int dice[6])
{
	int t = dice[1];
	dice[1] = dice[0]; /* 2 ??? 1 */
	dice[0] = dice[4]; /* 1 ??? 5 */
	dice[4] = dice[5]; /* 5 ??? 6 */
	dice[5] = t;       /* 6 ??? 2 */
}

void
rotate(int dice[6])
{
	int t = dice[3];
	dice[3] = dice[1]; /* 4 ??? 2 */
	dice[1] = dice[2]; /* 2 ??? 3 */
	dice[2] = dice[4]; /* 3 ??? 5 */
	dice[4] = t;       /* 5 ??? 4 */
}

bool
solve(int dice1[6], int dice2[6])
{
	int u, v;
	int i;

	u = dice1[0];
	v = dice1[1];
	for (i = 0; i < 4; ++i)
	{
		if (dice2[1] == v)
			break;

		south(dice2);
	}

	if (dice2[1] != v) /* dice2[2]????????¢???????????????????????? */
	{
		for (i = 0; i < 4; ++i)
		{
			if (dice2[1] == v) /* dice2[2]????????¢??? */
				break;

			rotate(dice2);
		}
	}

	if (dice2[1] != v)
		return false;

	for (i = 0; i < 4; ++i)
	{
		if (dice2[0] == u) /* dice2[1]????????¢??? */
			break;

		east(dice2);
	}

	for (i = 2; i < 6; ++i)
	{
		if (dice1[i] != dice2[i])
			break;
	}

	if (i == 6)
		return true;
	else
		return false;
}

int
main(int argc, char** argv)
{
	int dice1[6];
	int dice2[6];
	int i;

	for (i = 0; i < 6; ++i)
		scanf("%d", &dice1[i]);

	for (i = 0; i < 6; ++i)
		scanf("%d", &dice2[i]);

	printf("%s\n", solve(dice1, dice2) ? "Yes" : "No");
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;

    ll sol = 0;
    map<int, int> H;
    FOR1(i, n){
        int a;
        cin >> a;
        sol += H[i-a];
        H[i+a]++;
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}

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

int main(){
    // H is monster health, N is how many moves Raccoon can make
int H, N;
    cin >> H >> N;
   
    // initialize an array
    int moves[N];
   
    // user input numbers, effectiveness of attack
    int i;
    for (i=0; i<N; i++){
      cin >> moves[i];
    }
    // add up all of the numbers in the arary
  	int sum = 0;
    for (i=0; i<N; i++){
		sum += moves[i];
    }
  	if(H > sum){
      cout << "No" << endl;
    }
  	else{
      cout << "Yes" << endl;
    }
   
   
}



Measured memory_bytes: 640
#include<iostream>
#include<vector>
 
using namespace std;
 
int n, q;
vector<int> A;
vector<bool> isE(2001);
 
int main()
{
    cin>>n;
    int num;
     
    for( int i=0; i<n; i++ ) {
        cin>>num;
        A.push_back( num );
        for( int j=2000-num; 0<j; j-- ) {
            if( isE.at( j ) ) {
                isE.at( j+num ) = true;
            }
        }
        isE.at( num ) = true;
    }
    cin>>q;
    for( int i=0; i<q; i++ ) {
        cin>>num;
        if( isE.at( num ) ) {
            cout<<"yes"<<'\n';          
        } else {
            cout<<"no"<<'\n';
        }
    }
    return 0;
}  

Measured memory_bytes: 1180
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a,b,cnt=0;
string s;
signed main()
{
	cin>>a>>b>>s;
	rep(i,s.size()-1){
		if(s[i]==s[i+1]){
			cnt++;
		}
	}
	cout<<min(cnt+b*2,a-1);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <list>
#include <string>
#define int long long
using namespace std;
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, w;
	cin >> n >> w;

	vector<pair<int, int>> all;

	for (int i = 0; i < n; i++)
	{
		int a, b;
		cin >> a >> b;

		all.push_back({ a,b });
	}

	//dp[i][j] for first i items and exactly j weight

	vector<int> fill(w + 1, -1);
	vector<vector<int>> dp(n + 1, fill);

	for (int i = 0; i <= w; i++)
	{
		dp[0][i] = 0;
	}
	for (int i = 0; i <= n; i++)
	{
		dp[i][0] = 0;
	}

	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j < all[i - 1].first; j++)
		{
			dp[i][j] = dp[i - 1][j];
		}
		for (int j = all[i-1].first; j < w + 1; j++)
		{
			if (dp[i - 1][j - all[i - 1].first] != -1)
			{
				dp[i][j] = max(dp[i-1][j], dp[i - 1][j - all[i - 1].first] + all[i - 1].second);
			}
		}
	}

	cout << *max_element(dp[n].begin(), dp[n].end()) << "\n";
}


Measured memory_bytes: 80256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int N, W;
	cin >> N >> W;
	vector<int> v(N);
	vector<int> w(N);
	for (int i = 0; i < N; ++i)
	{
		cin >> v[i] >> w[i];
	}
	vector<vector<int> > dp(N + 1, vector<int>(W + 1));
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j <= W; ++j)
		{
			if (j < w[i])
			{
				dp[i + 1][j] = dp[i][j];
			}
			else
			{
				dp[i + 1][j] = max(dp[i][j], dp[i + 1][j - w[i]] + v[i]);
			}
		}
	}
	cout << dp[N][W] << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 4964
// abc131_b
// #include <bits/stdc++.h>
#include <vector>
#include <iostream>
using namespace std;
int main(void){
  int N, X;
  cin >> N >> X;
  vector<int> L;
  int n;
  for(int i = 0; i < N; i++){
    cin >> n;
    L.push_back(n);
  }
  int count = 0;
  int D = 0;
  if(X >= D){
    count++;
  }
  for(int i = 0; i < N; i++){
    D += L.at(i);
    if(X >= D){
      count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

int N,M,Q,B,C,D;
int A[100010];
std::string S;

int main(){
	int n,m,x,a[110],ans1=0,ans2=0;
	set<int> u;
	cin>>n>>m>>x;
	REP(i,m){
		cin>>a[i];
		u.insert(a[i]);
	}
	for(int i=x;i<=n;i++){
		if(u.find(i)!=u.end()){
			ans1++;
		}
	}
	for(int i=x;1<=i;i--){
		if(u.find(i)!=u.end()){
			ans2++;
		}
	}
	cout<<std::min(ans1,ans2)<<endl;
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())
empty_row = ['.'] * w
a_empty_row = ['#'] + ['.'] * (w - 1)
a_filled_row = ['#'] * (w - 1) + ['.']
b_empty_row = ['.'] * (w - 1) + ['#']
b_filled_row = ['.'] + ['#'] * (w - 1)

violet = [input() for _ in range(h)]

aaa = []
bbb = []
for i in range(h):
    if i % 2 == 0:
        aaa.append(a_filled_row.copy())
        bbb.append(b_empty_row.copy())
    else:
        aaa.append(a_empty_row.copy())
        bbb.append(b_filled_row.copy())
for i in range(1, h - 1):
    for j in range(1, w - 1):
        if violet[i][j] == '#':
            aaa[i][j] = '#'
            bbb[i][j] = '#'
print('\n'.join(''.join(row) for row in aaa))
print()
print('\n'.join(''.join(row) for row in bbb))


Measured memory_bytes: 8732
n=int(input())
m,a,r,c,h=0,0,0,0,0
for i in range(n):
  name=input()
  init=name[0]
  if init =="M":
    m+=1
  elif init =="A":
    a+=1
  elif init =="R":
    r+=1
  elif init =="C":
    c+=1
  elif init =="H":
    h+=1
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll gcd(ll a,ll b){
		if(a==0)return b;
		return gcd(b%a,a);
}
int main()
{
  ll n;
  cin >> n;
  ll s=0;
  for(ll a=1;a<=n;a++)
  {
      for(ll b=1;b<=n;b++)
      {
          for(ll c=1;c<=n;c++)
          {
              s=s+gcd(gcd(a,b),c);
          }
          
      }
  }
  cout <<s;
}


Measured memory_bytes: 3632
import sys
import math

sys.setrecursionlimit(4100000)


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


def solve(inputs):
    [side, hight, X] = string_to_int(inputs[0])
    max_size = side * side * hight
    if max_size / X < 2:
        z = (2*X / (side*side)) - hight
        w = hight - z
        sheta = math.atan2(side, w)
        return 90 - math.degrees(sheta)

    else:
        tri_side = 2 * X / (side * hight)
        sheta = math.atan2(hight, tri_side)
        return math.degrees(sheta)


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


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


Measured memory_bytes: 3064
#include <stdio.h>
int main(){
int a, b, c, temp;
int n, i;
scanf("%d", &n);
for(i = 0; i < n; i++){
scanf("%d %d %d", &a, &b, &c);
if(a > c){
temp = c;
c = a;
a = temp;
}
if(b > c){
temp = c;
c = b;
b = temp;
}
if(a * a + b * b == c * c){
printf("YES\n");
}else{
printf("NO\n");
}
}
return 0;
}

Measured memory_bytes: 1008
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
struct edge
{
	int to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }

template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
//int index(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int d[1000];
vector<vector<edge>> es;

void dijkstra(int s)
{
	fill(ALL(d), INF);
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P>> que;
	que.push(P(0, s));
	while (!que.empty())
	{
		P p = que.top(); que.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		REP(i, es[v].size())
		{
			edge e = es[v][i];
			if (d[e.to] > d[v] + e.cost)
			{
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

int main()
{
	int n, m;
	cin >> n >> m;
	es.resize(n);
	REP(i, m)
	{
		int a, b, c;
		cin >> a >> b >> c;
		c *= -1;
		es[a].push_back(edge{ b, c });
	}
	dijkstra(0);
	cout << -d[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>

int main(int argc, const char * argv[]) {
    
    int x,y;
    
    while (1) {
        std::cin >> x >> y ;
        if (x==0 && y==0) break ;
        if (x > y) {
            int c = x ;
            x = y ;
            y = c ;
        }
        printf("%d %d\n", x, y) ;
    }
    
    return 0;
}



Measured memory_bytes: 3216
#include<bits/stdc++.h>
#define rep(j,n) for(int i=j;i<n;i++)
#define pb push_back
#define MX_N 100001
#define INF 10000000;
#define f first
#define s second
using namespace std;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long unsigned int llui;
typedef long long int ll;

int main(){
	string s;
	cin >> s;
	int b=0;
	int c=1;
	if(s[0]=='A')b++;
	for(int i=2;i<s.size()-1;i++){
		if(s[i]=='C'){
			b++;
			c=i;
			break;
		}
	}
	b++;
	for(int i=1;i<s.size();i++){
		if(i!=c&&s[i]!=tolower(s[i])){
			b--;
			break;
		}
	}
	if(b==3){
		cout << "AC" << endl;
	}else{
		cout << "WA" << endl;
	}return 0;
}

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

#define all(n) n.begin(),n.end()
#define ll long long

#define pb push_back
#define eb emplace_back
#define endl "\n"
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;
const ll maxn=3e4+120;
const ll maxx=1e16;
const ll mod1=1e9+7;
const ll mod=998244353;
vector<ll> adj[maxn];
ll h1[maxn] ;
ll cnt[maxn];
bool dd[maxn];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    if (fopen("TEAMS.INP","r"))
    {
        freopen("TEAMS.INP", "r", stdin);
        freopen("TEAMS.OUT", "w", stdout);
    }
   char x;
   cin>>x;
   if (x>='a'&&x<='z')
   {
       cout <<"a";
   }
   else
   {
       cout <<"A";
   }



}


Measured memory_bytes: 4400
#include<iostream>
#include<climits>
#include<algorithm>
using namespace std;
int main()
{
    int n, a;
    int amin = INT_MAX, amax = INT_MIN;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a;
        amin = min(amin, a);
        amax = max(amax, a);
    }
    cout << amax - amin << endl;
    return 0;
}

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

ll n;
ll divisor_middle(ll n){
    ll out = 0;
    for(ll i=1; i<=pow(n,0.5); i++){
        if(n%i == 0) out = i;
    }
    return out;
}

int main(void){

    cin >> n;

    ll a = divisor_middle(n);

    ll b = n / a;


    ll ans = (a-1) + (b-1);

    cout << ans;

    return 0;
}

Measured memory_bytes: 384
N = int(input())
ans = 0
def chr(i,a):
    global ans
    if i <= 9:
        chr(i+1,a+"7")
        chr(i+1,a+"5")
        chr(i+1,a+"3")
    if i >= 3:
        if a.count("7"):
            if a.count("5"):
                if a.count("3"):
                    if int(a) <= N:    
                        ans += 1
chr(0,"")
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	int k;char s[105];
	cin>>k>>s;
	int l=strlen(s);
	if(l<=k) cout<<s;
	else {
		for(int i=0;i<k;++i)
		cout<<s[i];
		cout<<"...";
	}
}

Measured memory_bytes: 3632
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <time.h>

#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll dp[2005][2005];
ll sdp[2005][2005];

void solve()
{
    int S;
    scanf("%d", &S);

    int S2 = S / 3 + 5;
    ll ans = 0;
    int i, j;
    dp[0][0] = 1;

    for (i = 0; i < S2; i++) {
        if (i > 0) {
            for (j = 3; j <= S; j++) {
                dp[i][j] = sdp[i - 1][j - 3 + 1];
            }
        }
        for (j = 0; j <= S; j++) {
            sdp[i][j + 1] = (sdp[i][j] + dp[i][j])%MOD;
        }
        ans = (ans + dp[i][S])%MOD;
    }
    printf("%lld\n", ans);
    return;
}

int main()
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for (t = 0; t < T; t++) {
        //printf("Case #%d: ", t + 1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 22740
def p(u):
 if u+1:print(s,u,end=s);p(T[u]);p(T[u+N])
def i(u):
 if u+1:i(T[u]);print(s,u,end=s);i(T[u+N])
def o(u):
 if u+1:o(T[u]);o(T[u+N]);print(s,u,end=s)
s=''
N=int(input())
T=[0,0]*N
R=set(range(N))
for _ in[0]*N:
 a,b,c=map(int,input().split())
 T[a],T[a+N]=b,c
 R-={b,c}
r=R.pop()
print('Preorder')
p(r)
print('\nInorder')
i(r)
print('\nPostorder')
o(r)
print()


Measured memory_bytes: 5620
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

int dx[] = {+1,-1, 0, 0};
int dy[] = { 0, 0,+1,-1};
int tb[10][10];
bool visited[10][10];

int n,t,sum;
vector<int> sx,sy;

bool dfs(int x, int y, int s, int c, int m)
{
	int tx,ty,ttx,tty,tc,tm,ts;
	for(int i=0; i<4; i++)
	{
		bool v=false;
		ts = s;
		tc = c;
		tx = x+dx[i];
		ty = y+dy[i];
		ttx= x;
		tty= y;
		tm = m+tb[tx][ty];

		if(tb[tx][ty]<=0) continue;
		if(visited[tx][ty]) continue;
		if(tm>0) continue;
		if(tm==0)
		{
			tc++;
			ts++;
			if(tc==sx.size())
			{
				if(ts==n*n)
				{
					return true;
				}
				else
				{
					continue;
				}
			}
			ttx=tx;
			tty=ty;
			tx = sx[tc];
			ty = sy[tc];
			tm = tb[tx][ty];
		}
		visited[ttx][tty]=1;
		visited[x][y]=1;
		if(dfs(tx,ty,ts+1,tc,tm)) return true;
		visited[x][y]=0;
		visited[ttx][tty]=0;
	}
	return false;
}

int main()
{
	while(cin >> n, n)
	{
		sum = 0;
		memset(visited, 0, sizeof(visited));
		sx.clear();
		sy.clear();

		for(int i=0; i<100; i++)
		{
			tb[i/10][i%10] = 0;
		}

		for(int i=0; i<n*n; i++)
		{
			cin >> t; sum+=t;
			tb[(i/n)+1][(i%n)+1] = t;

			if(t<0)
			{
				sx.push_back((i/n)+1);
				sy.push_back((i%n)+1);
			}
		}

		// »è»Ì1
		if(sum!=0) { cout << "NO\n"; continue; }

		if(dfs(sx[0],sy[0],1,0,tb[sx[0]][sy[0]]))
		{
			cout << "YES\n";
		}
		else
		{
			cout << "NO\n";
		}
	}

	return 0;
}

Measured memory_bytes: 904
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

n = ii()
b1 = False
b2 = False
b3 = False
for i in range(n):
    x = li()
    if(x[0] == x[1]):
        if(b1):
            if(b2):
                b3 = True
            b2 = True
        b1 = True
    else:
        b1 = False
        b2 = False

print("Yes" if b3 else "No")

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

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

  ll N, M, V, P;
  cin >> N >> M >> V >> P;
  vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i];
  sort(A.rbegin(), A.rend());

  ll l = 0, r = N;
  while (l + 1 < r) {
    ll m = (l + r) / 2;
    ll thre = A[P - 1];
    bool ok = false;

    if (A[m] + M < thre) {
      ok = false;
    } else {
      ll sum = 0;
      for (ll i = 0; i < N; i++) {
        if (A[i] > thre) sum += M;
        else sum += min(A[m] + M - A[i], M);
      }
      // cout << m << ' ' << sum << '\n';
      if (sum >= V * M) ok = true;
    }

    if (ok) l = m; else r = m;
  }
  cout << (l + 1) << '\n';
  return 0;
}

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

int main(){
	int n;
	cin >> n;
	if(n == 0){
		cout << "0" << endl;
		return 0;
	}

	string ans = "";
	while(n != 0){
		if(n%2 == 0){
			ans += "0";
		}else{
			ans += "1";
			n--;
		}
		n = -n/2;
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256