akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

#define SIZE 255

char M[SIZE][SIZE];

int main() {
  int n, mx, cnt;
  
  while(cin>>n && n) {
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
	cin >> M[i][j];
      }
    }

    mx = 0;
    // x = k
    for(int i = 0; i < n; i++) {
      cnt = 0;
      for(int j = 0; j < n; j++) {
	if(M[i][j]-'0') { 
	  cnt++;
	  mx = max(mx, cnt);
	} else {
	  cnt = 0;
	}
      }
    }

    // y = k
    for(int i = 0; i < n; i++) {
      cnt = 0;
      for(int j = 0; j < n; j++) {
	if(M[j][i]-'0') { 
	  cnt++;
	  mx = max(mx, cnt);
	} else {
	  cnt = 0;
	}
      }
    }

    int I;
    // y = x + k
    for(int i = 0; i < 2*n; i++) {
      cnt = 0;
      for(int j = 0; j < n; j++) {
	I = -j + i;
	if(0<=I&&I<n) {
	  if(M[I][j]-'0') { 
	    cnt++;
	    mx = max(mx, cnt);
	  } else {
	    cnt = 0;
	  }
	}
      }
    }
    
    // y = -x + k
    for(int i = 0; i < 2*n; i++) {
      cnt = 0;
      for(int j = 0; j < n; j++) {
	I = j + (-(n-1)+i); 
	if(0<=I&&I<n) {
	  if(M[I][j]-'0') { 
	    cnt++;
	    mx = max(mx, cnt);
	  } else {
	    cnt = 0;
	  }
	}
      }
    }

    cout << mx << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1224
N, K = map(int, input().split())
S = input()
H = N - 1
for i in range(N - 1):
    H -= 1 if S[i:i + 2] == "RL" or S[i:i + 2] == "LR" else 0
print(min(H + K * 2, N - 1))


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define mid (l+r)/2
using namespace std;
const int INF=0x3f3f3f3f;
const int MOD=1e5+3;
const int N=2e5+7;
int read()
{
    int f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}
void print(int x)
{
    if(x<0){putchar('-');x=-x;}
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
int n,m,k;
int a[N],f[N],cnt[N],xo[N],ans=0,sit,up;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;++i)
	{
		int u,v,w;
		scanf("%d%d%d",&u,&v,&w);
		a[u]^=w;a[v]^=w;
	}
	up=(1<<15);
	for(int i=0;i<n;++i)
		cnt[a[i]]++;
	for(int i=1;i<=15;++i)
	{
		ans+=cnt[i]/2;
		sit|=((cnt[i]&1)<<(i-1));
	}
	for(int i=1;i<up;++i)
		for(int j=0;j<15;++j)
			if((i>>j)&1) xo[i]^=(j+1); 
	for(int i=1;i<up;++i)
		f[i]=f[i>>1]+(i&1);//统计1的个数（f的上界）
	for(int i=1;i<up;++i)
		f[i]--;
	for(int i=1;i<up;++i)
	{
		if(xo[i]) continue;
		for(int k=(i-1)&i;k;k=(k-1)&i)
		{
			if(xo[k]) continue;
			f[i]=min(f[i],f[k]+f[i^k]);
		}
	}
	printf("%d",ans+f[sit]);
	return 0;
}

Measured memory_bytes: 4488
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>

