akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef vector< pii > vii;

#define ll          long long
#define ff          first
#define ss          second
#define pb          push_back
#define mkp         make_pair
#define sz          size()

#define forf(a,b,c)    for(int i=a;i<=b;i+=c)
#define forr(a,b,c)    for(int i=a;i>=b;i-=c)
#define all(a)      a.begin(),a.end()
#define mem(a,b)    memset(a,b,sizeof(a))
#define pi          2*acos(0.0)
#define End         return 0;
#define nl endl

#define scan1(a)    scanf("%d",&a)
#define scan2(a,b)  scanf("%d %d",&a,&b)
#define scan3(a,b,c)  scanf("%d %d %d",&a,&b,&c)
#define scanl(a)    scanf("%lld",&a)
#define scanll(a,b) scanf("%lld %lld",&a,&b)
#define scanlll(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)

#define print1(a)    printf("%d",a)
#define print2(a,b)  printf("%d %d",a,b)
#define print3(a,b,c)  printf("%d %d %d",a,b,c)
#define printl(a)    printf("%lld",a)
#define printll(a,b) printf("%lld %lld",a,b)
#define printlll(a,b,c) printf("%lld %lld %lld",a,b,c)

#define MAXN        100000007
#define INF 0x3f3f3f3f
bool mark[100005];vi prime;
void seive(ll N){for(int i=2;i<=N;i++){if(mark[i]==false){prime.pb(i);for(int j=i+i;j<N;j+=i)mark[j]=true;}}}
//freopen("input.txt", "r", stdin);

int main()
{
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   string s;
   cin>>s;
   for(int i=0;i<3;i++)
   {
       if(s[i]==s[i+1]){
        cout<<"Bad"<<endl;
        End;
       }
   }
   cout<<"Good"<<endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

        int ans = 0;
        int N = in.nextInt();
        int[] values = new int[N];

        for (int i = 0; i < N; i++) {
            values[i] = in.nextInt();
        }
        // 先頭と末尾を0で埋める
        int[] valuesWithPadding = new int[N+2];
        for (int i = 0; i < N; i++) {
            valuesWithPadding[i+1] = values[i];
        }

        while (true) {
            
            // 0でない数字の塊の数を数える
            int count = 0;
            for (int i = 1; i < N+2; i++) {
                if (valuesWithPadding[i] != 0) {
                    if (valuesWithPadding[i - 1] == 0) {
                        count++;
                    }
                }
            }
            if (count == 0) break;
            for (int i = 0; i < N+2; i++) {
                if (valuesWithPadding[i] != 0) {
                    valuesWithPadding[i] -= 1;
                }
            }
            ans += count;
        }
        System.out.println(ans);

    }

}


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

