akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> x(N), y(N);
  rep(i, N) cin >> x[i] >> y[i];
  ll ans = 4*1e18+1;
  rep(i, N) rep(j, N) rep(k, N) rep(l, N) {
    if(x[i] < x[j] && y[k] < y[l]) {
      int cnt = 0;
      rep(m, N) {
        if(x[m] >= x[i] && x[m] <= x[j] && y[m] >= y[k] && y[m] <= y[l])
          cnt++;
      }
      if(cnt == K)
        chmin(ans, (ll)(x[j]-x[i])*(y[l]-y[k]));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from random import choice,randint
inp=sys.stdin.readline
out=sys.stdout.write
flsh=sys.stdout.flush
 
sys.setrecursionlimit(10**9)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]
 
def MI(): return map(int, inp().strip().split())
def LI(): return list(map(int, inp().strip().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines().strip()]
def LI_(): return [int(x)-1 for x in inp().strip().split()]
def LF(): return [float(x) for x in inp().strip().split()]
def LS(): return inp().strip().split()
def I(): return int(inp().strip())
def F(): return float(inp().strip())
def S(): return inp().strip()
def pf(s): return out(s+'\n')
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)

def main():
    k = I()
    a,b=MI()
    for i in range(a,b+1):
        if i%k==0:
            print("OK")
            break
    else:
        print("NG")

if __name__ == "__main__":
    main()

Measured memory_bytes: 9584
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static int n;
	static int[] d;
	static int count = 0;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		d = new int[n];
		for (int i = 0; i < n; i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(d);
		System.out.println(d[n / 2] - d[n / 2 - 1]);
	}
}


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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    i64 N;
    cin >> N;
    vector<i64> A(N),B(N);
    rep(i,0,N) cin >> A[i];
    rep(i,0,N) cin >> B[i];

    i64 suma=0,sumb=0;
    rep(i,0,N) suma+=A[i];
    rep(i,0,N) sumb+=B[i];

    if(suma<sumb){
        cout << -1 << endl;
        return;
    }

    vector<i64> minus,plus;
    rep(i,0,N){
        if(A[i]<B[i]) minus.push_back(B[i]-A[i]);
        if(A[i]>B[i]) plus.push_back(A[i]-B[i]);
    }

    if(minus.size()==0){
        cout << 0 << endl;
        return;
    }

    sort(rbegin(plus),rend(plus));

    i64 ans=minus.size(),i=0,rem=0;
    rep(j,0,minus.size()){
        while(minus[j]>rem){
            rem+=plus[i];
            ++i;
            ++ans;
        }
        rem-=minus[j];
    }

    cout << ans << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 2812
#include <iostream>
#include <string>
#include <random>
using namespace std;
std::random_device rnd;
int main() {
    string S;
    cin >> S;

    int number = rnd() % (S.size() - 2);
    for (int i = number; i < number+3; i++) {
        cout << S.at(i);
    }
    cout << endl;
}



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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << end
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;

    ll k; cin >> k;
    queue<ll> BFS;
    for(int i=1;i<10;i++)BFS.push(i);
    while(!BFS.empty()){ // キューが空になるまで続ける
        ll t = BFS.front();
        BFS.pop();
        if(--k==0){
            cout << t << endl;
            return 0;
        }
        if(t%10!=0)BFS.push(t*10+(t%10)-1);
        BFS.push(t*10+t%10);
        if(t%10!=9)BFS.push(t*10+(t%10)+1);
    }
}


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

int main(){
    int n;
    int k;
    cin >> n >> k;
    char d[10];
    char f;
    for(int i=0;i<k;i++){
        cin >> f;
        d[f-'0']=1;
    }
    for(int i=n;i<1e7;i++){
        string str=to_string(i);
        int count=0;
        for(int j=0;j<str.size();j++){
            if(d[(str[j]-'0')]==1)goto E;
        }
        cout << i << endl;
        break;
        E:;
    }
}

Measured memory_bytes: 384
N, A, B = list(map(int, input().split()))
i = 0
b = 0
r = 0

c = N//(A+B)
#print(c)
d = N%(A+B)
#print(d)
if d <= A:
    b = c*A + d
else:
    b = (c+1)*A
