akhauriyash/Code-Regression huggingface dataset:
#define _USE_NATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <random>
#include <tuple>


using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
#define EPS 1e-9
const int INF = 1050000000;
const long long LINF = 1LL << 60;
const ll MOD = 1e9 + 7;
const int MINF = -1050000000;

int main() {
	ll a, b, c, k;
	cin >> a >> b >> c >> k;
	
	if (abs(a - b) > 1e18) {
		cout << "Unfair" << endl;
		return 0;
	}
	if(k%2 ==0)cout << a - b << endl;
	else cout << b-a << endl;
	return 0;
}


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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int x=max({a,b,c});
    cout << a+b+c-x << endl;
    return 0;
}











Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <ctype.h>
#include <climits>
#include <queue>
#include <iostream>
#include <string>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
    int k;
    cin >> k;
    int x = 7%k;
    set<int> s;
    int i = 1;
    while (s.count(x) == 0) {
        if (x == 0) {
            cout << i << endl;
            return 0;
        }
        s.insert(x);
        x = (x*10 + 7)%k;
        i++;
    }
    cout << -1 << endl;
    return 0;
}

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

int main() {

  int N;
  cin >> N;

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

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

  for (int i = 0; i < N; i++) {
    cout << B[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 4792
#include<bits/stdc++.h>
using namespace std;
int dp[100100];
void init() {
  memset(dp, 0x8f, sizeof dp);
  dp[0] = 1;
  for(int i = 0;i <= 5; i++) {
    for(int j = 100 + i; j <= 100000; j++) {
      dp[j] = max(dp[j], dp[j-100-i]);
    }
  }
}
int main() {
  init();
  int n;
  cin >> n;
  if(dp[n] == 1) cout << 1 << endl;
  else cout << 0 << endl;
}

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

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

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (to_string(i).length() % 2 == 1) ans++;
    }

    cout << ans << endl;
}


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

int main() {
  int n,m;
  cin>>n>>m;
  vector<int> x(m);
  rep(i,m)cin>>x[i];
  /////////////////////
  int ans=0;
  //最初のコマは最小値に置く
  sort(all(x));  
  vector<int> y(m-1);
  rep(i,m-1) y[i]=x[i+1]-x[i];// 右隣との差
  sort(all(y)); 
  if(m>n){
      rep(i,m-n){       //m-1-(n-1)
        ans+=y[i];
      }
  }
  
  
  
  
  
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <cstdio>  // {{{
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>

#define GET_MACRO(a, b, c, d, NAME, ...) NAME
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REP2(i, a) REP3(i, 0, a)
#define REP3(i, a, b) REP4(i, a, b, 1)
#define REP4(i, a, b, s) for (int i = (a); i < (int)(b); i += (s))
#define REPR(...) GET_MACRO(__VA_ARGS__, REPR4, REPR3, REPR2)(__VA_ARGS__)
#define REPR2(i, a) REPR3(i, 0, a)
#define REPR3(i, a, b) REPR4(i, a, b, 1)
#define REPR4(i, a, b, s) for (int i = (b)-1; i >= (int)(a); i -= (s))
#define ALL(c) (c).begin(), (c).end()

using Int = long long;
// clang-format off
template<typename T,typename U>inline bool chmax(T&x,U a){return x<a&&(x=a,1);}
template<typename T,typename U>inline bool chmin(T&x,U a){return a<x&&(x=a,1);}
inline signed in(){signed x;scanf("%d",&x);return x;}
// clang-format on
// }}}

using namespace std;

const int MOD = 12;

int getRank(string& s) {
  if (s == "C") return 0;
  if (s == "C#") return 1;
  if (s == "D") return 2;
  if (s == "D#") return 3;
  if (s == "E") return 4;
  if (s == "F") return 5;
  if (s == "F#") return 6;
  if (s == "G") return 7;
  if (s == "G#") return 8;
  if (s == "A") return 9;
  if (s == "A#") return 10;
  if (s == "B") return 11;
}

int N, M;
int rankT[50500];
int rankB[50500];

bool solve(int n, int m) {
  if (m == -1) return n == -1;
  if (n < 0) return false;
  if (rankT[n] == rankB[m]) {
    if (solve(n - 1, m - 1)) return true;
  }
  if ((rankT[n] + 1) % MOD == rankB[m]) {
    if (solve(n - 2, m - 1)) return true;
  }
  if ((rankT[n] + MOD - 1) % MOD == rankB[m]) {
    if (solve(n + 1, m - 1)) return true;
  }
  return false;
}

signed main() {
  int T = in();
  REP(t, T) {
    N = in(), M = in();
    REP(i, N) {
      string S;
      cin >> S;
      rankT[i] = getRank(S);
    }
    REP(i, M) {
      string S;
      cin >> S;
      rankB[i] = getRank(S);
    }
    if (solve(N - 1, M - 1) || solve(N - 2, M - 1)) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5304
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

signed main() {
    vector<ll> a(3);
    REP(i,3) cin>>a[i];
    REP(i,3) {
        if(a[i]%2==0) {
            cout<<0<<endl;
            return 0;
        }
    }
    cout<<min(min(a[0]*a[1],a[0]*a[2]),a[1]*a[2])<<endl;
    return 0;
}


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

ll ans1, ans2, sum;
int n;
int a[100010];

int main() {
  cin >> n;
  rep(i, 0, n - 1) cin >> a[i];
  sum = 0;
  for (int i = 0, s = 1; i < n; i++, s *= -1) {
    sum += a[i];
    if (sum * s <= 0) {
      ans1 += abs(sum - s);
      sum = s;
    }
  }
  sum = 0;
  for (int i = 0, s = -1; i < n; i++, s *= -1) {
    sum += a[i];
    if (sum * s <= 0) {
      ans2 += abs(sum - s);
      sum = s;
    }
  }
  cout << min(ans1, ans2) << endl;
}


Measured memory_bytes: 640
#include <stdio.h>

int big = 0;
unsigned int small = 0;

const unsigned int BASE = 2147483648;


void sub(unsigned int a)
{
	if (big < 0) {
		if (small + a > BASE) {
			big--;
			small = small + a - BASE;
		} else {
			small += a;
		}
	} else {
		if (small >= a) {
			small -= a;
		} else {
			big--;
			small = small + BASE - a;
		}
	}
}


void add(unsigned int a)
{
	if (big >= 0) {
		if (a + small >= BASE) {
			big++;
			small = (a + small) - BASE;
		} else {
			small += a;
		}
	} else {
		if (a + small >= BASE) {
			small = a + small - BASE;
			big++;
		} else {
			small += a;
		}
	}
}
int isZero()
{
	return small == 0 && big == 0;
}

int main()
{
	int i;
	int q;
	int p, n;
	char c;

	scanf("%d", &q);
	for (i = 0; i < q; i++) {
		scanf("%d %c %d", &p, &c, &n);
		if (c == '(') {
			add(n);
		} else {
			sub(n);
		}

		if (isZero()) {
			puts("Yes");
		} else {
			puts("No");
		}
	}
	return 0;
}

Measured memory_bytes: 0
N,M = (int(a) for a in input().split());
A = input();

A = A.split();


B = [int(s) for s in A];

sum = sum(B)

line = sum/4/M
point = 0;
length = len(B);

for i in range(length):
    if B[i] >= line:
        point += 1;
    else:
        pass;
    
if point >= M:
    print("Yes");
else:
    print("No");
        

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

#include <math.h> 
using namespace std;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(){
  int n;
  cin>>n;
  int k=0;
for(int i=n;i<n+10000;i++){
bool A=IsPrime(i);
  if(A){int k=i;
    cout << k <<endl;
        break;}
}

}


Measured memory_bytes: 3600
#include<cstdio>
using ll=long long;
ll gcd(ll a,ll b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    return a/gcd(a,b)*b;
}
// 1以上x以下の整数でyでもzでも割り切れないものの個数
ll count_anti_divisor(ll x,ll y,ll z){
    return x-x/y-x/z+x/lcm(y,z);
}
int main(){
    ll a,b,c,d;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
    printf("%lld\n",count_anti_divisor(b,c,d)-count_anti_divisor(a-1,c,d));
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.XPath;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            //// 文字列の入力
            //string s = Console.ReadLine();

            //// 整数の入力
            //long n = long.Parse(Console.ReadLine());

            //// 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            //// 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            var k = inputLongArray[0];
            var x = inputLongArray[1];

            var min = x - k + 1;
            var max = x + k - 1;

			if (min <= -1000000) {
                min = -1000000;
            }

			if (max >= 1000000) {
                max = 1000000;
            }

            string result = "";

            for (long n = min; n <= max; n++) {
                result += n.ToString();
                result += " ";
			}

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28156
#include<iostream>
using namespace std;
using ll = long long;

ll euclid(const ll& a, const ll& b){
    if(a % b == 0) return b;
    return euclid(b, (a%b));
}

int main(){
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    cout << (B - (B/C + B/D) + (B/(C*D/euclid(C,D)))) -
                (A-1 - ((A-1)/C + (A-1)/D) + ((A-1)/(C*D/euclid(C,D))));
}

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

const int inf = LLONG_MAX/2;

int32_t main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	vector<double> a(n);
	for (int i=0; i<n; ++i) cin >> a[i];
	vector<double> dp(n+1);
	dp[0] = 1;
	for (int i=0; i<n; ++i){
		for (int j=i+1; j>=0; --j){
			if (j-1 >= 0) dp[j] = a[i]*dp[j-1] + dp[j]*(1-a[i]);
			else dp[j] = dp[j]*(1-a[i]);
		}
	}
	double res = 0;
	for (int i=n/2+1; i<=n; ++i){
		res += dp[i];
	}
	cout.precision(10);
	cout << fixed;
	cout << res;
	return 0;
}


Measured memory_bytes: 3872
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <numeric>

using namespace std;


int main(){
   int n,k;
   cin>>n>>k;
   int ans=1;
   for(int i=0;i<n;i++){
      if(ans*2<ans+k)ans*=2;
      else ans+=k;
   }
   cout<<ans<<endl;
   

}

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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
  
  	ll X, Y;
  	cin >> X >> Y;
  
  	cout << X + Y/2 << endl;
  	
    

    return 0;
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define INF 1e8
#define ALL(a) a.begin(), a.end()
#define MAXEL max_element
#define MINEL min_element
#define POW (int)pow
#define BIT(i) (int)pow(2, i)

int main() {
  int n;
  cin >> n;
  int nAns = 0;
  REP(i, n) {
    int a;
    cin >> a;
    while (a % 2 == 0) {
      nAns++;
      a /= 2;
    }
  }
  cout << nAns << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
const int INF = 1001001001;


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

  size = S.length();

  string ans;
  ans = string(size, 'x');
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
s = str(input())
a = ['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']
if s in a:
    print('a')
else:
    print('A')

Measured memory_bytes: 9008
def main():
    N, M = map(int, input().split())
    E = [[] for _ in range(N + 1)]
    D = [0] * (N + 1)
    for _ in range(M):
        x, y = map(int, input().split())
        E[x].append(y)
        # Keeps number of input destinations for each output distination.
        D[y] += 1

    # topological sort
    Q = [i for i in range(1, N + 1) if D[i] == 0]
    L = []
    while Q:
        s = Q.pop()
        L.append(s)
        for r in E[s]:
            D[r] -= 1
            if D[r] == 0:
                Q.append(r)

    dp = [0] * (N + 1)
    for v in L:
        d = dp[v] + 1
        for k in E[v]:
            dp[k] = max(dp[k], d)
    print(max(dp))


main()


Measured memory_bytes: 65824
#include<iostream>
using namespace std;
int main() {

	//B
	long long int a, b, v, w, t;
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;
	if (v <= w) {
		cout << "NO" << endl;
		return 0;
	}
	if (abs(a - b) <= t * (v - w)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;

	//A
	/*string s;
	cin >> s;
	int i;
	for (i = 0; i < 3; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
	*/
}

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

int count2Dividable(int);

int main() {
  int n, count;
  count = 0;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    count += count2Dividable(a[i]);
  }
  cout << count << endl;
  return 0;
}

int count2Dividable(int n) {
  int count;
  count = 0;
  if(n%2 == 0) {
    count = count2Dividable(n/2) + 1;
  }
  return count;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> T(N);
    int amount=0;
    for(int i=0; i<N; i++){
        cin >> T[i];
        amount+=T[i];
    }
    int ans=amount, tmp=0;

    for(int i=0; i<N; i++){
        tmp+=T[i];
        amount-=T[i];
        ans=min(ans, abs(amount-tmp));
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;

int main() {

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

	int k, x;
	cin >> k >> x;
	int n = 2000001;
	k--;
	for (int i = x - k; i <= x + k; ++i) {
		cout << i << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,M=map(int,input().split())

# UnionFind

Group = [i for i in range(N)] # グループ分け
Nodes = [1]*N # 各グループのノードの数

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):
    if find(x) != find(y):
        if Nodes[find(x)] < Nodes[find(y)]:
            
            Nodes[find(y)] += Nodes[find(x)]
            Nodes[find(x)] = 0
            Group[find(x)] = find(y)
            
        else:
            Nodes[find(x)] += Nodes[find(y)]
            Nodes[find(y)] = 0
            Group[find(y)] = find(x)

for i in range(M):
    x,y=map(int,input().split())
    Union(x-1,y-1)

from collections import Counter

print(max(Counter([find(x) for x in range(N)]).values()))


Measured memory_bytes: 41768
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.stream.Collectors;

public class Main {

    int cnt = 0;

    void solve() {
        int n = io.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = io.nextInt();
        }
        mergeSort(S, 0, S.length);
        System.out.println(Arrays.stream(S).mapToObj(Integer::toString).collect(Collectors.joining(" ")));
        System.out.println(cnt);
    }

    void merge(int[] A, int left, int mid, int right) {
        final int INF = Integer.MAX_VALUE;
        int n1 = mid - left, n2 = right - mid;
        int[] L = new int[n1 + 1], R = new int[n2 + 1];
        for (int i = 0; i < n1; i++) {
            L[i] = A[left + i];
        }
        for (int i = 0; i < n2; i++) {
            R[i] = A[mid + i];
        }
        L[n1] = INF;
        R[n2] = INF;
        int i = 0, j = 0;
        for (int k = left; k < right; k++) {
            cnt++;
            if (L[i] <= R[j]) {
                A[k] = L[i];
                i += 1;
            } else {
                A[k] = R[j];
                j += 1;
            }
        }
    }

    void mergeSort(int[] A, int left, int right) {
        if (left + 1 < right) {
            int mid = (left + right) / 2;
            mergeSort(A, left, mid);
            mergeSort(A, mid, right);
            merge(A, left, mid, right);
        }
    }

    public static void main(String[] args) {
        new Main().solve();
    }

    IO io = new IO();

    class IO {
        private final int SIZE = 1 << 12;
        private final InputStream stream = System.in;
        private final byte[] buffer = new byte[SIZE];
        private int ptr = 0, buffLen = 0;

        private boolean hasNextByte() {
            if (ptr < buffLen) return true;
            ptr = 0;
            try {
                buffLen = stream.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return buffLen > 0;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isAscii(byte i) {
            return '!' <= i && i <= '~';
        }

        public char nextChar() {
            byte b = readByte();
            while (!isAscii(b)) b = readByte();
            return (char) b;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();
            byte b = readByte();
            while (isAscii(b)) {
                sb.append((char) b);
                b = readByte();
            }
            return sb.toString();
        }

        public int nextInt() {
            return Integer.valueOf(next());
        }

        public long nextLong() {
            return Long.valueOf(next());
        }

        public double nextDouble() {
            return Double.valueOf(next());
        }
    }
}



Measured memory_bytes: 121316
using System;
using System.Collections;

public class p0051
{
	p0051(){
		string str;
		char[] ch;
		int n, t;
		
		while((str=Console.ReadLine()) != null){
			n = int.Parse(str);
			while(0 < n--){
				ch = Console.ReadLine().ToCharArray();
				Array.Sort(ch);
				t = int.Parse(new string(ch));
				Array.Reverse(ch);
				
				Console.WriteLine("{0}", (int.Parse(new string(ch))-t));
			}
		}
	}
	
	public static int Main(string[] args){
		new p0051();
		return 0;
	}
}

Measured memory_bytes: 13896
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){
  string A;
  cin >> A;
  int apos, zpos;
  bool aflag=false;
  for(int i=0; i<A.length(); i++){
    if(A[i]=='A'&&!aflag){
      apos=i;
      aflag=true;
    }
    if(A[i]=='Z'&&aflag) zpos=i;
  }

  int ans = zpos-apos +1;
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <queue>
#include <map>
using namespace std;

#define INF int(1e9)

int t, n, x, y, sx, sy, ans;
bool used[500][500];
int used_min[500][500]; // minimum turn

int vx[6] = {0, 1, 1, 0, -1, -1},
    vy[6] = {1, 1, 0, -1, -1, 0};
/*
int dfs(int x, int y, int turn) {
    //cout << "now : " << x-250 << " " << y-250 << endl;
    used[x][y] = true;
    used_min[x][y] = (used_min[x][y] > turn) ? turn : used_min[x][y];

    if (turn == t) return 0;

    int ret = 0;

    for (int i = 0; i < 6; ++i) {
        int nx = x + vx[i], ny = y + vy[i];
        if (!used[nx][ny]) {
            ret += dfs(nx, ny, turn + 1);
            ret++;
        }
        else if (used[nx][ny] && used_min[nx][ny] >= turn) {
            ret += dfs(nx, ny, turn + 1);
        }
    }

    return ret;
}
*/

struct Tuple {
    int f, s, t;
    Tuple(int f, int s, int t) : f(f), s(s), t(t) {}
};

int bfs() {
    int ret = 0;
    queue<Tuple> que;
    que.push(Tuple(sx + 250, sy + 250, 0));
    used[sx + 250][sy + 250] = true;
    used_min[sx + 250][sy + 250] = 0;

    while (!que.empty()) {
        Tuple tpl = que.front();
        que.pop();

        //cout << "pos : " << tpl.f-250 << " " << tpl.s-250 << ", used is " << used[tpl.f][tpl.s] << endl;

        if (tpl.t > used_min[tpl.f][tpl.s]) continue;

        if (tpl.t == t) continue;

        for (int i = 0; i < 6; ++i) {
            int nx = tpl.f + vx[i], ny = tpl.s + vy[i];

            if (!used[nx][ny]) {
                ret++;
                que.push(Tuple(nx, ny, tpl.t + 1));
                used[nx][ny] = true;
                used_min[nx][ny] = tpl.t + 1;  
                //cout << "next : " << nx-250 << " " << ny-250 << endl;
            }
            else if (used[nx][ny] && used_min[nx][ny] > tpl.t + 1) {
                que.push(Tuple(nx, ny, tpl.t + 1));
                used_min[nx][ny] = tpl.t + 1;                
            }
        }
    }

    return ret;
}

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

    while (cin >> t >> n, t | n) {
        for (int i = 0; i < 500; ++i) {
            for (int j = 0; j < 500; ++j) {
                used[i][j] = false;
                used_min[i][j] = INF;
            }
        }

        for (int i = 0; i < n; ++i) {
            cin >> x >> y;
            x += 250; y += 250;
            used[x][y] = true;
            used_min[x][y] = -INF;
        }
        cin >> sx >> sy;

        //ans = dfs(sx + 250, sy + 250, 0);
        ans = bfs();

        cout << ans + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 4372
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;

set<string> sts;

int solve(string str, char tmp, int n) {
    if (str.size() == n) {
        sts.insert(str);
        return 0;
    }
    for (char c = 'a'; c <= tmp; c++) {
        solve(str + c, (c == tmp) ? (char)(tmp + 1) : tmp, n);
    }
    return 0;
}

int main() {
    int n; cin >> n;
    if (n == 1) {
        cout << "a\n"; 
        return 0;
    }
    solve("", 'a', n);
    for (auto& s : sts) cout << s <<"\n";
}

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

int main()
{
  int n, k, p, ans = 0;
  vector<int> pn;
  cin >> n >> k;
  while(cin >> p)
  {
    pn.push_back(p);
  }
  sort(pn.begin(), pn.end());
  for(int i=0; i<k; i++)
    ans += pn[i];
  
  cout << ans << endl;
  return 0;
}

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

class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        boolean[] color = new boolean[8];
        Arrays.fill(color, false);
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();

        }
        int other = 0;
        for (int i = 0; i < n; i++) {
            int rate = a[i];
            if (rate < 400) {
                color[0] = true;
            } else if (rate < 800) {
                color[1] = true;
            } else if (rate < 1200) {
                color[2] = true;
            } else if (rate < 1600) {
                color[3] = true;
            } else if (rate < 2000) {
                color[4] = true;
            } else if (rate < 2400) {
                color[5] = true;
            } else if (rate < 2800) {
                color[6] = true;
            } else if (rate < 3200) {
                color[7] = true;
            } else {
                other++;
            }

        }
        int in = 0;
        for (int i = 0; i < 8; i++) {
            if (color[i]) {
                in++;
                other++;
            }
        }
        if (in == 0) {
            in = 1;
        }
        System.out.println(in + " " + other);

        sc.close();
    }
}

Measured memory_bytes: 22996
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int h=s.nextInt(),w=s.nextInt();
		for(int i=1;i<=h;++i)
			for(int j=0;j<w;++j)
				if(s.next().equals("snuke"))
					System.out.println(""+(char)(j+'A')+i);
	}
}

Measured memory_bytes: 21972
#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 a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;

	int ans1 = 0, ans2 = 0;
	double nodo = 0;
	for(int A = 0; A <= 50; A++)
		for(int B = 0; B <= 50; B++){
			int mizu = (A*a+B*b);
			for(int C = 0; C <= 4000; C++)
				for(int D = 0; D <= 4000; D++){
					int sato = C*c + d*D;
					if(mizu*100 + sato > f) break;
					if(mizu*e < sato) break;
					double check = 100.0*sato/(mizu*100.0+sato);
					if(check >= nodo){
						nodo = check;
						ans1 = mizu*100 + sato;
						ans2 = sato;
					}
				}
		}

	cout << ans1 << " " << ans2 << endl;

	return 0;
}

Measured memory_bytes: 256
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 ll H, W, ans;
  cin >> H >> W;
  
  if(H == 1 || W == 1){
    ans = 1;
  }
  else{
    ans = (H * W + 1) / 2; 
  }
  cout << ans;






	return 0;
}


Measured memory_bytes: 3644
import math

N, M = list(map(int, input().split()))

l = abs(N - M)

# 列を作れないとき
if l >= 2:
    print(0)
    exit()

if l == 1:

    if N < M:
        _n = math.factorial(N)
        _m = _n * (M)
        ans = _n * _m
        print(ans%(10**9+7))
        exit()

    else:
        _m = math.factorial(M)
        _n = _m * (N)
        ans = _n * _m
        print(ans%(10**9+7))
        exit()



_n = math.factorial(N)
# _m = factorial(M)

ans = (_n * _n * 2) % (10**9+7)
print(ans)


Measured memory_bytes: 50416
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  int x = -100;
  int y = 100;
  int xx, yy;
  for (int i = 0; i < n; i++){
    cin >> xx;
    x = max(xx, x);
  }

  for (int i = 0; i < m; i++){
    cin >> yy;
    y = min(yy, y);
  }

  if ((x < y) && (X < y) && (Y > x))
    cout << "No War" << endl;
  else
    cout << "War" << endl;
}


Measured memory_bytes: 256
import { readFileSync } from 'fs'
import { reverse } from 'dns'
import { start } from 'repl'

function main(input: string[]) {
  let N = Number(input[0])
 
  // 26
  // 26 * 26 = 676        702
  // 26 * 26 * 26 = 17576 18278
  N--
  let startVal = 0
  let addVal = 26;
  while (1) {
    if (startVal <= N && N < startVal + addVal) {
      N -= startVal
      break;
    }
    startVal += addVal
    addVal *= 26
  }

  let ans = ""
  addVal /= 26
  while (1) {
    let ansOne = Math.floor(N / addVal)
    N -= ansOne * addVal
    ansOne += "a".charCodeAt(0)
    ans += String.fromCharCode(ansOne)
    if (addVal == 1) break
    addVal /= 26
  }
  // 18278 - 702 = 17576

  console.log(ans.toString())
}

let lines: string[] = [];
const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', function (line: string) {
  lines.push(line);
});
reader.on('close', function () {
  main(lines)
});


