akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#define FAST ios::sync_with_stdio(false);
#define pb push_back
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 5;
const int maxn = (int)1e6 + 5;
using namespace std;

int main()
{
	int a[5];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	cout << a[1] - a[0] + a[2] - a[1] << endl;
	return 0;
}

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

int main()
{
	double w;
	while(cin >> w)
	{
		if(w <= 48.0)
			cout << "light fly";
		else if(w <= 51.0)
		    cout << "fly";
		else if(w <= 54.0)
		    cout << "bantam";
		else if(w <= 57.0)
		    cout << "feather";
		else if(w <= 60.0)
		    cout << "light";
		else if(w <= 64.0)
		    cout << "light welter";
		else if(w <= 69.0)
		    cout << "welter";
		else if(w <= 75.0)
		    cout << "light middle";
		else if(w <= 81.0)
		    cout << "middle";
		else if(w <= 91.0)
		    cout << "light heavy";
		else
		    cout << "heavy";
		
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1220
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	A = getlist()
	D0 = defaultdict(int)
	D1 = defaultdict(int)
	for i in range(N):
		a = A[i]
		for j in range(61):
			if a % 2 == 0:
				D0[j] += 1
			else:
				D1[j] += 1
			a = int(a // 2)

	ans = 0
	for i in range(61):
		ans += (D0[i] * D1[i] * (2 ** i)) % con

	ans = ans % con
	print(ans)

if __name__ == '__main__':
	main()

Measured memory_bytes: 89712
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>pppp(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}
 
int main() {
  int64_t a,b,c;
  cin>>a>>b>>c;
  int64_t d=c-a-b;
  if(d>0&&d*d>4*a*b){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

Measured memory_bytes: 3628
H=int(input())
s = [list(map(int,input().split())) for _ in range(H)]

sum=0
flg=False

for i in s:
  if i[0]==i[1]:
    sum+=1
  elif i[0]!=i[1]:
    sum=0
  if sum==3:
    flg=True
    break

if flg==True:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9196
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        // 主処理
        String result = s;
        while (0 <= result.indexOf("B")) {
            result = result.replaceAll("^B", "");
            result = result.replaceAll("[01]B", "");
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 10**9

int main() {
    string s,t;
    bool flag=true;
    cin >> s >> t;
    rep(i,3){
        if (s.at(i)!=t.at(2-i)){
            flag = false;
            break;
        } 
    }
    if (flag){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a, b, c, temp;

        a = sc.nextInt();
        b = sc.nextInt();
        c = sc.nextInt();

        if(a > b){
            temp = a;
            a = b;
            b = temp;
        }
        if(b > c){
            temp = b;
            b = c;
            c = temp;
        }
        if(a > b){
            temp = a;
            a = b;
            b = temp;
        }
        
        System.out.println(a + " " + b + " " + c);

        sc.close();
    }
}


Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  string s="";
  ll k=2;
  ll a=1;
  while(n!=0){
    if(n%k!=0){
      s+='1';
      n-=a*(k/2);
    }
    else{
      s+='0';
    }
    k*=2;
    a*=-1;
  }
  if(s==""){
    cout << 0 << endl;
  }
  else{
    reverse(s.begin(),s.end());
    cout << s << endl;
  }
}

Measured memory_bytes: 256
S = input()
ans = [0]*len(S)
rcnt = 0
for i in range(len(S)):
  if S[i] == "R":
    rcnt += 1
    if S[i+1] == "L":
      ans[i] += (rcnt+1)//2
      ans[i+1] += rcnt//2
  else:
    rcnt = 0
lcnt = 0
for i in range(len(S))[::-1]:
  if S[i] == "L":
    lcnt += 1
    if S[i-1] == "R":
      ans[i] += (lcnt+1)//2
      ans[i-1] += lcnt//2
  else:
    lcnt = 0
print(*ans)

Measured memory_bytes: 6400
d = {
    'AC': 0,
    'WA': 0,
    'TLE': 0,
    'RE': 0
}

n = int(input())

for _ in range(n):
    res = input()
    d[res] += 1

for k, v in d.items():
    print('{} x {:d}'.format(k, v))


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int A1,A2,A3;
  cin>>A1>>A2>>A3;
  if(A1+A2+A3>=22)cout<<"bust"<<endl;
  else cout<<"win"<<endl;
  return 0;
}


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

int main() {
    ll a,b,c,k;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);
    ll ans = 0;
    if(a >= k) {
        ans = k;
        printf("%lld\n",ans);
    } else {
        ans += a;
        k -= a;
        if(b >= k) {
            printf("%lld\n",ans);
        } else {
            k -= b;
            ans -= k;
            printf("%lld\n",ans);
        }
    }
}

Measured memory_bytes: 3816
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.buffer.readline


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def f(c1, c2, c3):
    if memo[c1][c2][c3] != -1:
        return memo[c1][c2][c3]
    c0 = N - (c1 + c2 + c3)
    p0 = c0 / N
    ip0 = 1 - p0
    ret = 1 / ip0
    if c1 > 0:
        p1 = c1 / N
        ret += f(c1-1, c2, c3) * p1 / ip0
    if c2 > 0:
        p2 = c2 / N
        ret += f(c1+1, c2-1, c3) * p2 / ip0
    if c3 > 0:
        p3 = c3 / N
        ret += f(c1, c2+1, c3-1) * p3 / ip0
    memo[c1][c2][c3] = ret
    return ret


N = read_int()
A = read_int_n()
memo = [[[-1] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)]
memo[0][0][0] = 0
print(f(A.count(1), A.count(2), A.count(3)))


Measured memory_bytes: 414444
S = input()

if S[0] == 'R' and S[1] == 'R' and S[2] == 'R':
    ans = 3
elif (S[0] == 'R' and S[1] == 'R' and S[2] == 'S') or (S[0] == 'S' and S[1] == 'R' and S[2] == 'R'):
    ans = 2
elif S[0] == 'S' and S[1] == 'S' and S[2] == 'S':
    ans = 0
else:
    ans = 1

print(ans)


Measured memory_bytes: 9052
#include<stdio.h>

int main()
{
	unsigned int a,b,sum;
	unsigned char digits;

	while(scanf("%d %d",&a,&b) == 2)
	{
		sum = a + b;
		digits = 0;

		while(sum != 0)	
		{
			digits++;
			sum = sum / 10;
		}
		printf("%d\n",digits);
	}
	return 0;
}

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

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    ll tot = 0;
    ll lct = 1;
    ll rct = 1;
    if (s[0] == '>'){
        
        int k = 1;
        while (s[k] == '>'){        
            tot += rct;
            rct++;
            k++;
        }
        tot += rct;
    }
    if (s[s.size()-1] == '<'){
        
        int j = s.size()-2;
        while(s[j] == '<'){
                
            tot += lct; 
            lct++;
            j--;
        }
        tot += lct;
        
    }
    
    REP(i, s.size()-1){    

        if (s[i] == '<' && s[i+1] == '>'){
            lct = 1;
            rct = 1;
            int j = i-1;
            int k = i+2;
            while(s[j] == '<'){
                
                tot += lct; 
                lct++;
                j--;
            }
            while (s[k] == '>'){
                
                tot += rct;
                rct++;
                k++;
            }
            tot += max(rct, lct);
        }
    }
    cout << tot << endl;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i,N) cin >> S[i];
    map<string, int> memo;
    rep(i,N) memo[S[i]] += 1;
    cout << memo.size() << "\n";
    return 0;
}


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

// 1 21
int main() {
  string a, b;
  cin >> a >> b;

  string ab = a + b;
  int num = stoi(ab);

  int k=num, i = 0;

  while (k > 1) {
    k = num;
    i++;
    if (i * i == num) {
      cout << "Yes" << endl;
      return 0;
    }
    k /= i;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

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

  long long x;
  cin >> x;

  long long a = x / 11;
  int b = x % 11;

  if (b == 0) {
    cout << a * 2 << eol;
  } else if (b <= 6) {
    cout << a * 2 + 1 << eol;
  } else {
    cout << a * 2 + 2 << eol;
  }
  
  return 0;
}


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

namespace abc171_e
{
  class Program
  {
    static void Main(string[] args)
    {
      var N = CIn.ReadInt();
      var a = CIn.ReadIntArray(N);

      var xor = a.Aggregate((p, c) => p ^ c);

      var ans = a.Select(e => e ^ xor);

      Console.WriteLine(string.Join(' ', ans));
    }
  }

  static class CIn
  {
    private static readonly Queue<string> fieldBuffer = new Queue<string>();

    public static string Read()
    {
      if (fieldBuffer.Count == 0)
      {
        foreach (var field in Console.ReadLine().Split())
        {
          fieldBuffer.Enqueue(field);
        }
      }
      return fieldBuffer.Dequeue();
    }

    public static int ReadInt() => int.Parse(Read());
    public static long ReadLong() => long.Parse(Read());
    public static double ReadDouble() => double.Parse(Read());

    public static string[] ReadStringArray(int n)
    {
      var array = new string[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = Read();
      }
      return array;
    }

    public static int[] ReadIntArray(int n)
    {
      var array = new int[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadInt();
      }
      return array;
    }

    public static long[] ReadLongArray(int n)
    {
      var array = new long[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadLong();
      }
      return array;
    }

    public static double[] ReadDoubleArray(int n)
    {
      var array = new double[n];
      for (var i = 0; i < n; i++)
      {
        array[i] = ReadDouble();
      }
      return array;
    }

    public static char[,] ReadCharMatrix(int h, int w)
    {
      var array = new char[h, w];
      for (var i = 0; i < h; i++)
      {
        var l = Console.ReadLine().ToCharArray();
        for (var j = 0; j < w; j++)
        {
          array[i, j] = l[j];
        }
      }
      return array;
    }
  }
}


Measured memory_bytes: 69720
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
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; }
const ll INF=1LL<<60;

string s;

int main(){
    cin>>s;
    //int l=s.size();
    int ans=0;
    for(int i=2;s.size()-i>=2;i+=2){
        bool flag=true;
        rep(j,(s.size()-i)/2){
            if(s[j]!=s[(s.size()-i)/2+j]){
                flag=false;
                break;
            }
        }
        if(flag){
            ans=s.size()-i;
            break;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

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

int main (){
	int n;
	cin >> n;
	int a[114514];
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 0; i < n; i++){
		while (a[i]%2 == 0) {
			ans++;
			a[i]/=2;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/// In The Name Of God
/// I wish, that I could leave it all behind me / Go to my own world where no one can find me
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define pii pair <int , int>
#define ld long double
#define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
#define setp cout << fixed << setprecision(15)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;
#define all(x) (x).begin() , (x).end()

int a[17];
int p[17];
int mx1 = 1000000000000000ll;
int mx2 = 1;
vector<int> v;

bool ch = 1;

void prt(int x,int z,int last = 17){
//    cout << x << endl;
    if(!x) return;
    int sum = 0;
    int i = x;
    if(ch){
        while(i){
            sum += i%10;
            i /= 10;
        }
        if( x*mx2 <= mx1*sum){
            mx1 = x;
            mx2 = sum;
            v.pb(x);
        //   cout << x << endl;
        }else{
            return ;
        }
    }
    ch = 1;
    i = x;
    while(1){
        if((x/p[z])%10){
            x -= p[z];
            prt(x,0,z);
        }
        else break;
    }
    if(z+1 < last){
        ch  = 0;
        prt(i,z+1,last);
    }
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    p[0] = 1;
    for2(i,1,17) p[i] = p[i-1]*10;
    prt(999999999999999,0);
    sort(all(v));
    v.resize(unique(all(v))-v.begin());
    int n; cin >> n;
    for2(i,0,n) cout << v[i] << endl;
    return 0;

    vector<int> u;
    for(auto x : v) if( x < 1000000) u.pb(x);


//    return 0;

    int mx1;
    int mx2;
    mx1 = 1000000;
    mx2 = 1;
    for(int i = 999999; i > 0; i--){
        int sum = 0;
        int x = i;
        while(x){
            sum += x%10;
            x /= 10;
        }
        if( i*mx2 <= mx1*sum){
            mx1 = i;
            mx2 = sum;
            if(!u.size() || u.back() != i){
                cout << i << endl;
                return 0;
            }
            u.pop_back();
        }
    }
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c - max(a, max(b, c)) << endl;
}


Measured memory_bytes: 256
n,m,x,y=map(int,input().split())
xx=sorted(list(map(int,input().split())))
yy=sorted(list(map(int,input().split())))

ans="War"

if xx[-1]<yy[0] and xx[-1]<y and x<yy[0]:
  ans="No War"

print(ans) 

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

int main(void){
  vector<int> a(3),b(3);

  rep(i,3){
    cin >> a.at(i);
    cin >> b.at(i);
  }
  map<int,int> p;
  rep(i,3){
    p[a.at(i)]++;
    p[b.at(i)]++;
  }

  for(auto x : p){
    if(x.second>=3){
      cout << "NO" << endl;
      return 0;
    }
  }    
  cout << "YES" << endl;
  
  return 0;
}


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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<long long> p(n);
    vector<long long> sum(n);
    for (auto &i : p) {
        cin >> i;
    }
    sum.front() = p.front();
    for (int i = 1; i < n; i++) {
        sum[i] = sum[i - 1] + p[i];
    }
    long long mx = sum[k - 1];
    for (int i = k; i < n; i++) {
        mx = max(mx, sum[i] - sum[i - k]);
    }
    cout << fixed << setprecision(9) << (double)(mx + k) / 2.0;
    return 0;
}

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

int main() {
	int n;
	string s;
	cin>>n>>s;
	int ans=0;
	for(int i=0;i<n;i++){
		std::vector<int> v(26,0);
		int now=0;
		for(int j=0;j<i;j++){
			v[(int)s[j]-97]++;
		}
		for(int j=i;j<n;j++){
			if(v[(int)s[j]-97]){
				now++;
				v[(int)s[j]-97]=0;
			}
		}
		ans=max(ans,now);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>  // ver1.9.4
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define mp make_pair
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repeq(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define repreq(i,a,b) for(int i=a;i>=b;i--)
#define leng(n) (int)(log10(n)+1)
#define Vout(a) rep(i,0,a.size()-1)cout<<a[i]<<' ';cout<<a[a.size()-1]<<endl;
#define INF 9000000000000000000  //  9.0 * 10^18
#define MOD 1000000007  //  10^9 + 7
using namespace std;

signed main() {
  cout << fixed << setprecision(15);
  string s,t="";
  cin >> s;
  Vi a(0);
  int now=0;
  rep(i,0,s.size()){
    if(s[i]=='x'){
      now++;
    }
    else {
      t += s[i];
      a.pb(now);
      now = 0;
    }
  }
  a.pb(now);
  string u;
  u = t;
  reverse(ALL(u));
  if(t!=u) {cout <<-1<< endl;return 0;}
  
  int ans = 0,l = a.size();
  rep(i,0,l/2){
    ans += abs(a[i]-a[l-1-i]);
  }
  cout << ans << endl;
  return 0;
}


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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var a = long.Parse(inputs[0]);
            var bs = inputs[1];
            var b = int.Parse(bs[0].ToString()) * 100 +
                    int.Parse(bs[2].ToString()) * 10 +
                    int.Parse(bs[3].ToString());

            var result = a * b;
            Console.WriteLine(result / 100);
        }
    }
}


Measured memory_bytes: 27448
l =[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())

print (l[k-1])

Measured memory_bytes: 3060
//Think simple yet elegant.
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll  long long
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
const ll maxn=105;
const ll mod=1e9+7;

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

bool chk(int x,int y,int h,int w){
	if(x<0 || x>=h || y<0 || y>=w)
		return false;
	return true;
}
int main(){
	fast;
	int h,w,i,j,k,sx,sy,dex,dey;
	cin>>h>>w>>sx>>sy>>dex>>dey;
	--sx,--sy,--dex,--dey;
	char gr[h][w];
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>gr[i][j];
		}
	}
	vector<vector<int>> d(h,vector<int>(w,1e9));
	deque<pi> q;
	q.push_front({sx,sy});
	d[sx][sy]=0;
	while(!q.empty()){
		pi v=q.front();
		int x=v.ff;
		int y=v.ss;
		q.pop_front();
		for(i=0;i<4;i++){
			if(chk(x+dx[i],y+dy[i],h,w) && gr[x+dx[i]][y+dy[i]]!='#'){
				if(d[x][y]<d[x+dx[i]][y+dy[i]]){
					d[x+dx[i]][y+dy[i]]=d[x][y];
					q.push_front({x+dx[i],y+dy[i]});
				}
			}
		}
		for(int cx=-2;cx<=2;++cx){
			for(int cy=-2;cy<=2;++cy){
				if((cx==-1 && cy==0) || (cx==1 && cy==0) || (cx==0 && cy==1) || (cx==0 && cy==-1))continue;
				if(chk(x+cx,y+cy,h,w) && gr[x+cx][y+cy]!='#'){
					if(d[x][y]+1<d[x+cx][y+cy]){
						d[x+cx][y+cy]=d[x][y]+1;
						q.push_back({x+cx,y+cy});
					}
				}
			}
		}
	}
	if(d[dex][dey]>=1e7)
		cout<<-1;
	else
		cout<<d[dex][dey];
	
}

Measured memory_bytes: 8528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n;
    cin >> n;

    cout << (n+1)/2 << endl;

    return 0;
}

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

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;

const int N = 210;

int main() {
  #ifdef LOCAL
  freopen("in", "r", stdin);
  #endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  string a, b;
  cin >> a >> b;
  int ans = 0;
  rep(i, 0, a.size()) {
    if (a[i] == b[i]) ++ans;
  }
  cout << ans;
  return 0;
}

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

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

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int A, B;
    cin >> A >> B;
    
    if ((A+B)%2==0)
    {
        cout << (A+B) / 2 << endl;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 888
s = gets.chomp.split("")
if  (s[0] == "A" && s.count{|st| st == "A" } == 1)&& (s[2..-2].count{|t|t == "C"} == 1)
  s.delete("A")
  s.delete("C")
  require 'set'
  al = ("a".."z").to_a
  if  Set.new(al).superset?(Set.new(s))
    puts "AC"
  else
    puts "WA"
  end
else
    puts "WA"
end


Measured memory_bytes: 2172
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
main()
{
	long long int n;
	cin >> n;
	long long int i;
	vector<string>v, ans;
	map<string, long long int >m, ispisan;
	for(i=0;i<n;i++)
	{
		string s;
		cin >> s;
		v.push_back(s);
		m[s]++;
	}
	long long int maxi = -1;
	for(i=0;i<n;i++)
	maxi = max(m[v[i]], maxi);
	
	for(i=0;i<n;i++)
	{
		if(m[v[i]] == maxi && ispisan[v[i]]==0)
		{
			ispisan[v[i]]++;
			ans.push_back(v[i]);
		}
	}
	
	sort(ans.begin(), ans.end());
	for(i=0;i<ans.size();i++)
	cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 40816
class Rectangle
  def initialize(height, width)
    @height = height
    @width = width
  end

  def area
    @height * @width
  end

  def perimeter
    (@height + @width) * 2
  end

  attr_accessor :height, :width
end

def read_input
  height, width = gets.split(" ").map {|x| x.to_i}
end

height, width = read_input
rectangle = Rectangle.new(height, width)
puts "#{rectangle.area} #{rectangle.perimeter}"

Measured memory_bytes: 8556
using System;
using System.Linq;

namespace B___Traveling_AtCoDeer_Problem
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Ai = Console.ReadLine().Split().Select(int.Parse).OrderBy(x => x).ToArray();

            Console.WriteLine(Ai.Last() - Ai.First());
        }
    }
}


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

int main(){
    vector <int> a(1000001,0);
    ll s;
    cin >> s;
    rep(i,1000001){
        if(a[s]==1){
            cout << i+1 << endl;
            break;
        }
        else{
            a[s]=1;
            if(s%2==1){
                s=3*s+1;
            }
            else{
                
                    s/=2;
                
            }
        }
    }
    

    return 0;
}

Measured memory_bytes: 7032
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int n, m, x;
	lli cheep = INF;
	cin >> n >> m >> x;
	vector<lli> c(n);
	lli a[n][m];

	rep(i,n){
		cin >> c[i];
		rep(j,m) cin >> a[i][j];
	}
	rep(bit, 1<<n){
		vector<lli> ans(m);
		lli cost = 0;
		rep(i,n){
			if(bit&(1<<i)){
				cost += c[i];
				rep(j,m) ans[j] += a[i][j];
			}
		}
		bool ok = true;
		rep(t,m) if(ans[t] < x) ok = false;
		if(ok) cheep = Min(cheep, cost);
	}
	if(cheep == INF) cout << "-1" << endl;
	else cout << cheep << endl;
	return 0;
}