print(b) 


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    string S, T; cin >> S >> T;
    vector<string> v;
    bool flg2 = false;

    rep(i, S.size() - T.size() + 1) {

        string tmp = S; 
        bool flg = true;

        rep(j, T.size()) {

            if (S[i+j] == T[j]) continue;
            if (S[i+j] == '?') continue;

            flg = false;
            break;
        }

        if (!flg) continue;
        flg2 = true;

        rep(k, S.size()) {

            if (S[k] != '?') tmp[k] = S[k];
            else if (k < i || i + T.size() <= k) tmp[k] = 'a';
            else tmp[k] = T[k-i]; 
            
        }

        v.push_back(tmp); 
        // cout << tmp << endl;
    }
    Sort(v);
    if (!flg2) cout << "UNRESTORABLE" << endl;
    else cout << v[0] << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,len,maxx=-1,lenn;
map<string,int> a;
string in,b[200010],out[200010];
int main()
{
	cin>>n;
	for(register int i=1;i<=n;i++)
	{
		cin>>in;
		if(!a[in])
			b[++len]=in;
		a[in]++;
	}
	for(register int i=1;i<=len;i++)
		maxx=max(a[b[i]],maxx);
	for(register int i=1;i<=len;i++)
		if(a[b[i]]==maxx)
			out[++lenn]=b[i];
	sort(out+1,out+1+lenn);
	for(register int i=1;i<=lenn;i++)
		cout<<out[i]<<endl;
	return 0;
}


Measured memory_bytes: 28288
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a=sc.next();
        String b=sc.next();
        int count=0;
        for (int i=0;i<a.length();i++){
            if (a.charAt(i)!=b.charAt(i)){
               count++;
            }
        }
        System.out.println(count);

    }
}

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

int main(){
    int N;
    cin >> N;
    string S;
    set<string> keihin;
    for (int i = 0; i < N; ++i){
        cin >> S;
        keihin.insert(S);
    }
    cout << keihin.size() << endl;
}

Measured memory_bytes: 19252
fun main(args:Array<String>):Unit {
    var n = readLine()!!.toInt()
    while (n != 0){
        val stage = Array(21){Array(21){false}}
        val robot = Robot()
        repeat(n){
            val (x, y) = readLine()!!.split(' ').map(String::toInt)
            stage[x][y] = true
        }
        repeat(readLine()!!.toInt()){
            val (dir, len) = readLine()!!.split(' ')
            val prev = robot.position
            when(dir){
                "N" -> robot.moveNorth(len.toInt())
                "S" -> robot.moveSouth(len.toInt())
                "E" -> robot.moveEast(len.toInt())
                else -> robot.moveWest(len.toInt())
            }
            val current = robot.position
            for (x in prev.x .. current.x) for (y in prev.y .. current.y) stage[x][y] = false
            for (x in current.x .. prev.x) for (y in current.y .. prev.y) stage[x][y] = false
        }
        println(if (stage.any{it.any{it}}) "No" else "Yes")
        n = readLine()!!.toInt()
    }
}
data class Point(val x:Int, val y:Int){
    operator fun plus(other:Point):Point = Point(x + other.x, y + other.y)
}
class Robot{
    private var mPoint:Point = Point(10, 10)
    val position:Point
        get() = mPoint
    fun moveNorth(length:Int):Unit {
        mPoint += Point(0, length)
    }
    fun moveSouth(length:Int):Unit {
        mPoint += Point(0, -length)
    }
    fun moveEast(length:Int):Unit {
        mPoint += Point(length, 0)
    }
    fun moveWest(length:Int):Unit {
        mPoint += Point(-length, 0)
    }
}


Measured memory_bytes: 40368
fn main() {
    proconio::input! {
        n: usize,
        bs: [i64; n - 1],
    }
    let mut a_s = vec![0; n];
    a_s[0] = bs[0];
    for i in 0..n - 1 {
        a_s[i + 1] = bs[i];
        if a_s[i] > bs[i] {
            a_s[i] = bs[i];
        }
    }
    let ans = a_s.iter().sum::<i64>();
    println!("{}", ans);
}


Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;
#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
#define INF (1<<29)

int main(){
  int n, k;
  cin >> n >> k;
  if(n%k==0)cout << "0" << endl;
  else cout << "1" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    string s;
    cin >> s;
    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';
    if(a + b + c + d == 7){
        cout << s[0] << "+" << s[1] << "+" << s[2] << "+" << s[3];
    } else if(a + b + c - d == 7){
        cout << s[0] << "+" << s[1] << "+" << s[2] << "-" << s[3];
    } else if(a + b - c + d == 7){
        cout << s[0] << "+" << s[1] << "-" << s[2] << "+" << s[3];
    } else if(a + b - c - d == 7){
        cout << s[0] << "+" << s[1] << "-" << s[2] << "-" << s[3];
    } else if(a - b + c + d == 7){
        cout << s[0] << "-" << s[1] << "+" << s[2] << "+" << s[3];
    } else if(a - b + c - d == 7){
        cout << s[0] << "-" << s[1] << "+" << s[2] << "-" << s[3];
    } else if(a - b - c + d == 7){
        cout << s[0] << "-" << s[1] << "-" << s[2] << "+" << s[3];
    } else if(a - b - c - d == 7){
        cout << s[0] << "-" << s[1] << "-" << s[2] << "-" << s[3];
    }
    cout << "=7" << endl;
    return 0;
}


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