int main(){
    int h, w;
    std::cin>>h>>w;
    std::vector<std::string> a(h);
    for(int i = 0;i < h;i++){
        std::cin>>a[i];
    }

    for(int i = 0;i < h;i++){
        a[i] = '#' + a[i] + '#';
    }

    std::string dec = "";
    for(int j = 0; j< w;j++){
        dec += '#';
    }
    dec += '#';
    dec += '#';

    std::cout<<dec<<std::endl;
    for(auto x : a){
        std::cout<<x<<std::endl;
    }
    std::cout<<dec<<std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main(){
    int n;cin >>n;
    string s;cin >> s;
    int a=0,b=0;
    rep(i,n)if(s[i]=='R')a++;else b++;
    if(a>b){
        cout << "Yes"<<endl;
    }else {
        cout << "No" <<endl;
    }

}


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

int main() {
  /*
    A: now *= 2
    B: now += K
    AとBを合計N回
  */
  int N, K;
  cin >> N >> K;

  int now = 1;
  for (int i = 0; i < N; i++) {
    if (now * 2 < now + K) {
      now *= 2;
    }
    else {
      now += K;
    }
  }
  cout << now << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
// #include <bits/stdc++.h>
#include <vector>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <iostream>
#include <random>
#include <queue>
#include <algorithm>
#include <climits>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <cstring>
#include <deque>

 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;
typedef vector<cd> vcd;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef vector<vl> vvl;


#define FOR(i,a,b) for (int i=a; i<b; i++)
#define F0R(i,a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = b; i > a; i--)
#define F0Rd(i,a) for (int i = a; i > -1; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define pob pop_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define que queue
#define pa pair
#define ex(m,i) m.find(i)!=m.end()
#define nex(m,i) m.find(i)==m.end()
#define ms(arr,i) memset(arr,i,sizeof(arr))

#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int inf = 1e9;
const int MX = 100001; //check the limits, dummy
const double epsilon = 1e-12;
const int ds[4][2] = {
    {-1,0},
    {1,0},
    {0,-1},
    {0,1}
};

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

    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    // ci, have 0, have 9
    int n; cin >> n;
    vector<vector<vl>> dp = vector<vector<vl>>(n+5,vvl(2,vl(2,0)));
    
    dp[0][0][0] = 1;
    for(int i = 0; i < n; i++){
        dp[i+1][0][0] = (dp[i][0][0] * 8ll)%MOD;
        dp[i+1][1][0] = (dp[i][0][0] + dp[i][1][0] * 9ll)%MOD;
        dp[i+1][0][1] = (dp[i][0][0] + dp[i][0][1] * 9ll)%MOD;
        dp[i+1][1][1] = (dp[i][1][0] + dp[i][0][1]+dp[i][1][1]*10ll)%MOD;
    }

    printf("%lld\n",dp[n][1][1]%MOD);
    
    return 0;
}

Measured memory_bytes: 151068
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;

int main(void){
	int W,H,w,h,x,y;
	cin >> W >> H >> w >> h >> x >> y;
	double ox,oy;
	ox = (double)(min(x+w/2,W/2)+max(x-w/2,-W/2))/2;
	oy = (double)(min(y+h/2,H/2)+max(y-h/2,-H/2))/2;
	printf("%.7lf\n",oy/ox);
	//cout << x-w/2 << " " << -W/2 << " " << ox << endl;
	return 0;
}


Measured memory_bytes: 3220
/*
 * ID: ITP1_7_D
 * Problem: Matrix Multiplication
 */

#include <stdio.h>

int main(void)
{
    int a[100][100];
    int b[100][100];
    int n, m, l;

    scanf("%d %d %d", &n, &m, &l);
        int i, j;
    for (i = 0; i < n; i++)
        for (j = 0; j < m; j++)
            scanf("%d", &a[i][j]);
    for (i = 0; i < m; i++)
        for (j = 0; j < l; j++)
            scanf("%d", &b[i][j]);

    int k;
    for (i = 0; i < n; i++) {
        for (j = 0; j < l; j++) {
            long sum = 0;
            for (k = 0; k < m; k++)
                sum += a[i][k] * b[k][j];
            printf("%ld%s", sum, j < l - 1 ? " " : "");
        }
        printf("\n");
    }

    return 0;
}



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

int main() {
  int A, B;
  cin >> A >> B;
  
  int p = A + B;
  int m = A - B;
  int x = A * B;
  
  if(p >= m && p >= x){
    cout << p << endl;
  } else if(m >= p && m >= x){
    cout << m << endl;
  } else if(x >= p && x >= m){
    cout << x << endl;
  }
}


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

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

  long long R = N % (A + B);
  long long RR = (N / (A + B)) * A;
  cout << min(R, A) + RR << 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 rep1(i,n) for(int i=1;i<=n;i++)
typedef long long ll;

int main(){
  int a,b,x;
  cin >> a >> b >> x;
  if(x>=a && a+b>=x)cout << "YES" << endl;
  else cout << "NO" << endl;
}


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

typedef complex<double> P;

#define X(a)		(a).real()
#define Y(a)		(a).imag()
#define EQ(a,b)		(-EPS<(a)-(b) && (a)-(b)<EPS)
#define EQV(a,b)	( EQ(X(a),X(b)) && EQ(Y(a),Y(b)) )

#define unit(a)		( (a)/abs(a) )
#define normal(a)	( (a)*P(0,1) )
#define dot(a,b)	( X((a)*conj(b)) )
#define cross(a,b)	( Y(conj(a)*(b)) )

// ツ青つ静シツづ陳シツ静シツづ個古ーツ点
P projection(P a, P b, P p)
{
	double t = dot(p-a, a-b) / norm(a-b);
	return a + t*(a-b);
}

// ツ陳シツ静シツづ可妥篠湘個づ按点
P reflection(P a, P b, P p)
{
  return p + 2.0*(projection(a,b,p) - p);
}

int main()
{
	double a,b,c,d,e,f;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&a,&b,&c,&d,&e,&f)!=EOF)
	{
		P p(a,b),q(c,d),r(e,f),s;
		s = reflection(p,q,r);
		printf("%.6lf %.6lf\n",X(s),Y(s));
	}
}

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 100000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


plus = 0
minus = 0
a.sort(reverse = True)
for i in range(n-k+1):
    plus += cmb(n-1-i, k-1, mod) * a[i]
    plus %= mod
a.reverse()
for i in range(n-k+1):
    minus += cmb(n-1-i, k-1, mod) * a[i]
    minus %= mod

print((plus-minus+mod) % mod)


Measured memory_bytes: 20744
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

struct edge {
	int v,w,nxt;
} e[400050];

int head[100050],ecnt;

void adde(int u,int v,int w) {
	e[++ecnt].v = v;
	e[ecnt].w = w;
	e[ecnt].nxt = head[u];
	head[u] = ecnt;
}

int N,M;
int l[200050],r[200050];
int d[200050];
int dist[100005];
queue<int> que;
bool vis[100050],inq[100050];

