akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <functional>
#include <iomanip>

using namespace std;

#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif
#define out(v) cout<<v<<"\n"
#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
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; }
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}

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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  string S; cin >> S;
  string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  rep(i, S.size()) {
    cout << alphabet[alphabet.find_first_of(S[i])+N];
  }
  cout << "\n";

  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    D, X = map(int, input().split())
    A = tuple(int(input()) for _ in [0] * N)

    choco = 0
    for i in A:
        j = 0
        n = 0
        while 1:
            n = i * j + 1
            j += 1
            if n > D:
                break
            choco += 1
    print(choco + X)

main()


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main() {
	unsigned long long a = 1, b,c[100010],d= 1000000000000000000;
	cin >> b;
	for (int i = 0; i < b; i++) {
		cin >> c[i];
		if (c[i] == 0) { cout << "0"; return 0; }
	}
	for (int i = 0; i < b; i++) {
		d /= c[i];
		if (d < 1) { cout << "-1"; return 0; }
	}
	for (int i = 0; i < b; i++) {
		a *= c[i];
		if (a > 1000000000000000000) { cout << "-1"; return 0; }
	}
	cout << a;

	return 0;
}

Measured memory_bytes: 4376
import math
K = int(input())
ans = 0
for a in range(1,K+1):
  for b in range(a,K+1):
    t = math.gcd(a, b)
    for c in range(b,K+1):
      if a==b and a==c:
        x=1
      elif a!=b and b!=c and c!=a:
        x=6
      else:
        x=3
      ans += x*math.gcd(t,c)
print(ans)

Measured memory_bytes: 9196
a = input()
if a == "SUN":
  print(7)
elif a == "MON":
    print(6)
elif a == "TUE":
    print(5)
elif a == "WED":
    print(4)
elif a == "THU":
    print(3)
elif a == "FRI":
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
int b[2]={-1,1};
char c[2]={'-','+'};
int main(){
	int A=getchar()-'0',B=getchar()-'0',C=getchar()-'0',D=getchar()-'0';
	REP(op1,0,1)REP(op2,0,1)REP(op3,0,1){
		int x=A+b[op1]*B+b[op2]*C+b[op3]*D;
		if(x==7){
			printf("%d%c%d%c%d%c%d=7\n",A,c[op1],B,c[op2],C,c[op3],D);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
require 'prime'

X = gets.to_i

def calc(x, y) x**5 - y**5 end

def divisors(n)
  n.prime_division.inject([1]) do |ary, (p, e)|
    (0..e).map{ |e1| p ** e1 }.product(ary).map{ |a, b| a * b }
  end.sort
end

ans = [0, 0]
divisors(X).each{|n|
  (0..120).each{|i|
    wk = calc(i, i-n)
    if wk == X then
      ans = [i, i-n]
      break
    end
  }
  break if ans != [0, 0]
}

puts ans*?\s


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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define ceill(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
ll mod = 1e9+7;
void ans(bool b, ostream& out=cout){ out << (b ? "Yes" : "No") << endl; }
void ans2(bool b, ostream& out=cout){ out << (b ? "YES" : "NO") << endl; }
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill((T*)array, (T*)(array+N), val);}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};

#ifndef INCLUDE_DEBUG_HPP
#define INCLUDE_DEBUG_HPP

class debug
{
public:
    template<typename T> void vdeb(T vec);
    template<typename T1, typename T2> void adeb(T1 *arr, T2 n);
    template<typename T> void mdeb(T mp);
};

#endif //INCLUDE_DEBUG_HPP

template<typename T> void debug::vdeb(T vec)
{
    cout << "#vector set debug" << endl;
    for(auto vv : vec) cout << vv << " ";
    cout << endl;
}

template<typename T1, typename T2> void debug::adeb(T1 *arr, T2 n)
{
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}

template<typename T> void debug::mdeb(T mp)
{
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
debug dbg;

class ARatedForMe {
public:
	void solve(std::istream& in, std::ostream& out)
	{
	    int r;
	    in >> r;
	    if(r < 1200) out << "ABC" << endl;
	    else if(r < 2800) out << "ARC" << endl;
	    else out << "AGC" << endl;
	}
};


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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][]A = new int[2][N];
		for(int i = 0; i < N; i++) {
			A[0][i] = sc.nextInt();
		}
		for(int i = 0; i < N; i++) {
			A[1][i] = sc.nextInt();
		}
		sc.close();
		if(N == 1) {
			System.out.println(A[0][0] + A[1][0]);
			System.exit(0);
		}
		int[][]B = new int[2][N];
		B[0][0] = A[0][0];
		B[1][0] = A[1][0] + A[0][0];
		for(int i = 1; i < N; i++) {
			B[0][i] = B[0][i - 1] + A[0][i];
			B[1][i] = B[1][i - 1] + A[1][i];
		}


		for(int i = 1; i < N; i++) {
			B[1][i] = Math.max(B[1][i - 1] + A[1][i], B[0][i] + A[1][i]);
		}
//		for(int i = 0; i < 2; i++) {
//			for(int j = 0; j < N; j++) {
//				System.out.printf("%d ", B[i][j]);
//			}
//			System.out.println();
//		}
		//B[1][N - 1] = Math.max(B[1][N - 2] + A[1][N - 1], B[0][N - 1] + A[1][N - 1]);
		System.out.println(B[1][N - 1]);
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define PI acos(-1.0)
//---------------------------

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



  int n;
  long long ans = 1;
  long long MOD = 1e9+7;
  string s,s2;
  cin >> n >> s >> s2;
  vector<int> v;

  //2タイプ判定
  for (int i = 0; s[i] != '\0'; i++) {
    if (s[i] == s[i+1]) {
      v.push_back(1);
      i++;
    }else{
      v.push_back(0);
    }
  }
  if (v[0] == 0) {
    ans *= 3;
  }else{
    ans *= 6;
  }
  for (int i = 0; i < v.size() - 1; i++) {
    if (v[i] == 0) {
      ans *= 2;
    }else if (v[i] == 1 && v[i+1] == 0) {
      ans = ans * 1;
    }else if (v[i] == 1 && v[i+1] == 1) {
      ans = ans * 3;
    }
  }
  P(ans % MOD);

  return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
X = [2*i//K for i in range(1,N+1) if 2*i%K == 0]
count1 = 0
count2 = 0
for x in X:
    if x%2 == 0:
        count1 += 1
    else:
        count2 += 1
print(count1**3 + count2**3)

Measured memory_bytes: 10936
s = input()
kita, minami = sorted([s.count('N'),s.count('S')])
nisi, higasi = sorted([s.count('W'),s.count('E')])
result = ['No','Yes']
r = 1
if kita==minami or kita*minami > 0:
    r *= 1
else:
    r = 0

if nisi==higasi or nisi*higasi > 0:
    r *= 1
else:
    r = 0
print(result[r])

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

typedef long long ll;
#define pb push_back

// int gcd(int a, int b) {   if (b == 0) return a; return gcd(b, a % b);  }
// int lcm(int a,int b){return a/gcd(a,b)*b;}

int main(){
    int n,cnt=0;
    cin>>n;
    int l[n];
    for(int i=0;i<n;i++) cin>>l[i];
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(((l[i]+l[j])>l[k]) && ((l[j]+l[k])>l[i]) && ((l[i]+l[k])>l[j]) && ((abs(l[k]-l[j]))<l[i]) && ((abs(l[j]-l[i]))<l[k]) && (abs((l[k]-l[i]))<l[j]) && l[i]!=l[j] && l[j]!=l[k] && l[k]!=l[i]){
                    // cout<<l[i]<<" "<<l[j]<<" "<<l[k]<<"\n";
                    cnt++;
                }
            }
        }
    }
    cout<<cnt;
    return 0;
}


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

