akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace ConsoleApplication1
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var input   = Console.ReadLine().Split(' ');
			int charNum = int.Parse(input[0]);
			int qNum    = int.Parse(input[1]);

			var str = Console.ReadLine().ToCharArray();
			char[] s = new char[str.Length];
			for ( int i = 0; i < charNum - 1; i++ ) {
				if ( str[i] == 'A' && str[i + 1] == 'C' ) s[i] = 'a';
			}

			int[] t = new int[charNum];
			t[0] = 0;
			for ( int i = 0; i < charNum - 1; i++ ) {
				if ( s[i] == 'a' ) {
					t[i + 1] = t[i] + 1;
				}
				else {
					t[i + 1] = t[i];
				}
			}


			List<string> questions = new List<string>();

			for ( int i = 0; i < qNum; i++ ) {
				questions.Add(Console.ReadLine());
			}

			foreach ( var question in questions ) {
				string[] q = question.Split(' ');

				int start = int.Parse(q[0]) - 1;
				int end   = int.Parse(q[1]) - 1;

				Console.WriteLine(t[end] - t[start]);

				// var count      = 0;
				// var tmpCount   = 0;
				// var countStart = false;
				//
				// for ( int i = start; i <= end; i++ ) {
				// 	if ( str[i] == 'A' && str[i + 1] == 'C' && (i + 1) <= end) {
				// 		count++;
				// 		// tmpCount++;
				// 		// if ( count < tmpCount ) count = tmpCount;
				// 	}
				// 	else {
				// 		// tmpCount = 0;
				// 	}
				// }
				// Console.WriteLine(count);
			}
		}
	}
}

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

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

	vector<int> a(n), b(n), c(n - 1);

	for (auto &t : a)cin >> t;
	for (auto &t : b) cin >> t;
	for (auto &t : c)cin >> t;
	int sum = 0;
	int last = -1;
	
	for (int i = 0; i < n; ++i) {
		if (last + 1 == a[i]) {
			sum += b[a[i] - 1] + c[a[i] - 2];
		}
		else {
			sum += b[a[i] - 1];
		}
		last = a[i];
	}
	cout << sum;

	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()

const int MAX = 1e5+10;

ll X, A;

int solve() {
    if (X >= A) return 10;
    return 0;
}

int main() {
    cin >> X >> A;
    cout << solve() << endl;
}

Measured memory_bytes: 256
/* Author - thiolhub */

#include <bits/stdc++.h>

using namespace std;

#define ll              long long int
#define ld              long double
#define db              double
#define pi              3.1415926535897932384626
#define PI              acos(-1.0)
#define endl            "\n"
#define mod             1000000007
#define mk              make_pair
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(t)            ll t; cin>>t; while(t--)
#define sc(a)	        scanf("%lld",&a);
#define pr(a)	        printf("%lld\n",a)
#define f(i,a,n)		for(ll i=a;i<n;i++)
#define m(a)		    memset(a,0,sizeof(a))
#define FastIO          ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)