bool spfa(int st) {
	que.push(st);
	inq[st] = 1;
	dist[st] = 0;
	while(!que.empty()) {
		int u = que.front();
		que.pop();
		for(int i = head[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if(dist[v] == 1061109567) {
				dist[v] = dist[u] + e[i].w;
				vis[v] = 1;
				if(!inq[v]) que.push(v);
			}
			else if(dist[v] != dist[u] + e[i].w) return 0;
				
		}
		inq[u] = 0;
	}
	return 1;
}

int main() {
	memset(dist,0x3f,sizeof(dist));
	scanf("%d%d",&N,&M);
	for(int i = 1; i <= M; ++ i) {
		scanf("%d%d%d",&l[i],&r[i],&d[i]);
		adde(l[i],r[i],d[i]);
		adde(r[i],l[i],-d[i]);
	}
	for(int i = 1; i <= N; ++ i) {
		if(!vis[i]) {
			vis[i] = 1;
			if(!spfa(i)) {
				printf("No\n");
				return 0;
			}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 8704
h,*s=open(0)
h,w,k,*m=map(int,h.split())
b=w
while b:
 b-=1;r=t=j=0;d=[0]*h
 while w-j:
  i=c=0;j+=1
  while h-i:
   d[c]+=s[i][~j]>'0';c+=b>>i&1;i+=1
   if max(d)>k:d=[0]*h;f=t<j;r-=h*w*~-f-1;t=j;j-=f;break
 m+=r+c,
print(min(m))

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

using namespace std;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long  ll;
#define endl '\n'


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


const int MOD = 1000000007;

//////////////////////////////////////////


int n;
string s;

void Input() {

    cin >> n;
    cin >> s;
}

void Solve() {

    char check;
    int ans = 1;

    check = s[0];

    for(int i = 1; i < n; i++) {

        if(check != s[i]) {

            ans++;
            check = s[i];
        }
    }

    cout << ans << endl;
}

int main() {

  cin.tie(0);
  ios::sync_with_stdio(false);
  Input();
  Solve();
  return 0;

}



Measured memory_bytes: 512
#include <stdio.h>

int main(void)
{
    int rect_w, rect_h, x, y, r;
    scanf("%d %d %d %d %d", &rect_w, &rect_h, &x, &y, &r);

    if (0 <= x - r && x + r <= rect_w && 0 <= y - r && y + r <= rect_h) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int N;
cin >> N;
int people = 0;

for ( int i = 0; i < N; i++){
    int l;
    int r;
    cin >> l >> r;
    people += r - l + 1;
}
cout << people << endl;
}

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

n,t =  (int(x) for x in input().split())

A = []
for i in range(n):
    c,ti  =  (int(x) for x in input().split())
    A.append([c,ti])

A.sort(key=lambda x: x[1])

if A[0][1] > t:
    print("TLE")
else:
    min = A[0][0]
    for i in A:
        if i[1] > t:
            break
        
        if min > i[0]:
            min = i[0]
        
    print(min)

Measured memory_bytes: 3064
#include<stdio.h>

double roundup(double x);

int main(void){
	double debt;
	int debt2;
	double rishi;
	int n;	//年数入力用変数
	int i;	//ループ用変数
	debt = 100000;
	rishi = 1.05;

	scanf("%d", &n);

	for (i = 0; i < n; i++){
		debt = debt*rishi;
		debt = roundup(debt/1000);
		debt *= 1000;
	}
	debt2 = (int)debt;
	printf("%d\n", debt2);

	return 0;

}

double roundup(double x){
	if (x != (int)x){
		x += 1;
		x = (int)x;
	}
	return x;

}

Measured memory_bytes: 588
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto C = new int[](N);
    auto D = new long[](N);
    foreach (i; 0..N) {
        auto s = readln.split.map!(to!long);
        C[i] = s[0].to!int;
        D[i] = s[1];
    }

    long ans = 0;
    int tmp = 0;
    int[] amari;

    foreach (i; 0..N) {
        if (D[i] <= 1) {
            continue;
        }
        tmp = 0;
        while (D[i] > 1) {
            ans += D[i] / 2;
            if (D[i] % 2) {
                amari ~= C[i];
            }
            if (D[i] > 1) {
                if (C[i] >= 5) {
                    ans += D[i] / 2;
                    C[i] = C[i] * 2 - 9;
                } else {
                    C[i] *= 2;
                }
            }
            if (D[i] > 1) {
                tmp = C[i];
            }
            D[i] /= 2;
        }
        foreach (a; amari) {
            if (tmp + a >= 10) {
                ans += 2;
                tmp = (tmp + a) - 9;
            } else {
                ans += 1;
                tmp += a;
            }
        }
        amari = [];
        C[i] = tmp;
    }

    tmp = C.front;
    foreach (a; C[1..$]) {
        if (tmp + a >= 10) {
            ans += 2;
            tmp = (tmp + a) - 9;
        } else {
            ans += 1;
            tmp += a;
        }
    }

    ans.writeln;
}




Measured memory_bytes: 5116
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/
int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  
  ll K; cin >> K;
  ll num = 7;
  rep(i, 1e6+1){
    if (num % K == 0){
      cout << i+1 << endl;
      return 0;
    }
    num *= 10;
    num += 7;
    num %= K;
  }
  cout << -1 << endl;
}


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

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

#define MAX 100005
#define INF INT_MAX

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

void preorder(Node u);
void inorder(Node u);

Node root;

Node treeMinimum(Node x)
{
    return NIL;
}
Node treeMaximum(Node x)
{
    return NIL;
}
Node treeSearch(Node u, int k)
{
    return NIL;
}
Node treeSuccessor(Node x)
{
    return NIL;
}
void treeDelete(Node z)
{
    Node y; // node to be deleted
    Node x; // child of y
}

void insert(int k)
{
    Node y = NIL;
    Node x = root;
    Node z;

    z = (Node)malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while (x != NIL) {
        y = x;
        if (k < x->key) x = x->left;
        else x = x->right;
    }
    if (y == NIL) root = z;
    else if (k < y->key) y->left = z;
    else y->right = z;
}

void inorder(Node u)
{
    if (u == NIL) return;
    
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);    
}
void preorder(Node u)
{
    if (u == NIL) return;

    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main(int, char**)
{
    int n, i, x;
    string com;
    cin >> n;

    for ( i = 0; i < n; i++ ){
        cin >> com;
        if ( com[0] == 'f' ){
            cin >> x;
            Node t = treeSearch(root, x);
            if ( t != NIL ) cout << "yes" << endl;
            else cout << "no" << endl;
        } else if ( com[0] == 'i' ){
            cin >> x;
            insert(x);
        } else if ( com[0] == 'p' ){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else if ( com[0] == 'd' ){
            cin >> x;
            treeDelete(treeSearch(root, x));
        }
    }
    return 0;
}



Measured memory_bytes: 26596
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int a, b;
    cin >> a >> b;
    if (b == 0)
        cout << a << endl;
    else
        cout << (a + b) % 24 << endl;
}



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

int main(){
    string s,t;
    cin>>s>>t;

    int n=t.length();

    t=t.erase(n-1);

    if(s==t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3568
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> dp(H + 1, vector<int>(W, 0));
  dp[0][0] = 1;
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = 0; k < 1 << (W - 1); k++) {
        bool ok = true;
        for (int l = 0; l < W - 2; l++) {
          if (((k >> l) & 1) && ((k >> (l + 1)) & 1)) {
            ok = false;
          }
        }
        if (ok) {
          if (j >= 1 && ((k >> (j - 1)) & 1)) {
            dp[i + 1][j - 1] += dp[i][j];
            dp[i + 1][j - 1] %= mod;
          }
          else if (j <= W - 2 && ((k >> j) & 1)) {
            dp[i + 1][j + 1] += dp[i][j];
            dp[i + 1][j + 1] %= mod;
          }
          else {
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= mod;
          }
        }
      }
    }
  }
  cout << dp[H][K - 1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
const int MOD=1000000007;

bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
int highestPowerof2(unsigned int n) 
{ 
    // Invalid input 
    if (n < 1) 
        return 0; 
  
    int res = 1;
    for (int i=0; i<8*sizeof(unsigned int); i++) 
    { 
        int curr = 1 << i; 
        if (curr > n) 
           break; 
  
        res = curr; 
    } 
  
    return res; 
} 
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}       
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int t=1;
  while(t--)
  {
      string s;
      cin>>s;
      int x=s.length();
      REP(i,x)cout<<"x";
  }
  return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v;
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    if(N==0){
        p(0);
        return 0;
    }

    vector<ll> answer;

    while(N!=0){
        ll r = N%2;
        if(r<0){
            r+=2;
        }
        answer.push_back(r);

        N -= r;
        N = N / (-2);
    }

    reverse(ALL(answer));
    vprint(answer);

    return 0;
}