Measured memory_bytes: 30048
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>

using namespace std;

int n,t,e;
int a[101];
int main(void){
	scanf("%d%d%d",&n,&t,&e);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int i=1;
	for(i=1;i<=n;i++){
		for(int j=1;j*a[i]<=14400;j++){
			if(j*a[i]>=t-e && j*a[i]<=t+e){
				printf("%d\n",i);
				return 0;
			}
		}
		if(i==n)printf("-1\n");
	}
    return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
int n,k,a,b,c,ds,fa[200010],L[200010],R[200010],d;
int ask(int x){return x==fa[x]?x:fa[x]=ask(fa[x]);}
long long m;
int main(){
	scanf("%d%lld%d",&n,&m,&k);ds=n;
	for(int i=0;i<n;i++)fa[i]=i;
	while(k--){
		scanf("%d%d%d",&a,&b,&c);
		int p=ask(a),q=ask(b);
		if(c==0&&p!=q)ds--,fa[q]=p;
		if(c==1)L[++d]=a,R[d]=b;
	}
	for(int i=1;i<=d;i++)if(ask(L[i])==ask(R[i]))return puts("No"),0;
	puts((m+ds-n>1ll*ds*(ds-1)/2)||(d&&(ds==2||m<n))?"No":"Yes");
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
typedef long long int ll;


void input(){
   ll n, m; cin >> n >> m;
   vector<ll>a(n), b(n);
   map<ll, vector<ll> > m1;
   f(i, n){
    cin >> a[i] >> b[i];
    if(m - a[i] >= 0)m1[m - a[i] + 1].push_back(b[i]);
   }
   int sum = 0;
   priority_queue<int>pq;
   for(int i = m; i >= 1; --i){
      for(auto &it : m1[i]){
        pq.push(it);
      }
      if(!pq.empty()){
        sum += pq.top();pq.pop();
      }
   }
   cout << sum << endl;
}
int main()
{
 input();
 return 0;
}


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

long mod=1e9+7;

int main() {
int N;
string S;
cin>>N>>S;
N*=2;
string T=S;
if(S[0]=='B') T[0]='L';
else{
  cout<<0<<endl;
  return 0;
}
for(int i=0;i<N-1;i++){
  if(T[i]=='L'){
    if(S[i]=='B'&&S[i+1]=='B') T[i+1]='R';
    if(S[i]=='B'&&S[i+1]=='W') T[i+1]='L';
    if(S[i]=='W'&&S[i+1]=='B') T[i+1]='L';
    if(S[i]=='W'&&S[i+1]=='W') T[i+1]='R';
  }
  else if(T[i]=='R'){
    if(S[i]=='B'&&S[i+1]=='B') T[i+1]='L';
    if(S[i]=='B'&&S[i+1]=='W') T[i+1]='R';
    if(S[i]=='W'&&S[i+1]=='B') T[i+1]='R';
    if(S[i]=='W'&&S[i+1]=='W') T[i+1]='L';
  }
}

if(S[N-1]=='B'&&T[N-1]=='R') T[N-1]='R';
else{
  cout<<0<<endl;
  return 0;
}

int l=0,r=0;
for(int i=0;i<N;i++){
  if(T[i]=='L') l++;
  if(T[i]=='R') r++;
}

if(l==N/2&&r==N/2) r=0;
else{
  cout<<0<<endl;
  return 0;
}

long ans=1;
r=0;
for(int i=N-1;i>=0;i--){
  if(T[i]=='R') r++;
  if(T[i]=='L'){
    if(r>0) ans*=r,r--,ans%=mod;
    else{
      cout<<0<<endl;
      return 0;
    }
  }
}
for(int i=1;i<=N/2;i++){
  ans *=i;
  ans %= mod;
}
cout<<ans<<endl;
}


Measured memory_bytes: 772
#include <bits/stdc++.h>
using namespace std;
#define M (((int)1e9)+7)
int gcdExtended(int a, int b, int *x, int *y) 
{ 
    // Base Case 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    int x1, y1; // To store results of recursive call 
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    // Update x and y using results of recursive 
    // call 
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
int modInverse(int a, int m) 
{ 
    int x, y; 
    int g = gcdExtended(a, m, &x, &y); 
    if (g != 1) 
        cout << "Inverse doesn't exist"; 
    else
    { 
        // m is added to handle negative x 
        int res = (x%m + m) % m; 
        return res;//cout << "Modular multiplicative inverse is " << res; 
    } 
}
long long nCr(int n,int r)
{
	long long ans = 1; 
  
    for (int i = 1; i <= r; i += 1) { 
  
        // Divide simultaneously by 
        // i to avoid overflow 
        ans *= (n - r + i); 
        ans%=M;
        ans *= modInverse(i,M); 
        ans%=M;
    } 
    return ans%M;
}
int main() {
    // your code goes here
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    long long s,ans=0;
    cin>>s;
    for(int i=1;i<=s/3;i++)
    {
    	ans+=nCr(s-2*i-1,i-1);
    	ans%=M;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 9223372036854775807
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int n;
  cin >> n;
  ll sum = 0;
  int a[n],b[n];
  bool f = true;
  REP(i,n){
    cin >> a[i] >> b[i];
    sum += a[i];
    if(a[i] != b[i]) f = false;
  }
  
  if(f){
    cout << 0 << endl;
    return 0;
  }
  
  int mini = MOD;
  REP(i,n){
    if(a[i]>b[i]) mini = min(mini,b[i]);
  }
  
  cout << sum - mini << endl;

  return 0;
}

Measured memory_bytes: 384
from collections import deque

N = int(input())
nodes = []
G ={}
is_visited = {}
q = deque()

for _ in range(N):
    lst = list(map(int, input().split()))
    idx = lst[0]
    nodes.append(idx)
    is_visited[idx] = False
    degree = lst[1]
    if degree > 0:
        G[idx] = lst[2:]
    else:
        G[idx] = []

INF = 10**12
costs = [INF]*N
# bfs
# 初期queue
que = deque()  # 必要なものはnodeidと原点からの距離
que.append(1)
costs[0] = 0
while que:
    node_id = que.popleft()  # 先入れ先出し
    cost = costs[node_id-1]
    for next_id in G[node_id]:
        if (costs[next_id-1] == INF):
            que.append(next_id)
            costs[next_id-1] = cost + 1
        
for i in range(N):
    if costs[i] != INF:
        print(i+1, costs[i])
    else:
        print(i+1, -1)


Measured memory_bytes: 6032
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define pb push_back
#define mp make_pair 
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rrep(i,a,b) for(int i = a; i >=b; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
#define all(x) (x).begin(),(x).end()
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using ii = pair<int, int>;
using pli = pair<ll, int>;
using vi = vector<int>;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using pil = pair<int,ll>;
using vvi = vector<vi>;
using vpi = vector<ii>;

const int N = 100100;
ll mod=1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<ll> f(n+1);
    for(int i  = 1; i <= n; i++){
    ll cnt = 0;
    for(ll x = 1; x*x<= i; x++){
        for(ll y = 1; y*y <= i; y++){
            ll b = (x + y);
            ll d = 4*i - 3*x*x - 3*y*y - 2*x*y;
            if(d < 0) continue;
            long double root = sqrt((d));
            if((root - floor(root)) == 0){
                ll x = (ll)floor(root);
                if(x > b){
                    cnt++;
                }
            }
            f[i] = cnt;
        }
    }
    }
    rep(i,1,n){
        cout<<f[i]<<nl;
    }
    return 0;
}


Measured memory_bytes: 3668
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

int main(){
    int m,d=0,n,h,k,max=-100000,min=1000000000,ans=0,sum=0;
    string s,t;
    cin >> n >> s >> t;
    for(int i=0; i<n;i++){
        for(int j=0; i+j<n;j++){
            if(t[j]==s[i+j]){
                if(i+j==n-1 && min > i+n){
                    min = i + n;
                    break;
                }
                continue;
            }
            else{
                break;
            }
        }
    }
    if(min==1000000000)
        cout << n*2 << endl;
    else cout << min << endl;
    return 0;
}
  


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  char n[5];
  scanf("%s",&n);
  if (n[0] == n[1] && n[1] == n[2])
    printf("Yes");
  else if (n[1] == n[2] && n[2] == n[3])
    printf("Yes");
  else
    printf("No");
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

using static Input;
using static Util;
class Program
{
    static int N,W;
    static int[] w,v;
    static void INPUT()
    {
        N = NextInt();
        W = NextInt();
        w = new int[N];
        v = new int[N];
        for (int i = 0; i < N; i++)
        {
            w[i] = NextInt();
            v[i] = NextInt();
        }
    }

    static void OUT()
    {
        var dp = new long[N + 1, W + 1];
        for (int i = 0; i < N; i++)
        {
            for (int j = 0; j <= W; j++)
            {
                dp[i + 1, j] = Math.Max(dp[i + 1, j], dp[i, j]);
                if (j + w[i] > W) continue;
                dp[i + 1, j + w[i]] = Math.Max(dp[i + 1, j + w[i]], dp[i, j] + v[i]);
            }
        }

        Console.WriteLine(dp[N, W]);
    }
    static void Main(string[] args)
    {
#if DEBUG  
        //TESTINPUT();
        INPUT();

#else
        INPUT();
#endif
        OUT();
    }

    static void TESTINPUT()
    {
    }

}

public class Input
{
    public const long MOD = 1000000007;
    public const int INF = 1000000007;
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}

class Util
{

}




Measured memory_bytes: 88800
#include<iostream>
#include<algorithm>
#include<vector>
int N;
std::vector<int> L;
int ans;
int main(){
    std::cin>>N;
    for(int i=0;i<N*2;i++){
        int tmp;
        std::cin>>tmp;
        L.emplace_back(tmp);
    }
    std::sort(L.begin(),L.end());
    for(int i=0;i<N;i++){
        ans+=L[2*i];
    }
    std::cout<<ans<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    
int main() {
    int K,N;
    cin>>K>>N;
    vector<int> A(N+1);
    for (int i=0;i<N;i++) cin>>A.at(i);
    
    A.at(N) = K+A.at(0);
    int arch = 0;
    for (int i=0;i<N;i++) {
        arch = max(arch, A.at(i+1)-A.at(i));
    }

    cout << K - arch << endl;
}

Measured memory_bytes: 1024
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (n:k:_) <- fmap (map read . words) getLine :: IO [Int]
  hs <- fmap join $ replicateM n $ map read . words <$> getLine :: IO [Int]

  print $ solve k hs

solve k hs = minimum $ go sorted (drop (k-1) sorted)
  where
    sorted = sort hs
    go _ [] = []
    go (a:as) (b:bs) = (b - a):go as bs

Measured memory_bytes: 68988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int h,w;
	std::cin >> h>>w;
	std::vector<string> s(h);
	rep(i,h)std::cin >> s[i];
	rep(i,h){
		rep(j,2)std::cout << s[i] << std::endl;
	}
	
}


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

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int T=1;
//cin>>T;
while(T--){
int n;
cin>>n;
string c;
set<string> s;
while(n--){
    cin>>c;
    s.insert(c);
}
cout<<s.size();
}
return 0;
}
/*_*/

Measured memory_bytes: 19156
import math

a, b, C = map(int, input().split())
rad_C = math.radians(C)
c = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad_C))
h = b * math.sin(rad_C)
L = a + b + c
s = a * h / 2
print(s)
print(L)
print(h)

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

bool is_prime(int x)
{
    if (x <= 1)
        return false;
    for (int i = 2; i * i <= x; i++)
    {
        if (x % i == 0)
            return false;
    }
    return true;
}

int main()
{
    int x;
    cin >> x;
    while (!is_prime(x)){
        x++;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s1,s2="";
int main()
{
	cin>>s1;
	for(int i=s1.size()-1;i>=0;i--)s2+=s1[i];
	for(int i=0;i<s2.size();i++)
	{
		if(s2[i]=='b')s2[i]='d';
		else if(s2[i]=='d')s2[i]='b';
		else if(s2[i]=='p')s2[i]='q';
		else if(s2[i]=='q')s2[i]='p';
	}
	if(s1==s2)printf("Yes\n");
	else printf("No\n");
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int pow(int n, int exp){
	int result = 1;
	for (int i = exp; i != 0; i >>= 1){
		result *= result;
		if ((i & 1) == 1)
				result *= n;
	}
	return result;
}
int main(){
	int n, r;
	int max = -pow(10, 9);
  int min;
	cin >> n;
  cin >> min;
	for  (int i = 1; i < n; i++){
		cin >> r;
		if (max < r - min)
			max = r - min;
  	if (min > r)
  			min = r;
	}
	cout << max << endl;
}

Measured memory_bytes: 1164
S=list(input())

n=len(S)

a=int((n-1)/2)
b=int((n+3)/2)

A=S[0:a]
B=S[b-1:n]

if A==A[::-1] and B==B[::-1] and S==S[::-1]:
    print('Yes')
else :
    print('No')

Measured memory_bytes: 3064
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  
  vector<int> A(n),B(n+1);
  rep(i,n) cin>>A[i];
  
  stack<int> s;
  int ans=0;
  rep(i,n){
    if(A[i]>0){
      if(B[A[i]]==1){
        ans=i+1;
        break;
      }
      s.push(A[i]);
      B[A[i]]=1;
    }
    else{
      if(s.size()==0 || s.top()!=-A[i]){
        ans=i+1;
        break;
      }
      else{
        s.pop();
        B[-A[i]]=0;
      }
    }
  }
  
  if(ans) cout<<ans<<endl;
  else cout<<"OK"<<endl;
  
  return 0;
}


Measured memory_bytes: 3100
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	z := nextString()
	b := []byte(z)
	b[0]++
	fmt.Println(string(b))
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type pair struct {
	a, b int
}

type pairs []pair

func (p pairs) Len() int {
	return len(p)
}
func (p pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


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

int main() {
    int n, x, ans;
    while (true) {
        cin >> n >> x;
        ans = 0;
        if (n == 0 && x == 0) break;
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                int k = x - i - j;
                if (k <= n && k > j) ++ans;
            }
        }
        cout << ans << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const double PI= 2*asin(1);
int main(){
	double a,b,x;cin>>a>>b>>x;
	//cout<<M_PI<<endl;
	if(x>(a*a)*(b/2)){
		double ans=PI/2.0 -  atan((a*a*a)/(2.0*(a*a*b-x)));
		ans=ans*180.0/PI;
		printf("%.10f",ans);
		return 0;
	}else{
		//cerr<<"less"<<endl;
		double ans=atan2((a*b*b),(2.0*x))*180.0/PI;
		printf("%.10f",ans);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
		public static void main(String[] args) {
				Scanner sc = new Scanner(System.in);
				int w = sc.nextInt();
				int a = sc.nextInt();
				int b = sc.nextInt();
				if(a+w<b&&Math.abs(w+a-b)<Math.abs(w+b-a)){
					System.out.println(Math.abs(w+a-b));
				}else if(b+w<a&&Math.abs(w+a-b)>Math.abs(w+b-a)){
					System.out.println(Math.abs(w+b-a));
				}else{
					System.out.println(0);
				}
				
		}	
	}

Measured memory_bytes: 21972