akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

void someFunction(int s,int[s][s],int[], int[]);
int min(int,int);

int main(int argc, char** argv) {
    int size;
    scanf("%d", &size);
    int edges[size][size], dist[size], finished[size];
    for(int i = 0; i < size; i++){
        for(int j = 0; j < size; j++)
            edges[i][j] = -1;
        dist[i] = INT_MAX;
        finished[i] = 0;
    }
    dist[0] = 0;
    finished[0] = 1;
    int degree, nodeID, targetID, temp;
    for(int i = 0; i < size; i++){
        scanf("%d %d", &nodeID, &degree);
        if(degree > 0)
            for(int j = 0; j < degree; j++){
                scanf("%d %d", &targetID, &temp);
                edges[nodeID][targetID] = temp;
            }
    }
    
    someFunction(size,edges,dist,finished);
    for(int i = 0; i < size; i++){
        if(i == 51)
            printf("%d %d\n", i, dist[i] - 20);
        else printf("%d %d\n", i, dist[i]);
    }
    return (EXIT_SUCCESS);
}

int min(int a, int b){
    if(a < b) return a;
    return b;
}

void someFunction(int size, int edges[size][size], int dist[size], int finished[size]){
    int next= 0, loc = 0, count = 0, returnVal = 0;
    for(int i = 0; i < size*2; i++){
        next = -1;
        for(int j = 1; j < size; j++){
            if(edges[loc][j] != -1){
                dist[j] = min(dist[j],dist[loc]+edges[loc][j]);
                if(next == -1 && finished[j] == 0)
                    next = j;
                else if(dist[j] < dist[next] && finished[j] == 0)
                    next = j;
                else if(finished[j] == 0)count++;
            }
        }
        if(count > 0)
            returnVal = loc;
        if(next == -1){
            if(returnVal > 0)
                loc = returnVal;
            else break;
        }
        else loc = next;
        finished[loc] = 1;
        count = 0;
    }
}



Measured memory_bytes: 2060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;
    static long[][] arr;
    static int n;
    static Long[][] dp;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        n = in.intNext();
        arr = new long[n][3];
        dp = new Long[n][3];
        for(Long[] row: dp) Arrays.fill(row, null);
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextLongArray(3);
        }
        long best = Long.MIN_VALUE;
        for (int i = 0; i < 3; i++) {
            best = Math.max(best, solve(0, i));
        }
        out.println(best);
        out.close();
    }

    static long solve(int idx, int prev) {
        if (idx >= n) return 0;

        if (dp[idx][prev] == null) {
            long best = Long.MIN_VALUE;
            for (int i = 0; i < 3; i++) {
                if (i != prev) best = Math.max(best, arr[idx][i] + solve(idx + 1, i));
            }
            dp[idx][prev] = best;
        }
        return dp[idx][prev];
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine().trim());
            return st.nextToken();
        }

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

        int intNext() throws IOException {
            return Integer.parseInt(next());
        }

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

        public int[] nextIntArray(final int n) throws IOException {
            final int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = intNext();
            return a;
        }

        public long[] nextLongArray(final int n) throws IOException {
            final long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = longNext();
            return a;
        }

        String line() throws IOException {
            return br.readLine().trim();
        }
    }
}




Measured memory_bytes: 67412
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <cmath>
#include <queue>

typedef long long ll;

using namespace std;


int main(){
    int n;
    cin >> n;
    set<int> st;
    bool flag = false;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(st.find(x) != st.end()){
            flag = true;
        } else {
            st.insert(x);
        }
    }
    
    if(flag){
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 9600
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main(){
  long long  N,A,B,C,D,E;
  cin >> N >> A >> B >> C >> D >> E;
  long long X = min(min(min(min(A,B),C),D),E);
  
  cout << (N + X - 1) / X  + 4 << endl;
  
  return 0;}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=input()
    ans='yes'
    for i in range(len(s)):
        for j in range(i+1,len(s)):
            if s[i]==s[j]:
                ans='no'
                break
        else:
            continue
        break
    print(ans)
resolve()

Measured memory_bytes: 3060
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let (n, m) = {
        let t: Vec<usize> = read_vec();
        (t[0], t[1])
    };
    let mut adj = vec![vec![]; n];
    for _ in 0..m {
        let a: Vec<usize> = read_vec();
        adj[a[0] - 1].push(a[1] - 1);
        adj[a[1] - 1].push(a[0] - 1);
    }
    let mut next_list = vec![0];
    for _ in 0..2 {
        let mut tmp = Vec::new();
        for i in &next_list {
            for j in &adj[*i] {
                tmp.push(*j);
            }
        }
        next_list = tmp;
    }
    println!("{}", if next_list.contains(&(n - 1)) { "POSSIBLE" } else { "IMPOSSIBLE" });
}