Measured memory_bytes: 256
inf = float('inf')

n, m = map(int, input().split())

dp = [inf] * (1 << n)
dp[0] = 0

for _ in range(m):
    cost, _ = map(int, input().split())
    c = (int(x) - 1 for x in input().split())

    mask = 0
    for k in c:
        mask |= 1 << k

    for b in range((1 << n) - 1):
        nb = b | mask
        dp[nb] = min(dp[nb], dp[b] + cost)

res = dp[(1 << n) - 1]
print(-1 if res == inf else res)


Measured memory_bytes: 49244
(* O(h w) *)
Scanf.scanf " %d %d" @@ fun h w ->
  let ss = Array.init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s in
  let bs = Array.init h @@ fun _ -> Bytes.create w in
  let f a b =
    let c = ref 0 in
    for y = -1 to 1 do
      for x = -1 to 1 do
        let a_y, b_x = a + y, b + x in
        if 0 <= a_y && a_y < h && 0 <= b_x && b_x < w then
          if ss.(a_y).[b_x] = '#' then incr c
      done
    done;
    char_of_int @@ 48 + !c in
  for y = 0 to h - 1 do
    for x = 0 to w - 1 do
      Bytes.set bs.(y) x @@ if ss.(y).[x] = '.' then f y x else '#'
    done 
  done;
  Array.iter (fun b -> print_bytes b; print_newline ()) bs

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <limits.h>
#include <stdio.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    
    //unsigned long long int l[n];
    std::vector<int> l;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    std::sort(l.begin(), l.end());
        
    int cnt = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            if(l[i] == l[j]) continue;
            for(int k=j+1; k<n; k++){
                if(l[i] == l[j] || l[k] == l[j] || l[i] == l[k]) continue;
                //cout << i+1 << ", " << j+1 << ", " << k+1 << ", " << endl;
                //cout << l[i] << ", " << l[j] << ", " << l[k] << ", " << endl;
                //unsigned  long long tmp = sqrt(l[i]*l[i]+l[j]*l[j]);
                unsigned  long long tmp = l[i]+l[j];
                
                if(l[k] < tmp){
                    cnt++;
                    //cout << tmp << endl;
                }
            }
        }
    }
    cout << cnt << endl;
    /*
    int ans = 0;
    if(s == "RRR") cout << 3 << endl;
    else if(s == "RRS") cout << 2 << endl;
    else if(s == "SRR") cout << 2 << endl;
    else if(s == "SSR") cout << 1 << endl;
    else if(s == "SRS") cout << 1 << endl;
    else if(s == "RSS") cout << 1 << endl;
    else if(s == "RSR") cout << 1 << endl;
    else cout << 0 << endl;
    */
 
    
    return 0;
}

