akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef long long ll;

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

  int n; cin >> n;
  vector<ll> a(n, 0);
  
  rep(i, n) { cin >> a[i]; }

  rep(i, n) {
    if (a[i] & 1) {
      cout << "first" << endl;
      return 0;
    }
  }

  cout << "second" << endl;

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss string
#define ll long long int
#define Endl endl
#define u_b upper_bound
#define rep(i,n)         for(int i=0;i<n;i++)
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define fr(i,a,b)        for(long long int i=a;i<=b;i++)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V vector<ll>v;
#define aaste long long int n;cin>>n;long long int a[n];for(long long int i=0;i<n;i++)cin>>a[i];
const ll   mod=            1000000007;
const ll   MOD1=           (int)1e9 + 9;
const ll   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
const int   N=                   1e6+7;

const int MAXR = 1000005;
ll         tests=          1;

using namespace std;
ll binarySearch(ll l, ll r,ll k)
{
	if (r >= l) {
		ll mid = l + (r - l) / 2;
		if (mid*(mid+1)==k)
			return 1;
		if (mid*(mid+1)>k)
			return binarySearch( l, mid - 1,k);
		return binarySearch(mid + 1, r, k);
	}
	return 0;
}
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
void swap(ll *p1, ll *p2)
{
   ll temp=*p1;
   *p1=*p2;
   *p2=temp;
}
ll cbratt(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
int MaxSubArraySumReturn(int a[], int  n) //negative thakle o kaaj korbe in O(n)
{
 
    int sum = 0, best = 0;
   for(ll i=0;i<n;i++)
    {
        sum = max(a[i], a[i] + sum);
        best = max(best, sum);
    }
    return best;
 
}
ll totalDigits(ll n) 
{ 

    ll number_of_digits = 0; 
    for (ll i = 1; i <= n; i *= 10) 
        number_of_digits += (n - i + 1); 
  
    return number_of_digits; 
} 

int main()
{
 
    #ifndef ONLINE_JUDGE
	{
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	}
  #endif
  ll  n;
  cin>>n;
  ll a[n];
long double sum=1;
for(ll i=0;i<=n-1;i+=1)
{
 cin>>a[i];
        if(a[i]==0)
        sum=0;
        if(sum!=-1)
       sum=sum*a[i];
        if(sum>1000000000000000000)
        sum=-1;

}
cout<<(ll)sum;
}


    




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

using namespace std;
const int MAX_N = 100 + 5;
int data[MAX_N];
int N;

int main() {
    ios::sync_with_stdio(false);
    cin >> N;
    for (int i = 0; i < 2 * N; i++) {
        cin >> data[i];
    }
    sort(data, data + 2 * N);
    int ans1 = 0, ans2 = 0;
    for (int i = 1; i < 2 * N; i = i + 2) {
        ans1 += min(data[i], data[i - 1]);
    }
    for (int i = 2; i < 2 * N; i = i + 2) {
        ans2 += min(data[i], data[i - 1]);
    }
    cout << max(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 256
// -> limitless <- //
#include<iostream>
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PB push_back
#define MP make_pair
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define read(n) scanf ("%d", &n)
using namespace std;
typedef unsigned long long ll;
    const int N = 1e5 + 2;
    const int mod = 1e9 + 7;

int main()
{
    int a, b, c;
    read(a), read(b), read(c);
    int t[3] = {};
    t[0] = abs(a-b);
    t[1] = abs(a-c);
    t[2] = abs(b-c);
    sort(t, t+3);
    printf("%d\n", t[0] + t[1]);
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int Combination(int n,int r){
    int num=1;
    for (int i=1; i<=r; i++){
        num = num*(n-i+1)/i;
    }
    return num;
}

int main(void){
    int n,m,ans;
    scanf("%d%d",&n,&m);
    ans = Combination(n,2) + Combination(m,2);
    printf("%d",ans);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
typedef unsigned long long int ll;

ll N, K;

int main()
{
  int i;
  ll x;
  ll ans;
  ll md;
//  ans = 1000000000000000000LL;

  cin >> N >> K;

  md = N%K;
  if (N*2>K && N<K)
    md = K%N;

  if (md == 0 || N<K) {
    printf("%llu\n", md);
  } else {
    printf("%llu\n", K-md);
  }

/*
  for (i=0,x=N; i<100; i++) {
    if (x>K)
      x -= K;
    else
      x = K-x;
    if (ans>x) ans = x;
//    printf(" %lld\n", x);
  }
  printf(" %lld\n", ans);
*/


  return 0;
}
/*
  N     K
  N->K-N
  
  */


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    map<int, int> cnt;
    cnt[0] = 1;
    int64_t ans = 0;
    int sum = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        sum = (sum + x) % m;
        ans += cnt[sum];
        ++cnt[sum];
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3200
n = float(input())

import math

if  math.floor(math.sqrt(2*n+0.25)-0.5)==math.sqrt(2*n+0.25)-0.5:
    for i in range(math.floor(math.sqrt(2*n+0.25)-0.5)):
        print(i+1)
elif n!=4:
    while n>0:
        x = math.floor(math.sqrt(2*n+0.25)-0.5)
        print(x+1)
        n -= x+1
else:
  print(3)
  print(1)
    
        


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
const int M = 1e9 + 7;
const int INF = 1e9;

// typedef
typedef pair<int, int> P;
typedef tuple<int, int, int> P3;
typedef vector<vector<int>> Graph;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.begin(), f.end(), greater<int>());
    ll worst = 1e12;
    ll ans = worst / 2;
    while (true) {
        ll sum = 0;
        rep(i, n) {
            sum += max((ll)0, a[i] - ans / f[i]);
        }
        if (sum <= k) {
            if (worst == ans) break;
            worst = ans;
            ans /= 2;
        } else {
            if (worst - ans <= 1) break;
            ans = (worst + ans) / 2;
        }
    }
    out(worst);
}


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

using std::cout;
using std::endl;
using std::cin;
using std::string;

string strUpp(string S) {
	// ??\????????§??????????????????
	for (size_t i = 0; i < S.size(); i++)
	{
		S[i] = toupper(S[i]);
	}
	return S;
}


int main() {
	string W;
	string T;
	int sum = 0;
	cin >> W;
	W = strUpp(W);
	while (1)
	{
		cin >> T;
		// ???????????¶
		if (T == "END_OF_TEXT")	break;
		T = strUpp(T);

		// ????´¢
		if (W == T) sum++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3128
//https://github.com/anmolvarshney05/SPOJ-Solutions/blob/master/SPOJ%20D-query%20(Using%20MO's%20Algorithm).cpp
#include<stdio.h>
#include<string.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

#define ARRAY_SIZE(arr) sizeof(arr)/sizeof(arr[0])
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define INF 2000000000
#define INF_LL 9223372036854775807LL
#define PI acos(-1.0)
#define llu long long unsigned
#define ll long long int
#define ld long int
#define iter(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define REP(p,a,b) for(int p=a;p<b;p++)
#define mod 1000000007
#define getchar_unlocked getchar
#define pb(f) push_back(f)
#define pob(f) pop_back(f)
#define pf(f) push_front(f)
#define pof(f) pop_front(f)
#define mkp(a,b) make_pair(a,b)
#define fst first
#define snd second
#define pii pair<int,int>
#define ins(a) insert(a)
#define N 1000000
#define A 1000010
#define BLOCK 800
#define M 1000000

int answer;
struct query
{
    int l,r,ind;
}Q[M];
int ans[M];
int a[N];
int cnt[A];

void add(int index)
{
    cnt[a[index]]++;
    if(cnt[a[index]]==1) answer++;
}

void remove(int index)
{
    cnt[a[index]]--;
    if(cnt[a[index]]==0) answer--;
}

bool cmp(query f,query s)
{
    if((f.l/BLOCK)!=(s.l/BLOCK))
        return (f.l/BLOCK)<(s.l/BLOCK);
    else
        return f.r<s.r;
}

int main() {
    ios_base::sync_with_stdio(false);
    int n,q;
    scanf("%d %d",&n, &q);
    REP(i,0,n)
    {
        scanf("%d",&a[i]);
    }
    REP(i,0,q)
    {
        scanf("%d%d",&Q[i].l,&Q[i].r);
        Q[i].ind=i;
        Q[i].l--;
        Q[i].r--;
    }
    sort(Q,Q+q,cmp);
    int cl=0,cr=0;
    REP(i,0,q)
    {
        int left=Q[i].l,right=Q[i].r;
        while(cl<left)
            remove(cl),cl++;
        while(cl>left)
            add(cl-1),cl--;
        while(cr<=right)
            add(cr),cr++;
        while(cr>(right+1))
            remove(cr-1),cr--;
        ans[Q[i].ind]=answer;
    }
    REP(i,0,q)
        printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 15480
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const ll mod=1000000007;
ll fast_mul(ll x,ll y)
{
	ll temp=x*y-(ll)((long double)x*y/mod+1.0e-8)*mod;
	return temp<0?temp+mod:temp;
}
int main()
{
	ll n,k,s,i,j,x,y,p=0,q=0,a[2005];
	cin>>n>>k;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[i]>a[j]){
				p++;
			}
		}
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			if(a[j]>a[i]){
				q++;
			}
		}
	}
	if(k%2==0){
		x=k/2;
		y=k-1;
	}
	else{
		x=k;
		y=(k-1)/2;
	}
	s=fast_mul(p,k)+(fast_mul(x,y)*q)%mod;
	cout<<s%mod<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define rep(i, n) for(int i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define riverse(v) reveYesrse((v).begin(), (v).end())
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vll = vector<ll>;
const ll MOD = 1e9+7;
vi alphabet = {'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z'};
 
int main() {
    int N;
    cin >> N;
    vi t(N+1);
    vi x(N+1);
    vi y(N+1);
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    rep(i, N) {
        cin >> t[i+1];
        cin >> x[i+1];
        cin >> y[i+1];
    }
    bool frag = true;
    rep(i, N) {
        if (t[i + 1] - t[i] < abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])) {
            frag = false;
        }
        else {
            int sa = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]) - (t[i + 1] - t[i]);
            if (sa % 2 != 0) frag = false;
        }
        if (!frag) break;
    }
    if (frag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N,K;
  int total = 0;
  cin >> N >> K;
  rep(i, N) {
    int x;
    cin >> x;
    if((K - x) >= x){
      total += x * 2;
    }else{
      total += (K - x) * 2;
    }
  }
  cout << total;
}

Measured memory_bytes: 3612
while True :
    try :
        n = input()
        J = 0
        I = 0
        
        for i in range(len(n) - 2) :
            if n[i : i + 3] == "JOI" :
                J += 1
            elif n[i : i + 3] == "IOI" :
                I += 1
        
        print(J)
        print(I)
        
    except :
        break
    


Measured memory_bytes: 5568
import sys
from math import floor, sqrt
from bisect import bisect_right as bi_r 

def prime_nums(n):
    sieve = set(range(2, n + 1))
    non_prime = set(range(2 * 2, n + 1, 2))
    sieve -= non_prime
    for i in range(3, floor(sqrt(n)) + 1, 2):
        if i in sieve:
            non_prime = set(range(i * 2, n + 1, i))
            sieve -= non_prime
    return sieve

n = int(sys.stdin.readline().rstrip())
ps = prime_nums(n)
ps -= set([2])
ps = sorted(ps)

def main():
    l = len(ps)
    cnt = 0

    # p**4
    for i in range(1, l+1):
        p = ps[i-1]
        if p ** 7 <= n:
            cnt += 1
        else:
            break
    
    # p**3 * q
    for i in range(1, l+1):
        p = ps[i-1]
        j = bi_r(ps, n // p ** 3)
        if j >= i:
            cnt += j - 1
        elif j > 0:
            cnt += j
        else:
            break
        
    # p * q * r
    for i in range(1, l-1):
        p = ps[i-1]
        for j in range(i+1, l):
            q = ps[j-1]
            if p * q > n:
                break
            for k in range(j+1, l+1):
                r = ps[k-1]
                if p * q * r > n:
                    break
                cnt += 1

    return cnt

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <climits>
#include <cmath>

int H, W;

void mark_bomb(char map[50][50], int w, int h) {
  if (w < 0 || h < 0) return;
  if (w >= W || h >= H) return;
  if (map[h][w] == '#') return;

  if (map[h][w] == '0') {
    map[h][w] = '1';
  } else {
    map[h][w]++;
  }

  return;
}

void check_map(char map[50][50], int w, int h) {
  if (map[h][w] == '#') {
    mark_bomb(map, w-1, h-1);
    mark_bomb(map, w  , h-1);
    mark_bomb(map, w+1, h-1);
    mark_bomb(map, w-1, h);
    mark_bomb(map, w  , h);
    mark_bomb(map, w+1, h);
    mark_bomb(map, w-1, h+1);
    mark_bomb(map, w  , h+1);
    mark_bomb(map, w+1, h+1);
  }
}

int main(void) {
  std::cin >> H >> W;

  char map[50][50];

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      std::cin >> map[i][j];
      if (map[i][j] == '.') {
        map[i][j] = '0';
      }
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      check_map(map, j, i);
    }
  }
 

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      std::cout << map[i][j];
    }
    std::cout << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m; i < n; i++) 
