akhauriyash/Code-Regression huggingface dataset:
/* Author: $%U%$
 * Time: $%Y%$-$%M%$-$%D%$ $%h%$:$%m%$:$%s%$
**/
#include <bits/stdc++.h>
using namespace std;
#define fore(i, a, b) for (int i = a, to = b; i < to; i++)
#define foref(i, a, b) for (int i = b - 1, to = a; i >= to; i--)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;
typedef pair<int, int> Pair;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  Long n, x, t;
  cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << endl;

  return 0;
}

Measured memory_bytes: 3464
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    bool flag = false;
    for(int i = 0; i < n; ++i){
        char c;
        cin >> c;
        flag |= (c == 'Y');
    }
    cout << (flag ? "Four" : "Three") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
using namespace std;
int main()
{
    int x,a;
    int sum=0;
    scanf("%d%d",&x,&a);
    int i,l[101];
    for(i=0; i<x; i++)
        scanf("%d",&l[i]);
    for(i=0; i<x; i++)
    {
        sum+=l[i];
        if(sum>a) break;
    }
    printf("%d\n",i+1);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
float d,t,v;
//string ws="aji";
int main() {
	// your code goes here
	cin >> d>>t>>v;
    float t_resultante = d/v;
    if(t_resultante<=t){
        cout << "Yes";

    }
    else{
        cout << "No";
    }
 
}

Measured memory_bytes: 3168
f::[Int]->String
f []="Yes"
f (x:[])="Yes"
f (x:y:es)
     |x<y=f ((y-1):es)
     |x==y=f (y:es) 
     |otherwise="No"

main =do
      n<-getLine
      e<-getLine
      let xs=map read (words e)::[Int]
      putStrLn $ f xs

Measured memory_bytes: 36220
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if ((A + B) == (C + D)) {
    cout << "Balanced" << endl;
  }
  else if ((A + B) > (C + D)) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

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

using namespace std;

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

typedef pair<int, int> ii;

const int N = 1e4 + 5;

int n;

int a[N], b[N];
long long cons = 0;

long long sumA, sumB;

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        sumA += a[i];
    }
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        sumB += b[i];
    }
    if(sumA > sumB) {cout << "No\n"; return 0;}
    for(int i = 1; i <= n; i++){
        if(a[i] < b[i])
            cons -= (b[i] - a[i]) / 2;
        else
            cons += a[i] - b[i];
    }
    if(cons > 0)
        cout << "No\n";
    else
        cout << "Yes\n";
}


Measured memory_bytes: 384
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,ii ) for( typeof(gg.begin()) ii=gg.begin();ii!=gg.end();ii++)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define sz(a) int((a).size())
#define N 100010
#define MAX 30
#define mod 1000000007
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define all(a) a.begin(),a.end()
const ll INF = 1e18+1;

int parent[N],ans=0,k;
vector <int> G[N];

int dfs(int v, int par)
{
	int curr=0,w;
	REP(i,sz(G[v]))
	{
		w=G[v][i];
		curr=max(curr,dfs(w,v));
	}
	if (curr==k-1&&par!=0&&v!=0)
	{
		curr=0;
		//printf("%d\n",v+1);
		ans++;
	}
	else curr++;
	//printf("%d %d\n",v+1,curr);
	return curr;
}

int main()
{
	int n;
	scanf("%d%d",&n,&k);
	REP(i,n)
	{
		scanf("%d",&parent[i]);
		parent[i]--;
		if (i!=0) G[parent[i]].pb(i);
	}
	dfs(0,-1);
	if (parent[0]!=0) ans++;
	printf("%d\n",ans);
return 0;
}


Measured memory_bytes: 13952
#include<iostream>
#include<math.h>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
long long c[26];
int main()
{
	string a;
	cin>>a;
	long long n=a.size();
	long long ans=n*(n-1)/2;
	for(long long i=0;i<n;i++)
	c[a[i]-'a']++;
	for(long long i=0;i<26;i++)
	if(c[i]>=2)
	ans-=c[i]*(c[i]-1)/2;
	cout<<ans+1;
	return 0;
}

Measured memory_bytes: 640
N = int(input())
S = input()

stock = 0
L_cnt = 0
for s in S:
    if s == "(":
        stock += 1
    if s == ")":
        if stock == 0:
            L_cnt += 1
        else:
            stock -= 1

print("(" * L_cnt + S + ")" * stock)

Measured memory_bytes: 3064
N=int(input())
flag=0
count=0
for i in range(N):
    d1,d2=map(int,input().split())
    if(d1==d2):
        count+=1
    else:
        count=0
    if(count==3):
        flag=1
        break
if(flag==1):
    print("Yes")
else:
    print("No")

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

int main() {
  vector<int> x(5);
  rep(i, 5) {
    cin >> x[i];
    if(x[i] == 0) cout << i << '\n';
  }
}

Measured memory_bytes: 3580
N, Q = map(int, input().split())
S = input()
X = [list(map(int, input().split()))for _ in range(Q)]