Measured memory_bytes: 3620
N = gets.to_i
A = gets.split(" ").map(&:to_i)
ans = Array.new(N, 0)
ans[0] = A.inject(:+)
j = 1
while j < N  do
    ans[0] -= 2 * A[j] 
    j += 2
end

(N - 1).times do |i|
    ans[i + 1] = 2 * A[i] - ans[i]
end

puts ans.join(" ")

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

#define rep(i, N)   for(int i = 0; i < (int)N; i++)
const long long INF = 1LL<<60;

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

    cout << 180 * (N - 2) << endl;
}

Measured memory_bytes: 256
fn main(){
  let inf: usize = 200000000;
  
  loop {
    let nk: Vec<usize> = read_vec();
    let n = nk[0];
    let k = nk[1];

    if n == 0 && k == 0 { break; }

    let mut ntu = false;
    let mut dist: Vec<Vec<usize>> = vec![vec![inf; n]; n];
    
    for i in 0 .. n {
      dist[i][i] = 0;
    }
    
    for _ in 0 .. k {
      let q: Vec<usize> = read_vec();

      if q[0] == 0 {
        let a = q[1] - 1;
        let b = q[2] - 1;

        if ntu {
          wf(&mut dist, n);
          ntu = false;
        }
        
        if dist[a][b] == inf {
          println!("-1");
        } else {
          println!("{}", dist[a][b]);
        }
      } else {
        let c = q[1] - 1;
        let d = q[2] - 1;
        let e = q[3];

        if dist[c][d] > e {
          dist[c][d] = e;
          dist[d][c] = e;
          ntu = true;
        }
      }
    }
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}

fn wf(d: &mut Vec<Vec<usize>>, n: usize) {
  for k in 0 .. n {
    for i in 0 .. n {
      for j in 0 .. n {
        let t = d[i][k] + d[k][j];
        if t < d[i][j] {
          d[i][j] = t;
        }
      }
    }
  }
}



Measured memory_bytes: 5048
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

// 約数の列挙 O(√n)
vector<ll> divisor(ll n) {
    vector<ll> res;

    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }

    return res;
}

// 素因数分解 O(√n)
map<ll, ll> prime_factor(ll n) {
    map<ll, ll> res;

    for (ll i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ++res[i];
            n /= i;
        }
    }

    if (n != 1) res[n] = 1;

    return res;
}

ll euclidean_gcd(ll a, ll b) {
    if (a < b) return euclidean_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    INIT;

    ll A, B;
    cin >> A >> B;

    ll gcd = euclidean_gcd(A, B);
    // cout << gcd << endl;

    map<ll, ll> ds = prime_factor(gcd);
    ll ans = 1;

    repv(ds) { ans++; }

    cout << ans << endl;

    return 0;
}

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

