akhauriyash/Code-Regression huggingface dataset:
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
int main(void){
	llint K,h,i;cin>>K;
	string ans;
	//よさそう
	//FESTIVA(L) FFEESSTTIIVVAA(L) FFFF...
	//これはかけです
	llint code[8]={0};code[0]=1;
	vector<llint>LLL;
	for(h=1;h<=128;h*=2){
		for(i=1;i<=7;i++){code[i]+=code[i-1]*h;}
		LLL.pub(code[7]);
		cerr<<"de"<<code[7]<<endl;
	}
	reverse(LLL.begin(),LLL.end());
	vector<llint> ansL;
	for(auto it:LLL){ansL.pub(K/it);K%=it;}
	string fes="FESTIVA";
	for(h=1;h<=128;h*=2){
		for(auto it:fes){
			for(i=0;i<h;i++){cout<<it;}
		}
		for(i=0;i<ansL.back();i++){cout<<"L";}
		ansL.pob();
	}
	cout<<endl;RE;
}

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

using namespace std;

int main() {
	int n, sumT, sumK;
	string t, k;

	sumT = sumK = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> t >> k;
		if (t > k) {
			sumT += 3;
		}else if (t < k) {
			sumK += 3;
		}
		else {
			++sumT;
			++sumK;
		}
	}
	cout << sumT << " " << sumK << endl;

	return 0;
}


Measured memory_bytes: 3200
/**********************************************

1.
2.炭田高輝
3.sumita.takaki@gmail.com

last updated: 2013-07-10@17:04

 **********************************************/
#include<iostream>
#include<algorithm>
#include<sstream>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
using namespace std;


int main(void){


        while(1){
                
                int n=0;
                int k=0;
                int total=0, answer=0;
               

                cin >> n >> k;
                if(n==0 && k==0)break;
                vector <int> data(n);
                
                for(int i=0; i<n; i++){
                        cin >> data[i];
                        //cout << "data[i]="<< data[i]<<endl;
                }

                for(int j=0; j<n-k+1; j++){
                        
                        if( j == 0){
                                for(int i=0; i<k; i++){
                                        total = total + data[j+i];
                                }
                                //cout << "subtotal1="<<total<<endl;
                        }else{
                                
                                total = total - data[j-1] + data[j+k-1];
                                //cout << "subtotal2="<<total<<endl;
                        }
                        //cout << "answer="<<answer<<"subtotal="<<total<<endl;
                        if( total > answer ){
                                answer = total;
                        }
                        //cout << "answer="<<answer<<endl;
                }
                
                cout << answer << endl;
                
        }

        return 0;

}

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

int n;
int a[60];
int mx, mxid;

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        if (i == 1) {
            mx = a[i];
            mxid = 1;
        }
        else {
            if (abs(a[i]) > abs(mx)) {
                mx = a[i];
                mxid = i;
            }
        }
    }

    cout << 2*n - 2 << endl;
    for (int i = 1; i <= n; i++) {
        if (i == mxid) continue;
        cout << mxid << " " << i << endl;
        a[i] += mx;
    }

    if (mx > 0) {
        for (int i = 2; i <= n; i++) {
            cout << i-1 << " " << i << endl;
            a[i] += a[i-1];
        }
    } else {
        for (int i = n-1; i > 0; i--) {
            cout << i+1 << " " << i << endl;
            a[i] += a[i+1];
        }
    }

    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))
using ll = long long;
using namespace std;

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

bool flag[501][501];
int dp[501][501];

int main() {

    int n;
    while (cin >> n and n) {
        vector<int> v(n);
        rep(i, n) cin >> v[i];

        fill(flag[0], flag[350], false);
        fill(dp[0], dp[350], 0);

        // [i, j) という区間がどうなのかを見たい
        for (int len = 1; len <= n; ++len) {
            for (int i = 0; i + len <= n; ++i) {
                int j = i + len;

                if (dp[i+1][j-1] == (j-1) - (i+1) and abs(v[i] - v[j-1]) <= 1) {
                    dp[i][j] = max(dp[i][j], dp[i+1][j-1] + 2);
                }

                for (int k = i; k <= j; ++k) {
                    dp[i][j] = max(dp[i][j], dp[i][k] + dp[k][j]);
                }
            }
        }

        cout << dp[0][n] << endl;
    }
}



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

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i=0;i<(n);i++)
#define rep2(i, m, n) for(int i=m;i<(n);i++)
#define rrep(i, n, m) for(int i=n;i>=(m);i--)
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;
#ifdef __DEBUG

#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    rep(i, N) H[i] --;
    int prev = -2;
    rep(i, N){
        int h = H[i];
        if (h < prev - 1) {
            cout << "No" << endl;
            return;
        }
        prev = max(prev, h);
    }
    cout << "Yes" << endl;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)

using namespace std;