s = str(input())
t = str(input())

counter = 0

counter = counter + 1 if s[0] == t[0] else counter
counter = counter + 1 if s[1] == t[1] else counter
counter = counter + 1 if s[2] == t[2] else counter

print(counter)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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 int INF = 100000; 

int main(){
    ll x, t;
    cin >> x >> t;

    if(x - t > 0){
        cout << x - t << endl;
    }else{
        cout << 0 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
int r, c, i, num, row_sum, col_sum[100];
int main() {
    scanf("%d %d", &r, &c);
    for (; r; r--) {
        row_sum = 0;
        for (i = 0; i < c; i++) {
            scanf("%d", &num);
            row_sum += num;
            col_sum[i] += num;
            printf("%d ", num);
        }
        printf("%d\n", row_sum);
    }
    row_sum = 0;
    for (i = 0; i < c; i++) {
        row_sum += col_sum[i];
        printf("%d ", col_sum[i]);
    }
    printf("%d\n", row_sum);
}


Measured memory_bytes: 2044
#include <stdio.h>
#include <string.h>
 
#define MAX 244140625
 
int Hash[MAX];
char s[13];
 
int getChar(char);
int getKey();
int find();
void insert();
 
int main(){
  int n;
  char com[7];
 
  scanf("%d" ,&n);
  while(n--){
    scanf("%s %s" ,com ,s);
 
    if(com[0] == 'i'){
      insert();
    }else{
      if(find()){
        puts("yes");
      }else{
        puts("no");
      }
    }
  }
 
  return 0;
}
 
int getChar(char ch){
  if(ch == 'A'){
    return 1;
  }else if(ch == 'C'){
    return 2;
  }else if(ch == 'G'){
    return 3;
  }
  return 4;
}
 
int getKey(){
  int sum = 0, p = 1, i;
 
  for(i = 0 ; i < strlen(s) ; i++){
    sum += p*(getChar(s[i]));
    p *= 5;
  }
  return sum;
}
 
int find(){
  return Hash[getKey()];
}
 
void insert(){
  Hash[getKey()] = 1;
}

Measured memory_bytes: 39036
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    ll n;
    cin >> n;
    ll sum = 0;
    rep(i,n){
        ll a;
        cin >> a;
        sum += a;
    }
    if(!(sum%2))cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

constexpr intmax_t MOD = 1e9+7;

int main() {
  size_t N;
  char buf[131072];
  scanf("%zu %s", &N, buf);
  std::string S = buf;

  std::vector<intmax_t> fr(26);
  for (char c: S)
    ++fr[c-'a'];

  intmax_t res = 1;
  for (auto jd: fr)
    (res *= jd+1) %= MOD;

  (res += MOD-1) %= MOD;
  printf("%jd\n", res);
}


Measured memory_bytes: 1016
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x = x2 - x1;
  int y = y2 - y1;
  cout << x2 - y << ' ' << y2 + x << ' ' << x1 - y << ' ' << y1 + x;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>

template <typename Tp>
class range {
public:
  using value_type = Tp;
  using difference_type = typename std::make_signed<value_type>::type;

private:
  value_type M_start = 0;
  value_type M_stop;
  difference_type M_stride = 1;
  bool M_fail = false;

public:
  range(value_type stop): M_stop(stop) {}
  range(value_type start, value_type stop, difference_type stride = 1):
    M_start(start), M_stop(stop), M_stride(stride)
  {}

  class iterator {
  public:
    using value_type = Tp;
    using difference_type = typename std::make_signed<value_type>::type;

  private:
    value_type M_start, M_stop;
    difference_type M_stride;
    value_type M_index;
    bool M_fail = false;
    static constexpr value_type S_min = std::numeric_limits<value_type>::min();
    static constexpr value_type S_max = std::numeric_limits<value_type>::max();

  public:
    iterator(value_type start, value_type stop, difference_type stride,
             value_type index):
      M_start(start), M_stop(stop), M_stride(stride), M_index(index)
    {}
    value_type operator *() const { return M_index; }
    iterator& operator ++() {
      if ((0 < M_stride && __builtin_add_overflow(M_index, M_stride, &M_index))
          || (M_stride < 0 && __builtin_sub_overflow(M_index, -M_stride, &M_index)))
        M_fail = true;
      return *this;
    }
    bool operator !=(iterator const& other) const {
      if (M_fail || other.M_fail) return false;

      if (0 < M_stride && M_stop == S_min) return !M_fail;
      if (M_stride < 0 && M_stop == S_max) return !M_fail;
      return ((0 < M_stride && M_index < M_stop)
              || (M_stride < 0 && M_stop < M_index));
    }
  };

  iterator begin() const { return iterator(M_start, M_stop, M_stride, M_start); }
  iterator end() const { return iterator(M_start, M_stop, M_stride, M_stop); }
};

int main() {
  size_t X, Y, Z, K;
  scanf("%zu %zu %zu %zu", &X, &Y, &Z, &K);

  std::vector<intmax_t> A(X), B(Y), C(Z);
  for (auto& ai: A) scanf("%jd", &ai);
  for (auto& bi: B) scanf("%jd", &bi);
  for (auto& ci: C) scanf("%jd", &ci);

  std::vector<intmax_t> AB;
  AB.reserve(X*Y);
  for (auto i: range<size_t>(X))
    for (auto j: range<size_t>(Y))
      AB.push_back(A[i]+B[j]);

  std::sort(AB.rbegin(), AB.rend());
  if (AB.size() > K) AB.resize(K);

  std::vector<intmax_t> res;
  res.reserve(AB.size()*Z);
  for (auto i: range<size_t>(AB.size()))
    for (auto j: range<size_t>(Z))
      res.push_back(AB[i]+C[j]);

  std::sort(res.rbegin(), res.rend());
  for (auto i: range<size_t>(K))
    printf("%jd\n", res[i]);
}


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

int main() {
  char x;
  cin >> x;
  if (x == 'a' || x == 'i' || x == 'u' || x == 'e' || x == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
from __future__ import print_function

import sys
input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


# import re
# import array
# import copy
# import functools
# import operator

# import math
# import string
import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
# import itertools
# import bisect

# import heapq
# from heapq import heappush
# from heapq import heappop
# from heapq import heappushpop
# from heapq import heapify
# from heapq import heapreplace
# from queue import PriorityQueue as pq
from queue import Queue

# from itertools import accumulate

# from collections import deque
# from collections import Counter

from operator import mul
from functools import reduce


# def lcm(n,m):
#     return int(n*m/gcd(n,m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

# import random
# import time

h,a = map(int, input().strip().split())
print(-(-h//a))


Measured memory_bytes: 66156
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)
#define int long long

using namespace std;
typedef pair<int, int> pii;

int n,k,h[100000]={0};
int dp[100000]={0};

signed main() {
	cin>>n>>k;
    rep(i,n){
        cin>>h[i];
    }

    rep(i,n){
        dp[i]=1e+9;
    }
    dp[0]=0;
    rep(i,n){
        rep(j,k){
            if(i-j-1>=0){
                dp[i]=min(dp[i],dp[i-j-1]+abs(h[i]-h[i-j-1]));
            }
        }
    }
	
    cout<<dp[n-1]<<endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
const ll p=1e9+7;
ll a[200005];
ll f[200005],s[200005];
int main()
{
	ll n;
	cin>>n;
	
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(i%2==1)
		s[i]=s[i-1]+a[i];
		else
		s[i]=s[i-1];
	}
	for(int i=2;i<=n;i++)
	{
		if(i%2==1)
		{
			f[i]=max(f[i-2]+a[i],f[i-1]);
		}
		else
		f[i]=max(f[i-2]+a[i],s[i-1]);
	}
	cout<<f[n]<<endl;
}

Measured memory_bytes: 8248
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: u64 = itr.next().unwrap().parse().unwrap();
    let k: u64 = itr.next().unwrap().parse().unwrap();
    let a: Vec<u64> = (0..n)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    let mut bit: Vec<u64> = vec![0; 44];
    for i in a.iter() {
        for j in 0..41 {
            bit[j] += i >> j & 1;
        }
    }

    let mut ans: u64 = 0;
    for i in (0..41).rev() {
        if k >> i & 1 == 0 {
            continue;
        }

        let mut tmp: u64 = 0;
        for j in (0..41).rev() {
            let mul = 1u64 << j;
            if j > i {
                if k >> j & 1 == 1 {
                    tmp += (n - bit[j]) * mul;
                } else {
                    tmp += bit[j] * mul;
                }
            } else if j == i {
                tmp += bit[j] * mul;
            } else {
                tmp += max(bit[j], n - bit[j]) * mul;
            }
        }
        ans = max(ans, tmp);
    }

    let mut tmp: u64 = 0;
    for i in 0..n {
        tmp += k ^ a[i as usize];
    }
    println!("{}", max(ans, tmp));
}


Measured memory_bytes: 6396
//E
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(), v.end()

using namespace std;
typedef long long LL;
int frekx[300001], freky[300001], Segtree1[8000001], Segtree2[8000001];
vector<int> v[300001], v2[300001];

void build(int p, int L, int R) {
	if (L == R) {
		Segtree1[p] = frekx[L];
		Segtree2[p] = freky[L];
		return;
	}
	int mid = (L + R) >> 1;
	build(p << 1, L, mid);
	build(p << 1 | 1, mid + 1, R);
	Segtree1[p] = max(Segtree1[p << 1], Segtree1[p << 1 | 1]);
	Segtree2[p] = max(Segtree2[p << 1], Segtree2[p << 1 | 1]);
}

void update1(int p, int L, int R, int idx, int val) {
	if (L == R) {
		Segtree1[p] += val;
		return;
	}
	int mid = (L + R) >> 1;
	if (idx <= mid) {
		update1(p << 1, L, mid, idx, val);
	} else {
		update1(p << 1 | 1, mid + 1, R, idx, val);
	}
	Segtree1[p] = max(Segtree1[p << 1], Segtree1[p << 1 | 1]);
}

void update2(int p, int L, int R, int idx, int val) {
	if (L == R) {
		Segtree2[p] += val;
		return;
	}
	int mid = (L + R) >> 1;
	if (idx <= mid) {
		update2(p << 1, L, mid, idx, val);
	} else {
		update2(p << 1 | 1, mid + 1, R, idx, val);
	}
	Segtree2[p] = max(Segtree2[p << 1], Segtree2[p << 1 | 1]);
}

int main(){
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int H, W, M;
	scanf("%d%d%d", &H, &W, &M);
	int a[M + 1], b[M + 1];
	for (int i = 0; i < M; i++) {
		scanf("%d%d", &a[i], &b[i]);
		frekx[a[i]]++;
		freky[b[i]]++;
		v[a[i]].pb(b[i]);
		v2[b[i]].pb(a[i]);
	}
	build(1, 1, 3e5);
	int ans = 0;
	for (int i = 1; i <= 3e5; i++) {
		int cnt = frekx[i];
		for (auto j : v[i]) {
			update2(1, 1, 3e5, j, -1);
		}
		cnt += Segtree2[1];
		for (auto j : v[i]) {
			update2(1, 1, 3e5, j, 1);
		}
		ans = max(ans, cnt);
		cnt = freky[i];
		for (auto j : v2[i]) {
			update1(1, 1, 3e5, j, -1);
		}
		cnt += Segtree1[1];
		for (auto j : v2[i]) {
			update1(1, 1, 3e5, j, 1);
		}
		ans = max(ans, cnt);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 49496
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm
#include <algorithm>
#include <cmath>
#include <numeric>

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

int main() {
    Int n;
    std::cin >> n;
    Vector<Int> a(n);
    for (auto& x : a) std::cin >> x;
    a.insert(a.begin(), 0);

    Vector<Int> psum(n + 1, 0);
    for (Int i = 1; i <= n; ++i) {
        psum[i] = psum[i - 1] + (i % 2 ? 1 : -1) * a[i];
    }

    for (Int i = 1; i <= n; ++i) {
        Int sum = psum[i - 1] - (psum[n] - psum[i]);
        if (i % 2) sum *= -1;
        std::cout << sum + a[i] << " ";
    }
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 2928
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = [0] * N
    for i in range(N):
        if i % 2 == 0:
            B[0] += A[i]
        else:
            B[0] -= A[i]
    for i in range(1,N):
        B[i] = 2 * A[i-1] - B[i-1]

    print(*B)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 64484
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S, T;
  cin >> S >> T;
  int slen = S.length();
  int tlen = T.length();
  int SA[slen+1], SB[slen+1];
  int TA[tlen+1], TB[tlen+1];
  SA[0] = SB[0] = 0;
  TA[0] = TB[0] = 0;
  FOR(i,0,slen) SA[i+1] = SA[i] + (S[i] == 'A');
  FOR(i,0,slen) SB[i+1] = SB[i] + (S[i] == 'B');
  FOR(i,0,tlen) TA[i+1] = TA[i] + (T[i] == 'A');
  FOR(i,0,tlen) TB[i+1] = TB[i] + (T[i] == 'B');
  int q; cin >> q;
  FOR(i,0,q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int sa = (SA[b] - SA[a-1]) % 3; // Aの数
    int sb = (SB[b] - SB[a-1]) % 3; // Bの数
    int ta = (TA[d] - TA[c-1]) % 3; // Aの数
    int tb = (TB[d] - TB[c-1]) % 3; // Bの数
    int check_a, check_b;
    if(sa == sb) check_a = 0;
    if(sa == 2 && sb == 1) check_a = 1;
    if(sa == 0 && sb == 2) check_a = 1;
    if(sa == 1 && sb == 0) check_a = 1;
    if(sa == 1 && sb == 2) check_a = 2;
    if(sa == 2 && sb == 0) check_a = 2;
    if(sa == 0 && sb == 1) check_a = 2;
    if(ta == tb) check_b = 0;
    if(ta == 2 && tb == 1) check_b = 1;
    if(ta == 0 && tb == 2) check_b = 1;
    if(ta == 1 && tb == 0) check_b = 1;
    if(ta == 1 && tb == 2) check_b = 2;
    if(ta == 2 && tb == 0) check_b = 2;
    if(ta == 0 && tb == 1) check_b = 2;
    cout << (check_a == check_b ? "YES" : "NO") << endl;
  }
}

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

struct edge
{
	int x,y;
}e[100001];

int fa[100001];

int findfa(int x)
{
	if(x!=fa[x]) fa[x]=findfa(fa[x]);
	return fa[x];
}

int main()
{
	int n,m,i,a;
	int f1,f2;
	cin>>n>>m;
	
	for(i=1;i<=n;i++)
		fa[i]=i;
	
	for(i=1;i<=m;i++)
	{
		cin>>e[i].x>>e[i].y>>a;
		f1=findfa(e[i].x);
		f2=findfa(e[i].y);
		if(f1!=f2) fa[f1]=f2;
	}
	
	int cnt=0;
	for(i=1;i<=n;i++)
    	if(fa[i]==i) cnt++;
    
	cout<<cnt;
	return 0;
}

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

struct a {
  long long int next;
  int flag;
  long long int from_start;
};

int main(void) {
  long long int n, k;
  scanf("%lld %lld", &n, &k);
  struct a a[n];
  for (long long int i = 0; i < n; i++) {
    scanf(" %lld", &a[i].next);
    a[i].flag = 0;
    a[i].from_start = 0;
  }

  long long int count = 0, pointer = 1;
  int break_flag = 0;
  for (long long int i = 0; i < k; i++) {
    a[pointer - 1].flag += 1;
    if (a[pointer - 1].flag == 2) {
      break_flag = 1;
      break;
    }
    a[pointer - 1].from_start = count;
    count++;
    pointer = a[pointer - 1].next;
  }

  if (!break_flag) printf("%lld\n", pointer);
  else {
    k -= a[pointer - 1].from_start;
    long long int hop = k % (count - a[pointer - 1].from_start);
    for (long long int i = 0; i < hop; i++) {
      pointer = a[pointer - 1].next;
    }
    printf("%lld\n", pointer);
  }

  return 0;
}


Measured memory_bytes: 6416
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define mt make_tuple
#define pb push_back
const int N = 1e5 + 10;
vector <int> graph[N],st;
int visited[N],dist[N];

void dfs(int ind){
    visited[ind] = 1;
    for(int i=0;i<graph[ind].size();i++){
        if(visited[graph[ind][i]]==0){
            dfs(graph[ind][i]);
        }
    }
    st.pb(ind);
    return ;
}
int main(){
    int n,m,u,v,maxDist=0;
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        cin>>u>>v;
        graph[u].pb(v); 
    }
    for(int i=1;i<=n;i++){
        if(visited[i]==0){
            dfs(i);
        }
        dist[i] = INT32_MIN;
    }
    for(int i=st.size()-1;i>=0;i--){
        if(dist[st[i]]==INT32_MIN)  dist[st[i]] = 0;
        for(int j=0;j<graph[st[i]].size();j++){
            if(dist[graph[st[i]][j]] < dist[st[i]] + 1) dist[graph[st[i]][j]] = dist[st[i]] + 1; 
        }
        maxDist = max(maxDist,dist[st[i]]);
    }
    cout<<maxDist<<endl;
    return 0;
}

Measured memory_bytes: 8440
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int main() {
  int a, b, c, d;
  scanf("%1d%1d%1d%1d", &a, &b, &c, &d);
  if (a == b || b == c || c == d) printf("Bad\n");
  else printf("Good\n");
  return 0;
}


Measured memory_bytes: 128
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);
    let a:u32 = sc.read();
    let b:u32 = sc.read();
    let formatted = format!("{:.*}", 5, a as f64 / b as f64);
    println!("{} {} {}", a/b , a%b, formatted);
}

use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;
 
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 5048
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;

int main() {
  int N, x;
  cin >> N >> x;
  if(x == 1 || x == 2 * N - 1) {
    puts("No");
  } else {
    puts("Yes");
    if(N == 2) {
      FOR(i,0,3) cout << i + 1 << endl;
    } else {
      int num[2*N-1], ind[2*N];
      FOR(i,0,2*N-1) {
        num[i] = i + 1;
        ind[i+1] = i;
      }
      if(x == 2) {
        swap(num[(2*N-1)/2-1],num[ind[3]]);
        swap(ind[num[(2*N-1)/2-1]],ind[num[ind[3]]]);
        swap(num[(2*N-1)/2],num[ind[2]]);
        swap(ind[num[(2*N-1)/2]],ind[num[ind[2]]]);
        swap(num[(2*N-1)/2+1],num[ind[1]]);
        swap(ind[num[(2*N-1)/2+1]],ind[num[ind[1]]]);
        swap(num[(2*N-1)/2+2],num[ind[4]]);
      } else {
        swap(num[(2*N-1)/2-2],num[ind[x-1]]);
        swap(ind[num[(2*N-1)/2-2]],ind[num[ind[x-1]]]);
        swap(num[(2*N-1)/2-1],num[ind[x+1]]);
        swap(ind[num[(2*N-1)/2-1]],ind[num[ind[x+1]]]);
        swap(num[(2*N-1)/2],num[ind[x]]);
        swap(ind[num[(2*N-1)/2]],ind[num[ind[x]]]);
        swap(num[(2*N-1)/2+1],num[ind[x-2]]);
      }
      FOR(i,0,2*N-1) cout << num[i] << endl;
    }
  }
  return 0;
}

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

void show(vector<int> a){
  for(int i=0;i<a.size();i++){
    cout << a[i] << endl;
  }
  cout << endl;
}
int main(){
  while(1){
    int N,R;
    cin >> N >> R;
    if(N==0&&R==0)break;
    vector<int> a;
    for(int i=N;i>=1;i--){
      a.push_back(i);
    }
    for(int i=0;i<R;i++){
      int p,c;
      cin >> p >> c ;
      vector<int> b;
      for(int j=0;j<c;j++){
        b.push_back(a[p-1+j]);
      }
      a.erase(a.begin()+p-1,a.begin()+p-1+c);
      a.insert(a.begin(),b.begin(),b.end());
    }
    cout << a[0] << endl;
  }
}



Measured memory_bytes: 3116
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<=0&&b>=0){
    	cout<<"Zero"<<endl;
	}else{
		if(a>0||(b-a)%2==1)cout<<"Positive"<<endl;
		else cout<<"Negative"<<endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}
/**
* @fn
* 指定した値との差の絶対値が最小のvectorの番号を返します。
*/
long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

//ここまでライブラリ
//ここから本文

long long int tpabsmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b) && a.at(i) >= b) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