a =[0]*N
for i in range(1,N):
    if S[i] =="C" and S[i-1] =="A":
        a[i] = a[i-1]+1
    else:
        a[i] = a[i-1]
# print(a)
for i in range(Q):
    print(a[X[i][1]-1]-a[X[i][0]-1])

Measured memory_bytes: 30752
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

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

// container util
#define all(x) (x).begin(), (x).end()

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

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

//
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s, t;
  cin >> s >> t;
  int index = -1;
  rep(i, (int)s.size() - (int)t.size() + 1) {
    string c = s.substr(i, t.size());
    bool flag = true;
    rep(j, t.size()) {
      if (c[j] != t[j]) {
        if (c[j] != '?') flag = false;
      }
    }
    if (flag) index = i;
  }
  if (0 <= index) {
    string ans = "";
    rep(i, s.size()) {
      if (index <= i && i < index + t.size())
        ans += t[i - index];
      else {
        if (s[i] == '?')
          ans += "a";
        else
          ans += s[i];
      }
    }
    cout << ans << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }

  return 0;
}

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

using namespace std;
using int64 = long long int;

int main()
{
	int A[3][3] = { };
	bool open[3][3] = { };

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

	int n;
	cin >> n;

	for (int _ = 0; _ < n; _++)
	{
		int b;
		cin >> b;

		for (int i = 0; i < 3; i++)
		{
			for (int j = 0; j < 3; j++)
			{
				if (A[i][j] == b)
				{
					open[i][j] = true;
				}
			}
		}
	}

	bool result = false;

	for (int i = 0; i < 3; i++)
	{
		if (open[i][0] && open[i][1] && open[i][2])
		{
			result = true;
		}

		if (open[0][i] && open[1][i] && open[2][i])
		{
			result = true;
		}
	}

	if (open[0][0] && open[1][1] && open[2][2])
	{
		result = true;
	}

	if (open[0][2] && open[1][1] && open[2][0])
	{
		result = true;
	}

	cout << (result ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    if abs(N - M) > 1:
        print(0)
        return
    ans = 1
    for i in range(1, N + 1):
        ans = ans * i % 1000000007
    for j in range(1, M + 1):
        ans = ans * j % 1000000007
    if N == M:
        ans = ans * 2 % 1000000007
    print(ans)


main()


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

#define x first
#define y second

#ifdef ONLINE_JUDGE
#define DEBUG(x)
#else
#define DEBUG(x) cerr << #x << ": " << x << endl;
#endif

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

ll dp[101][101][401];
ll N,W,w[100],v[100];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

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

	ll tw=0;
	ll r=0;
	for (int k=0;k<=N;k++,tw+=w[0]) for (int i=0;i<=N;i++) for (int j=0;j<=400;j++)
		if (tw+j<=W) smax(r,dp[i][k][j]);
	cout << r << endl;
}

Measured memory_bytes: 31872
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    std::string s;
    std::cin >> s;
    std::cout << s[0] << s.size() - 2 << s[s.size() - 1] << std::endl;
    return 0;
}


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

xy=[]
for i in range(n):
    xi,yi=map(int,input().split())
    xy.append([xi,yi])

f0=[]
f1=[]

for i in range(n):
    f0.append(xy[i][0]-xy[i][1])
    f1.append(xy[i][0]+xy[i][1])

print(max(max(f0)-min(f0),max(f1)-min(f1)))

Measured memory_bytes: 54864
#include <bits/stdc++.h>
#define ll long long 
using namespace std;
const int n = 2e5 + 5;
ll a[n];
ll fr[n];
int main()
{
ll n;
cin>>n;

ll ans=0;
for(int i=0;i<n;i++){
cin>>a[i];
ans+=fr[a[i]];
fr[a[i]]++;

}
for(int i=0;i<n;i++){
cout<<ans-(fr[a[i]]-1)<<endl;
}

  
  // your code goes here
	return 0;
}


Measured memory_bytes: 4736
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};


int main(int argc, char const *argv[]) {
  int n,m,c,a[50][50],b[50],cnt=0;
  std::cin >> n >> m >> c;
  for(int i=0; i<m; i++) std::cin >> b[i];
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      std::cin >> a[i][j];
    }
  }

  for(int i=0; i<n; i++){
    ll ans=0;
    for(int j=0; j<m; j++){
      ans+=a[i][j]*b[j];
    }
    ans+=c;
    if(ans>0) cnt++;
  }
  std::cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
    SPEED;
    int x,y,a,b,c,cnt=0;
    cin>>x>>y>>a>>b>>c;
    multiset <int> s; 
    vector <int> p(a),q(b),r(c);
    for(int i=0;i<a;i++)
    {
        cin>>p[i];
    }
    for(int i=0;i<b;i++)
    {
        cin>>q[i];
    }
    for(int i=0;i<c;i++)
    {
        cin>>r[i];
        s.insert(r[i]);
    }
    sort(p.rbegin(),p.rend());
    sort(q.rbegin(),q.rend());
    int c1=0,c2=0;
    while(c1!=x || c2!=y)
    {
        auto it=s.end();
        --it;
        int chk=*it;
        if(p[c1]>=chk && c1<x)
        {
            cnt+=p[c1];
            ++c1;
        }
        else if(q[c2]>=chk && c2<y)
        {
            cnt+=q[c2];
            ++c2;
        }
        else
        {
            if(c1==x)
            {
                int temp=q[c2];
                q[c2]=chk;
                cnt+=chk;
                s.erase(it);
                s.insert(temp);
                ++c2;
            }
            else if(c2==y)
            {
                int temp=p[c1];
                p[c1]=chk;
                cnt+=chk;
                s.erase(it);
                s.insert(temp);
                ++c1;
            }
            else
            {
                if(p[c1]>q[c2])
                {
                    int temp=q[c2];
                    q[c2]=chk;
                    cnt+=chk;
                    s.erase(it);
                    s.insert(temp);
                    ++c2;
                }
                else
                {
                    int temp=p[c1];
                    p[c1]=chk;
                    cnt+=chk;
                    s.erase(it);
                    s.insert(temp);
                    ++c1;
                }
            }
        }
    }
    cout<<cnt;
}   