int main(void) {
	int s;
	cin >> s;
	if ((s % 2) == 0) {
		cout << 0.5;
		return 0;
	}
	double r = s;

	cout << (r - ((r - 1) / 2)) / r;
	return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
r = (n-1) * (n-2) // 2 - k
if r < 0:
  print(-1)
else:
  print( n - 1 + r )
  for i in range(1,n):
    print(1,i+1)
  for i in range(1,n):
    for j in range(i+1,n):
      if r > 0:
        print(i+1,j+1)
        r -= 1
      else:
        break

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int N;

int check(vector<tuple<int,int,int>> &v){
    stable_sort(v.begin(), v.end());
    /*if(cnt == 4){
        REP(i,N){
            int num, flip, idx;
            tie(num, flip, idx) = v[i];
            cout << num << " " << flip << " " << idx << endl;
        }
    }*/
    vector<int> vv;
    REP(i,N){
        int num, flip, idx;
        tie(num, flip, idx) = v[i];
        flip *= -1;
        if(flip && (i%2 == idx%2)) return INF;
        if(flip && i == idx) return INF;
        if(!flip && (i%2 != idx%2)) return INF;
        vv.push_back(idx);
    }
    int res = 0;
    for(int i=0;i<N;i++){
        for(int j=N-1;j>i;j--){
            if(vv[j-1] > vv[j]){
                res++;
                swap(vv[j-1], vv[j]);
            }
        }
    }

    return res;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    vector<ll> A(N), B(N);
    REP(i,N) cin >> A[i];
    REP(i,N) cin >> B[i];
    int ODD = (N + 1) / 2;
    int EVEN = N / 2;

    int ans = INF;
    REP(bits, 1<<N){
        vector<pair<int,int>> even, odd;
        REP(j,N){
            if((bits >> j) & 1){
                if(j & 1) odd.emplace_back(B[j], j);
                else even.emplace_back(B[j], j);
            }
            else{
                if(j & 1) even.emplace_back(A[j], j);
                else odd.emplace_back(A[j], j);
            }
        }
        if(ODD != (int)odd.size() || EVEN != (int)even.size()) continue;
        sort(odd.begin(), odd.end());
        sort(even.begin(), even.end());
        vector<pair<int,int>> v;
        REP(i,ODD){
            v.emplace_back(odd[i]);
            if(i < EVEN) v.emplace_back(even[i]);
        }
        bool ok = true;
        for(int i=1;i<N;i++) if(v[i-1].first > v[i].first) ok = false;
        if(!ok) continue;
        int cnt = 0;
        REP(i,N) for(int j=i+1;j<N;j++) if(v[i].second > v[j].second) cnt++;
        chmin(ans, cnt);
        //REP(i,N) cout << v[i].first << " " << v[i].second << endl;
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
}

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

namespace ABC055B
{
    class Program
    {
        static void Main(string[] args)
        {
            Solver sol = new Solver();
            sol.Solve();
#if DEBUG
            Console.ReadLine();
#endif
        }
    }
    class Solver
    {
        int N;
        static readonly long m = 1000000007L;

        public void Solve()
        {
            long ans = 1L;
            for(int i=1;i<= N; i++)
            {
                ans = (i * ans) % m;
            }
            Console.WriteLine(ans);
        }

        public Solver()
        {
            N = ri();
        }

        static String rs() { return Console.ReadLine(); }
        static int ri() { return int.Parse(Console.ReadLine()); }
        static long rl() { return long.Parse(Console.ReadLine()); }
        static double rd() { return double.Parse(Console.ReadLine()); }
        static String[] rsa() { return Console.ReadLine().Split(' '); }
        static int[] ria() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); }
        static long[] rla() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); }
        static double[] rda() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); }
    }
}


Measured memory_bytes: 11092
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main(){
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var N int
	fmt.Fscan(r, &N)
	A := make([]int, N)
	for i:=0; i < N; i++{
		fmt.Fscan(r, &A[i])
	}
	ans := 0
	for i:=0; i < N; i++{
		ans += A[i] / 2
		A[i] %= 2
		if i!=N-1 && A[i] != 0 && A[i+1] != 0{
			ans++
			A[i]--
			A[i+1]--
		}
	}
	fmt.Fprintln(w, ans)
}

Measured memory_bytes: 4304
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc= new Scanner(System.in);
    int N = sc.nextInt(), T=N/2;
    String S = sc.next();
    if(N % 2 !=0) {
      System.out.println("No");
    } else if(S.substring(0,T).equals(S.substring(T,N))){
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

using i64 = int64_t;

i64 query(i64 a, i64 b, i64 l, i64 r) {
    if (r <= a || b <= l)
        return 0;

    if (a <= l && r <= b)
        return 1;

    i64 vl = query(a, b, l, (l + r) / 2);
    i64 vr = query(a, b, (l + r) / 2, r);
    return vl + vr;
}

int main(){
    int n;
    cin >> n;
    i64 left = -1, right = 1;
    while(left > -1000000000)left *= 2;
    while(right < 1000000000)right *= 2;
    for(int i=0;i<n;++i){
        i64 s, d;
        cin >> s >> d;
        cout << query(s, d, left, right) << endl;
    }

    return 0;
}



Measured memory_bytes: 3100
import fractions
N=int(input())
s = list( map(int , input().split()) )
ans = s[0]
count = 0
for i in range(1,N):
 ans = fractions.gcd(ans,s[i])
while i < pow(10,9):
 if ans%2 == 0:
  count +=1
  ans = ans/2
 else:
  break
print(count)


Measured memory_bytes: 5560
#include<bits/stdc++.h>
using namespace std;
 
typedef    long long          ll;
typedef    vector<long long>    vi; 
typedef    vector<vi>         vvi; 
typedef    pair<long,long>      ii; 
#define    sz(a)              long((a).size()) 
#define    pb                 push_back 
#define    mp                   make_pair
#define    all(c)             (c).begin(),(c).end() 
#define    tr(c,i)            for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++) 
#define    present(c,x)       ((c).find(x) != (c).end()) 
#define    cpresent(c,x)      (find(all(c),x) != (c).end())  
#define    input(v,n)           for(ll i = 0 ; i<n ; i++) cin>>v[i]
#define    output(v,n)          for(ll i = 0 ; i<n ; i++) cout<<v[i]<<" "

 vi g[300000];
 ll ans [300000],in[300000];

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


  ll n,m,i,j;
  cin>>n>>m;
  for(i=0;i<m;i++)
  {
    ll x,y;
    cin>>x>>y;
    g[x].pb(y);
    in[y]++;
  }


  queue<ll> q;
  for(i=1;i<=n;i++)
  {
    if(in[i] == 0)
    {
      q.push(i);
    }
  }
  ll  bns = 0;
  while(q.empty() == 0)
  {
    ll p =q.front();
    q.pop();

    for(i=0;i<g[p].size();i++)
    {
      ans[g[p][i]] = max(ans[g[p][i]],ans[p]+1);
      in[g[p][i]]--;
      if(in[g[p][i]] == 0)
      {
        q.push(g[p][i]);
      }
    }
  }

  for(i=1;i<=n;i++)
  {
    bns = max(bns,ans[i]);


  }

  cout<<bns<<"\n";



  return 0;
}


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