#define mod 1000000007
#define pi 3.1415926535
typedef long long ll;
int main(){
    int N,A,B;
    cin>>N>>A>>B;
    int ma=min(A,B);
    int mi;
    if(N-A-B>0){
        mi=0;
    }else{
        mi=A+B-N;
    }
    cout<<ma<<" "<<mi<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

void Main() {
  Cin(int, a, b, k);
  vector<int> vi;
  for (int i = 1; i <= min(a, b); ++i) {
    if (a % i == 0 && b % i == 0) vi.push_back(i);
  }
  reverse(all(vi));
  cout << vi[k - 1] << endl;
  return;
}

int main() {
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
def is_divisible_A_and_B(x, A, B):
    if A % x == 0 and B % x == 0:
        return True
    else:
        return False

A, B, K = map(int, input().split())

k = min(A, B)
divisible_list = []
for i in range(1, k + 1):
    if is_divisible_A_and_B(i, A, B):
        divisible_list.append(i)

print(divisible_list[-K])


Measured memory_bytes: 2940
#include"bits/stdc++.h"
using namespace std;

const long long MOD = 1e9 + 7;

long long modsub(long long a, long long b, long long mod) {
  long long res = ((a % mod) - (b % mod)) % mod;
  if (res < 0) res += mod;
  return res;
}

// nCk {{{
const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

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

// nCk (mod )
long long modcomb(long long n, long long k, long long mod){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
// }}}

void Main() {
  int n;
  cin >> n;
  int a[n + 1];
  int l, r;
  map<int, int> m;
  for (int i = 0; i < n + 1; i++) {
    int tmp;
    cin >> tmp;
    if (m[tmp] == 0) m[tmp] = i + 1;
    else {
      l = m[tmp];
      r = i + 1;
      break;
    }
  }

  modcombinit(MOD);
  for (int k = 1; k <= n + 1; k++) {
    // cout << modcomb(n + 1, k, MOD) << " " << modcomb(l - 1 + n + 1 - r, k - 1, MOD) << endl;
    cout << modsub(modcomb(n + 1, k, MOD), modcomb(l - 1 + n + 1 - r, k - 1, MOD), MOD) << endl;
  }
}

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



Measured memory_bytes: 17920
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here
    int k,cnt=0,t;
    char a[20],s[20];
    scanf("%s%s",a,s);
    k=strlen(s);
    t=strlen(a);
    for(int i=0;i<k;i++){
        if(a[i]==s[i])cnt++;
    }
    if(cnt!=t)printf("No\n");
    else if(t+1==k)printf("Yes\n");
    return 0;
    
}

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

using namespace std;

int main()
{
	int m, f, r;
	
	while(true)
	{
		scanf("%d %d %d", &m, &f, &r);
		
		if(m == -1 && f == -1 && r == -1)
			break;
		
		if(m == -1 || f == -1)
			printf("F\n");
		else if((m+f) >= 80)
			printf("A\n");
		else if((m+f) >= 65 && (m+f) < 80)
			printf("B\n");
		else if((m+f) >= 50 && (m+f) < 65)
			printf("C\n");
		else if((m+f) >= 30 && (m+f) < 50)
		{
			if(r >= 50)
				printf("C\n");
			else
				printf("D\n");
		}
		else
			printf("F\n");
	}
	return 0;
}


Measured memory_bytes: 3136
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	A := ReadInts(N)
	sum := Sum(A...)
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	c := 0
	for _, a := range A {
		if a*4*M >= sum {
			c++
		}
	}
	if c >= M {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func Sum(slice ...int) int {
	sum := 0
	for _, v := range slice {
		sum += v
	}
	return sum
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if (a == 0 && b == 0) {
				break;
			}
			if(a > b) {
				int temp = a;
				a = b;
				b = temp;
			}
		System.out.printf("%d %d\n",a,b);
		}

		
	}

}



Measured memory_bytes: 40228
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
// 最小公倍数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}

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

	int result = 0;
	string prev = "";
	repeat(i, S) {
		string n = N.substr(i, 1);

		if (n == prev) continue;
		prev = n;
		result++;
	}

	cout << result << endl;
	return 0;
}

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