int main(){ FastIO;

string s;cin>>s;
int f=1,i,n;n=s.length();
for(i=0;i<n/2;i++)
{
	if(s[i]!=s[n-1-i]) {
		f=0;break;
	}
	if(i<n/2 && s[i]!=s[n/2-1-i])
	{
		f=0;break;
	}
	if(i>n/2 && s[i]!=s[n-1-(i-n/2-1)])
	{
		f=0;break;
	}
}
if(f) cout<<"Yes";
else cout<<"No";

return 0;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort()
C.sort()
ans = 0
for b in B:
    la = bisect.bisect_left(A,b)
    rc = N - bisect.bisect_right(C,b)
    ans += la*rc
print(ans)


Measured memory_bytes: 23232
# -*- coding: utf-8 -*-
D,G = map(int,input().split())

G1 = int(G)
G2 = int(G)
taples = []
count = 1e9

for i in range(D):
	p,c = map(int,input().split())
	taples.append((p,c,100*(i+1)))

for bit in range(1 << D):
	# bit = [0 ~ 1<<D)
	sumpoint = 0
	solved = 0
	remprob = []
	for i in range(D):
		# i bit目が立っているか
		if (bit >> i) & 1:
			# 100i点の問題を全問解く
			sumpoint += 100*(i+1)*taples[i][0]+taples[i][1]
			solved += taples[i][0]
		else:
			# 解かない
			remprob.append(i)
	
	if sumpoint < G:
		maxi = max(remprob)
		for num in range(1, taples[maxi][0]):
			if sumpoint + 100*(maxi+1)*num >= G:
				count = min(count, solved + num)
				break
	else:
		count = min(count, solved)

print(count)

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
  // D
  int N;
  int a[60];
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  int max_idx = -1;
  int min_idx = -1;
  int max = -1000000-1;
  int min = 1000000+1;

  REP(i, N) {
    if(max < a[i]) {
      max = a[i];
      max_idx = i;
    }
    if (min > a[i]) {
      min = a[i];
      min_idx = i;
    }
  }

  int sum = 0;
  int sum_idx = -1;
  if (abs(max) >= abs(min) ){
    sum = max;
    sum_idx = max_idx;
  } else {
    sum = min;
    sum_idx = min_idx;
  }

  cout << 2*N-1 << endl;
  REP(i, N) {
    a[i] += sum;
    cout << sum_idx+1 << " " << i+1 << endl;
  }

  if (a[0] >= 0) {
    REP(i, N-1) {
      cout << i+1 << " " << i+2 << endl;
    }
  } else {
    for(int i=N-1 ; i > 0; i--) {
      cout << i+1 << " " << i << endl;
    }
  }
  return 0;
}


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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double argA = 30 * h + 0.5 * m;
    double argB = 6 * m;
    double arg = min(abs(argA - argB), 360 - abs(argA - argB)) / 180 * pi;
    cout << setprecision(10) << fixed << sqrt(a * a + b * b - 2 * a * b * cos(arg)) << endl;
}

Measured memory_bytes: 4232
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) > (b) ? (b) : (a))
#define Abs(x) ((x) > 0 ? (x) : -(x))
#define REP(i, n) for(int i = 0; i < n; i++)
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9 + 7
typedef long long ll;

int
main(int arg, char *argv[])
{
  char s[200000];
  scanf("%s", s);
  int f = 0, l = strlen(s) - 1, cnt = 0, flag = 0;
  while(l - f >= 0){
    if(s[f] == 'x' && s[l] != 'x'){
      f++;
      cnt++;
    }
    else if(s[f] != 'x' && s[l] == 'x'){
      l--;
      cnt++;
    }
    else if(s[l] == s[f]){
      f++;
      l--;
    }
    else{
      flag++;
      break;
    }
  }
  if(flag == 0) printf("%d\n", cnt);
  else printf("-1\n");

  return 0;
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)
viii edj;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z,k,l;
    cin>>l;
    for(int i=0;i<21;i++){
        if((l>>i)&&1){
            x = (1ll<<i);
            n = i+1;
        }
    }
    for(int i=0;i<n-1;i++){
        edj.pb(mc(i+1,i+2,0));
        edj.pb(mc(i+1,i+2,1ll<<i));
    }

    l-=x;

    for(int i=21;i>=0;i--){
        if((l>>i)&1){
            edj.pb(mc(i+1,n,x));
            x+=(1ll<<i);
        }
    }

    cout<<n<<" "<<edj.size()<<endl;
    for(auto it:edj){
        cout<<it.F.F<<" "<<it.F.S<<" "<<it.S<<endl;
    }
    
    



    return 0;
}

Measured memory_bytes: 3628
unittest
{
	assert( [ "-9" ].solve == "1011" );
	assert( [ "123456789" ].solve == "11000101011001101110100010101" );
	assert( [ "0" ].solve == "0" );
}



import std.conv;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	
	if( n == 0 ) return "0";
	
	// 桁ごとに表現できる範囲を計算
	auto ms = [ 0L ];
	auto ps = [ 0L ];
	for( auto i = 0L; n < ms.back || ps.back < n; i++ )
	{
		ms ~= ms.back;
		ps ~= ps.back;
		if( i % 2 ) ms.back += ( -2L ) ^^ i;
		else        ps.back += ( -2L ) ^^ i;
	}
	
	// 上の桁から判定
	auto anss = new long[ ms.length - 1 ];
	for( auto i = 0L, j = anss.length.signed - 1; i < anss.length; i++, j-- )
	{
		auto d = ( -2L ) ^^ j.signed;
		auto x = n - d;
		if( ms[ j ] <= x && x <= ps[ j ] )
		{
			n -= d;
			anss[ i ] = 1;
		}
	}
	return anss.to!( string[] ).join;
}


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

