akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
using namespace std;

const ll Maxn = 123456;
const ll Mod = 1000000007;



ll A[Maxn];
ll fact[Maxn];
ll inv[Maxn], ifact[Maxn];
ll freq[Maxn];



template<typename T, typename T1>
T mod(T x, T1 p)
{
    x %= p;
    while (x < 0)
        x += p;
    return x;
}


template<typename T>
T inverse(T x, T p) {
    x = mod(x, p);
    if (x == 1)
        return x;
    return mod((1LL * (-p / x) * (inv[p % x] % p)) , p);
    // Since inverse of p % x is already calculated.
}


ll NcR(ll n, ll r) {
    ll ret = (1LL * ifact[n - r] * ifact[r]) % Mod ;
	ret = (1LL * ret * fact[n]) % Mod;
    return ret;
}

int main()
{
ios_base::sync_with_stdio(false);


fact[0] = 1;
ifact[0] = 1;
for(ll i = 1; i < Maxn; i++) {
	fact[i] = 1LL * fact[i - 1] * i % Mod;
}

ifact[0] = 1;
for(ll i = 1; i < Maxn; i++) {
	ifact[i] = 1LL * ifact[i - 1] * inverse(i, Mod) % Mod;
}
for(ll i = 1; i < Maxn; i++) {
	inv[i] = inverse(i, Mod);
	ifact[i] = ifact[i - 1] * inv[i] % Mod;
}



ll n;
cin>>n;

n++;

//cout<<NcR(4,2)<<endl;


ll num=1;
for(ll i=0;i<n;i++)
    {cin>>A[i];
     freq[A[i]]++;
     if(freq[A[i]]==2)
        num=A[i];
    }

    ll i=0,p=0,q=0;

    //cout<<num<<endl;
    ll idx1,idx2;
    while(i<n)
    {
        if(A[i]==num){idx1=i;break;}
        p++;
        i++;
    }
    i=n-1;
    while(i>=0)
    {
        if(A[i]==num){idx2=i;break;}
        q++;
        i--;
    }
    ll d  = idx2-idx1;
    //d++;
   // cout<<p<<" "<<q<<endl;
    ll ans;
    cout<<n-1<<'\n';
    for(ll k=2;k<=n;k++)
    {

      ans= NcR(n,k);
      if(k-1<=n-d-1)
      {
          ans-=NcR(n-d-1,k-1);
          if(ans<0)ans+=Mod;
      }

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


Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define f first
#define ss second
#define pb push_back
//#define mp make_pair

ll n, a[202020], s[202020];
map<ll, int> mp;
set<ll> v;


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

//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);


cin >> n ;
rep(i, 1, n){
cin >> a[i];
s[i] += s[i-1]+a[i];
mp[s[i]]++;
v.insert(s[i]);
}

ll ans = 0;
for(auto t:v){
if(mp[t]>1){
    ll k = mp[t];
    ans += (k*(k-1))/2;
}
}
ans+= mp[0];
cout << ans << endl;

return 0;}


Measured memory_bytes: 25216
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for (int i=0;i<n;i++)
		cin >> a[i];
	for (int i=n-1;i>=0;i-=1)
		cout << a[i] << (i==0?"":" "); 
    cout << endl;
	return 0;
}


Measured memory_bytes: 3084
from collections import deque

sa = input()
sb = input()
sc = input()
a, b, c = 0, 0, 0
turn = 'a'
while True:
    if turn == 'a':
        if len(sa) == a:
            print('A')
            exit()
        turn = sa[a]
        a += 1
    if turn == 'b':
        if len(sb) == b:
            print('B')
            exit()
        turn = sb[b]
        b += 1
    if turn == 'c':
        if len(sc) == c:
            print('C')
            exit()
        turn = sc[c]
        c += 1


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