int main() {
	int n;
	char a = ' ';
	cin >> n;
	map<string, int> m;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (a != ' ' && a != s.at(0)) {
			cout << "No" << endl;
			return 0;
		}
		if (m.find(s) != m.end()) {
			cout << "No" << endl;
			return 0;
		}
		m.insert(make_pair(s, 1));
		a = s.at(s.size() - 1);
	}
	cout << "Yes" << endl;
	}



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

using namespace std;

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

  string a, b, c;
  cin >> a >> b >> c;
  if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> void amax(T &x, T y) { x = max(x, y); }
template <typename T> void amin(T &x, T y) { x = min(x, y); }
template <typename T> T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

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

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


Measured memory_bytes: 3656
import sys
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue
from decimal import Decimal

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()

    ret, r, sm = 0, 0, 0
    for l in range(N):
        while r < N and A[r] ^ sm == sm + A[r]:
            sm += A[r]
            r += 1

        ret += r - l
        if l == r:
            r += 1
        else:
            sm -= A[l]
    print(ret)


if __name__ == '__main__':
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

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

    ll ans = 0;
    ll t = 100;
    while(t < X){
        t += t / 100;
        ans++;
    }

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


Measured memory_bytes: 3548
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	int total = 700;
	for (int i = 0; i < 3; i++) {
		if (S[i] == 'o') {
			total += 100;
		}
	}
	cout << total << endl;
}