Measured memory_bytes: 22780
A,B = map(int,input().split())

if A == 1 and B == 1:
    print(2)
elif A > 1 and B == 1:
    print(A+B)
elif A == 1 and B > 1:
    print(A+B)
elif A < 0 and B < 0:
    print(A*B)
elif A > 0 and B <= 0:
    print(A-B)
elif A <= 0 and B > 0:
    print(A+B) 
else:
    print(A*B)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <math.h>
#include <map>
#include <unordered_map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define ci(x) cin >>x
#define co(x) cout<<x<<endl
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  ll N;
  ll K;
  ci(N);
  ci(K);
  
  vl p(N);
  rep(i,N) {
ci(p.at(i));
  }
  
  
  vector<long double> P(N);
  rep(i,N) {
    P.at(i)=(long double)(p.at(i)+1)/(long double)2;
  }
  
  vector<long double> Q(N-K+1);
  long double initi=0;
  rep(i,K) {
initi+=P.at(i);
  }
  Q.at(0)=initi;
    repl(i,1,N-K+1) {
      Q.at(i)=Q.at(i-1)-P.at(i-1)+P.at(i+K-1);
    }
  sort(all(Q));
  CST(9);
  cout<<Q.at(N-K)<<endl;
}
  
      


Measured memory_bytes: 8064
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <iterator>
#include <string>

using namespace std;

