akhauriyash/Code-Regression huggingface dataset:
import math
import sys
N = int(input())
N_next = math.ceil((math.sqrt(N)+1)**2)
#print(N_next)

    
    
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n + 1):
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
    
#print(primes(7)[-1])
for i in range(N,N_next):
    if primes(i)[-1] >= N:
        print(i)
        sys.exit()

Measured memory_bytes: 10120
#include <stdio.h>

int main(void) {
    int n;
    scanf("%d", &n);
    int x = 0, ten = 1;
    for(int i = 0; i <= 8; i++) {
        x += n / ten % 10;
        ten *= 10;
    }
    if(n % x == 0) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
n, k = gets.split.map(&:to_i)
m = 998244353
dp = Array.new(n, 0)
dp[0] = 1

lr = k.times.map {gets.split.map(&:to_i)}

n.times do |i|
    dp[i + 1] += dp[i] if 0 < i && i + 1 < n
    lr.each do |l, r|
        dp[i + l] = (dp[i + l] + dp[i]) % m if i + l < n
        dp[i + r + 1] = (dp[i + r + 1] - dp[i]) if i + r + 1 < n
    end
end

p dp[-1] % m

Measured memory_bytes: 15796
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
  int N, M;
  cin>>N>>M;
  int k[M];
  int A[M][N]={ };
  for(int i=0;i<M;i++){
    cin>>k[i];
    for(int j=0;j<k[i];j++){
      int k;
      cin>>k;
      A[i][k-1]=1;
    }
  }
  int p[M],ans[M];
  for(int i=0;i<M;i++){
    cin>>p[i];
  }
  
  //////////////
  int cnt=0;
  int b[N];
  for(int i=0;i<pow(2,N);i++){
    int num=i;
    for(int j=0;j<N;j++){
      b[j]=num%2;
      num /= 2;
    }
    //b
    //A*b=p?
    for(int row=0;row<M;row++){
      int tmp=0;
      for(int column=0;column<N;column++){
        tmp+=A[row][column]*b[column];
      }
      ans[row]=tmp;
    }
    //ans judge
    int sum=0;
    for(int i=0;i<M;i++){
      if(ans[i]%2==p[i]){
        sum++;
      }
    }
    if(sum==M){
      cnt++;
    }
  }
  cout<<cnt;
  
  /////////
  /*
  for(int i=0;i<M;i++){
    for(int j=0;j<N;j++){
		cout<<A[i][j]<<" ";
    }
    cout<<endl;
  }
  for(int i=0;i<M;i++){
    cout<<p[i]<<" ";
  }
  */
  
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> key;
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    int s = 0;
    rep(j, b) {
      int c;
      cin >> c;
      --c;
      s |= 1 << c;
    }
    key.emplace_back(s, a);
  }

  constexpr int INF = 1001001001;
  vector<int> dp(1 << n, INF);
  dp[0] = 0;
  rep(s, 1 << n) {
    rep(i, m) {
      int next_s = s | key[i].first;
      dp[next_s] = min(dp[next_s], dp[s] + key[i].second);
    }
  }
  cout << (dp.back() == INF ? -1 : dp.back()) << endl;
  return 0;
}