int main(){

	while(true){
		int n;
		cin>>n;
	
	if(n==0){
		break;
	}

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

	int dif = 1000001;

	for(int i=0;i<n-1;i++){
		for(int j=i+1;j<n;j++){
			int d= abs(a[i]-a[j]);
		
			if(d<dif){
				dif=d;
			}
		}
	}

	cout<<dif<<endl;
	}
return 0;
}

Measured memory_bytes: 3080
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;

	int x, y;
	if (n < 2) x = 0;
	else x = n * (n - 1) / 2;
	if (m < 2) y = 0;
	else y = m * (m - 1) / 2;

	cout << x + y << endl;

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  string s; cin >> s;
  vector<ll> cntb(n+1), cntw(n+1);
  for (int i = 1; i <= n; i++) {
    cntb[i] += cntb[i-1];
    if (s[i-1] == '#') cntb[i]++;
  }
  for (int i = n-1; i >= 0; i--) {
    cntw[i] += cntw[i+1];
    if (s[i] == '.') cntw[i]++;
  }
  ll ans = INF;
  rep(i, n+1) {
    // debug2(cntb[i], cntw[i]);
    ans = min(ans, cntb[i] + cntw[i]);
  }
  if (ans == INF) outl(0);
  else outl(ans);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


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

int main() {
 int a, b, c;
 cin >> a >> b >> c;
 if (a < b){
   if(b < c){
     cout << a << " " << b << " " << c;
   } else if (a < c){
     cout << a << " " << c << " " << b;
   } else {
     cout << c << " " << a << " " << b;
   }
 } else if (a < c){
   cout << b << " " << a << " " << c;
 } else if (c < b){
   cout << c << " " << b << " " << a;
 } else {
   cout << b << " " << c << " " << a;
 }
 cout << endl;
 return 0;
}



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

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			List<int> data = new List<int>();
			for (int i = 0; i < n; i++)
			{
				int input = int.Parse(Console.ReadLine());
				data.Add(input);
			}
			data.Sort();
			data[data.Count - 1] /= 2;

			Console.WriteLine(data.Sum());
		}
	}
}