using namespace std;

int main()
{
    string sa, sb, sc;
    cin >> sa >> sb >> sc;
    char t = 'a';
    while(1)
    {
        if(t == 'a')
        {
            if(sa.empty())
            {
                cout << "A" << endl;
                return 0;
            }
            t = sa.front();
            sa.erase(sa.begin(), sa.begin()+1);
        }
        if(t == 'b')
        {
            if(sb.empty())
            {
                cout << "B" << endl;
                return 0;
            }
            t = sb.front();
            sb.erase(sb.begin(), sb.begin()+1);
        }
        if(t == 'c')
        {
            if(sc.empty())
            {
                cout << "C" <<endl;
                return 0;
            }
            t = sc.front();
            sc.erase(sc.begin(), sc.begin()+1);
        }
    }
    return 0;
}


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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> str(50);
    for(int i=0; i<h; i++){
        string s;
        cin >> s;
        str.at(i) = s;
    }

    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            int a=0;
            char c;
            c = str.at(i).at(j);
            if(c == '#') continue;
            for(int k=i-1; k<=i+1; k++){
                for(int l=j-1; l<=j+1; l++){
                    if(k<0 || k>h-1 || l<0 || l>w-1)
                        continue;
                    if(str.at(k).at(l) == '#')
                        a++;
                }
            }
        str.at(i).at(j) = char(a + '0');
        }
    }
    for(int i=0; i<h; i++){
        cout << str.at(i) << endl;
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N, W = Scanner.map_int()
    V = [Scanner.map_int() for i in range(N)]
    dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
    for i in range(N):
        for j in range(W+1):
            dp[i+1][j] = max(dp[i+1][j], dp[i][j])
            if 0 <= j - V[i][0]:
                dp[i+1][j] = max(dp[i+1][j], dp[i][j - V[i][0]] + V[i][1])
    print(dp[N][W])


if __name__ == "__main__":
    main()


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

int main() {

  int N,M,X,Y;
  cin >> N >> M >> X >> Y;

  vector<int>x(N);
  vector<int>y(M);
  
  for(int i=0;i<N;i++){
  cin >> x.at(i);
  }
  for(int i=0;i<M;i++){
  cin >> y.at(i);
  }
  
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  
  if(X<Y&&x.at(N-1)<Y&&x.at(N-1)<y.at(0)&&X<y.at(0)){
    cout << "No War" << endl;
  }else{
    cout << "War" << endl;
  }
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int Mod = 1e9 + 7;
const int mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
			comp_[i] = mod_pow(fact_[i], mod - 2, mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % mod * comp_[y] % mod;
}*/
//---------------------------------------------------
signed main() {
	string s;
	cin >> s;
	if (s == "Sunny") {
		cout << "Cloudy\n";
	}
	else if (s == "Cloudy") {
		cout << "Rainy\n";
	}
	else {
		cout << "Sunny\n";
	}
}

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

int main(){
    int N;cin>>N;
    if(N%2)cout<<N/2<<endl;
    else cout<<N/2-1<<endl;
    return 0;
}

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

int main()
{
  size_t K;
  std::string S;
  std::cin >> K >> S;

  if(S.size() > K) {
    S.resize(K+3);
    S[K] = '.';
    S[K+1] = '.';
    S[K+2] = '.';
  }

  std::cout << S << std::endl;
  return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std; 
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
 
typedef long long int ll; 
typedef long double ld; 
 
#define MAX 300005
#define endl endl
#define UPPER 1000000000

ll H, W;
ll C1, C2, D1, D2;
vector<string> vec;
vector<vector<ll>> flg(1000+1, vector<ll>(1000+1, 0));
vector<vector<ll>> cost(1000+1, vector<ll>(1000+1, 1e18));
set < pair<ll, pair<ll,ll> > > q;
	
int main(){
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>H>>W;
	
	cin>>C1>>C2;
	
	cin>>D1>>D2;
	C1--;C2--;D1--;D2--;
	
	for(ll i=0;i<H;i++){
		string s;
		cin>>s;
		vec.push_back(s);
	}
	
	q.insert({0, {C1, C2}});
	
	flg[C1][C2] = 1;
	
	while(q.size()>0){
		auto it = *q.begin();
		q.erase(it);
		flg[it.second.first][it.second.first] = 1;
		if(it.second.first == D1 && it.second.second==D2){
			cout<<it.first;
			return 0;
		}
		for(ll ii=-2;ii<=2;ii++){
			for(ll jj=-2;jj<=2;jj++){
				if(ii==0 && jj==0)continue;
				ll it1 = ii+it.second.first;
				ll it2 = jj+it.second.second;
				ll it3 = it.first;
				if(it1<0 || it2<0 || it1>=H || it2>=W){
					continue;
				}
				if(vec[it1][it2]=='#'){
					continue;
				}
				if((abs(ii)<2&&jj==0) || (abs(jj)<2&&ii==0)){
					
				}
				else{
					it3++;
				}
				if(flg[it1][it2]==2){
					continue;
				}
				if(flg[it1][it2]==0){
					q.insert({it3, {it1, it2}});
					cost[it1][it2] = it3;
					flg[it1][it2] = 1;
				}
				else{
					if(cost[it1][it2]>it3){
						//q.erase({cost[it1][it2], {it1, it2}});
						cost[it1][it2] = it3;
						q.insert({it3, {it1, it2}});
					}
				}
			}
		}
	} 
	
	cout<<-1;
	
}


Measured memory_bytes: 21024
#include <bits/stdc++.h>
#define ld long double
using namespace std;

#define ld long double
#define int long long int
#define ps push_back
#define fi first
#define so second
#define mod 1000000007
#define pii pair<int,int>
#define TT int t;cin>>t;while(t--)
#define ina for(i=0;i<n;i++){cin>>a[i];}

int dp[21][1<<21];
vector<int> v[21];
int n;
int solve(int id,int mask)
{
    if(id==n)
    {
        return (mask==((1<<n)-1));
    }
    if(dp[id][mask]!=-1) return dp[id][mask];
    int ways=0;
    for(int i=0;i<n;i++)
    {
        if(v[id][i] && !(mask&(1<<i))) ways=((ways%mod)+(solve(id+1,mask|(1<<i))%mod))%mod;
    }
    dp[id][mask]=ways;
    return ways;
}

signed main()
{
   cin>>n;
   int i,j,k;
   for(i=0;i<=20;i++) for(j=0;j<(1<<n);j++) dp[i][j]=-1;
   for(i=0;i<n;i++) for(j=0;j<n;j++) {cin>>k;v[i].ps(k);}
   cout<<solve(0,0);
}


Measured memory_bytes: 344320
#include<stdio.h>
int main(void) {
	int b[3];
	scanf("%d %d %d",&b[0],&b[1],&b[2]);
	if(b[0]==1&&b[1]==1&&b[2]==0){
		puts("Open");
	}
	else if(b[0]==0&&b[1]==0&&b[2]==1){
		puts("Open");
	}
	else{
		puts("Close");
	}
	return 0;
}


Measured memory_bytes: 2124
#include<algorithm>
#include<bitset>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<unordered_map>
#include<utility>
#include<vector>

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;

template<typename T>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template<typename T>
bool chmin(T& a, T b){
    if(b < a){
        a = b;
        return true;
    }
    return false;
}

int main(){
    int h, w;
    std::cin >> h >> w;

    for(int i = 0 ; i < h ; ++i){
        std::string c;
        std::cin >> c;
        for(int k = 0 ; k < 2 ; ++k){
            std::cout << c << std::endl;
        }
    }
}

Measured memory_bytes: 3584
import math
from functools import reduce

def gcd(numbers):
    return reduce(math.gcd, numbers)

K = int(input())

total = 0
for l in range(1,K+1):
  for m in range(1,K+1):
    for n in range(1,K+1):
      total += gcd([l, m, n])

print(total)

Measured memory_bytes: 69364
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long h = sc.nextLong();
        long w = sc.nextLong();
        long h1 = h / 2;
        long h2 = h % 2;
        if(h == 1 || w == 1){
            System.out.println(1);
        }else if(h2 == 0){
            System.out.println(h1 * w);
        }else{
            System.out.println(h1 * w + w / 2 + w % 2);
        }
    }
}

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

using namespace std;

int main(){

  int X[5];

  for(int i=0; i<5; i++) cin>>X[i];
  
  for(int i=0; i<5; i++){
    if(X[i]==0){
      cout<<i+1<<endl;
      break;
    }
  }

}


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

long long int gcd(long long int a, long long int b) {
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

long long int lcm(long long int a, long long int b) {
    return a * b / gcd(a, b);
}

int main() {
    long long int A, B;

    cin >> A >> B;

    cout << lcm(A,B) << endl;
    
    
    return 0;
}

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

string S;
bool y=false, m=false;
int main() {
    cin >> S;
    int mae = stoi(S.substr(0,2));
    int ato = stoi(S.substr(2,4));
    if (mae<0 || ato<0) cout << "NA" << endl;
    else if (mae == 0 || ato ==0) {
        if (mae == 0 && ato == 0) cout << "NA" << endl;
        else {
            if (mae > 0 && mae <= 12) cout << "MMYY" << endl;
            else if (ato > 0 && ato <= 12) cout << "YYMM" << endl;
            else  cout << "NA" << endl;
        }
    }
    else {
        if (mae <= 12) m = true;
        if (ato <= 12) y = true;

        if (y && m) cout << "AMBIGUOUS" << endl;
        else if (y) cout << "YYMM" << endl;
        else if (m) cout << "MMYY" << endl;
        else cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<fstream>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define endl '\n'
#define pb push_back
#define fi first
#define se second
typedef long long ll;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define all(con) con.begin(),con.end()
#define w(x) int x; cin>>x; while(x--)
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

/*ofstream fout("bcount.out");
ifstream fin("bcount.in");*/

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    cout<<fixed<<setprecision(8);
     string s,t;
     cin>>s>>t;
     int ans = INT_MAX;
     for(int i = 0;i<= s.size() - t.size();i++)
     {
          int diff = 0;
          for(int j = 0;j<t.size();j++)
          {
               if(s[i+j] != t[j])
                    diff++;
          }
          ans = min(ans,diff);
     }
     cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main{
    public static void main(String arg[]){
        Scanner sc=new Scanner(System.in);
        while(true){
            String s=sc.next();
            if(s.equals("-"))break;
            int N=s.length();
            int m=sc.nextInt();
            for(int i=0;i<m;i++){
                int n=sc.nextInt();
                String x=s.substring(0,n);
                String y=s.substring(n,N);
                s=y+x;
            }
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 26504
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>

using namespace std;

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

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main () {
  int n,m,c,sum = 0,cnt = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  vector<vector<int>> a(n,vector<int>(m));
  for (int i = 0; i < m; i++){
    cin >> b[i];
  }
  for (int i = 0; i < n; i++){
    sum = 0;
    for (int j = 0; j < m; j++){
      cin >> a[i][j];
      sum += a[i][j]*b[j];
    }
    if (sum + c > 0){
      cnt++;
    }
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false

int N;
vector<vector<int>> G;

PP dfs(int v,int p){
    
    PP B={1,1};
    for(int &e:G[v]){
        if(e==p)continue;
        PP C = dfs(e,v);
        B.first*=(C.first+C.second);
        B.second*=C.first;
        
        B.first%=MOD;
        B.second%=MOD;
    }
    return B;
    
}


signed main(void){
    int x,y;
    cin >> N;
    G.resize(N);
    REP(i,N-1){
        cin >> x >> y;
        x--;y--;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    PP p= dfs(0,-1);
    
    int Ans = (p.first+p.second)%MOD;
    cout << Ans << endl;
    
    return 0;
}



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

class ALDS1
{
    static int isprime(int x)
    {
        if (
            x == 2 ||
            x == 3 ||
            x == 5 ||
            x == 7 ||
            x == 11 ||
            x == 13 ||
            x == 17 ||
            x == 19
            ) return 1;
        else if (
            x == 1 ||
            x % 2 == 0 ||
            x % 3 == 0 ||
            x % 5 == 0 ||
            x % 7 == 0 ||
            x % 11 == 0 ||
            x % 13 == 0 ||
            x % 17 == 0 ||
            x % 19 == 0
        ) return 0;
        else if (x < 100000)
        {
            for (int i = 23; i < x; i += 2)
            {
                if (x % i == 0) return 0;
            }
        }
        else if (x >= 100000)
        {
            for (int i = 23; i * i < x; i += 2)
            {
                if (x % i == 0) return 0;
            }
        }
        return 1;
    }
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int b, c=0;
        for (int i = 0; i < a; i++)
        {
            b = int.Parse(Console.ReadLine());
            c += isprime(b);
        }
        Console.WriteLine(c);
    }
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#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 SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

VL a = {1};
VL p = {1};

LL dfs(LL n,LL x) {
	// レベル0はパティ1枚
	if (n == 0) {
		return 1;
	}
	if (x == 1) {
		return 0;
	}
	// レベルn(>0)の時
	//
	if (x > a[n-1]+2) {
		return dfs(n-1,x - a[n-1] - 2) + p[n-1] + 1;
	}
	if (x == a[n-1]+2) {
		return p[n-1] + 1;
	}
	return dfs(n-1,x-1);
}

int main(int argc, char const* argv[])
{
	LL n,x;
	cin >> n >> x;

	for (int i = 0; i < n; i++) {
		a.push_back(a[i]*2+3);
		p.push_back(p[i]*2+1);
	}
	cout << dfs(n,x) << endl;
	return 0;
}


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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f first
#define s second

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0);
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}

int main() { _
  string a,b; cin >> a >> b;
  a += a;
  if (a.find(b) == string::npos) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
ll n,k,b;
void solve()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
    {
        ll a;cin>>a;
        if(a>=k)
        ans++;
    }
    cout<<ans<<endl;
}

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	var K, S int
	K, S = readInt(), readInt()
	cnt := 0
	if K > S {
		K = S
	}
	for i := 0; i <= K; i++ {
		for j := 0; j <= K; j++ {
			if k := S - (i + j); 0 <= k && k <= K {
				cnt++
			}
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 	int n, m;
  cin >> n >> m;
  float total=0;
  vector<float> v;
  for (int i=0; i<n; i++){
    float x;
    cin >> x;
    total+=x;
    v.push_back(x);
  }
  total/=(4*(float)(m));
  sort(v.begin(), v.end(), greater<int>());
  
  int cnt=0;
  for (int i=0; i<n; i++){
    if (v[i]>=total) cnt++;
    else break;
  }
  
  if (cnt >= m) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
int main() {
	ll n; cin>>n;
	VLL A(n), B(3), C(3);
	ll k=n-1;
	for (int i = 0;i < n;i++)cin >> A[i];
	if (n%2 != 0) {
		for (k;k >= 0;k -= 2) {
			cout << A[k] << " ";
		}
		for (ll t = 1;t < n - 1;t += 2) {
			cout << A[t] << " ";
		}
	}
	if (n%2 == 0) {
		for (k;k >= 0;k -= 2) {
			cout << A[k] << " ";
		}
		for (ll t = 0;t < n - 1;t += 2) {
			cout << A[t] << " ";
		}
	}
}

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

int main() {
long long n,k;
cin >> n >> k;
long long amari = n % k;
long long t = abs(k - amari);
long long ans = min(amari, t);
cout << ans << endl;

}

Measured memory_bytes: 3636
import java.util.*;

public class Main {

    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	
        int X = sc.nextInt();
        int A = sc.nextInt();

        if (X < A) {
            System.out.println(0);
        } else if (X >= A) {
            System.out.println(10);
        }
   	}
}

Measured memory_bytes: 21716
n=int(input())
a=list(map(int,input().split()))
cost=[]
for i,g in enumerate(a):
    cost.append([g,i])
cost.sort(reverse=True)

dp=[[0] *(n+1) for _ in range(n+1) ]

for i in range(n):
    for j in range(i+1):
        dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+cost[i][0]*abs(cost[i][1]-j))
        dp[i+1][j]=max(dp[i+1][j],dp[i][j]+cost[i][0]*abs((n-1-(i-j))-cost[i][1]))

print(max(dp[-1]))

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

using namespace std;
const int MAXN = 300; 
const int INF = 1e8;
 
int n,m,s,t;
int c[MAXN][MAXN],f[MAXN][MAXN],d[MAXN],ptr[MAXN],q[MAXN];

void input()
{
  cin>>n>>m;
  s=0;
  t=n-1;
  for(int i=1;i<=m;i++)
    {
      int k1,k2,val;
      cin>>k1>>k2>>val;
      c[k1][k2]=val;
    }
}
bool bfs() {
  int qh=0, qt=0;
  q[qt++] = s;
  memset (d, -1, n * sizeof d[0]);
  d[s] = 0;
  while (qh < qt) {
    int v = q[qh++];
    for (int to=0; to<n; ++to)
      if (d[to] == -1 && f[v][to] < c[v][to]) {
	q[qt++] = to;
	d[to] = d[v] + 1;
      }
  }
  return d[t] != -1;
}
 
int dfs (int v, int flow) {
  if (!flow)  return 0;
  if (v == t)  return flow;
  for (int & to=ptr[v]; to<n; ++to) {
    if (d[to] != d[v] + 1)  continue;
    int pushed = dfs (to, min (flow, c[v][to] - f[v][to]));
    if (pushed) {
      f[v][to] += pushed;
      f[to][v] -= pushed;
      return pushed;
    }
  }
  return 0;
}
 
int dinic() {
  int flow = 0;
  for (;;) {
    if (!bfs())  break;
    memset (ptr, 0, n * sizeof ptr[0]);
    while (int pushed = dfs (s, INF))
      flow += pushed;
  }
  return flow;
}
int main()
{
  input();
  int MaxFlow=dinic();
  cout<<MaxFlow<<endl;
  return 0;
}

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int T = sc.nextInt();
		int cost = 10000;
		for (int i=0;i<N;i++) {
			int c = sc.nextInt();
			int t = sc.nextInt();
			if (t<=T&&c<cost) {
				cost = c;
			}
		}
		if (cost==10000) {
			System.out.println("TLE");
		} else {
		System.out.println(cost);
		}
	}
}

Measured memory_bytes: 36048
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  while(1){
    string s;
    cin>>s;
    if(s=="-"){
      break;
    }
    int m;
    cin>>m;
    for(int i=0;i<m;i++){
      int h;
      cin>>h;
      s=s.substr(h)+s.substr(0,h);
    }
    cout<<s<<endl;
  }
  return 0;
}


Measured memory_bytes: 3168
#include <stdio.h>
#include <math.h>
 
 
int main(){
    double x1,y1,x2,y2;
    scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
    printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
}



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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    ll ans = L_INF;
    for (ll x = 1; x * x <= N; x++) {
        if (N % x == 0) {
            ans = min(ans, x + N / x - 2);
        }
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 256
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<=ll(b);++i)
#define ALL(f,x,...) ([&](decltype((x)) xxxx) { return (f)(begin(xxxx), end(xxxx), ## __VA_ARGS__); })(x)
#define lim 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define MSG(msg1,msg2,flag) cout<<((flag)? msg1:msg2);

#include<bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = std::pair<ll,ll>;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template <class T> T 
gcd(T a, T b){if (a < b) {a ^= b;b ^= a;a ^= b;} return b ? gcd(b, a % b) : a;}
template <class T> T 
lcm(T a, T b){return a * b / gcd(a, b);}
vector<char> 
string_to_vector_char(const string& input){vector<char> out(input.length());rep(i,input.length()){out[i]=input[i];}return out;}
template <class T> map<T,int> 
count_same_elements(const vector<T>& v){map<T,int>cmap; for_each(v.begin(),v.end(),[&cmap](auto x){cmap[x]++;}); return cmap; }
template<class A,class B> vector<B> 
mapf(const vector<A>& v,const function<B(A)>& func){vector<B> v_(v.size());rep(i,v.size()){ v_[i]=func(v[i]); }return v_;}
template<class A,class B> vector<B> 
adjacent_map(const vector<A>& v,const function<B(A,A)>& func){vector<B> v_(v.size()-1);rep(i,v.size()-1){ v_[i]=func(v[i+1],v[i]); }return v_;}
template<class A> bool
all_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]<1){flag=false;}; }return flag;}
template<class A> bool
any_of(const vector<A>& v){bool flag=false;rep(i,v.size()){ if(v[i]>0){flag=true; break;}; }return flag;}
template<class A> bool
none_of(const vector<A>& v){bool flag=true;rep(i,v.size()){ if(v[i]>0){flag=false;}; }return flag;}
template<class T>
void scan_vector(long long size,vector<T>& vector){
    vector.resize(size);
    for(long long i=0;i<size;++i){
        cin>>vector[i];
    }
}
int n;
double ans;
void input(){
    cin>>n;
}
void src(){
    rep(i,n){
        double x;string u;
        cin>>x>>u;
        if(u=="JPY"){
            ans+=x;
        }else{
            ans+=x*380000.0;
        }
    }
    cout<<setprecision(8)<<fixed<<ans;
}   

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc121c()
}

