akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{ 
  string s1,s2,s3;
  cin>>s1>>s2>>s3;
  cout<<char(s1[0] - 'a' +'A');
  cout<<char(s2[0] - 'a' +'A');
  cout<<char(s3[0] - 'a' +'A');
  cout<<endl;
  return;
}

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

  std::cout << std::fixed;
  std::cout << std::setprecision(15);
  solve();

  return 0;
}


Measured memory_bytes: 384
a11, a12, a13 = map(int, input().split())
a21, a22, a23 = map(int, input().split())
a31, a32, a33 = map(int, input().split())
l = []
for i in range(int(input())):
    l.append(int(input()))
if (l.__contains__(a11) and l.__contains__(a12) and l.__contains__(a13)):
    print('Yes')
elif (l.__contains__(a21) and l.__contains__(a22) and l.__contains__(a23)):
    print('Yes')
elif (l.__contains__(a31) and l.__contains__(a32) and l.__contains__(a33)):
    print('Yes')
elif (l.__contains__(a31) and l.__contains__(a21) and l.__contains__(a11)):
    print('Yes')
elif (l.__contains__(a12) and l.__contains__(a22) and l.__contains__(a32)):
    print('Yes')
elif (l.__contains__(a13) and l.__contains__(a23) and l.__contains__(a33)):
    print('Yes')
elif (l.__contains__(a11) and l.__contains__(a22) and l.__contains__(a33)):
    print('Yes')
elif (l.__contains__(a13) and l.__contains__(a22) and l.__contains__(a31)):
    print('Yes')
else:
    print('No')

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

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    if (c <= (a + b))
        cout << (b + c) << endl;
    else
        cout << (a + b + b + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
#define ll               long long
//動画解説写し
const long long INF=1e18+1;
int main() {
  int n;
  ll k;
  cin>>n>>k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  ll l=-INF,r=INF;
  while(l+1<r){
    ll x=(l+r)/2;
    bool ok=[&]{
      ll tot=0;
      rep(i,n){
        if(a[i]<0){
          int l=-1,r=n;
          while(l+1<r){
            int c=(l+r)/2;
            if(a[c]*a[i]<x)r=c;
            else l=c;
          }
          tot+=n-r;
        }else{
          int l=-1,r=n;
          while(l+1<r){
            int c=(l+r)/2;
            if(a[c]*a[i]<x)l=c;
            else r=c;
          }
          tot+=r;
        }
        if(a[i]*a[i]<x)tot--;
      }
      tot/=2;
      return tot<k;
    }();
    if(ok)l=x;
    else r=x;
  }
  cout<<l<<endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};

int main() {
  int h1,m1,h2,m2,k; cin >>h1 >>m1 >>h2 >>m2 >>k;
  int M = h2*60+m2 - h1*60-m1;
  int res = max(0, M-k);
  cout <<res <<endl;
}


Measured memory_bytes: 3624
import sys
from collections import defaultdict
input = sys.stdin.buffer.readline

count = defaultdict(lambda: 0)

H, W, N = map(int, input().split())
for _ in range(N):
    a, b = map(int, input().split())
    for a_2 in range(a-1, a+2):
        for b_2 in range(b-1, b+2):
            if 2 <= a_2 <= H-1 and 2 <= b_2 <= W-1:
                count[a_2, b_2] += 1

ans = [0] * 10
for _, v in count.items():
    ans[v] += 1

ans[0] = (H-2) * (W-2) - sum(ans)

print(*ans, sep = '\n')

Measured memory_bytes: 145600
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if is_prime[i]:
            for j in range(i*2, n+1, i):
                is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

def resolve():
    N = I()

    primes = sieve(55555)
    # 1の位が同じ数字を5つ集めれば5の倍数になる
    ans = [i for i in primes if i % 10 == 3]
    print(*ans[:N])

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10832
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    vector<int> h(n+1),ans(n+1);
    for(int i=1;i<=n;i++) cin>>h[i];
    ans[1]=0;ans[2]=abs(h[2]-h[1]);
    int mini=INT_MAX;
    for(int i=3;i<=n;i++)
    {
        mini=INT_MAX;
        for(int j=max(1,i-k);j<=i-1;j++){
            mini=min(mini,ans[j]+abs(h[i]-h[j]));
        }
        ans[i]=mini;
    }
    cout<<ans[n];
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<queue>

int main(){
	int n, l;
	std::cin>>n>>l;

	long long sum=0;

	for(int i=0; i<n; i++)
		sum+= l+i;

	long long min= l;
	long long max= l+n-1;

	if(min> 0)
		sum-= min;
	else if(max< 0)
		sum-= max;

	std::cout<<sum<<std::endl;

	return 0;
	
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val inf = 1200000
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val keys = (0 until m).map {
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        val c = readLine()!!.split(' ')
                .map { 1 shl (it.toInt() - 1) }
                .reduce { acc, i -> acc or i }
        a to c
    }

    val dp = Array(m + 1) { IntArray(4096) { inf } }
    dp[0][0] = 0

    for (i in 0 until m) {
        for (j in 0 until 4096) {
            dp[i + 1][j] = Math.min(dp[i + 1][j], dp[i][j])
            val j2 = j or keys[i].second
            dp[i + 1][j2] = Math.min(dp[i + 1][j2], dp[i][j] + keys[i].first)
        }
    }

    dp[m][(1 shl n) - 1].let { println(if (it < inf) it else -1) }
}


Measured memory_bytes: 62528
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	vector<int> hs(n);
	for(auto &h : hs) cin >> h;
	--hs[0];
	for(int i = 1; i < n; ++i) if(hs[i] > hs[i - 1]) --hs[i];
	cout << (is_sorted(hs.begin(), hs.end()) ? "Yes" : "No") << '\n';
}

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