Measured memory_bytes: 7296
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>
#include <cstdlib>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int inf = 1000000000;

//#define DEBUG

int main() {
    int n;
    cin >> n;
    cout << ceil(n / 2.0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const long long MOD = 1e9+7;
using namespace std;
#define ll long long
#define ar array

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

	int a,b;
	cin >> a >> b;
	int ans = max({a+b,a-b,a*b});
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3632
N,A,B = map(int,input().split())
if abs(B-A)%2==0:
    print(abs(B-A)//2)
elif A<B:
    print(min(A-1,N-B)+1+(B-A-1)//2)
else:
    print(min(B-1,N-A)+1+(A-B-1)//2)

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

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

  int ans = 0;
  if (D == 0) {
    if (N == 100) ans += 1;
    ans += N;
  } else if (D == 1) {
    if (N == 100) ans += 100;
    ans += N * 100;
  } else if (D == 2) {
    if (N == 100) ans += 10000;
    ans += N * 10000;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n, a, b = map(int, input().split())
p = 10**9 + 7

# 全組み合わせ 2**n % (10**9 + 7) から1本も選択しない1パターンを引いている
x = pow(2, n, p) - 1

# nCa % (10**9 + 7)
y = 1
z = 1
for i in range(1, a+1):
  y = y * (n - i + 1) % p
  z = z * i % p
n_c_a = y * pow(z, p-2, p) % p

# nCb % (10**9 + 7)
y = 1
z = 1
for i in range(1, b+1):
  y = y * (n - i + 1) % p
  z = z * i % p
n_c_b = y * pow(z, p-2, p) % p

print((x - n_c_a - n_c_b) % p)

Measured memory_bytes: 63768
#include<bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

long long int mod=1e9+7,maximum=-1;
char ar[1001][1001];

 long long int getmax(long long int n,long long int m)
{
  
    long long int i,j;
    long long int dp[n+1][m+1];

    
   
    for(i=0;i<n+1;i++)
    dp[i][0]=0;
    for(j=0;j<m+1;j++)
    dp[0][j]=0;
    dp[0][1]=1;
    
     for(i=1;i<n+1;i++)
     {
         for(j=1;j<m+1;j++)
         {
             if(ar[i-1][j-1]=='#')
             dp[i][j]=0;
             else
             {
                 dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
             }
             
         }}
     
         
   
 
  
    return dp[n][m]%mod;

    

}
int main()
{
     long long int n,m;
    
    
   
        cin>>n>>m;

        
         long long int i,j;
        for(  i=0;i<n;i++)
        for(j=0;j<m;j++)
   
        cin>>ar[i][j];
        cout<<getmax(n,m)<<"\n";
    
}


Measured memory_bytes: 12392
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if i==0 or i==H-1 or j==0 or j==W-1:
                print('#',end='')
            else:
                print('.',end='')
        print()
    print()


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

int M, N, K;
char field[1000][1000];
int J[1000][1000], O[1000][1000], I[1000][1000];
int a, b, c, d;

signed main()
{
	cin >> M >> N >> K;
	rep(i,M) cin >> field[i];

	rep(i,M) {
		int JSum = 0, OSum = 0, ISum = 0;
		rep(j,N) {
			if (field[i][j] == 'J') JSum++;
			else if (field[i][j] == 'O') OSum++;
			else if (field[i][j] == 'I') ISum++;

			if (i == 0) {
				J[i][j] = JSum;
				O[i][j] = OSum;
				I[i][j] = ISum;
			} else {
				J[i][j] = J[i-1][j] + JSum;
				O[i][j] = O[i-1][j] + OSum;
				I[i][j] = I[i-1][j] + ISum;
			}
		}
	}

	/*
	rep(i,M) {		
		rep(j,N) {
			printf("%d ", O[i][j]);
		}
		cout << endl;
	}
	*/

	rep(i,K) {
		cin >> a >> b >> c >> d;
		--a; --b; --c; --d;
		int ansJ = J[c][d]; int ansO = O[c][d]; int ansI = I[c][d];
		if (a >= 1) {
			ansJ -= J[a-1][d]; ansO -= O[a-1][d]; ansI -= I[a-1][d];
		}
		if (b >= 1) {
			ansJ -= J[c][b-1]; ansO -= O[c][b-1]; ansI -= I[c][b-1];
		}
		if (a >= 1 && b >= 1) {
			ansJ += J[a-1][b-1]; ansO += O[a-1][b-1]; ansI += I[a-1][b-1];
		}

		cout << ansJ << " " << ansO << " " << ansI << endl;
	}
}

Measured memory_bytes: 13852
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	int sum = 0;
	int sum2 = 0;
	for (int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		sum += x;
		sum2 += x * x;
	}
	cout << (sum * sum - sum2) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    string s;
    cin >> s;
    s[5] = ' ';
    s[13] = ' ';
    cout << s;
}


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

namespace ConsoleApplication2
{
    class Program
    {

        public static void call(int n)
        {
            int i = 1;

            for (i = 1; i <= n; i++)
            {
                int x = i;
                if (x % 3 == 0)
                {
                    Console.Write(" " + i);
                    continue;
                }
                while (x > 0)
                {
                    if (x % 10 == 3)
                    {
                        Console.Write(" " + i);
                        break;
                    }
                    x /= 10;
                }

            }
            Console.WriteLine();
        }

        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            call(input);
        }
    }
}

Measured memory_bytes: 9228
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    int n;
    cin >> n;
    vll a(n);
    vll b(n);
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    sort(all(b));
    double med_a, med_b;
    ll ans;
    if(n%2==0){
        med_a = (double)(a[n/2] + a[n/2-1]) / 2;
        med_b = (double)(b[n/2] + b[n/2-1]) / 2;
        ans = med_b*2 - med_a*2 + 1;
    }else{
        med_a = a[(n-1)/2];
        med_b = b[(n-1)/2];
        ans = med_b - med_a + 1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 6428
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

//	入力の読み込み
		Scanner sc = new Scanner(System.in);
		int shurui = sc.nextInt();  //商品の種類数
		double select = sc.nextInt();  //選びたい商品数
		double sum = 0;  //総投票数
		int shouhin[] = new int[shurui];  //商品配列

//	お菓子1つずつに得票数を記入
		for(int i=0 ; i<shurui ; i++) {
			int tokuhyou = sc.nextInt();
			shouhin[i] += tokuhyou;
			sum += tokuhyou;
		}

//	総投票数がわかったので基準値を求める
		double kijun = Math.ceil(sum/(4*select));

//	並列の中身を開けてみて、選べる商品をカウント
		int count = 0;
		for(int i : shouhin) {
			if(i >= kijun) {
				count ++;
			}
		}

//	選べる商品がM個以上あるかどうか
		System.out.println(count >= select ? "Yes" : "No");
	}
}

Measured memory_bytes: 27228
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
int a[N];
int n,k;
int vis[30],ans_vis[30];
int main()
{
	int n;
	scanf("%d",&n);
	memset(ans_vis,127,sizeof(ans_vis));
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		memset(vis,0,sizeof(vis));
		for(int j=0;j<s.size();j++)
		{
			 vis[s[j]-'a']++;
		}
		for(int j=0;j<26;j++)
		{
			//cout<<vis[i]<<endl;
			ans_vis[j]=min(ans_vis[j],vis[j]);
		}
	}
	for(int i=0;i<26;i++)
	{
		for(int j=0;j<ans_vis[i];j++)
		{
			cout<<(char)('a'+i);
		}
	}
    return 0;
}

Measured memory_bytes: 256
a = str(input())
s = ['z','x','c','v','b','n','m','a','s','d','f','g','h','j','k','l','q','w','e','r','t','y','u','i','o','p']
s.append(a)
s.sort()
Q = s.index(a)
e = int(Q) + 2
print(s[int(e)])



Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
#include <vector>

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))