int main() {
  int N;
  cin>>N;
  vector<int> backet(100000,0);
  long long sum=0LL;
  for(int i=0;i<N;i++){
    int A;
    cin>>A;
    sum+=A;
    backet.at(A-1)++;
  }
  int Q;
  cin>>Q;
  for(int i=0;i<Q;i++){
    int B,C;
    cin>>B>>C;
    sum+=backet.at(B-1)*(C-B);
    backet.at(C-1)+=backet.at(B-1);
    backet.at(B-1)=0;
    cout<<sum<<endl;
  }
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int arr[4005][3];
int32_t main()
{
    int n;
    string s;
    cin >> n >> s;

    for(int i=1; i<=n; i++)
    {
        if(s[i-1] == 'R')
            arr[i][0] = 1;
        else if(s[i-1] == 'B')
            arr[i][1] = 1;
        else
            arr[i][2] = 1;
    }

    for(int i=1; i<=n; i++)
    {
        arr[i][0] += arr[i-1][0];
        arr[i][1] += arr[i-1][1];
        arr[i][2] += arr[i-1][2];
    }

    int counts = 0;
    for(int i=1; i<=n; i++)
    {
        for(int j=i+1; j<=n; j++)
        {
            if(s[i-1] == s[j-1])
                continue;
            if(s[i-1] == 'R' && s[j-1] == 'G')
            {
                int sum = arr[n][1] - arr[j][1];
                counts += sum;
                if(s[j + (j - i) - 1] == 'B')
                {
                    counts--;
                }
            }
            else if(s[i-1] == 'R' && s[j-1] == 'B')
            {
                int sum = arr[n][2] - arr[j][2];
                counts += sum;
                if(s[j + (j - i) - 1] == 'G')
                {
                    counts--;
                }
            }
            else if(s[i-1] == 'G' && s[j-1] == 'R')
            {
                int sum = arr[n][1] - arr[j][1];
                counts += sum;
                if(s[j + (j - i) - 1] == 'B')
                {
                    counts--;
                }
            }
            else if(s[i-1] == 'G' && s[j-1] == 'B')
            {
                int sum = arr[n][0] - arr[j][0];
                counts += sum;
                if(s[j + (j - i)-1] == 'R')
                {
                    counts--;
                }
            }
            else if(s[i-1] == 'B' && s[j-1] == 'R')
            {
                int sum = arr[n][2] - arr[j][2];
                counts += sum;
                if(s[j + (j - i)-1] == 'G')
                {
                    counts--;
                }
            }
            else if(s[i-1] == 'B' && s[j-1] == 'G')
            {
                int sum = arr[n][0] - arr[j][0];
                counts += sum;
                if(s[j + (j - i) - 1] == 'R')
                {
                    counts--;
                }
            }
        }
    }
    cout << counts << endl;
    return 0;
}


Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
//string s,p;
//map<string,int>mp;
//vector<int>v;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    cin>>n>>m;
    n=(n*(n-1))/2;
    m=(m*(m-1))/2;
    cout<<(n+m)<<"\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> d(n); for (auto&& e : d) cin >> e;
  sort(begin(d), end(d));
  cout << d[n / 2] - d[n / 2 - 1] << '\n';
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#define rep(i,s,t) for(register int i=s;i<=t;++i)
using namespace std;
const int N=1e5+11;
int n,ans;
int a[N];
inline bool cmp(int x,int y){
	return x>y;
}
int main(){
	scanf("%d",&n);
	rep(i,1,n)
		scanf("%d",a+i);
	sort(a+1,a+n+1,cmp);
	rep(i,1,n)
		if(i+1>a[i+1]){
			for(int j=i+1;a[j]==i;++j)
				ans^=1;
			ans|=(a[i]-i)&1;
			break;
		}
	puts(ans?"First":"Second");
	return 0;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

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

	cout << (n-1)*(m-1) << endl;

	return 0;
}

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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < 4; i++){
        if (S[i] == '+'){
            ans ++;
        }else{
            ans --;
        }
    }
    cout << ans << endl;


    return 0;
}

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

using namespace std;


int main() {

	int N;
	cin >> N;
	vector<int> A;

	A.resize(N);
	int min = 10000000000;
	int premin = 10000000000;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (min > A[i]) {
			min = A[i];
		}
	}
	int finisher = 10000000000;
	while (min != premin) {

		premin = min;
		int tempmin = 10000000000;
		for (int i = 0; i < N; i++) {
			int remainder = A[i] % min;
			if (remainder != 0)A[i] = remainder;
			if (min > A[i]) tempmin = A[i];
		}
		if (tempmin == finisher)break;
		min = tempmin;

	}

	cout << min << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k;
    int res = 0;
    cin >> n >> k;
    int t;
    map<int, int> m;
    si s;
    for (int i = 0; i < n; i++)
    {
        cin >> t;
        m[t]++;
        s.insert(t);
    }
    if (s.size() <= k)
        return cout << res << endl, 0;
    vi v;
    for (auto i : m)
        v.emplace_back(i.second);
    sort(v.begin(), v.end());
    for (int i = 0; i < s.size() - k; i++)
        res += v[i];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 20216
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back

void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  ll res = 0;
  map<int, int> cnt;
  for (int i = 0 ; i < n ; i++) {
    cin >> a[i];
    cnt[a[i]]++;
    res += (ll)(cnt[a[i]] - 1);
  }
  for (int i = 0 ; i < n ; i++) {
    ll k = res - cnt[a[i]] + 1;
    cout << k << endl;
  }
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

int n, m, q;
vector <int> a, b, c, d;
int ans;

template <typename T>
void printVec(vector<T> &vec) {
  cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    cout << *it << " ";
  }
  cout << endl;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <ll> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  vector<vector<int>> data(m, vector<int>(2));
  for(int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    data.at(i).at(0) = a;
    data.at(i).at(1) = b;
  }
  int ans_count = 0;
  vector <bool> ans(n, true);
  for(int i = 0; i < m; i++) {
    if (h[data[i][0] - 1] <= h[data[i][1] - 1]) {
      ans[data[i][0] - 1] = false;
    }
    if (h[data[i][1] - 1] <= h[data[i][0] - 1]) {
      ans[data[i][1] - 1] = false;
    }      
  }
  for(int i = 0; i < n; i++) {
    if (ans[i] == true) {
      ans_count = ans_count + 1;
    }
  }
  cout << ans_count << endl;
	return 0;
}


