akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
map<string, int> mp;
int main()
{
	mp["SUN"]=7;
	mp["MON"]=6;
	mp["TUE"]=5;
	mp["WED"]=4;
	mp["THU"]=3;
	mp["FRI"]=2;
	mp["SAT"]=1;
	string s; cin>>s;
	cout<<mp[s]<<endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, M; cin >> N >> M;
 
	vector<vector<int>> vec(M);
 
	for (int i = 0; i < M; ++i) {
		int k; cin >> k;
		vec[i].resize(k);
		for (int j = 0; j < k; ++j) {
			cin >> vec[i][j];
			--vec[i][j];
		}
	}
 
	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];
 
	int ans = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id : vec[j]) {
				if ((i >> id) & 1) {
					++c;
				}
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			++ans;
		}
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
//#define TASK "file"

#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long i64;
typedef long double dbl;
const dbl PI = acos(-1.0L);
const dbl EPS = 1e-12L;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

namespace task {
const int N = 200001;
int n, k;
dbl p, r;
dbl a[N];

int main() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> p;
    a[i] = (1.0L + p) / 2.0L + a[i - 1];
  }
  for (int i = k; i <= n; ++i) {
    r = max(r, a[i] - a[i - k]);
  }
  cout << r << '\n';
  return 0;
}
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(11);
  cout.setf(ios::fixed);
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#elif defined(TASK)
  freopen(TASK".in", "r", stdin);
  freopen(TASK".out", "w", stdout);
#endif
  return task::main();
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < s.size()-1;i++)
	{
		if(s.size()==2)
			break;
		if (s[i] == 'S'&&s[i + 1] == 'T')
		{
			s.erase(i, 2);
			if(i==0)
				i=-1;
			else
				i -= 2;
		}
	}
	if(s=="ST")
		cout<<'0'<<endl;
	else
		cout << s.size() << endl;	
    return 0; 
}


Measured memory_bytes: 640
n, k = map(int, input().split())
a = list(map(int, input().split()))

num = 1
li = [1]
flag = [True] * n
flag[0] = False

for i in range(k):
    num = a[num-1]
    if flag[num-1]:
        li.append(num)
        flag[num-1] = False
    else:
        break

d = li.index(num)
ans = (k-d)%(len(li)-d)+d

print(li[ans])

Measured memory_bytes: 32376
fun main(args: Array<String>) {
    val (m, d) = readIntegerList()
    var ans = 0
    for (M in 4..m) {
        for (D in 20..d) {
            val d10 = D / 10
            val d1 = D % 10
            if (d10 >= 2 && d1 >= 2 && (d1 * d10) == M) {
                ans++
            }
        }
    }
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 37840
n = int(input())
lis = list(map(int,input().split()))
num = [0 for i in range(max(lis)+1)]
if lis[0] != 0:
    print(0)
    exit()
if lis.count(0) > 1:
    print(0)
    exit()
for nu in lis:
    num[nu] += 1
ans = 1
for i in range(max(lis)):
    if num[i] == 0:
        print(0)
        exit()
    for _ in range(num[i+1]):
        ans *= num[i]
        ans %= 998244353
print(ans%998244353)

Measured memory_bytes: 14396
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		char[] S = sc.next().toCharArray();
		sc.close();

		List<Integer> list = new ArrayList<Integer>();
		int cnt = 0;
		int prev = S[0];

		// 連続している回数を数える
		for (int i = 0; i < N; i++) {
			if (S[i] == prev) {
				cnt++;
			} else {
				if (prev == '0') {
					prev = '1';
				} else {
					prev = '0';
				}
				// 値の追加
				list.add(cnt);
				cnt = 1;
			}
		}
		// for last
		list.add(cnt);

		// 最初と最後が0なら、listに0を足しておく
		if (S[0] == '0') {
			list.add(0, 0);
		}
		if (S[N - 1] == '0') {
			list.add(0);
		}

		int max = 0;
		int score = 0;
		int idx = 0;
		for (int i = 0; i < list.size(); i++) {
			// 最初の2K+1回はただ足し算
			if (i < 2 * K + 1) {
				score += list.get(i);
			} else {
				if (i % 2 != 0) {
					int minus = list.get(idx) + list.get(idx + 1);
					int plus = list.get(i) + list.get(i + 1);
					score = score - minus + plus;
					idx += 2;
				}
			}
			max = Math.max(max, score);
		}

		System.out.println(max);
	}
}


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