Measured memory_bytes: 256
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	int ans = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int r, g, b, n, ans = 0;
    cin >> r >> g >> b >> n;

    rep(i, n+1) {
        rep(j, n+1) {
            int m = n-i*r-j*g;

            if(0 <= m && m%b == 0) {
                ans++;
            }
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
long long f(long long a, long long b) {
    long long r, t;
  if(a<b){
    t = a;
    a = b;
    b = t;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int main(void){
    long long A, B, C, D, S, gcd, lcm;
    scanf("%lld %lld %lld %lld", &A, &B, &C, &D);
    S=B-A+1;
    S-=B/C-(A-1)/C;
    S-=B/D-(A-1)/D;
    gcd=f(C, D);
    lcm=C*D/gcd;
    S+=B/lcm-(A-1)/lcm;
    printf("%lld\n", S);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  ll a[n];
  rep(i,n) cin >> a[i];
  ll s[n+1];
  s[0]=0;
  ll ans=LLONG_MAX;
  rep(i,n){
    s[i+1]=s[i]+a[i];
    //    cout << s[i+1] << endl;
  }
  rep(i,n+1){
    ans=min(ans,abs(s[n]-s[i] - s[i] ));
  }
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define TR(X) ({ if(1) cerr << "Trace: " << (#X) << " = " << (X) << endl; })
const ll mod = 1e9 + 7;

void add_self(ll &a, ll b) {
	a += b;
	if(a >= mod) a -= mod;
	if(a < 0) a += mod;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n; cin >> n;
	vector<vector<ll> > a(n, vector<ll>(n));
	for(ll i = 0; i < n; i++) for(ll j = 0; j < n; j++) cin >> a[i][j];
	vector<ll> dp(1LL << n);
	dp[0] = 1;
	for(ll k = 0; k < (1LL << n) - 1; k++) {
		ll m = __builtin_popcountll(k);
		for(ll b = 0; b < n; b++) {
			if(!(k & (1LL << b)) && a[m][b]) add_self(dp[k ^ (1LL << b)], dp[k]);
		}
	}
	cout << dp[(1LL << n) - 1] << '\n';
}


Measured memory_bytes: 16640
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
//#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;
const lli INF = 1e18L+5;
/*
lli power(lli x,lli y)
{
    lli res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}
*/
int main()
{
//cout.precision(10);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   //freopen("input1.txt","r",stdin);
   //freopen("outputmid1.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
		lli i,n,k,q,x,ans=0;
		cin>>n>>k>>q;
		lli arr[n]={0};
		for(i=0;i<q;i++)
		{
			cin>>x;
			arr[x-1]++;
		}
		for(i=0;i<n;i++)
		arr[i]=k-(q-arr[i]);
		for(i=0;i<n;i++)
		{
			if(arr[i]>0)
			cout<<"Yes"<<endl;
			else
			cout<<"No"<<endl;
		}
	}
}

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

int main(){
  int n,c,ans=0;
  cin>>n;
  for(int i=1;i<=n;i++){
    c=0;
    if(i%2==0){
      continue;
    }
    for(int j=1;j<=i;j++){
      c+=(i%j==0);
    }
    ans+=(c==8);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int i,j,m[10],b[3],w;
  for(i=0;i<10;i++){
    scanf("%d",&m[i]);
  }
  
  for(i=0;i<10;i++){
    for(j=0;j<9;j++){
      if(m[j]<m[j+1]){
	w=m[j];m[j]=m[j+1];m[j+1]=w;
      }
    }
  }
  for(i=0;i<3;i++){
    printf("%d\n",m[i]);
  }

  return 0;
}

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

using namespace std;

void Main() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> bells;
    bells.push_back(a);
    bells.push_back(b);
    bells.push_back(c);
    sort(bells.begin(), bells.end());
    cout << bells[0] + bells[1] << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef vector<string> svec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;

string s;


typedef bitset<100>bt;
bt b[100];
ll dp[101];
ll t2[101];

ll dnum[101];
void init() {
	dnum[1] = 1;
	t2[0] = 1;
	rep1(i, 100) {
		t2[i] = t2[i-1] * 2 % mod;
		for (int j = 2; j <= i; j++) {
			if (i%j == 0) {
				dnum[i] += dnum[i / j];
			}
		}
	}
}

map<string, ll> ansmemo;
map<string, bool> used;

ll calc(string s) {
	if (used[s])return ansmemo[s];
	used[s] = true;
	int len = s.length();
	vector<ll> dp(len+1, 0);
	dp[0] = 1;
	rep(i, len) {
		for (int j = 1; i + 2*j <= len; j++) {
			string t = s.substr(i, j);
			for (int k = 2; i + j * k <= len; k++) {
				for (int x = i + j * (k - 1); x < i + j * k; x++) {
					if (s[x] == '0') {
						t[(x - i) % j] = '0';
					}
				}
				(dp[i + j * k] += dp[i] * calc(t)) %= mod;
			}
		}
		(dp[i + 1] += dp[i]) %= mod;
		if (s[i] == '1') {
			(dp[i + 1] += dp[i]) %= mod;
		}
	}
	ll res = dp[len];
	//cout << s << " " << res << endl;
	return ansmemo[s] = res;
}

void solve() {
	cin >> s;
	cout << calc(s) << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(5);
	init();
	solve();
	//cout << "finish" << endl;
	//stop
	return 0;
}


Measured memory_bytes: 2816
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
import random
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()



N=int(input())
mod=10**9+7
dp=[[8,1,1,0] for i in range(N)]#1,2~8,9,both
for i in range(1,N):
    dp[i][0]=dp[i-1][0]*8
    dp[i][1]=dp[i-1][0]+dp[i-1][1]*9
    dp[i][2]=dp[i-1][0]+dp[i-1][2]*9
    dp[i][3]=dp[i-1][1]+dp[i-1][2]+dp[i-1][3]*10
    for n in range(4):
        dp[i][n]%=mod
print(dp[-1][3]%mod)


Measured memory_bytes: 233288
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  vi dp(5001, INF);
  rep(a, 30) rep(b, 30) rep(c, 30) {
    int s = 0;
    s += a % 5 * 380 + a / 5 * 5 * 380 * 80 / 100;
    s += b % 4 * 550 + b / 4 * 4 * 550 * 85 / 100;
    s += c % 3 * 850 + c / 3 * 3 * 850 * 88 / 100;
    int w = a * 200 + b * 300 + c * 500;
    if (w <= 5000) cmin(dp[w], s);
  }
  int n;
  while (cin >> n, n) cout << dp[n] << endl;
}

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

int main()
{
    
    string s1;
    getline( cin, s1 );
    int n1 = s1.size();
    
    int n=0;
    for( int i = 0; i < n1-1; i++ ){
        if( (int)s1[i+1]==(int)s1[i] ) n++;
    }

    if( n >= 1 ) {
        cout << "Bad" << endl;
    }
    else {
        cout << "Good" << endl;
    }
      
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vl vaector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
ll pow(ll x, ll y,ll m) { ll res = 1;x=x%m; while (y > 0) { if (y & 1) res = ((res%m) * (x%m))%m; y = y >> 1; x = ((x%m) * (x%m))%m; } return res%m; }
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
const ll INF = 0xFFFFFFFFFFFFFFFL;
clock_t time_p=clock();
void abhigyan10()
{time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}
ll seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l=0,ll r=INF){return uniform_int_distribution<ll>(l,r)(rng);}
#define clrbuf cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define preciset(x) cout<<setprecision(x)<<fixed;
const ll mod =1000000007;
int main()
{
        FastIO

        int a[3];
        cin>>a[0]>>a[1]>>a[2];
        sort(a,a+3);
        if(a[0]!= a[2] && (a[0]==a[1]||a[1]==a[2]))
        	cout<<"Yes\n";
        	else
        		cout<<"No\n";
        	return 0;
        }

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

int main() {

    // 1. input.
    int n;
    cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    
    // 2. calculate smallest, largest, total value.
    long long minVal = 1000000;
    long long maxVal = -1000000;
    long long total = 0;
    for(int i = 0; i < n; i++){
        minVal = min(minVal, a[i]);
        maxVal = max(maxVal, a[i]);
        total += a[i];
    }
    
    // 3. output answer.
    cout << minVal << " " << maxVal << " " << total << endl;
    return 0;
    
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
          using namespace std;
          #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
          #define M_PI 3.14159265358979323846
          #define data data_
          #define ff first
          #define ss second
          int const N = 21;
          bool a[N+1][N+1];
          long long dp[N+1][(1 << N)];
          long long const mod = 1e9 + 7;
          int n;
          long long fun(int id,int mask)
          {
            if(id == n)
                return (mask + 1 == (1 << n));
            else if(dp[id][mask] != -1)
                return dp[id][mask];
            else
            {
                long long ans = 0;
                for(int j = 0; j < n; j++)
                {
                    if(a[id][j] && ((mask & (1 << j)) == 0))
                    {
                        ans += fun(id+1,mask|(1<<j));
                        ans %= mod;
                    }
                }
                return dp[id][mask] = ans;
            }

          }
          int main()
          {
          // clock_t begin = clock();
          // #ifndef ONLINE_JUDGE
          // freopen("input.txt", "r", stdin);
          // freopen("output.txt", "w", stdout);
          // #endif
          tani_nachi_ke  

          cin >> n;
          for(int i = 0; i < n; i++)
          {
            for(int j = 0; j < n; j++)
                cin >> a[i][j];
          }
          memset(dp, -1, sizeof(dp));
          cout << fun(0,0) << endl;




          // #ifndef ONLINE_JUDGE 
          // clock_t end = clock();
          // cout<<endl<<double(end - begin) / CLOCKS_PER_SEC*1000<<" ms";
          // #endif 
          // return 0;
          }

Measured memory_bytes: 360704
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int D = sc.nextInt();

		if(D == 25) {
			System.out.println("Christmas");
		}else if(D == 24) {
			System.out.println("Christmas Eve");
		}else if(D == 23) {
			System.out.println("Christmas Eve Eve");
		}else if(D == 22) {
			System.out.println("Christmas Eve Eve Eve");
		}

	}
}

Measured memory_bytes: 21844
A,B=map(int, input().split())
S=input()

flag=True
if S[A]!='-':
    flag=False
a=S[:A]
b=S[A+1:]
if not(a.isdigit() and b.isdigit()):
    flag=False
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
import sys
import math
from fractions import gcd
# import queue
# from collections import Counter
# from itertools import accumulate
# from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

big_prime = 1000000007

"""
# 標準入力取得
## 文字列
 =  sys.stdin.readline().rstrip()
 =  list(sys.stdin.readline().rstrip())

## 数値
 =  int(sys.stdin.readline())
 =  map(int, sys.stdin.readline().split())
 =  list(map(int, sys.stdin.readline().split()))
 =  [list(map(int,list(sys.stdin.readline().split()))) for i in range(N)]
"""
from heapq import heappop, heappush, heapify
n,m =  map(int, sys.stdin.readline().split())
a =  list(map(int, sys.stdin.readline().split()))
q = []

for x in a:
        heappush(q,-x)
for _ in range(m):
        l = heappop(q)# 最小値をヒープから取り出す
        heappush(q, -((-l)//2))
print(-sum(q))

Measured memory_bytes: 16272
import java.util.Scanner;

/**
 * @author kawakami
 *
 */
class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner as = new Scanner(System.in);
		
		String mot = "";
		String fro = "";
		String bac = ""; 
		String str = "";
		String shu = "";
		
		
		
		int count = 0;
		int i = 0;
		int h = 0;
		
		
		while(true){
			
			mot = as.next();
			
			if(mot.equals("-")){
				
				break;
				
			}
			
			shu = mot;
			count = as.nextInt();
			
			for(i=0;i<count;i++){
				
				h = as.nextInt();
				
				fro = shu.substring(0,h);
				bac = shu.substring(h);
				shu = bac + fro;
				
			}
			
			str = shu;
			System.out.println(str);
			
		}

	}

}

Measured memory_bytes: 26272
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] str;
        str = s.split("");
        for (int i = 0; i < s.length(); i++) {
            for (int j = i + 1; j < s.length(); j++) {
                if (str[i].equals(str[j])) {
                    System.out.println("no");
                    System.exit(0);
                }
            }
        }
        System.out.println("yes");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int x;
  cin >> x;
  if (x >= a && x <= a + b) cout << "YES" << endl;
  else cout << "NO" << endl;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n;
    cin>>n;
    int p;
    while(n>0)
    {
        p=n%10;
        if(p==7)
        {
            cout<<"Yes";
            return 0;
        }
        n=n/10;

    }
    cout<<"No";
}


Measured memory_bytes: 3664
#include <iostream>
using namespace std;
int main(void) {
  int h, m, s;
  int h1, m1, s1, h2, m2, s2;
  int sec, rest;
  int rest1, rest2;

  while(1) {
    sec = 0;
    h1 = 0; m1 = 0; s1 = 0;
    h2 = 0; m2 = 0; s2 = 0;
    rest = 7200;
    cin >> h >> m >> s;
    if(h == -1 && m == -1 && s == -1) break;
    sec += h * 3600;
    sec += m * 60;
    sec += s;
    
    rest1 = rest - sec;
    while(rest1 != 0) {
      if(rest1 >= 3600) { rest1 -= 3600; h1++; }
      else if(rest1 >= 60) { rest1 -= 60; m1++; }
      else { rest1 -= 1; s1++; }
    }

    rest2 = rest - sec;
    rest2 *= 3;
    while(rest2 != 0) {
      if(rest2 >= 3600) { rest2 -= 3600; h2++; }
      else if(rest2 >= 60) { rest2 -= 60; m2++; }
      else { rest2 -= 1; s2++; }
    }
    
    cout << "0" << h1 << ":";
    if(m1 < 10) cout << "0" << m1 << ":";
    else cout << m1 << ":";    
    if(s1 < 10) cout << "0" << s1 << endl;
    else cout << s1 << endl;
    
    cout << "0" << h2 << ":";
    if(m2 < 10) cout << "0" << m2 << ":";
    else cout << m2 << ":";
    if(s2 < 10) cout << "0" << s2 << endl;
    else cout << s2 << endl;
    
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int,int>>a;
    rep(i,n){
        int x;
        cin >> x;
        a.emplace_back(x, -i);
    }
    sort(a.rbegin(), a.rend());
    vector<ll> ans(n);
    int cnt = 0;
    int id = n;
    for(int i = 0; i < n;){
        id = min(id,-a[i].second);
//        int id = -a[i].second;
        int num = a[i].first;
        while(i < n and  a[i].first == num)i++,cnt++;
        if(i < n){
            ans[id] += (long long)(num - a[i].first) * cnt;
        }else{
            ans[id] += (long long)a[i - 1].first * cnt;
        }
    }
    rep(i,n){
        cout << ans[i] << "\n";
    }
}

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

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

	int n;
	cin>>n;
	char s[n];
	cin>>s;
	char abc[3] = {'A','B','C'};
	int c=0,i,j;

	for(i=0;i<n;i++){
		if(s[i]==abc[0]){
			for(j=1;j<3;j++){
				if(s[i+j]!=abc[j])
					break;
			}
			if(j>=3)
				c++;
		}
	}
	cout<<c;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int

const int lim = (int)2e5 + 5;
const int mod = (int)1e9 + 7;


vpii adjList[(int)2e5];
vector<bool> visited(lim);

bool fail = false;
int oneVal = -1;
int ans = 0;
int minval = INT_MIN;// lower bound
int maxval = INT_MAX;// upper bound
vpii dp((int)2e5);
void dfs(int cur, int P, int cost, bool add){
//    cout << cur << " " << P << " " << cost << " " << add <<endl; 
    if(visited[cur]){
        if(dp[cur].second == add){
            if(dp[cur].first != cost)fail = true;
        }else{
            int tot = 0;
            tot = dp[cur].first - cost;
            if(!add)tot *= -1;
            if(tot % 2 || (oneVal != -1 && oneVal != tot/2)){
                fail = true;
            }
            oneVal = tot/2;
        }
        return;
        /*
        if(add){
            if(cost)fail = true;
            return;
        }
        if(cost % 2 || (oneVal != -1 && oneVal != cost/2)){
            fail = true;
            return;
        }
        oneVal = cost/2;
        return;*/
    }
    visited[cur] = true;
    dp[cur] = {cost, add};
    if(add){
        //cost + x > 0
        // cost + x >= 1
        // x >= 1 -cost
        minval = max(minval, 1 - cost);
    }else{
        //cost - x >= 1
        //cost - 1 >= x
        maxval = min(maxval, cost - 1); 
    }
    for(pii info: adjList[cur]){
        int child = info.first;
        int val = info.second;
        if(child != P){
            dfs(child, cur, val - cost, !add);
        }
    }
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,m;cin >> n >> m;
    int u, v, s;
    FOR(i, m){
        cin >> u >> v >> s;
        adjList[u].pb(mp(v, s));
        adjList[v].pb(mp(u, s));
    }
    dfs(1, -1, 0, true);
 //   debug(fail);
  //  debug(maxval);
   // debug(minval);
   // debug(oneVal);
    if(fail || maxval <= 0 || (oneVal != -1 && (oneVal > maxval || oneVal < minval)) || minval > maxval)cout << 0;
    else if(oneVal != -1)cout << 1;
    else cout << maxval - minval + 1 <<endl;
}




Measured memory_bytes: 19584
s = input()
ans = 0
for i in range(0,len(s),2):
    if s[i] == "L":
        ans += 1
    
for i in range(1,len(s),2):
    if s[i] == "R":
        ans += 1
        
if ans == 0:
    print("Yes")
else:
    print("No")
        

Measured memory_bytes: 2940
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
ll dp[100010];
ll sum[100010];
ll dp1[100010];
ll a[100010];
int main() {
	ll n, m;
	scanf("%lld %lld", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		sum[i] = sum[i - 1] + a[i];
	}
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		if (a[i] > 0)
			dp[i] += a[i];
	}
	for (int i = n; i >= 1; i--)
	{
		dp1[i] = dp1[i + 1];
		if (a[i] > 0)
			dp1[i] += a[i];
	}
	ll dap = 0;
	for (int i = m; i <= n; i++)
	{
		dap = max(sum[i] - sum[i - m] + dp[i - m] + dp1[i + 1], dap);
		dap = max(dp[i - m] + dp1[i + 1], dap);
	}
	printf("%lld", dap);
}

Measured memory_bytes: 3328
(defun solve (n &key (c 0))
  (if (and (<= (expt 2 c) n)
           (< n (expt 2 (+ c 1))))
      c
      (solve n :c (+ c 1))))

(defun main ()
  (let ((n (read)))
    (princ (expt 2 (solve n)))))

(main)

Measured memory_bytes: 12896
#include<iostream>
#include<set>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)

#include <algorithm>
using namespace std;
#include <cmath>
#include <string>
#include<vector>
#define elif else if
#define pb push_back
typedef long long ll;
#define TENNINE 1000000005
#define TENFIVE 200005
// #define int long long
#define mp make_pair
#define pb push_back

int N;


signed main(){
    cin>>N;
    
    pair<ll, pair<int,int>>inputp;
    vector<pair<ll, pair<int,int>>> v;
    int x,y;
    ll h;
    int not_zero_idx = -1;
    rep(i,N){
        cin>>x>>y>>h;
        if(h != 0 && not_zero_idx == -1)not_zero_idx = i;
        inputp = make_pair(h,make_pair(x,y));
        v.push_back(inputp);
    }
    ll zero = 0;
    rep(i,101){
        rep(j,101){
            ll H = v[not_zero_idx].first + abs(v[not_zero_idx].second.first -i) + abs(v[not_zero_idx].second.second -j);  
            rep(k,N){
                ll expect_h = max(H - abs(v[k].second.first -i) - abs(v[k].second.second -j) ,zero );
                if(v[k].first  != expect_h  )break;
                if(k == N-1){
                    cout<<i<<" " <<j<<" "<<H<<endl;
                    return 0;
                }
                
            }
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define SIZE 3

int main(void)
{
    int five = 0;
    int seven = 0;
    int num[SIZE];

    //input
    scanf("%d %d %d", &num[0], &num[1], &num[2]);
    for (int i = 0; i < SIZE; i++){
        if (num[i] == 5)
        five ++;
        else if(num[i] == 7)
        seven ++;
    }

    //output
    if(five == 2 && seven == 1)
        printf("YES");
    else
        printf("NO");

    return 0;
}

Measured memory_bytes: 128
open Scanf
open Printf

let () = scanf "%s %s" (fun a b->
  if a = "H" && b = "H" then "H"
  else if a = "H" && b = "D" then "D"
  else if a = "D" && b = "H" then "D"
  else "H"
  ) |> printf "%s\n"

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

int main() {
  string S, T;
  cin >> S >> T;
  int ans = 0;
  rep(i, S.size()) if (S[i] == T[i]) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void read(ll &a) {a=0;int b=1,c=getchar(); while(c>'9'||c<'0'){if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b;}
const int N=1e5+5;
ll n,k,cnt[55],ans,X,a[N];
int main()
{
    read(n);read(k);
    for(ll i=1;i<=n;i++) {read(a[i]); for(ll j=0;j<=40;j++) if(a[i]&(1ll<<j)) cnt[j]++;}
    for(ll i=40;i>=0;i--) if(cnt[i]<n-cnt[i] && X+(1ll<<i)<=k) X+=(1ll<<i);
    for(ll i=1;i<=n;i++) ans+=(X^a[i]);
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 1024
S = input()
T = input()
len_T = len(T)

kouho = []

for i in range(len(S) - len_T+1):
    # print(S[i:i+len_T])
    flag = 0
    for a, b in zip(T, S[i:i+len_T]):
        if a == b or b == '?':
            continue
        else:
            flag = 1
    if flag == 1:
        continue
    # print((S[:i]+T+S[i+len_T:]).replace('?', 'a'))
    kouho.append((S[:i]+T+S[i+len_T:]).replace('?', 'a'))
if not kouho:
    print("UNRESTORABLE")
else:
    print(sorted(kouho)[0])

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";cout<<endl;}
void solve(){
  int a,b;
  cin>>a>>b;
  int s1=a+b;
  int s2=a*b;
  int s3=a-b;
  cout<<max(s1,max(s2,s3))<<endl;
}
int32_t main(){
  IOS;
  solve();
  #ifdef LOCAL_DEFINE
  cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

int main() {
  int32_t n, d;
  std::cin >> n >> d;

  std::vector<int32_t> x(n), y(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> x.at(i) >> y.at(i);
  }

  int64_t dd = std::pow(d, 2);
  int32_t count = 0;
  for (int i = 0; i < n; ++i) {
    if (std::pow(x.at(i), 2) + std::pow(y.at(i), 2) <= dd) {
      ++count;
    }
  }

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


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int x = 6;
  int a, b;
  cin >> a >> b;
  x -= a + b;
  cout << x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int arr[n];
  int i;
  int s=0;
  for(i=0;i<n;i++)
    cin>>arr[i];
  sort(arr,arr+n);
  for(i=0;i<k;i++)
    s=s+arr[i];
  cout<<s;
}

Measured memory_bytes: 3568
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	d2 := [9][9]int{}
	top := 0
	for i1 := 0; i1 < 10; i1++ {
		top = i1
		for i2 := 0; i2 < 10; i2++ {
			if i1 == 0 {
				top = i2
			}
			for i3 := 0; i3 < 10; i3++ {
				if i1 == 0 && i2 == 0 {
					top = i3
				}
				for i4 := 0; i4 < 10; i4++ {
					if i1 == 0 && i2 == 0 && i3 == 0 {
						top = i4
					}
					for i5 := 0; i5 < 10; i5++ {
						if i1 == 0 && i2 == 0 && i3 == 0 && i4 == 0 {
							top = i5
						}
						for i6 := 0; i6 < 10; i6++ {
							if i1 == 0 && i2 == 0 && i3 == 0 && i4 == 0 && i5 == 0 {
								top = i6
							}
							for i7 := 1; i7 < 10; i7++ {
								if i1 == 0 && i2 == 0 && i3 == 0 && i4 == 0 && i5 == 0 && i6 == 0 {
									top = i7
								}
								if i1*1000000+i2*100000+i3*10000+i4*1000+i5*100+i6*10+i7 > n {
									goto BREAK
								}
								d2[top-1][i7-1]++
							}
						}
					}
				}
			}
		}
	}
BREAK:

	count := 0
	for i := 0; i < 9; i++ {
		for j := 0; j < 9; j++ {
			for k := 0; k < 9; k++ {
				for l := 0; l < 9; l++ {
					if i == l && j == k {
						count += d2[i][j] * d2[k][l]
					}
				}
			}
		}
	}

	fmt.Printf("%d\n", count)
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int Q = Integer.parseInt(br.readLine());
		
		boolean seive[] = new boolean[200000];
		
		seive[0] = seive[1] = true;
		
		for(int i = 2; i<200000; i++) {
			if(!seive[i]) {
				for(int j = i*2; j<200000; j += i) {
					seive[j] = true;
				}
			}
		}
		
		int pre[] = new int[200000];
		
		for(int i = 3; i<200000; i++) {
			pre[i] = pre[i-1];
			if(!seive[i] && !seive[(i+1)/2]) pre[i]++;
		}
		
		for(int q = 0; q<Q; q++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			
			int a = Integer.parseInt(st.nextToken()), b = Integer.parseInt(st.nextToken());
			
			System.out.println(pre[b] - pre[a-1]);
		}
		
	}

}


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

using namespace std;

int n;
map<int, set<pair<int, int>>> edge;
vector<long long> cost;

void dfs(int k) {
  cost[k] = 0;
  queue<int> q;
  q.push(k);
  while (!q.empty()) {
    auto u = q.front();
    q.pop();
    for (auto vs: edge[u]) {
      int v = vs.first, l = vs.second;
      if (cost[v] != 1e18) {
        continue;
      }
      cost[v] = cost[u] + l;
      q.push(v);
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int u, v, l;
    cin >> u >> v >> l;
    edge[u].insert(make_pair(v, l));
    edge[v].insert(make_pair(u, l));
  }
  int q, k;
  cin >> q >> k;
  cost = vector<long long>(n + 1, 1e18);
  dfs(k);
  for (int i = 0; i < q; i++) {
    int x, y;
    cin >> x >> y;
    long long ans = cost[x] + cost[y];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 21376
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,a[N],to[N*2],nxt[N*2],fst[N],l,ans;
void link(int x,int y)
{
	to[++l]=y;nxt[l]=fst[x];fst[x]=l;
	to[++l]=x;nxt[l]=fst[y];fst[y]=l;
}
void dfs(int x,int f)
{
	for (int i=fst[x];i;i=nxt[i])
		if (to[i]!=f)
		{
			dfs(to[i],x);
			if (!a[to[i]])
				ans|=a[x],a[x]=a[to[i]]=1;
		}
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<n;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		link(x,y);
	}
	dfs(1,0);ans|=a[1]==0;
	puts(ans?"First":"Second");
}

Measured memory_bytes: 2560
n,x=map(int,input().split())
c=0
l=list(map(int,input().split()))
for i in range(1,n):
    if(l[i-1]+l[i]>x):
        c+=l[i-1]+l[i]-x
        l[i]=max(0,l[i]-(l[i-1]+l[i]-x))
print(c)


Measured memory_bytes: 85144
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<map>
#include<queue>

using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef pair< double , double > Pi;
typedef pair< double , Pi > Pii;
typedef long long int64;

int M, N;
string mas[1000], FIND[2];
bool flag[1000][1000];


int cnt_mas(){
  int ret = 0;
  for(int i = 0; i < M - 1; i++){
    for(int j = 0; j < N - 1; j++){
      bool judge = true;
      for(int k = 0; k < 2; k++){
        for(int l = 0; l < 2; l++){
          judge &= mas[i + k][j + l] == FIND[k][l];
        }
      }
      flag[i][j] = judge;
      ret += flag[i][j];
    }
  }
  return ret;
}


int main(){

  cin >> M >> N;
  for(int i = 0; i < M; i++){
    cin >> mas[i];
  }
  for(int i = 0; i < 2; i++){
    cin >> FIND[i];
  }
  int base = cnt_mas(), ret = 0;
  string buff = "JOI";
  for(int i = 0; i < M; i++){
    for(int j = 0; j < N; j++){
      for(int k = 0; k < 3; k++){
        if(buff.at(k) != mas[i][j]){
          swap( mas[i][j], buff.at(k));
          int add = 0;
          for(int l = -(i != 0); l < (i != M - 1); l++){
            for(int m = -(j != 0); m < (j != N - 1); m++){
              bool judge = true;
              for(int n = 0; n < 2; n++){
                for(int o = 0; o < 2; o++){
                  judge &= mas[i + l + n][j + m + o] == FIND[n][o];
                }
              }
              add += judge - flag[i + l][j + m];
            }
          }
          ret = max( ret, add);
          swap( mas[i][j], buff.at(k));
        }
      }
    }
  }
  cout << base + ret << endl;
}

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

if 1 <= n <= 9:
    print(n)
elif 10 <= n <= 99:
    print(9)
elif 100 <= n <= 999:
    print(9 + (n - 99))
elif 1000 <= n <= 9999:
    print(9 + 900)
elif 10000 <= n <= 99999:
    print(9 + 900 + (n - 9999))
else:
    print(9 + 900 + 90000)

Measured memory_bytes: 9156
#include <stdio.h>

int main(){
    int H, W, i, j;
    while(1){
    scanf("%d %d\n", &H, &W);
    if(H == 0 && W == 0) break;
    for(i = 0; i < H; i++){
        if((i % 2) == 1){
            for(j = 0; j < W; j++){
                if((j % 2) == 1){
                    printf("#");
                }
                else{
                    printf(".");
                }
            }
        }
        else{
            for(j = 0; j < W; j++){
                if((j % 2) == 1){
                    printf(".");
                }
                else{
                    printf("#");
                }
            }
        }
        printf("\n");
   }
   printf("\n");
   }
   return 0;
}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n;
    cin>>n;
    string s;
    set<string> ss;
    while(n--){
    	cin>>s;
    	ss.insert(s);
	}
	cout<<ss.size()<<"\n";
    return 0;
}

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

using namespace std;

typedef long long ll;

bool IsPrime(ll N){
  for (ll i=2; i*i<=N; i++){
    if(N % i == 0) return false;
  }
  return N != 1;
}

int main(){
  ll X;
  cin >> X;
  
  while(!IsPrime(X)) ++X;

  cout << X << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
bool p(double a){
	if(a==int(a))return true;
		else return false;
	}
int main(){
	int a,b;
	cin>>a>>b;
	if(b<10&&p(sqrt(a*10+b))==1){
		cout<<"Yes"<<endl;
	}
	else if(b<100&&b>9&&p(sqrt(a*100+b))==1){
		cout<<"Yes"<<endl;
	}
	else if(b==100&&p(sqrt(a*1000+b))==1){
		cout<<"Yes"<<endl;
	}	
	else{
		cout<<"No"<<endl;
	}
	return 0;
}




Measured memory_bytes: 256
B, Z, W, J, I, X, Y, N, M, A['   '];
main() {
  scanf("%d%d", &N, &M);
  for (; ~scanf("%d%d", &X, &Y);) {
    B = Y + 1;
    for (J = 1; J * J <= M; J++) {
      Z = (X + J - 1) / J, W = Y / J;
      A[Z]++;
      A[W + 1 < B ? W + 1 : B]--;
      B = Z;
    }
    for (I = 1; I < B; I++) {
      if ((X - 1) / I < Y / I) {
        A[I]++;
        A[I + 1]--;
      }
    }
  }
  for (I = 1; I <= M; I++) {
    A[I] += A[I - 1];
    printf("%d\n", A[I]);
  }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<int,int> pii;

int n,k,a[200005];

int main()
{
    scanf("%d%d",&k,&n);
    for(int i=0;i<n;i++) scanf("%d",a+i);
    sort(a,a+n);
    int ans=0;
    for(int i=1;i<n;i++) ans=max(ans,a[i]-a[i-1]);
    ans=max(ans,a[0]+k-a[n-1]);
    printf("%d",k-ans);
    return 0;
}

Measured memory_bytes: 1024
from collections import deque

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

color = [-1] * n
G = [ deque([]) for _ in xrange(n)]

def dfs(r, c):
    S = deque([])
    S.append(r)
    color[r] = c
    while len(S) > 0:
        u = S.pop()
        for i in xrange(len(G[u])):
            v = G[u][i]
            if color[v] == -1:
                color[v] = c
                S.append(v)

    return 

def assignColor():
    id_ = 1
    for u in xrange(n):
        if color[u] == -1:
            dfs(u,id_)
            id_ += 1
    return

def main():
    for i in xrange(m):
        a = map(int, raw_input().split())
        #print a,a[1],G[a[1]],color[9]
        G[a[0]].append(a[1])
        G[a[1]].append(a[0])

    assignColor()
    
    q = int(raw_input())
    for i in xrange(q):
        a = map(int, raw_input().split())
        if color[a[0]] == color[a[1]]:
            print 'yes'
        else:
            print 'no'

    return 0

main()

Measured memory_bytes: 75772
import java.util.*;

public class Main
{

    static Scanner sc = new Scanner(System.in);
    static class Str{
        int[] chars = new int[26];
    }
    public static void main(String[] args) {
        int n = sc.nextInt();
        Str[] words = new Str[n];
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            words[i] = new Str();
            for (int j = 0; j < s.length(); j++) {
                char c = s.charAt(j);
                words[i].chars[c - 'a'] += 1;
            }
        }
        Str fin = new Str();
        for (int i = 0; i < 26; i++) {
            int min_c = Integer.MAX_VALUE;
            for (int j = 0; j < n; j++) {
                min_c = Math.min(min_c, words[j].chars[i]);
            }
            fin.chars[i] = min_c;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 26; i++) {
            for (int j = 0; j < fin.chars[i]; j++) {
                sb.append((char)(i + 'a'));
            }
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 23764
function main(input) {
   input = input.trim();
 　const a = input.split(" ").map(Number);
 　const gou = a[0]+a[1];
 　console.log(a[2]>=a[0]&&gou>=a[2]?"YES":"NO");
 }
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29568
#include<stdio.h>
int main(){
  int n,i,t;
  scanf("%d",&n);
  while(n--){
    int h=1,b=0,c=0;
    for(i=0;i<10;i++){
      scanf("%d",&t);
      if(h){
	if     (b<t)b=t;
	else if(c<t)c=t;
	else        h=0;
      }
    }
    if(h)printf("YES\n");
    else printf("NO\n");
  }
  return 0;
}
  

Measured memory_bytes: 580