Measured memory_bytes: 13268
#include <iostream>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

void swap(int *x, int *y) {
  int temp = *x;
  *x = *y;
  *y = temp;
}

int bubbleSort(int *A, int N) {
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    for (int j = N - 1; j > i; j--) {
      if (A[j] < A[j - 1]) {
        swap(&A[j], &A[j - 1]);
        cnt++;
      }
    }
  }

  return cnt;
}

int main() {
  int n;
  std::cin >> n;
  int a[n];
  rep(i, n) std::cin >> a[i];

  int cnt = bubbleSort(a, n);

  rep(i, n) {
    std::cout << a[i];
    if (i == n - 1) {
      std::cout << '\n';
    } else {
      std::cout << ' ';
    }
  }

  std::cout << cnt << '\n';

  return 0;
}


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

int main(void) {
  int N;
  int B[102];
  cin >> N;
  for(int i = 0; i < 102; i++) {
     B[i] = 100000;
  }

  for(int i = 1; i <= N-1; i++) {
     cin >> B[i];
  }

  int sum = 0;
  for(int i = 1; i <= N; i++) {
    sum += min(B[i], B[i-1]); 
    //cout << i << ":" << min(B[i], B[i-1]) << endl; 
  }
  
  cout << sum;  
  return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n,a[N],f[N],b[N];
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n; ++i) {
        cin >> a[i];
        f[i] = max(f[i-1],a[i]);
    }
    for(int i = n;i >= 1; --i)
        b[i] = max(b[i+1],a[i]);
    cout << b[2] <<'\n';
    for(int i = 2;i <= n-1; ++i)
        cout << max(b[i+1],f[i-1]) <<'\n';
    cout << f[n-1];
    return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int32_t main(){
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
        // for debug in error.txt
        freopen("error.txt", "w", stderr);
    #endif
    int t = 1;
    while(t--) {
        string s;
        cin >> s;
        ll ans = INT_MIN, cnt = 0;
        for(int i = 0; i < 3; i++) {
            if(s[i] == 'R') {
                cnt++;
            }else{
                ans = max(cnt,ans);
                cnt = 0;
            }
        }
        ans = max(ans,cnt);
        cout << ans << '\n';
    }
}