Measured memory_bytes: 3616
import sys


def main():
    n, a, b, c, d = [int(x) for x in sys.stdin.readline().split()]
    s = '#' + sys.stdin.readline().rstrip()

    if '##' in s[a+1:c-1] or '##' in s[b+1:d-1]:
        ans = 'No'
    else:
        if c < d:
            ans = 'Yes'
        else:
            for i in range(b, d+1):
                if s[i-1] == s[i] == s[i+1] == '.':
                    ans = 'Yes'
                    break
            else:
                ans = 'No'
        
    print(ans)

if __name__ == '__main__':
    main()


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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

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

  string s;
  cin >> s;
  
  vector<P_ii> g[26];
  REP(i, n) g[s[i] - 'a'].push_back({abs(i - n / 2) ,i});
  REP(i, 26) sort(all(g[i]));

  int ans = 0;
  REP(i, n){
    for(auto&& k : g[s[i] - 'a']){
      int j = k.second;
      if(i >= j) continue;

      if(j + ans >= n || s.substr(i, ans) != s.substr(j, ans)) continue;

      int d = ans;
      while(i + d < j && i + d < n && j + d < n && s[i + d] == s[j + d]) d++;
      
      chmax(ans, d);
    }
  }

  std::cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

typedef struct{
  int I;
  int U;
  int A;
  int P;
}T;