using namespace std;

#define MOD 1000000007

int main(int argc, char* argv[])
{
    long n, h, w;
    scanf("%ld", &n);
    scanf("%ld", &h);
    scanf("%ld", &w);

    printf("%ld\n", (n-h+1)*(n-w+1));

    return 0;
}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int N, M;

using P = pair<int, int>;
 P p[100001];

signed main()
{
	cin >> N >> M;
	REP(i, N) cin >> p[i].first >> p[i].second;

	ARY_SORT(p, N);

	int rest = M;
	int sum = 0;
	REP(i, M)
	{
		if (rest <= p[i].second)
		{
			sum += rest * p[i].first;
			break;
		}
		else
		{
			sum += p[i].second * p[i].first;
			rest -= p[i].second;
		}
	}

	cout << sum << endl;
}









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

int main(){
    int x;
    cin >> x;
    int sum = 0;
    while(x >= 5){
    	if(x >= 500){
    		sum += 1000;
    		x -= 500;
    	}
    	else{
    		sum += 5;
    		x -= 5;
    	}
    }
    cout << sum << endl;
    return 0;
}


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

int main() {
	long long N, A, XOR = 0, COUNT = 0;
	bool B[32] = {};
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A;
		for (int j = 1; j <= 31; j++) {
			if ((A ^ (A - 1)) == pow(2, j) - 1) B[j] = true;
		}
		XOR = XOR ^ A;
	}
	for (int i = 31; i > 0; i--) {
		int X = pow(2, i - 1);
		if (XOR >= X) {
			if (B[i]) {
				XOR = XOR ^ (X * 2 - 1);
				COUNT++;
			}
			else {
				cout << -1;
				return 0;
			}
		}
	}
	cout << COUNT;
}

Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

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

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};
signed main(){
	int n, m, k;
	cin >> n >> m >> k;
	vector<set<int>>dame(n);
	UnionFind uf(n);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		dame[a].insert(b);
		dame[b].insert(a);
		uf.merge(a, b);
	}
	rep(i,k) {
		int c, d; cin >> c >> d; --c, --d;
		if (!uf.issame(c, d)) continue;
		dame[c].insert(d);
		dame[d].insert(c);
	}
	rep(i,n){
		cout << uf.size(i)-dame[i].size()-1 << " ";
	}
	cout << endl;
}