int main() {
	int n;
	cin >> n;
	vector<int>c(n,0),s(n,0),f(n,0);
	for(int i = 0 ;i < n-1 ;i++)
	{
		cin >> c.at(i) >> s.at(i) >> f.at(i);
	}
	for(int i=0;i<n;i++)
	{
		int cnt=0;
		cnt = s.at(i) + c.at(i);
		for(int j=i+1;j<n-1;j++)
		{
			if(s.at(j) >= cnt)
			{
				cnt = s.at(j) + c.at(j);
			}
			else
			{
				int z=(cnt - s.at(j)) / f.at(j);
				int zz = cnt % f.at(j),zzz;
				if(zz == 0)
				{
					cnt+=c.at(j);
				}
				else
				{
					cnt=c.at(j) + s.at(j) + f.at(j) * (z+1);
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


Measured memory_bytes: 256
n = int(input())
N = list(map(int, input().split()))

# plus
ans1 = 0
subtotal = 0
for i in range(n):
	subtotal += N[i]
	if i % 2 == 0 and subtotal <= 0:
		diff = abs(subtotal) + 1
		subtotal += diff
		ans1 += diff
	elif i % 2 != 0 and subtotal >= 0:
		diff = abs(subtotal) + 1
		subtotal -= diff
		ans1 += diff

#minus
ans2 = 0
subtotal = 0
for i in range(n):
	subtotal += N[i]
	if i % 2 != 0 and subtotal <= 0:
		diff = abs(subtotal) + 1
		subtotal += diff
		ans2 += diff
	elif i % 2 == 0 and subtotal >= 0:
		diff = abs(subtotal) + 1
		subtotal -= diff
		ans2 += diff

print(min(ans1, ans2))

Measured memory_bytes: 14648
H, W = map(int, input().split())
field = [list(input()) for i in range(H)]
flag = []
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

for i in range(H):
    for j in range(W):
        if field[i][j] == '#':
            inflag = [False] * 4
            for k in range(4):
                ni = i + dx[k]
                nj = j + dy[k]
                if ni < 0 or ni >= H or nj < 0 or nj >= W:
                    inflag[k] = False
                elif field[ni][nj] == '#':
                    inflag[k] = True
            flag.append(any(inflag))
        elif field[i][j] == '.':
            flag.append(True)

if all(flag):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  int W,H,x,y,r;
  scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
  if(x>=r && x+r<=W && y>=r && y+r<=H)
    printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 584
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
max_1 = max(a)
a[a.index(max_1)] = -1
max_2 = max(a)
a[a.index(-1)] = max_1
for i in range(0,n):
  if a[i] == max_1:
    print(max_2)
  else:
    print(max_1)

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

using namespace std;

int main(void) {
  int h, w;
  cin >> h >> w;
  string s[h];
  for(int i = 0; i < h; i++) {
    cin >> s[i];
  }

  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      if(s[i][j] == '.') {
	int count = 0;
	for(int k = -1; k <= 1; k++) {
	  for(int l = -1; l <= 1; l++) {
	    if(i + k < 0 || i + k >= h || j + l < 0 || j + l >= w) {
	      continue;
	    }
	    if(s[i + k][j + l] == '#') {
	      count++;
	    }
	  }
	}
	s[i][j] = '0' + count;
      }
    }
  }

  for(int i = 0; i < h; i++) {
    cout << s[i] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
using namespace std;
int n;
ll ans=1;
int main(){
	scanf("%d",&n);
	for (int i=2;i<=n;i++){
		int fl=0;
		for (int j=2;j*j<=i;j++)
			if (i%j==0) fl=1;
		if (fl==1) continue;
		int cnt=0,tmp=n;
		for (;tmp;cnt+=(tmp/=i));
		ans=ans*(cnt+1)%mo;
	} 
	printf("%lld",ans);
} 

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  std::string s;
  std::cin >> s;

  ll N = s.size();

  ll point = 0LL;
  ll sum   = 0LL;
  ll pcnt  = 0LL;
  for (ll i = 0; i < N; i++) {
    if (s[i] == 'g') {
      // pcnt < gcnt だが, gcnt は sum - pcnt なので, pcnt < sum - pcnt になる
      if (pcnt * 2 < sum) {
	pcnt++;
	point++;
      }
    } else {
      if (pcnt * 2 < sum) {
	pcnt++;
      } else {
	point--;
      }
    }
    sum++;
  }

  print(point);
  return 0;
}


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

int main() {
  
  string A, B;
  cin >> A >> B;
  int out = 0;
  for(int i = 0; i < 3; i++){
    if(A.at(i) == B.at(i)){
      out++;
    }
  }
  cout << out;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int henkan(string s,int i){

  int S;
  if( s[i+1] == '1' ){
    S = 1;
  }
  else if( s[i+1] == '2'){
    S = 2;
  }
  else if( s[i+1] == '3'){
    S = 3;
  }
  else if( s[i+1] == '4'){
    S = 4;
  }
  else if( s[i+1] == '5'){
    S = 5;
  }
  else if( s[i+1] == '6'){
    S = 6;
  }
  else if( s[i+1] == '7'){
    S = 7;
  }
  else if( s[i+1] == '8'){
    S = 8;
  }
  else if( s[i+1] == '9'){
    S = 9;
  }
  return S;
}


int main(void){

  string s;
  while( cin >> s ){

    for( int i = 0 ; i < s.size() ; i++ ){
      if( s[i] == '@'){
	int S;
	S = henkan(s,i);
	for( int j = 0 ; j < S ; j++ ){
	 cout << s[i+2];
       	}
	i += 2;
      }
      else cout << s[i];
    }
    cout << endl;
  }  
  return 0;
}

Measured memory_bytes: 1184
import java.util.*;
import java.math.*;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    String[] s = new String[n];
    String[] s2 = new String[n];
    int[] p = new int[n];
    int[] p2 = new int[n];
    for(int i = 0;i<s.length;i++) {
      s[i] = stdIn.next();
      p[i] = stdIn.nextInt();
      s2[i] = s[i];
      p2[i] = p[i];
    }
    for(int i = s.length-1;i>=0;i--) {
      for(int j = 0;j<i;j++) {
      int k = s2[j].compareTo(s2[j+1]);
      if(k>0) {
        String tep = s2[j];
        s2[j] = s2[j+1];
        s2[j+1] = tep;
        int tep2 = p2[j];
        p2[j] = p2[j+1];
        p2[j+1] = tep2;
      }
      k = s2[j].compareTo(s2[j+1]);
      if(k==0&&p2[j]<p2[j+1]) {
        String tep3 = s2[j];
        s2[j] = s2[j+1];
        s2[j+1] = tep3;
        int tep4 = p2[j];
        p2[j] = p2[j+1];
        p2[j+1] = tep4;
      }
    }
  }
  int[] count = new int[n];
  int tintin = 0;
    for(int i = 0;i<s.length;i++) {
      for(int j = 0;j<s.length;j++) {
        int k2 = s[i].compareTo(s2[j]);
        if(k2==0&&p[i]==p2[j]) {
          count[j] = i+1;
          tintin += 1;
        }
      }
    }
    for(int i = 0;i<count.length;i++) {
      System.out.println(count[i]);
    }

}
}

Measured memory_bytes: 21844
n=int(input())
l=list(map(int,input().split()))
i=-1
c=maxc=0

while i < n:
    if c > maxc:
        maxc=c
        ans=i
    i=i+c+1
    c=0
    for j in range(i+1,n):
        if l[j-1]>=l[j]:
            c+=1
        else:
        	break

print(maxc)


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

int main() {
  char N,S,t=3;
  int C[5] = {0};
  cin >> N;
  while(N--){
    cin >> S;
    if(S=='Y')
      t=4;
  }
  if(t==3)
    cout << "Three" << endl;
  else
    cout << "Four" << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;


int main(){FIN

    ll n;cin>>n;
    ll ans=0;
    REP(i,n){
        ll a; cin>>a;
        ans += a-1;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}

//combination(Nが小さい時はこれを使う)
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}
int COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else 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 / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
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 kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int s, w;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> s >> w;
	if (w >= s)puts("unsafe");
	else puts("safe");
	ggr
}


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

int main() {
  int H, W, J;
  cin >> H >> W;
  string tmp;
  getline(cin, tmp); 
  string sarray[H];
  string new_str[H];
  for (int i=0; i<H; i++){
    getline(cin, sarray[i]);
    new_str[i] = sarray[i];
  }
  int h_start, h_end, w_start, w_end, count;
  for (int i=0; i<H; i++) {
    for (int j=0; j<W; j++) {
      if (sarray[i][j] == '.') {
        if (i == 0) h_start = 0; else h_start = -1;
        if (i == (H-1)) h_end = 0; else h_end = 1;
        if (j == 0) w_start = 0; else w_start = -1;
        if (j == (W-1)) w_end = 0; else w_end = 1;
      
        count = 0;
        for (int k=w_start; k <= w_end; k++) {
          for (int l=h_start; l <= h_end; l++) {
            if (sarray[i+l][j+k] == '#') count += 1;
          }
        }
        new_str[i][j] = to_string(count)[0];
      }
    }
  }
  for (int i = 0; i<H; i++) {
      cout << new_str[i] << endl;
  }
}



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

typedef pair<int,int> Pi;

int main(){
    ll a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if (v*t - w*t >= abs(b-a)) cout << "YES" << "\n";
    else cout << "NO" << "\n";
}


Measured memory_bytes: 3624
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  
  int sum = 0;
  
  sum += a[0] + a[n-1];
  REP(i,n-1){
    sum += abs(a[i] - a[i+1]);
  }
  
  int ans = sum/2;
  cout << ans << endl;           
              
}

Measured memory_bytes: 3612
#include <stdio.h>
 
int main(void){
 
int i;
char str[20];
 
 
scanf("%s", str);
 
for(i=19; i>=0; i--){
 
if(str[i]!='\0')
putchar(str[i]);
 
}

putchar('\n');
 
 
return 0;
 
}

Measured memory_bytes: 524
from math import sqrt
x = int(input())

if (sqrt(1 + 8*x) - 1)%2 == 0:
    x_ = (sqrt(1 + 8*x) - 1)//2 
else:
    x_ = (sqrt(1 + 8*x) - 1)//2 +1

print(int(x_))

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

int main()
{
  
int k;
int sum = 0;
cin >> k;
    for (int i = 1; i <= k; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            for (int n = 1; n <= k; n++)
            {
                sum += __gcd(n, __gcd(i, j));
            }
        }
    }
  cout << sum << endl;
}

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

const int maxv = 300000;
int main(){
  int n,q;
  cin >> n >> q;
  vector<int> c(n);
  for(int i=0;i<n;i++)cin >> c[i];
  c.push_back(0); c.push_back(maxv+1);
  sort(c.begin(),c.end());

  vector<int> pred(maxv+2,0);
  for(int i=0;i<n+1;i++){
    for(int j=c[i]+1;j<=c[i+1];j++){
      pred[j] = c[i];
    }
  }

  while(q--){
    int x;
    cin >> x;
    int ans = 0;
    for(int i=0;i<=maxv;i+=x)ans = max(ans, pred[i]%x);
    cout << ans << endl;
  }
}

Measured memory_bytes: 3380
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}
	
	long[] hamburgerHeightArr;
	long[] pattyHeightArr;

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		long x = fs.nextLong();
		
		hamburgerHeightArr = new long[n+1];
		pattyHeightArr = new long[n+1];
		hamburgerHeightArr[0] = 1;
		pattyHeightArr[0] = 1;
		for(int i = 1; i < n+1; i++){
			hamburgerHeightArr[i] = 3 + 2*hamburgerHeightArr[i-1];
			pattyHeightArr[i] = 1+ 2* pattyHeightArr[i-1];
		}
		
		System.out.println(calcPattyNum(n,x));
	}
	
	
	long calcPattyNum(int hamburgerHeight, long x){
		
		if(hamburgerHeight == 0){
			if(x == 0){
				return 0;
			}else{
				return 1;
			}
		}
		
		if(x == 1){
			return 0;
		}
		
		if(x <= hamburgerHeightArr[hamburgerHeight-1]+1){
			return calcPattyNum(hamburgerHeight-1, x-1);
		}
		
//		if(x == hamburgerHeightArr[hamburgerHeight-1]+1){
//			return pattyHeightArr[hamburgerHeight-1];
//		}
		
		if(x == hamburgerHeightArr[hamburgerHeight-1]+2){
			return pattyHeightArr[hamburgerHeight-1]+1;
		}
		
		if(x <= hamburgerHeightArr[hamburgerHeight] - 1){
			return pattyHeightArr[hamburgerHeight-1] + 1 + calcPattyNum(hamburgerHeight-1 , x-2-hamburgerHeightArr[hamburgerHeight-1]); 
		}
		
		return pattyHeightArr[hamburgerHeight];
	}
	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


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