Measured memory_bytes: 3624
def main():
	bought = 0
	money = 0
	DrinkList = []
	N,M = map(int,input().split())
	for i in range(N) :
		a,b = map(int,input().split())
		DrinkList.append( (a,b) )
	DrinkList.sort()
	for price,drink_max in DrinkList :
		for i in range(drink_max) :
			if bought < M :
				money += price
				bought += 1
			if bought == M :
				print(money)
				return 0
	
if __name__ == "__main__" :
	main()


Measured memory_bytes: 16908
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = Integer.parseInt(stdIn.next());
        if (n % 2 == 0) {
            System.out.println(n / 2);
        } else {
            System.out.println(n / 2 + 1);
        }
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int t,x;
    cin >> t >> x;
    double t_a = double(t)/double(x);
    cout << t_a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};

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

    int h, w, n, x[212345], y[212345], mi[212345];

    cin >> h >> w >> n;

    fill(mi, mi + h + 1, w + 1);

    REP(i, n)
    {
        cin >> x[i] >> y[i];

        mi[x[i]] = min(mi[x[i]], y[i]);
    }

    int r = 1;
    for (int i = 2; i <= h; i++)
    {
        if (mi[i] <= r)
        {
            cout << i - 1 << endl;
            return 0;
        }

        r = min(mi[i] - 1, r + 1);
    }

    cout << h << endl;

    return 0;
}

Measured memory_bytes: 2688
#include <stdio.h>
#include <limits.h>
#include <math.h>

int main(void)
{
	int n, i, j, flag=0;
	
	scanf("%d", &n);
	
	for (i = n; i < 100200; i++) {
		for (j = 2; j <=sqrt(n); j++) {
			if (i % j == 0) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			printf("%d", i);
			return 0;
		}
		flag = 0;
	}
	
}

Measured memory_bytes: 128
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
12 18
---+/
/+---test
420 660
---+/
/+---test
1 2019
---+/