Measured memory_bytes: 9576
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    cin>>n;
    ll A[300][300];
    rep(i,n)rep(j,n) cin>>A[i][j];
    int z=1;
    ll ans=0;
    rep(i,n)for(int j=i+1;j<n;j++){
        int x=1;
        rep(k,n){
            if(k==i||k==j) continue;
            if(A[i][j]==A[i][k]+A[k][j]) x=0;
            if(A[i][j]>A[i][k]+A[k][j]) z=0;
        }
        if(x) ans+=A[i][j];
    }
    if(z) cout<<ans<<"\n";
    else cout<<-1<<"\n";
}

Measured memory_bytes: 896
import numpy as np

grid = []
for i in range(3):
    temp = list(map(int,input().split()))
    grid.append(temp)

db1 = grid[0][1]-grid[0][0]
db2 = grid[0][2]-grid[0][1]

flag = True

for i in range(1,3):
    d1 = grid[i][1]-grid[i][0]
    d2 = grid[i][2]-grid[i][1]

    if d1 == db1 and d2 == db2:
        continue
    else:
        flag = False

db1 = grid[1][0] - grid[0][0]
db2 = grid[2][0] - grid[1][0]

for i in range(1, 3):
    d1 = grid[1][i] - grid[0][i]
    d2 = grid[2][i] - grid[1][i]

    if d1 == db1 and d2 == db2:
        continue
    else:
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 12500
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int A, B, C;
	cin >> A >> B >> C;
	cout << max({ A, B, C }) - min({ A, B, C }) << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int x[] = new int[5];
    for (int i = 0;i < 5; i++) {
      x[i] = scan.nextInt();
      if (x[i] == 0) {
        System.out.println(i + 1);
        return;
      }
    }
  }
}



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

using namespace std;


int main() {
    string s;
    cin >> s;
    int n = (int) s.size();
    if (n == 1) {
        cout << s << endl;
        return 0;
    }

    bool flag = true;
    for (int i = 1; i < n; ++i) {
        if (s[i] != '9') {
            flag = false;
            break;
        }
    }

    if (flag) cout << 9 * (n - 1) + (int) (s[0] - '0') << endl;
    else {
        cout << 9 * (n - 1) + (int) (s[0] - '1') << endl;
    }
    return 0;
}

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

int main(){
    int x;cin >> x;
    for (int i = 1;i < x;i++){
        if ((100*i <= x) and (x <= 105 * i)){
            cout << "1" << endl;
            return 0;
        }
    }
    cout << "0" << endl;
}

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

using namespace std;

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

	int64_t a, b;
	cin >> a >> b;
	if((a + b) & 1) cout << "IMPOSSIBLE";
	else cout << a + ((b-a) >> 1);

	return 0;
}




Measured memory_bytes: 256
import itertools


def amida_patterns(w):
    # (0, 1, 2, ... , w - 1) -> ?
    ret = list()
    for bars in itertools.product([0, 1], repeat=w-1):
        if sum([b * bb for b, bb in zip(bars[1:], bars[:-1])]) > 0:
            continue
        location = list(range(w))
        for i in range(w):
            if i > 0 and bars[i - 1] == 1:
                location[i] = i - 1
            elif i < w - 1 and bars[i] == 1:
                location[i] = i + 1
        ret.append(location)
    return ret


def main():
    MOD = 10**9 + 7
    H, W, K = list(map(int, input().split(' ')))
    ap_list = amida_patterns(W)
    dp = [[0 for _ in range(W)] for _ in range(H + 1)]
    dp[0][0] = 1
    for h in range(1, H + 1):
        for a in ap_list:
            for w in range(W):
                dp[h][a[w]] += dp[h - 1][w]
                dp[h][a[w]] %= MOD
    print(dp[H][K - 1])


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e18 + 3)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

const int n_max = 205;
int n;
string G[n_max];
int saisyoku[n_max];

bool dfs(int v){
    REP(i,n){
        if(G[v][i] == '0') continue;
        int to = i;
        if(saisyoku[v] == saisyoku[to]) return false;
        else if(saisyoku[to] == -1){
            saisyoku[to] = 1 - saisyoku[v];
            if(dfs(to) == false) return false;
        }
    }
    return true;
}

int kazu[n_max];


bool dfs2(int v){
    REP(i,n){
        if(G[v][i] == '0') continue;
        if(kazu[i] == -1){
            kazu[i] = kazu[v] + 1;
            dfs2(i);
        }
        else if( kazu[i] != kazu[v] - 1 and kazu[i] != kazu[v] + 1) return false;
    }
    return true;
}