Measured memory_bytes: 25088
//omg that took waaay me longer that it should

#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll x,y,z;

int main() {
	scanf("%lld%lld",&x,&y);
	x = x%y;
	printf("%lld\n",min(x,abs(x-y)));
}

Measured memory_bytes: 256
def calc_ans(a,b,c,x,y):
    #2. candidate
    less = min([x,y])
    if less == y:
        use_c = 2*c*less + a*(x-less)
    else:
        use_c = 2*c*less + b*(y-less)
        
    not_use_c = a*x + b*y
    
    only_c = 2*c*max([x,y])
    
    return min([use_c, not_use_c, only_c])

def main():
    #1.input
    a,b,c,x,y = map(int, input().split())
    
    
    ans = calc_ans(a,b,c,x,y)
    print(ans)

if __name__ == "__main__":
    main()

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

int main(){
	
	string s;
	
	cin >> s;
	
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]){
		cout << "Bad";
	} else {
		cout << "Good";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  ll x;
  cin>>x;
  if(x>=30){
    puts("Yes");
  }else{
    puts("No");
  }
  return 0;
}


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

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cout.tie(nullptr);
    std::cin.tie(nullptr);

    long long a, b, c, d;
    std::cin >> a >> b >> c >> d;

    std::cout << std::max({ a * c, b * d, a * d, b * c });
}

Measured memory_bytes: 3636
def main():
    A, B, M = map(int, input().split())
    xyc_list = [0]*M

    a_list = list(map(int, input().split()))
    b_list = list(map(int, input().split()))
    for i in range(M):
        xyc_list[i] = list(map(int, input().split()))

    mini = min(a_list)+min(a_list)
    for x, y, c in xyc_list:
        value = a_list[x-1] + b_list[y-1] - c
        if value < mini:
            mini = value
    print(mini)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38560
