akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>
#include <chrono>
#include <cstring>
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double db;

#define ft first
#define sd second
#define flag bool fl=true

#define mod 1000000007
#define N 100001
#define MX 1000000001
#define MXX 1000000000000000001

#define pb push_back
#define For(i, a, b) for(int i=a;i<=b;i++)
#define T int t, qq=0; cin>>t; while(qq++<t)
#define fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define scarr(array, size) for(int i=0;i<size;i++) cin>>array[i]

#define deg(rad) (rad*180.0)/pi
#define pi acos(-1)
#define log(n) (int)log2(n)
#define logg(a)(b) log(b)/log(a)


/*
//----------useful_functions----------

long long extended_euclid(ll a, ll b, ll &x, ll &y){//ax+by=c
    if(b==0)
    {
        x=1, y=0;
        return a;
    }

    ll x1, y1;
    ll d=extended_euclid(b, a%b, x1, y1);
    x=y1;
    y=x1-y1*(a/b);
    return d;
}
long long bigMod(ll a, ll b){//(a^b)%mod
    ll ans=1;
    while(b)
    {
        if(b%2==1) ans=(ans*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return ans%mod;
}
long long modInverse(ll a, ll b){//a*x=1 mod b
    ll x, y;
    ll gcd=extended_euclid(a, b, x, y);

    if(gcd==1) return ((x%b)+b)%b;
    else return 1;
}
long long nCr(ll n, ll r){//n<=1e6
    //declare globally-> ll fact[1000001];
    fact[1]=1;
    for(ll i=2;i<1000001;i++)
        fact[i]=(i*fact[i-1])%mod;

    return (fact[n]*modInverse(fact[r], mod)*modInverse(fact[n-r], mod))%mod;
}
long long josephus(ll n, ll k){//k'th person is killed out of n in the circle
    if(n==1) return 1;
    else return (josephus(n-1, k)+k-1)%n+1;
}

vector<int> sieve(ll n){
    bool fl[n+1];
    vector<int> primes;
    for(int i=0;i<=n;i++) fl[i]=false;

    for(int i=3;i*i<=n;i+=2)
        for(int j=i+i;j<=n;j+=i)
            fl[j]=true;

    primes.pb(2);
    for(int i=3;i<=n;i+=2) if(!fl[i]) primes.pb(i);
    return primes;
}
*/

int main()
{
    int n;
    cin>>n;
    vector<pair<int, int> > v[n+1];
    vector<ll> vis(n+1, MXX);
    for(int i=0;i<n-1;i++)
    {
        int x, y, z;
        cin>>x>>y>>z;
        v[x].push_back({y, z});
        v[y].push_back({x, z});
    }

    queue<int> q;
    q.push(1);
    vis[1]=0;
    while(!q.empty())
    {
        int x=q.front();
        q.pop();

        for(auto it=v[x].begin();it!=v[x].end();it++)
        {
            if(vis[x]+it->second<vis[it->first])
            {
                vis[it->first]=vis[x]+it->second;
                q.push(it->first);
            }
        }
    }

    for(int i=1;i<=n;i++)
    {
        if(vis[i]%2==0) cout<<0<<endl;
        else cout<<1<<endl;
    }
//        cout<<"Case "<<qq<<": ";
}


Measured memory_bytes: 10036
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<map>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<utility> 
#include<fstream>
#include<cassert>
#include<cstdlib>
#include<deque>
#include<list>
#include<bitset>
#include<cassert>
#include<functional>
using namespace std;
int n,dp[100005];
vector<int> nei[100005];
void dfs(int v,int pa)
{
	int cnt=0;
	for(int i=0;i<nei[v].size();i++)
	{
		int u=nei[v][i];
		if(u==pa) continue;
		dfs(u,v);
		
		if(dp[u]==0) cnt++;else dp[v]+=dp[u];
	}
	if(cnt>1) dp[v]+=cnt-1;
	dp[v]=max(dp[v],0);
}
int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		nei[x].push_back(y);
		nei[y].push_back(x);
	}
	bool flag=0;
	int ro=-1;
	for(int i=0;i<n-1;i++)
	{
		if(nei[i].size()>=3) ro=i; 
	}
	if(ro==-1)
	{
		cout<<1;
		return 0;
	}
	dfs(ro,-1);
	cout<<dp[ro];
}

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

const int MAX = 1e5 + 5;

#define dbg(a) cout << "-> " << __LINE__ << ": " << #a << " = " << a << endl