int main()
{
  double a, b;
  cin >> a >> b;
  cout << ceil((a + b) / 2) << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

import static java.lang.System.*;

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

        long[] cnts = new long[N + 1];
        for (int i = 1; i <= N; i++) {
            cnts[i] = sc.nextLong();
        }

        // 小さい順番から貪欲にペアを作成
        long pairs = 0;
        for (int i = 1; i <= N; i++) {
            if (cnts[i - 1] > 0 && cnts[i] > 0) {
                pairs++;
                cnts[i - 1]--;
                cnts[i]--;
            }
            pairs += cnts[i] / 2;
            cnts[i] %= 2;
        }

        out.println(pairs);
    }
}

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

int main() {
	
	ll n, m, k; cin >> n >> m >> k;
	vector<ll> aAccum(n + 1, 0), bAccum(m + 1, 0);
	for (ll i = 1; i <= n; i++) {
		ll a;  cin >> a;
		aAccum[i] += aAccum[i - 1];
		aAccum[i] += a;	
	}
	for (ll i = 1; i <= m; i++) {
		ll b;  cin >> b;
		bAccum[i] += bAccum[i - 1];
		bAccum[i] += b;
	}
	if (k < min(aAccum[1], bAccum[1])) {
		cout << 0 << endl;
		return 0;
	}
	ll ans = 0;
	ll a_index = 0;
	ll b_index = m;
	for (; a_index <= n; ) {
		if (aAccum[a_index] + bAccum[b_index] <= k) {
			ans = max(ans, a_index + b_index);
			a_index++;
		}
		else {
			b_index--;
		}
		if (b_index == -1) {
			break;
		}		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6424
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int n;
	while(cin>>n,n){
		string s;
		int ba=0;
		cin>>s;
		vector<int>in(n);
		rep(i,100){
			int d=i%n;
			if(s[i]=='M')in[d]++;
			else if(s[i]=='L'){
				in[d]+=ba+1;
				ba=0;
			}else{
				ba+=in[d]+1;
				in[d]=0;
			}
		}
		sort(all(in));
		rep(i,n)cout<<in[i]<<" ";
		cout<<ba<<endl;
	}
}

Measured memory_bytes: 1228
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int N,K;
vector<int> P;

class BIT{//1-indexed
public:

  vector<ll> bit;
  BIT(){}
  BIT(int size){
    bit.resize(size,0);
  }

  ll sum(int i){
    ll s=0;
    while(i>0){
      s+=bit[i];
      i-=i&(-i);
    }
    return s;
  }

  void add(int i,ll x){//i!=0
    while(i<bit.size()){
      bit[i]+=x;
      i+=i&(-i);
    }
  }
};


int main(){
  cin>>N>>K;
  P.resize(N);
  rep(i,N) cin>>P[i];

  if(K==N){
    for(int i=0;i+1<N;i++){
      if(P[i]+1==P[i+1]||P[i]==N&&P[i+1]==1);
      else {
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    return 0;
  }

  BIT bit(N+1);
  ll ans=0;
  for(int i=0;i<N;i++){
    ans+=i-bit.sum(P[i]);
    bit.add(P[i],1);
  }

  if(K%2==0||ans%2==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}



Measured memory_bytes: 3888
#include<bits/stdc++.h>
#define ll                 long long int
#define mod                9000000000000000000
#define pi                 3.14159265358979323846264338327950288419716939937510
#define setbit(x)          __builtin_popcountll(x)
#define db                 long double
#define pp(x)              pair<x,x>
#define ff                 first
#define ss                 second
#define FIO                ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tc                 ll tc; cin>>tc; for(ll number = 1 ; number <= tc ; number ++ )
#define vv(x)              vector<x>
#define pb                 push_back
#define pob                pop_back
#define pf                 push_front
#define pof                pop_front
#define endl               "\n"
#define pq                 priority_queue
#define dbg(x)             { cout<< #x << ": " << (x) << endl; }
#define dbg2(x,y)          { cout<< #x << ": " << (x) << " , " << #y << ": " << (y) << endl; }
#define bp                 ll kkk; cin >>kkk;
#define dbgArr(a,n)        cout<<"Array "<<#a<<endl; for(ll i=0 ; i<n ; i++) cout<<a[i]<<" "; cout<<endl;
#define maxE(a,n)          *max_element(a,a+n);
#define minE(a,n)          *min_element(a,a+n);
#define forn(i,s,n)        for(ll i=s ; i<n ; i++)
#define fornr(i,e,s)       for(ll i=e-1 ; i>=s ; i--)
#define arr(a,n)           for(ll i=0;i<n;i++){ cin>>a[i]; }
#define arr1(a,n)          for(ll i=1;i<=n;i++){ cin>>a[i]; }
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
#define print cout<<"Case #"<<number<<": "
#define all(x) x.begin(), x.end()
ll power(ll x, ll b) {ll p = 1;while (b > 0) {if(b&1) {p = p * x; p %= mod;} b >>= 1; x *= x; x %= mod;} return p % mod;}
using namespace std;
# define INF 1e15
struct lex_compare {
    bool operator() (const pair<db,ll>  p1, const pair<db,ll> p2){
        return (p1.first ==  p2.first) ? p1.ss < p2.ss : p1.first > p2.first;
    }
};

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


Measured memory_bytes: 3652
// In the name of GOD
 
#include <bits/stdc++.h>
#define ll long long
#define pp pair <int, int>
using namespace std;
const ll N = 2e5 + 10, MOD =  998244353;

void solve() {
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') {
        cout << 'A';
    } else {
        cout << 'a';
    }
}


int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    } 
}                                   

Measured memory_bytes: 3636
import sys
from fractions import gcd
n = int(input())
a = [int(input()) for _ in range(n+1)]
x = 0
while True:
	m = abs(sum([a[i]*pow(x, n-i) for i in range(n+1)]))
	if m != 0:
		break
	x += 1
ps = []

i = 2
while i**2 <= m and i <= n+1:
	if m%i == 0:
		ps.append(i)
		while m%i == 0:
			m //= i
	i += 1
if m != 1 and n != 0:
	ps.append(m)
g = a[0]
for i in range(1, n+1):
	g = gcd(g, abs(a[i]))

ans = []
i = 2
while i**2 <= g:
	if g%i == 0:
		if i >= n+1:
			ans.append(i)
		while g%i == 0:
			g //= i
	i += 1
if g != 1 and g >= n+1:
	ans.append(g)

a = a[::-1]
for p in ps:
	if p-1 > n:
		ng = False
		for i in range(1, n+1):
			if a[i]%p != 0:
				ng = True
				break
		if not ng:
			ans.append(p)
	else:
		mods = [0 for _ in range(p-1)]
		for i in range(1, n+1):
			mods[i%(p-1)] += a[i]
			mods[i%(p-1)] %= p
		if mods[0] == 0:
			ng = False
			for i in range(1, p-1):
				if mods[i] != 0:
					ng = True
					break
			if not ng:
				ans.append(p)
ans = sorted(list(set(ans)))
if ans:
	print(*ans, sep="\n")

Measured memory_bytes: 78932
n = int(input())
s = [input() for i in range(n)]
for i in range(n):
    s[i] = sorted(s[i])
s.sort()
result = 0
count = 1
for i in range(n-1):
    if s[i] == s[i+1]:
        count += 1
    else:
        result += (count*(count-1))//2
        count = 1
result += count*(count-1)//2
print(result)

Measured memory_bytes: 26320
#include <iostream>
using namespace std;
int main(){
  int a,ans=0;
  cin >> a;
  for(int i = 1;i<a+1;i++){
    if(i/10==0)ans++;
    else if(i/1000==0&&i/100!=0)ans++;
    else if(i/100000==0&&i/10000!=0)ans++;
  }
  cout << ans;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int A[200100];
int cnt[200100];
std::stack<int> st;

bool can(int k){
    memset(cnt, 0, sizeof(cnt));
    until(st.empty()){
        st.pop();
    }

    for(int i=1;i<=N;++i){
        if(A[i-1] < A[i]){continue;}
        if(A[i] > N){continue;}

        while(!st.empty() && st.top() > A[i]){
            cnt[st.top()] = 0;
            st.pop();
        }

        int j = A[i];
        for(;j>=1;--j){
            if(cnt[j] + 1 < k){
                cnt[j] += 1;
                break;
            }else{
                cnt[j] = 0;
            }
        }

        if(j == 0){
            return false;
        }

        while(!st.empty() && st.top() > j){
            st.pop();
        }

        st.emplace(j);
    }

    return true;
}

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

    std::cin >> N;

    for(int i=1;i<=N;++i){
        std::cin >> A[i];
    }

    int lb = 0, ub = N;
    while(ub - lb > 1){
        int m = (lb + ub) / 2;

        if(can(m)){
            ub = m;
        }else{
            lb = m;
        }
    }

    std::cout << ub << std::endl;
}



Measured memory_bytes: 2724
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll INF = 100000000;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0);

    rep1(i, n) cin >> a[i];
    sort(a.begin(), a.end(), greater<ll>());
    priority_queue<ll> pq;
    ll res, ans = 0;
    rep1(i,n){
        if (i == 0) pq.push(a[i]);
        else {
            res = pq.top(); pq.pop();
            ans += res;
            pq.push(a[i]);
            pq.push(a[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 6924
#include <stdio.h>
int main() {
    int RB[10][10],i,j,k;for (i=0;i<10;i++) for (j=0;j<10;RB[i][j++]=0);while (scanf("%d,%d,%d",&i,&j,&k)!=EOF) {
        RB[i][j]++;if (i) RB[i-1][j]++;if (i<9) RB[i+1][j]++;if (j) RB[i][j-1]++;if (j<9) RB[i][j+1]++;if (k>1) {if (i*j) RB[i-1][j-1]++;if (i<9 && j<9) RB[i+1][j+1]++;if (i && j<9) RB[i-1][j+1]++;if (i<9 && j) RB[i+1][j-1]++;} if (k==3) {if (i>1) RB[i-2][j]++;if (i<8) RB[i+2][j]++;if (j>1) RB[i][j-2]++;if (j<8) RB[i][j+2]++;}}
    for (i=0,k=100;i<10;i++) for (j=0;j<10;j++) if (RB[i][j]) k--;printf("%d\n",k);for (i=0,k=0;i<10;i++) for (j=0;j<10;j++) if (RB[i][j]>k) k=RB[i][j];printf("%d\n",k);return 0;}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;

ll mod = 2019;

void solve() {
    ll l, r; cin >> l >> r;
    if(r-l > 2019){
        cout << 0 << endl;
        return;
    }
    l %= mod; r %= mod;
    // cout << l << " " << r << endl;
    if(r <= l){
        cout << 0 << endl;
        return;
    }
    ll ans = 2018;
    Rep(i, l, r-1){
        Rep(j, i+1, r){
            ans = min(ans, (i*j)%mod);
        }
    }
    cout << ans << endl;
}

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

    solve();
    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 t = sc.nextInt();
        int ans = 1001;
        for (int i=0;i<n;i++){
            int c = sc.nextInt();
            if (sc.nextInt()<=t)ans=Math.min(c,ans);
        }
        if (ans==1001)System.out.println("TLE");
        else System.out.println(ans);
    }
}


Measured memory_bytes: 36016
/*================================================================
*   Copyright (C) 2019 Sangfor Ltd. All rights reserved.
*
*   创 建 者： badcw
*   创建日期： 2019/12/22
*
================================================================*/
#include <bits/stdc++.h>

#define ll long long
using namespace std;

const int maxn = 100;
const int mod = 1e9+7;
ll qp(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
inline bool scan(T& ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return 0; // EOF
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}

//template <class T>
//inline void out(T x) {
//    if (x > 9) out(x / 10);
//    putchar(x % 10 + '0');
//}

int main(int argc, char* argv[]) {
    int a, b;
    scanf("%d%d", &a, &b);
    int res = 6;
    res -= a + b;
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 256
use proconio::fastout;

#[fastout]
fn main(){
    
    use proconio::input;

    input!{
        n: usize,
        x: usize,
        t: usize,
    }

    let ans = if n%x == 0 {
       n/x
    }else{
         n / x + 1
    };

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


}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, ans=0, tmp=0;
vector<ll> A;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a;
        cin >> a;
        if((i+1)%2==1&&a%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using ll = long long;
#define rep(i,N) for(ll i=0;i<ll(N);++i)
int main() {
  ll N,K;
  cin >> N >> K;
  vector<ll> tele(N);
  rep(i,N){
    cin >> tele.at(i);
    tele.at(i) --;
    //cout << tele.at(i)<< " ";
  }
  //cout << endl;
  ll loop = 0,now = 1 - 1;
  vector<ll> memo(N,0);
  memo.at(now) = 0;
  //町は1-indexに注意
  ll point;
  bool fin = true;
  rep(i,K){
    now = tele.at(now);
    //cout << "now = " << now << endl;
    if(memo.at(now) == 0){
      memo.at(now) = i+1;
      //cout << "memo = " << memo.at(now) << endl;
      continue;
    }
    if(memo.at(now) != 0){
      loop = i + 1 - memo.at(now);
      point = i + 1;
      fin = false;
      //cout << "break" << endl;
      break;
    }
  }
  if(fin){
    cout << now + 1 << endl;
    return 0;
  }
  ll rest = (K - point) % loop;
  //cout <<"rest = " <<  rest << endl;
  rep(i,rest){
    now = tele.at(now);
  }
  cout << now + 1 << endl;
  return 0;
}

Measured memory_bytes: 6432
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <set>
#include <climits>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ll n;
    scanf("%lld", &n);
    ll m = (ll)sqrt(n);
    ll min_move = n * 2;
    for (ll i = 1; i <= m; ++i) {
        if (n % i == 0) {
            ll j = n / i;
            min_move = min(min_move, i + j - 2);
        }
    }
    printf("%lld\n", min_move);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define scl(n) scanf("%lld", &n)
#define pcl(n) printf("%lld\n", n)
#define pcl1(n) printf("%lld ", n)
#define nln printf("\n")
#define dev(x) cout << #x << " " << x << " ";
#define PTT pair<ll, ll>

map<ll, ll> mp, mp1;
map<ll, ll>::iterator itr;

int main()
{
    ll t, n, x;
    scl(n);
    if (n >= 30)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }

    return 0;
}

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

int a[200000];
int q[1000];
int f[200000];
int main() {
  int n,m,Q;
  scanf("%d%d%d", &n, &m, &Q);
  memset(f,0,sizeof(f));
  REP(i,m) scanf("%d", a+i);
  REP(i,Q) scanf("%d", q+i);
  list<int> ls;
  REP(i,n) ls.push_back(i);
  auto it = ls.begin();
  REP(i,m) {
    int x = a[i];
    if (a[i] & 1) {
      REP(_,x) {
        if (it == ls.begin()) {
          it = prev(ls.end());
        } else {
          it--;
        }
      }
    } else {
      REP(_,x) {
        it++;
        if (it == ls.end())
          it = ls.begin();
      }
    }
    f[*it] = 1;
    it = ls.erase(it);
    if (it == ls.end()) it = ls.begin();
  }
  REP(i,Q) printf("%d\n", !f[q[i]]);
}

Measured memory_bytes: 8992
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int x=0;
    for(int i=0;i<=n;i++){
    if(i<10){
         if(i>=a && i<=b){
         x+=i;
     }
   }
   else if(i>=10 && i<100){
        int c=i/10;
        int d=i%10;
        if(c+d>=a && c+d<=b){
          x+=i;
    }
  }
  else if(i>=100 && i<1000){
  int c=i/100;
  int d=(i-c*100)/10;
  int e=(i-c*100-d*10)/1;
   if(c+d+e>=a && c+d+e<=b){
   x+=i;
}
  }
  else if(i>=1000 && i<10000){
  int c=i/1000;
  int d=(i-c*1000)/100;
  int e=(i-c*1000-d*100)/10;
  int f=(i-c*1000-d*100-e*10)/1;
  if(c+d+e+f>=a && c+d+e+f<=b){
  x+=i;
}
  }
  else if(i==10000){
     if(1>=a && 1<=b){
     x+=10000;
 }
  }
 if(i==n){
 cout << x << endl;
}
}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
#include <string>
#include <sstream>
#define ll long long
#define F first
#define S second
#define pb push_back
#define ld long double
#define pll pair<long long,long long>
#define pld pair<long double,long double>
#define ios     ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll mod=1000000007;
ll gcd (ll a,ll b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
ll fastexp(ll x ,ll n)
{
    ll result =1;
    while(n>0)
    {
        if(n%2==1)
            result*=x;
        x*=x;
        n=n/2;
    }
    return result;
}

ll modularExp(ll x,ll n,ll mod)
{
    ll result=1;
    while(n>0)
    {
        if(n%2==1)
            result=(result*x)%mod;
        x=((x%mod)*(x%mod))%mod;
        n=n/2;
    }
    return (result)%mod;
}
bool isPrime(ll n)
{
    for(ll i=2;i*i<=n;i++)
        if(n%i==0)
            return false;
    return true;
}
bool mycomp(pll &a,pll &b)
{
    if(a.F!=b.F)
        return a.F < b.F;
    else
        return a.S < b.S;
}

void solve()
{
     ll n,m;
     cin>>n>>m;
     ll i,j;
     vector< vector<char> > v(n+1,vector<char>(m+1));
     for(i=1;i<=n;i++)
          for(j=1;j<=m;j++)
               cin>>v[i][j];
     vector< vector<ll> > dp(n+1,vector<ll>(m+1));
     dp[1][1]=1;
     for(i=1;i<=n;i++)
     {
          for(j=1;j<=m;j++)
          {
               if(i==1 && j==1)
                    continue;
               if(v[i][j]=='#')
                    dp[i][j]=0;
               else 
               {
                    if(i==1)
                         dp[i][j]=(dp[i][j-1])%mod;
                    else if(j==1)
                         dp[i][j]=(dp[i-1][j])%mod;
                    else
                         dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
               }
          }
     }
     cout<<dp[n][m];
}

int main()
{
    ios;
    ll t;
//    cin>>t;
  t=1;
    while(t--)
        solve();
}


Measured memory_bytes: 9216
#include<iostream>

using namespace std;

int main(){
  int N,W;
  cin>>N>>W;
  int c=0;
  int a[100001]={};
  for(int i=1;i<=N;i++){
    if(W<2*i&&i<W){
      a[i+1]+=i*3<=i+1+W-1;
      for(int j=i;j<=2*N;j+=i){
	int x=j-W+1;
	if(x>i+1&&x<=N){
	  a[x]++;
	}
	if(i+1<j+1&&j+1<=N){
	  a[j+1]--;
	}
      }
    }else if(i<W){
      a[i+1]++;
    }
  }
  for(int i=1;;i++){
    cout<<c+W;
    if(i==N-W+1){
      cout<<endl;
      break;
    }else{
      cout<<' ';
      c+=a[i+1];
    }
  }
}

      

Measured memory_bytes: 1560
#include <stdio.h>

int main(void) {
 int n;
  int dat;
  scanf("%d", &n);
  int er = 0;
  for (int i = 1;i <= n;i ++) {
    scanf("%d", &dat);
    if (dat % 2 == 0) {
    	if (dat % 3 == 0 || dat % 5 == 0) {
        } else {
          er = 1;
          break;
        }
    }
  }
  
  if (er == 0) printf("APPROVED");
  else printf("DENIED");
  return 0;
}

Measured memory_bytes: 128
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main() {
    string ans, N;
    rep(i, 4) {
        cin >> N;
        ans += N;
    }
    sort(all(ans));
    cout << ((ans == "1479") ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int bip(int i, int n);
int bip2(int i, int n);
char Graph[200][200];
int v[200];
int main() {
	//A
	/*string S;
	long long int spart[100];

	long long int k;
	int diflag = 0;
	cin >> S;
	cin >> k;

	int i;
	int j = 0;
	for (i = 0; i < 100; i++) {
		spart[i] = 0;
	}
	spart[0] = 1;
	for (i = 0; i < S.length() - 1; i++) {
		if (S[i] == S[i + 1]) {
			spart[j]++;
		}
		else {
			diflag = 1;
			j++;
			spart[j]++;
		}
	}
	long long int counter = 0;
	if (diflag == 1) {
		if (S[0] == S[S.length() - 1]){
			if ((spart[0] % 2 == 1) && (spart[j] % 2 == 1))counter = -1;
			spart[0] = spart[0] + spart[j];

			//spart[j] = 0;
			j = j - 1;
		}
		for (i = 0; i <= j; i++) {
			//cout << spart[i] ;
			counter = counter + k * ((spart[i] - (spart[i] % 2)) / 2);
		}
		cout << counter;
	}
	else {
		if (k % 2 == 0) {
			cout << S.length() * k / 2;
		}
		else if (S.length() % 2 == 0) {
			cout << S.length() * k / 2;

		}
		else {
			cout << (S.length() * k - 1) / 2;
		}
	}

	return 0;*/
	//B

	int n;
	cin >> n;
	int i, j;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			cin >> Graph[i][j];
		}
	}


	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			v[j] = -1;
		}
		v[i] = 0;
		if (bip(i, n) == 0) {
			cout << -1;
			return 0;
		}
	}
	int vmax = 0;
	int vmax2 = 0;
	int bp2 = 0;
	
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			v[j] = 201;
		}
		vmax = 0;
		v[i] = 0;
		bp2 = bip2(i, n);
		for (j = 0; j < n; j++) {
			if (v[j] > vmax) {
				vmax = v[j];
			}
		}
		if (vmax > vmax2) {
			vmax2 = vmax;
		}
		//if (vmax2 == 200)cout << i;
	}
	cout << vmax2+1;
	return 0;

}

int bip(int i, int n) {
	int j;
	int bp;
	for (j = 0; j < n; j++) {
		if (Graph[i][j] == '1') {
			if ((v[j]>=0) && ((v[j] % 2)==(v[i] % 2))) {
				return 0;
			}
			else if (v[j] != -1) {
				//return 1;
			}
			else {
				v[j] = v[i]+1;
				bp = bip(j, n);
				if (bp == 0)return 0;
			}
		}
	}
	return 1;
}
int bip2(int i, int n) {
	int j,k;
	for (j = 0; j < n; j++) {
		if (Graph[i][j] == '1') {
			if (v[i] == v[j]) {
				//return 0;
			}
			else if (v[i] >= v[j]-1) {
				//return 1;
			}
			else {
				v[j] = v[i]+1;
				//cout << i;
				//cout << ',';
				//cout << j;
				//cout << ':';
				//for(k=0;k<6;k++)cout << v[k];
				//cout << '\n';
				k= bip2(j, n);
			}
		}
	}
	return 1;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const double PI = acos(-1);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int a, sum = 0;
	rep(i,m){
		cin >> a;
		sum += a;
	}
	int ans = n - sum;
	if(ans < 0) ans = -1;
	cout << ans << endl;
	return 0;
}


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

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 100005
#define MOD 1000
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int x, p;

int main () {
    scanf("%d%d", &x, &p);

    double ans = (x+1)/2 * 100.0/p;
    printf("%.9g", ans);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
LLONG MOD = 1000000007;

LLONG N, K;

const int MAX = 2000;
LLONG fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
LLONG Combination(const LLONG n, const LLONG k)
{
    if (n <= 0) return 1;
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const LLONG Compute(const LLONG i)
{
    const LLONG redNum = N - K;
    // 青いボールの箱が１つのときは間に入れる赤いボールがないので別処理
    if (i == 1)
    {
        return Combination(redNum + 2 - 1, redNum);
    }

    // 青いボールをi個の箱に分類する場合の数
    const LLONG blue = Combination(K - 1, i - 1);

    // 青いボールの箱の間に入れる赤いボールの個数を減らしていく
    LLONG red = 0;
    for (LLONG midRedNum = redNum; midRedNum >= i - 1; --midRedNum)
    {
        // 青いボールの箱の間(i - 1)箇所に赤いボールを入れる場合の数
        const LLONG midRed = Combination(midRedNum - 1, (i - 1) - 1);

        // 残った赤いボールを青いボールの箱の両脇におく場合の数
        LLONG remRedNum = redNum - midRedNum;
        const LLONG remRed = Combination(remRedNum + 2 - 1, remRedNum);

        red += ((midRed % MOD) * (remRed % MOD)) % MOD;
    }
    return ((blue % MOD) * (red % MOD)) % MOD;
}

int main()
{
    COMinit();
    cin >> N >> K;
    for (LLONG i = 1; i <= K; ++i)
    {
        cout << Compute(i) << endl;
    }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int Q = scanner.nextInt();
    Node[] nodes = new Node[N];
    for (int i = 0; i < N; i++) nodes[i] = new Node();
    for (int i = 0; i < N - 1; i++) {
      int a = scanner.nextInt() - 1;
      int b = scanner.nextInt() - 1;
      nodes[a].neighbors.add(nodes[b]);
      nodes[b].neighbors.add(nodes[a]);
    }
    for (int i = 0; i < Q; i++) {
      int p = scanner.nextInt() - 1;
      int q = scanner.nextInt();
      nodes[p].offset += q;
    }
    dfs(null, nodes[0], 0);
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < N; i++) {
      sb.append(nodes[i].counter).append(' ');
    }
    System.out.println(sb.toString());
  }

  private static void dfs(Node parent, Node node, int sum) {
    sum += node.offset;
    node.counter = sum;
    for (Node a : node.neighbors) {
      if (a != parent) {
        dfs(node, a, sum);
      }
    }
  }

  private static class Node {
    private List<Node> neighbors = new ArrayList<>();
    private int offset;
    private int counter;
  }
}


Measured memory_bytes: 206344
/*In The Name of AintAH*/
#include <bits/stdc++.h>
#define inf 1000000007
#define mod	1000000007
#define MAX 200005 
#define ll long long
#define fr first
#define sc second
#define endl '\n'

using namespace std;
set<int> al[26];
int main(){ 
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	string s,t;
	cin>>s>>t;
	int n = s.size();
	for(int i =0 ; i < n ; i++)al[s[i] - 'a'].insert(i);
	int cur = -1;
	ll ans = 0;
	for(int i = 0 ; i < t.size();i ++){
		auto it = al[t[i]-'a'].lower_bound(cur+1);
		if(it == al[t[i]-'a'].end()){
			// cout<<"sad";
			ans += n - cur;
			cur = 0;
			it = al[t[i] - 'a'].lower_bound(cur);
			if(it == al[t[i]-'a'].end())return cout<<-1, 0;
			else {
				ans += (*it - cur);
				cur = *it;	
			}
		}else{
			ans += (*it - cur );
			cur = *it;	
			// cout<<ans<<" "<<cur<<endl;
		}
	}
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 5200
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
    int k,x;
    cin>>k>>x;
    int z=x-k+1;
    int c=x+k-1;
    for(int i=z;i<=c;i++){
        cout<<i;
        if(i!=c){
            cout<<" ";
        }
    }

}


Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
*/

main:-
    get_number(A),
    X is A * A,
    writeln(X).


Measured memory_bytes: 8184
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	long long int a, b;
	long long int v, w, t;
	std::cin >> a >> v;
	std::cin >> b >> w;
	std::cin >> t;

	long long int distance = abs(b - a);
	long long int speed = abs(w-v);

	if (w - v >= 0) {
		cout << "NO" << endl;
		return 0;
	}

	if (distance <= t*speed) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}

	return 0;
}


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