#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define revp(i,a,b)     for(int i=b;i>=a;i--)

int n,arr[52],sum=0,ans=0;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
  

    cin>>n;
    rep(i,1,n)
    {
        cin>>arr[i];
        if(i!=1)
            arr[i]+=arr[i-1];
    }
    sum=arr[n];
    rep(i,1,n-1)
        ans+=(arr[i]-arr[i-1])*(sum-arr[i]);
    cout<<ans;
}




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

#define LL long long
#define ULL unsigned long long int
LL INF=1000000000000000001;
#define mx 100009
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define INP freopen("in.txt","r",stdin)
#define OP  freopen("in.txt","w",stdout)

#define sf 	scanf
#define pf 	printf
#define F  	first
#define S  	second
#define pb 	push_back
#define NL	pf("\n")
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%I64d",&x);
#define sll(x,y)	sf("%I64d%I64d",&x,&y);
#define slll(x,y,z)	sf("%I64d%I64d%I64d",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v)		sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(i=0;i<n;i++)
#define FORE(i,n)	for(i=1;i<=n;i++)
#define FORR(i,n)	for(i=n-1;i>=0;i--)
#define FORRE(i,n)	for(i=n;i>0;i--)
// graph direction array [4]
//int X[4]={0,0,1,-1};
//int Y[4]={1,-1,0,0};

//bool cmp( int a,int b ){
//	return  a>b ;
//}