void main(string[] args) {
  long A, B;
  readf(" %d %d ", &A, &B);

  auto C = gcd(A, B);

  int[long] fact;
  for (long i = 2; i*i <= C; ++i) {
    while (C%i == 0) {
      if (i !in fact) fact[i] = 0;
      ++fact[i];
      C /= i;
    }
  }
  if (C != 1) fact[C] = 1;

  (fact.length+1).writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
string a;
int main(){
    int n;
    while(cin>>n){
        ll ans=n;
        cin>>a;
        for(int i=0; i<n; ++i){
            if(i>0 && a[i]==a[i-1]){
                --ans;
            }
        }
        cout<<ans<<endl;
    }
  return 0;
}




Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using lint = long long;

vector<lint> dist;
const lint INF = 1e18;
struct  edge{lint to, cost;};
vector<edge> G[100010];

void dfs(lint now, lint ago, lint depth){
  dist[now] = depth;
  for(lint i = 0; i < G[now].size(); i++){
    lint next = G[now][i].to;
    if(next == ago) continue;
    dfs(next, now, depth + G[now][i].cost);
  }
}

signed main(){
  lint N; cin >> N;
  for(lint i = 1; i < N; i++){
    lint a, b, c; cin >> a >> b >> c; --a; --b;
    G[a].push_back(edge{b, c}); G[b].push_back(edge{a, c});
  }
  dist.resize(N, 0);
  lint Q, K; cin >> Q >> K;
  dfs(K - 1, -1, 0);
  for(lint i = 0; i < Q; i++){
    lint x, y; cin >> x >> y;
    lint ans = dist[x - 1] + dist[y - 1];
    cout << ans << endl;
  }
}

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

using namespace std;

int sum_elements(int n) 
{
    int sum = 0, m;

    while(n > 0)
    {    
        m = n % 10;    
        sum = sum + m;    
        n = n / 10;    
    }
    return sum;
}

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

    int sum = sum_elements(N);

    if(N % sum == 0)
        cout << "Yes\n";
    else
        cout << "No\n";


    return 0;
}