int main(){
    int N;
    cin>>N;
    long long H[100010];
    for(int i=0;i<N;i++)cin>>H[N-1-i];

    if(N==1)cout<<"Yes"<<endl;
    else{
       for(int i=1;i<N-1;i++){
            if(H[i]-H[i-1]==1)H[i]=H[i]-1;
            if (H[i]-H[i-1]>1){
                cout<<"No"<<endl;
                goto lol;
            }
        }

        if(H[N-1]-H[N-2]<=1)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
    lol:
    return 0;
}

Measured memory_bytes: 1024
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define int long long
#define ll long long
#define P pair<int,int>
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define all(V) V.begin(),V.end()
#ifdef int
constexpr int INF = LLONG_MAX / 10;
#else
constexpr int INF = INT_MAX / 10;
#endif
constexpr double eps = 1e-9;
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
using namespace std;
inline ll gcd(ll a, ll b) {
	while (b) {
		ll c = a;
		a = b; b = c % b;
	}
	return a;
}
inline ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
bool isprime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
ll mypow(ll a, ll b) {
	if (!b)return 1;
	if (b & 1)return mypow(a, b - 1) * a;
	int memo = mypow(a, b >> 1);
	return memo * memo;
}
signed main() {
	int h, w;
	cin >> h >> w;
	if (h == 1 || w == 1)cout << 1 << endl;
	else cout << (h * w + 1) / 2 << endl;
	return 0;
}

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

int main()
{
    char x, y;
    cin >> x >> y;
    if(x == y){
        cout << "=" << endl;
    }else if(x < y){
        cout << "<" << endl;
    }else{
        cout << ">" << endl;
    }
    return 0;
}

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

#############
# Libraries #
#############

import math

#############
# Constants #
#############

MOD = 10**9 +7
INF = float('inf')

#############
# Functions #
#############

kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

#############
# Main Code #
#############

a,b = map(int, input().split())
 
if a >= b:
  print(str(b)*a)
else:
  print(str(a)*b)

Measured memory_bytes: 38384
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-11
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 500031;

int n;
vector<int> g[N];
int X[N];
int ok=1;

int min_other[5050];
int knap_min[2][25000];

void solve(int v)
{
	for (int i=0;i<g[v].size();i++)
	{
		int to=g[v][i];
		solve(to);
	}
	for (int i=0;i<=1;i++)
	{
		for (int j=0;j<=5050;j++)
		{
			knap_min[i][j]=1e9;
		}
	}
	knap_min[0][0]=0;
	for (int i=0;i<g[v].size();i++)
	{
		int to=g[v][i];
		for (int j=0;j<=5000;j++)
		{
			knap_min[1-i%2][j]=1e9;
		}
		for (int j=0;j<=5000;j++)
		{
			if (knap_min[i%2][j]>1e8)
				continue;
			// same col
			if (j+X[to]<=5000)
				knap_min[1-i%2][j+X[to]]=min(knap_min[1-i%2][j+X[to]],
						knap_min[i%2][j]+min_other[to]);
			// dif col
			int new_w=j+min_other[to];
			if (new_w<=5000)
				knap_min[1-i%2][new_w]=min(knap_min[1-i%2][new_w],
						knap_min[i%2][j]+X[to]);
		}
	}
	min_other[v]=1e9;
	int have_solution=0;
	int p=g[v].size()%2;
	for (int i=0;i<=5000;i++)
	{
		if (i<=X[v]&&knap_min[p][i]<1e8)
		{
			min_other[v]=min(min_other[v],knap_min[p][i]);
			have_solution=1;
		}
		if (knap_min[p][i]<=X[v])
		{
			min_other[v]=min(min_other[v],i);
			have_solution=1;
		}
	}
	if (!have_solution)ok=0;
}

int main(){
	//freopen("tree.in","r",stdin);
	//freopen("tree.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);

	cin>>n;
	for (int i=2;i<=n;i++)
	{
		int id;
		cin>>id;
		g[id].push_back(i);
	}

	for (int i=1;i<=n;i++)
	{
		cin>>X[i];
	}

	solve(1);

	if (ok)
		cout<<"POSSIBLE"<<endl;
	else
		cout<<"IMPOSSIBLE"<<endl;

	cin.get(); cin.get();
	return 0;
}



Measured memory_bytes: 12288
#include <iostream>

using namespace std;

int main(){
  int n,l,i;
  cin >> n;
  
  int a[n];
  
  for(i =0; i<n;i++){
    cin >> l;
    a[i] = l;
  }
  
  int count=0;
  int max =0;
  
  for(i=0;i<n;i++){
    for(int j=0;j<=i;j++){
		if(a[j] >= max){
          max = a[j];
        }
      
        if(i == j && max <= a[j]){
          count++;
          //cout << "in:" << a[j] << ":max:" << max << endl;
        }
    }
    max = 0;
  }
  cout << count <<endl;
  return 0;
}
    

Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int D = in.nextInt(), G = in.nextInt();
        int[] p = new int[D], c = new int[D];
        for(int i = 0; i < D; i++) {
            p[i] = in.nextInt();
            c[i] = in.nextInt();
        }
        int ans = Integer.MAX_VALUE;
        int loop = (int)Math.pow(2, D);
        for(int k = 0; k < loop; k++)  {
            int sum = 0, restMax = -1, cnt = 0;
            for(int i = 0; i < D; i++) {
                if((k>>i) % 2 == 1) {
                    sum += (i+1) * 100 * p[i] + c[i];
                    cnt += p[i];
                } else {
                    restMax = i;
                }
            }
            if(sum < G) {
                int point = 100 * (restMax + 1);
                int rest = (int)Math.ceil((G - sum) / (double)point);
                if(p[restMax] <= rest) {
                    continue;
                }
                cnt += rest;
            }
            ans = Math.min(ans, cnt);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
        
        try {
            int n = Integer.parseInt(br.readLine());
            st = new StringTokenizer(br.readLine());
            HashMap<Integer, Integer> hm = new HashMap<>();

            int[] a = new int[n];
            for(int i=0 ; i<n ; i++) {
                int x = Integer.parseInt(st.nextToken());
                a[i] = x;
                hm.put(x, hm.getOrDefault(x, 0) + 1);
            }

            int count = 0;
            for(int i=0 ; i<n ; i++) {
                int fr = hm.get(a[i]);
                if(a[i] == 1) {
                    if(fr == 1) count++;
                }
                else {
                    if(fr == 1 && !hm.containsKey(1)) {
                        boolean poss = true;
                        for(int j=2 ; j*j<=a[i] ; j++) {
                            if(a[i]%j == 0) {
                                if(hm.containsKey(a[i]/j) || hm.containsKey(j)) {
                                    poss = false;
                                    break;
                                }
                            }
                        }

                        if(poss) count++;
                    }
                }
            }

            pw.println(count);
        }
        finally {
            pw.flush();
            pw.close();
        }
    }
}