int main(){

//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
	LL n,m,i,j,k,t,d,bs,cs=0,c,sq,x,s,f,v;
	cin>>n;
	char cc;
	bool yel=false;
	FOR(i,n){
		cin>>cc;
		if( cc=='Y' )yel=true;
	}
	if( yel )cout<<"Four";
	else cout<<"Three";
	NL;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;

class Proc{
	public:
		string nam;
		int tim;
		Proc(){
			nam = "";
			tim = 0;
		}
};

Proc Q[100001];

class Queue{
	private:
		int fp;
		int rp;
	public:
		Queue(){
			fp = 0;
			rp = 0;
		}
		int next(int p) const{
			return (p+1)%100001;
		}
		bool isFull() const{
			return (next(rp) == fp);
		}
		bool isEmpty() const{
			return (rp == fp);
		}
		void push(Proc d);
		Proc front();
		void pop();
};

void Queue::push(Proc d){
	if(isFull()) return;
	Q[rp] = d;
	rp = next(rp);
}

Proc Queue::front(){
	if(isEmpty()){
		Proc er;
		er.tim = -1;
		return er;
	}
	return Q[fp];
}

void Queue::pop(){
	if(isEmpty()) return;
	fp = next(fp);
}

int main(){
	Queue que;

	int n,q;
	cin >> n >> q;
	rep(i,n){
		Proc p;
		cin >> p.nam >> p.tim;
		que.push(p);
	}

	int total_tim = 0;

	while(!que.isEmpty()){
		Proc p = que.front();
		que.pop();

		if(p.tim<=q){
			total_tim += p.tim;

			cout << p.nam << ' ' << total_tim << endl;
		}else{
			total_tim += q;
			p.tim -= q;
			que.push(p);
		}
	}
}


Measured memory_bytes: 7052
#include<iostream>
using namespace std;
int main(){
 int N;
 cin>>N;
 int n=N,f;
 while(N>=1){
  f+=(N%10);
  N/=10;
 }
 if(n%f==0)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
 return 0;
}

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

ans = 0
for i in range(1,N + 1):
  a = i
  digit_sum = 0
  while a > 0:
    digit_sum += a%10
    a //= 10
  if A <= digit_sum <= B:
    ans += i
print(ans)  

Measured memory_bytes: 9100
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

signed main(void){
    int N,a;
    vector<int> A;
    cin >> N;
    REP(i,N){
        cin >> a;
        A.push_back(a);
    }
    
    int dp[4][214514]={};
    REP(j,4){
        REP(i,N+3){
            dp[j][i]=-INF;
        }
    }
    dp[0][0]=0;
    REP(j,3){
        REP(i,N){
            dp[j][i+2]=max(dp[j][i+2],dp[j][i]+A[i]);
            dp[j+1][i+1]=max(dp[j+1][i+1],dp[j][i]);
        }
    }
    
    int Ans=-INF;
    
    #if debug
    REP(j,3){
        REP(i,N+3){
            if(dp[j][i]<-INF/10){
                cout << "-∞ ";
            }else{
                cout << dp[j][i] << " ";
            }
        }cout << endl;
    }
    #endif
    
    REP(i,3){
        if(N%2==0){
            Ans=max(Ans,dp[i][N+i]);
        }else{
            Ans=max(Ans,dp[i][N-1+i]);
        }
    }
    
    cout << Ans << endl;
    return 0;
}



Measured memory_bytes: 11672
#include <stdio.h>

void depth(int,int);
void height(int,int);

int d[25],s[25],c[25][2],p[25],h[25],hh,root;

int main()
{
  int n,i,j,id,type[25],left,right,hig=0;

  scanf("%d",&n);

  for(j=0;j<n;j++){
    c[j][0]=-1;
    c[j][1]=-1;
    p[j]=-1;
    s[j]=-1;
  }

  for(j=0;j<n;j++){
    scanf("%d",&id);
    scanf("%d %d",&left,&right);

    if(left!=-1){
      s[left]=right;
      p[left] = id;
    }
    if(right!=-1){
      s[right]=left;
      p[right] = id;
    }
    c[id][0]=left;
    c[id][1]=right;
  } 

  /*type*/
  for(j=0;j<n;j++){
    if(p[j]==-1) {
      root=j;
      type[j] = 0;
    }
    else if(c[j][0]==-1&&c[j][1]==-1) type[j] = 1;
    else type[j] = 2;
  }

  depth(root,0);
  
  for(j=0;j<n;j++){
    hh=0;
    height(j,0);
    h[j]=hh;
  }

  /* ??¨??? */
  for(j=0;j<n;j++){
    printf("node %d: parent = %d, sibling = %d, ",j,p[j],s[j]);

    printf("degree = ");

    if(type[j]==1||n==1){
      printf("0, ");
    }
    else if(c[j][0]!=-1&&c[j][1]!=-1)printf("2, ");
    else printf("1, ");

    printf("depth = %d, ",d[j]);
    printf("height = %d, ",h[j]);

    if(type[j]==0) printf("root\n");
    else if(type[j]==1) printf("leaf\n");
    else printf("internal node\n");
  }

  return 0;
}

void depth(int id,int dep){
  d[root]=0;
  if(c[id][0]==-1&&c[id][1]==-1) return;
  dep++;
  if(c[id][0]==-1) {
    d[c[id][1]]=dep;
    depth(c[id][1],dep);
  }
  else if(c[id][1]==-1)   {
    d[c[id][0]]=dep;
    depth(c[id][0],dep);
  }
  else{
    d[c[id][0]]=dep;
    d[c[id][1]]=dep;

    depth(c[id][0],dep);
    depth(c[id][1],dep);
  }
}

void height(int id,int hig){
  if(c[id][0]==-1&&c[id][1]==-1) return;
  hig++;
  if(hh<=hig) hh=hig;

  if(c[id][1]==-1) height(c[id][0],hig);
  else if(c[id][0]==-1)  height(c[id][1],hig);
  else{
    height(c[id][0],hig);
    height(c[id][1],hig);
  }
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 998244353;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);
double PI = 3.14159265358979;
int n;


signed main(){
    int a,b;
    cin >> n >> a >> b;
    if((b-a)%2==0){
        print((b-a)/2);
    }
    else{
        print(min(a,n-b+1)+((b-a)/2));
    }
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
int main() {
  int  h, w;
  cin >> h >> w;
  string s[h];
  rep(i, h) {
    cin >> s[i];
  }
  rep(i, h) {
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
int n=(int)s.size();
for(int i=0;i<n;i++){
    if(i%2==0){
        if(s[i]=='L'){
            cout<<"No";
            return 0;
        }
    }
    else {
        if(s[i]=='R'){
            cout<<"No";
            return 0;
        }
    }
}
cout<<"Yes";

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define llint long long
#define mod 1000000007

using namespace std;

llint N;
llint T[100005], A[100005];
llint v[100005];

int main(void)
{
  cin >> N;
  for(int i = 0; i < N; i++) cin >> T[i];
  for(int i = 0; i < N; i++) cin >> A[i];

  llint prev = 0;
  for(int i = 0; i < N; i++){
    if(T[i] != prev){
      v[i] = T[i];
      prev = T[i];
    }
  }
  prev = 0;
  for(int i = N-1; i >= 0; i--){
    if(A[i] != prev){
      if(v[i] != 0 && v[i] != A[i]){
        cout << 0 << endl;
        return 0;
      }
      v[i] = A[i];
      prev = A[i];
    }
  }

  llint ans = 1, m;
  for(int i = 0; i < N; i++){
    m = min(T[i], A[i]);
    if(m < v[i]){
      cout << 0 << endl;
      return 0;
    }
    if(v[i] == 0){
      ans *= m;
      ans %= mod;
    }
  }

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
 
int n, m, l[200007], r[200007], d[200007];
 
ll pa[200007], dist[200007];
 
pair<ll, ll> parent(int child){
  ll now = child, distance = 0;
  while(now != pa[now]){
    distance += dist[now];
    now = pa[now];
  }
  return make_pair(now, distance);
}
 
int main(void){
  cin >> n >> m;
  for(int i=0;i<m;i++){
    //cin >> l[i] >> r[i] >> d[i];
    scanf("%ld %ld %ld", &l[i], &r[i], &d[i]);
    l[i]--; r[i]--;
  }
  for(int i=0;i<n;i++) pa[i] = i;
  
  bool flg = true;
  for(int i=0;i<m;i++){
  	pair<ll, ll> p1 = parent(l[i]); 
    int pa1 = p1.first; int dist1 = p1.second;
    pa[l[i]] = pa1; dist[l[i]] = dist1;
    pair<ll, ll> p2 = parent(r[i]);
    int pa2 = p2.first; int dist2 = p2.second;
    pa[r[i]] = pa2; dist[r[i]] = dist2;
	//cerr << pa1 << "," << dist1 << "  " << pa2 << "," << dist2 << endl;
    if (pa1 != pa2){
      if (rand()%2){
	      pa[pa1] = pa2; dist[pa1] = dist2 - dist1 + d[i];
      }else{
          pa[pa2] = pa1; dist[pa2] = dist1 - dist2 - d[i];
      }
    }else{ //矛盾判定
      if (dist1 - dist2 != d[i]) {flg = false; break;}
    }
  }
  cout << (flg ? "Yes" : "No" ) << endl;
  return 0;
}

Measured memory_bytes: 4992
import java.util.*;

public class Main {


    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

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

        int l[] = new int[n];

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

        int total = 0;
        int count = 0;

        for (int i = 0; i < n; i++) {
            if (total <= x) {
                total += l[i];
                count++;
            }
        }
        int sum = 0;
        for (int i = 0; i < n; i++) {
            sum += l[i];
        }
        if (sum <= x) {
            System.out.println(count + 1);
        } else {
            System.out.println(count);
        }
    }
}



Measured memory_bytes: 24020
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
//97->a 122->z
//65-A
int main()
{
	//freopen("testcase.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		string a;
		cin>>a;
		if(a[0]==a[2])
		{
			cout<<"Yes"<<endl;
			return 0;
		}
		cout<<"No"<<endl;
		
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){

  cin.tie(0);
  ios::sync_with_stdio(false);
 
  int a,b,cnt=0;
  cin>>a>>b;
  if(a>b){
    cnt=a;
    a--;
  }else{
    cnt=b;
    b--;
  }
  if(a>b){
    cnt=cnt+a;
  }else{
    cnt=cnt+b;
  }
  cout<<cnt<<'\n';
}


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

int main() {
  string s,t; cin>>s>>t;
  int ans=0;
  rep(i, 3) if (s[i]==t[i]) ans++;
  cout<<ans<<endl;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };


int main() {
	int n, i;
	cin >> n;
	vi a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	int cnt = 1;
	int pre = a[0];
	int state = 2;
	for (i = 1; i < n; i++) {
		if (state == 0) {
			if (a[i] >= pre) {
				pre = a[i];
			}
			else {
				state = 2;
				pre = a[i];
				cnt++;
			}
		}
		else if (state == 1) {
			if (a[i] <= pre) {
				pre = a[i];
			}
			else {
				state = 2;
				pre = a[i];
				cnt++;
			}
		}
		else {
			if (a[i] > pre) {
				state = 0;
			}
			else if (a[i] < pre) {
				state = 1;
			}
			pre = a[i];
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

long combi(int n)
{
  if (n < 2) return 0;
  long si = 1;
  for (int i = 0; i < 2; ++i) {
    si *= n - i;
  }
  return si / 2;
}

long solve(int n, int m)
{
  return combi(n) + combi(m);
}

int main()
{
  int n, m;
  std::cin >> n >> m;

  std::cout << std::setprecision(20);
  std::cout << solve(n, m) << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n;
    cin>>n;
    map<int,int>P;
    long long ans=1;
    for(int i=2;i<=n;i++){
        int tmp=i;
        for(int j=2;j<=i;j++){
            while(tmp%j==0){
                tmp/=j;
                P[j]++;
            }
        }
    }
    for(auto x:P){
        ans=ans*(x.second+1)%1000000007;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <thread>
#include <bitset>

using namespace std;


int main(void)
{
	double a, b, n;

	cin >> a >> b >> n;

	double max;

	if (b - 1 > n)
	{
		max = floor((a * n) / b) - a * floor(n / b);
	}
	else
	{
		max = floor((a * (b - 1)) / b);
	}


	cout << max;
	return 0;
}

/*
	int n, m, q;
	int a[50], b[50], c[50], d[50];

	cin >> n >> m >> q;
	for (int i = 0; i < q; i++)
	{
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	int A[10];

	for (int i = 0; i < q; i++)
	{

	}
*/

Measured memory_bytes: 3872
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<cctype>
#include<cmath>
#include<queue>
#include<stack> 
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
//const int MAX_V=105;
const long double pi = 3.14159265;
const long long mod =1e9+7;


int main(){
    int N,A,B;
    
    cin >> N >> A >> B;
    cout <<min(N*A, B) << endl;

    return 0;
}
 

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

int main(){
  long long n;
  int i;
  long long t = 1;
  scanf("%lld", &n);

  for(i = 0;i < 3;i++){
    t *= n;
  }

  printf("%lld\n", t);
  return 0;
}


Measured memory_bytes: 128
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]

need_s = q - k + 1

if need_s <= 0:
    for i in range(n):
        print('Yes')
    exit()

a.sort()

per = [0]*(n+1)

#print(need_s)

for i in range(q):
    per[a[i]] += 1

#print(per)

for i in range(1,n+1):
    if per[i] >= need_s:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 8612
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>
#include <list>

using namespace std;

int main() {
	int h, a, count = 0;
	cin >> h >> a;
	while (h > 0) {
		h -= a;
		count++;
	}
	cout << count << endl;

	return 0;
}

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

int main(){
    string word;
    cin >> word;
    int len = word.size();
    for (int i = 1; i < len; ++i)
    {
        if(word[i-1] == 'S' && word[i] == 'T'){
            word.erase(word.begin() + i);
            word.erase(word.begin() + i - 1);
            i = i - 2;
            len = len - 2;
        }
    }
    cout << word.size() << endl;
}

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

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

  vector<pair<ll, int>> fs;
  for (ll i = 2; i * i <= n; i++) {
    int x = 0;
    while (n % i == 0) {
      n /= i;
      x++;
    }
    fs.emplace_back(i, x);
  }
  if (n != 1) fs.emplace_back(n, 1);

  int ans = 0;
  for (auto p : fs) {
    int x = p.second;
    int b = 1;
    while (b <= x) {
      x -= b;
      b++;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19692
N=int(input())
a=int(N/4)
b=int(N/7)

flag=False

for i in range(a+1):
    for j in range(b+1):
        if 4*i+7*j==N:
            flag=True
        
if flag==True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define INF (1e9)
#define M 105
#define N 15
using namespace std;
int n,m,s[N],d[M],dp[(1<<N)][M],ans[(1<<N)];

int main(){
  while(1){
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<n;i++)
      cin>>s[i];
    for(int i=0;i<m;i++)
      cin>>d[i];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<(1<<n);i++)ans[i]=INF;
    for(int i=0;i<(1<<n);i++){
      int sum=0;
      for(int j=0;j<n;j++)
	if(i&(1<<j))sum+=s[j];
      int temp[M];
      for(int j=0;j<n;j++){
	if(i&(1<<j))continue;
	int x=0;
	for(int k=0;k<m;k++){
	  temp[k]=dp[i][k];
	  if(dp[i][k]==sum&&(abs(d[k]-dp[i][k])>abs(d[k]-(dp[i][k]+s[j]))))
	    temp[k]+=s[j];
	  x+=abs(d[k]-temp[k]);
	}
	if(ans[i|(1<<j)]>x){
	  ans[i|(1<<j)]=x;
	  for(int k=0;k<m;k++)
	    dp[i|(1<<j)][k]=temp[k];
	}
      }
    }
    cout<<ans[(1<<n)-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 16660
def pushBack(t,x):
    global A
    A[t].append(str(x))

def dump(t):
    global A
    if A[t] == []:
        print()
    else:
        print(" ".join(A[t]))
def clear(t):
    global A
    A[t] =[]


A =[]
num = list(map(int, input().split()))
for j in range(num[0]):
    A.append([])

for i in range(num[1]):
    queryi = list(map(int, input().split()))
    
    if queryi[0] == 0:
        pushBack(queryi[1], queryi[2])

    elif queryi[0] == 1:
        dump(queryi[1])
    
    else:
        clear(queryi[1])



Measured memory_bytes: 44048
#include <bits/stdc++.h>
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define cinf(x,n) for(int i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(int i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

int turn,tmp;

int main(){
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	while(true){
		if(!s[turn].empty()){
			tmp = s[turn][0]-'a';
			s[turn].erase(s[turn].begin());
		}else{
			cout << static_cast<char>(turn+'A') << endl;
			return 0;
		}
		turn = tmp;
	}
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
typedef long long lint;
const int N=105;
int n;
struct pnt{
	int x,y;
	friend bool operator < (const pnt &a,const pnt &b){
		return a.x<b.x;
	}
}pa[N],pb[N];
bool vis[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x>y?x:y;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=c=='-'&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
	n=nxi();
	for(int i=1; i<=n; ++i){
		pa[i].x=nxi(),pa[i].y=nxi();
	}
	for(int i=1; i<=n; ++i){
		pb[i].x=nxi(),pb[i].y=nxi();
	}
	std::sort(pb+1,pb+n+1);
	int ans=0;
	for(int i=1; i<=n; ++i){
		int res=0;
		for(int j=1; j<=n; ++j){
			if(!vis[j]&&pa[j].x<pb[i].x&&pa[j].y<pb[i].y&&pa[j].y>=pa[res].y){
				res=j;
			}
		}
		if(res) ans+=vis[res]=1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
def retNumOfCommonCharacters(left: str, right: str) -> int:
    cnt = 0
    for l in left:
        if l in right:
            cnt += 1

    return cnt

n = int(input())
s = input()

ans = 0
for i in range(1, n):
    num = retNumOfCommonCharacters(set(s[0:i]), set(s[i:]))
    if ans <= num:
        ans = num

print(ans)


Measured memory_bytes: 3060
N=int(input())
A=list(map(int, input().split()))
sum_f=[0 for _ in range(N-1)]
sum_b=[0 for _ in range(N-1)]
sum_f[0]=A[0]
sum_b[-1]=A[-1]
for i in range(N-2):
  sum_f[i+1]=sum_f[i]+A[i+1]
  sum_b[-(i+2)]=sum_b[-(i+1)]+A[-(i+2)]
print(min([abs(sum_f[i]-sum_b[i]) for i in range(N-1)]))

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  vector<vector<int>> C(3);
  int c;
  REP(i, 3) {
    REP(j, 3) {
      cin >> c;
      C.at(i).push_back(c);
    }
  }

  bool ans = true;
  REP(j, 2) {
    if (!(C.at(0).at(j + 1) - C.at(0).at(j) ==
              C.at(1).at(j + 1) - C.at(1).at(j) &&
          C.at(1).at(j + 1) - C.at(1).at(j) ==
              C.at(2).at(j + 1) - C.at(2).at(j))) {
      ans = false;
      break;
    }
  }

  if (!ans) {
    cout << "No" << endl;
    return 0;
  }

  REP(i, 2) {
    if (!(C.at(i + 1).at(0) - C.at(i).at(0) ==
              C.at(i + 1).at(1) - C.at(i).at(1) &&
          C.at(i + 1).at(1) - C.at(i).at(1) ==
              C.at(i + 1).at(2) - C.at(i).at(2))) {
      ans = false;
      break;
    }
  }

  if (!ans) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) (a).begin(), (a).end()
typedef vector<int> vi;
const int INF = 1LL << 60; //10e18+10e17ちょっとくらい
const int MOD = 1000000007;
const int MAX_N = 200100;

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int n, d;
    cin >> n >> d;
    d *= d;
    int ans = 0;
    rep(i, n)
    {
        int x, y;
        cin >> x >> y;
        x *= x;
        y *= y;
        if (d >= x + y)
            ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 1001001001;
constexpr long long INFL = (1LL<<60);
constexpr double eps = (1e-9);

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

  ll a;
  string b;
  cin >> a >> b;
  string bb;
  for (auto& c : b) {
    if (c != '.') bb.push_back(c);
  }

  ll c = atoi(bb.c_str());

  ll ans = a * c;
  ans /= 100;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
	long long m,n;
	scanf("%lld %lld", &m, &n);
	if(m >= 3 && n >= 3)
	{	
		printf("%lld\n",(m - 2) * (n - 2));
	}
	if(m == 2 || n == 2)
	{
		printf("0\n");
	}
	if(m == 1 || n == 1)
	{
		if(m * n - 2 < 0)
		{
			printf("1\n");
		}
		else
		{
			printf("%lld\n", m * n - 2);
		}
	}
	return 0;
}

Measured memory_bytes: 128
import math


def main():
    h = int(input())

    counter = 0
    multiple = 1

    while True:
        if h == 1:
            counter += multiple
            break
        else:
            h = math.floor(h/2)
            counter += multiple
            multiple *= 2

    print(counter)


if __name__ == "__main__":
    main()


Measured memory_bytes: 62176
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <deque>
#include <cstdio>
#include <cmath>

using namespace std;

#define reep(i,f,t) for(int i=f ; i<int(t) ; ++i)
#define rep(i,n) reep(i, 0, n) 

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main()
{
	int nums[16384], ans[8192];
	int i, j, n, size, half;
	
	while(scanf("%d", &n), n){
		size = 0;
		half = (n-1) / 2;
		for(i=1; i<n; ++i)
			nums[size++] = (i*i) % n;

		sort(nums, nums + size);
		size = unique(nums, nums + size) - nums;

		memset(ans, 0, (half+1)*4);
		for(i=0; i<size; ++i){
			for(j=0; j<i; ++j){
				int p = abs(nums[i]-nums[j]);
				if(p>half) p = n - p;
				++ans[p];
			}
		}
		for(i=1; i<=half; ++i)
			printf("%d\n", ans[i]*2);
	}

	return 0;
}

Measured memory_bytes: 828
n, m, x = list(map(int, input().split()))

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

book_list.sort(key=lambda el: el[0])  # 価格でソート

# 金額の最小値
ans = 1e10

for bit in range(1 << n):
    # 全アルゴリズムの理解度
    algo_val = [0 for _ in range(m)]
    # 金額
    ans_tmp = 0

    # 全アルゴリズムの理解度がxを超える
    for i, book in enumerate(book_list):
        if (bit & (1 << i)):
            ans_tmp += book[0]
            for j, a in enumerate(book[1:]):
                algo_val[j] += a

    if all(i >= x for i in algo_val):
        # その中で最小のもの
        ans = min(ans_tmp, ans)

if ans == 1e10:
    print(-1)
else:
    print(ans)


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;

#ifdef HOME
#define db(x) { cerr << #x << " = " << x << endl; }
#define db2(x, y) { cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl; }
#define db3(x, y, z) { cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl; }
#define dbv(a) { cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl; }
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

#define sz(a)  (int)(a).size()
#define all(a) (a).begin(),a.end()
#define pw(x)  (1LL << (x))


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

class A {
public:
    void solve(std::istream &in, std::ostream &out) {
        ios_base::sync_with_stdio(0);
        in.tie(0);

        int n, m;
        in >> n >> m;
        vector<string> a(n);
        for (int i = 0; i < n; i++) in >> a[i];

        queue<pair<int, int>> q;
        vector<vector<int>> d(n, vector<int>(m, INF));
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (a[i][j] == '#') {
                    q.push({i, j});
                    d[i][j] = 0;
                }
            }
        }
        assert(!q.empty());
        while (!q.empty()) {
            int x = q.front().first;
            int y = q.front().second;
            q.pop();

            for (int k = 0; k < 4; k++) {
                int nx = x + dx[k];
                int ny = y + dy[k];
                if (!(0 <= nx && nx < n && 0 <= ny && ny < m)) continue;
                if (d[nx][ny] > d[x][y] + 1) {
                    d[nx][ny] = d[x][y] + 1;
                    q.push({nx, ny});
                }
            }
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                ans = max(ans, d[i][j]);
            }
        }
        out << ans << endl;
    }
};


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


Measured memory_bytes: 13456
#include<stdio.h>
#define N 500000
void merge(int*,int,int,int);
void mergeSort(int*,int,int);
int sum = 0;
int main(){
  int n,i,S[N];

  scanf("%d",&n);

  for(i = 0; i < n; i++)
    scanf("%d",&S[i]);
  mergeSort(S,0,n);
  for(i = 0; i < n; i++){
    printf("%d",S[i]);
    if(i < n-1) printf(" ");
  }
  printf("\n");
  printf("%d\n",sum);

  return 0;
}

void merge(int A[],int left,int mid,int right){
  int n1 = mid - left,n2 = right - mid,L[n1 + 1],R[n2 + 1],i,j,k;

  for(i = 0; i < n1; i++)
    L[i] = A[left +i];

  for(i = 0; i < n2; i++)
    R[i] = A[mid + i];

  L[n1] = 1000000000;
  R[n2] = 1000000000;
  i = 0;
  j = 0;

  for(k = left; k < right; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }

    else{
      A[k] = R[j];
      j = j + 1;
    }
    sum++;
  }
}

void mergeSort(int A[],int left,int right){
  int mid;

  if (left + 1 < right){
  mid = (left + right)/2;
  mergeSort(A,left,mid);
  mergeSort(A,mid,right);
  merge(A,left,mid,right);
  }
}

Measured memory_bytes: 4508
import java.io.IOException;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException{
	Scanner sc	= new Scanner(System.in);
	int x = sc.nextInt();
	int t = sc.nextInt();
	
	if (x < t) {
		System.out.println(0);
	} else {
		System.out.println(x - t);
	}
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <array>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

typedef  pair<int,int> P;


int main(){
     int a,b,c;
     cin>>a>>b>>c;
     if(a+b+c==17&&((a==5&&b==7)||(a==5&&b==5)||(a==7&&b==5))){
          cout<<"YES"<<endl;
     }else {
          cout<<"NO"<<endl;
     }
}

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

int main(void){
    int W,H,N,menseki;
    cin>>W>>H>>N;
    int max1x=0,max2x=W,max3y=0,max4y=H;
    int x[N],y[N],a[N];
    for(int i=0;i<N;i++){
        cin>>x[i]>>y[i]>>a[i];
        switch(a[i]){
            case 1:if(x[i]>max1x)max1x=x[i];break;
            case 2:if(x[i]<max2x)max2x=x[i];break;//syuseihituyou
            case 3:if(y[i]>max3y)max3y=y[i];break;
            case 4:if(y[i]<max4y)max4y=y[i];break;
        }
    }

    if(max1x>=max2x||max3y>=max4y)
        cout<<0<<endl;
    else
        cout<<(max2x-max1x)*(max4y-max3y)<<endl;

    return 0;
}


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

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    ll pseq = -1;
    rep(i, N) {
        if(A[i] >= 0) {pseq = i;
        break;}
    }
    //cout << pseq << endl;
    vector<P> res;
    if(pseq > 0) {
        for(ll i=pseq; i<N-1; i++) {
            res.push_back(P(A[0], A[i]));
            A[0] -= A[i];   
        }
        for(ll i=0; i<pseq; i++) {
            res.push_back(P(A[N-1], A[i]));
            A[N-1] -= A[i];
        }
      
    } else if(pseq == 0) {
        for(ll i=pseq+1; i<N-1; i++) {
            res.push_back(P(A[0], A[i]));
            A[0] -= A[i];   
        }
        res.push_back(P(A[N-1], A[0]));
        A[N-1] -= A[0];
       
    } else {
        for(ll i=0; i<N-1; i++) {
            res.push_back(P(A[N-1], A[i]));
            A[N-1] -= A[i];
        }    
    }
    
    
     cout << A[N-1] << endl;
    for(auto& p: res) {
        cout << p.first << " " << p.second << endl;
    }
    return 0;
    
}

Measured memory_bytes: 4336
#include <stdio.h>

void InsertionSort(int n, int nums[]) {
  int i, j, k;
  int v;

  for (k = 0; k < n; k++) {
    printf("%d", nums[k]);
    if (k == n-1)  {
      putchar ('\n');
      break;
    }
    putchar(' ');
  }
  
  for (i = 1; i < n; i++) {
    v = nums[i];
    j = i-1;
    while (0 <= j && v < nums[j]) {
      nums[j+1] = nums[j];
      j--;
    }
    nums[j+1] = v;
    for (k = 0; k < n; k++) {
      printf("%d", nums[k]);
      if (k == n-1)  {
	putchar ('\n');
	break;
      }
      putchar(' ');
    }
  }
  
}

int main() {
  int n;
  int nums[100];

  scanf("%d", &n);

  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &nums[i]);
  }

  InsertionSort(n, nums);

  return 0;
}


Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector<bool> ds(10,true);
    rep(i,k){
        int d;
        cin>>d;
        ds.at(d)=false;
    }
    
    while(true){
        string m=to_string(n);
        bool ok=true;
        int s=m.size();
        rep(i,s) if(!ds.at(m.at(i)-'0')) ok=false;
        if(ok){
            cout<<n<<endl;
            break;
        }
        n++;
    }
    
}


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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> C(N, 0);
  int x;
  
  for (int i = 0; i < 2 * M; i++) {
  	cin >> x;
    C.at(x - 1)++;
  } 
  
  for (int i = 0; i < N; i++)
    cout << C.at(i) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{

	public static void main(String[] args) 
	{
		Scanner sc  = new Scanner(System.in);
		
		long money = sc.nextLong();
		
		long totalMoney = 0;
		
		long fiveHundredCoin = money/500;
		totalMoney = fiveHundredCoin * 1000;
		long remaining = money%500;
		
		long fiveCoin = remaining/5;
		totalMoney += fiveCoin * 5;
		
		System.out.println(totalMoney);
		
		

	}

}


Measured memory_bytes: 21844