T TT[300],tmp;

int main()
{
  int i,j,n,UU[1001],SS[1001],head;

  while(1){
    scanf("%d",&n);   
    if(n==0)break;
    for(i=0;i<1001;i++)UU[i]=0;
    for(i=0;i<n;i++){
      scanf("%d%d%d%d",&TT[i].I,&TT[i].U,&TT[i].A,&TT[i].P);
    }  
    for(i=0;i<n;i++){
      for(j=n-1;j>i;j--){
	if(TT[j].A>TT[j-1].A){
          tmp=TT[j];
	  TT[j]=TT[j-1];
	  TT[j-1]=tmp;
	}
        else if(TT[j].A==TT[j-1].A && TT[j].P<TT[j-1].P){
	  tmp=TT[j];
	  TT[j]=TT[j-1];
	  TT[j-1]=tmp;
	}
        else if(TT[j].A==TT[j-1].A && TT[j].P==TT[j-1].P && TT[j].I<TT[j-1].I){
	  tmp=TT[j];
	  TT[j]=TT[j-1];
	  TT[j-1]=tmp;
	}
      }
    }
    for(i=0,head=0;i<n;i++){
      UU[TT[i].U]++;
      if(head<10 && UU[TT[i].U]<=3){
        SS[head]=TT[i].I;
	head++;
      }
      else if(head<20 && UU[TT[i].U]<=2){ 
	SS[head]=TT[i].I;
	head++;
      }
      else if(head<26 && UU[TT[i].U]<=1){
 	SS[head]=TT[i].I;
	head++;
      }
    }
    for(i=0;i<head;i++)printf("%d\n",SS[i]);
  }
  return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = sc.nextInt();
        boolean[] inA = new boolean[n];
        for (int i = 0; i < x; i++) {
            int a = sc.nextInt() - 1;
            inA[a] = true;
        }
        int y = sc.nextInt();
        boolean[] inB = new boolean[n];
        for (int i = 0; i < y; i++) {
            int b = sc.nextInt() - 1;
            inB[b] = true;
        }
        int z = sc.nextInt();
        boolean[] hasC = new boolean[n];
        for (int i = 0; i < z; i++) {
            int c = sc.nextInt() - 1;
            hasC[c] = true;
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if(!inA[i] && hasC[i]) {
                ans++;
                continue;
            } else if(inB[i] && hasC[i]) {
                ans++;
                continue;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 26668
from collections import defaultdict

res_dic = defaultdict(list)

num = input()

for i in range(int(num)):
    s = input()
    lis = s.split()
    res_dic[lis[0]].append([i+1, int(lis[1])])

res_dic = sorted(res_dic.items(), key=lambda x:x[0])

for k, l in res_dic:
    ls = sorted(l, key=lambda x:-x[1])
    for id, v in ls:
        print(id)


Measured memory_bytes: 3316