signed main(){
    cin >> n;
    REP(i,n) cin >> G[i];
    REP(i,n) saisyoku[i] = -1;

    saisyoku[0] = 0;
    if(dfs(0) == false){
        cout << - 1 << endl;
        return 0;
    };

    int ans = -1;
    REP(i,n){
        REP(j,n) kazu[j] = -1;
        kazu[i] = 1;
        queue<int> Q;
        Q.push(i);
        bool flag = true;
        while(Q.size() != 0){
            int v = Q.front();
            Q.pop();
            REP(j,n){
                if(G[v][j] == '0') continue;
                
                if(kazu[j] == -1){
                    Q.push(j);
                    kazu[j] = kazu[v] + 1;
                }
                else if(kazu[j] != kazu[v] + 1 and kazu[j] != kazu[v] - 1){
                    flag = false;
                }
            }
        }
        if(flag == false) continue;
        REP(i,n) chmax(ans,kazu[i]);

    }
    cout << ans << endl;



}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  vector<string> s(3);
  cin >> s[0] >> s[1] >> s[2];
  char ans;
  char now = 'a';
  while(true){
    bool flag = false;
    rep(i, 3){
      if(s[i].length() <= 0 && now == i + 'a'){
        ans = 'A' + i;
        flag = true;
        break;
      }
    }
    if(flag) break;
    rep(i, 3){
      if(now == 'a' + i){
        now = s[i][0];
        s[i] = s[i].erase(0, 1);
        break;
      }
    }
  }
  cout << ans << endl;

}

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

int main() {

  int A,B,C; 
  cin >> A >> B;
  C = A * B;
  
  if (A > 9) {
     C = -1;
  }
   if (B > 9) {
     C = -1;
  }
   cout << C << endl;
}


Measured memory_bytes: 256
class Node
  attr_accessor :left, :right, :value
  def initialize(x=nil)
    @left = self
    @right = self
    @value = x
  end
end

class Dic
  def initialize
    @top = Node.new
  end

  def solve
    ans = []
    n = gets.chomp.to_i
    n.times do
      cmd = gets.chomp
      if /insert/ =~ cmd
        insert(@top, cmd.split(' ')[1])
      else
        ans << find(@top, cmd.split(' ')[1])
      end
    end
    return ans
  end

  def insert(pt, x)
    if pt.right == @top
      if pt.left == @top
        pt.left = Node.new(x)
      else
        insert(pt.left, x)
      end
    else
      if pt.value == x
        return
      elsif pt.value > x
        if pt.left == pt
          pt.left = Node.new(x)
        else
          insert(pt.left, x)
        end
      else
        if pt.right == pt
          pt.right = Node.new(x)
        else
          insert(pt.right, x)
        end
      end
    end
  end
    
  def find(pt, x)
    if pt.right == @top
      if pt.left == @top
        return "no"
      else
        find(pt.left, x)
      end
    else
      if pt.value == x
        return "yes"
      elsif pt.value > x
        if pt.left == pt
          return "no"
        else
          find(pt.left, x)
        end
      else
        if pt.right == pt
          return "no"
        else
          find(pt.right, x)
        end
      end
    end
  end
    
end

if $0 == __FILE__
  puts Dic.new.solve
end

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

int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a==b&&b!=c) printf("Yes");
    else if(a==c&&a!=b) printf("Yes");
    else if(b==c&&a!=c) printf("Yes");
    else printf("No");




    return 0;
}

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


using namespace std;

const int MX = 100500;

int a[MX];
int b[MX];
int c[MX];
int flag[MX];

long long ans = 0;

long long check(priority_queue<pair<int,int>> &q, int fl){
	while(true){
		int pos = q.top().second;
		if(flag[pos] != fl) q.pop(); else return q.top().first;
	}
}

priority_queue<pair<int,int>> to_silver;
priority_queue<pair<int,int>> to_bronze;
priority_queue<pair<int,int>> to_bronze_from_silver;


void make_silver(){
	check(to_silver, 0);
	int val = to_silver.top().first;
	int pos = to_silver.top().second;

	flag[pos] = 1;
	ans += val;
	to_bronze_from_silver.push({c[pos] - b[pos], pos});
}

void make_bronze(){
	long long r1 = check(to_bronze, 0);
	long long r2 = check(to_bronze_from_silver, 1) + check(to_silver, 0);
	int pos;
	long long val;
	if(r1 > r2) {
		val = to_bronze.top().first; 
		pos = to_bronze.top().second;
	}else{
		val = to_bronze_from_silver.top().first; 
		pos = to_bronze_from_silver.top().second;
		make_silver();
	}
	
	flag[pos] = 2;
	ans += val;
}