Measured memory_bytes: 70368
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		if((-40<=X)&&(X<=40)) {
			if(30<=X) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}
		sc.close();
	}

}

Measured memory_bytes: 35612
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int>> c(10, vector<int>(10));
	for (int i = 1; i <= n; ++i) {
		int a = i % 10;
		int b = i;
		while (b >= 10) {
			b /= 10;
		}
		c[a][b]++;
	}
	int ans = 0;
	rep(i, 10) {
		rep(j, 10) {
			ans += c[i][j] * c[j][i];
		}
	}
	dunk(ans);
	return 0;
}

Measured memory_bytes: 256
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    

#乗法のmod逆元
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

# nCr mod m
# modinvが必要
# rがn/2に近いと非常に重くなる
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res


#べき乗
def Raise(x, y, mod=10**9+7):
    # xをy乗する。
    n = 0
    while True:
        if (1<<n) > y:
            break
        n+=1
    D = [0]*(n+1)
    x = x % mod
    D[0] = x
    index = 0
    for index in range(1,n):
        D[index] = (D[index-1]**2)
    res = 1
    index = 0
    for index in range(0, n):
        if (y>>index)&1 == 1:
            res *= D[index]
    return res


def main():
    #答えは 10^2 - 2*9^2 + 8^2
    n = I()
    res = Raise(10, n)- 2 * Raise(9, n) + Raise(8, n)
    print(res % (10**9+7))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 97116