Measured memory_bytes: 3592
import math
S = int(input())

if S == 10 ** 18:
  print(0, 0, 0, 10 ** 9, 10 ** 9, 0)
  exit()

t = math.floor(math.sqrt(S))
if t * (t + 1) < S:
  x1 = t + 1
  y2 = t + 1
else:
  x1 = t
  y2 = t + 1
x2 = 1
y1 = x1 * y2 - S

print(0, 0, x1, y1, x2, y2)



Measured memory_bytes: 3060
import java.util.*;
public class Main {
    static int ans = 0;
    static int[] check = new int[3];
    public static void main(String[] args) {
        int n = new Scanner(System.in).nextInt();
        dfs(n, 0, 0, check);
        System.out.println(ans);
    }
    public static void dfs(int n, int m, int d, int[] check) {
        if (m <= n && check[0] > 0 && check[1] > 0 && check[2] > 0) ans++;
        if (d >= 9) return;
        for (int i = 1; i <= 3; i++) {
            check[i - 1]++;
            dfs(n, 10 * m + 2 * i + 1, d + 1, check);
            check[i - 1]--;
        }
    }
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n,a[200005],b[200005];
pll l[200005],r[200005];
ll binsearch1(ll x)
{
	ll l=1,r=x;
	ll mid=(l+r)>>1;
	while(r-l>1)
	{
		if(b[mid]>b[x]-b[mid])
			r=mid;
		else
			l=mid;
		mid=(l+r)>>1;
	}
	ll dif=abs(b[x]-2*b[mid]);
	if(mid+1<x&&abs(b[x]-2*b[mid+1])<dif)
		mid++;
	return mid;
}
int main()
{
	SPEED;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	l[2]=mp(a[1],a[2]);
	r[n-1]=mp(a[n-1],a[n]);
	for(int i=1;i<=n;i++)
		b[i]=a[i]+b[i-1];
	ll j=1;
	for(int i=3;i<=n;i++)
	{
		ll x=binsearch1(i);
		l[i]=mp(b[x],b[i]-b[x]);
	}
	reverse(a+1,a+n+1);
	memset(b,0,sizeof b);
	for(int i=1;i<=n;i++)
		b[i]=a[i]+b[i-1];
	for(int i=3;i<=n;i++)
	{
		ll x=binsearch1(i);
		r[n-i+1]=mp(b[x],b[i]-b[x]);
	}
	ll ans=INF;
	for(int i=2;i<=n-2;i++)
	{
		ll d[5]={0};
		d[1]=l[i].FF;
		d[2]=l[i].SS;
		d[3]=r[i+1].FF;
		d[4]=r[i+1].SS;
		sort(d+1,d+5);
		ans=min(ans,abs(d[4]-d[1]));
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define all(in) in.begin(),in.end()

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; }

using ll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
    int n, k; cin >> n >> k;
    vector<ll> data(n), left(n+1,0), right(n+1,0);
    rep(i,n) cin >> data[i];
    rep(i,n) left[i+1] = left[i] + max(0ll,data[i]);
    rep(i,n) right[i+1] = right[i] + max(0ll,data[n-1-i]);

    ll count = 0; rep(i,k) count += data[i];
    ll ans = max(0ll,count) + left[0] + right[n-k];
    rep(i, n-k){
        count += data[k+i];
        count -= data[i];
        chmax(ans, max(0ll,count) + left[1+i] + right[n-k-1-i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5556
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
#define mkpr make_pair
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


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


  int N; cin>>N;

  vvi cnt(10, vi(10, 0));
  for (int i = 1; i <=N; i++) {
    string s = to_string(i);
    int head = s[0]-'0';
    int tail = s.back()-'0';
    cnt[head][tail]++;
  }

  int ans = 0;
  REP(i,10) {
    REP(j,10) {
      ans += cnt[i][j]*cnt[j][i];
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = scanner.nextInt();

        if (b/a>=c) {
            System.out.println(c);
        }else{
            System.out.println(b/a);
        }
        
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define INF 1000000000
int dp[100005], arr[100005];
bool record[100005];
using namespace std;
int solve(int current, int n)
{
	if (current == n - 1)
		return 0;
	if (record[current])
		return dp[current];
	dp[current] = min(abs(arr[current] - arr[current + 1]) + solve(current + 1, n), (current + 2 <= n - 1)? abs(arr[current] - arr[current + 2]) + solve(current + 2, n): INF);
	record[current] = true;
	return dp[current];
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	cout << solve(0, n) << '\n';
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define endl '\n'
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
//#include "debug.cpp"

int32_t main()
{
	boost;
	int h,a;
  cin>>h>>a;
  int ans=0;
  while(h>0){
    h-=a;
    ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long A[] = new long[N];
    boolean isMinusCntIsOdd =false;
    long answer =0;
    for(int i=0;i<N;i++){
      A[i] = sc.nextLong();
      if(A[i]<0){
        isMinusCntIsOdd=!isMinusCntIsOdd;
        A[i]=(-1)*A[i];
      }
      answer = answer +A[i];
    }
    Arrays.sort(A);
    if(!isMinusCntIsOdd){
      System.out.println(answer);
      return;
    }else{
      answer = answer - A[0]*2;
      System.out.println(answer);
      return;
    }
    
      
      
  }
  

  
}

Measured memory_bytes: 50676
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
ll gcd(ll a, ll b){
  if(b==0) return a;
  else gcd(b,a%b);
}
ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}
using Graph = vector<vector<int>>;

struct UnionFind{
  vector<int>par;
  UnionFind(int n):par(n){
    rep(i,n) par[i]=i;
  }
  int root(int x){
    if(par[x]==x)return x;
    return par[x]=root(par[x]);
  }
  
  void unite(int x, int y){
    int rx=root(x);
    int ry=root(y);
    if(rx==ry)return;
    par[rx]=ry;
  }
  bool same(int x,int y){
    int rx=root(x);
    int ry=root(y);
    return rx==ry;
  }
};


int main(){
  int n,m;
  cin >> n >> m;
  vector<int>a(m);
  vector<int>b(m);
  rep(i,m){
    int A,B;
    cin >> A >> B;
    A--;
    B--;
    a[i]=A;
    b[i]=B;
  }

  int ans=0;
  rep(i,m){
    UnionFind UF(n);
    rep(j,m){
      if(i==j)continue;
      UF.unite(a[j],b[j]);
    }
    if(!UF.same(a[i],b[i])) ans++;
  }
    
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.PrintWriter
import kotlin.math.absoluteValue
import kotlin.math.min

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun <T> Iterable<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)
fun <T> Array<T>.join(separator: CharSequence = ", ", prefix: CharSequence = "", postfix: CharSequence = "") = joinToString(separator, prefix, postfix)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val N = nextInt()
    val A = nextLongList()
    val B = A.mapIndexed { index, a -> a - index - 1 }
    val ans = searchMin(B.min()!!, B.max()!!) { v ->
        B.map { (it - v).absoluteValue }.sum()
    }
    println(ans)
}

fun searchMin(l: Long, r: Long, f: (Long) -> Long): Long {
    val c1 = l + (r - l) / 3
    val c2 = l + (r - l) * 2 / 3
    if (l == c1) return min(f(c1), f(c2))
    return if (f(c1) < f(c2)) searchMin(l, c2, f) else searchMin(c1, r, f)
}

Measured memory_bytes: 104336
n = int(input())
h = list(map(int,input().split()))

ans = 'Yes'
flag = False
for i in range(n-1):
  diff = h[i+1]-h[i]
  if diff <= -1:
    if flag:
      ans='No'
      break        
    
    if diff <= -2:
      ans = 'No'
      break
        
    flag = True          
    
  else:
    if diff >= 1:
      flag = False

print(ans)      

Measured memory_bytes: 14396
import sys
input=sys.stdin.readline
N,K=map(int,input().split())
A=list(map(int,input().split()))
A=sorted(A)
F=list(map(int,input().split()))
F=sorted(F,reverse=True)

def is_ok(b):
    k=0
    for a,f in zip(A,F):
        if a>b//f:
            k+=a-(b//f)
            if k>K:
                return False
    return True

ok=10**12+1
ng=-1
while ok-ng>1:
    m=(ok+ng)//2
    if is_ok(m):
        ok=m
    else:
        ng=m

print(ok)


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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int n, m;
    n = in();
    m = in();
    vector<int> deck;
    rep(i, 2 * n) deck.push_back(i);
    rep(i, m){
        int k = in();
        vector<int> next_deck;
        if (k == 0){
            rep(j, n){
                next_deck.push_back(deck[j]);
                next_deck.push_back(deck[j + n]);
            }
        }
        else {
            rep(j, 2 * n - k){
                next_deck.push_back(deck[k + j]);
            }
            rep(j, k){
                next_deck.push_back(deck[j]);
            }
        }
        deck = next_deck;
    }
    eachv(deck, i){
        printf("%d\n", deck[i] + 1);
    }

    return (0);
}

Measured memory_bytes: 1212
def solve():
    import heapq
    n = int(input())
    g = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b, c = map(int, input().split())
        a, b = a - 1, b - 1
        g[a].append((b, c))
        g[b].append((a, c))
    inf = 10**15
    dist = [inf] * n

    def dijkstra(s):
        q = []
        dist[s] = 0
        heapq.heappush(q, [0, s])
        while q:
            p, v = heapq.heappop(q)
            if dist[v] < p:
                continue
            for i, x in g[v]:
                if dist[i] > dist[v] + x:
                    dist[i] = dist[v] + x
                    heapq.heappush(q, [dist[i], i])

    m, k = map(int, input().split())
    k = k - 1
    dijkstra(k)
    for _ in range(m):
        e, f = map(int, input().split())
        res = dist[e - 1] + dist[f - 1]
        print(res)


solve()


Measured memory_bytes: 110468
s=input()
t=input()
leng=len(s)
lent=len(t)
count=0
tmp=0
i=0
while True:
   ans=s[tmp:].find(t[i])
   if ans!=-1:
       i += 1
       tmp += ans+1
       if i ==lent:
           count += tmp
           break
       continue
   if tmp==0:
       count=-1
       break
   tmp=0
   count+=leng
if count>leng*10**100:
    count=-1
print(count)

Measured memory_bytes: 3316
#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
using namespace std;
 
int main () {
  int n;
  cin >> n;
  string s;
  cin >> s;
  unsigned long long int c = 0;
  long long int cr = 0;
  long long int cg = 0;
  long long int cb = 0;
  for (int i=0; i<n; i++){
    switch (s[i]){
      case 'R':
        cr ++;
        break;
      case 'G':
        cg ++;
        break;
      case 'B':
        cb ++;
        break;
    }
  }
  c = cr * cg * cb;
  for (int j = 0; j < n-2; j++){
    for (int k = j+1; k < n-1; k++){
      if (s[j]!=s[k] && s[k]!=s[2*k-j] && s[j]!=s[2*k-j] && (2*k-j) < n){
        c --;
      }
    }
  }
  cout << c;
  return 0;
}

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

int dp[100010][3];

int main() {
    int N; cin >> N;
    int a[100010][3];
    for(int i = 0; i < N; ++i) for(int j = 0; j < 3; ++j) cin >> a[i][j];
    for(int i = 0; i <= N; ++i) {
        for(int j = 0; j < 3; ++j) {
            for(int k = 0; k < 3; ++k) {
                if(j == k) continue;
                dp[i+1][j] = max(dp[i+1][j], dp[i][k] + a[i][k]);
            }
        }
    }
    
    int res = 0;
    for(int j = 0; j < 3; ++j) res = max(res, dp[N][j]);
    cout << res << endl;
}


Measured memory_bytes: 2560
/*https://atcoder.jp/contests/abc142/tasks/abc142_c*/
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	int n, a;
	cin >> n;
	vector <pair<int , int>> v;
	for (int i = 1; i <= n; i++)
	{
		cin >> a;
		v.push_back(make_pair(a, i));
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n; i++)
		cout << v[i].second << " ";
}

Measured memory_bytes: 4260
"use strict";
main(require("fs").readFileSync("/dev/stdin", "utf8").replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	while(true){
		var cards = lines.shift();
		if(cards == "-") break;
		var times = +lines.shift();
		var sum = 0;
		for(var i=0;i<times;i++) sum += +lines.shift();
		sum %= cards.length;
		console.log(cards.slice(sum) + cards.slice(0, sum));
	}
}

Measured memory_bytes: 15528
#include<iostream>
#include<queue>
using namespace std;
int main(){
long long n, a,t1[2]={},cnt=0,ans=0;
priority_queue<long long> q;
cin>>n;
for(int i=0;i<n;i++){
cin>>a;
q.push(a);
}
while(q.size()-1){
long long tmp=q.top();
q.pop();
if(tmp==q.top()){
q.pop();
t1[cnt]=tmp;
cnt++;
}
if(cnt==2)break;
}
if(cnt==2)cout<<t1[0]*t1[1];
else cout<<'0';
return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, Abel w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, m;
	cin >> n >> m;
	
	UnionFind<int> uf(n);
	
	rep(i, m) {
		int l, r, d;
		cin >> l >> r >> d;
		l--; r--;
		if (uf.issame(l, r)) {
			int ud = uf.diff(l, r);
			if (d != ud) {
				out("No");
				return 0;
			}
		}
		else {
			uf.merge(l, r, d);
		}
	}

	out("Yes");

	return 0;
}

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

int main()
{
	int S, h, m, s;

	cin >> S;

	h = S / 3600;
	m = S % 3600 / 60;
	s = S % 3600 % 60;

	cout << h << ":" << m << ":" << s << endl;

	return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

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

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int mod=100000;

ll dp[4][110][110];

int main(void){
	
	dp[0][1][0]=1;
	dp[1][0][1]=1;
	
	rep(i,110)rep(j,110){
		if(i+j<=1)
			continue;
		
		if(i-1>=0){
			dp[0][i][j]=(dp[0][i][j]+dp[0][i-1][j]+dp[2][i-1][j])%mod;
			dp[2][i][j]=(dp[2][i][j]+dp[1][i-1][j])%mod;
		}
	
		if(j-1>=0){
			dp[1][i][j]=(dp[1][i][j]+dp[1][i][j-1]+dp[3][i][j-1])%mod;
			dp[3][i][j]=(dp[3][i][j]+dp[0][i][j-1])%mod;
		}
	}
	
	int h,w;
	while(1){
		cin >> h >> w;
	
		if(h==0&&w==0)
			break;
		
		ll ans=0;
	
		rep(i,4) ans=(ans+dp[i][h-1][w-1])%mod;
	
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1532