private data class Shop(val price: Long, val stock: Long)

fun abc121c() {
    val (n, m) = readLine()!!.split(" ").map { it.toLong() }
    val shopList = (1..n).map { readLine()!!.split(" ").map { it.toLong() } }
        .map { Shop(it[0], it[1]) }

    val sortedShopList = shopList.sortedBy { it.price }

    var remain = m
    var answer = 0L
    for (shop in sortedShopList) {
        if (remain <= 0) break
        val buyItems = Math.min(remain, shop.stock)
        remain -= buyItems
        answer += shop.price * buyItems
    }

    println(answer)
}


Measured memory_bytes: 85300
import math


def main():
    n, s = map(int, input().split())
    xs = sorted(list(map(int, input().split())))

    for i in range(n):
        xs[i] = abs(xs[i] - s)

    for i in range(1, n):
        xs[i] = math.gcd(xs[i], xs[i-1])

    print(xs[n-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 20324
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            int x = sc.nextInt();
            int a = 0;

            if(n == 0 && x == 0){
                break;
            }else{
                for(int i=1;i<n-1;i++){
                    for(int j=i+1;j<n;j++){
                        for(int k=j+1;k<n+1;k++){
                            if(i+j+k == x) a++;
                        }
                    }
                }
                System.out.println(a);
            }
        }
        sc.close();
    }
}