int main() {
	ios_base::sync_with_stdio(false);
	int x, y, z;
	cin >> x >> y >> z;
	int n = x + y + z;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i] >> c[i];
		ans += a[i];
		to_silver.push({b[i] - a[i], i});
		to_bronze.push({c[i] - a[i], i});
		flag[ i ] = 0;
	}
	while(y--){
		make_silver();
	}
	while(z--){
		make_bronze();
	}
	cout << ans << endl;
	return 0;
}

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

long double ki(int x1,int y1,int x2,int y2){
    return (long double)sqrt(((x1-x2)*(x1-x2))+((y1-y2)*(y1-y2)));
}
int main()
{
    int n;
    cin>>n;
    vector<int>x(n);
    vector<int>y(n);
    rep(i,n){
    cin>>x[i];
    cin>>y[i];
    }
    long double ans=0;
    rep(i,n){
        for(int j=i+1;j<n;j++){
            ans+=ki(x[i],y[i],x[j],y[j]);
        }
    }
    ans=(long double)((ans/n)*2);
    cout<<setprecision(12)<<ans<<endl;
    return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    string s;
    cin >> s;
    int c = 0;
    int res[SIZE] = {};
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == 'L') {
            res[i - 1] += (c + 1) / 2;
            res[i] += c / 2;
            c = 0;

        } else {
            ++c;

        }
    }

    c = 0;
    for(int i = s.size() - 1; i >= 0; --i) {
        if(s[i] == 'R') {
            res[i + 1] += (c + 1) / 2;
            res[i] += c / 2;
            c = 0;

        } else {
            ++c;

        }
    }

    for(int i = 0; i < s.size(); ++i) cout << res[i] << " ";
    cout << endl;
    return 0;
}



Measured memory_bytes: 1488
fun main() {
    val s = readLine()!!.map { it.toString() }
    val length = s.size

    val pattern = 1.shl(length - 1)

    var answer = 0L
    for (i in 0 until pattern) {
        var tmp = s[0]
        for (j in 0 until (length - 1) ) {
            if (i.shr(j).and(1) == 0) {
                tmp += "+"
            }
            tmp += s[j + 1]
        }
        answer += calc(tmp)
    }
    println(answer)
}

fun calc(str: String): Long {
    return str.split("+").map { it.toLong() }.sum()
}


Measured memory_bytes: 38144
#include <bits/stdc++.h>
#include<queue>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<double,double> Pdouble;

const int INF = 2000000000;
const int MOD = 1000000007;

// a^n mod を計算する

int main(){
  string s;
  cin >> s;
  bool a1 = false;
  for(int i=0; i < s.size(); i++){
    if(i%2 == 0){
      if(s.at(i) != 'R' && (s.at(i) != 'U'&&s.at(i) != 'D')){
        a1 =true;
      }
    }else{
      if(s.at(i) != 'L' && (s.at(i) != 'U'&&s.at(i) != 'D')){
        a1 =true;
      }
    }
  }
  if(a1){

    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
  
  
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<algorithm>
using namespace std;

string roma = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
	int a[100], b;
	while (cin >> b, b) {
		for (int c = 0; c < b; c++)cin >> a[c];
		string d;
		cin >> d;
		for (int e = 0; e < d.length(); e++) {
			bool p = false;
			int f = 0;
			for (; f <104; f++) {
				if (roma[f] == d[e]) {
					if (p)break;
					else p = true;
				}
			}
			f -= a[e%b];
			cout << roma[f];
		}
		cout << endl;
	}
}

Measured memory_bytes: 3148
N = int(input())

XY_max = -10**10
XY_min = 10**10
YX_max = -10**10
YX_min = 10**10

for _ in range(N):
  x,y = map(int, input().split())
  XY_max = max(XY_max,x+y)
  XY_min = min(XY_min,x+y)
  YX_max = max(YX_max,x-y)
  YX_min = min(YX_min,x-y)

print(max(XY_max-XY_min,YX_max-YX_min))

Measured memory_bytes: 74168
// Problem : E - Picking Goods
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define plii pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
int arr[3001][3001];
int n,m,k;
int dp[3001][3001][4];
int go(int i,int j,int v)
{
	if(i==n && j==m){
		if(v==3)return 0;
		else return arr[i][j];
	}
	if(i>n || j>m)return INT_MIN;
	if(dp[i][j][v]!=-1)return dp[i][j][v];
	if(v==3){
		return dp[i][j][v]=max(go(i,j+1,v),go(i+1,j,0));
	}
	int with=arr[i][j]+max(go(i+1,j,0),go(i,j+1,v+1));
	int without=max(go(i,j+1,v),go(i+1,j,0));
	return dp[i][j][v]=max(with,without);
}
void solve(){
	rd(n,m,k);
	FOR(i,k){
		int u,v,val;
		rd(u,v,val);
		arr[u][v]=val;
	}
	pp(go(1,1,0));
	return;	
}


int32_t main() {
    // fint{
    	memset(dp,-1,sizeof(dp));
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 355796
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 n;
  cin >> n;
  if (n == 2) {
    cout << "1\n";
    return;
  }
  int ans = 2;
  auto f = [&] (int64 d) {
    int64 a = n;
    for (; a % d == 0; a /= d);
    return a % d == 1;
  };
  for (int64 i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      int64 x = n;
      for (; x % i == 0; x /= i);
      ans += f(i);
      if (i * i != n) {
        ans += f(n / i);
      }
    }
  }
  --n;
  for (int64 i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      ++ans;
      if (i * i != n) {
        ++ans;
      }
    }
  }
  cout << ans << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}




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

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

    int h[n];
    for(int i = 0; i < n; i++)  cin >> h[i];

    int ans = 0;

    while(true){
        int i;
        for(i = 0; i < n; i++)  if(h[i])    break;
        if(i == n)  break;

        ans++;
        for(int j = i; j < n; j++){
            if(h[j] == 0)   break;
            h[j]--;
        }
    }

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

Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	aa := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	l := 0
	r := int(1e9 + 1)
	for l+1 < r {
		m := (l + r) >> 1
		c := 0
		for i := 0; i < n; i++ {
			c += (aa[i] - 1) / m
		}
		if c <= k {
			r = m
			continue
		}
		l = m
	}
	fmt.Fprintln(writer, r)
}


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

