akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, A: int):
    if N % 500 <= A:
        ret = YES
    else:
        ret = NO
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = int(next(tokens))  # type: int
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int N;
i64 A[202020];

int main(){
  cin >> N;
  rep(i,0,N - 1){
    cin >> A[i];
  }
  int r = 0;
  i64 ans = 0;
  i64 now = 0;
  rep(l,0,N - 1){
    while(r < N && (now & A[r]) == 0){
      now |= A[r];
      r++;
    }
    ans += r - l;
    if(l == r){
    }
    else{
      now &= ~(A[l]);
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 1792
n = gets.to_i
a1 = gets.split.map(&:to_i)
a2 = gets.split.map(&:to_i)

ans = 0
n.times do |i|
  sum = a1[0..i].inject(&:+) + a2[i..-1].inject(&:+)
  ans = [ans, sum].max
end

puts ans


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

int main(){
  long long n;
  cin >> n;
  ll ans = 0;
  for(int i = 0; i < n; i++){
    ll a; cin >> a;
    ans += a-1;
  }
  cout << ans << endl;
}

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

int main(){
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N+1);
  for(int i=1; i<=N; i++){
    cin >> A.at(i);
  }
  int S=0;
  for(int i=1; i<=N; i++){
    S+=(D-1)/A.at(i)+1;
  }
  cout << S+X << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int op[100001] = {0};
int main()
{
	int n, k, q;
	cin >> n >> k >> q;
	int pop;
	for (int i = 0; i < q; i++) {
		scanf("%d", &pop);
		op[pop]++;
	}
	if (k > q)
		for (int i = 0; i < n; i++)
			cout << "Yes" << endl;
	else {
		for (int i = 1; i <= n; i++)
		{
			if (q - op[i] < k)
				cout << "Yes" << endl;
			else
				cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
fun main(args:Array<String>) {
    val studentCount = readLine()!!.toInt()
    val numList = readLine()!!.split(" ").map { it.toLong() }
    val ans = if(getAns(numList)) "Yes" else "No"
    println(ans)

}
fun getAns(numList:List<Long>):Boolean {
    var div2 = 0
    var div4 = 0
    var other = 0
    numList.forEach {
        if(it % 4 == 0L) {
            div4++
        } else if(it % 2 == 0L) {
            div2++
        } else {
            other++
        }
    }
    if(other == 0) {
        return true
    }
    if(div2 > 0) {
        other++
    }
    return div4 + 1 >= other
}



Measured memory_bytes: 54036
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;
int A, B, T;

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

    cin >> A >> B >> T;

    cout << floor((T + 0.5) / A) * B << endl;

    return 0;
}


Measured memory_bytes: 888
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.ReadLine();
        }

        public void Solve(ConsoleInput cin)
        {
            long a = cin.ReadLong;
            int[] list = cin.ReadIntArray(a);

            int i;
            int next = 1;
            for (i = 1; i <= a; i++)
            {
                next = list[next-1];
                if (next == 2) break;
            }
         

            Console.WriteLine(i > a ? -1 : i);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long num) { var ret = new string[num]; for (long i = 0; i < num; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long num) { var ret = new int[num]; for (long i = 0; i < num; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long num) { var ret = new long[num]; for (long i = 0; i < num; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 15456
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    s ss;
    cin>>ss;
    q i=0;
    if(ss[0]=='+')
    i++;
    if(ss[1]=='+')
    i++;
    if(ss[2]=='+')
    i++;
    if(ss[3]=='+')
    i++;
    if(ss[0]=='-')
    i--;
    if(ss[1]=='-')
    i--;
    if(ss[2]=='-')
    i--;
    if(ss[3]=='-')
    i--;
    cout<<i;
return 0;}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main()
{
    ll n,m,k,ans=0;
    cin>>n>>m>>k;
    ll a[n+5]={0},b[m+5]={0};
    for(ll i=1;i<=n;i++)
    {
    	 cin>>a[i];
	a[i]+=a[i-1];
    }
    for(ll i=1;i<=m;i++)
    {
    	 cin>>b[i];
	b[i]+=b[i-1];
    }
    for(ll i=0;i<=n;i++) 
	 if(k>=a[i]) ans=max(ans,upper_bound(b+1,b+1+m,k-a[i])-b-1+i);
    
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 6736
prime=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47]
s=[0 for i in range(15)]
N=int(input())
for i in range(15):
  j=1
  while N//(prime[i]**j)>0:
    s[i]+=N//(prime[i]**j)
    j+=1
o3,o5,o15,o25,o75=0,0,0,0,0
for item in s:
  if item>=2:
    o3+=1
    if item>=4:
      o5+=1
      if item>=14:
        o15+=1
        if item>=24:
          o25+=1
          if item>=74:
            o75+=1
ans=[0,0,0,0]
if o75>0:
  ans[0]+=1
if o25>0:
  ans[1]+=o25*(o3-1)
if o15>0:
  ans[2]+=o15*(o5-1)
if o5>1 and o3>2:
  ans[3]+=o5*(o5-1)//2*(o3-2)
print(sum(ans))


Measured memory_bytes: 3064
#pdf見た
n = int(input())
xl = [list(map(int,input().split())) for i in range(n)]
sf = []
choice = -1e+9
for x,l in xl:
    sf.append([x-l,x+l])
sf.sort(key=lambda x:x[1])
cnt = 0
for s,f in sf:
    if choice <= s:
        cnt += 1
        choice = f
        
print(cnt)

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

int main() {
	int x;
	std::cin >> x;
	int k = 7 % x;
	for (int i = 0; i < x; i++) {
		if (k % x == 0) {
			std:cout << i + 1 << std::endl;
			return 0;
		}
		k = (10 * k + 7) % x;
	}
	std::cout << -1 << std::endl;
	return 0;
}

Measured memory_bytes: 3628
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});

process.stdin.on('end', function() {
    Main(g_input.split(/\r?\n/));
});

var memo = {};

function Main(input) {
    var n = parseInt(input[0], 10);
    var worstRank = 0;
    var worstScore = 0;
    for (var i = 0; i < n; i++) {
        var tokens = input[i + 1].split(' ');
        var a = parseInt(tokens[0], 10);
        var b = parseInt(tokens[1], 10);

        if (a > worstRank) {
            worstRank = a;
            worstScore = b;
        }
    }

    var entryNumber = worstRank + worstScore;

    console.log(entryNumber);

    return 0;
}

Measured memory_bytes: 44716
def check_palindrome(target):
    reverse_t = target[::-1]
    if reverse_t == target:
        return True
    else:
        return False


s = input()
n = len(s)

if not check_palindrome(s):
    print('No')
    exit()

if not check_palindrome(s[:int((n-1)/2)]):
    print('No')
    exit()

if not check_palindrome(s[int((n+3)/2) - 1:]):
    print('No')
    exit()

print('Yes')


Measured memory_bytes: 3064
n,m=map(int,input().split())
l=[list(map(int,input().split())) for i in range(m)]
for i in l:
    i[0],i[1]=i[1],i[0]
ll=sorted(l)
x,cnt=ll[0][0],1
for i in ll:
    a=i[1]
    b=i[0]
    if a>=x:
        cnt+=1
        x=b
print(cnt)

Measured memory_bytes: 28764
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

ll powmod(ll x, ll n, ll m = MOD) {
    ll ans = 1;
    while(n) {
        if(n & 1) {
            ans = ans * x % m;
        }
        x = x * x % m;
        n >>= 1;
    }
    return ans;
}
inline ll invmod(ll x, ll m = MOD) {
    return powmod(x, m - 2);
}

const int N = 444444;
ll fact[N], invfact[N];
void initfact(ll m = MOD) {
    fact[0] = 1;
    invfact[0] = 1;
    rep(i, 1, N - 1) {
        fact[i] = fact[i - 1] * i % m;
        invfact[i] = invmod(fact[i]);
    }
}
inline ll ncr(ll n, ll r, ll m = MOD) {
    if(r < 0 || r > n) return 0;
    if(r == 0 || r == n) return 1;
    return fact[n] * invfact[r] % m * invfact[n - r] % m;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    initfact();
    int n, k;
    cin >> n >> k;
    int ans = 1;
    k = min(k, n - 1);
    rep(m, 1, k) {
        ans += ncr(n, m) * ncr(n - 1, m) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7168
#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d%d", &a, &b);
    (a > b) ? (c = a--) : (c = b--);
    (a > b) ? (c += a--) : (c += b--);
    printf("%d\n", c);

    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int k;cin>>k;
  rep(i, k)cout<<"ACL";
  return 0;
}

Measured memory_bytes: 3592
using System;
using System.Collections.Generic;
using System.Linq;

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

            var d = new Dictionary<long, bool>();
            for(var i = 0; i < n; i++){
                var a = long.Parse(Console.ReadLine());
                if(d.ContainsKey(a)){
                    d[a] = !d[a];
                }else{
                    d.Add(a, true);
                }
            }

            var count = d.Count(t => t.Value);
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 22240
N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for i in range(M)]

for i in range(10**N):
  n = str(i)
  if len(n) != N: continue
  if all([n[s-1] == str(c) for s, c in sc]):
    print(n)
    break
else:
  print(-1)


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

int main()
{
    int n,k, intOnBall, diffInt=0;

    int intCnt[200001] = {0};

    cin >> n >> k;


    for(int i=1; i<=n; i++)
    {
        cin >> intOnBall;

        if(intCnt[intOnBall] == 0) diffInt++;
        intCnt[intOnBall]++;
    }

    if(n==1 || diffInt <= k) cout << 0 << endl;
    else
    {
        sort(intCnt, intCnt+200000);

        int minNumOfRewrite=0;
        for(int i=1; i<=200000; i++)
        {
            if(intCnt[i] > 0)
            {
                minNumOfRewrite+=intCnt[i];
                diffInt--;

                if(diffInt==k) break;
            }
        }

        cout << minNumOfRewrite << endl;
    }



    return 0;
}

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

int main(void) {
	int N;
	string S;
	cin >> N >> S;

	int ans = 0;
	int p = 0;
	while (p <= N - 3) {
		if (S[p] == 'A' && S[p + 1] == 'B' && S[p + 2] == 'C') {
			++ans;
			p += 3;
		}
		else
			++p;
	}

	cout << ans << '\n';
	return 0;
}


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

using namespace std;

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

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

class RollingHash {
    static const ll base1 = 1009;
    static const ll base2 = 2009;
    static const ll mod1 = 1000000007;
    static const ll mod2 = 1000000009;
    vector<ll> hash1, hash2, pow1, pow2;

public:
    RollingHash(const string &S) {
        int n = (int) S.size();
        hash1.assign(n + 1, 0);
        hash2.assign(n + 1, 0);
        pow1.assign(n + 1, 1);
        pow2.assign(n + 1, 1);
        for (int i = 0; i < n; ++i) {
            hash1[i + 1] = (hash1[i] * base1 + S[i]) % mod1;
            hash2[i + 1] = (hash2[i] * base2 + S[i]) % mod2;
            pow1[i + 1] = (pow1[i] * base1) % mod1;
            pow2[i + 1] = (pow2[i] * base2) % mod2;
        }
    }

    /**
     * S の [l, r) のハッシュ値を返す
     * O(1)
     */
    inline pair<ll, ll> get(int l, int r) const {
        ll res1 = hash1[r] - hash1[l] * pow1[r - l] % mod1;
        if (res1 < 0) res1 += mod1;
        ll res2 = hash2[r] - hash2[l] * pow2[r - l] % mod2;
        if (res2 < 0) res2 += mod2;
        return make_pair(res1, res2);
    }

    /**
     * S のハッシュ値を返す
     * O(1)
     */
    inline pair<ll, ll> hash() const {
        return get(0, (int) hash1.size() - 1);
    }

    /**
     * LCP (Longest Common Prefix)
     */
    inline int getLCP(int a, int b) const {
        int len = min((int) hash1.size() - a, (int) hash1.size() - b);
        int low = 0, high = len;
        while (high - low > 1) {
            int mid = (low + high) >> 1;
            if (get(a, a + mid) != get(b, b + mid)) high = mid;
            else low = mid;
        }
        return low;
    }

    /**
     * hash h1 と 長さ h2_lenの 文字列のhash h2 を結合
     */
    pair<ll, ll> concat(pair<ll, ll> h1, pair<ll, ll> h2, int h2_len) {
        return make_pair((h1.first * pow1[h2_len] + h2.first) % mod1, (h1.second * pow2[h2_len] + h2.second) % mod2);
    }
};

void Main() {
    int N;
    string S;
    cin >> N >> S;
    RollingHash rollingHash(S);
    ll ans = 0;
    rep(i, N) {
        rep2(j, i + 1, N) {
            ll lcp = rollingHash.getLCP(i, j);
            lcp = min(lcp, j - i);
            ans = max(ans, lcp);
        }
    }
    cout << ans << '\n';
}

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


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

int main() {
  int n; cin >> n;
  vector<int> a1(n), a2(n);
  int c1 = 0, c2 = 0, ans = 0;
  rep(i,n) {cin >> a1[i]; }
  rep(i,n) {cin >> a2[i]; c2 += a2[i]; }
  ans = 0;
  rep(i,n) {
    c1 += a1[i];
    if (i!=0) c2 -= a2[i-1];
    ans = max(ans, c1 + c2);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int64_t H, W;
  cin >> H >> W;
  int64_t x = H/3;
  int64_t ans = 1000000;
  
  if(H %3 == 0 || W %3 == 0){
    ans = 0;
  }
  else{
    ans = min(H,W);
  }
  
  vector<int64_t> vec(3);
  for(int i=0; i<=3; i++){
    vec.at(0) = (x+i)*W;
    vec.at(1) = (H-x-i)*(W/2);
    vec.at(2) = H*W - vec.at(1) - vec.at(0);
    sort(vec.begin(),vec.end());
    ans = min(ans,vec.at(2)- vec.at(0));
  }
  swap(H,W);
  x = H/3;
  for(int i=0; i<=3; i++){
    vec.at(0) = (x+i)*W;
    vec.at(1) = (H-x-i)*(W/2);
    vec.at(2) = H*W - vec.at(1) - vec.at(0);
    sort(vec.begin(),vec.end());
    ans = min(ans,vec.at(2)- vec.at(0));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 3e6 + 17;
const int MOD = 1e9 + 7;
int fac[N], invfac[N];
int binpow(int a, int n) {
    if (n == 0) return 1;
    else {
        if (n % 2 == 0) {
            int k = binpow(a, n / 2) % MOD;
            return k * k % MOD;
        } else {
            int k = binpow(a, n - 1) % MOD;
            return k * a % MOD;
        }
    }
}
int C(int n, int k) {
    if (n - k < 0) return 0;
    return (fac[n] % MOD * invfac[k] % MOD * invfac[n - k] % MOD) % MOD;
}
signed main() {
        fac[0] = invfac[0] = 1;
        for (int i = 1; i < N; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            invfac[i] = binpow(fac[i], MOD - 2);
        }
 	int K;
	string S;
	cin >> K >> S;
	int n = S.size();
	int ans = 0;
	for (int i = n; i <= n + K; ++i) {
		ans = (ans + (C(n + K, i) * binpow(25, n + K - i)) % MOD) % MOD;	
	}
	cout << ans;
}

Measured memory_bytes: 52136
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

const int MOD = 1000000007;

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

    ll H, W;
    cin >> H >> W;
    vector<vector<char>> a(H, vector<char>(W));
    Rep (i, H) {
        Rep (j, W) {
            cin >> a[i][j];
        }
    }

    vector<vector<ll>> dp(H, vector<ll>(W, 0));
    dp[0][0] = 1;
    Rep (i, H) {
        Rep (j, W) {
            if (i > 0 && j > 0) dp[i][j] = dp[i-1][j] + dp[i][j-1];
            else if (i > 0) dp[i][j] = dp[i-1][j];
            else if (j > 0) dp[i][j] = dp[i][j-1];
        
            if (a[i][j] == '#') dp[i][j] = 0;
            dp[i][j] %= MOD;
        }
    }

    // Rep (i, H) {
    //     Rep (j, W) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << "\n";
    // }

    cout << dp[H-1][W-1] << "\n";


}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/gcd(m,n))
#define fast std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pi acos(-1.0)
#define endl '\n'
#define MOD 1000000007
#define ull unsigned long long
#define ll long long
#define ld long double
#define pb push_back
#define dbg(x) cout << #x << "  " << x << endl;

ll power(ll base, ll exp) 
{ll res=1;while(exp>0) {if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return res;}
ll mod(ll a, ll b) {return (a % b + b) % b;}
using namespace std;

int main() 
{
	fast;
	ll n,m; cin>>n>>m;
	vector<ll>x(n),y(m);
    for(ll i = 0; i < n; i++) cin>>x[i];
    for(ll i = 0; i < m; i++)  cin>>y[i];
    ll a[n], b[m];
  	for (ll i = 1; i < n; i++) 
	{
    	a[i] = i * (n - i) % MOD;
  	}
  	for (ll j = 1; j < m; j++) 
	{
    	b[j] = j * (m  - j) % MOD;
  	}
	ll ansy = 0;
	for (ll j = 1; j < m; j++) 
	{
	    ansy += b[j] * (y[j] - y[j - 1]);
	    ansy %= MOD;
	}
	ll ansx = 0;
	for (ll i = 1; i < n; i++) 
	{
	    ansx += a[i] * (x[i] - x[i - 1]) % MOD;
	    ansx %= MOD;
	}
	ansx *= ansy % MOD;
	cout << ansx % MOD << endl;
  	return 0; 
}

Measured memory_bytes: 3328
#include<stdio.h>
#include<string.h>
#include<math.h>
#include <stdlib.h>
long n,m,b,x,y;
long a=0;
int main(){
scanf("%ld",&n);
while(1){
b=n%10;
a+=b;
n/=10;
if(n==0)break;
}
if(a==1){printf("10");}
else{printf("%ld",a);}
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

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

    ll N, A, B;
    cin >> N >> A >> B;
    ll ans = (N / (A + B)) * A + min(A, N % (A + B));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nums = scanner.next().split("");
        for (int i = 0; i < 8; i++) {
            String bin = Integer.toString(i, 2);
            if (getSum(bin, nums))break;
        }
    }

    private static boolean getSum(String bin, String[] nums){
        if (bin.length() == 1) bin = "00"+bin;
        else if (bin.length() == 2) bin = "0"+bin;
        int sum = Integer.parseInt(nums[0]);
        StringBuilder ans = new StringBuilder(nums[0]);
        for (int i = 0; i < bin.length(); i++) {
            if (bin.charAt(i) == '0'){
                sum += Integer.parseInt(nums[i + 1]);
                ans.append("+").append(nums[i + 1]);
            }
            else{
                ans.append("-").append(nums[i + 1]);
                sum -= Integer.parseInt(nums[i + 1]);
            }
        }

        if (sum == 7) {
            ans.append("=7");
            System.out.println(ans);
        }
        return sum == 7;
    }
}


Measured memory_bytes: 23508
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::equal;
using std::min;

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

  int num;
  vector<int> nums;
  for(int i = 0; i < N; i++) {
    cin >> num;
    nums.push_back(num);
  }
  if(equal(nums.begin() + 1, nums.end(), nums.begin())) {
    cout << 0 << endl;
    return 0;
  }

  long long lowest_cost = 0x7ff0000000000000;
  for(int i = -100; i <= 100; i++) {
    long long cost = 0;
    for(int k = 0; k < N; k ++) {
      cost += (nums[k] - i) * (nums[k] - i);
    }
    lowest_cost = min(lowest_cost, cost);
  }

  cout << lowest_cost << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <utility>
#include <algorithm>
#define llint long long
#define inf 1000000000000LL

using namespace std;
typedef pair<string, llint> P;

llint n;
string s[10005];
string t;
vector<P> vec;

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

  cin >> n;
  for(int i = 1; i <= n; i++) cin >> s[i];
  cin >> t;

  llint l;
  for(int i = 1; i <= n; i++){
    string S = s[i];
    for(int i = 0; i < S.size(); i++){
      if(S[i] == '?') S[i] = 'z';
    }
    vec.push_back(P(S, i));
  }
  string T = t;
  for(int i = 0; i < t.size(); i++){
    if(T[i] == '?') T[i] = 'a';
  }
  vec.push_back(P(T, 0));
  sort(vec.begin(), vec.end());

  for(int i = 0; i < vec.size(); i++){
    if(vec[i].second == 0){
      l = i+1;
      break;
    }
  }
  vec.clear();

  llint r;
  for(int i = 1; i <= n; i++){
    string S = s[i];
    for(int i = 0; i < S.size(); i++){
      if(S[i] == '?') S[i] = 'a';
    }
    vec.push_back(P(S, i));
  }
  T = t;
  for(int i = 0; i < t.size(); i++){
    if(T[i] == '?') T[i] = 'z';
  }
  vec.push_back(P(T, inf));
  sort(vec.begin(), vec.end());

  for(int i = 0; i < vec.size(); i++){
    if(vec[i].second == inf){
      r = i+1;
      break;
    }
  }

  for(int i = l; i <= r; i++){
    cout << i;
    if(i < r) cout << " ";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}


int main() {
  ll n;
  cin >> n;
  vector<ll> a(n-1);
  vector<ll> b(n-1);

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

  vector<vector<ll>> nodemap(n,vector<ll>());

  for(int i=0;i<n-1;i++){
    nodemap[a[i]].push_back(b[i]);
    nodemap[b[i]].push_back(a[i]);
  }


  vector<ll> mp(n,-1);//フェネックなら0 sunukeなら1

  bool isFennecWin = false;//fenecは黒

  ll turn = 0;//2 で割れるときフェネック

  vector<ll> fstack;
  vector<ll> sstack;
  fstack.push_back(0);
  sstack.push_back(n-1);

  mp[0] = 0;
  mp[n-1] = 1;
  ll fcount = 1;
  ll scount = 1;

  while(!(fstack.size() ==0 && sstack.size() ==0)){
    vector<ll> tmp;
    if (turn%2==0){//フェネック
      for(auto v:fstack){
        for(auto p:nodemap[v]){
          if (mp[p] == -1){
            tmp.push_back(p);
            mp[p] = turn%2;
            fcount++;
          }
        }
      }
      fstack = tmp;
    }else{
      for(auto v:sstack){
        for(auto p:nodemap[v]){
          if (mp[p] == -1){
            tmp.push_back(p);
            mp[p] = turn%2;
            scount++;
          }
        }
      }
      sstack = tmp;
    }
    turn++;
  }


  isFennecWin = fcount > scount;





  cout << (isFennecWin?"Fennec":"Snuke") <<endl;




}




















Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/

ll get(ll n,ll d){//未満
	//puta("call",n,d);
	if(n<(1ll<<d)) return 0;
	if(d==0) return (n+1)/2;
	ll ret=0;
	if(n%2==0){
		ret+=(!!(n&(1ll<<d)));
		n--;
	}
	ret+=2ll*get(n/2,d-1);
	//puta("ret",n,d,ret);
	return ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a,b;
	cin>>a>>b;
	if(a==0)a=1;
	if(a==b){
		puta(a);
		return 0;
	}
	
	ll ans=0;
	rep(i,40){
		//puta(i,get(a,i));
		//puta(i,get(b,i));
		if((get(b,i)-get(a-1,i))%2==1)ans|=(1ll<<i);
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#include<cstdio>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<string>
#include<iostream>
#include<map>
#include<set>
#include<queue>
#include<set>
#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)
#define INF9                1000000010
#define INF18               1000000000000000010
#define dist(ax,ay,bx,by)   sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by))
#define gcd(a,b)            __gcd(a,b)
#define lcm(a,b)            (a*b)/__gcd(a,b)
#define m_p(a,b)            make_pair(a,b)
#define sqr(a)              ((a)*(a))
#define pb                  push_back
#define bpll(a)             __builtin_popcountll(a)
#define MX                  1000006
#define PI                  acos(-1)
#define mod                  1000000007
#define cnt_bin(n)          __builtin_clzll(0ll) - __builtin_clzll(n)

typedef long long lli;
using namespace std;

string str;

int main()
{
    cin>>str;

    lli sum=0;

    for(lli i=0; i<str.size(); i++)
    {
        sum+= (str[i]-'0');
    }

    if(sum%9) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 3716
R=range
K=4000
S=[input()for i in R(3)]
A,B,C=S
a,b,c=[len(i)for i in S]
def F(S,T):
 Q=[1]*(K*2+1)
 for i in R(-len(T),len(S)):
  for j in R(max(i,0),min(len(S),len(T)+i)):
   if len(set([S[j],T[j-i],'?']))>2:Q[i]=0
 return Q
S=F(A,B)
T=F(A,C)
U=F(B,C)
m=K*3
for p in R(-K,K+1):
 if S[p]!=0:
  for q in R(-K,K+1):
   if T[q]!=0 and U[q-p]!=0:
    m=min(m,max(p+b,q+c,a)-min(p,q,0))
print(m)

Measured memory_bytes: 53704
#include<bits/stdc++.h>
					
					#define F first
					#define S second
					#define N 222222
					#define M 1000000007
					#define pb push_back
					#define cend(s) return cout << s, 0
					using namespace std;
					typedef long long ll;
					typedef vector<int> vi;
					
					int main()
					{
						int n, r = 0, w, r1 = 0, w1 = 0;
						string s, ss;
						cin >> n >> s;
						for(int i = 0; i < n; i++)
							r += (s[i] == 'R');
						w = n - r;
						if(!w || !r)	
							cend(0);		
						for(int i = 0; i < n; i++)
						{
							w1 += (s[i] == 'W');
							r1 += (s[i] == 'R');
							if(w1 == r-r1 || w1 == w)
								cend(w1);
						}
					}

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

int isprime[50101];

int main() {
  memset(isprime, 0, sizeof(isprime));
  for(int i=4; i<50101; i+=2) isprime[i] = 1;
  isprime[1] = 1;
  for(int i=3; i*i<50101; i+=2)
    if(isprime[i] == 0)
      for(int j=2; i*j<50101; ++j)
	isprime[i*j] = 1;

  int n;
  while(cin>>n) {
    for(int k=n-1; k>0; --k)
      if(isprime[k] == 0) {
	cout<<k<<" ";
	break;
      }

    for(int k=n+1; k<50101; ++k)
      if(isprime[k] == 0) {
	cout<<k<<endl;
	break;
      }
  }
}

Measured memory_bytes: 0
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int[] antena = new int[5];
        for (int i = 0; i < 5; i++) {
            antena[i] = scan.nextInt();
        }
        int k = scan.nextInt();
        boolean found = false;
        for (int i = 0 ; i < 5; i++) {
            for (int j = i + 1; j < 5; j++) {
                if (antena[j] - antena[i] > k) {
                    found = true;
                    break;
                }
            }
        }
        System.out.println(found ? ":(" : "Yay!");
    }
}


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

using namespace std;

#define sz(a) (int)a.size()
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define ll long long        
#define f first
#define s second 
#define y1 Emilia
#define N 500300
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int inf = (int)1e9;
const int mod = inf + 7;

ll n,x;
ll a[111];
int main(){dracarys
	#ifdef LOCAL
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif
	cin >> n >> x;
	for(int i = 0; i < n; ++i) cin >> a[i];
	sort(a, a + n);
	ll sum = 0, ans = 0;
	for(int i = 0; i < n; ++i){
		if(sum + a[i] > x) break;
		else{
			sum += a[i];
			++ans;
		}
	}
	if(ans == n && x > sum) --ans;
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
nkq = input().split(' ');
n = int(nkq[0]);
k = int(nkq[1]);
q = int(nkq[2]);
point = [0]*(n+1);
for i in range(q) :
	a = int(input());
	point[a] += 1;

for i in range(1,n+1) :
	if k - (q - point[i]) > 0 :
		print('Yes');
	else :
		print('No');

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

int main() {
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a,a+n);
  double ans=a[0];
  for(int i=1; i<n; i++) ans=(ans+a[i])/2;
  cout << ans << '\n';
  return 0; 
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include <math.h>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define pa pair<int,int>
#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

class Point{
	public:
	double x,y;
	Point(double x=0,double y=0):x(x),y(y) {}
	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
	Point operator * (double a) {return Point(x*a,y*a);}
	Point operator / (double a) {return Point(x/a,y/a);}
	double absv() {return sqrt(norm());}
	double norm() {return x*x+y*y;}
	bool operator < (const Point &p) const{
		return x != p.x ? x<p.x: y<p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
	}
};
typedef Point Vector;

struct Segment{
Point p1,p2;
};


double dot(Vector a,Vector b){
	return a.x*b.x+a.y*b.y;
}
double cross(Vector a,Vector b){
	return a.x*b.y-a.y*b.x;
}

//----------------kokomade temple------------


int main(){
int n;
double a1,a2,a3,a4,a5,a6;
cin>>a1>>a2>>a3>>a4;
cin>>n;
Vector b,s;
Point p,q,w;
b.x=a3-a1,b.y=a4-a2;
b=b/b.absv();
p.x=a1,p.y=a2;

for(int i=0;i<n;i++){
cin>>a5>>a6;
w.x=a5,w.y=a6;
s=w-p;
double l=dot(s,b);
q=p+b*l;
Vector d=q-w;
Point r=w+d*2;
printf("%.10f %.10f\n",r.x,r.y);
}



return 0;
}

Measured memory_bytes: 1252
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	letters := make([]byte, 'z'-'a'+1)
	for sc.Scan() {
		S := strings.ToLower(sc.Text())
		for _, s := range S {
			if 'a' <= s && s <= 'z' {
				letters[s-'a']++
			}
		}
	}
	for i, num := range letters {
		fmt.Printf("%s : %d\n", string('a'+i), num)
	}
}



Measured memory_bytes: 1092
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int a; cin >> a;
    string s; cin >> s;

    if(a >= 3200){
        cout << s;
    }
    else{
        cout << "red";
    }

    return 0;
}

Measured memory_bytes: 256
import functools

@functools.lru_cache(maxsize = 30)
def f(n) :
      if(n == 1) :
        return 1
      elif(n == 2) :
        return 2
      elif(n == 3) :
        return 4
      else :
        return f(n - 1) + f(n - 2) + f(n - 3)
      
while True :
  n = int(input())
  if(n == 0) :
    break
  else :
    if(f(n) % 10 == 0) :
      x = f(n) // 10
    else :
      x = f(n) // 10 + 1
    
    if(x % 365 == 0) :
      s = x // 365
    else :
      s = x // 365 + 1
     
    print(s)


Measured memory_bytes: 6272
#include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+10;
long long a[MAXN],b[MAXN],c[MAXN];
long long l;
int n;
int main()
{
    scanf("%lld",&l);
    scanf("%d",&n);
    for (int i=1;i<=n;i++) {
        scanf("%lld",&a[i]);
    }
    for (int i=1;i<=n;i++) b[i]=b[i-1]+a[i];    
    for (int i=n;i>=1;i--) c[i]=c[i+1]+l-a[i];
    if (n==1) cout << max(a[1],l-a[1]) <<endl;
     else if (n==2) cout << max(a[1],l-a[2])+max(a[2]-a[1],l-(a[2]-a[1])) << endl;
     else {
        long long ans=a[n];
        for (int i=1;i<n;i++)
        if (i<n-i) ans=max(max(ans,b[i]*2+(c[i+1]-c[i*2+2])*2-(l-a[i+1])),b[i]*2+(c[i+1]-c[i*2+1])*2-a[i]);
        else if (i>n-i) ans=max(max(ans,(b[i]-b[i-n+i-1])*2+c[i+1]*2-(a[i])),(b[i]-b[i-n+i])*2+c[i+1]*2-(l-a[i+1]));
        else ans=max(ans,b[i]*2+c[i+1]*2-min(l-a[i+1],a[i]));
        cout << ans << endl;
     }
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef pair<l_l,ll> lll;
typedef vector<string> vs;
const ll dx[4]={1,-1,0,0};
const ll dy[4]={0,0,1,-1};
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll n,m;cin>>n>>m;
    vector<l_l> p(m);
    rep(i,m){
        ll a,b;cin>>a>>b;
        p[i]={b,a};
    }
    sort(p.begin(),p.end());
    ll s=0,e=0;
    ll ans=0;
    rep(i,m){
        if(e<=p[i].se&&s<p[i].se){
            s=p[i].fi-1;
            e=p[i].fi;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string s;
    cin >> s;
    if(s[0]-'A'>25) print("a");
    else print("A");

    return 0;
}

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

struct UnionFind{
    vector<int> d;
    UnionFind(int n): d(n, -1) {}
    int root(int x){
        if(d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y){return root(x) == root(y);}
    int size(int x) {return -d[root(x)];}
};

int deg[100005];
vector<int> to[100005];

int main(){
    int n , m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        deg[a]++;
        deg[b]++;
        uf.unite(a, b);
    }
    rep(i, k){
        int a, b;
        cin >> a >> b;
        --a;
        --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    rep(i, n){
        int ans = uf.size(i)  - 1 - deg[i];
        for (int u : to[i]){
            if (uf.same(i, u)) ans--;
        }
        printf("%d%c", ans, i==n-1?'\n':' ');
    }
    return 0;
}

Measured memory_bytes: 6784
#include <iostream>
//#include <iomanip>
#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n ; cin >> n ;
	set<string> s ;
	char c ;
	for(int i=0;i<n;i++){
		string t ; cin >> t ;
		if(s.count(t)){
			yorn(0) ;
			return 0 ;
		}else{
			s.insert(t) ;
		}
		if(i==0) c = t.at(t.size()-1) ;
		else{
			if(c!=t.at(0)){
				yorn(0) ;
				return 0 ;
			}else{
				c = t.at(t.size()-1) ;
			}
		}
	}
	yorn(1) ;
}



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

using namespace std;

int main(){
	int n;
	int ans = 0;
	cin >> n;

	for (int i = 0; i <= n; i++){
		int cnt = 0;
		if (i % 2 == 1){
			
			for (int j = 1; j <= i; j++){
			
				if (i%j == 0){
					cnt++;
				}

			}

			if (cnt == 8){
				ans++;
			}

		}

	}

	cout << ans << endl;

}

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

using namespace std;

ll n,k,a[100010],ans;

int main()
{
	scanf("%lld%lld",&n,&k);
	for(int i=1; i<=n; i++)scanf("%lld",&a[i]);
	ans=0x3f3f3f3f;
	for(int i=1; i+k-1<=n; i++)
	{
		ll l=a[i],r=a[i+k-1];
		if(l*r>0)ans=min(ans,max(abs(l),abs(r)));
		else ans=min(ans,r-l+min(abs(l),abs(r)));
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
n_list = [''] * n
ans = 0

for i in range(m):
    a, b = map(int, input().split())
    if h_list[b - 1] >= h_list[a - 1]:
        n_list[a - 1] = 'x'
    if h_list[a - 1] >= h_list[b - 1]:
        n_list[b - 1] = 'x'

for i in range(n):
    if n_list[i] == '':
        ans += 1

print(ans)


Measured memory_bytes: 20112
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define DB double
#define SG string
#define LL long long
#define Fp(A,B,C,D) for(A=B;A<=C;A+=D)
#define Fm(A,B,C,D) for(A=B;A>=C;A-=D)
#define Clear(A) memset(A,0,sizeof(A))
#define Copy(A,B) memcpy(A,B,sizeof(A))
using namespace std;
const LL Max=1e3+5;
const LL Mod=1e9+7;
const LL Inf=1e18;
LL N,Ans;
inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}
inline void Write(LL X){
	if(X<0)X=-X,putchar('-');
	if(X>9)Write(X/10);
	putchar(X%10+48);
}
void Solve(LL X){
	while(X%2==0){
		Ans++;
		X/=2;
	}
}
int main(){
	LL I,J,K;
	N=Read();
	Fp(I,1,N,1){
		K=Read();Solve(K);
	}Write(Ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>

using lli = long long int;
int inf = 1000000007;
using namespace std;
#define sort(X) sort(X.begin(),X.end())

int M, K;

int main()
{
	cin >> M >> K;
	int m = pow(2, M);
	if (K == 0) { for (int i = 0; i < m; i++)cout << i << " " << i << " "; }
	else if (K < m) {
		int x = 0;
		for (int i = 0; i < m; i++)
			x ^= (i == K ? 0 : i);
		if (x == K) {
			for (int i = 0; i < m; i++)
				if (i != K)cout << i << " ";
			cout << K << " ";
			for (int i = m - 1; i >= 0; i--)
				if (i != K)cout << i << " ";
			cout << K << " ";
		}
		else cout << -1;
	}
	else cout << -1;
	cout << endl;
	return 0;
}

Measured memory_bytes: 1792
n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

def point(x):
  if x == 'r':
    return(p)
  elif x == 's':
    return(r)
  else:
    return(s)

score = 0
for i in range(n):
  score += point(t[i])
  
for i in range(k):
  a = i
  b = 1
  while a+k < n:
    if t[a] == t[a+k]:
      b += 1
    else:
      score -= point(t[a])*(b//2)
      b = 1
    a += k
  else:
    score -= point(t[a])*(b//2)
print(score)

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

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

	string S;
	cin >> S;
	int n=S.length();
	sort(S.begin(), S.end());
	if (S[0] != 'a') {
		cout << "a";
		return 0;
	}
	for (int i = 0; i < n-1; i++) {
		if (S[i] + 1 < S[i + 1]) {
			cout << (char)(S[i] + 1);
			return 0;
		}
	}
	if (S[n - 1] < 'z')cout << (char)(S[n - 1] + 1);
	else cout << "None";
}


Measured memory_bytes: 512
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
const A_MAX = 100010;

$map = array_fill(0, A_MAX, 0);
for ($i = 0; $i < $n; ++$i) {
    ++$map[$A[$i]];
    ++$map[$A[$i] + 1];
    ++$map[$A[$i] - 1];
}


echo max($map);


Measured memory_bytes: 20980
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
vector<ll> ans[1000];
int main(){
    cin>>N;
	ll x;
	for(x=1;x*x<2*N;x++);
	if(x*(x-1)!=2*N){
		cout<<"No";
		return 0;
	}
	cout<<"Yes"<<endl;
	cout<<x<<endl;
	ll now=1;
	for(ll i=0;i<x;i++){
		for(ll j=i+1;j<x;j++){
			ans[i].push_back(now);
			ans[j].push_back(now);
			now++;
		}
	}
	for(ll i=0;i<x;i++){
		cout<<x-1<<" ";
		for(auto a:ans[i]){
			cout<<a<<" ";
		}cout<<endl;
	}

    return 0;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

int main(){
  int z, x, y;

  while(scanf("%d", &z) && z){
    z = pow((double)z, 3);
    int res = 0, tx, ty;
    for(x = 1; x < 2000; x++){
      for(y = 1; y < 2000; y++){
	tx = pow((double)x, 3); ty = pow((double)y, 3);
	if(tx + ty > z) break;
	res = max(res, tx+ty);
      }
    }
    printf("%d\n", z - res);
  }
  return 0;
}

Measured memory_bytes: 1188