#include <iostream>
using namespace std;
#define rep(i, N) for(i = 0; i < N; i++)
#define ll long long

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

  //リセット
  int Sunuke[N];
  int i;
  rep(i, N) { Sunuke[i] = 0; }

  rep(i, K) {
    int d;
    cin >> d;
    int j;
    rep(j, d) {
      int num;
      cin >> num;
      Sunuke[num - 1]++;
    }
  }
  int ans = 0;
  rep(i, N) {
    if(Sunuke[i] == 0) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3616
// A.

#pragma GCC target("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <stdio.h>

typedef long long LL;

char buffer[3072000];
LL cnt[20][20];
LL sum[20][20];
LL n;
LL ans;

int main(int argc, char* argv[]) {
	char c, *bufptr = buffer;
	fread(buffer, 1, 3072000, stdin);
	while ((c = *bufptr++) >= '0') {
		n = (n * 10) + (c - '0');
	}
	for (LL i = 0; i < n; ++i) {
		LL x = 0, two = 0, five = 0, df = 0;
		while ((c = *bufptr++) >= ' ') {
			if (c == '.') {
				df = -1;
			} else {
				x = (x * 10) + c - '0';
				five += df;
			}
		}
		two = __builtin_ctzll(x);
		x >>= two;
		two += five;
		while (x % 5 == 0) {
			++five;
			x /= 5;
		}
		if (two > 9) two = 9;
		if (five > 9) five = 9;
		cnt[9 + two][9 + five] += 1;
		sum[9 - two][9 - five] += 1;
	}
	for (int i = 0; i < 20; ++i) {
		for (int j = 1; j < 20; ++j) {
			sum[i][j] += sum[i][j - 1];
		}
	}
	for (int i = 1; i < 20; ++i) {
		for (int j = 0; j < 20; ++j) {
			sum[i][j] += sum[i - 1][j];
		}
	}
	for (int i = 0; i <= 18; ++i) {
		for (int j = 0; j <= 18; ++j) {
			ans += sum[i][j] * cnt[i][j];
			if (i >= 9 && j >= 9) {
				ans -= cnt[i][j];
			}
		}
	}
	printf("%lld\n", ans >> 1);
	return 0;
}


Measured memory_bytes: 4220
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long

using namespace std;

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

const int N = 100000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, E, T, a[N], b[N], dp[N], seg[N << 2], sm[N];

void add(int id, int lq, int rq, int x, int l, int r){
	if (rq <= l || r <= lq) return;
	if (lq <= l && r <= rq){
		seg[id] = x;
		return;
	}
	int md = (l + r) >> 1;
	add(id << 1, lq, rq, x, l, md);
	add(id << 1 | 1, lq, rq, x, md, r);
	seg[id] = min(seg[id << 1], seg[id << 1 | 1]);
}

int get(int id, int lq, int rq, int l, int r){
	if (rq <= l || r <= lq) return INF;
	if (lq <= l && r <= rq) return seg[id];
	int md = (l + r) >> 1;
	return min(get(id << 1, lq, rq, l, md), get(id << 1 | 1, lq, rq, md, r));
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> E >> T;
	for (int i = 1; i <= n; i++) {cin >> a[i]; b[i] = 2 * a[i];}
	memset(dp, 63, sizeof dp);
	memset(seg, 63, sizeof seg);
	memset(sm , 63, sizeof sm);
	dp[n + 1] = 0;
	a[n + 1] = E;
	for (int i = n; i >= 1; i--){
		add(1, i, i + 1, dp[i + 1] + 3 * a[i] + a[i + 1] - a[i] + T - 2 * a[i], 1, n + 1);
		int koj = lower_bound(b + 1, b + n + 1, T + 2 * a[i]) - b;
		//cout << koj << '\n';
		dp[i] = sm[koj] - 3 * a[i];
		dp[i] = min(dp[i], get(1, i, koj, 1, n + 1) - a[i]);
		sm[i] = min(sm[i + 1], dp[i + 1] + 3 * a[i] + a[i + 1] - a[i]);
//		int mx = 0;
//		for (int j = i; j <= n; j++){
//			dp[i] = min(dp[i], dp[j + 1] + 3 * (a[j] - a[i]) + a[j + 1] - a[j] + max(0ll, T - 2 * a[j] + 2 * a[i]));
//		}
		//cout << dp[i] << '\n';
	}
	cout << dp[1] + a[1];










	return 0;
}


Measured memory_bytes: 6528
# A - キャンディーと2人の子供

# 2人の子供がキャンディーの取り合いをしている
# 3個のキャンデーパックがあり、れぞれのパックには
# キャンディーが  a ,  b ,  c  個入っています

# 先生が、上記3個のパックをキャンディーの個数が等しくなるように
# 2人に分けようとしている

# そのような分け方が可能かどうかを判定する。
# 可能なら Yes  そうでないなら No

# a b c を標準入力から得る
a, b, c = map(int, input().split(maxsplit=3))
# print(a, b, c)

# 以下条件で等しく分けることが可能
# a = b + c
# b = a + c
# c = a + b

if a == (b + c):
    answer = "Yes"
elif b == (a + c):
    answer = "Yes"
elif c == (a + b):
    answer = "Yes"
else:
    answer = "No"

# 結果を出力
print(answer)


Measured memory_bytes: 9156
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools, os, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)
def perr(s): return print(s, file=sys.stderr)
N, K = LI()
S = input()

"""

答えは0以上N-1以下になる
まず何回ひっくり返せるかが重要
N==Kなら、全部ひっくり返して最大値となる
K==N-1なら、最大値から1箇所は矛盾する
LLRRLLなら
LLはRRになる
愚直回は、毎回どの区間をひっくり返すかを探索する
そうすると、区間の選び方だけでもかなり多い
好きな回数だけ選ぶと
まず塊の場所を特定する
6 1
LRLRRL
なら
てかどちらに統一するか問題もある
RRを
一番つながってるやつをひっくり返すのでいいか
Lにする場合とRにする場合を分けて考える
上のやつなら
Lにする場合
RRを返して
LRLLLL
で3
Rにする場合
LRRRRLになって3となる

9 2
RRRLRLRLL
の場合
Lの場合
LLLLRLRLL
になり、
LLLLLLRLL
5
Rの場合
111110101
111111101

長さをリストにすると
3, 1, 1, 1, 1, 2
最大にすると
5, 1, 1, 1, 1
6, 1, 1, 1

3, 1, 1, 1, 1, 2
3 1 1 4
7 1 1
RRRLRLLLL
LRLLLLLLL
だと6
RRRRRLRLL
RRRRRRRLR

LRLLLLRLL
LRLLLLLLL

RRRRLRRLL
RRRRRRLLR

RRRLLRLLL
RRRRRRLRR

RRRRRLRLR
RRRRRRLRR

-- RRRLRLRLL

RRRLRRRLR
LLLLRRRRR


長さをリストにすると
3, 1, 1, 1, 1, 2
3 3 1 2
3 6
2 + 5

RRRLLLRLL
RRRLLLLLL

まず、リストを作成

3 1 1 4
3 3 1 2
RRR LLL R LL
3 6
2 + 5
または


5 1 1 1


5 3
4 + 2

最小値の組み合わせをあわせる？
2個ずつ減っていく

LRLRRL
の場合
1 1 1 2 1
3 2 1
2+1 = 3
1 1 4 = 3

3 2 1
6
何回裏返せるかで決まってる

塊の数が
6子なら
6
4
26子なら
6
4
26子なら
6
4
26子なら
6
4
26子なら
6
4
26子なら
6
4
2
というふうに減っていく
4塊の場合はもう決まってる
3 3 1 2 = 5
3 1 1 4 = 5

-- RRRLRLRLL
3 1 1 1 1 2
6塊
まず9-6
ほんで3あまってる
答えは必ず3

"""
tmp = 1
l = []
for i in range(N-1):
    if S[i] == S[i+1]:
        if i == N - 2:
            tmp += 1
            l.append(tmp)
        else:
            tmp += 1
    else:
        if i == N - 2:
            l.append(tmp)
            l.append(1)
        else:
            l.append(tmp)
            tmp = 1