using namespace std;
int main() {
  int N, a, b, c, dp[3]{};
  cin >> N;
  while (cin >> a >> b >> c) {
    int ma = max(dp[1], dp[2]), mb = max(dp[0], dp[2]), mc = max(dp[0], dp[1]);
    dp[0] = a + ma;
    dp[1] = b + mb;
    dp[2] = c + mc;
  }
  cout << *max_element(dp, dp + 3) << endl;
}


Measured memory_bytes: 3640
import Control.Applicative
import Control.Monad

lcmmult :: [Int] -> Int
lcmmult [x] = x
lcmmult (x:xs) = lcm x $ lcmmult xs

main :: IO ()
main = do
    n <- readLn :: IO Int
    xs <- replicateM n readLn :: IO [Int]
    putStrLn $ show $ lcmmult xs



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

vector<int> g1[101010], g2[101010];

struct UnionFind {
    static const int MAX = 1000000;
    int par[MAX];
    void init(int N) {
        for (int i=0; i<N; ++i) {
            par[i] = -1;
        }
    }
    void init() {
        for (int i=0; i<MAX; ++i) {
            par[i] = -1;
        }
    }
    int find(int x) {
        if (par[x] < 0) return x;
        else return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (par[x] > par[y]) {
            int tmp = x;
            x = y;
            y = tmp;
        }
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    // そのグループの木の大きさを返す
    int size(int x) {
        return -par[find(x)];
    }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;

    UnionFind uf1;
    uf1.init(N);

    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g1[a].push_back(b);
        g1[b].push_back(a);

        uf1.unite(a, b);
    }

    rep(i, K) {
        int c, d;
        cin >> c >> d;
        c--; d--;

        g2[c].push_back(d);
        g2[d].push_back(c);
    }

    rep(i, N) {
        int ans = (uf1.size(i) - 1) - g1[i].size();
        for (int & v : g2[i]) {
            if (uf1.same(i, v)) ans--;
        }
        cout << ans << " ";
    }
    cout << endl;

}


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

struct Card{
    char suit;
    int value;
};

void display(struct Card C[], int N)
{
    rep(i, N){
        if(i > 0) cout << " ";
        cout << C[i].suit << C[i].value;
    }
    cout << endl;
    return;

}

void bubble(struct Card C[], int N)
{
    rep(i, N-1){
        for (int j = N-1; j > i; --j){
            if (C[j-1].value > C[j].value){
                Card T = C[j-1]; C[j-1] = C[j]; C[j] = T;
            }
        }
    }
}

void selectionSort(struct Card C[], int N) {
    rep(i, N){
        int minj = i;
        for ( int j = i; j < N; ++j){
            if( C[j].value < C[minj].value) minj = j;
        }
        if (minj != i){
            Card T = C[i]; C[i] = C[minj]; C[minj] = T;
        }
    }
}

bool isEqual(struct Card C1[], struct Card C2[], int N)
{
    rep(i, N){
        if (C1[i].suit != C2[i].suit ) return false;
    }
    return true;
}

int main(){

    Card A1[100], A2[100];
    int N;
    cin >> N;

    rep(i, N){
        cin >> A1[i].suit >> A1[i].value ;
    }
    rep(i, N) A2[i] = A1[i];

    bubble(A1, N);
    display(A1, N);
    cout << "Stable" << endl;

    selectionSort(A2, N);
    display(A2, N);
    if (isEqual(A1, A2, N)) cout << "Stable" << endl;
    else cout << "Not stable" << endl;

}