int main() {
  int A, B, C, D;
  
  cin >> A >> B >> C >> D;
  
  int sum_l = A + B;
  int sum_r = C + D;
  
  if (sum_l > sum_r) {
    cout << "Left" << endl;
  }
  else if (sum_l < sum_r) {
    cout << "Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define dbug(x) cout<<#x<<"="<<x<<endl
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
int n,x,ans;
multiset<int> s;
multiset<int>::iterator it;
int main() {
	//freopen("1.txt","r",stdin);
	read(n);
	for (int i=1;i<=n;i++) {
		read(x);
		it=s.lower_bound(x);
		if (i==1||it==s.begin()) s.insert(x),ans++;
		else {
			it--;
			s.erase(it);
			s.insert(x);
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
	int n,y;
	cin >> n >> y;
	int a,b,c;
	a=b=c=-1;
	for(int i=0; i<=n; ++i){
		for(int j=0; j<=n-i; ++j){
			if(10000*i + 5000*j + 1000*(n-i-j) == y){
				a=i;
				b=j;
				c=n-i-j;
				goto END;
			}
		}
	}
	END:
	cout << a << " " << b << " " << c << endl;

	return 0;
}

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

K = 1
while K*(K-1)//2 < N:
    K += 1

if N != K*(K-1)//2:
    print("No")
    exit(0)
print("Yes")
S = [[] for i in range(K)]

print(K)

v = 1
for i in range(K):
    for j in range(i+1, K):
        S[i].append(v)
        S[j].append(v)
        v += 1
for s in S:
    print(len(s), *s)

Measured memory_bytes: 9416
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n ;
  int a ;
  cin >> n;
  int kisu =0;
  for(int i = 0; i< n ;i++){
    cin >> a ;
    if( a%2 !=0){
      kisu +=1;
    }
  }
  if(kisu%2 == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" <<endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1e14;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;

signed main() {
    int H, W, A, B;
    cin >> H >> W >> A >> B;
    for(int i = 0;i < H;i++) {
        for(int j = 0;j < W;j++) {
            if((i < B && j < A) || (i >= B && j >= A)) {
                cout << 0;
            }
            else {
                cout << 1;
            }
            if(j == W - 1) {
                cout << endl;
            }
        }
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int N;
    cin>>N;
    int H[100001];
    bool can=true;
    
    for(int i=0;i<N;i++){
        cin>>H[i];
    }
    
    for(int i=N-1;i>=0;i--){
        if(H[i-1]>H[i]){
            H[i-1]--;}
            //cout<<i<<endl;
        }

    for(int i=0;i<N-1;i++){
        if(H[i]>H[i+1]){
            can=false;
            break;
        } //cout<<i<<endl;
        }

if(can==true) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}

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

using namespace std;
using ll = long long;
string a,b;
int ans;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);
    cin>>a>>b;
    for(int i=0; i<a.size(); i++){
        if(a[i]!=b[i]) ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 300010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S;

void solve() {
	cin >> S;
	N = sz(S);
	for(int i = 0; i < N; i++) {
		for(int j = i; j < N + 1; j++) {
			string key = S.substr(0, i) + S.substr(j, -1);
			// debug(i, j, key);
			if(key == "keyence") {
				cout << "YES\n";
				return;
			}
		}
	}
	cout << "NO\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n,a,b;
int main(){
	scanf("%d %d",&a,&b);
	int mx1=a+b;
	printf("%d\n",max(mx1,max(a-b,a*b)));
	return 0;
}




Measured memory_bytes: 256
s = input()
b = 'AKIHABARA'
n = len(b)
if  n < len(s):
    print('NO')
    exit()
j = 0
s += 'A'
for i in range(n):
    if b[i] == 'A' and s[j] == 'A':
        j += 1
    elif b[i] == 'A' and s[j] != 'A':
        continue
    elif b[i] == s[j]:
        j += 1
    else:
        print('NO')
        exit()
print('YES')
    


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

#define int long long

using namespace std;



const int MAXN = 5000 + 23, MXN2 = MAXN * MAXN + 23;












int n, c[2 + (3)][3 + (3)], dp1[MAXN], dp2[MXN2];





int32_t main() {
	cin >> n;
	for (int i = 0; i < 2; i++) for (int j = 0; j < 3; j++) cin >> c[i][j];
	iota(dp1, dp1 + MAXN, 0);
	for (int i = 0; i < MAXN; i++) for (int j = 0; j < 3; j++) if (i >= c[0][j]) dp1[i] = max(dp1[i], dp1[i - c[0][j]] + c[1][j]);
	iota(dp2, dp2 + MXN2, 0);
	for (int i = 0; i < MXN2; i++) for (int j = 0; j < 3; j++) if (i >= c[1][j]) dp2[i] = max(dp2[i], dp2[i - c[1][j]] + c[0][j]);
	cout << dp2[dp1[n]];
	return 0;
}

Measured memory_bytes: 197376
#include<iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int n,m;
map<int,vector<pair<int,int> > >G[1<<17];
map<int,int>d[1<<17];
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		G[a][c].push_back(make_pair(b,c));
		G[b][c].push_back(make_pair(a,c));
		G[a][c].push_back(make_pair(a,0));
		G[b][c].push_back(make_pair(b,0));
		G[a][0].push_back(make_pair(b,c));
		G[b][0].push_back(make_pair(a,c));
	}
	priority_queue<pair<int,pair<int,int> > >P;
	d[1][0]=0;
	P.push(make_pair(0,make_pair(1,0)));
	while(!P.empty())
	{
		int dis=-P.top().first;
		int u=P.top().second.first;
		int c=P.top().second.second;
		P.pop();
		if(u==n&&c==0)
		{
			cout<<dis<<endl;
			return 0;
		}
		if(d[u][c]<dis)continue;
		for(pair<int,int>&p:G[u][c])
		{
			int v=p.first;
			int cost=dis+!c;
			int col=p.second;
			if(d[v].find(col)==d[v].end()||d[v][col]>cost)
			{
				d[v][col]=cost;
				P.push(make_pair(-cost,make_pair(v,col)));
			}
		}
	}
	cout<<-1<<endl;
}

Measured memory_bytes: 84404
/*
ex6_2
tomatokan
*/

#include<stdio.h>

int main(void){
    int length=0;
    char head;
    char tail;
    char read;
    scanf("%c",&read);//読み取り
    head=read;
    while(read!='\n'){
        tail=read;
        length++;//改行までの文字の読み取り回数を数える
        scanf("%c",&read);
    }
    printf("%c%d%c\n",head,length-2,tail);
    return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,x;
    cin>>n>>x;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = 1e18;
    for(int i=0;i<n;i++){
        ll ret = 0;
        multiset<ll> st;
        for(int j=0;j<=i;j++){
            st.insert(a[j]);
        }
        for(int j=0;j<n;j++){
            int t = (i+j+1)%n;
            ret += *st.begin();
            st.erase(a[j]);
            st.insert(a[t]);
        }
        
        ans = min(ans, ret + x*i);
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys


def solve(N: int):
    from itertools import takewhile, count
    dp = list(range(N+1))
    for n in (6, 9):
        for m in takewhile(lambda x: x<=N, (n**e for e in count(1))):
            for i in range(m, N+1):
                dp[i] = min(dp[i], dp[i-m]+1)
    return dp[N]


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    print(solve(N))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


Measured memory_bytes: 12492
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,r;
    cin>>n>>r;
    if(n>=10){
        cout << r<<endl;
    }else{
        cout << r+100*(10-n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
//ALDS1_11C
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

static const int N=100;
static const int INF=(1<<21);
int n,d[N];
vector<vector<int> > M(N,vector<int>(N));

void bfs(int s){
 queue<int> q;
 q.push(s);
 for(int i=0;i<n;i++) d[i]=INF;
 d[s]=0;
 int u;
 while(!q.empty()){
  u=q.front();
  q.pop();
  for(int v=0;v<n;v++){
   if(M[u][v]==0) continue;
   if(d[v]!=INF) continue;
   d[v]=d[u]+1;
   q.push(v);
  }
 }
 for(int i=0;i<n;i++){
  cout<<i+1<<" "<<((d[i]==INF) ? (-1):d[i])<<endl;
 }
}

int main(){
 int u,k,v;
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>u>>k;
  u--;
  for(int j=0;j<k;j++){
   cin>>v;
   v--;
   M[u][v]=1;
  }
 }
 bfs(0);
 return 0;
}

Measured memory_bytes: 1260
// inputに入力データ全体が入る
function Main(input) {
  inputs = input.split(/\n/);
  // N 個の県, M個の市
  var firstLine = inputs[0]
  var firstLines = firstLine.split(/\s/)
  var n = Number(firstLines[0])
  var m = Number(firstLines[1])

  var prefs = {}
  var prefLineLength = inputs.length - 1 - 1
  for (var i = 0; i < prefLineLength; i++) {
    var prefLine = inputs[i+1]
    var prefLines = prefLine.split(/\s/)
    var p = Number(prefLines[0])
    var y = Number(prefLines[1])
    if (!prefs[p]) {
      prefs[p] = []
    }
    prefs[p].push({i: i, pref: p, year: y})
  }

  var cities = []
  for (var i = 0; i <= n; i++) {
    var pref = prefs[i]
    if (!pref) continue;
    pref.sort(function(a,b) {
      return a.year - b.year;
    })
    for (var j = 0; j < pref.length; j++) {
      pref[j].ID = ("00000"+pref[j].pref).slice(-6)+("00000"+(j+1)).slice(-6)
      cities.push(pref[j])
    }
  }

  cities.sort(function(a, b) {
    return a.i - b.i
  })

  console.log( cities.map(a => a.ID).join("\n") )
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));



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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> to[n],from[n];
  rep(i,0,m){
    int a,b;
    cin>>a>>b;
    to[a-1].push_back(b-1);
    from[b-1].push_back(a-1);
  }
  vector<int> ans(n+1);
  rep(i,0,n){
    int dist[n];
    rep(j,0,n) dist[j]=114514;
    dist[i]=0;
    queue<int> q;
    q.push(i);
    int par[n];
    rep(j,0,n) par[j]=-1;
    while(q.size()){
      int r=q.front();
      q.pop();
      for(int x:to[r]){
        if(dist[x]==114514){
          dist[x]=dist[r]+1;
          q.push(x);
          par[x]=r;
        }
      }
    }
    P p=P(114514,-1);
    for(int x:from[i]){
      if(dist[x]<p.first){
        p=P(dist[x],x);
      }
    }
    if(p.first<ans.size()){
      vector<int> v;
      int cur=p.second;
      while(cur!=i){
        v.push_back(cur);
        cur=par[cur];
      }
      v.push_back(i);
      ans=v;
    }
  }
  if(ans.size()==n+1) cout<<-1<<endl;
  else{
    cout<<ans.size()<<endl;
    for(int x:ans) cout<<x+1<<endl;
  }
}

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

int main() {
  int n, i, j;
  cin >> n;
  i = n % 1000;
  j = n / 10;
  if (i % 111 == 0 || j % 111 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

temp = N
S = ""
while temp != 0:
    rem = temp % -2
    div = temp // -2
    if rem == -1:
        div += 1
        rem = 1
    temp = div
    S = str(rem) + S
if N == 0:
    print(0)
else:
    print(S)

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

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

  string s;
  map<string, ll> mp;
  rep(i,0,N-1) {
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }

  ll ans = 0;
  for (auto p : mp) ans += p.second * (p.second - 1) / 2;

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


Measured memory_bytes: 11376
n=int(input())
x=[]
y=[]
h=[]
for i in range(n):
  a,b,c=map(int,input().split())
  x.append(a)
  y.append(b)
  h.append(c)
  if c!=0:q=[a,b,c]
for i in range(101):
  for j in range(101):
    H=q[2]+abs(q[0]-i)+abs(q[1]-j)
    for a,b,c in zip(x,y,h):
      if c!=max(H-abs(a-i)-abs(b-j),0):break
    else:
      print(i,j,H)
      exit()

Measured memory_bytes: 73732
#include <iostream>
#include <set>
#include <cmath>
#include <tuple>
#include <vector>
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(){
	ll a,b,c;
	std::string ans = "NO";
	std::cin >> a>>b>>c;
	for ( int i = 1 ; i <= b ; i++ ) {
		if((i*a)%b==c) ans="YES";
	}
	std::cout << ans << std::endl;
	return 0;
}


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

using namespace std;

int main(){
    long long n, m, ans = 0;
    cin >> n >> m;
    if(!m) {cout << n*n << endl; return 0;}
    for(int i = m + 1; i <= n; i++){
        if(n % i == 0){
            ans += max(0ll, (i - m) * (n / i));
        }
        else{
            ans += max(0ll, (i - m) * (n / i));
            ans += max(0ll,(n % i < m) ? 0 : (n % i - m + 1));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// ~/Remember,remember the 6th of March
#include <functional>
#include <iomanip>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include<complex>
#include <unordered_map>
#include<unordered_set>
#include <numeric>
#include <string>
#include<iostream>
#include <fstream>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include<cmath>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int N = 1000007;
void fast()
{
	std::ios_base::sync_with_stdio(0);
}

int main()
{
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	//	freopen("output.txt","w",stdout);
#endif*/
	int r;
	cin >> r;
	cout << r * r << endl;
	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,m,i,j,k,a;
    double b;
	t = 1;
	while(t--) {
          a = 0;
	      cin >> n >> m;
          int arr[n][m];
          for(i = 0; i < n; i++)
           for(j = 0; j < m; j++)
            cin >> arr[i][j];
          for(i = 0; i < n - 1; i++) {
           for(j = i + 1; j < n; j++) {
            b = 0;
            for(k = 0; k < m; k++) {
             b = b + pow(arr[i][k] - arr[j][k], 2);
            }
            if(int(sqrt(b)) == sqrt(b))
             a++;
           }
          }
          cout << a << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cassert>
const int MAXN = 1e5 + 10;
typedef int IntAr[MAXN];
typedef long long LL;

int N;
IntAr A, B, C, D;
LL tot;

namespace FastIO {
	template <typename T>
	void read(T & x) {
		x = 0; register char ch = getchar();
		for (; ch < '0' || ch > '9'; ch = getchar());
		for (; ch >= '0' && ch <= '9'; x = (x << 3) + (x << 1) + (ch ^ '0'), ch = getchar());
	}
}
LL count(int);
void merge(int l, int r);

// #define DEBUG_MD_

int main() {
	using FastIO::read;
	read(N);
	for (int i = 0; i < N; i++) scanf("%d", &A[i]);
	memcpy(B, A, sizeof(int) * N);
	std::sort(B, B + N);
	int lb = -1, mid, ub = std::unique(B, B + N) - B - 1;
	LL pos = (LL(N) * (N + 1) >> 2) + 1;
#ifdef DEBUG_MD_
	printf("pos=%lld\n", pos);
#endif 
	for (; ub - lb > 1; ) { // (lb, ub]
		mid = lb + ub >> 1;
		assert(mid >= 0);
		if (count(B[mid]) >= pos) ub = mid;
		else lb = mid;
	}
	// return 0;
	printf("%d\n", B[ub]);
	return 0;
}

LL count(int key) {
	C[0] = 0;
	for (int i = 1; i <= N; i++) C[i] = C[i - 1] + (A[i - 1] > key ? -1 : 1);
	tot = 0;
	merge(0, N + 1);
#ifdef DEBUG_MD_
	printf("key=%d, tot=%lld\n", key, tot);
#endif 
	return tot;
}

void merge(int l, int r) {
	// merge sort interval [l, r)
	if (r - l <= 1) return;
	int mid = l + r >> 1;
	merge(l, mid);
	merge(mid, r);
#ifdef DEBUG_MD_
	printf("[%d, %d)\n", l, r);
#endif
	int i, j, k;
	for (i = l, j = mid, k = l; i < mid && j < r; )
		if (C[i] < C[j]) {
			D[k++] = C[i++];
			tot += r - j;
		}
		else D[k++] = C[j++];
	for (; i < mid; ) D[k++] = C[i++];
	for (; j < r; ) D[k++] = C[j++];
	memcpy(C + l, D + l, sizeof(int) * (r - l));
}

Measured memory_bytes: 1664
from collections import Counter
N = int(input())
A = []
for _ in range(N):
  A.append(input())

c = Counter(A)
maxcnt = c.most_common()[0][1]
l = []
for i in c.most_common():
  if i[1] != maxcnt:
    break
  l.append(i[0])

for s in sorted(l):
  print(s)

Measured memory_bytes: 45040
n = gets.chomp.to_i
matrix = Array.new(n) {Array.new(n, 0)}

n.times do |row|
  inputs = gets.chomp.split.map(&:to_i)
  inputs[1].times do |index|
    matrix[inputs[0]-1][inputs[2+index]-1] = 1
  end
end

matrix.each do |row|
  puts row.join(' ')
end

Measured memory_bytes: 8896
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    // Write Your Code Below
    string a;
    cin >> a;
    cout << a[0] << a.size()-2 << a[a.size()-1] << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,a,b,n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=1;i<=n;i++) cin>>arr[i-1];
    sort(arr,arr+n);
    int ans=0;
    for(int i=0;i<k;i++) ans+=arr[i];
    cout<<ans<<endl;

}



Measured memory_bytes: 3640
#include <cstdio>
#define g getchar();
inline void r(int &x){x=0;char c=g;while(c<'0')c=g;while(c>='0'){x=x*10+c-48;c=g;}}int x[100000];int main(){int n,a,b;r(n);r(a);r(b);long d=0;r(x[0]);for(int i=1;i<n;i++){r(x[i]);d+=(long)a*(x[i]-x[i-1])>b?b:(long)a*(x[i]-x[i-1]);}printf("%ld\n",d);}


Measured memory_bytes: 512
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
  int a, b, c, d, f;
  double e;
  cin >> a >> b >> c >> d >> e >> f;
  vector<double> w,s;

  for (int i = 0; 100 * a * i <= f; i++){
    for (int k = 0; 100 * a * i + 100 * b * k <= f; k++){
      if (i == 0 && k == 0){
        continue;
      }
      w.push_back(100 * a * i + 100 * b * k);
    }
  }
  for (int i = 0; c * i <= f; i++){
    for (int k = 0; c * i + d * k <= f; k++){
      s.push_back(c * i + d * k);
    }
  }

  int aw = 100 * a, as = 0;
  double Max = 0;
  double D = e / (100 + e);
  for (int i = 0; i < w.size(); i++){
    for (int k = 0; k < s.size(); k++){
      if (w[i] + s[k] > f){
          continue;
      }
      double dens = s[k] / (w[i] + s[k]);
      if (dens > Max && dens <= D)
      {
        Max = dens;
        aw = w[i];
        as = s[k];
      }
    }
  }
  cout << aw + as << " " << as << endl;
  return 0;

}


Measured memory_bytes: 2420
<?php

class Magic
{
    public $d;
    public $c;
}

sscanf(fgets(STDIN), "%d %d", $h, $n);

$mag = [];
for ($i = 0; $i < $n; $i++) {
    sscanf(fgets(STDIN), "%d %d", $d, $c);

    $mag[] = [$d, $c]; 
}

$arr[0] = 0;

for ($i = 0; $i < $h; $i++) {
    if (!isset($arr[$i])) continue;
    
    $prev = $arr[$i];
    foreach ($mag as $magic) {
        $idx = min($h, $i + $magic[0]);
        
        if (!isset($arr[$idx]))
            $arr[$idx] = $prev + $magic[1];
        else
            $arr[$idx] = min($prev + $magic[1], $arr[$idx]);
    }
}

echo $arr[$h];

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

int main() {
  int N;
  long long K;
  cin >> N >> K;
  vector<pair<int,long long>> ab(N);
  for(int i=0;i<N;i++){
    cin >> ab.at(i).first >> ab.at(i).second;
  }
  
  sort(ab.begin(),ab.end());
  
  long long cnt = 0;
  for(int i=0;i<N;i++){
    cnt += ab.at(i).second;
    if( cnt >= K ){
      cout << ab.at(i).first << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

ll n, k;
vector<ll> v;

ll throw_away(priority_queue<int, vector<int>, greater<int>> q_minus, int num) {
  ll sum = 0;

  for (ll i = 0; i < num; i++) {
    sum += q_minus.top();
    q_minus.pop();
  }
  return sum;
}

// 35569098

ll calc(ll leftnum, ll rightnum) {
  priority_queue<int, std::vector<int>, std::greater<int>> q_minus;
  // -> 0,1,2,...

  ll plus_sum = 0;

  ll minus_sum = 0;

  ll remain = k;

  ll left_index = 0;
  ll right_index = n - 1;

  for (;;) {
    if (remain <= 0) {
      break;
    }
    if (left_index > right_index) {
      break;
    }

    ll ope;

    if (leftnum > 0) {
      leftnum--;
      ope = 0;
    } else if (rightnum > 0) {
      rightnum--;
      ope = 1;
    } else {
      break;
    }

    ll num;
    if (ope == 0) {
      // left
      num = v[left_index];
      left_index++;
    } else {
      // right
      num = v[right_index];
      right_index--;
    }

    if (num >= 0) {
      plus_sum += num;
    } else {
      minus_sum += num;
      q_minus.push(num);
    }
    remain--;
  }

  ll current_value = plus_sum + minus_sum;
  if (remain >= q_minus.size()) {
    current_value -= minus_sum;
  } else if (remain > 0) {
    current_value -= throw_away(q_minus, remain);
  }

  return current_value;
}

int main() {
  scanf("%lld %lld", &n, &k);
  v.resize(n);

  for (ll i = 0; i < n; i++) {
    scanf("%lld", &v[i]);
  }

  ll ans = 0;

  // for (ll i = 0; i < (1ll << n); i++) {
  //   ans = max(ans, calc(i));
  // }

  for (ll i = 0; i <= k; i++) {
    for (ll j = 0; j <= (k - i); j++) {
      ll left = i;
      ll right = j;

      ans = max(ans, calc(left, right));
    }
  }

  cout << ans << endl;
}

// 6 4
// -10 8 2 1 2 6


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;

const int mod = 1e9+7;
int N;

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

  cin >> N;

  string s;

  int cnt = 0;
  if (N == 0) {
    cout << 0 << endl;
    return 0;
  }

  while (N != 0) {
    if (N%2 == 0) {
      s.push_back('0');
    } else {
      s.push_back('1');
      if (cnt%2 == 0) {
        N--;
      } else {
        N++;
      }
    }
    N = N/2;
    cnt++;
  }
  reverse(s.begin(), s.end());
  cout << s << endl;
}

Measured memory_bytes: 256
n,m,c = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n):
  sum_i = c
  for j in range(m):
    sum_i += A[i][j]*B[j]
  if sum_i > 0:
    ans += 1
print(ans)

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

int main()
{
    int n,m,max,GCD = 1;
    cin >> n >> m;
    max = m/n;

    for(int i = max; i > 0; i--)
    {
        if(m%i == 0)
        {
            GCD = i;
            break;
        }
    }

    cout << GCD << endl;
}    


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)
from collections import defaultdict


def read():
    N = int(input().strip())
    return N,


def sieve(n):
    """
    n以下の素数を昇順に列挙する
    """
    is_prime = [True for i in range(n+1)]
    primes = []
    for i in range(2, n+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i+i, n+1, i):
                is_prime[j] = False
    return primes


def prime_factorization(n, primes):
    """
    nの素因数分解を求める
    """
    prime_factors = defaultdict(int)
    if n < 2:
        return prime_factors
    for p in primes:
        if p * p > n:
            break
        while n % p == 0:
            prime_factors[p] += 1
            n //= p
    if n > 1:
        prime_factors[n] = 1
    return prime_factors


def solve(N, INF = 10**8):
    primes = sieve(10**6+1)
    factors = prime_factorization(N, primes)
    ans = 0
    for c in factors.values():
        m = 0
        for i in range(1, 63):
            if m + i <= c:
                m += i
                ans += 1
            else:
                break
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 20416
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    // Your code here!
 ll i,n;
 string t;
 t="";
 cin >> n;
 if(n<=26)
 {
  cout << (char)(n+'a'-1);
  return 0;
 }
 while(n>0)
 {
  for(i=1;i<=26;i++)
  {
   if((n-i)%26==0)
   {
    t.append(1,(char)(i+'a'-1));
    n=(n-i)/26;
    break;
   }
  }
 }
 reverse(t.begin(),t.end());
 cout << t;
 return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, q;
	cin >>n >>m >>q;
	VI a(q), b(q), c(q), d(q);
	rep(i, q){ cin >>a[i] >>b[i] >>c[i] >>d[i]; a[i]--; b[i]--;}
	int ans = 0;
	rep(msk, 1<<(n+m-1)){
		if(__builtin_popcount(msk) !=n ) continue;
		VI v; int ct =0;
		rep(i, n+m-1){ if(msk>>i &1) v.push_back(ct); else ct++;}
		int sm = 0;
		rep(i, q) if(v[b[i]] - v[a[i]] == c[i]) sm += d[i];
		ans = max(ans, sm);
	}
	cout <<ans <<"\n";
	return 0;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A == B) {
  	cout << "Draw" << endl;
  }
  else if ((A == 1) || (B == 1)) {
  	if (A == 1) {
    	cout << "Alice" << endl;
    }
    else {
    	cout << "Bob" << endl;
    }
  }
  else if (A < B) {
  	cout << "Bob" << endl;
  }
  else {
  	cout << "Alice" << endl;
  }    
}


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

int main(){
    int B, C, sum=0;
    vector<int> A(3);

for(int i = 0; i < 3; i++){
    cin >> A[i];
}
    sort(A.begin(), A.end());
    
    sum += A[0] + A[1]; 

    //vector<int> S(A);

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int x,k,d;
//	unsigned long long x,k,d;
	cin>>x>>k>>d;
	if(x<0)
	{
		x=(-x);
	}
  long long int t=k;
	k=k-(x/d);
	
  if(k<0)
  {
    cout<<abs(x-t*d)<<endl;
  }
  else
  {
    x=x%d;
	if(k%2==0)
	{
		cout<<x<<endl;
	}
	else
	{
		cout<<abs(x-d)<<endl;
	}
  }
}

Measured memory_bytes: 3592
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int H = sc.nextInt();
        int M = sc.nextInt();
        double mrad = 6*M;
        double hrad = (30*H) + (0.5*M);
        double angle = Math.abs(mrad - hrad);
        double C = Math.sqrt(Math.pow(A,2) + Math.pow(B,2) - 2*A*B*Math.cos(Math.toRadians(angle)));
        System.out.println(C);
    }
}


Measured memory_bytes: 35916
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/27/20 20:37:13
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> ds(n+1, 1);
  ll ans = 0;
  for (int m = 1; m <= n; m++) {
    ll c = n/m;
    ans += (c*(c+1)/2)*m;
  }
  cout << ans << endl;

  return 0;
}


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

#define int long long

using namespace std;

#define N 1000005

int fact[N];
int infact[N];

#define ll long long

#define mod 1000000007

ll gcd(ll aa,ll bb) { if(aa==0) return bb; return(bb%aa,aa); }

ll gcdExtended(ll a, ll b, ll *x, ll *y);

// Function to find modulo inverse of a
ll modInverse(ll a, ll m)
{
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);

    ll res = (x%m + m) % m;
    return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y)
{
    // Base Case
    if (a == 0)
    {
        *x = 0, *y = 1;
        return b;
    }

    ll x1, y1; // To store results of recursive call
    ll gcd = gcdExtended(b%a, a, &x1, &y1);

    // Update x and y using results of recursive
    // call
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}


int findme(int x1,int y1,int x2,int y2)
{
        int n=x2-x1+y2-y1;

        int r=x2-x1;
        int ncr=fact[n]*infact[r];
        ncr%=mod;
        ncr*=infact[n-r];
        ncr%=mod;

        return ncr;
}

void foo()
{
        fact[0]=1;
        infact[0]=1;
        for(int i=1;i<N;i++)
        {
                fact[i]=fact[i-1]*i;
                fact[i]%=mod;
                infact[i]=modInverse(fact[i],mod);
        }
}

int32_t main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        foo();
        int h,w,a,b;
        cin>>h>>w>>a>>b;

        int ans=0;
        int x=h-a;
        for(int i=b+1;i<=w;i++)
        {
                int cur=findme(1,1,x,i);
                int nex=findme(x+1,i,h,w);
                //cout<<x<<" "<<i<<endl;
                ans+=(cur*nex)%mod;
                ans%=mod;
        }

        cout<<ans<<endl;

        return 0;

}

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

vector < int > v;

bool check(int n, int m, int mid){

    int x=(m-mid);
    long long int y=(n-1)*1LL*mid;
    return (x>=y && x%mid==0);
    ///return (m/mid>=n && m%mid==0);
}

int cal(int n, int m){
    int ans=0;
    for(int i=1; i*i<=m; i++){
        if(m%i==0){
             if(check(n,m,i))ans=max(ans,i);
             if(check(n,m,m/i))ans=max(ans,m/i);
        }
    }
    return ans;
}

int main(){

    int n,m;
    cin>>n>>m;
    int ans=cal(n,m);
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int N,A,B,P1,P2;

    cin >> N >> A >> B;
    P1 = A*N;
    P2 = B;
    
    if(P1>=P2){
        cout << P2 << endl;
    }else{
        cout << P1 << endl;
    }
}


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

#define N (31)

int memo[N];

int getWay(int n)
{
	int ret = 0;
	
	if (memo[n] != -1){
		return (memo[n]);
	}
	
	if (n == 1){
		return (1);
	}
	if (n == 2){
		return (2);
	}
	if (n == 3){
		return (4);
	}
	
	ret += (getWay(n - 1) + getWay(n - 2) + getWay(n - 3));
	
	return (memo[n] = ret);
}


int main(void)
{
	int n;
	while (1){
		scanf("%d", &n);
		memset(memo, -1, sizeof(memo));
		
		if (n == 0){
			break;
		}
		
		printf("%d\n", (getWay(n) / 10 + 1) / 365 + 1);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <vector> 
#include <list> 
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

const LL mod = 1e9 + 7;


int main() {
	
	int N, M;
	cin >> N >> M;
	LL time = 100 * (N - M) + 1900 * M;
	double seiko = 1.0 / pow(2, M);
	double sippai = 1.0 - seiko;

	double prob = time * seiko;
	int n = 2;
	while (true) {

		
		prob += n * time*pow(sippai, n - 1)*seiko;
		n++;
		if (n * time*pow(sippai, n - 1)*seiko < 0.01) {
			break;
		}
	}
	cout << (LL)round(prob) << endl;

}

Measured memory_bytes: 256
n = int(input())
a, b = [0]*n, [False]*n
b[0] = True
for i in range(n):
    a[i] = int(input())
count = 1
light = a[0]

while light != 2:
    b[light-1] = True
    light = a[light-1]
    count += 1
    if b[light-1]:
        print(-1)
        exit(0)
print(count)


Measured memory_bytes: 7796
n = gets.chomp.to_i
cnt_4 = 0
cnt_2 = 0

gets.chomp.split.map do |i|
  if i.to_i % 4 == 0 then
    cnt_4 = cnt_4 + 1
  elsif i.to_i % 2 == 0 then
    cnt_2 = cnt_2 + 1
  end
end

if cnt_4 + (cnt_2 / 2) >= (n / 2) then
  print "Yes"
else
  print "No"
end

Measured memory_bytes: 9476
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);
        ABC_108_A solver = new ABC_108_A();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC_108_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            if (n % 2 == 0) {
                out.print((int) Math.pow(n / 2, 2));
            } else {
                out.print(n / 2 * (n / 2 + 1));
            }
        }

    }
}



Measured memory_bytes: 21332