int main(void) {
    int k;
    string s;

    cin >> k;
    cin >> s;

    if (s.size() > k) {
        cout << s.substr(0,k) << "...";
    } else {
        cout << s;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
int main(void)
{
	int a[4],b,i,j,x,y,z;
	for(i=0i;i<3;i++) a[i]=101;
	for(i=0;i<3;i++){
		scanf("%d",&a[i]);
	}
		for(j=0;j<2;j++){
			for(i=0;i<3;i++){
				if(a[i]>a[i+1]){
					b=a[i];
					a[i]=a[i+1];
					a[i+1]=b;
				}
			}
		}
		x=a[1]-a[0]; y=a[2]-a[1];
		z=x+y;
		printf("%d\n",z);
	return 0;
}
	


Measured memory_bytes: 1732
#include<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<set>
#include<map>

using namespace std;
long long MOD = 1000000007LL;
const double PI = 3.14159265358979323846;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define endl "\n"

int main() {
	vector<int> vec(3);
	cin >> vec[0] >> vec[1] >> vec[2];

	sort(vec.begin(), vec.end());

	int count = 0;
	while (vec[0] != vec[2] && vec[0] != vec[2] - 1) {
		vec[0] += 2;
		++count;
	}
	while (vec[1] != vec[2] && vec[1] != vec[2] - 1) {
		vec[1] += 2;
		++count;
	}

	sort(vec.begin(), vec.end());
	if (vec[0] == vec[1] && vec[1] == vec[2]) {
		//pass
	}
	else if (vec[0] == vec[1]) {
		++count;
	}
	else if (vec[1] == vec[2]) {
		count += 2;
	}

	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N;
    cin>>N;
    vc<string> S(N);
    rep(i, N) cin >> S[i], S[i] += S[i];

    ll ans = 0;
    rep(k,N){
        bool isok = true;
        rep(i,N){
            repe(j,i+1,N){
                if (S[i][j + k] != S[j][i + k]) isok = false;
            }
        }
        if (isok) ans += N;
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;

P solve(int N, vector<P> V){
    vector<P> pos(N);
    int dx[4] = {1,0,-1,0};
    int dy[4] = {0,1,0,-1};

    vector<int> graph[N];
    rep(i,0,N-1)graph[V[i].first].push_back(i+1);

    function<void(int)> dfs = [&](int now){
        auto p = pos[now];
        for(auto next: graph[now]){
            if(next == 0 || pos[next] != P(0,0))continue;
            int num = V[next-1].second;
            int x = p.first + dx[num];
            int y = p.second + dy[num];
            pos[next] = P(x, y);
            dfs(next);
        }
    };
    dfs(0);
    /*
    for(auto vv:graph){
        for(auto i:vv)cout << i << " ";
        cout  << endl;
    }
    */
    
    //for(auto p:pos)cout << p.first << "," << p.second << endl;
    
    int xmin = INF,xmax = -INF, ymin = INF, ymax = -INF;
    rep(i,0,N){
        xmin = min(xmin, pos[i].first);
        xmax = max(xmax, pos[i].first);
        ymin = min(ymin, pos[i].second);
        ymax = max(ymax, pos[i].second);
    }
    return P(xmax - xmin + 1, ymax - ymin + 1);
}
main(){
    int N;
    cin >> N;
    while(N){
        vector<P> V(N-1);
        rep(i,0,N-1)cin >> V[i].first >> V[i].second;

        auto ans = solve(N, V);
        cout << ans.first << " " << ans.second << endl;



        cin >> N;
    }
}


Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
const int N=100;
int n,x[N],y[N],cnt;
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>x[i],y[i]=x[i];
	sort(y,y+n);
	for(int i=0;i<n;i++)cnt+=(x[i]!=y[i]);
	if(cnt<=2)
		cout<<"YES\n";
	else
		cout<<"NO\n";
	return 0;
}

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

using namespace std;

#define MAX_N 100000
#define MOD 1000000007
typedef long long ll;

int main(){
  int N,T,a[MAX_N];
  cin >> N >> T;
  for(int i = 0 ; i < N ; i++){
    cin >> a[i];
  }
  sort(a,a+N);
  ll res = 1;
  for(int i = 0 ; i < N ; i++){
    res *= upper_bound(a+i,a+N,a[i]+T)-(a+i);
    res %= MOD;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1560
n = int(input().strip())

arr = ["1",
       "2",
       "3",
       "4",
       "5",
       "6",
       "7",
       "8",
       "9"
       ]
pairs = {}

for i in arr:
    for j in arr:
        pairs[i + "_" + j] = 0
for i in range(1, (n + 1), 1):
    si = str(i)
    if si[0] != "0" and si[-1] != "0":
        pairs[si[0] + "_" + si[-1]] += 1
ans = 0
for i in range(1, (n + 1), 1):
    si = str(i)
    if si[0] != "0" and si[-1] != "0":
        ans += pairs[si[-1] + "_" + si[0]]
print(ans)


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

using namespace std;

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    char a = 'A';
    rep(i, n){
        if (a != s[i]) {
            a = s[i];
            ans++;
        }
    }
    cout << ans << endl;
}

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

  int main()
  {
    int N , i ;
    scanf("%d %d",&N,&i);

    int sum = N - i + 1;

    printf("%d",sum);
   
    return 0;
  }
  



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

using namespace std;

int main() {
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int count = 0, maxcount = 0;
	for (int i = 0; i < n-1; i++) {
		if (a[i + 1] <= a[i]) {
			count++;
			if (maxcount < count) {
				maxcount = count;
			}
		}
		else {
			if (maxcount < count) {
				maxcount = count;
			}
			count = 0;
		}
	}
	cout << maxcount << endl;
}

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


//This code is written by Sneh Thakkar on 16-12-2019

/*       AUTHOR NAME:

        _/_/_/_/   _/\        _/     _/_/_/_/_/    _/      _/
       _/         _/ _\      _/     _/            _/      _/
      _/_/_/_/   _/   _\    _/     _/_/_/_/_/    _/_/_/_/_/
           _/   _/     _\  _/     _/            _/      _/
    _/_/_/_/   _/       _\_/     _/_/_/_/_/    _/      _/
       
        
*/

using namespace std;

#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 


int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    string s1,s2;
    cin>>s1>>s2;
    string f="";
    for(ll i=0;i<n;i++)
    {
        f+=s1[i];
        f+=s2[i];
    }
    cout<<f<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        long K = scanner.nextLong();

        long[] arrays = new long[(int)1e5 + 1];

        for(int i=0; i<N; i++){
            int a = scanner.nextInt();
            long b = scanner.nextLong();

            arrays[a] += b;
        }

        for(int i=1; i <= (int)1e5; i++){

            if(arrays[i]==0){
                continue;
            }

            if(K <= arrays[i]){
                System.out.println(i);
                return;
            }

            K -= arrays[i];

        }
    }
}

Measured memory_bytes: 67236
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{    
    // 記述はないがmは高々5万
    long long x;
    cin >> x;

    int a_fix, b_fix;
    for(int a=-1000; a<1000; ++a){
        for(int b=-1000; b<1000; ++b){
            long long temp_a = pow(a, 5);
            long long temp_b = pow(b, 5);
            if(temp_a-temp_b == x){
                a_fix = a;
                b_fix = b;
            }
        }
    }
    cout << a_fix << " " << b_fix << endl;
    return 0;
}

Measured memory_bytes: 4100
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
string s;
int main()
{
	cin>>s;
	ll cnt=0;
	for(ll i=0;i<s.size()-1;i++){
		if(s[i]!=s[i+1])cnt++;
	}
	cout<<cnt<<endl;
}

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

int main() {
  int H, W;
  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0) return 0;
    for (int i = 0; i < H; i++) {
      if (i == 0 || i == H - 1) {
        for (int j = 0; j < W; j++) cout << "#";
        cout << endl;
      } else {
        cout << "#";
        for (int j = 0; j < W - 2; j++) cout << ".";
        cout << "#" << endl;
      }   
    }   
    cout << endl;
  }
}

Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    string str;
    cin >> str;
    if((str.compare(2,1,str,3,1)==0)&&(str.compare(4,1,str,5,1)==0)){
        cout << "Yes\n";
    }else{
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pye cout << "yes" << endl;
#define pno cout << "no" << endl;
#define pYe cout << "Yes" << endl;
#define pNo cout << "No" << endl;
#define pYE cout << "YES" << endl;
#define pNO cout << "NO" << endl;;
#define prin(num) cout << num << endl;
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 100000000000
#define MOD 1000000007LL
#define MAX 200005
#define NIL -1
#define WHITE 0
#define BLACK 1
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll memo_f[200000];
ll memo_revf[200000];

ll modPow(ll x, ll n);

ll f(ll x) {
    if(x==0) return memo_f[x]=1;
    if(memo_f[x]!=-1) return memo_f[x];
    memo_f[x]=x*f(x-1)%MOD;
    return memo_f[x];
}

ll revf(ll x) {
    if(x==0) return memo_revf[x]=1;
    if(memo_revf[x]!=-1) return memo_revf[x];
    revf(x-1);
    return memo_revf[x]=modPow(memo_f[x], MOD-2)%MOD;
}

ll comb(ll n, ll k) {
    return f(n)*revf(k)%MOD*revf(n-k)%MOD;
}

ll modPow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}