int main(){
  char c;
  cin >> c;
  if(c == 'a' ||c == 'e' ||c== 'i' ||c== 'o' ||c== 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 256
n,m=map(int, input().split())
ans=['*']*n

for _ in range(m):
    s,c=input().split()
    s=int(s)
    if ans[s-1] == '*' or ans[s-1] == c:
        ans[s-1]=c
    else:
        print('-1')
        exit()

if len(ans) == 1:
    if ans[0] == '*':
        ans[0]=0
    print(ans[0])
    exit()

if ans[0] == '0':
    print('-1')
    exit()

for i, val in enumerate(ans):
    if i == 0 and val == '*':
        print("1", end="")
    elif val == '*':
        print("0", end="")
    else:
        print(val, end="")

print("")

Measured memory_bytes: 3064
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

total = p[:x]+q[:y]
total.sort(reverse=True)

#print(p, q, total)

for i in range(min(x+y, c)):
  if total[-(i+1)]<r[i]:
    total[-(i+1)] = r[i]
  else:
    break

print(sum(total))

Measured memory_bytes: 105580
n = int(input())
l = list(map(int,input().split()))
d = {}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i] = 1
cp = 0
for i in d.values():
    cp+= i*(i-1)//2
for i in l:
    print(cp-d[i]+1)

Measured memory_bytes: 24996
def resolve():
    A, B, C, D = map(int, input().split()) 

    if (A // D) == (C // B): 
        if (A % D) == 0 and (C % B) != 0:
            print("No")
        else:
            print("Yes")
    elif (C // B) < (A // D):
        print("Yes")
    else:
        if (C // B) == ((A // D) + 1) and (C % B) == 0:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 9136
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

bool solve(string s, ll start, ll stop) {
    // cout << "solve" << endl;
    bool flag = false;
    for (int i = start+1; i <= stop; i++) {
        if (s[i] == '#') {
            // cout << "#" << endl;
            if (flag) return false;
            flag = true;
        }
        else
        {
            // cout << "." << endl;
            flag = false;
        }
    }
    return true;
}

bool can_throw(string S, ll start, ll stop) {
    // return true;
    for (int i = start; i <= stop; i++) {
        if (S[i-1] == '.' and S[i] == '.' and S[i+1] == '.') {
            return true;
        }
    }
    return false;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    // 0indexs
    A--;
    B--;
    C--;
    D--;
    std::string S;
    std::cin >> S;

    if ((C < D) or (C < B)) {
        if (solve(S, A, C) and solve(S, B, D)) {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
    else
    {
        if (solve(S, A, C) and solve(S, B, D)) {
            if ( can_throw(S, max({A, B}), min({C, D})) ) {
                cout << "Yes" << endl;
            }
            else
            {
                cout << "No" << endl;
            }
        }
        else
        {
            cout << "No" << endl;
        }
    }
    
}


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

int main() {
    int n;
 cin >> n;
 vector<long long> a(n);
 rep(i,n) {
  cin >> a.at(i);
  }
  long long ans = 0;
  
  long long sum =0;
   rep(i,n) {
   ans = (ans+a.at(i)*sum)%1000000007;
   sum=(sum+a.at(i))%1000000007;    
   
   }

    
    cout << ans;
 }


Measured memory_bytes: 4848
#include <iostream>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

long long fun(long long x) {
    if(x == 1) {
        return 1;
    }
    else {
        return 1 + (2 * fun(x/2));
    }
}

int main() {
    long long h;
    cin >> h;
    cout << fun(h) << "\n";    
    return 0;
}

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

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int K, N;
	cin >>N >>K;
	if (1==K)
		cout <<0 <<endl;
	else
		cout <<N-K <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  while(cin>>n,n){
    for(int i=0,k;i<9;i++){
      cin>>k;
      n-=k;
    }
    cout<<n<<endl;
  }
  return 0;
}

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

char s[100010];

int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	if((!(n&1))^(s[1]==s[n]))
	{
		puts("Second");
	}
	else
	{
		puts("First");
	}
}

Measured memory_bytes: 384
N=int(input())
p = list(map(int,input().split()))
cnt=0
x=[]
for i in range(N):
    if i==0:
        x=p[i]
        cnt+=1
    else:
        if p[i]<x:
            x=p[i]
        if p[i] <= x:
            cnt+=1
            x = p[i]
        else:
            continue
print(cnt)

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

#define MAX 200000
#define SENTINEL 2000000000
typedef long long llong;

int L[MAX / 2 + 2], R[MAX / 2 + 2];

llong merge(int A[], int n, int left, int mid, int right) {
	int i, j, k;
	llong cnt = 0;
	int n1 = mid - left;
	int n2 = right - mid;
	for (i = 0; i < n1; i++)L[i] = A[left + i];
	for (i = 0; i < n2; i++)R[i] = A[mid + i];
	L[n1] = R[n2] = SENTINEL;
	i = j = 0;
	for (k = left; k < right; k++) {
		if (L[i] <= R[j]) {
			A[k] = L[i++];
		}
		else {
			A[k] = R[j++];
			cnt += n1 - i;
		}
	}
	return cnt;
}

llong mergeSort(int A[], int n, int left, int right) {
	int mid;
	llong v1, v2, v3;
	if (left + 1 < right) {
		mid = (left + right) / 2;
		v1 = mergeSort(A, n, left, mid);
		v2 = mergeSort(A, n, mid, right);
		v3 = merge(A, n, left, mid, right);
		return v1 + v2 + v3;
	}
	else return 0;
}

int main() {
	int A[MAX], n, i;

	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> A[i];
	}

	llong ans = mergeSort(A, n, 0, n);
	cout << ans << endl;

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    
    int i,p;
    int SUM = 0;
    int x;
    for(p = 1; ; p++){
        if(pow(10,p) > N){
            break;
        }
    }
    
    for(i = 0; i < p-1; i++){
        if(i%2==0){
            SUM += 9*pow(10,i);
        }
    }
    if(p%2 == 1){
        SUM += N - pow(10,p-1) + 1;
    }
    
    cout << SUM << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	char A, B;
	cin >> A >> B;

	if (A == B) {
		cout << "=" << endl;
	}
	else if (A > B) {
		cout << ">" << endl;
	}
	else {
		cout << "<" << 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 rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    string s; cin >> s;
    int a = 0, b = 0, c = 0;
    for (char ch: s) {
        if (ch == 'a') a++;
        if (ch == 'b') b++;
        if (ch == 'c') c++;
    }

    bool ok = true;
    if (abs(a-b) > 1 || abs(b-c) > 1 || abs(c-a) > 1) ok = false;
    cout << (ok ? "YES" : "NO") << endl;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;   
    string tmp;
    char back;
    bool flag = true;
    vector<string> W;
    for(int i = 0; i < N; i++){
        cin >> tmp;
        if(i != 0){
            if(tmp[0] != back){
                flag = false;
            }
        }
        back = tmp.back();
        if(find(W.begin(), W.end(), tmp) != W.end()){
            flag = false;
        }
        W.push_back(tmp);
    }
    if(flag == true){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;



}



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

typedef pair<int,int> P;
typedef pair<int,P> PP;
PP kouji[200005];
int d[200005];
vector<int> Q[200005];
int ans[200005];

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

  for(int i = 0; i < n;i++) {
    int s,t,x;
    cin >> s >> t >> x;
    kouji[i] = PP(x,P(s,t));
  }
 
  sort(kouji,kouji + n);
  /* for(int i = 0; i < n; i++) {
    cout << kouji[i].first <<"   "<<kouji[i].second.first<<"   "<<kouji[i].second.second<<endl;
    }*/
  
  for(int i = 0; i < q; i++) cin >> d[i];

  for(int i = 0; i < n; i++) {
    int S = kouji[i].second.first;
    int T = kouji[i].second.second;
    int X = kouji[i].first;
    int l = lower_bound(d,d+q,S - X) - d;
    int r = upper_bound(d,d+q,T - 1  - X) - d;
    //   cout << "l = "<<l<<"   r = "<<r<<endl;
     Q[l].push_back(i+1);
    Q[r].push_back(i+1);
  }

  /* for(int i = 0; i < q; i++) {
    for(int j = 0; j < Q[i].size(); j++) {
      cout <<"Q["<<i<<"]["<<j<<"] = "<<Q[i][j] << endl;
    }
    }*/
  set<int> qq;

  for(int i = 0; i < q; i++) {
    for(int j = 0; j < Q[i].size(); j++) {
      if(qq.find(Q[i][j]) == qq.end()) {
	qq.insert(Q[i][j]);
	auto itr = qq.begin();
	ans[i] = *itr;
      }
      else {
	qq.erase(Q[i][j]);
	if(qq.size() == 0) ans[i] = -1;
	else {
	  auto itr = qq.begin();
	    ans[i] = *itr;
	}
      }
    }
    if(Q[i].size() == 0) {
      if(qq.size() == 0) ans[i] = -1;
      else {
	auto itr = qq.begin();
	ans[i] = *itr;
      }
    }
    }

  /* for(int i = 0; i < q; i++) {
    cout << "ans["<<i<<"] = "<<ans[i] << endl;
    }*/

  for(int i = 0; i < q; i++) {
    if(ans[i] == -1) cout << -1 << endl;
    else cout << kouji[ans[i] - 1].first << endl;
  }

}
  
  


Measured memory_bytes: 26228
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt;
  int n;
  cin >> n;
  vector<int> x(n + 2), y(n + 2), r(n + 2);
  x[0] = xs;
  y[0] = ys;
  x[n + 1] = xt;
  y[n + 1] = yt;
  for (int i = 1; i <= n; i++) {
    cin >> x[i] >> y[i] >> r[i];
  }
  vector<vector<pair<int, double>>> g(n + 2);
  for (int i = 0; i < n + 2; i++) {
    for (int j = 0; j < n + 2; j++) {
      if (i == j) continue;
      g[i].push_back({j, max(0.0, sqrt(1. * (x[i] - x[j]) * (x[i] - x[j]) + 1. * (y[i] - y[j]) * (y[i] - y[j])) - (r[i] + r[j]))});
    }
  }
  vector<double> dist(n + 2, 1e10);
  dist[0] = 0;
  priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> que;
  que.push({0, 0});
  while (que.size()) {
    auto cur = que.top();
    que.pop();
    if (cur.first - dist[cur.second] > 1e-8) continue;
    for (auto nbr : g[cur.second]) {
      int to = nbr.first;
      double d = nbr.second;
      if (dist[to] > dist[cur.second] + d) {
        dist[to] = dist[cur.second] + d;
        que.push({dist[to], to});
      }
    }
  }
  cout << setprecision(20) << fixed << dist[n + 1] << '\n';
  return 0;
}

Measured memory_bytes: 22524
n = int(input())
d,x = map(int,input().split())
a = []
for i in range(n):
    a.append(int(input()))
eat_chocolate = 0
for i in range(n):
    Ai = a[i]
    m = 1
    eat_day = 1
    while eat_day <= d:
        eat_day = Ai*m + 1
        eat_chocolate += 1
        m += 1
print(eat_chocolate+x)

Measured memory_bytes: 3064
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    d = {i * j for i in range(1, 10) for j in range(1, 10)}
    n = int(input().rstrip('\n'))
    print("Yes" if n in d else "No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 40496
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<utility>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<unordered_set>
#include<unordered_map>
#include<set>
#include<map>
#include<list>

using namespace std;
using ll = long long;

#define in(s) cin >> s
#define out(s) cout << s << endl
#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define pcnt __builtin_popcount
#define pcntll(x) __builtin_popcountll(x)
#define DMAX DBL_MAX;
#define IMIN INT_MIN;
#define IMAX INT_MAX;

const long long MOD = 1e9+7;
const long long INF = 1e11;
const long long MAX = 3e5+1;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int N, M, X;
    in(N); in(M); in(X);

    vector<int> C(N, 0);
    vector<vector<int>> A(N, vector<int> (M, 0));
    rep(i, N) {
        in(C[i]);
        rep(j, M) in(A[i][j]);
    }
    int ans = INT_MAX;
    int cost;
    rep(i, (1<<N)) {
        cost = 0;
        vector<int> U(M, 0);

        rep(j, N) {
            if ((i>>j) & 1) {
                cost += C[j];
                rep(k, M)
                    U[k] += A[j][k];
            }
        }
        /*
        rep(j, M) cout << U[j] << '\t';
        cout << endl;
        cout << cost << endl;
        */

        bool flag = true;
        rep(j, M) {
            if (U[j] < X) {
                flag = false;
                break;
            }
        }
        if (!flag) continue;
        ans = min(ans, cost);
    }

    if (ans == INT_MAX) out(-1);
    else out(ans);


    return 0;
}


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

int main() {
    int n;
    cin >> n;
    map<string, int> counter;
    while (n--) {
        string s;
        cin >> s;
        counter[s]++;
    }
    cout << "AC" << " x " << counter["AC"] << endl;
    cout << "WA" << " x " << counter["WA"] << endl;
    cout << "TLE" << " x " << counter["TLE"] << endl;
    cout << "RE" << " x " << counter["RE"] << endl;
}


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

int main() {
  int A,B;
  cin >>A>>B;
  int c=0;
  
  for(int i=A;i<B+1;i++){
    if(i%10==i/10000 && (i/10)%10==(i/1000)%10)c++;
  }
  cout << c << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n;
	int i, j, k, l;
	int num[100];
	int sort;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d", &num[i]);
	}
	
	for (i = 0; i < n; i++){
		for (k = 0; k < n; k++){
			printf("%d", num[k]);
			if (k < n - 1){
				printf(" ");
			}
		}
		printf("\n");
		
		for (j = 0; j < i + 1; j++){
			if (num[i + 1] < num[j]){
				sort = num[j];
				num[j] = num[i + 1];
				num[i + 1] = sort;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 604
def search(t,st,h,sh):
    for ta in t:
        for ha in h:
            if st-ta+ha==sh-ha+ta: return ' '.join(map(str,[ta,ha]))
    return -1

while True:
    n,m = map(int,input().split())
    if n==m==0: break
    t = sorted([int(input()) for _ in range(n)])
    h = sorted([int(input()) for _ in range(m)])
    st,sh = sum(t),sum(h)
    r = search(t,st,h,sh)
    print(r)

Measured memory_bytes: 7488
#include<stdio.h>
int main()
{
    int k,a,b,i=1,m=1;
    scanf("%d%d%d",&k,&a,&b);
    while (k*i<=b)
    {
        if((k*i)>=a && (k*i)<=b)
        {
            printf("OK\n");
            return 0;
        }
        i++;
    }
    printf("NG\n");
    
}

Measured memory_bytes: 1648
import math
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

for p in range(1, 4):
    D = []
    for count in range(n):
        D.append((math.fabs(A[count] - B[count]))**p)
    if p==1:
        di = max(D)
    d=(sum(D))**(1/p)
    print('%.06f' % d)
print('%.06f' % di)

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

#define REP(i, s, e) for(int i = (int)s; i < (int) e; i++)
#define rep(i, n) REP(i, 0 ,n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define fi first
#define se second
#define pb push_back
#define mp nake_pair

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

struct query{
    int x, y, w;
};

int calc(vector<pii>& p){
    int ret = 0;
    for(auto & a : p){
        if(ret >= a.fi) ret = max(ret, a.se);
        else return -1;
    }
    return ret;
}

int main(){
    int n, w, h;
    cin>>n>>w>>h;
    vector<query> q;
    rep(i, n){
        query t;
        cin>>t.x>>t.y>>t.w;
        q.pb(t);
    }
    vector<pii> x, y;
    for(auto & p : q){
        x.pb({max(0, p.x-p.w), min(w, p.x+p.w)});
        y.pb({max(0, p.y-p.w), min(h, p.y+p.w)});
    }
    sort(all(x));
    sort(all(y));
    int fx = calc(x), fy = calc(y);
    if(fx == w || fy == h) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 7092
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        x: usize, d: usize,
        xd_vec: [[isize; d]; x]
    }

    let mut ans = 0;

    for i in 0..x {
        for j in 0..x {
            if i == j {
                continue
            }
            let mut tmp_sum = 0;
            for idx in 0..d {
                tmp_sum += (xd_vec[i][idx] - xd_vec[j][idx]).pow(2);
            }

            if num_rational::Ratio::from_float((tmp_sum as f64).sqrt()).unwrap().is_integer() {
                ans += 1;
            }
        }
    }

    println!("{}", ans/2);
}


Measured memory_bytes: 2624