int main() {
    long long n, ans = LLONG_MAX;
    scanf("%lld", &n);
    int lim = sqrtl(n + 1);
    for (int i = 1; i <= lim; i++) {
        if (n % i == 0) {
            long long u = i, v = n / i;
            ans = min(ans, u + v - 2);
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

f_count = 2
s_count = 1
haikuflag = False
input_stuck = input().split()
num = [int(input_stuck[0]),int(input_stuck[1]),int(input_stuck[2])]
for i in num:
    if i == 5:
        f_count-=1
    elif i == 7:
        s_count-=1
if f_count == 0 and s_count == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    int N; cin >> N;
    int numOdd = 0;
    rep(i, 0, N) {
        int A;
        cin >> A;
        if (A % 2 == 1)
            ++numOdd;
    }

    if (numOdd % 2 == 0)
        cout << "YES\n";
    else
        cout << "NO\n";
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		long mod = (long)(1e9 + 7);
		string S = GetString();
		int N = S.Length;
		long[,] dp = new long[N, 13];
		if(S[0] == '?')
		{
			for(int i = 0; i < 10; i++)
				dp[0, i] = 1;
		}
		else
		{
			dp[0, (int)(S[0] - '0')] = 1;
		}

		for(int i = 1; i < N; i++)
		{
			if(S[i] == '?')
			{
				for(int j = 0; j < 13; j++)
				{
					for(int k = 0; k < 10; k++)
					{
						dp[i, (10 * j + k) % 13] += dp[i - 1, j];
						dp[i, (10 * j + k) % 13] %= mod;
					}
				}
			}
			else
			{
				int k = (int)(S[i] - '0');
				for(int j = 0; j < 13; j++)
				{
					dp[i, (10 * j + k) % 13] += dp[i - 1, j];
					dp[i, (10 * j + k) % 13] %= mod;
				}
			}
		}

		Console.WriteLine(dp[N - 1, 5]);
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





Measured memory_bytes: 21856
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll l, r;
    cin>>l>>r;
    ll ans = INF;
    for(ll i=l;i<r;++i){
        for(ll j=i+1;j<=r;++j){
            ll flag = (i * j) % (ll)2019;
            ans = min(ans, flag);
            if(ans == 0){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<ans<<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++)

int main(){
  int w, h, x,y, r;
  cin >> w >> h >> x >> y >> r;
  if((x>=r&&w-r>=x)&&(y>=r&&h-r>=y)) cout << "Yes" << endl;
  else cout << "No" << endl;

}



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(r) (r).begin(), (r).end()

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; }
const long long INF = 1LL<<60;

const int MAX_N = 110;
const int MAX_V = 100100;

int32_t N;
int64_t W, R = 0;
int64_t weight[MAX_N], value[MAX_N];
int64_t dp[MAX_N][MAX_V];

int main() {
    cin >> N >> W;
    rep(i, N) cin >> weight[i] >> value[i];
    rep(i, MAX_N) rep(j, MAX_V) dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i, N) {
        rep(j, MAX_V) {
            if (j - value[i] >= 0) {
                chmin(dp[i+1][j], dp[i][j - value[i]] + weight[i]);
            }
            chmin(dp[i+1][j], dp[i][j]);
        }
    }

    rep(j, MAX_V) if (dp[N][j] <= W) R = j;
    cout << R << endl;
}


Measured memory_bytes: 89580
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl

int main() {
  IN(N);

  vvi A(N, vi(N, -1));
  REP(i, N) {
    REP(j, N) {
      IN(a);
      A[i][j] = a;
    }
  }
  priority_queue<pii, vector<pii>, greater<pii>> edge;
  REP(i, N) {
    if (A[0][i] != -1)
      edge.push(make_pair(A[0][i], i));
  }
  vector<bool> visited(N, false);
  visited[0] = true;
  int ans = 0;
  while (!edge.empty()) {
    pii p = edge.top(); edge.pop();
    if (visited[p.second])
      continue;
    visited[p.second] = true;
    ans += p.first;
    REP(i, N) {
      if (A[p.second][i] != -1 && !visited[i])
        edge.push(make_pair(A[p.second][i], i));
    }
  }
  OUT(ans);

  return 0;
}



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


void solve(int ar[] , int n ,int k){
    int dp[k+1];
    dp[0] = 0;
    for(int i=1;i<=k;i++){
        int c=1;
        for(int j=1;j<=n;j++){
            if(i >= ar[j]){
                if(dp[i-ar[j]]==0){
                    c=0;
                    break;
                }
            }
        }
        if(c==0){
            dp[i]=1;
        }
        else dp[i]=0;
    }
    /*for(auto i:dp){
        cout<<i<<" ";
    }
    cout<<endl;
    */
    if(dp[k]==1){
        cout<<"First";
    }
    else cout<<"Second";
}

int main(){
    int n,k;
    cin>>n>>k;
    int ar[n+1];
    for(int i=1;i<=n;i++){
        cin>>ar[i];
    }
    solve(ar,n,k);
}


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

int main(void) {
    int r, d, x;
    vector<int> xs;

    cin >> r >> d >> x;
    xs.push_back(x);

    for (int i = 0;i < 10; ++i) {
        int nextX = r * xs.at(i) - d;
        xs.push_back(nextX);
    }
    
    for (int i = 1;i < 11; ++i) {
        cout << xs.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[15],n;
long long go(int x,long long sum)
{
	if(x==n) return sum;
	long long cur=0,ans=0;
	for(int i=x;i<n;i++)
	{
		cur=cur*10+a[i];
		ans+=go(i+1,sum+cur);
	}
	return ans;
}
int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		a[n]=s[i]-'0';
		n++;
	}
	cout<<go(0,0)<<endl;
	return 0;
}


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

using ll = long long;
using std::cout;
using std::cin;
using std::endl;

int main(){
    std::string S,T;
    cin >> S >> T;
    ll ans = 0;
    for(int i=0; i<S.length(); i++){
        if(S[i] != T[i]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	unsigned N, M;
	cin >> N >> M;
	
	array<unsigned, 100010> num;
	for(unsigned i=0; i<100010; ++i) num[i] = 1;
	bitset<100010> bs(1);
	for(unsigned m=0; m<M; ++m) {
		unsigned x, y;
		cin >> x >> y;
		
		++num[y-1];
		if(bs[x-1] == 1) {
			bs[y-1] = 1;
		}
		
		--num[x-1];
		if(num[x-1] == 0) {
			bs[x-1] = 0;
		}
	}
	
	cout << bs.count() << endl;
	
	return 0;
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	get_g(int i, vector<int> &grp) {
	if (i==grp.at(i)) return i;
	//return get_g(grp.at(i), grp);
	return (grp.at(i)=get_g(grp.at(i), grp));
}

int     main() {
	// N: Number of nodes
	// M: Number of links
	int N, M;
	cin >>N >>M;
	// Data store
	// p: Original value for each position
	// grp: Group#
	// grp_depth: Steps to the group root
	//vector<int> p(N+1, 0);
	vector<int> grp(N+1, 0);
	vector<int> grp_depth(N+1, 0);
	// Read data for each node
	// Initialize group# as each own
	for (int i=1; i<=N; i++) {
		//cin >>p.at(i);
		grp.at(i)=i;
	}
	// Links
	// Each link connects nodes x and y
	// (Swap rules)
	vector<int> x(M, 0);
	vector<int> y(M, 0);
	for (int i=0; i<M; i++)
		cin >>x.at(i) >>y.at(i);
	// Grouping
	for (int i=0; i<M; i++) {
		int xx=x.at(i);
		int yy=y.at(i);
		xx=get_g(xx, grp);
		yy=get_g(yy, grp);
		if (xx==yy) {
			// Already in same group, do nothing
		} else {
			// Put into one group
			if (grp_depth.at(xx)==grp_depth.at(yy)) {
				// Groups have same height
				// Merge into less-number-group
				grp.at(max(xx, yy)) = get_g(min(xx, yy), grp);
				grp_depth.at(min(xx, yy))++;
			} else if (grp_depth.at(xx)>grp_depth.at(yy)) {
				// x is higher
				// Merge into x so that the hight will not increase
				// (height for y will be +1)
				grp.at(yy) = xx;
			} else
				// y is higher
				// Merget into y
				grp.at(xx) = yy;
		}
	}
	vector<int> GN(N+1, 0);
	Rep1(i, N)
		GN.at(get_g(i, grp))++;
	int ANS=0;
	Rep1(i, N)
		ANS=max(ANS, GN.at(i));
	cout <<ANS <<endl;
	return 0;
};



Measured memory_bytes: 7220
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)
#define endl "\n"
#define ios std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

const int N=1e5+9;
int dp[N];

int main(){
	ios;
	int n,k;
	cin>>n>>k;

	int a[n+2];
	F(i,1,n) cin>>a[i];


	F(i,2,n){
		int mn=1e9;
		F(j,1,k){
			if(i-j<1) break;
			mn=min(mn,dp[i-j]+abs(a[i]-a[i-j]));
		}
		dp[i]=mn;
	}
	cout<<dp[n];
}

Measured memory_bytes: 1024
import java.util.*;
import java.util.function.Predicate;

public class Main {

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

    void run(){
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        int Y = cin.nextInt();

        // 10000円札を0枚からN枚まで全探索する
        for (int A = 0; A <= N; A++){
            // 5000円札を0枚から8枚まで全探索する
            for (int B = 0; B <= Math.min(N - A, 8); B++){
                // 1000円札の枚数を計算する
                int C = N - A - B;
                int Money = 10000 * A + 5000 * B + 1000 * C;
                // 枚数はN枚なので、金額だけ見れば良い。
                if(Money == Y){
                    System.out.println(A + " " + B + " " + C);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,c,d;
  string ans;
  cin >> a >> b >> c >> d;
  for(int i=0;i<d-b;i++){
    cout << 'U';
  }
  for(int i=0;i<c-a;i++){
    cout << 'R';
  }
  for(int i=0;i<d-b;i++){
    cout << 'D';
  }
  for(int i=0;i<=c-a;i++){
    cout << 'L';
  }
  for(int i=0;i<=d-b;i++){
    cout << 'U';
  }
  for(int i=0;i<=c-a;i++){
    cout << 'R';
  }
  cout << "DR";
  for(int i=0;i<=d-b;i++){
    cout << 'D';
  }
  for(int i=0;i<=c-a;i++){
    cout << 'L';
  }
  cout << 'U' << endl;
  return 0;
}

Measured memory_bytes: 256
A,B,C,D,E,F = map(int,input().split())
M = []
S = []

for a in range(1+F//100):
    for b in range(1+F//100):
        if 100*(a*A+b*B)<=F:
            M.append(100*(a*A+b*B))
for c in range(F//C):
    for d in range(F//D):
        if c*C+d*D<=F:
            S.append(c*C+d*D)
M = set(M)
S = set(S)

t = -1
ans1 = 0
ans2 = 0
for m in M:
    for s in S:
        if m==s==0:
            pass
        elif s<=E*m//100 and m+s<=F and t<(s*100)/(m+s):
            t = (s*100)/(m+s)
            ans1 = m+s
            ans2 = s

print(ans1, ans2)

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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  while(true){
    if(C-B<=0){
      cout << "Yes" << endl;
      break;
    }
    else{
      C -= B;
    }
    if(A-D<=0){
      cout << "No" << endl;
      break;
    }
    else{
      A -= D;
    }
  }
}

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

static const long N = 1000;

long lcs(string X, string Y){
	long c[N + 1][N + 1];
	long m = X.size();
	long n = Y.size();
	long maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for (long i = 1; i <= m; i++) c[i][0] = 0;
	for (long j = 1; j <= n; j++) c[0][j] = 0;

	for (long i = 1; i <= m; i++){
		for (long j = 1; j <= n; j++){
			if (X[i] == Y[j]){
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}

	return maxl;
}

int main(){
	string s1, s2;
	long n; cin >> n;
	for (long i = 0; i < n; i++){
		cin >> s1 >> s2;
		cout << lcs(s1, s2) << endl;
	}
	return 0;
}

Measured memory_bytes: 9040
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

string s;
stack < pair<char, int> > st;
long long ans;

int main() { 

  getline(cin, s);

  for (int i = 0; i < sz(s); ) {
    if (i + 2 < sz(s) && s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
      int as = (!st.empty() && st.top().first == 'A') ? st.top().second : 0;
      if (as > 0) {
        st.pop();
      }
      ans += 1 + as;
      st.push({'B', 1});
      st.push({'C', 1});
      if (as) {
        st.push({'A', as});
      }
      s[i + 2] = 'A';
      i += 2;
    } else {
      char c = s[i];
      if (st.empty() || st.top().first != c) {
        st.push({c, 1});
      } else {
        st.top().second++;
      }
      i++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1540
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back 
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int> 
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second 
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0); 
const int32_t mod = 1e9+7;
const int32_t maxn=2e5+5;

void solve(){
    int n;cin>>n;
    int ans=0;
    rep(i,1,n){
        int u,v;cin>>u>>v;
        if(u>v) swap(u,v);
        ans+=-1*(u)*(n-v+1);
    }
    rep(i,0,n) ans+=(i+1)*(n-i);
    cout<<ans;
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;                                                                                                                  
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;

class BFrog2 {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n,k;
        in>>n>>k;
        int arr[n+1];
        for(int i=1;i<=n;i++)
            in>>arr[i];

        arr[0]=1e15;

        vector<int> dp(n+1, 1e15);
        dp[1]=0;
        dp[0]=0;

        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<=k&&i-j>=1;j++)
            {
                dp[i]=min(dp[i], dp[i-j]+abs(arr[i]-arr[i-j]));
            }
        }

        out<<dp[n];

    }
};

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

    BFrog2 solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <iomanip>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
typedef long long ll;

struct edge { int s, t, d; };
int V, E, R;
const ll Inf = 1L << 56;

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

  cin >> V >> E >> R;
  if (E == 0) {
    cout << 0 << endl;
    return 0;
  }
  edge es[E];
  ll d[V];
  REP(i,V) d[i] = Inf;
  d[R] = 0;
  REP(i,E) cin >> es[i].s >> es[i].t >> es[i].d;
  int count = 0;
  while (true) {
    count++;
    if (count == V) {
      cout << "NEGATIVE CYCLE" << endl;
      return 0;
    }
    bool update = false;
    REP(i,E) {
      edge e = es[i];
      if (d[e.s] == Inf)
        continue;
      ll dd = d[e.s] + e.d;
      if (d[e.t] > dd) {
        d[e.t] = dd;
        update = true;
      }
    }

    if (!update)
      break;
  }

  REP(i,V) {
    if (d[i] == Inf) {
      cout << "INF\n";
    } else {
      cout << d[i] << '\n';
    }
  }
  cout << flush;
    
  return 0;
}

Measured memory_bytes: 1224
#define _USE_MATH_DEFINES 
#include <iomanip> 
#include <cmath>  
#include<iostream>
#include <fstream>
#include<vector>
#include<algorithm>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

ll n, a;
map<ll, ll> MP;

int main() {
	rd(n);
	repi(i, 0, n) {
		rd(a);
		if (MP.find(a) == MP.end()) MP[a] = 1;
		else MP.erase(a);
	}
	wrln(MP.size());
	return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
int change(double n){
	if((int)n<n)
	    return (int)n+1;
	else
	    return (int)n;
}
int main(){
	double a,b;
	scanf("%lf%lf",&a,&b);
	double s1=a/0.08,s2=(a+0.999999)/0.08,s3=b/0.1, s4=(b+0.99999999)/0.1; 
	
	if(s2<s3 || s1>s4)
	    printf("-1\n");
	else{
		if(s1<=s3)
		    printf("%d\n",change(s3));
		else
		    printf("%d\n",change(s1));
	}
	
	return 0; 
}

Measured memory_bytes: 256
def gcd(a, b):
    if a < b:
        return gcd(b, a)
    d = a % b
    if d == 0:
        return b
    return gcd(b, d)

def main():
    K = int(input())
    table = [[0]*K for i in range(K)]
    for i in range(K):
        for j in range(K):
            table[i][j] = gcd(i + 1, j + 1)
    ans = 0
    for i in range(K):
        for j in range(K):
            for k in range(K):
                ans += gcd(i + 1, table[j][k])
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9328
<?php

while (($line = trim(fgets(STDIN))) !== '') {
    $d = (int)$line;
    for ($i = $d, $result = 0; $i <= 600; $i += $d) {
        $result += pow(600 - $i, 2) * $d;
    }
    echo $result, PHP_EOL;
}

Measured memory_bytes: 6572
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); --i)
#define sz(c) ((int)c.size())
#define all(c) c.begin(), c.end()

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

const int INF = 1e9;
template <class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T> using heap = priority_queue<T, vector<T>, greater<T>>;

int DY[2][9] = {
    {-2, -1, -1, 0, 0, 0, 1, 1, 2},
    {-2, -1, -1, 0, 0, 0, 1, 1, 2},
};
int DX[2][9] = {
    {1, 1, 2, 1, 2, 3, 1, 2, 1},
    {-1, -1, -2, -1, -2, -3, -1, -2, -1},
};

bool inrange(int x, int l, int r) {
    return l <= x and x < r;
}

void solve(int W, int H) {
    vvi A(H, vi(W));
    rep(i, 0, H) rep(j, 0, W) {
        char x;
        cin >> x;
        A[i][j] = x;
    }

    vector<vvi> dist(H, vvi(W, vi(2, INF)));
    using dijkstra_state = tuple<int, int, int, int>;
    heap<dijkstra_state> hp;
    rep(i, 0, H) rep(j, 0, W) if (A[i][j] == 'S') {
        dist[i][j][0] = dist[i][j][1] = 0;
        hp.push(dijkstra_state(0, i, j, 0));
        hp.push(dijkstra_state(0, i, j, 1));
    }
    while (sz(hp)) {
        int c, y, x, foot;
        tie(c, y, x, foot) = hp.top(); hp.pop();
        if (c > dist[y][x][foot]) continue;
        rep(step, 0, 9) {
            int yy = y + DY[foot][step];
            int xx = x + DX[foot][step];
            if (!(inrange(yy, 0, H) && inrange(xx, 0, W))) continue;
            if (A[yy][xx] == 'X') continue;

            int cost = A[yy][xx] - '0';
            if (A[yy][xx] == 'S' || A[yy][xx] == 'T') cost = 0;
            if (chmin(dist[yy][xx][foot ^ 1], c + cost)) {
                hp.push(dijkstra_state(dist[yy][xx][foot ^ 1], yy, xx, foot ^ 1));
            }
        }
    }

    int ans = INF;
    rep(i, 0, H) rep(j, 0, W) if (A[i][j] == 'T') {
        chmin(ans, dist[i][j][0]);
        chmin(ans, dist[i][j][1]);
    }
    if (ans == INF) ans = -1;
    cout << ans << endl;
}

signed main() {
    while (1) {
        int w, h;
        cin >> w >> h;
        if (w == 0 && h ==0 ) break;
        solve(w, h);
    }
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
//#define int long long //Strong Power
#ifdef LOCAL
#define lout cout
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...)                                 \
  GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) \
  (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...)                                    \
  GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1) \
  (__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a)-1, n, d, >=)
// -----
typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
template <class T = int>
inline T in();

void solve()
{
  int n = in();
  vector<int> a(n);
  vcin(a);
  //a.push_back(a[0]);

  vector<lint> x(n);
  lint s = accumulate(a.begin(), a.end(), (lint)0);

  lout << "s:" << s << endl;

  lint t = 0;
  rep(i, 1, n - 1, 2)
      t += 2 * a[i];

  x[0] = s - t;
  lout << "x[0]:" << x[0] << endl;

  rep(i, 0, n - 1)
      x[i + 1] = 2 * a[i] - x[i];

  vcout(x, " ");
  cout << endl;
}

signed main()
{
  AMULET
  solve();
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}
template <class T = int>
inline T in()
{
  T x;
  cin >> x;
  return (x);
}


Measured memory_bytes: 2560
n, k = map(int,input().split())
h = list(map(int,input().split()))
h_as_o = sorted(h)
count1 = 0
count2 = 0
if n > k:
  count1 = n - k
  for i in range(count1):
    count2 += h_as_o[i]
  print(count2)
else:
  print(0)  

Measured memory_bytes: 26024
/*
17/10/2017
*/
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
int k=(a)/b;
if(a%b!=0)
{
k++;
}
cout<<c*k<<endl;
}
/*
 *||||

 */

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

int main() {
    int64_t n, k;
    cin >> n >> k;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i], a[i]--;
    }
    vector<int> path;
    vector<int> visited(n);

    int aa = 0;
    for(; k > 0; k--){
        if(visited[aa]) break;
        visited[aa] = 1;
        path.push_back(aa);
        aa = a[aa];
    }

    if(k == 0){
        cout << aa + 1 << endl;
        return 0;
    }

    int idx = find(begin(path), end(path), aa) - begin(path);
    k %= path.size() - idx;
    cout << path[idx + k] + 1 << endl;
    return 0;
}

Measured memory_bytes: 5888
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse(Console.ReadLine());

            int s = S % 60;
            S /= 60;
            int m = S % 60;
            int h = S/ 60;

           Console.WriteLine("{0}:{1}:{2}",h,m,s);

        }
    }
}


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

int main(){
  string S;
  cin >> S;
  for(int i = 0; i < 3; i++){
    if(S[i]=='1'){
      S[i]='9';
    }else if(S[i]=='9'){
      S[i]='1';
    }
  }
  cout << S << endl;
}

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

int main(void) {
  int N; 
  cin >> N;
  map<string,int> m;
  int maxnum = 0;
  
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    if (m.find(s) == m.end()) {
      m[s] = 1;
    } else {
      m[s]++;
    }
    if (maxnum < m[s]) maxnum = m[s];
  }
  
  for (map<string,int>::iterator it=m.begin(); it!=m.end(); ++it) {
    if (it->second == maxnum) cout << it->first << endl;
  }
  
  return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <iomanip>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<double> p(n);
    REP(i, 0, n) {
        ll a;
        cin >> a;
        p[i] = a * (a + 1) / 2.0 / a;
    }
    vector<double> sum(n + 1, 0.0);
    REP(i, 0, n) {
        sum[i + 1] = sum[i] + p[i];
    }
    double ans = 0.0;
    REP(i, 0, n - k + 1) {
        chmax(ans, sum[i + k] - sum[i]);
    }
    cout << fixed << setprecision(15) << ans << endl;

    return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define INF 100000000000000
using namespace std;

int main() {
    int n;
    cin >> n;
    long b[n];
    cin >> b[0];
    for (int i = 1; i < n; i++) {
        cin >> b[i];
        b[i] += b[i - 1];
    }

    long ans = INF;
    for (int i = 0; i < n - 1; i++) {
        ans = min(abs(b[n - 1] - 2 * b[i]), ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }

        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, k) = (line[0], line[1]);
    let mut a = read_as_vec::<i64>();
    let mm =  1_000_000_007;
    a.sort();
    //println!("{:?}", a);
    let mut max_sum: i64 = 0;
    let comb = CombMod::new(n as u64+1, mm);

    for i in k-1..n{
        // println!("\ni = {}", i);
        // println!("k-1 = {}", k-1);
        if k-1 == 0{
            max_sum += a[i];
        }else{
            max_sum += (a[i] * (comb.get(i as u64, (k-1) as u64) as i64)) % mm as i64;
        }
        //println!("{}", a[i] * comb.get(i as u64, (k-1) as u64));
        max_sum %= mm as i64;
    }

    let mut min_sum: i64 = 0;
    for i in 0..n-k+1{
        // println!("i = {}", i);
        // println!("n-i-1={}", n-i-1);
        // println!("k-1={}", k-1);
        if k-1 == 0{
            min_sum += a[i];
        }else{
            min_sum += a[i] * (comb.get((n as u64)-(i as u64)-1 as u64, (k-1) as u64) as i64);
        }
        min_sum %= mm as i64;
    }
    min_sum %= mm as i64;
    let ans = (max_sum+mm as i64-min_sum)%mm as i64;

    println!("{}", ans);
}


Measured memory_bytes: 8444
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int n;cin>>n;
    map<int,int> d;
    rep(i,n){
        int x;cin>>x;
        d[x]++;
    }
    int m;cin>>m;
    map<int,int> t;
    rep(i,m){
        int x;cin>>x;
        t[x]++;
    }

    for(auto x:t){
        if(x.second>d[x.first]){
            cout<<"NO"<<endl;return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)
const int intinf = numeric_limits<int>::max();

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define MOD 1000000007

void solve()
{
    double L;
    cin >> L;
    cout << fixed << setprecision(10) << pow(L, 3) / 27 << endl;
}

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


Measured memory_bytes: 384
#import<iostream>
#import<set>
using namespace std;main(){typedef pair<int,int>P;int n,m,i,x,y;for(;cin>>m,m;){set<P>c,p;for(i=m;i--;c.insert(P(x,y)))cin>>x>>y;cin>>n;for(i=n;i--;p.insert(P(x,y)))cin>>x>>y;for(set<P>::iterator k,j=p.begin();j!=p.end();++j){k=c.begin();x=j->first-k->first;y=j->second-k->second;for(;++k!=c.end()&&p.find(P(k->first+x,k->second+y))!=p.end(););if(k==c.end()){cout<<x<<" "<<y<<endl;break;}}}}

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

int main()
{

        int N;
        cin >> N;
        int t[N];
        int x[N];
        int y[N];
        for (int i = 0; i < N; ++i) {
                cin >> t[i] >> x[i] >> y[i];
        }

        int x0 = 0;
        int y0 = 0;
        int t0 = 0;
        for (int i = 0; i < N; ++i) {

                int sum = abs(x[i] - x0) + abs(y[i] - y0);

                if (sum == (t[i] - t0)) {

                }
                else if (sum > (t[i] - t0)) {
                        cout << "No" << endl;
                        exit(0);
                }
                else {
                        int diff = (t[i] - t0) - sum;
                        if (diff % 2 != 0) {
                                cout << "No" << endl;
                                exit(0);
                        }
                }
                x0 = x[i];
                y0 = y[i];
                t0 = t[i];

        }
        cout << "Yes" << endl;


}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Lphabet | diff Lphabet.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Lphabet.cpp && ./a.out

/*

 6/21/2020

 5:00-

 */

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  char c; cin>>c;
  cout<<(islower(c)?"a":"A")<<endl;

  return 0;
}


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

int main() {
    int h, w, n;
    cin >> h >> w >> n;

    long long int total = 0;
    int cnt = 0;

    if (h > w) {
        for (cnt = 0; total < h * w; total += h) {
            if (total >= n) {
                break;
            }
            cnt += 1;
        }
    }
    else if (h <= w) {
        for (cnt = 0; total < h * w; total += w) {
            if (total >= n) {
                break;
            }
            cnt += 1;
        }
    }
    
    cout << cnt << endl;

    return 0;
}


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

  int N;

  cin >> N;

  string S;
  
  cin >> S;

  int ans=0;

  for(int i=1;i<=N-1;i++){
    vector<int> A(26,0),B(26,0);
    int eq=0;
    string a=S.substr(0,i);
    string b=S.substr(i,N-i);

    for(int j=0;j<a.size();j++) A.at((int)(a.at(j)-'a'))++;
    for(int j=0;j<b.size();j++) B.at((int)(b.at(j)-'a'))++;

    for(int j=0;j<26;j++){
      if(A.at(j)!=0&&B.at(j)!=0) eq++;
    }

    if(ans<eq) ans=eq;

  }

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

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

ll r,c,n;

bool judge(pll a){
    return a.F==0 || a.F==r || a.S==0 || a.S==c;
}

ll num(pll a){
    if(a.F==0){return a.S;}
    if(a.S==c){return c+a.F;}
    if(a.F==r){return c+r+c-a.S;}
    return c+r+c+r-a.F;
}


int main(){
    cin>>r>>c>>n;
    vector<pll> a;
    for(int i=0;i<n;i++){
        pll A,B;
        cin>>A.F>>A.S>>B.F>>B.S;
        if(judge(A) && judge(B)){
            a.push_back({num(A),i});
            a.push_back({num(B),i});
        }
    }
    sort(a.begin(),a.end());
    vector<bool> used(n,false);
    stack<ll> S;
    for(auto &I:a){
        if(used[I.S]){
            used[I.S]=false;
            if(S.top()!=I.S){cout<<"NO"<<endl; return 0;}
            S.pop();
        }
        else{
            used[I.S]=true;
            S.push(I.S);
        }
    }
    cout<<"YES"<<endl;
    
    return 0;
}


Measured memory_bytes: 6384
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int dp[100001];

int length(int i,vector<vector<int>> &v)
{
    if(v[i].size()==0)
    {
        return dp[i]=0;
        // it simply means ki vo vertex kisi dusre vertex ko point nhi kr rha hai...and the legth of the
        // longest path from that particular vertex is zero.
    }
    else
    {
        if(dp[i]!=-1)
        {
            return dp[i];
        }
        
        int max=INT_MIN;
        for(int j=0;j<v[i].size();j++)
        {
            int ans=1+length(v.at(i).at(j),v);
            if(ans>max)
            {
                max=ans;
            }
        }
        return dp[i]=max;
    }
}

int solve(int n,int m,vector<vector<int>> &v)
{
    memset(dp,-1,sizeof(dp));
    // dp[i] wll define the max length of the path that is strating from the index i...
    int max=INT_MIN;
    for(int i=1;i<=n;i++)
    {
        if(length(i,v)>max)
        {
            max=length(i,v);
        }
    }
    return max;
}


int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>> v(n+1);
    for(int i=0;i<m;i++)
    {
        int a,b;
        // directed path is thier from the vertex a to b..
        cin>>a>>b;
        v[a].pb(b);
    }
    cout<<solve(n,m,v);
    return 0;
}


Measured memory_bytes: 8832
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>

#define ll long long 
using namespace std;

int main(void) {
    ll k, a, b;

    scanf("%lld %lld %lld", &k, &a, &b);

    ll ans = 1;
//    k -= (a-1);

    if (a+2 < b) {
        //ans = k/(a+2) * b + k % (a+2);
        if ( k >= a-1 ) {
            k -= (a-1);
            ans += (a-1);
            ans += k/2 * (b-a) + k%2;
        } else {
            ans += k;
        }

    } else {
        ans += k;
    }

    printf("%lld\n", ans);
    
}


Measured memory_bytes: 256