int main(){
    int n, ans = 0;
    string a, b, c;
    cin >> n >> a >> b >> c;
    for(int i=0; i<n; ++i){
        if(a[i] != b[i] && b[i] != c[i] && c[i] != a[i]){
            ans += 2;
        }else if(a[i] != b[i] || b[i] != c[i] || c[i] != a[i]){
            ans += 1;
        }else{
            continue;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// God put a smile upon your face <3

#include <bits/stdc++.h>

#define slld(longvalue) scanf("%lld", &longvalue)

#define ll long long
#define ull unsigned long long
#define pll pair < long long, long long >

#define fastio ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0)

#define pb push_back

#define bug printf("BUG\n")

#define mxlld LLONG_MAX
#define mnlld -LLONG_MAX

#define mxd 2e8
#define mnd -2e8

#define pi 3.14159265359

using namespace std;

bool check(ll n, ll pos)
{
	return n & (1LL << pos);
}

ll Set(ll n, ll pos)
{
	return n = n | (1LL << pos);
}

int main()
{
    ll i, j, k, l, m, n, o, r, q;
    ll testcase;
    ll input, flag, tag, ans;

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

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

    string s, t;

    while(cin >> s >> t)
    {
		ans = t.size();

		for(ll i = 0; i + t.size() <= s.size(); i++)
		{
			string x = "";

			for(ll j = i; j < i + t.size(); j++)
			{
				x += s[j];
			}

			ll cnt = 0;

			for(ll j = 0; j < x.size(); j++)
			{
				if(x[j] != t[j]) cnt++;
			}

			ans = min(ans, cnt);
		}

		cout << ans << "\n";
    }


}






Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=2005;
int n,sz[N];ll ans=1e18,f[N],g[N];
char s[N];vector<int>G[N];
void dfs(int x,int p)
{
	sz[x]=s[x]=='1';g[x]=0;ll mx=0,sum=0;
	for(int i=0;i<G[x].size();i++)if(G[x][i]!=p)
	{
		int y=G[x][i];dfs(y,x);sz[x]+=sz[y];
		g[y]+=sz[y];g[x]+=g[y];f[y]+=sz[y];
		if(f[y]>=f[mx])sum+=g[mx],mx=y;else sum+=g[y];
	}
	if(sum>=f[mx])f[x]=(sum-f[mx])&1;else f[x]=f[mx]-sum;
}
int main()
{
	scanf("%d%s",&n,s+1);
	for(int i=1,u,v;i<n;i++)scanf("%d%d",&u,&v),G[u].push_back(v),G[v].push_back(u);
	for(int i=1;i<=n;i++){dfs(i,0);if(!f[i])ans=min(ans,g[i]);}
	printf("%d\n",ans==1e18?-1:ans/2);return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = s; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   int n;
   cin >> n;
   vector<int> a(n), b(n), c(n);
   rep(i, 0, n) { cin >> a[i] >> b[i] >> c[i]; }

   vector<vector<int>> dp(n + 1, vector<int>(3));

   rep(i, 1, n + 1) {
      dp[i][0] = max(dp[i - 1][1] + a[i - 1], dp[i - 1][2] + a[i - 1]);
      dp[i][1] = max(dp[i - 1][2] + b[i - 1], dp[i - 1][0] + b[i - 1]);
      dp[i][2] = max(dp[i - 1][0] + c[i - 1], dp[i - 1][1] + c[i - 1]);
   }
   cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
   return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n;
    cin >> n;
    if(n == 1) ANS(1);
    ll l0 = 2, l1= 1, k = 0;
    for(ll i = 2; i <= n; i++){
        k = l0+l1;
        l0= l1;
        l1 = k;
    }
    cout << k;
}
main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}

const ll MX=1000000000;

int main(){
    ll s;
    cin>>s;
    ll S=s;
    ll x1=0,y1=0,x2,y2,x3,y3;
    
    auto judge=[&](ll a){return (a/2)*((a+1)/2)>=s;};
    
    ll l=0,r=MX*2;
    
    while(r-l>3){
        ll m=l+(r-l)/2;
        if(judge(m)){r=m;}
        else{l=m;}
    }
    for(ll i=max(0LL,l-10);i<=min(r+10,MX*2);i++){
        if(judge(i)){x2=i/2; y3=(i+1)/2; break;}
    }
    s=x2*y3-s;
    x3=1; y2=s;
    assert(x2*y3-x3*y2==S);
    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i=0;i<VMAX;i++)
    C[i]=0;
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=VMAX;i++)
    C[i]=C[i]+C[i-1];
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%hu",B[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9584
n = int(input())

prime = list()

i = 2
while i * i <= n:
  if n % i == 0:
    cnt = 0
    while n % i == 0:
      cnt += 1
      n //= i
    prime.append(cnt)
  i += 1
  
if n != 1:
  prime.append(1)
  
ans = 0
for x in prime:
  a = 1
  while a * (a+1) // 2 <= x:
    a += 1
  ans += a-1
  
print(ans)

Measured memory_bytes: 9120
import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    -- 文字列の入力
    odds <- getLine
    evens <- getLine
    -- 出力
    putStrLn $ solve odds evens

solve :: String -> String -> String
solve [] _ = []
solve o [] = o
solve o e = (head o) : (head e) : (solve (tail o) (tail e))


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vii vector<vector<int>>

int main() {

    int H, W, K;
    cin >> H >> W >> K;

    vii T(310, vector<int>(310, 0));
    vector<string> S(310);
    for (int i = 0; i < H; i++) {
        cin >> S[i];
    }

    int num = 1;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (S[i][j] == '#') {
                T[i][j] = num;
                num++;
            }
        }
    }

    for (int i = 0; i < H; i++) {
        int l = 0;
        for (int j = 0; j < W; j++) {
            if (T[i][j] > 0) {
                for (int x = l; x <= j; x++) {
                    T[i][x] = T[i][j];
                }
                l = j + 1;
            }
            else {
                if (j == W - 1 && l > 0) {
                    for (int x = l; x <= j; x++) {
                        T[i][x] = T[i][l-1];
                    }
                }
            }
        }
    }

    for (int j = 0; j < W; j++) {
        int t = 0;
        for (int i = 0; i < H; i++) {
            if (T[i][j] > 0) {
                for (int y = t; y <= i; y++) {
                    T[y][j] = T[i][j];
                }
                t = i + 1;
            }
            else {
                if (i == H - 1 && t > 0) {
                    for (int y = t; y <= i; y++) {
                        T[y][j] = T[t-1][j];
                    }
                }
            }
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << T[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}


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

using namespace std;

int main() {
    size_t n, m;
    cin >> n >> m;
    vector<size_t> ls(m, 0);
    auto rs = ls;
    for (size_t i = 0; i < m; ++i) {
        cin >> ls[i];
        cin >> rs[i];
    }
    auto l = *max_element(ls.begin(), ls.end());
    auto r = *min_element(rs.begin(), rs.end());
    if (r >= l)
        cout << r + 1 - l << endl;
    else
        cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define trav(a,v) for(auto a:v)
typedef long long int ll;
typedef long double lld;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main() {
	fastIO();
	int n;
	string s;
	cin>>n>>s;
	char alpha[26];
	int pos=0;
	for(int i=65;i<=90;i++){
		alpha[pos]=(char)i;
		pos++;
	}
	string ans="";
	for(int i=0;i<s.length();i++){
		int pos=0;
		for(int j=0;j<26;j++){
			if(alpha[j]==s[i]){
				pos=j;
				break;
			}
		}
		ans+=alpha[(pos+n)%26];
	}
	cout<<ans<<endl;
}
// - VERIFICAR LONG VS INT -
  


  

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, M, a, b;

    cin >> N >> M;

    if(N<2) a=0;
    else{
        a = N*(N-1)/2;
    }
    if(M<2) b=0;
    else{
        b = M*(M-1)/2;
    }

    cout << a+b << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i < n; i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define repran(i, a,b) for (int i = a; i<b;i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> P;
const int inf = 100000000;
int main()
{
    int n, k;
    cin >> n>> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> dp(k+1, 0);
    dp[0] = 0;
    repran(i, 1, k+1){
        rep(j, n){
            if (i>=a[j] and dp[i-a[j]]==0) dp[i] = 1;
        }
    }
    if (dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}

Measured memory_bytes: 3740
#include <stdio.h>

struct A { int a, b, c; };
struct A T[10000];
int n;

void preParse(int u)
{
   if ( u == -1 ) {
      return;
   }
   printf(" %d", u);
   preParse( T[ u ].b );
   preParse( T[ u ].c );
}

void inParse(int u)
{
   if ( u == -1 ) {
      return;
   }
   inParse( T[ u ].b );
   printf(" %d", u);
   inParse( T[ u ].c );
}

void postParse(int u)
{
   if ( u == -1 ) {
      return;
   }
   postParse( T[ u ].b );
   postParse( T[ u ].c );
   printf(" %d", u);
}

int main()
{
   int i, k, b, c, root;

   scanf("%d", &n);
   for ( i = 0; i < n; i++ ) {
      T[ i ].a = -1;
   }

   for ( i = 0; i < n; i++ ) {
      scanf("%d %d %d", &k, &b, &c);
      T[ k ].b = b;
      T[ k ].c = c;
      if ( b != -1 ) {
         T[ b ].a = k;
      }
      if ( c != -1 ) {
         T[ c ].a = k;
      }
   }

   for ( i = 0; i < n; i++ ) {
      if ( T[ i ].a == -1 ) {
         root =i;
      }
   }

   printf("Preorder\n");
   preParse(root);
   printf("\n");
   printf("Inorder\n");
   inParse(root);
   printf("\n");
   printf("Postorder\n");
   postParse(root);
   printf("\n");

   return 0;
}

Measured memory_bytes: 1856
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),k=sc.nextInt(),r=sc.nextInt(),s=sc.nextInt(),p=sc.nextInt();
		char[] t=sc.next().toCharArray(),d=new char[n];
		long score =0;
		sc.close();
		for(int i=0;i<n;i++) {
			if(t[i]=='p') {
				if(i-k<0 || (i-k>=0 && d[i-k]!='s')) {
					score+=s;
					d[i]='s';
				}
			}else if(t[i]=='s') {
				if(i-k<0 || (i-k>=0 && d[i-k]!='r')) {
					score+=r;
					d[i]='r';
				}
			}else {
				if(i-k<0 || (i-k>=0 && d[i-k]!='p')) {
					score+=p;
					d[i]='p';
				}
			}
		}
		System.out.println(score);
	}
}

Measured memory_bytes: 28452
n = int(input())
a = list(map(int,input().split()))
den = 0
aseki = 1
for i in range(n):
    for j in range(n):
        if i != j:
            aseki *= a[j]
    den += aseki
    aseki = 1
fra = 1
for i in range(n):
    fra *=a[i]
print(fra/den)

Measured memory_bytes: 9084
/* Sugoroku and Pieces*/
#include <iostream>

int main()
{
  // 変数宣言
  int n, m, a;
  int *x;
  int flag;

  // N 読み込み
  std::cin >> n;

  // X_i 読み込み
  x = new int[n];
  for (int i = 0; i < n; i++)
  {
    std::cin >> x[i];
  }

  // M 読み込み
  std::cin >> m;

  // A_i を順に読み込み処理
  for (int i = 0; i < m; i++){
    // A_i を読み込む
    std::cin >> a;

    // 以下で条件分岐
    // コマA_iの次のマスがゴールマス : A_iはそのまま
    if (x[a-1] == 2019){
      continue;
    }
    // コマA_iの次のマスにコマがあるかチェック
    // flag : if コマがない then flag = 1 else flag = 0
    flag = 1;
    for (int j = 0; j < n; j++)
    {
      if (x[a-1]+1 == x[j])
      {
        flag = 0;
        break;
      }
    }
    // flag == 1 のときA_iを次のマスに移す
    if (flag == 1)
    {
      x[a-1]++;
    }
  }

  // 出力
  for (int i = 0; i < n; i++){
    std::cout << x[i] << std::endl;
  }

  // X を解放
  delete[] x;
}



Measured memory_bytes: 3104
N,K = map(int, input().split())
MOD = 10 ** 9 + 7

ans = 0
for k in range(K, N+2):
    L = (k-1) * k // 2 % MOD
    R = (2*N-k+1) * k // 2 % MOD
    ans += R - L +1
    ans %= MOD

print(ans)

Measured memory_bytes: 9180
#-*-coding:utf-8-*-

def main():
    n, k = map(int, input().split())
    l_list = list(map(int, input().split()))
    l_list.sort(reverse=True)

    ans = 0
    for i in range(k):
        ans += l_list[i]
    print(ans)

if __name__ == '__main__':
    main()

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

int main() {
  
  int n,d;
  cin >> n >> d;
  
  int ans = 0;
  
  if ( n % ( d * 2 + 1 ) == 0 ){
    ans = n / ( d * 2 + 1 );
  }else{
    ans = ( n / ( d * 2 + 1 ) ) + 1;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
//#define P pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int digitSum(int i) {
    int ret = 0;
    while(i > 0) {
        ret += i % 10;
        i /= 10;
    }
    return ret;
}

int main() {
    int N; cin >> N;
    int ans = INF;
    for(int i = 1; i <= (N + 1) / 2; ++i) {
        int j = N - i;
        int res = digitSum(i) + digitSum(j);
        ans = min(ans, res);
    }
    cout << ans << endl;
}


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

using namespace std;

int main(void) {
  int N, K; cin >> N >> K;
  vector<int> p;

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

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += p[i];
  }
  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3592
def main():
    N = int(input())
    S = input()
    K = int(input())
    replace_char = S[K-1]
    ans = []
    for s in S:
        if s == replace_char:
            ans.append(replace_char)
        else:
            ans.append('*')
    print("".join(ans))

if __name__ == "__main__":
    main()
    

Measured memory_bytes: 3060
import sys

number = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))
answer = 0

for i in range(number):
    answer += b[a[i]-1]
    
    if i != 0:
        if a[i-1] == a[i]-1:
            answer += c[a[i-1]-1]

print(answer)
            


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

#define fast ios::sync_with_stdio(false); cin.tie(0)
#define fi first
#define se second
#define eb emplace_back
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define pre(a) cout<<fixed; cout.precision(a);
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll INF = 1e18;
const int inf = 1e9;

int n;

int main() {
	fast;
	pre(10);

	cin >> n;	

	cout << (double) (n - n/2) / n;
}

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

int main() {
	string S;
	int64_t K;
	cin >> S >> K;
	rep(i, min((int64_t)S.size(), K)) {
		if (S[i] != '1') {
			cout << S[i] << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}

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


int main() {
	int n,m;
	cin >> n >> m;
	int i;
	int first[200009];
	int second[200009];
	for(i=1;i<=n;i++)
	{
		first[i]=0;second[i]=0;
	}
	for(i=1;i<=m;i++)
	{
		int a,b;
		cin >>a >> b;
		if(a==1 && b!=1)
		first[b]=1;
		if(a!=1 && b==1)
		first[a]=1;
		if(a==n&&b!=n)
		second[b]=1;
		if(a!=n&&b==n)
		second[a]=1;
	}
	int flag=0;
	for(i=1;i<=n;i++)
	{
		if(first[i]==1 && second[i]==1)
		flag=1;
	}
	if(flag)
	cout << "POSSIBLE" << endl;
	else
	cout << "IMPOSSIBLE" << endl;
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 1792
def sumdigit(n):
  dsum = 0
  while(n > 0):
    dsum += n % 10
    n = int(n/10)
  
  return dsum

l = []
l = list(map(int, input().split()))
N = l[0]
minnum = l[1]
maxnum = l[2]
sumnum = 0
dsum = 0
        
for i in range(N + 1):
  dsum = sumdigit(i)
  if minnum <= dsum <= maxnum:
    sumnum += i
  
print(sumnum)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <random>
#include <functional>
#include <bit>
#include <cstdint>

#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long int
#define MOD 1000000007

using namespace std;

bool isPrime(ll n)
{
    if(n == 1)
    {
        return false;
    }
    for(ll i = 2; i*i <= n; i++)
    {
        if(n % i == 0)
        {
            return false;
        }
    }
    
    return true;
}

int main(void)
{
    
    ll a,b,c,k;
    
    cin >> a >> b >> c >> k;
    
    for(ll i = 0; i < k; i++)
    {
        if(a >= b)
        {
            b *= 2;
        }
        else if(b >= c)
        {
            c *= 2;
        }
    }
    
    if(a < b && b < c)
    {
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    // 7    ->    77    ->    777    -> ...
    //   *10 + 7      *10 + 7
    // Kの倍数かどうか -> mod K で考える
    // a[i+1] = a[i] *10 + 7 mod K
    // 0 <= a[i] < K
    // K = 6)
    // mod K
    // 0*10+7 mod K = 1 -> 17 mod K = 5 -> 57 mod K = 3 -> 37 mod K = 1 -> 5 -> 3 -> 1 -> ...
    // 方針)
    // 1) 余りのパターンが 0 <= a[i] < KのK通りなので K回やる
    // 2) ループにハマる前に0が出てくるかどうか
    int k;
    cin >> k;
    int x = 7 % k;
    set<int> s;
    // 2) ループにハマる前に0が出てくるかどうか
    // -> 同じあまりが出てきたらループスタート
    int i = 1;
    while (s.count(x) == 0) {
        if (x == 0) {
            cout << i << '\n';
            return 0;
        }
        s.insert(x);
        x = (x*10+7) % k;
        i++;
    }
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 50504
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    S = input_raw[0]
    max_char_num = len(S)/3 + (0 if len(S) % 3 == 0 else 1)

    char_num_dict = {}
    char_num_dict["a"] = 0
    char_num_dict["b"] = 0
    char_num_dict["c"] = 0
    for s in S:
        char_num_dict[s] += 1

    for s in char_num_dict:
        if char_num_dict[s] > max_char_num:
            print "NO"
            return
    print "YES"

if __name__ == '__main__':
    main()


Measured memory_bytes: 2936
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  string s;
  cin >> s;
  
  reverse(s.begin(), s.end());
  while(1) {
    if (s.find("esare") == 0 || s.find("maerd") == 0) {
      s.erase(0, 5);
    } else if (s.find("resare") == 0) {
      s.erase(0, 6);
    } else if (s.find("remaerd") == 0) {
      s.erase(0, 7);
    } else {
      cout << "NO" << endl;
      return 0;
    }
    if (s == "") {
      cout << "YES" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 512
import static java.util.Arrays.deepToString;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			for (int i = 0; i < n; i++) {
				if (i > 0) System.out.println();
				solve();
			}
		}
	}
	void solve() {
		int[][] t = new int[9][9];
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				t[i][j] = sc.nextInt();
			}
		}
		boolean[][] ng = new boolean[9][9];
		int[] count = new int[10];
		
		// --
		for (int r = 0; r < 9; r++) {
			Arrays.fill(count, 0);
			for (int c = 0; c < 9; c++) {
				count[t[r][c]]++;
			}
			for (int c = 0; c < 9; c++) {
				if (count[t[r][c]] > 1) {
					ng[r][c] = true;
				}
			}
		}
		// |
		for (int c = 0; c < 9; c++) {
			Arrays.fill(count, 0);
			for (int r = 0; r < 9; r++) {
				count[t[r][c]]++;
			}
			for (int r = 0; r < 9; r++) {
				if (count[t[r][c]] > 1) {
					ng[r][c] = true;
				}
			}
		}
		for (int bk = 0; bk < 9; bk++) {
			final int or = bk / 3 * 3, oc = bk % 3 * 3;
			Arrays.fill(count, 0);
			
			for (int in = 0; in < 9; in++) {
				int r = or + in / 3, c = oc + in % 3;
				count[t[r][c]]++;
			}
			
			
			for (int in = 0; in < 9; in++) {
				int r = or + in / 3, c = oc + in % 3;
				if (count[t[r][c]] > 1) {
					ng[r][c] = true;
				}
			}
		}
		
		for (int i = 0; i < 9; i++) {
			for (int j = 0; j < 9; j++) {
				System.out.print(ng[i][j] ? '*':' ');
				System.out.print(t[i][j]);
			}
			System.out.println();
		}
		
	}
}

Measured memory_bytes: 26508
while True:
  n, m, a = map(int, input().split())
  if n == 0:
    break
  edges = [[] for _ in range(1001)]
  for _ in range(m):
    h, p, q = map(int, input().split())
    edges[h].append((p, q))
  
  for h in range(1000, -1, -1):
    if (a, a + 1) in edges[h]:
      a = a + 1
    elif (a - 1, a) in edges[h]:
      a = a - 1
  print(a)



Measured memory_bytes: 5832
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
const int mod =1'000'000'007;

int main(){
    int n;
    cin >> n;
    vi x(n);
    rep(i,n) cin >> x.at(i);

    int MIN = 1'000'000;
    rep(i,100){
        int sum = 0;
        rep(j,n){
            sum += (x.at(j)-i) * (x.at(j)-i);
        }
        MIN = min(MIN, sum);
    }
    cout << MIN << endl;
    return 0;
}


Measured memory_bytes: 3656
#coding:utf-8

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

A = []
for i in range(N):
    A.append(list(map(int, input().split())))


count = 0

for i in range(N):
    sum_ = 0
    for j in range(M):
        sum_ += A[i][j] * B[j]
    sum_ += C

    if sum_ >  0:
        count += 1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int f(int N, vector<int> &A) {
	sort(ALL(A));
	if (N & 1) return A[N / 2];
	return A[N / 2 - 1] + A[N / 2];
}

int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	REP(i, N) scanf("%d %d", &A[i], &B[i]);
	
	cout << f(N, B) - f(N, A) + 1 << endl;
	
	return 0;
}


Measured memory_bytes: 4824
from collections import deque
n=int(input())
graph=[[] for i in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    a-=1;b-=1
    graph[a].append(b)
    graph[b].append(a)
distfrom1=[-1]*n
distfromn=[-1]*n
distfrom1[0]=0
distfromn[n-1]=0
d=deque([0])
while d:
    v=d.popleft()
    for i in graph[v]:
        if distfrom1[i]!=-1:continue
        distfrom1[i]=distfrom1[v]+1
        d.append(i)
d.append(n-1)
while d:
    v=d.popleft()
    for i in graph[v]:
        if distfromn[i]!=-1:continue
        distfromn[i]=distfromn[v]+1
        d.append(i)
F=0
for i in range(n):
    if distfrom1[i]<=distfromn[i]:F+=1
if F>n-F:print("Fennec")
else:print("Snuke")

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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;

#define LINF		((ll)1 << 63 -1)
#define INF 		2000000007
#define MINF		-2000000007
#define MAX 		100005

const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//


bool f(vector<int> &a,vector<int> &b){
	int suml = 0;
	REP(i,a.size()){
		suml += abs(a[i]-b[i])*abs(a[i]-b[i]);
	}
	double t = sqrt(suml);
	return ceil(t)==floor(t);
}

//
int main(){
	int N,D;cin>>N>>D;
	vector<vector<int>> X(N,vector<int>(D));
	REP(i,N)REP(j,D)cin>>X[i][j];

	int cnt = 0;
	REP(i,N-1)REPS(j,i+1,N){
		if(f(X[i],X[j]))cnt++;
	}

	cout << cnt << endl;

	return 0;
}




Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
x0 = 0
for i in range(n):
    x0 += a[i]*(-1)**(i)
print(x0,end="")
print(" ",end="")
x = x0//2
for i in range(1,n):
    x = a[i-1] - x
    print(2*x,end="")
    print(" ",end="")
print("")

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

namespace ABC116_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int ab = int.Parse(strs[0]);
            int bc = int.Parse(strs[1]);

            Console.WriteLine("{0}", ab * bc / 2);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 2e5+10;
const int N = 1e6+10;
const int E = 1e6+10;  
ll n,m,k;
string s; 
ll a[maxn];

int main(){
	cin>>k>>n;
	F(i,1,n){
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	a[n+1] = a[1];
	ll ans = inf;
	F(i,1,n){
		ans = min(ans,k-(a[i+1]-a[i]+k)%k);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
def print_a_b(a, b):
    """
    a: int
    b: int
    outputs quotient(int) of a and b, remainder of a and b, quotient(float) of a and b

    >>> print_a_b(3, 2)
    1 1 1.500000
    """
    print("{0} {1} {2:.6f}".format(a//b, a%b, a/b))

if __name__ == '__main__':
    (a, b) = [int(i) for i in input().split(' ')]
    print_a_b(a, b)

Measured memory_bytes: 7724
s = []
gets.to_i.times do
  s << Hash[*gets.chomp.chars.group_by{|x|x}.map{|x,y| [x,y.size]}.flatten]
end

puts (?a..?z).map{|c| [c, s.map{|x| x[c] || 0}.min]}.inject(''){|s,(x,i)| s + x*i}


Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    int T, X;
    double ans;

    cin >> T >> X;

    ans = (double)T/X;

    cout << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  char str[200001];
  int len = 0, i, j, max = 0;

  scanf("%s",str);

  for(i = 0; str[i] != '\0'; i++)
    if(str[i] == 'A')
      break;

  for(j = i; str[j] != '\0'; j++){
    if(str[j] == 'Z'){
      len++;
      max = len;
    }
    else 
      len++;
  }
  

  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string> 
#include <cctype>
#include <cmath>
//#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(){
    double a, b, C, x, y, L, h, S;
    cin >> a >> b >> C ;
    C = C*2*acos(-1)/360;
    x = sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(C));
    L = a + b + x;
    y = (pow(b,2)-pow(x,2)-pow(a,2))/(2*a);
    h = sqrt(pow(x,2)-pow(y,2));
    S = a*h/2;

    printf("%f\n", S);
    printf("%f\n", L);
    printf("%f\n", h);
    return 0;
}



Measured memory_bytes: 3364
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

int main()
{
  int n;
  cin >> n;
  int k = 1;
  while (k * (k - 1) / 2 < n) k++;
  if (k * (k - 1) / 2 != n) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  cout << k << endl;
  vector<vector<int>> g(k);
  int cur = 0;
  for (int i = 0; i < k; ++i) {
    for (int j = i + 1; j < k; ++j) {
      g[i].push_back(cur);
      g[j].push_back(cur);
      cur++;
    }
  }

  for (auto v : g) {
    cout << v.size();
    for (int x : v) cout << " " << x + 1;
    cout << endl;
  }

  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 100;
int a[N + 5], b[N + 5];
int n;
int dp[N + 5];
int F(int pos){
  if (pos >= n){
    return 0;
  }
  if (dp[pos] != INT_MIN){
    return dp[pos];
  }
  int x = F(pos + 1) + (a[pos] - b[pos]);
  int y = F(pos + 1);
  return dp[pos] = max(x, y);
}
int main(){
  FASTER;
  for (int i = 0; i < N; i++) dp[i] = INT_MIN;
  cin >> n;
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  for (int i = 0; i < n; i++){
    cin >> b[i];
  }
  cout << F(0) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <utility>
#include <algorithm>
#include <vector>

using namespace std;

typedef pair<int,int> rect_t;
vector<rect_t> ordering;

int comp(const rect_t& a,const rect_t& b){
    return rect_t(a.first*a.first+a.second*a.second,a.first)<rect_t(b.first*b.first+b.second*b.second,b.first);
}

int main(){

    for(int i=1;i<=150;i++)
        for(int j=i+1;j<=150;j++)
            ordering.push_back(rect_t(i,j));

    sort(ordering.begin(),ordering.end(),comp);
    int h,w;
    while(scanf("%d%d",&h,&w)&&(h&&w)){
        auto ans=*(lower_bound(ordering.begin(),ordering.end(),rect_t(h,w),comp)+1);
        printf("%d %d\n",ans.first,ans.second);
    }

    return 0;
}


Measured memory_bytes: 2828
// Etavioxy
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<bitset>
#define il inline
#define ll long long
#define re register
#define rep(i,s,t) for(re int i=(s);i<=(t);i++)
#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)
#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)
#define pt(x) putchar(x)
#define pti(x) printf("%d",x)
#define ptll(x) printf("%lld",x)
#define file(s) freopen(s".in" ,"r",stdin),freopen(s".out","w",stdout)
using namespace std;
il int ci(){
	re char ch;int f=1;
	while(!isdigit(ch=getchar()))f=ch=='-'?-1:1;
	re int x=ch^'0';
	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');
	return f*x;
}
// bitset << 只能用 正数！！
enum{N=81};
const int base= 81*81;
bitset<81*81*2> f[N][N], tmp;
int a[N][N];
int main(){
	int n=ci(), m=ci();
	rep(i,1,n) rep(j,1,m) a[i][j]= ci();
	rep(i,1,n) rep(j,1,m) a[i][j]= abs(a[i][j]-ci());
	f[1][1][base]= 1;
	rep(i,1,n) rep(j,1,m){
		f[i][j]|= f[i-1][j]|f[i][j-1];
		f[i][j]= (f[i][j]>>a[i][j])|(f[i][j]<<a[i][j]);
	}
	rep(i,0,base-1) if( f[n][m][base+i] ){
		pti(i),pt('\n');
		break;
	}
	return 0;
}


Measured memory_bytes: 10624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>

int main() {

    int N;
    string S;
    cin >> N >> S;

    ll ans = 0;
    ll r = 0;
    ll g = 0;
    ll b = 0;

    for (int i = 0; i < N; ++i) {
        if (S[i] == 'R') r++;
        if (S[i] == 'G') g++;
        if (S[i] == 'B') b++;
    }

    ans = r * g * b;

    for (int d = 1; d*2 < N; d++) {
        for (int i = 0; i + d*2 < N; i++) {
            int j = i + d;
            int k = i + 2*d;
            if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans--;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main(){

  ll H=0;

  cin>>H;

  ll t=H;
  ll count=0;
  while(t!=0){

    t/=2;
    count++;
  }

  ll count2=0;
  
  for(int i=0;i<count;i++){

    if(i==0)count2+=1;
    else count2+=pow(2,i);
    
  }
  
  cout<<count2;
  
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
void swap(int *a, int *b){
    int t = *a;
    *a = *b;
    *b = t;
}
int main() {
    int N=3, a[N];
    for (int i=0;i<N;i++) cin >> a[i];
    for (int i=0;i<N-1;i++) {
        for (int j=i+1;j<N;j++) {
           if (a[i] > a[j]) swap(a[i],a[j]);
        }
        cout << a[i] << " ";
    }
    cout << a[N-1] << endl;
    return 0;
}

Measured memory_bytes: 3104
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    Double A=sc.nextDouble();
    Double B=sc.nextDouble();
    Long N=sc.nextLong();
    Double S=0.0;
    if(B-1<=N){
      S=Math.floor(A*(B-1)/B)-(A*(Math.floor((B-1)/B)));

    }else{
      S=Math.floor(A*N/B)-(A*(Math.floor(N/B)));
    }
    int C=(int)(S/100.0*100);
      System.out.println(C);




  }
}


Measured memory_bytes: 37404
# include <cstdio>
# include <iostream>
# include <cstring>
# include <map>
# define R register int

using namespace std;

const int maxn=100005;
int n,m,g;
long long x;
bool f=true;
char s[maxn],t[maxn],c;
map <long long,char> M;

int gcd (int x,int y) { return y?gcd(y,x%y):x; }

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s);
	scanf("%s",t);
	g=gcd(n,m);
	x=1LL*n/g*m;
	for (R i=0;i<n;++i)
		M[1LL*x/n*i]=s[i];
	for (R i=0;i<m;++i)
	{
		c=M[1LL*x/m*i];	
		if(c&&c!=t[i]) f=false;
	}
	if(f) printf("%lld",x);
	else printf("-1");
	return 0;
}

Measured memory_bytes: 10880
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define mp make_pair
#define X first
#define Y second
#define INF 1987654321987654321
#define PI 3.14159265358979323846264
#define MOD 20091101
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };//동북남서

int a[100000];
int main() {
	int n;
	scanf("%d", &n);
	fup(i, 0, n - 1, 1)
		scanf("%d", a + i);
	int now = 2;
	ll ans = a[0] - 1;
	fup(i, 1, n - 1, 1)
	{
		if (a[i] == now)
			now++;
		else
			ans += (a[i] - 1) / now;
	}
	printf("%lld", ans);
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;

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

vector<pair<int, int>> func(ll n)
{
	vector<pair<int, int>> res;
	for (ll i = 2; i * i <= n; i++) {
		if (n % i)continue;
		res.emplace_back(i,0);
		while (n % i == 0) {
			res.back().second++;
			n /= i;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int main()
{
	ll a, b;
	cin >> a >> b;
	ll g = gcd(a, b);
	int size = 0;
	ll ans = 1LL;

	auto v = func(g);
	//printf("gcd=%lld\n", g);
	/*for (int i = 0; i < v.size(); i++) {
		printf("[%d,%d]", v[i].first, v[i].second);
	}*/
	
	printf("%d", v.size() + 1);

	return 0;
}




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

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

int main() {
  int n;
  cin >> n;
  ll t[n];
  rep(i, n) cin >> t[i];
  
  ll ans = t[0];
  rep(i, n) {
    ll gcd = euclid(ans, t[i]);
    ans /= gcd;
    ans *= t[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];


int main(){
    int a,b;
    long long c;
    cin>>a>>b>>c;
    vector<vector<long long>> data(a, vector<long long>(b+1));
 
  // 入力 (2重ループを用いる)
  for (int i = 0; i < a; i++) {
    for (int j = 0; j < b+1; j++) {
      cin >> data.at(i).at(j);
    }
  }
  long long min=INF;
  for (int bit = 0; bit < (1<<a); ++bit) {
        vector<long long> S;
        for (int i = 0; i < a; ++i) {
            if (bit & (1<<i)) { // 列挙に i が含まれるか
                S.push_back(i);
            }
        }
        long long sum=0;
        vector<long long> check(b,0);
        bool flag=true;
        for (int i = 0; i < (int)S.size(); ++i) {
            rep(j,b+1){
                if(j==0){
                    sum+=data.at(S.at(i)).at(j);
                }
                if(j!=0){
                    check.at(j-1)+=data.at(S.at(i)).at(j);
                }
            }
        }
        rep(i,b){
            if(check.at(i)<c){
                flag=false;
            }
        }
        if(flag){
            if(sum<min){
                min=sum;
            }
        }
  }
  if(min==INF){
      cout<<-1<<endl;
  }
  else{
      cout<<min<<endl;
  }
  
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll func(ll n)
{
	return (n*(n-1))/2;
}
int main()
{
	ll n;
  cin>>n;
  unordered_map<string,ll> finale;
  ll i,j;ll ans=0;
  for(i=0;i<n;i++)
  {
  	string s;
    cin>>s;
    vector<ll> check(26,0);
    string check2="";
    for(j=0;j<s.size();j++)
      check[(ll)s[j]-97]++;
     for(j=0;j<26;j++)
     {
         ll num=check[j];
         ostringstream str1; 
         str1<<num;
         string geek = str1.str();
         check2=check2+geek;
     }
    finale[check2]++;
  }
  for(auto it=finale.begin();it!=finale.end();it++){
      ans+=func(it->second);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 12196