Measured memory_bytes: 256
#include <Codeforces.Solutions.h>
#include <ONLINE_JUDGE_SOLUTION <solution.cf(contestID = "1359",problemID = "C",method = "GET")>.h>
"""
    Author : thekushalghosh
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################

def solve():
    s = insr()
    t = insr()
    ONLINE_JUDGE_SOLUTION = Codeforces.Solutions(s,t,"1361","A","GET","POST")
    print(ONLINE_JUDGE_SOLUTION)
                
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
    sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(float,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)
 
def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
    return(q)

class Codeforces():
    def Solutions(s,t,id,question,get,post):
        if s == t[:-1]:
            return("Yes")
        else:
            return("No")
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
main()


Measured memory_bytes: 62672
#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000010
 
typedef pair<int,int> ii;
 
int arr[MAXN], lastPos[MAXN];
 
struct Node {
	int sum;
	void make_Node(int v) { sum = v; }
	void merge(Node left, Node right) { sum = left.sum + right.sum; }
};
 
struct SegmentTree {
	
	Node *stree;
 
	SegmentTree(int N) {
		stree = new Node[getSegmentTreeSize(N)];
		buildTree(1, 0, N - 1);
	}
 
	void buildTree(int nodo, int L, int R) {
		if (L == R)
			stree[nodo].make_Node(arr[L]);
		else {
			int mid = (L + R)/2, leftIdx = 2 * nodo, rightIdx = 2 * nodo + 1;
			buildTree(leftIdx, L, mid);
			buildTree(rightIdx, mid + 1, R);
			stree[nodo].merge(stree[leftIdx], stree[rightIdx]);
		}
	}
 
	Node query(int nodo, int L, int R, int i, int j) {
		if (L >= i && R <= j)
			return stree[nodo];
		
		int mid = (L + R)/2, leftIdx = 2 * nodo, rightIdx = 2 * nodo + 1;
		if (j <= mid)
			return query(leftIdx, L, mid, i, j);
		if (i > mid)
			return query(rightIdx, mid + 1, R, i, j);
		
		Node leftResult = query(leftIdx, L, mid, i, mid);
		Node rightResult = query(rightIdx, mid + 1, R, mid + 1, j);
		Node result;
		result.merge(leftResult, rightResult);
		return result;
	}
 
	void update(int nodo, int L, int R, int idx, int value) {
		if (L == R) {
			arr[idx] = value;
			stree[nodo].make_Node(value);
			return;
		}
		int mid = (L + R)/2, leftIdx = 2 * nodo, rightIdx = 2 * nodo + 1;
		if (idx <= mid)
			update(leftIdx, L, mid, idx, value);
		else
			update(rightIdx, mid + 1, R, idx, value);
		stree[nodo].merge(stree[leftIdx], stree[rightIdx]);
	}
 
	int getSegmentTreeSize(int N) {
		int size = 1;
		for(; size < N; size <<= 1);
		return size << 1;
	}
};
 
int main() {
	
	int n, q, l, r, a[500010];
	vector<pair<ii,int>> queries;
	vector<int> ans;
 
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (int i = 0; i < q; i++) {
		scanf("%d %d", &l, &r);
		queries.push_back(make_pair(ii(r - 1, l - 1), i));
	}
	sort(queries.begin(), queries.end());
	memset(lastPos, -1, sizeof(lastPos));
	ans.assign(q, 0);
 
	int idx = 0;
	SegmentTree st(n);
	for (int i = 0; i < n; i++) {
		if (lastPos[a[i]] != -1)
			st.update(1, 0, n - 1, lastPos[a[i]], 0);
		lastPos[a[i]] = i;
		st.update(1, 0, n - 1, lastPos[a[i]], 1);
		while (queries[idx].first.first == i) {
			ans[queries[idx].second] = st.query(1, 0, n - 1, queries[idx].first.second, queries[idx].first.first).sum;
			idx++;
		}
	}
	for (int i = 0; i < ans.size(); i++) {
		printf("%d\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 23500
import heapq as hp
class MinimumCostFlow():
    def __init__(self, N, INF=10**18):
        self.graph = [{} for _ in range(N)]
        self.N = N
        self.INF = INF
    
    def add_edge(self, u, v, cap, cost, undirected=False):
        # u -> v (maxflow, cost)
        if cap == 0: return
        if undirected:
            self.graph[u][v] = [cap, cost]
            self.graph[v][u] = [cap, -cost]
        elif v in self.graph[u]:
            self.graph[u][v] = [cap, cost]
        else:
            self.graph[u][v] = [cap, cost]
            self.graph[v][u] = [0, -cost]       
    
    def dijkstra(self, start):
        self.dist = [self.INF]*self.N # nearest distance
        self.dist[start] = 0
        self.que = [(0, start)]
        while self.que:
            d, v = hp.heappop(self.que)
            if self.dist[v] < d: continue
            for nv, (ncap, ncost) in self.graph[v].items():
                if ncap > 0 and self.dist[nv] > self.dist[v] + ncost + self.H[v] - self.H[nv]:
                    self.dist[nv] = self.dist[v] + ncost + self.H[v] - self.H[nv]
                    self.prevv[nv] = v
                    hp.heappush(self.que, (self.dist[nv], nv))
                
    
    def min_cost_flow(self, start, finish, flow):
        self.res = 0
        self.prevv = [-1]*self.N
        self.H = [0]*self.N # potential
        while flow > 0:
            self.dijkstra(start)
            if self.dist[finish] == self.INF: return -1 # cant run flow anymore
            for i in range(self.N):
                self.H[i] += self.dist[i]
            
            d = flow
            v = finish
            while v != start:
                d = min(d, self.graph[self.prevv[v]][v][0])
                v = self.prevv[v]
            flow -= d
            self.res += d*self.H[finish]

            v = finish
            while v != start:
                self.graph[self.prevv[v]][v][0] -= d
                self.graph[v][self.prevv[v]][0] += d
                v = self.prevv[v]
        return self.res
    

INF = 10**5
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
L = N*M
State = [list(input().rstrip()) for _ in range(N)]

FL = MinimumCostFlow(2*L+2)
c = 0
for n in range(N):
    for m in range(M):
        if State[n][m] == "o":
            FL.add_edge(2*L, m*N+n, 1, INF)
            c += 1
            cango = {(n-1, m)}
            for an in range(n, N):
                for am in range(m, M):
                    if ((an-1, am) in cango or (an, am-1) in cango) and State[an][am] != "#":
                        cango.add((an, am))
                        dist = an - n + am - m
                        FL.add_edge(m*N+n, L+am*N+an, 1, INF-dist)
        if State[n][m] != "#":
            FL.add_edge(m*N+n+L, 2*L+1, 1, INF)

ans = 3*c*INF - FL.min_cost_flow(2*L, 2*L+1, c)
print(ans)


Measured memory_bytes: 122528
S=input()
T=input()

if S == T:
  print('Yes')
  exit()

#最後の文字以外を、後ろにくっつけていく
nowS = S
for _ in range(len(S)-1):
  nowS = nowS[1:] + nowS[0]
  if nowS == T:
    print('Yes')
    exit()
    
print('No')

Measured memory_bytes: 3060
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let n: u8 = scan(tokens);
    let s: String = scan(tokens);
    let mut bytes: Vec<u8> = s.into_bytes();
    for i in 0..bytes.len() {
        bytes[i] += n;
        if bytes[i] > b'Z' {
            bytes[i] -= 26;
        }
    }
    println!("{}", String::from_utf8(bytes).unwrap());
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int N;
string S;

void solve() {
    cin >> N >> S;
    long long count = 0;
    vector<int> R(N + 1), G(N + 1), B(N + 1);
    R.at(0) = 0;
    G.at(0) = 0;
    B.at(0) = 0;

    rep(i, N) {
        if (S.at(i) == 'R') {
            R.at(i + 1) = R.at(i) + 1;
            G.at(i + 1) = G.at(i);
            B.at(i + 1) = B.at(i);
        }
        else if (S.at(i) == 'G') {
            R.at(i + 1) = R.at(i);
            G.at(i + 1) = G.at(i) + 1;
            B.at(i + 1) = B.at(i);
        }
        else {
            R.at(i + 1) = R.at(i);
            G.at(i + 1) = G.at(i);
            B.at(i + 1) = B.at(i) + 1;
        }
    }

    rep(i, N) {
        for (int j = i + 1; j < N; j++) {
            if (S.at(i) != S.at(j)) {
                if ((S.at(i) == 'R' && S.at(j) == 'G') || (S.at(i) == 'G' && S.at(j) == 'R')) {
                    count += (B.at(N) - B.at(j));
                }
                else if ((S.at(i) == 'R' && S.at(j) == 'B') || (S.at(i) == 'B' && S.at(j) == 'R')) {
                    count += (G.at(N) - G.at(j));
                }
                else {
                    count += (R.at(N) - R.at(j));
                }
                if (2 * j - i < N) {
                    if (S.at(2 * j - i) != S.at(i) && S.at(2 * j - i) != S.at(j)) {
                        count--;
                    }
                }
            }
        }
    }

    cout << count << endl;
    return;
}

int main() {
    solve();
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int>list(26,0);
  string S;cin>>S;
  for(int i=0;i<S.size();i++){
    list.at(S.at(i)-'a')++;
  }
  bool flag=true;
  for(int i=0;i<26;i++){
    if(list.at(i)%2==1){
      flag=false;
    }
  }
  if(flag){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    var ac = 0
    var wa = 0
    var tle = 0
    var re = 0
    for (i in 0 until n) {
        val s = sc.nextLine()
        if (s == "AC") ac++
        if (s == "WA") wa++
        if (s == "TLE") tle++
        if (s == "RE") re++
    }
    println("AC x $ac")
    println("WA x $wa")
    println("TLE x $tle")
    println("RE x $re")
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll M,K;
ll i, j, k,l;
ll anss[101010],ans;
ll mk[101010],mkr[101010];
int main(){
    scanf("%lld%lld", &M,&K);
    if(M<=1){
        if(K!=0){
            printf("-1");
            return 0;
        }
        printf("0 0 ");
        if(M==1){
            printf("1 1");
        }
        return 0;
    }


    if((1ll<<M)<=K){
        printf("-1");
        return 0;
    }

    fornum(i, 0, 1ll<< M)
    {
        if(i!=K)
            printf("%lld ", i);
    }
    printf("%lld ", K);
    for(i= (1ll<< M)-1;i>=0;i--)
    {
        if(i!=K)
            printf("%lld ", i);
    }
    printf("%lld ", K);

    return 0;
}

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

int main()
{
	string s,t;
	cin>>s>>t;
	int n = s.length(),ans=0;
	for (int i = 0; i < n; ++i)
	{
		if(s[i]!=t[i])
			ans++;
	}
	cout<<ans<<endl;

	
	return 0;
}

Measured memory_bytes: 3896
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n-1);
  for(ll i = 0; i < n-1; i++) cin >> b[i];
  a[0] = INT_MAX;  
  for(ll i = 0; i < n-1; i++) {
  	 if(a[i] > b[i]) a[i] = b[i];
  	 a[i+1] = b[i];
  }
  ll ans = 0;
  for(auto it: a) ans+= it;
  cout << ans << endl;
  return 0;
} //good night.

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

int main(){
  int N; cin >> N;
  vector<int> H(N);
  for(int i=0; i<N; i++) cin >> H[i];
  int ans=0;
  for(int i=0; i<N; i++){
      vector<int> W(i+1);
      for(int j=0; j<=i; j++){
          W[j]=H[j];
      }
      sort(W.begin(), W.end());
      if(W[i]==H[i]) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import Data.List
main=do
 n<-readLn;a<-map read.words<$>getLine
 print((if(even n)then (f 1 1) else (g 1 0))(sort a))
  where g i j a |a==[] = i
                |j==0&&(head a)==0 = g i (j+2) (tail a)
                |(head a)==j&&(head(tail a))==j = g (mod(i*2)1000000007) (j+2) (tail(tail a))
                |otherwise = 0
        f i j a |a==[] = i
                |(head a)==j&&(head(tail a))==j = g (mod(i*2)1000000007) (j+2) (tail(tail a))
                |otherwise = 0

Measured memory_bytes: 31100