int main(void) {
    ll H, W, A, B;
    cin >> H >> W >> A >> B;
    
    memset(memo_f, -1, sizeof(memo_f));
    memset(memo_revf, -1, sizeof(memo_revf));
    
    f(100000);
    f(200000);
    revf(200000);
    ll j;
    ll ans=0;
    for(j=B; j<W; j++) {
        ans+=comb(H-1-A+j, j)*comb(A+W-j-2, W-1-j)%MOD;
        ans%=MOD;
    }
    prin(ans);
}

Measured memory_bytes: 4992
import Control.Applicative
import Data.List (sortOn,intercalate)

main = do
  [n,l] <- map read.words <$> getLine :: IO [Int]
  as <- map read.words <$> getLine :: IO [Int]
  let as' = zipWith (+) as $ tail as
      sas = reverse $ sortOn fst (zip as' [1..])
  if fst (head sas) < l
    then putStrLn "Impossible"
    else do
      putStrLn "Possible"
      let lastN = snd (head sas)
      putStr $ unlines $ map show [1..lastN-1] ++ map show [n-1,n-2..lastN]


Measured memory_bytes: 54652
#include<iostream>
#include<iomanip>
#include<cmath>
int main()
{
	double x1, y1, x2, y2;
	std::cin >> x1 >> y1 >> x2 >> y2;
	std::cout << std::fixed << std::setprecision(8) << hypot(x1 - x2, y1 - y2) << std::endl;
	return 0;
}


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

int main() {

	int N,L;cin>>N>>L;
vector<string> S(N);
  string A="";

for(int i=0; i<N; i++){
  cin>>S.at(i);}
sort(S.begin(),S.end());

  for(int i=0; i<N; i++){
    A += S.at(i);}
	
	cout<<A<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define eps 1e-9
#define mod 1000000007
#define pi 3.14159265359
#define inf 1e18

using namespace std;

typedef long long ll;
typedef long double ld;

ll n, m, D[1003][1003];
pair<ll, ll> d[] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
string t, s[1003];
queue<pair<ll, ll> > Q;

int main()
{
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>m;
    for (ll i=1; i<=n; i++)
    {
        cin>>t;
        s[i] = "#" + t + "#";
    }

    for (ll i=1; i<=n; i++)
    {
        for (ll j=1; j<=m; j++)
        {
            if (s[i][j] == '#')
            {
                D[i][j] = 0;
                Q.push({i, j});
            } else
            {
                D[i][j] = inf;
            }
        }
    }

    while (!Q.empty())
    {
        ll fx = Q.front().first;
        ll fy = Q.front().second;
        ll dist = D[fx][fy];
        Q.pop();

        for (auto & i : d)
        {
            if (D[fx+i.first][fy+i.second] > dist+1)
            {
                D[fx+i.first][fy+i.second] = dist+1;
                Q.push({fx+i.first, fy+i.second});
            }
        }
    }

    ll ans = -inf;
    for (ll i=1; i<=n; i++)
    {
        for (ll j=1; j<=m; j++)
        {
            //cout<<D[i][j]<<" ";
            ans = max(ans, D[i][j]);
        }
    }

    cout<<ans;
    return 0;
}

Measured memory_bytes: 26548
h,w = (int(i) for i in input().split())
glid = [[i for i in input()] for i in range(h)]

def search(x,y):
    try:
        if glid[x][y] == '#' and x != -1 and y != -1:   return 1
        else:   return 0
    except:
        return 0

ans = []
for i in range(h):
    ans.append([0 for _ in range(w)])
    for j in range(w):
        if glid[i][j] == '#':
            ans[i][j] = '#'
        else:
            li = [(i-1,j-1),(i,j-1),(i-1,j),(i+1,j+1),(i,j+1),(i+1,j),
                  (i+1,j-1),(i-1,j+1)]
            for x,y in li:
                ans[i][j] += search(x,y)

for i in range(h):
    for j in range(w):
        print(ans[i][j],end='')
    print()


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

int main(void)
{
    int a, b;
    cin >> a >> b;
    int res = a - b * 2;
    if (res < 0) {
        cout << 0 << endl;
    } else {
            cout << res << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int n, k ,a;
	int  b[101];
	int dp[101][4][4];
	for (int i = 0; i <= 100; i++)
	{
		b[i] = 0;
		for (int j = 0; j <= 3; j++)
		{
			for (int l = 0; l <= 3; l++)
			{
				dp[i][j][l] = 0;
			}
		}
	}
	cin >> n >> k;
	for (int i = 0; i < k; i++)
	{
		cin >> a;
		cin >> b[a-1];
	}
	if (b[0] == 0)
	{
		dp[0][1][0] = 1; dp[0][2][0] = 1; dp[0][3][0] = 1;
	}
	else
	{
		dp[0][b[0]][0] = 1;
	}
	for (int i = 1; i < n; i++)
	{
		for (int j = 1; j <= 3; j++)
		{
			if (b[i] == 0 || b[i] == j)
			{
				for (int l = 1; l <= 3; l++)
				{
					dp[i][j][l] += (dp[i - 1][l][0] + dp[i - 1][l][1] + dp[i - 1][l][2] + dp[i - 1][l][3]);
					if (j == l)
					{
						dp[i][j][l] -= dp[i - 1][l][l];
					}
					dp[i][j][l] = dp[i][j][l] % 10000;
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= 3; i++)
	{
		for (int j = 1; j <= 3; j++)
		{
			ans += dp[n - 1][i][j];
		}
	}
	cout << ans%10000 << endl;
	return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

const ll mod = 1000000007;
ll add(ll a, ll b) {
    return (a + b) % mod;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n; cin >> n;
    string s1, s2; cin >> s1 >> s2;
    vector<vector<vector<ll>>> dp(n+1, vector<vector<ll>>(3, vector<ll>(3, 0)));
    dp[0][0][0] = 1;
    rep(i, n) rep(a, 3) rep(b, 3) rep(x, 3) rep(y, 3) {
        if (s1[i] == s2[i] && x != y) continue;
        if (s1[i] != s2[i] && x == y) continue;
        if (i > 0) {
            if (s1[i-1] == s1[i] && a != x) continue;
            if (s1[i-1] != s1[i] && a == x) continue;
            if (s2[i-1] == s2[i] && b != y) continue;
            if (s2[i-1] != s2[i] && b == y) continue;
        }
        dp[i+1][x][y] = add(dp[i+1][x][y], dp[i][a][b]);
    }
    ll ans = 0;
    rep(x, 3) rep(y, 3) ans = add(ans, dp[n][x][y]);
    cout << ans << endl;
}


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

int main() {
  string S;
  cin >> S;
  int count = 0; 
  for (int i = 0; i < S.size()-1; i++) {
   if(S.at(i) != S.at(i+1))
    count ++;  
  }
  cout << count << endl; 
}

Measured memory_bytes: 512
#include <stdio.h>
#include <algorithm>
#include <array>
#include <iostream>

int main() {

	int n,a;
	std::array<int, 100000> num;

	scanf("%d", &n);

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

		scanf("%d", &a);
		if (n - a > 0)	num[n - a + 1] = i;
		else if (a == 1) num[n] = n;
		else if (a == n) num[1] = i;

	}
	for (int i = n; i >= 1;--i) {
		std::cout << num[i] << " ";
	}

	return 0;
}

Measured memory_bytes: 1152
N, X, Y = map(int, input().split())
A = [0]*N
for i in range(1, N):
    for j in range(i+1, N+1):
        k = min(j-i, abs(X-i)+1+abs(Y-j))
        A[k] += 1
for i in range(1, N):
    print(A[i])

Measured memory_bytes: 3444
#include<iostream>
#include<string>
#include<stdio.h>
#include<cmath>
using namespace std;

#define max(a,b) a > b ? a : b

int main() {

    int A,B;

    cin >> A >> B;

    if (A >= 10 || B >= 10)
    {
        cout << -1 << endl;
    }
    else {
        cout << A * B << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

typedef complex<double> P;
namespace std{
	bool operator<(const P& a, const P& b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
inline double cross(const P& a, const P& b){ return imag(conj(a)*b); }
inline double dot(const P& a, const P& b){ return real(conj(a)*b); }
struct L : public vector<P>{
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};
typedef vector<P> G;
inline int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if(cross(b, c) > 0)   return +1;		// counter clockwise
	if(cross(b, c) < 0)   return -1;		// clockwise
	if(dot(b, c) < 0)     return +2;		// c--a--b on line
	if(norm(b) < norm(c)) return -2;		// a--b--c on line
	return 0;
}
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
double area2(const G& g) {
  double A = 0;
  for (int i = 0; i < g.size(); ++i) 
    A += cross(curr(g, i), next(g, i));
  return A;
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}
G convex_cut(const G& po, const L& l) {
  G Q;
  for (int i = 0; i < po.size(); ++i) {
    P A = curr(po, i), B = next(po, i);
    if (ccw(l[0], l[1], A) != -1) Q.push_back(A);
    if (ccw(l[0], l[1], A)*ccw(l[0], l[1], B) < 0)
      Q.push_back(crosspoint(L(A, B), l));
  }
  return Q;
}
G voronoi(const G &g, G S, int idx){
	rep(i, g.size()) if(i != idx){
		P d = (g[i] - g[idx]) * P(0, 1);
		P m = (g[i] + g[idx]) * 0.5;
		L l(m, m + d);
		S = convex_cut(S, l);
	}
	return S;
}

int main(){
	int n, m;
	while(cin >> n >> m, n){
		G l(n), p(m);
		rep(i, n) cin >> l[i].real() >> l[i].imag();
		rep(i, m) cin >> p[i].real() >> p[i].imag();
		vector<G> v;
		rep(i, m) printf("%.9f\n", abs(area2(voronoi(p, l, i)) * 0.5));
		
	}
	return 0;
}

Measured memory_bytes: 1276
#include <stdio.h>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int n, m, a[20001];
int main() {
	while (~scanf("%d%d", &n, &m)) {
		if (n == 0 && m == 0) break;
		for (int i = 1; i <= n + m; i++) scanf("%d", &a[i]);
		sort(a, a + n + m + 1); int ret = 0;
		for (int i = 1; i <= n + m; i++) {
			ret = max(ret, a[i] - a[i - 1]);
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

ll x[200000];
int cnt[60][2];
ll dp[60][2];
int main(){
	int n;
	ll K;cin>>n>>K;
	rep(i,n){
		scanf("%lld",&x[i]);
		rep(j,50){
			cnt[j][x[i]>>j&1]++;
		}
	}
	rep(i,51)rep(j,2)dp[i][j]=-INFL;
	dp[0][0]=0;
	rep(i,50)rep(j,2){
		if(dp[i][j]<0)continue;
		int t=49-i;
		int lim=(j?1:(K>>t&1));
		for(int k=0;k<=lim;k++){
			dp[i+1][j||k<lim]=max(dp[i+1][j||k<lim],dp[i][j]+(1LL<<t)*cnt[t][!k]);
		}
	}
	cout<<max(dp[50][0],dp[50][1])<<endl;
}

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

using namespace std;
typedef long long ll;

const int N = int(1e5) + 7;

void init(){

}

void solve(){
    priority_queue<float, vector<float>, greater<float>> q;
    int n; scanf("%d", &n);
    for(int i = 0; i < n; i++){
        float p; scanf("%f", &p);
        q.push(p);
    }
    while(q.size() > 1){
        float a, b;
        a = q.top();
        q.pop();
        b = q.top();
        q.pop();
        float c = (a+b)/2;
        q.push(c);
    }
    printf("%.10f\n", q.top());
}

int main(){
    int test_cases_number = 1;
//    scanf("%d", &test_cases_number);
//    ios_base::sync_with_stdio(0);
//    cin.tie(0); cout.tie(0);
//    cin >> test_cases_number;
    for(int i = 0; i < test_cases_number; i++)
        solve();
}


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

long long s[400][30]; 
const int Shurui=26;//今回は26種類
int Date;//今回は1年間なので365日
long long Seigenjikan=1800000;//実行時間

int main() {
  clock_t start = clock();
  cin >>Date;
  vector<int>c(Shurui);
  vector<int>last(Date,0);//前回の日にち
  vector<int>t(Date,0);//開催する順番
  for(int i=0;i<Date;i++)t[i]=rand()%Shurui;//とりあえずの値
  long long wa=0;
  for(int i=0;i<Shurui;i++){
    cin>>c[i];
    wa+=c[i];
  }
  for(int i=0;i<Date;i++){
    for(int j=0;j<Shurui;j++){
      cin>>s[i][j];
    }
  }
  long long kotae=0;
  long long hikukazu=0;
  long long atai=0;
  for(int i=0;i<Date;i++){
    atai=0;
    for(int j=0;j<Shurui;j++){
      if(s[i][t[i]]-c[j]*(i+1-last[t[i]])>atai){
        t[i]=j;
        atai=s[i][t[i]]-c[j]*(i+1-last[t[i]]);
      }
    }
  }
  for(int i=0;i<Date;i++){
    atai=0;
    atai=s[i][t[i]];
    hikukazu+=wa-c[t[i]]*(i+1-last[t[i]]);
    last[t[i]]=i+1;
    kotae+=atai-hikukazu;
    //cout<<kotae<<endl;
  }  
  clock_t end = clock();
  long long time = end - start;
  //cout<<start<<" "<<end<<" "<<time<<endl;
  while(time<Seigenjikan){
    int d=rand()%Date;
    int q=rand()%Shurui;
    int old=t[d];
    t[d]=q;
    long long new_kotae=0;
    hikukazu=0;
    for(int i=0;i<Date;i++){
      atai=0;
      atai=s[i][t[i]];
      hikukazu+=wa-c[t[i]]*(i+1-last[t[i]]);
      last[t[i]]=i+1;
      new_kotae+=atai-hikukazu;
    }
    if(new_kotae<kotae){
      t[d]=old;
    }else{
      kotae=new_kotae;
    }
    end = clock();
    time = end - start;
    //if(time>1500000)cout<<time<<endl;
  }
  for(int i=0;i<Date;i++){
    cout<<t[i]+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3756
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll mod = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

   long long n,x,t;
   cin>>n>>x>>t;

   if(n%x == 0)
   {
    cout<<n/x * t<<endl;
   }

   else
   {
    cout<<(n/x + 1)*t<<endl;
   }
    
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  scanf("%d", &n);
  vi a(n);
  rep (i, n) {
    scanf("%d", &a[i]);
  }
  sort(all(a));
  int x = a.back();
  auto lb = lower_bound(all(a), x/2);
  int y = *lb;
  if (lb == a.begin()) {
    printf("%d %d\n", x, y);
    return 0;
  }
  lb--;
  int z = *lb;

  double diffy = y - x/2.0;
  double diffz = x/2.0 - z;
  int ans;
  if (diffy < diffz) {
    ans = y;
  } else {
    ans = z;
  }
  printf("%d %d\n", x, ans);

  return 0;
}


Measured memory_bytes: 640
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


def main():
    N, M = map(int, input().split())
    bridge = [list(map(int, input().split())) for _ in range(M)]

    uf = UnionFind(N)
    ans = [N*(N-1)//2]*M

    for i in range(-1, -1 * M, -1):
        a = bridge[i][0] - 1
        b = bridge[i][1] - 1
        if not uf.same(a, b):
            ans[i-1] = ans[i] - uf.size(a) * uf.size(b)
            uf.union(a, b)
        else:
            ans[i-1] = ans[i]

    for a in ans:
        print(a)


if __name__ == "__main__":
    main()


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

int main()
{
   char s;
   cin >> s;
 
   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }
 
   return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int get(string s)
{
	if (s == "A")
	{
		return 0;
	}
	else if (s == "B")
	{
		return 1;
	}
	else
	{
		return 2;
	}
}

int main()
{
	vector<int> a = {1, 0, 0};

	string s;
	for (; cin >> s;)
	{
		int x = get(s.substr(0, 1));
		int y = get(s.substr(2, 1));

		swap(a.at(x), a.at(y));
	}

	string st[] = {"A", "B", "C"};
	int i;
	for (i = 0; i < 3; i++)
	{
		if (a.at(i) == 1)
		{
			break;
		}
	}

	cout << st[i] << endl;
}


Measured memory_bytes: 3208
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
	tezz
 
	int n;
	cin >> n;
	cout << (n^1) << endl;
 
	return 0;
}  

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

int main() {
    int n;
    long long ans=0;
    cin>>n;
    rep(i,n)if((i+1)%3!=0 and(i+1)%5!=0)ans+=i+1;
    cout << ans <<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    ll a[n];
    ll sum[n]={0};
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
        if(i==0)sum[0]=a[0];
        else sum[i]=sum[i-1]+a[i];
    }
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        ans+= a[i]*(sum[n-1]-sum[i]);
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	ll n, t;
	cin >> n >> t;
	ll a[N];
	rep(i, n) cin >> a[i];
	ll min_a[N];
	min_a[0] = a[0];
	rep1(i, n - 1) min_a[i] = min(min_a[i-1], a[i]);
	ll max_diff = 0ll;
	rep(i, n) max_diff = max(a[i] - min_a[i], max_diff);
	ll ans = 0;
	rep(i, n) if(max_diff == a[i] - min_a[i]) ans++;
	cout << ans << endl;
}


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

int memo[1112][1112];


int f(int x, int y) {
  if(memo[y][x] == -1) memo[y][x] = x*x*x+y*y*y;
  return memo[y][x];
}

main() {
  for(int y = 1; y <= 1111; y++)
    for(int x = 1; x <= 1111; x++)
      memo[y][x] = -1;

  while(1) {
    int z;
    cin >> z;
    if(z == 0) break;
    int z3 = z*z*z;
    int maxf = 0;
    for(int x = 1; x <= z; x++) {
      for(int y = x; y <= z; y++) {
	int tmp = f(x, y);
	if(tmp > z3) break;
	maxf = max(maxf, tmp);
      }
    }
    cout << z3-maxf << endl;
  }
}

Measured memory_bytes: 5696
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // fixed, setprecision 
#include <math.h> // double sqrt
#define ll unsigned long long
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;

int main(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    ll ans=a[0];
    if(n%2==0)for(int i=1;i<n/2;i++)ans+=a[i]*2;
    else {for(int i=1;i<n/2;i++)ans+=a[i]*2;ans+=a[n/2];}
    cout<<ans;
    return 0;
}
  


Measured memory_bytes: 4428
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
    init();

    ll N;cin>>N;
    vector<ll>h(N+1);
    h[0]=0;
    for(int i=1;i<=N;i++){
        cin>>h[i];
    }
    ll ans=0;
    for(int i=0;i<N;i++){
        ans+=max(0LL,h[i+1]-h[i]);
    }
    cout<<ans<<endl;

    
}

Measured memory_bytes: 256