int main() {
  int a,b; cin >> a >> b;
  int mini = min(a,b), maxi = max(a,b);
  if(mini == 1 && maxi == 2) cout << 3 << endl;
  if(mini == 1 && maxi == 3) cout << 2 << endl;
  if(mini == 2 && maxi == 3) cout << 1 << endl;
}


Measured memory_bytes: 256
from operator import itemgetter
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 

n = int(readline())

red = []
for i in range(n):
    a,b = map(int,readline().split())
    red.append([a,b])

blue = []
for i in range(n):
    a,b = map(int,readline().split())
    blue.append([a,b])

red.sort(reverse=True,key=itemgetter(1))
blue.sort()

ans = 0
used = []
for c,d in blue:
    for a,b in red:
        if c > a and d > b:
            if not (a,b) in used:
                ans += 1
                used.append((a,b))
                break

print(ans)

Measured memory_bytes: 41068
def sol():
    h,w=map(int,raw_input().split())
    l=[]
    y,x=0,0
    if h==w==0:
        exit()
    for i in range(h):
        l.append(list(raw_input()))
    while 1:
        if l[y][x]=='.':
            print x,y
            return
        elif l[y][x]=='>':
            l[y][x]=1
            x+=1
        elif l[y][x]=='<':
            l[y][x]=1
            x-=1
        elif l[y][x]=='^':
            l[y][x]=1
            y-=1
        elif l[y][x]=='v':
            l[y][x]=1
            y+=1
        elif l[y][x]==1:
            print 'LOOP'
            return


while 1:
    sol()

Measured memory_bytes: 6396
import sys
input = sys.stdin.readline
H,W=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]
A=[list(map(int,input().split())) for _ in range(H)]
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
n=10
B=warshall_floyd(c)
#print(B)
ans=0
for i in range(H):
    for j in range(W):
        if A[i][j]==-1 or A[i][j]==1:
            continue
        else:
            ans+=B[A[i][j]][1]
print(ans)


Measured memory_bytes: 40668
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        ITP1_2_A(args);
    }

    public static void ITP1_2_A(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}



Measured memory_bytes: 26172