Measured memory_bytes: 3096
import java.util.Arrays;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int M=10000000;
		for(;;)
		{
			int n=in.nextInt();
			int k=in.nextInt();
			if((n|k)==0)
				return;
			int cost[][]=new int[n+1][n+1];
			for(int i=0;i<=n;i++)
				Arrays.fill(cost[i], M);
			for(int i=0;i<=n;i++)
				cost[i][i]=0;

			for(int i=0;i<k;i++)
			{
				int ju=in.nextInt();
				if(ju==0)
				{
					int s=in.nextInt();
					int t=in.nextInt();

					int p=0;
					int v[] = new int[n+1];// decision flag
					int leng[]=new int[n+1];// minimum distance
					for(int l=0;l<=n;l++)
					{
						leng[l]=M;
						v[l]=0;
					}
					leng[s]=0;
					for(int j=0;j<=n;j++)
					{
						int min=M;//最小の節点を探す
						for(int l=0;l<=n;l++)
						{
							if(v[l]==0&&leng[l]<min)
							{
								p=l;
								min=leng[l];
							}
						}
						v[p]=1;//確定フラグ
						for(int l=0;l<=n;l++) //pを経由してlに至長さがそれまでの最短経路より小さければ更新
						{
							if((leng[p]+cost[p][l])<leng[l])
							{
								leng[l]=leng[p]+cost[p][l];
							}
						}
					}
					if(leng[t]>=M)
						System.out.println(-1);
					else
						System.out.println(leng[t]);
					}
				else if(ju==1)
				{
					int S=in.nextInt();
					int T=in.nextInt();
					int c=in.nextInt();
					if(cost[S][T]>c)
					{
						cost[S][T]=c;
						cost[T][S]=c;
					}
				}
			}
		}
	}
}

Measured memory_bytes: 13000
n,y = map(int, input().split())
for i in range(min(n+1, y//10000+1)):
    for j in range(min(n-i+1, y//1000+1)):
        c = n-i-j
        if 10000 * i + 5000 * j + 1000 * c == y:
            print(i,j,c)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNext()) {
				int n=sc.nextInt();
				if(n==0) break;
				char[][] board=new char[n][n];
				for(int i=0; i<n; i++) {
					String str=sc.next();
					for(int j=0; j<n; j++) {
						board[i][j]=str.charAt(j);
					}
				}
				int[][] dp=new int[n][n];
				for(int k=0; k<n; k++) {
					dp[0][k]=(board[0][k]=='.'?1:0);
					dp[k][0]=(board[k][0]=='.'?1:0);
				}
				for(int i=1; i<n; i++) {
					for(int j=1; j<n; j++) {
						if(board[i][j]=='.')dp[i][j]=Math.min(dp[i-1][j-1],Math.min(dp[i-1][j], dp[i][j-1]))+1;
						else dp[i][j]=0;
					}
				}
				int ans=0;
				for(int i=0; i<n; i++) {
					for(int j=0; j<n; j++) {
						ans=Math.max(ans, dp[i][j]);
					}
				}
				System.out.println(ans);
			}

		}

	}
}


Measured memory_bytes: 77312
#include <bits/stdc++.h>
#define fto(i,a,b) for(int i=a; i<=b; ++i)
#define fdto(i,a,b) for(int i=a; i>=b; --i)
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define st first
#define nd second
#define maxn 2009
#define Ntu "bai2"

using namespace std;
const int base = 1e9+7;
int n;
ll k;
int a[maxn];
int sl[maxn];
vector<int> b;
int main()
{
    ios_base::sync_with_stdio(0);
    //freopen(Ntu".inp","r",stdin);
    //freopen(Ntu".out","w",stdout);
    cin.tie(NULL);cout.tie(NULL);
    cin >> n >> k;
    fto(i,1,n) cin >> a[i],++sl[a[i]];
    ll rs=0;
    fto(i,1,n)
    {
        fto(j,1,i-1) if (a[j]<a[i])
        {
            rs=(rs+(k-1)*k/2)%base;
        }
        fto(j,i+1,n) if (a[j]<a[i])
        {
            rs=(rs+(k+1)*k/2)%base;
        }
    }
    cout << rs;
    return 0;
}


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

int cmp1(const void *a, const void *b) {
    return *(char*)a - *(char*)b;
}
int cmp2(const void *a, const void *b) {
    return - *(char*)a + *(char*)b;
}
int main() {
	char s[100], t[100];
	scanf("%s%s",s,t);
	qsort(s, strlen(s), sizeof(char), cmp1);
	qsort(t, strlen(t), sizeof(char), cmp2);
	printf(strcmp(s,t) < 0 ? "Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N;cin>>N;
    string s,t;
    cin>>s>>t;
    string ans;
    REP(i,N){
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
###
### atcorder test program
###

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

math = math()

### input num
#i = input()
#A, B = [int(x) for x in i.split()]
R = float(input())
#A = [int(x) for x in input().split()]

#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))

print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))



Measured memory_bytes: 5588
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))

using namespace std;

