akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		String[] strArray = new String[N];
		for (int i = 0; i < strArray.length; i++) {
			strArray[i] = sc.next();
		}
		Arrays.sort(strArray);
		System.out.println(Arrays.stream(strArray).collect(Collectors.joining()));
		sc.close();
	}
}

Measured memory_bytes: 28756
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		for(;;)
		{
			String str = scanner.next();
			if(str.equals("-"))
			{
				break;
			}
			
			int m = scanner.nextInt();
			for(int i=0; i<m; i++)
			{
				int h = scanner.nextInt();
				str = str.substring(h) + str.substring(0, h);
			}
			System.out.println(str);
		}
	}
}

Measured memory_bytes: 26056
#include <iostream>

int
main(int argc, char** argv) {
    int N, X;
    std::cin >> N >> X;

    int ans = 1;
    int D = 0;
    for (int i = 0; i < N; i++) {
        int L;
        std::cin >> L;

        D = D + L;
        if (D <= X) {
            ans++;
        } else {
            break;
        }

    }
    std::printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
// 4/30
// 過去問攻略

#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <math.h>
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    double minA, maxA, minB, maxB;

    minA = (double)A / 0.08;
    maxA = (double)(A + 1) / 0.08;

    minB = (double)B / 0.1;
    maxB = (double)(B + 1) / 0.1;

    // cout << "minA, maxA, minB, maxB = " << ceil(minA) << ", " << ceil(maxA) << ", " << minB << ", " << maxB << ", " << endl;

    // int value = maxB - 1;
    int ans = 0;
    bool have_answer = false;

    // while (have_answer) {
    //     if (value > minA) {
    //         value++;
    //     }
    // }

    for (int i = 0; i < 11000; i++) {
        if (i >= minA  && i >= minB && i < maxA && i < maxB) {
            ans = i;
            have_answer = true;
            break;
        }
    }

    if (have_answer) cout << ans << endl;
    else cout << -1 << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
bool valid(int x, int y, int n) {
	return x >= 0 && x < n&&y >= 0 && y < n;
}
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,-1,0,1 };
void fi(vector<vector<int>>&field, int x, int y) {
	int uad = 0;
	const int uy = y - 1;
	const int ux = x;
	for (int way = 0; way < 3; ++way) {
		if (valid(ux + dx[way], uy + dy[way], field.size()) &&
			field[uy][ux] == field[uy + dy[way]][ux + dx[way]])uad++;
	}
	if (uad == 0 || uad == 3)assert(false);
	else if (uad == 1) {
		field[y][x] = field[uy][ux];
	}
	else {
		field[y][x] = !field[uy][ux];
	}
}
void solve(vector<vector<int>>&field) {
	for (int n = 0; n < field.size(); ++n) {
		for (int k = 1; k <= n-1; ++k) {
			int nowy = k;
			int nowx = n - k;
			fi(field, nowx, nowy);
		}
	}
	for (int n = field.size(); n < 2 * field.size()-1; ++n) {
		for (int k = 1; k < 2*field.size()-n; ++k) {
			int nowy = k+n-field.size();
			int nowx = field.size()-k;
			fi(field, nowx, nowy);
		}
	}
}