N, M = map(int, input().split())
H = list(map(int, input().split()))
good = [1] * N

for i in range(M):
    A, B = map(int, input().split())
    A -= 1; B -= 1
    if H[A] > H[B]:
        good[B] = 0
    elif H[B] > H[A]:
        good[A] = 0
    else:
        good[A] = 0; good[B] = 0

print(sum(good))

Measured memory_bytes: 20108
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using static System.Console;
using static System.Math;

class program
{
    static public int mod = 1000000007;
    static void Main()
    {
        var z = longa();
        long x = z[0], k = z[1], d = z[2];
        long n = x / d;
        long ans = 0;
        if(Abs(n) > k)
        {
            ans = Max(x - k * d, - x - k * d);
        }
        else
        {
            if((k-n)%2 == 0)
            {
                ans = Abs(x - n * d);
            }
            else
            {
                ans = Min(Abs(x - d - n * d), Abs(x + d - n * d));
            }
        }
        Write(ans);
    }

    static int pow(int a, int b) { string binary = Convert.ToString(b, 2); int bileng = binary.Length; long a_power = a; long value = 1; for (int i = bileng - 1; i >= 0; i--) { if (binary[i] == '1') { value = value * a_power % mod; } a_power = a_power * a_power % mod; } return (int)value; }
    static string rstr() { return ReadLine(); }
    static int rint() { return int.Parse(ReadLine()); }
    static long rlong() { return long.Parse(ReadLine()); }
    static string[] stra() { return ReadLine().Split(' '); }
    static char[] chara() { string[] a = stra(); string b = ""; for (int i = 0; i < a.Length; i++) { b += a[i]; } return b.ToCharArray(); }
    static int[] inta() { string[] read_str_array = ReadLine().Split(' '); int[] return_int_array = new int[read_str_array.Length]; for (int countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_int_array[countup_i] = int.Parse(read_str_array[countup_i]); } return return_int_array; }
    static long[] longa() { string[] read_str_array = ReadLine().Split(' '); long[] return_long_array = new long[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_long_array[countup_i] = long.Parse(read_str_array[countup_i]); } return return_long_array; }
    static double[] doublea() { string[] read_str_array = ReadLine().Split(' '); double[] return_double_array = new double[read_str_array.Length]; for (long countup_i = 0; countup_i < read_str_array.Length; countup_i++) { return_double_array[countup_i] = double.Parse(read_str_array[countup_i]); } return return_double_array; }
    static long GCD(long a, long b) { if (a < b) { long temp = a; a = b; b = temp; } if (a % b == 0) { return b; } else { long temp = b; b = a % b; a = temp; return GCD(a, b); } }
    static long LCM(long a, long b) { return a * b / GCD(a, b); }
    static void WriteArray2(int[,] a, int b, int c) { for (int i = 0; i < b; i++) { for (int j = 0; j < c; j++) { if (j != 0) Write(" "); Write(a[i, j]); } WriteLine(); } }
    static void WriteArray(int[] a, int b) { for (int i = 0; i < b; i++) { Write(" "); Write(a[i]); } WriteLine(); }
}