int solve(int a, int b, int c)
{
	int res = 0;
	
	FOR(i, 0, 3)
	{
		if( a>=i && b >= i && c >= i )
			res = max(res, i + (a-i)/3 + (b-i)/3 + (c-i)/3);
	}
	
	return res;
}

int main()
{
	int mt, gre, geo, dp, grp, otr;

	while(cin >> mt >> gre >> geo >> dp >> grp >> otr, mt||gre||geo||dp||grp||otr)
	{
		cout << solve(mt+dp, gre+grp, geo+otr) << endl;	
	}
	
	return 0;
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;

    pair<pair<string, int>, int> R[110];
    for(int i = 0; i < n; i++){
        int p;
        string s;
        cin >> s >> p;
        R[i] = make_pair(make_pair(s, -p), i);
    }
    sort(R, R+n);
    for(int i = 0; i < n; i++){
        cout << R[i].second + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 101
unsigned short F[N][N][N][N],mp[N][N],sum[N][N];
using namespace std;
inline int rd() { int r; scanf("%d",&r); return r; }
int n,m,sx,sy;
char s[N];

inline void ut(unsigned short &x,unsigned short y) { x = max(x, y); }
void init() {
	n = rd(), m = rd();
	for (int i=1;i<=n;i++) {
		scanf("%s",s+1);
		for (int j=1;j<=m;j++) {
			s[j] == 'E' ? sx=i, sy=j :0;
			s[j] == 'o' ? mp[i][j]=1 :0; 
			sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + mp[i][j];
		}
	}
}

inline short get(int x1, int y1, int x2, int y2) {
	if (x1 > x2 || y1 > y2) return 0;
	return sum[x2][y2] - sum[x1][y2] - sum[x2][y1] + sum[x1][y1];
}
void dp(int i, int j, int x, int y) {
	unsigned short v = 0;
	
	v = i+x+1 <= sx-1 ? 
		get(sx-i-2, max(sy-j-1, y), sx-i-1, min(sy+y, m-j)) :0;
	ut( F[i+1][j][x][y], F[i][j][x][y] + v );

	v = i+x+1 <= n-sx ?
		get(sx+x, max(sy-j-1, y), sx+x+1, min(sy+y, m-j)) :0;
	ut( F[i][j][x+1][y], F[i][j][x][y] + v );
	
	v = j+y+1 <= sy-1 ?
		get(max(sx-i-1, x), sy-j-2, min(sx+x, n-i), sy-j-1) :0;
	ut( F[i][j+1][x][y], F[i][j][x][y] + v );
	
	v = j+y+1 <= m-sy ?
		get(max(sx-i-1, x), sy+y, min(sx+x, n-i), sy+y+1) :0;
	ut( F[i][j][x][y+1], F[i][j][x][y] + v );
	
	return ;
}

void solve() {
	unsigned short ans = 0;
	for (int i=0;i<=sx-1;i++)
		for (int j=0;j<=sy-1;j++)
			for (int _i=0;_i<=n-sx;_i++)
				for (int _j=0;_j<=m-sy;_j++) {
					dp(i,j,_i,_j), ans = max(ans, F[i][j][_i][_j]);
//					if (F[i][j][_i][_j] == 1) printf("::1:: %d %d %d %d\n",i,j,_i,_j);
//					if (F[i][j][_i][_j] == 2) printf("::2:: %d %d %d %d\n",i,j,_i,_j);
//					if (F[i][j][_i][_j] == 3) printf("::3:: %d %d %d %d\n",i,j,_i,_j);
				}
	printf("%d\n",(int)ans);
}

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

Measured memory_bytes: 201472
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF (1LL<<57)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;
typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	VI X;
	int ct = 1;
	for(int i=1;i<n;i++)
	{
		if(s[i-1] == s[i])
		ct++;
		else
		{
			X.pb(ct);
			ct = 1;
		}	
	}
	X.pb(ct);
	cout<<(int)X.sz()<<"\n";
	return;
}

int main(void)
{
	FLASH();
	int T;
	T = 1;

/*#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif*/

	while(T--)
	solve(T);

/*#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cout<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif*/

	return 0;
}

Measured memory_bytes: 972
#include<algorithm>
#include<bitset>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<list>
#include<map>
#include<iomanip>
#include<iostream>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<algorithm>
#include<memory.h>
using namespace std;
int main(){
	int n,a[100002]={0},b[100002]={0};  
    while(cin>>n){  
        memset(b,-1,sizeof(b));  
        for(int i=1;i<=n;i++){
            cin>>a[i]; b[i]=0;  
        }  
        int flag=0,ans=0,i=1;  
        while(1){  
            if(b[i]==0){  
                b[i]=1;
				ans++;  
                i=a[i];  
                if(i==2){  
                	flag=1;
					break;  
                }  
            }  
            else if(b[i]==1){  
                flag=0;
				break;  
            }  
        }  
        if(flag==0)  
            cout<<-1<<endl;  
        else  
            cout<<ans<<endl;  
    }  
	return 0;
}


Measured memory_bytes: 1024