int main() {
	while (1) {
		int N; cin >> N;
		long long int K; cin >> K;
		K--;
		if (!N)break;
		if (1ll << (N/2) <= K||N%2)cout << "No" << endl;
		else {
			bitset<64>bs(K);
			vector<vector<int>>field(N, vector<int>(N,-1));
			for (int i = 0; i < N/2; ++i) {
				for (int j = 0; j < 2; ++j) {
					field[0][i * 2+j ] = bs[N/2-1-i];
					field[i*2+j][0] = bs[N/2-1-i];
				}
			}
			solve(field);
			for (int y = 0; y < N; ++y) {
				for (int x = 0; x < N; ++x) {
					if (!field[y][x])cout << '.';
					else cout << 'E';
				}
				cout << endl;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
char s[1010],t[1010];
int main(){
	cin>>(s+1)>>(t+1);
	int lens=strlen(s+1),lent=strlen(t+1);
	int ans=INF;
	for(int i=1;i<=lens-lent+1;i++){
        int need=0;
        for(int j=1;j<=lent;j++){
        	if(s[i+j-1]!=t[j])need++;
        }
        ans=min(ans,need);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3592
function Main(input){
var S = input.split("\n")[0].split("");
var T = input.split("\n")[1].split("");
  var count = 0;
for(i=0;i<=2;i++){
  var j = S[i] == T[i];
  if(j==true){
    count += 1;
  }
}
console.log(count);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
MOD = 1000000007

n = input()
a = []
for _ in range(n):
    a.append(map(int, raw_input().split()))

# dp[S] cant de match usando |S| primeros hombres y S mujeres
dp = [0] * (1 << n)
dp[0] = 1
for mask in range(1, 1 << n):
    i = bin(mask).count('1') - 1  # bin(6) => 0x110
    for j in range(n):
        if a[i][j] == 1 and mask & (1 << j):
            dp[mask] += dp[mask ^ (1 << j)]
            dp[mask] %= MOD
print(dp[(1 << n) - 1])


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

int main(void){

    ll N; cin>>N;
    ll mindigit=11;
    ll tmpmax = 0;
    for (ll i = 1; i <= sqrt(N); ++i) {
        if(N % i == 0){
            ll j = N/i;
            tmpmax = max(int(log10(i)+1), int(log10(j))+1);
            mindigit = min(mindigit, tmpmax);
        }
    }

    cout<<mindigit<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string.h>
#include<utility>
#include<map>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n=0;
	cin >> n;
	int ar[n][3];
	for(int i=0;i<n;i++){
		for(int j=0;j<3;j++){
			cin >> ar[i][j];
		}
	}
	int br[n][3];
	br[0][0]=ar[0][0];
	br[0][1]=ar[0][1];
	br[0][2]=ar[0][2];
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			br[i][j]=ar[i][j] + max(br[i-1][(j+1)%3],br[i-1][(j+2)%3]);
			//cout << br[i][j] <<  " ";
		}
		//cout << endl;
	}
	cout << max(br[n-1][0],max(br[n-1][1],br[n-1][2]));
}

	

Measured memory_bytes: 2560
function move(x,arr){
var d1=arr[0];
var d2=arr[1];
var d3=arr[2];
var d4=arr[3];
var d5=arr[4];
var d6=arr[5];
var after=[];
if(x=="N")after=[d2,d6,d3,d4,d1,d5];
if(x=="S")after=[d5,d1,d3,d4,d6,d2];
if(x=="E")after=[d4,d2,d1,d6,d5,d3];
if(x=="W")after=[d3,d2,d6,d1,d5,d4];
return after;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var diceA=Arr[0].split(" ").map(Number);
var diceB=Arr[1].split(" ").map(Number);
var NSEW="NSEW".split("");

for(var i=0;i<100;i++){
   var r = Math.floor(Math.random () * 4) ;
   diceA=move(NSEW[r],diceA)
   var flag=diceA.every(function(v,i){return (v==diceB[i]);});
   if(flag)break;
}
console.log(flag?"Yes":"No");

Measured memory_bytes: 8440
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
    for(auto i=begin(v); i != end(v); ++i){
        if(i !=begin(v)) os << ' ';
        os << *i;
    }
    return os;
}

int main(){
    ll X,Y,C=0;
    cin >> X >> Y;
    if(X==1){
        C+=300000;
    }
    if(Y==1){
        C+=300000;
    }
    if(X==2){
        C+=200000;
    }
    if(Y==2){
        C+=200000;
    }
    if(X==3){
        C+=100000;
    }
    if(Y==3){
        C+=100000;
    }
    if(X==1 && Y== 1){
        C+=400000;
    }
    cout << C <<  endl;
}


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

int N, W;
long long w[110], v[110];

long long dp[110][100100];

int main() {
    cin >> N >> W;
    for (int i = 1; i <= N; i++) cin >> w[i] >> v[i];

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= W; j++) dp[i][j] = 0;
    }

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j <= W; j++) {
            dp[i][j] = max(dp[i][j], dp[i-1][j]);
            if (j - w[i] >= 0) {
                dp[i][j] = max(dp[i][j], dp[i-1][j - w[i]] + v[i]);
            }
        }
    }

    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

vector<vector<pair<LL, LL>>> tree; // pair<to, cost>
vector<LL> depth;

void dfs(LL v, LL p, LL d) {
  depth[v] = d;
  for (LL i = 0; i < tree[v].size(); i ++) {
    if (tree[v][i].first == p) continue;
    dfs(tree[v][i].first, v, d + tree[v][i].second);
  }
}

int main() {
  int n; cin >> n;
  tree = vector<vector<pair<LL, LL>>>(n);
  depth = vector<LL>(n);
  for (int i = 0; i < n - 1; i ++) {
    LL a, b, c;
    cin >> a >> b >> c;
    a --, b --;
    tree[a].push_back(make_pair(b, c));
    tree[b].push_back(make_pair(a, c));
  }

  LL q, k;
  cin >> q >> k;
  k --;
  dfs(k, -1, 0);
  for (int i = 0; i < q; i ++) {
    LL x, y;
    cin >> x >> y;
    x --, y --;
    cout << depth[x] + depth[y] << endl;
  }
}

Measured memory_bytes: 14336
S = input()
from collections import defaultdict
C = defaultdict(int)
for s in S:
    C[s] += 1
if C["R"] == 3:
    print(3)
elif C["S"] == 3:
    print(0)
elif C["R"] == 1:
    print(1)
else:
    if S == "RSR":
        print(1)
    else:
        print(2)

Measured memory_bytes: 64720
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<iterator>
#include<algorithm>
#include<functional>

typedef long long ll;
typedef std::map<char, int> string_type;
typedef std::map<string_type, int> type_occurences;

struct solver_abc_137_c {
	/*
	長さ 10 の文字列
	各文字は英小文字
	アナグラムの総数

	map<char, int> で種別にできる
	map<map<char, int>, int> で、種別別出現回数を数える
	N C 2 を全部足す
	*/
	string_type str2type(std::string &str) {
		string_type stype;
		for(std::string::iterator it = str.begin(); it != str.end(); ++it) {
			stype[*it] += 1;
		}
		return stype;
	}

	ll run(std::vector<std::string> &src) {
		std::stringstream ss;
		type_occurences occ;
		ll ans = 0, tmp;

		// count
		for(std::vector<std::string>::iterator it = src.begin(); it != src.end(); ++it) {
			occ[str2type(*it)] += 1;
		}

		for(type_occurences::iterator it = occ.begin(); it != occ.end(); ++it) {
			tmp = it->second;
			tmp = (tmp * (tmp -1)) / 2;
			ans += tmp;
		}

		return ans;
	}
};

int main(void) {
	solver_abc_137_c solver;
	int N;
	std::string sn;
	std::vector<std::string> src;

	std::cin >> N;
	for(int i = 0; i < N; ++i) {
		std::cin >> sn;
		src.push_back(sn);
	}

    std::cout << solver.run(src) << std::endl;

	return 0;
}


Measured memory_bytes: 56180
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N,T;
  cin>>N>>T;
  
  vector<pair<int,int>> P(N);
  for(int i=0;i<N;i++){
    cin>>P[i].first>>P[i].second;
  }
  
  int mini=10000000;
  
  
  for(int i=0;i<N;i++){
    if(P[i].second<=T){
      mini=min(mini,P[i].first);
    }
  }
  
  if(mini==10000000){
    cout<<"TLE"<<endl;
  }
  else{
    cout<<mini<<endl;
  }
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

using namespace std;
#define md 1000000007
#define itn int
#define pb push_back
#define mp make_pair
#define ull unsigned long long int
#define ll long long 
// #define int ll
#define ppi pair<int, int>
#define ppl pair<ll, ll>
#define vi vector<int>
#define all(x) x.begin(), x.end()
#define ff first
#define lb lower_bound
#define ub upper_bound
#define ss second
#define inf 1e9
#define enld '\n'
#define cuot cout
#define trace1(x) cerr << #x << ": " << x << endl
#define trace2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define trace3(x, y, z)                                                        \
  cerr << #x << ":" << x << " | " << #y << ": " << y << " | " << #z << ": "    \
       << z << endl
#define trace4(a, b, c, d)                                                     \
  cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
       << c << " | " << #d << ": " << d << endl
#define trace5(a, b, c, d, e)                                                  \
  cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
       << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl
#define trace6(a, b, c, d, e, f)                                               \
  cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": "   \
       << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | "   \
       << #f << ": " << f << endl
#define trace(v)                                                               \
  for (auto it = v.begin(); it != v.end(); it++)                               \
    cerr << *it << " ";                                                        \
  cerr << endl;
#define linf 1e18
#define reset(x) memset(x, 0, sizeof(x))
#define rep(i, a, b) for (int i = a; i < b; i++)

using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    oset;

void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

void solve()
{
    int n,k;cin>>n>>k;
    int a[n+1];
    rep(i,1,n+1)cin>>a[i];
    int dp[n+1];
    a[0]=inf;
    dp[0]=0;
    dp[1]=0;
    rep(i,2,n+1){
        dp[i]=inf;
        for(int j=max(1,i-k);j<i;j++){
            dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
        }
    }
    cout<<dp[n];
}

signed main() {
  fastio();
  int t;
  t = 1;
  // cin >> t;
  for (int i = 1; i <= t; i++) {
    // cout << "Case #" << i << ": ";
    solve();
  }
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  


int main() {
	string s,sc,sr;
	bool ans = true;
	cin >> s;
	sc = s;
	sr = s;
	reverse(sr.begin(), sr.end());
	if (sc != sr) {
		ans = false;
	}
	sc=sc.substr(0,(s.length()-1)/2);
	//cout << (s.length() - 1) / 2 << endl;
	sr = sc;
	reverse(sr.begin(), sr.end());
	if (sc != sr) {
		ans = false;
	}
	sc = s;
	sc=sc.substr((s.length() + 3) / 2-1);
	sr = sc;
	reverse(sr.begin(), sr.end());
	if (sc != sr) {
		ans = false;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")

#include <iostream>
#include <string>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <queue>
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define T3I tuple<int, int, int>
#define x first
#define y second
using namespace std;

typedef long long ll;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;

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

    string s;
    cin >> s;
    for(int i = 1; i < 3; ++i) {
        if(s[i] != s[0]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

int main()
{
    int w,a,b,c,d;
    scanf("%d %d %d",&w,&a,&c);
    b=a+w;d=c+w;
    if(c>b)
    {
        printf("%d\n",c-b);
    }
    else if(c>=a&&c<=b)
    {
        printf("0\n");

    }
    else if(c<a&&d>=a)
    {
        printf("0\n");
    }
    else
    {
        printf("%d\n",a-d);
    }
    return 0;
}


Measured memory_bytes: 128
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

l = [(x+9)//10*10 for x in [a,b,c,d,e]]
ans=sum(l)
ans-=max([abs(x-y) for x,y in zip(l, [a,b,c,d,e])])
print(ans)

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

const int MOD = 1e9 + 7;
const int N = 3e6 + 6;
ll fat[N];

void init(){
    fat[0] = 1LL;
    for(ll i = 1; i < N; i++){
        fat[i] = fat[i-1] % MOD * (ll) i % MOD;
        fat[i] %= MOD;
    }
}

ll fast(ll a, ll p){
    if(p == 1) return a % MOD;
    if(p&1) return ((a % MOD) * (fast(a, p-1) % MOD)) % MOD;
    int x = p / 2;
    ll t = fast(a, x);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll nck(ll n, ll k){
    if(n < k) return 0;
    if(k == 0) return 1;
    ll up = fat[n];
    ll a = fast(fat[k], MOD - 2);
    ll b = fast(fat[n-k], MOD - 2);

    ll prod = up % MOD * a % MOD;
    prod %= MOD;
    prod *= b;

    return prod % MOD;
}

int main(){
    fcin;

    init();

    ll i, j, i2, j2;
    cin >> i >> j >> i2 >> j2;

    ll a = nck(i2 + j2 + 2, i2 + 1) - nck(i2 + j + 1, i2 + 1);
    ll b = nck(i + j2 + 1, i) - nck(i + j, i);

    cout << (a - b + MOD) % MOD << endl;
    return 0;
}



Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
int A[1<<18];
struct Node
{
    int mx,se;
    Node operator + (const Node & rhs)
    {
        Node res=*this;
        if(rhs.mx>res.mx)res.se=res.mx,res.mx=rhs.mx;
        else if(rhs.mx>res.se)res.se=rhs.mx;

        if(rhs.se>res.mx)res.se=res.mx,res.mx=rhs.se;
        else if(rhs.se>res.se)res.se=rhs.se;
        return res;
    }
}f[1<<18];
int Ans[1<<18];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<(1<<n);i++)
    {
        scanf("%d",&A[i]);
        f[i].mx=A[i];
    }
    for(int i=1;i<(1<<n);i<<=1)
        for(int j=0;j<(1<<n);j++)
            if(j&i)f[j]=f[j]+f[j^i];
    for(int i=1;i<(1<<n);i++)
    {
        Ans[i]=max(Ans[i-1],f[i].mx+f[i].se);
        cout<<Ans[i]<<'\n';
    }

    return 0;
}


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    int n;
    cin >> n;
    int a=0,b=0,c=0,d=0;
    rp(i,n){
        string s;
        cin >> s;
        if(s=="AC") a++;
        if(s=="WA") b++;
        if(s=="TLE") c++;
        if(s=="RE") d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstring>
#include<cstdio>
#include<algorithm>
using namespace std;

#define INF -10005
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define DEBUG 



int main(void){
	int k,t,a[200],ans=0;
	cin>>k;
	cin>>t;
	REP(i,t){
		scanf("%d",&a[i]);
	}
	REP(i,t){
		if(2*a[i]>k+1){
			ans=2*a[i]-(k+1);
			break;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <assert.h>
#include <memory.h>
#include <queue>
#include <string.h>
#include <map>
using namespace std;
#define ll long long
void solve() {
  long long n,k;scanf("%lld %lld ",&n,&k);
  if(k<=(n+1)/2) {
    vector<long long> a,b,c;
    for(int i=0;i<n;++i) {
      a.push_back(k+i);
      b.push_back(k+i+n);
      c.push_back(k+i+n+n);
    }
    vector<pair<ll ,pair<ll,ll> > >q;
    int mid = n/2;
    if(n&1) {
      for(int i=mid;i<n;++i) {
        q.push_back(make_pair(a[i]+b[i-mid],make_pair(a[i],b[i-mid])));
      }
      for(int i=0;i<mid;++i) {
        q.push_back(make_pair(a[i]+b[i+mid+1],make_pair(a[i],b[i+mid+1])));
      }
    } else {
      for(int i=mid;i<n;++i) {
        q.push_back(make_pair(a[i]+b[i-mid],make_pair(a[i],b[i-mid])));
        q.push_back(make_pair(a[i-mid]+b[i],make_pair(a[i-mid],b[i])));
      }
    }
    sort(q.begin(),q.end());
    for(int i=0;i<n;++i) {
      printf("%lld %lld %lld\n", q[i].second.first,q[i].second.second,c[i]);
    }
  } else {
    printf("-1\n");
  }
}

int main() {
  //freopen("input.txt","r",stdin);
  solve();
  return 0;
}


Measured memory_bytes: 8024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a1 = Integer.parseInt(sc.next());
		int a2 = Integer.parseInt(sc.next());
		int a3 = Integer.parseInt(sc.next());
		int cnt;
		cnt = a1 + a2 + a3;
		if(cnt < 22) {
			System.out.println("win");
		}else {
			System.out.println("bust");
		}
	}

}

Measured memory_bytes: 23252
package main

import "fmt"

func main() {
  var n int
  fmt.Scan(&n)
  currency := map[string]float64{
    "JPY": 1.0,
    "BTC": 380000.0,
  }
  var (
    x, sum float64
    u      string
  )

  for i := 0; i < n; i++ {
    fmt.Scan(&x, &u)
    sum += x * currency[u]
  }
  fmt.Println(sum)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

ll C[51][51];

void comb_table(ll N) {
    for (ll i = 0; i <= N; i++) {
        for (ll j = 0; j <= i; j++) {
            if (j == 0 or j == i) C[i][j] = 1LL;
            else C[i][j] = (C[i-1][j-1] + C[i-1][j]);
        }
    }
}

int main()
{
    ll N, A, B;
    cin >> N >> A >> B;
    const int NMAX=50;
    vll v(N); rep(i, N) cin >> v[i];
    comb_table(NMAX);

    sort(all(v));
    reverse(all(v));

    double max_average = 0;
    rep(i, A) {
        max_average += v[i];
    }
    max_average /= A;

    ll a_th_val_num = 0, a_th_val_pos = 0;
    rep(i, N) {
        if (v[i] == v[A-1]) {
            a_th_val_num++;
            if (i < A) a_th_val_pos++;
        }
    }

    ll cnt = 0;
    if (a_th_val_pos == A) {
        for (a_th_val_pos = A; a_th_val_pos <= B; a_th_val_pos++) cnt += C[a_th_val_num][a_th_val_pos];
    } else {
        cnt += C[a_th_val_num][a_th_val_pos];
    }

    cout.precision(20);
    cout << fixed << max_average << endl;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
n,m=map(int,input().split())
x=[int(i) for i in input().split()]
v=[[] for i in range(m)]
for i in x:v[i%m].append(i)
a=0
for i in range(1,m//2+m%2):
  x,y=v[i],v[m-i]
  d=len(x)-len(y)
  if d<0:d,x,y=-d,y,x
  c=sorted([p[1] for p in Counter(x).items()])
  p=0
  for t in c:p+=t//2
  a+=len(y)+min(p,d//2)
a+=len(v[0])//2+(1-m%2)*len(v[m//2])//2
print(a)

Measured memory_bytes: 76908
#include <bits/stdc++.h>
#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;

int power(int n) {
	if(n == 0) return 0;
	int res = 1;
	rep(i, n) res *= 10;
	return res;
}

bool check(int n, int s, int c) {
	vector<int> v;
	if(n == 0) v.push_back(0);
	else while(n) {
		v.push_back(n % 10);
		n /= 10;
	}
	reverse(all(v));
	// rep(i, v.size()) cout << v[i] << " ";
	if(v[s-1] == c) return true;
	else return false;
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> s(m), c(m);
	rep(i, m) cin >> s[i] >> c[i];
	for(int i = power(n-1); i < power(n); i++) {
		bool ok = true;
		rep(j, m) {
			if(!check(i, s[j], c[j])) ok = false;
		}
		// cout << i << endl;
		if(ok) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int A, B, H, M;
double res;

int main()
{
    cin >> A >> B >> H >> M;

    res = sqrt(A * A + B * B - 2 * A * B * cos(abs((H * 30 + M * 0.5) - (M * 6)) * PI / 180));
    cout << fixed << setprecision(9) << res << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define nl "\n"
#define pb push_back
#define sp " "
typedef long long ll;
#define len(x) x.length()
#define vsort(x) sort(x.begin(), x.end();
using namespace std;
ll inf=2e18;

int main()

{

    ios::sync_with_stdio(false);
    cin.tie(0);
   // freopen("bruh.txt","r",stdin);
    double a, b;
    cin>> a >>b;
    double mn=a/.1, mx=b/.08;
    //cout<<mn<<mx<<nl;
    int bruh=(int)mx+1000;
    for(int i=(int )mn;i<=bruh;i++){
            //cout<<i*.08<<sp<<i*.1<<nl;
        if((int)(i*.08 )==a and  (int)(i*.1)==b){
            cout<<i<<nl;
            return 0;
        }
    }
    cout<<-1<<nl;
    }


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

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

	void run() {
		// long cur = System.currentTimeMillis();
		solver();
		// System.out.println(System.currentTimeMillis() - cur + "ms");
	}

	int N;

	@SuppressWarnings("rawtypes")
	void solver() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		ans = N - 1;
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}
		pow10[0] = 1;
		for (int i = 1; i <= 10; i++) {
			pow10[i] = 10L * pow10[i - 1];
		}
		factorial[0] = 1;
		for (int i = 1; i <= 10; i++) {
			factorial[i] = factorial[i - 1] *(long) i;
		}
		memo=new int[(int)factorial[N]];
		Arrays.fill(memo, -1);
		enumerate(A);
		Arrays.sort(A);
		second = true;
		enumerate(A);
		System.out.println(ans);
	}

	int ans;
	boolean second = false;

	long[] pow10 = new long[11];
	int[] memo;
	long[] factorial = new long[11];

	ArrayList<Long> enumerate(int[] A) {
		long a = to_long(A);
		ArrayDeque<Long> cur_que = new ArrayDeque<>();
		cur_que.add(a);
		ArrayDeque<Long> next_que = new ArrayDeque<>();
		ArrayList<Long> ret = new ArrayList<>();
		ret.add(a);
		int index = numbering(to_array(a));
		if (memo[index] != -1) {
			ans = Math.min(memo[index], ans);
		}

		memo[index] = 0 + (second ? 10 : 0);
		for (int i = 1; i <= N / 2 - ((N % 2 == 0) ? 1 : 0); i++) {
			while (!cur_que.isEmpty()) {
				long cur = cur_que.poll();
				for (int j = 0; j < N; j++) {
					for (int k = j + 1; k < N; k++) {
						int[] tmp = to_array(cur);
						int s = j, t = k;
						while (s < t) {
							int dummy = tmp[s];
							tmp[s] = tmp[t];
							tmp[t] = dummy;
							s++;
							t--;
						}
						long dummy = to_long(tmp);
						int idx = numbering(tmp);
						if (memo[idx] == -1) {
							next_que.add(dummy);
							memo[idx] = i + (second ? 100 : 0);
						} else if (memo[idx] < 100 && second) {
							ans = Math.min(memo[idx] + i, ans);
						}
					}
				}
			}
			ret.addAll(next_que);
			cur_que.addAll(next_que);
			next_que.clear();
		}
		return ret;
	}

	int numbering(int[] permutation) {
		int ret = 0;
		for (int i = 0; i < permutation.length; i++) {
			int count = 0;
			for (int j = i - 1; j >= 0; j--) {
				if (permutation[i] > permutation[j])
					count++;
			}
			ret += factorial[i] * count;
		}
		return ret;
	}

	long to_long(int[] array) {
		long ret = 0;
		for (int i = 0; i < array.length; i++) {
			ret += pow10[array.length - 1 - i] * array[i];
		}
		return ret;
	}

	int[] to_array(long a) {
		int[] ret = new int[N];
		int pos = N - 1;
		while (a > 0) {
			ret[pos--] = (int) (a % 10);
			a /= 10;
		}
		return ret;
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 119724
object Main extends App {


  val Array(h, w) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
  val s = (1 to h).map { _ => scala.io.StdIn.readLine }

  var ruisekihidari = Array.ofDim[Int](h, w)
  var ruisekimigi = Array.ofDim[Int](h, w)
  var ruisekiue = Array.ofDim[Int](h, w)
  var ruisekisita = Array.ofDim[Int](h, w)

  var ans = 0

  (0 until h).foreach { i =>
    (0 until w).foreach { j =>
      // 左計算
      if (j == 0) {
        // 一番左
        ruisekihidari(i)(j) = 0
      } else if (s(i)(j - 1) == '#') {
        ruisekihidari(i)(j) = 0
      } else {
        ruisekihidari(i)(j) = ruisekihidari(i)(j - 1) + 1
      }

      //逆でやらないと行けない
      // 右計算
      val ii = h - i - 1
      val jj = w - j - 1
      // println(ii + ":" + jj)

      if (jj == w - 1) {
        // 一番右
        ruisekimigi(ii)(jj) = 0
      } else if (s(ii)(jj + 1) == '#') {
        ruisekimigi(ii)(jj) = 0
      } else {
        ruisekimigi(ii)(jj) = ruisekimigi(ii)(jj + 1) + 1
      }

      // 上計算
      if (i == 0) {
        // 一番上
        ruisekiue(i)(j) = 0
      } else if (s(i - 1)(j) == '#') {
        ruisekiue(i)(j) = 0
      } else {
        ruisekiue(i)(j) = ruisekiue(i - 1)(j) + 1
      }

      // 下計算
      //逆でやらないと行けない
      if (ii == h - 1) {
        // 一番右
        ruisekisita(ii)(jj) = 0
      } else if (s(ii + 1)(jj) == '#') {
        ruisekisita(ii)(jj) = 0
      } else {
        ruisekisita(ii)(jj) = ruisekisita(ii + 1)(jj) + 1
      }
    }
  }
  /*
    println(ruisekihidari.deep)
    println(ruisekimigi.deep)
    println(ruisekiue.deep)
    println(ruisekisita.deep)
   */
  (0 until h).foreach { i =>
    (0 until w).foreach { j =>
      if (s(i)(j) != '#') {
        val tmp = 1 + ruisekihidari(i)(j) + ruisekimigi(i)(j) + ruisekiue(i)(j) + ruisekisita(i)(j)
        ans = List(ans, tmp).max
      }
    }
  }

  println(ans)
}


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

typedef long long ll;

#define v(T) vector<T>
#define ttt(T) tuple<T, T, T>
#define pb push_back
#define mp make_pair
#define rep(i, s, n) for(int i=s;i<n;i++)
#define repeq(i,s,n) for(int i=s;i<=n;i++)
#define poiu(n) for(int i=0; i < n; i++)
#define MOD 1000000007
#define endl '\n'

template<typename T>
void max_self(T& a, T b) { a=a>b?a:b; }
template<typename T>
void min_self(T& a, T b) { a=a<b?a:b; }

using namespace std;

int n;
int k;

int distances[200005];


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

    cin >> k >> n;
    for(int i=0; i<n; ++i) cin >> distances[i];
    
    int curr_min = 0x3f3f3f3f;
    for(int i=1; i<n; ++i) {
        min_self(curr_min, k-(distances[i]-distances[i-1]));
    }
    min_self(curr_min, k-(k-distances[n-1]+distances[0]));
    cout << curr_min << endl;



    return 0;

}



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

struct LCA {
    const int n = 0;
    const int log2_n = 0;
    vector<vector<int>> g;
    vector<vector<int>> par;  // par[2^i上][頂点v]
    vector<int> dep;

    void dfs(int v, int p, int d) {
        par[0][v] = p;
        dep[v] = d;
        for(auto to: g[v]) {
            if(to == p) continue;
            dfs(to, v, d+1);
        }
    }

    LCA() {}
    LCA(int n) : n(n), log2_n(log2(n)+1), g(n),
        par(log2_n, vector<int>(n)), dep(n) {}

    void add_edge(int u, int v) {
        g[u].push_back(v);
        g[v].push_back(u);
    }

    void build(ll root=0) {
        dfs(root, -1, 0);
        for(int i=0; i+1 < log2_n; ++i) {
            for(int j = 0; j < n; ++j) {
                if(par[i][j] < 0) par[i+1][j] = -1;
                else par[i+1][j] = par[i][par[i][j]];
            }
        }
    }

    int get(int u, int v) {
        if(dep[u] > dep[v]) swap(u, v);
        rep(i, log2_n) {
            if((dep[v] - dep[u]) >> i & 1) {
                v = par[i][v];
            }
        }
        if(u == v) return u;
        for(int i=log2_n-1; i>=0; --i) {
            if(par[i][u] != par[i][v]) {
                u = par[i][u];
                v = par[i][v];
            }
        }
        return par[0][u];
    }
};

int N;
struct node{
	node*l,*r;
	int cnt;
	node*update(int,int,int,int);
}pool[5000000];

node*nx(){
	static int p=0;
	return &pool[p++];
}
node*null;

void init(int n){
	N=1;while(N<n)N<<=1;
	null=nx();
	null->l=null->r=null;
}
node* node::update(int k,int x,int l=0,int r=N){
	if(k<l||r<=k)return this;
	if(r-l==1){
		node*n=nx();
		n->cnt=this->cnt+x;
		return n;
	}
	node*n=nx();
	n->l=this->l->update(k,x,l,(l+r)/2);
	n->r=this->r->update(k,x,(l+r)/2,r);
	n->cnt=n->l->cnt+n->r->cnt;
	return n;
}

int n,q;
node*seg[200000];

vector<int>E[200000];
int x[200000];

void dfs(int v,int p){
	seg[v]=(p==-1?null:seg[p])->update(x[v],1);
	for(int u:E[v]){
		if(u==p)continue;
		dfs(u,v);
	}
}

int lower_bound(node*a,node*b,node*p,int val,int x,int l=0,int r=N){
	if(r-l==1)return l;
	int lc=a->l->cnt+b->l->cnt-2*p->l->cnt+(l<=val&&val<(l+r)/2);
	if(lc>=x)return lower_bound(a->l,b->l,p->l,val,x,l,(l+r)/2);
	return lower_bound(a->r,b->r,p->r,val,x-lc,(l+r)/2,r);
}

int main(){
	scanf("%d%d",&n,&q);
	LCA lca(n);
	vector<int>xs;
	rep(i,n){
		scanf("%d",&x[i]);
		xs.push_back(x[i]);
	}
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	init(xs.size());
	rep(i,n){
		x[i]=lower_bound(xs.begin(),xs.end(),x[i])-xs.begin();
	}
	rep(i,n-1){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		lca.add_edge(a,b);
		E[a].push_back(b);
		E[b].push_back(a);
	}
    lca.build();
	dfs(0,-1);
	rep(i,q){
		int a,b,c;scanf("%d%d%d",&a,&b,&c);a--;b--;
		int p=lca.get(a,b);
		printf("%d\n",xs[lower_bound(seg[a],seg[b],seg[p],x[p],c)]);
	}
}


Measured memory_bytes: 69952
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>

#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
typedef pair<int, int> P;

int main()
{
	double L;
	cin >> L;
	double three = 3;
	L = L /= three;

	double ans = L * L * L;
	printf("%.10f\n", ans);
	
	return 0;
}

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

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) for(auto x:obj)cout<<x<<' ';cout<<endl;
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	if(!(a%2) || !(b%2) || !(c%2)){cout<<0<<endl; return 0;}
	cout<<min({a*b, b*c, c*a})<<endl; 
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    s = [x for x in input()]
    t = [x for x in input()]
    s.sort()
    t.sort(reverse=True)
    if s < t:
        print("Yes")
    else:
        print("No")



    

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""



"""


Measured memory_bytes: 9308
#include <bits/stdc++.h>
using namespace std;
#define INF 2147483647
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,m,n) for(long long i=m;i<n;i++)
#define rep(i,n) for(long long i = n-1;i>=0;i--)
#define repp(i,m,n) for(long long i = n-1; i >= m; i--)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int N,K;
string S;
bool flag = 0,flag1 = 0;
string T = "";
int ans = 0;
void solve(int X,int Y){
  	T = "";
    repp(i,X+1,Y+1){
      	if(T.size() == 0 && S[i] == 'L') T = 'R';
      	else if(T.size() == 0 && S[i] == 'R') T = 'L';
        else if(S[i] == 'L') T += 'R';
        else T += 'L';
    }
    REPP(i,X+1,Y+1){
      	int p = 0;
        S[i] = T[p];
      	p++;
    }

    flag = 1;
  	ans++;
}

int main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> N >> K;
    cin >> S;
  	if(S.size() == 1){cout << 0 << endl; return 0;}
  	else if(S.size() == 2){
      	if(S[0] == S[1]){cout << 1 << endl; return 0;}
      	else{cout << 0 << endl; return 0;}
    }
    REP(k,min(K,200)){
        REP(i,S.size()-2){
            flag = 0;
            if(S[i] != S[i+1]){
                REPP(j,i+1,S.size()-1){
                    if(S[j] == S[i+1] && S[j+1] == S[i]){solve(i,j); break;}
                }
            }
          	if(ans == K) break;
        }
    }
    int cnt = 0,maxv = 0,var = 0;
    REP(i,S.size()-1){
      	if(S[i] == S[i+1]) maxv++;
      	else{
          	var = maxv;
          	maxv = 0;
        }
      
        if(S[i] == S[i+1]) cnt++;
    }
  	if(K - ans >= 1 && maxv + var == N-2) cout << N-1 << endl;
    else cout << cnt << endl;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b[]=new int[a];
	for(int i=0;i!=a;i++) {
		b[i]=scan.nextInt();
	}
	int ans=0;
	loop:for(;;) {
	for(int i=0;i!=a;i++) {
		if(i==a-1) {
			ans++;
		}
		if(b[i]%2==1) {
			System.out.println(ans);
			break loop;
		}
		else {
			b[i]/=2;
		}
	}
	}
}
}

Measured memory_bytes: 22868
def counting_sort(a, b, k)
	c = Array.new(k+1,0)

	a.each { |j|
		c[j] += 1
	}
	
	for i in 1..k
		c[i] = c[i] + c[i-1]
	end
	
	(0..$n-1).reverse_each { |j|
		aj = a[j]
		caj=c[aj]-1
		b[caj] = a[j]
		c[aj] -= 1
	}
end

$n = gets.to_i
a = gets.split(" ").map(&:to_i)

b = Array.new
counting_sort(a, b, a.max)

puts b.join(" ")

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

int took(int a,int b){return a%b==0?b:took(b,a%b);}

int main(void)
{
	vector <int > V;
	int n,x;
		cin >> n >> x;
	
	for(int i=0;i<n;i++){
		int g;
		cin >> g;
		V.push_back(g);
	}
	V.push_back(x);
	sort(V.begin(),V.end());
	
	
	int ans=V[1]-V[0];
	for(int i=1;i<n;i++)
		ans=took(ans,V[i+1]-V[i]);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 892
program kadai
implicit none
integer  ::  a,b,i,k


read(*,*) a,b

if (a<b) then
    k=b
else if (a>b) then
    k=a
end if

do while(k>0)
    if (abs(a-k)==abs(b-k)) then
        write(*,*) k
        stop
    end if
    k=k-1
end do

write(*,*) "IMPOSSIBLE"


stop

end program kadai

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.replace(/\n$/,"")).split("\n");
while(true){
   var str=Arr.shift();
   if(str=="0")break;
   var arr=str.split("");
   var a=0;
   var b=0;
   arr.shift();
   arr.forEach(function(v){
      if(v=="A")a++;
      if(v=="B")b++;
   });
   (a>b)?a++:b++;
   console.log(a+" "+b);
}

Measured memory_bytes: 7648
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 100003, INF = 0x3f3f3f3f;
int n, k, fa[N], head[N], to[N << 1], nxt[N << 1], p[N], v[N], val[N];
inline void add(int a, int b){
	static int cnt = 0;
	to[++ cnt] = b; nxt[cnt] = head[a]; head[a] = cnt;
}
bool odd[N];
inline void dfs(int x){
	for(Rint i = head[x];i;i = nxt[i])
		if(to[i] != fa[x]){
			fa[to[i]] = x;
			odd[to[i]] = odd[x] ^ 1;
			dfs(to[i]);
		}
}
int l[N], r[N];
inline void dfs2(int x){
	if(val[x] < INF) l[x] = r[x] = val[x];
	else l[x] = -INF, r[x] = INF;
	for(Rint i = head[x];i;i = nxt[i])
		if(to[i] != fa[x]){
			dfs2(to[i]);
			l[x] = max(l[x], l[to[i]] - 1);
			r[x] = min(r[x], r[to[i]] + 1);
		}
}
inline void dfs3(int x){
	for(Rint i = head[x];i;i = nxt[i])
		if(to[i] != fa[x]){
			if(val[to[i]] == INF && val[x] + 1 >= l[to[i]] && val[x] + 1 <= r[to[i]]) val[to[i]] = val[x] + 1;
			else if(val[to[i]] == INF && val[x] - 1 >= l[to[i]] && val[x] - 1 <= r[to[i]]) val[to[i]] = val[x] - 1;
			else if(val[to[i]] == INF){puts("No"); exit(0);}
			dfs3(to[i]);
		}
}
int main(){
	scanf("%d", &n);
	for(Rint i = 1;i < n;i ++){
		int a, b;
		scanf("%d%d", &a, &b);
		add(a, b); add(b, a);
	}
	scanf("%d", &k);
	dfs(1);
	memset(val, 0x3f, sizeof val);
	for(Rint i = 1;i <= k;i ++){
		scanf("%d%d", p + i, v + i);
		val[p[i]] = v[i];
		if(i > 1 && (v[i] % 2 + odd[p[i]] % 2 + 4) % 2 != (v[i - 1] % 2 + odd[p[i - 1]] % 2 + 4) % 2){
			puts("No"); return 0;
		}
	}
	dfs2(1); val[1] = l[1];
	for(Rint i = 1;i <= n;i ++)
		if(l[i] > r[i]){puts("No"); return 0;}
	dfs3(1);
	puts("Yes");
	for(Rint i = 1;i <= n;i ++) printf("%d\n", val[i]);
}

Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
const ll N = 1e2+5;

int ans[N];
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%d\n",min(b/a,c));
    return 0;
}


Measured memory_bytes: 256
a = list(map(int,input().split(" ")))
b = list()

for i in range(a[0]):
    b.append(list(map(int,input().split(" "))))

c = sorted(b, key=lambda x:x[0])

ans = c[0][0]
tmp = 0


for i in range(a[0]):
    tmp = tmp + c[i][1]
    if tmp >= a[1]:
        ans = c[i][0]
        break

print(ans)

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<int> vi;

int main()
{
    vector< vector<int> > c(3, vector<int>(3, 0));

    REP (i, 3) REP (j, 3) cin >> c[i][j];

    int a[3] = {0, c[1][0] - c[0][0], c[2][0] - c[0][0]};
    int b[3] = {c[0][0], c[0][1], c[0][2]};

    bool flg = true;
    REP (i, 3)
    {
        REP (j, 3)
        {
            if (c[i][j] != a[i] + b[j])
            {
                flg = false;
                break;
            }
        }
        if (!flg) break;
    }

    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<unsigned char, unsigned char> pcc;
typedef pair<double, double> pdd;
typedef vector<vector<ll>> matrix;

const int MOD = 924844033;
ll fact[4005];
ll ifact[4005];

ll modpow(ll b, ll e, ll m) {
  ll r = 1;
  while(e) {
    if(e%2) {
      r*=b;
      r%=m;
    }
    b*=b;
    b%=m;
    e/=2;
  }
  return r;
}
ll combo(int n, int k) {
  ll ret = fact[n];
  ret *= ifact[k];
  ret %= MOD;
  ret *= ifact[n-k];
  ret %= MOD;
  return ret;
}
ll partition(int n, int k) {
  // how many solutions to x_1 + ... + x_k == n
  return combo(n+k-1, n);
}
void getFacs() {
  fact[0] = 1;
  for(int i = 1; i <= 4000; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= MOD;
  }
  ifact[4000] = modpow(fact[4000], MOD-2, MOD);
  for(int i = 3999; i >= 0; i--) {
    ifact[i] = ifact[i+1] * (i+1);
    ifact[i] %= MOD;
  }
}

ll dp[2005];
void solve() {
  getFacs();
  int n, k;
  cin >> n >> k;
  dp[0] = 1;
  for(int qq = 0; qq < 2; qq++) {
    for(int i = 0; i < k; i++) {
      int amt = 0;
      {
        int x = i+k;
        while(x < n) {
          amt++;
          x += k;
        }
      }
      vector<pii> ins;
      for(int l = 1; 2*l-1 <= amt; l++) {
        ll inc = partition(amt - (2*l-1), l+1);
        ins.push_back({l, (int)inc});
      }
      for(int x = n; x >= 0; x--) {
        for(pii out: ins) {
          if(x >= out.first) {
            dp[x] += dp[x-out.first] * out.second;
            dp[x] %= MOD;
          }
        }
      }
    }
  }
  ll ret = 0;
  for(int i = 0; i <= n; i++) {
    ll delta = fact[n-i];
    delta *= dp[i];
    delta %= MOD;
    if(i%2) ret += MOD-delta;
    else ret += delta;
    ret %= MOD;
  }
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ":" << "\n";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


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

int main() {
    string s;
    cin >> s;
    map<char, int> mp;
    for (int i = 0; i < s.size(); i++) mp[s[i]]++;
    if(abs(mp['a'] - mp['b']) > 1){
        cout << "NO" << endl;
    }else if(abs(mp['a'] - mp['c']) > 1){
        cout << "NO" << endl;
    }else if(abs(mp['c'] - mp['b']) > 1){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 512