Measured memory_bytes: 26792
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  unsigned int N, M;
  cin >> N >> M;
  unsigned int ks[M];
  unsigned int ss[10][10] = {{}};
  int ps[M];
  int val;
  for (int i = 0; i < M; i++) {
    cin >> ks[i];
    for (int j = 0; j < ks[i]; j++) {
      cin >> val;
      ss[i][val - 1]++;
    }
  }
  for (int i = 0; i < M; i++) {
    cin >> ps[i];
  }
  int count = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<int> sws;
    for (int i = 0; i < N; i++) {
      if (bit & (1 << i)) {
        sws.push_back(i);
      }
    }
    int sum = 0;
    for (int i = 0; i < M; i++) {
      int cnt = 0;
      for (int j = 0; j < (int)sws.size(); j++) {
        if (ss[i][sws.at(j)] != 0) {
          cnt++;
        }
      }
      if (cnt % 2 == ps[i]) {
        sum++;
      }
    }
    if (sum == M) {
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3640
import math
(n, m)  =map(int, input().split())
factor = []
for i in range(2 , int(math.sqrt(m)) + 1):
    count = 0
    while m % i == 0:
        m = m / i
        count += 1
    if count != 0:
        factor.append(count)
if m > 1:
    factor.append(1)
sum = 1
for i in range(len(factor)):
    tmpn = n + factor[i] - 1
    d = 1
    for j in range(factor[i]):
        sum = sum * (tmpn - j)
        d = d * (factor[i] - j)
    sum = sum // d % 1000000007
print(sum)

Measured memory_bytes: 3064