#  print(l)

len_l = len(l)
len_l -= 2 * K
if len_l <= 1:
    print(N - 1)
    exit()
elif len_l <= 2:
    print(N - 2)
else:
    ans = N - len_l
    print(ans)



Measured memory_bytes: 84716
import math
import heapq
import sys
from collections import Counter

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

N=int(input())
S=input()
if N%2==1:
    print('No')
    exit()

#print(S[:N//2],S[-(N//2):])

if S[:N//2]==S[-(N//2):]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long n,k,sum=0;
  cin>>n>>k;
  long h[n],i;
  for(i=0;i<n;i++)
    cin>>h[i];
  if(k>=n)
    cout<<sum<<endl;
  else
  {
    sort(h,h+n);
    for(i=0;i<(n-k);i++)
      sum+=h[i];
    cout<<sum<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (ll i=(ll)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const ll INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(ll x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { ll d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll modpow(ll x, ll p) { ll result = 1, now = 1, pm = x; while (now<=p) { if (p&now) { result = result * pm % MOD; } now*=2; pm = pm*pm % MOD; } return result; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

struct SegTree {
  ll size;
  vector<ll> pos;
  SegTree(ll N) { size = 1; while(size<N) size<<=1; pos.resize(2*size,0); }
  ll operator[](const ll &x) const { return pos[x+size]; }

  void set(ll x, const ll v) { pos[x+size] = v; }
  void update(ll x, const ll v) { set(x,v); x+=size; while (x>>=1) operate(x); }
  ll query(ll a, ll b) {
    ll L = 0, R = 0;
    for (a+=size, b+=size; a<b; a>>=1, b>>=1) {
      if (a&1) { L = q(L,pos[a]); a++; }
      if (b&1) { b--; R = q(pos[b],R); }
    }
    return q(L,R);
  }
  void operate(ll i) { pos[i] = q(pos[i*2], pos[i*2+1]); }
  ll q(ll x, ll y) { return max(x, y); }
};

// ----------------------------------------------------------------------
// ----------------------------------------------------------------------

int main() {
  ll N, K; cin >> N >> K;
  ll A[N]; rep(i,N) cin >> A[i];

  ll MA = 300010;
  SegTree st(MA);
  rep(i,N) {
    st.update(A[i], st.query(max(0ll, A[i]-K), min(MA-1,A[i]+K)+1)+1);
    // rep(i,MA) cout << st[i] << " "; cout << endl;
  }

  ll result = st.query(0,MA);
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 13820
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <climits>
using namespace std;
#define MOD int(1e9 + 7)
#define INF (long long)(1e18)

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

    while(true){
        C -= B;
        if(C <= 0){
            cout << "Yes" << endl;
            return 0;
        }
        A -= D;
        if(A <= 0){
            cout << "No" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(void){
  int n,k,c;
  scanf("%d %d %d", &n, &k, &c);
  char s[n];
  scanf("%s", s);
  int first[k];
  int last[k];
  int work = 0;
  int day;
  for (day = 0; work < k; day++) {
    if (s[day] == 'o') {
      first[work] = day;
      day += c;
      work++;
    }
  }
  work = 0;
  for (day = n-1; work < k; day--) {
    if (s[day] == 'o') {
      last[work] = day;
      day -= c;
      work++;
    }
  }

  for (int i = 0; i < k; i++) {
    if (first[i] == last[k-i-1]) {
      printf("%d\n",first[i]+1);
    }
  }

  return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<map>
#include<string>
#include<cstdio>
using namespace std;

map<char, string> dict;
map<string, char> tcid;
void init(){
    dict[' '] = "101";
    dict['\''] = "000000";
    dict[','] = "000011";
    dict['-'] = "10010001";
    dict['.'] = "010001";
    dict['?'] = "000001";
    dict['A'] = "100101";
    dict['B'] = "10011010";
    dict['C'] = "0101";
    dict['D'] = "0001";
    dict['E'] = "110";
    dict['F'] = "01001";
    dict['G'] = "10011011";
    dict['H'] = "010000";
    dict['I'] = "0111";
    dict['J'] = "10011000";
    dict['K'] = "0110";
    dict['L'] = "00100";
    dict['M'] = "10011001";
    dict['N'] = "10011110";
    dict['O'] = "00101";
    dict['P'] = "111";
    dict['Q'] = "10011111";
    dict['R'] = "1000";
    dict['S'] = "00110";
    dict['T'] = "00111";
    dict['U'] = "10011100";
    dict['V'] = "10011101";
    dict['W'] = "000010";
    dict['X'] = "10010010";
    dict['Y'] = "10010011";
    dict['Z'] = "10010000";
    tcid["00000"] ='A';
    tcid["00001"] ='B';
    tcid["00010"] ='C';
    tcid["00011"] ='D';
    tcid["00100"] ='E';
    tcid["00101"] ='F';
    tcid["00110"] ='G';
    tcid["00111"] ='H';
    tcid["01000"] ='I';
    tcid["01001"] ='J';
    tcid["01010"] ='K';
    tcid["01011"] ='L';
    tcid["01100"] ='M';
    tcid["01101"] ='N';
    tcid["01110"] ='O';
    tcid["01111"] ='P';
    tcid["10000"] ='Q';
    tcid["10001"] ='R';
    tcid["10010"] ='S';
    tcid["10011"] ='T';
    tcid["10100"] ='U';
    tcid["10101"] ='V';
    tcid["10110"] ='W';
    tcid["10111"] ='X';
    tcid["11000"] ='Y';
    tcid["11001"] ='Z';
    tcid["11010"] =' ';
    tcid["11011"] ='.';
    tcid["11100"] =',';
    tcid["11101"] ='-';
    tcid["11110"] ='\'';
    tcid["11111"] ='?';
}

string solve(string a){
    string tmp = "";
    string res = "";
    if(a == "")return a;
    for(int i = 0;i < a.size();i++){
	tmp += dict[a[i]];
    }
    while(tmp.size()%5)tmp+="0";
    for(int i = 0;i < tmp.size();i += 5){
	string x = "";
	for(int j = 0;j < 5;j++){
	    x += tmp[i + j];
	}
	res += tcid[x];
    }
    return res;
}
bool fin = false;
string get_line(){
    string res = "";
    while(true){
	char t = getchar();
	if(t == '\n' || t == EOF){
	    if(t == EOF)fin = true;
	    break;
	}
	res += t;
    }
    return res;
}

int main(){
    init();
    while(!fin){
	string res = solve(get_line());
	if(fin&&res=="")break;cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int H, W, N;
    cin >> H >> W >> N;

    vi colors;
    rep(i, N) {
        int a;
        cin >> a;
        rep(j, a) {
            colors.pb(i+1);
        }
    }

    vvi res(H, vi(W, -1));
    rep(i, H) {
        rep(j, W) {
            int c = colors[i*W+j];
            if(i%2) res[i][W-1-j] = c;
            else res[i][j] = c;
        }
    }

    rep(i, H) {
        rep(j, W) {
            cout << res[i][j] << " ";
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
int fa[200010],FA[200010],v0[200010],v1[200010];
ll ans;
int hd(int x){return FA[x]==x?x:FA[x]=hd(FA[x]);}
std::priority_queue<std::pair<double,int>>que,del;
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi();
	for(int i=2;i<=n;++i)fa[i]=gi();
	for(int i=1;i<=n;++i)FA[i]=i;
	for(int i=1;i<=n;++i)gi()?v1[i]=1:v0[i]=1;
	for(int i=2;i<=n;++i)que.push({1.0*v0[i]/v1[i],i});
	for(int i=1;i<n;++i){
		while(!que.empty()&&!del.empty()&&que.top()==del.top())que.pop(),del.pop();
		int x=que.top().second;que.pop();
		int y=hd(fa[hd(x)]);
		ans+=1ll*v0[x]*v1[y];
		if(y!=1)del.push({1.0*v0[y]/v1[y],y});
		v0[y]+=v0[x],v1[y]+=v1[x];
		if(y!=1)que.push({1.0*v0[y]/v1[y],y});
		FA[x]=y;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 15212
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int s,w;
  cin>>s>>w;
  if(w>=s){
    cout<<"unsafe"<<endl;
  }else{
    cout<<"safe"<<endl;
  }
}

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

int main(){
	int a,b;
	int flag;
	cin >> a >> b;
	if(a >= 1 && b >= 1) flag = 1;
	else if(a <= 0 && b >= 0) flag = 0;
	else{
		if((b - a) % 2 == 1) flag = 1;
		else flag = -1;
	}
	if(flag == 1) cout << "Positive" << endl;
	else if(flag == 0) cout << "Zero" << endl;
	else cout << "Negative" << endl;
	return 0;
}

Measured memory_bytes: 256