Measured memory_bytes: 27556
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
#define int long long
signed main(void){
    int n,W; cin>>n>>W;
    vector <int> w(n),v(n);
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    vector<vector<vector<int>>> dp (n+1, vector<vector<int>>(110 , vector<int>(400))); //見た数、入れた数、重さの端数(?)
    for(int i=0;i<n;i++){
        for(int j=0;j<i+1;j++){
            for(int k=0;k<350;k++){
                
                if((j+1)*w[0]+ k+(w[i]-w[0]) <= W&&k+(w[i]-w[0])<400 )
                chmax(dp[i+1][j+1][k+(w[i]-w[0])] ,dp[i][j][k] + v[i]);
                chmax(dp[i+1][j][k], dp[i][j][k]);
            }
            
        }
    }
    int ans = -114514;
    for(int i=0;i<110;i++){
        for(int j=0;j<400;j++){
            if(i*w[0]+j<=W)
            chmax(ans,dp[n][i][j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 35712
import math as m
def isprime(n):
  #if n == 2:
  #  return True
  d = int(m.sqrt(n))
  for i in range(2, d):
    if n%i==0:
      return False
  return True

n = int(input())

while (True):
  if isprime(n):
    print(n)
    break
  else:
    n += 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define MOD 1000000007
#define INF 100000000
#define MAX 100001
#define int ll
#define ll long long
#define ld long double
#define vi vector<int>
#define pa pair<int, int>
#define pb push_back
#define mp make_pair
 
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...)type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void MACRO_VAR_Scan(First& first, Rest&...rest) { cin >> first; MACRO_VAR_Scan(rest...); }
#define VEC(type, c, n) vector<type> c(n);for(auto& i:c)cin>>i;
#define MAT(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
 
#define BR cout << "\n";
#define SP cout << " ";
#define ENDL cout<<endl;
#define OUT(d) cout<<(d);
#define OUTL(d) cout<<(d)<<endl;
#define YES OUTL("YES")
#define Yes OUTL("Yes")
#define NO OUTL("NO")
#define No OUTL("No")
#define RET return 0;
 
#define REP(i, n) for(int i=0;i<(n);i++)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define FOR(i, m, n) for(int i = m;i < n; i++)
#define RFOR(i, a, b) for(int i=(a)-1;i>=(b);--i)
#define AREP(a, n) for(auto (a):(n))
#define ALL(a) (a).begin(),(a).end()
#define IN(n, a, b) ((a)<=(n)&&(n)<(b))

typedef struct{
    int a, b;
}S;
signed main(){ INIT;
    VAR(int, n, h);
    S s[n];
    int maxv = 0;
    REP(i, n){
        cin >> s[i].a >> s[i].b;
        maxv = max(maxv, s[i].a);
    }
    
    sort(s, s+n, [](const S& s1, const S& s2){ return s1.b > s2.b; });
    int d = 0, ans = 0;
    REP(i, n){
        if(s[i].b >= maxv){
            d += s[i].b;
            ans++;
            if(d >= h){
                OUTL(ans); RET;
            }
        }else{
            break;
        }
    }
    ans += (h - d) / maxv + ((h - d) % maxv ? 1 : 0);
    OUTL(ans);
RET;}


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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define mod 1e9+7
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define pp pop_back
#define bs binary_search
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {
	fast_io;
	
	ll n,k,x,y;
	cin>>n>>k;
	set<ll> S;
	while(k--)
	{
	    cin>>x;
	    while(x--)
	    {
	        cin>>y;
	        S.insert(y);
	    }
	}
	cout<<n-S.size();
	return 0;
}


Measured memory_bytes: 3644
N = int(input())
a = []
for i in range(N):
  a.append(list(map(int,input().split())))
A = [a[0][0]]
B = [a[0][1]]
C = [a[0][2]]
if N == 1:
  print(max(A[0],B[0],C[0]))
else:
  for i in range(N-1):
    A.append(max(B[i],C[i])+a[i+1][0])
    B.append(max(A[i],C[i])+a[i+1][1])
    C.append(max(A[i],B[i])+a[i+1][2])
  print(max(A[N-1],B[N-1],C[N-1]))

Measured memory_bytes: 42544
#include <bits/stdc++.h>
#define db(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
#define ll long long
#define ld long double
#define pll pair<ll, ll>
#define MOD 1000000007
using namespace std;
const long long INF = 3*1e18;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll N, A, B;
    cin >> N >> A >> B;
    if(A == 0 && B == 0){
        cout << 0 << "\n";
        return 0;
    }
    ll ans = ((N / (A + B)) * A) + min((N % (A + B)), A);
    cout << ans << "\n";
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <cctype>
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef vector<ll> vecl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template <class T>
inline void read(T &ret) {
    char c;
    int sgn;
    if (c = getchar(), c == EOF) return ;
    while (c != '-' && (c < '0' || c > '9')) c = getchar();
    sgn = (c == '-') ? -1:1;
    ret = (c == '-') ? 0:(c - '0');
    while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
    ret *= sgn;
    return ;
}
inline void outi(int x) {if (x > 9) outi(x / 10);putchar(x % 10 + '0');}
inline void outl(ll x) {if (x > 9) outl(x / 10);putchar(x % 10 + '0');}

using namespace std;

int k;
int main()
{
    cin>>k;
    for(int i=1;i<=k;i++)
    {
        cout<<"ACL";
    }
    cout<<endl;
    
}


Measured memory_bytes: 3624
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, core.stdc.stdio;

void main() {
    auto X = readln.chomp.to!int;

    auto dp = new int[](100);
    dp[] = 1 << 29;
    dp[0] = 0;

    foreach (i; 0..100) {
        foreach (j; 1..6) {
            if (i + j < 100) {
                dp[i + j] = min(dp[i + j], dp[i] + 1);
            }
        }
    }

    if (dp[X % 100] <= X / 100) {
        writeln(1);
    } else {
        writeln(0);
    }
}

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Vector.Unboxed as Vec
import Debug.Trace as De

getIntList = map read . words <$> getLine


listToTriple abc =(a,b,c)
    where [a,b,c]=abc
main :: IO ()

fir (a,_,_)=a
sec (_,b,_)=b
trd (_,_,c)=c

canlogcut::Int->[Int]->Int ->Bool
canlogcut k as l = k >= (sum (map (\x ->  (x-1) `div` l )as) )

solve:: Int->[Int]->Int->Int ->Int
solve k as bmin bmax
    | bmin+1==bmax = bmax
    | (canlogcut k as bgen) = solve k as bmin bgen
    | otherwise = solve k as bgen bmax
        where bgen =(bmin+bmax) `div` 2


main = do
    [_,k]<-getIntList
    as<-getIntList
    putStrLn(show (solve k as 0 1000000005))



    



Measured memory_bytes: 64192
n,k = map(int,input().split())
s= n
ans=[]
freeNode = [2]
cur=2
ans.append([1,2])
if n==2 :
    if k>0:
        print(-1)
    else:
        print(1)
        print(1, 2)
        exit()
else:
    s=0
    c=1
    if (n-2)*(n-1)//2<k:
        print(-1)
        exit()
    else:
        while(1):
            s += c
            cur+=1
            c+=1
            freeNode.append(cur)
            ans.append([1,cur])
            if s >=k:
                break
    if cur!=n:
        remove = s-k;
        if remove:
            for v in freeNode:
                ans.append([v,cur])
                remove-=1
                if remove==0:
                    break
        for i in range(cur + 1, n + 1):
            cur+=1
            for j in range(1, cur):
                ans.append([i, j])
        print(len(ans))
        for u,v in ans:
            print(u,v)
    else:
        remove = s - k;
        if remove:
            for v in freeNode:
                ans.append([v, cur])
                remove -= 1
                if remove == 0:
                    break
        print(len(ans))
        for u, v in ans:
            print(u, v)

Measured memory_bytes: 4144
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;
int a[200100];

ll solve() {
    ll res = 0;
    int j = 0;
    int b = 0;
    for (int i = 0; i < n; i++) {
        while (j < n && ((b ^ a[j]) == b + a[j])) {
            b ^= a[j];
            j++;
        }
        res += j - i;
        b ^= a[i];
    }
    
    return res;
}

void input() {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
}

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

    input();
    cout << solve() << endl;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(void) {

	ios::sync_with_stdio(false);
	cin.tie(0);


	int a[10][10] = {}; //begin end;

	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		string str = to_string(i);
		int ib = ctoi(str[0]);
		int ie = ctoi(str[str.length() - 1]);
		a[ib][ie] += 1;

	}

	ll ans = 0;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {

			ans += a[i][j] * a[j][i];

		}

	}

	cout << ans << endl;

	return 0;
}


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

string S;
long int K;

int main(){
    cin >> S >> K;
    int i = 0;
    while(true){
        if (S[i] != '1'){
            break;
        }
        if (i == K -1){
            break;
        }
        i++;
    }
    cout << S[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define endl '\n'
#define MAX INT_MAX
#define MIN INT_MIN
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mod 1000000007
#define pb push_back
#define sz(a) (int)((a).size())
#define all(a) a.begin(),a.end()
#define loopf(i,a,b) for(int i = a;i < b;i++)
#define loopb(i,a,b) for(int i = a;i >= b;i--)
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;


int32_t main()
{
    fast

   int test=1;
   //cin>>test;


  while(test--)
  {
  int n,x;
  cin>>n;
 vi h(n),dp(n);
 dp[0]=0;
 for(int i=0;i<n;i++)cin>>h[i];
  dp[1]=abs(h[1]-h[0]);
  for(int i=2;i<n;i++)
  {
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
  }
 cout<<dp[n-1];

  //while loop ending 
  }

return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int[] c = new int[4];

		for ( int i=0; i<n; i++ ) {
			String s = sc.next();
			if ( s.equals("AC") ) c[0]++;
			else if ( s.equals("WA") ) c[1]++;
			else if ( s.equals("TLE") ) c[2]++;
			else c[3]++;
		}

		System.out.println("AC x " + c[0]);
		System.out.println("WA x " + c[1]);
		System.out.println("TLE x " + c[2]);
		System.out.println("RE x " + c[3]);
	}
}


Measured memory_bytes: 58360
#include <iostream>
#include <string>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int price = 700;
  if (s[0]== 'o') price = price + 100;
  if (s[1]== 'o') price = price + 100;
  if (s[2]== 'o') price = price + 100;
  cout << price<< endl;
}

Measured memory_bytes: 256