akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int N, M, Q, col[100009], lst[11][100009];
vector < int > h[100009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &M);
while (M --)
{
    int x, y;
    scanf ("%d %d", &x, &y);
    h[x].push_back (y);
    h[y].push_back (x);
}
scanf ("%d", &Q);
for (int i=1; i<=Q; i++)
{
    int x, d;
    scanf ("%d %d %d", &x, &d, &col[i]);
    lst[d][x] = i;
}
for (int lev=10; lev>=1; lev--)
    for (int u=1; u<=N; u++)
        if (lst[lev][u] > 0)
            for (auto v : h[u])
                if (lst[lev][u] > lst[lev - 1][v])
                    lst[lev - 1][v] = lst[lev][u];
for (int i=1; i<=N; i++)
{
    int latest = 0;
    for (int j=0; j<=10; j++)
        if (lst[j][i] > latest)
            latest = lst[j][i];
    printf ("%d\n", col[latest]);
}
return 0;
}


Measured memory_bytes: 11128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int n = s.length();
        char[] c = s.toCharArray();

        int count = 0;

        Deque<Character> deque = new ArrayDeque<>();
        for(int i = 0;i<n;i++){
            if(deque.peekFirst() == null){
                deque.addFirst(s.charAt(i));
            }else{
                if(deque.peekFirst() == s.charAt(i)){
                    deque.addFirst(s.charAt(i));
                }
                else{
                    deque.removeFirst();
                    count++;
                }
            }
        }

        System.out.println(count * 2);
    }
}

Measured memory_bytes: 28092
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);
	static boolean debug = false;

	static void solve() {
		int n = in.nextInt();
		int[] a = new int[n];
		for (int i=0; i<n; i++) {
			a[i] = in.nextInt();
		}

		int ans = -1;
		for (int i=0; i<n; i++) {
			for (int j=i+1; j<n; j++) {
				String s = String.valueOf(a[i]*a[j]);
				boolean f = true;
				for (int k=0; k<s.length()-1; k++) {
					if (s.charAt(k) + 1 != s.charAt(k+1)) f = false;
				}
				if (f) {
					ans = Math.max(ans, a[i]*a[j]);
				}
			}
		}
		out.println(ans);
	}

	public static void main(String[] args) {
		debug = args.length > 0;
		long start = System.nanoTime();

		solve();
		out.flush();

		long end = System.nanoTime();
		dump((end - start) / 1000000 + " ms");
		in.close();
		out.close();
	}

	static void dump(Object... o) { if (debug) System.err.println(Arrays.deepToString(o)); }
}

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

using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define PI 3 .14159265

//typedef tuple <int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

#define siz(x) (int)(x).size()
#define Y second
#define X first
#define IN insert
#define PB push_back
#define P pop_back
#define PU push
#define PO pop
//#define F find
#define ED end()
#define MP(a,b) make_pair( a, b )

#define MOD 1000000007LL
#define INF 1000000000
#define rep(a,i,b) for (ll i = (a); i < (b); ++i)
#define reps(a,i,b) for (ll i = (a); i <= (b); ++i)
#define repd( num, i, ed ) for(ll (i)= (num)-1; (i) >= e38d; --(i))
#define repkt( bg, i, num, kt ) for(ll (i)= (bg); (i) < (num) && (kt); ++(i))
#define repchar( i ) for(char (i)= 48; (i) <= 122; (i)++)   
#define in(n) scanf("%lld", &n)
#define out(n) printf("%lld\n", n)
#define outS(s) printf("%s\n", s)
#define setA(a,n) for(ll i= 0, j= sizeof(a)/sizeof(a[0]); i < j; ++i) a[i]= n;
#define repe(num,i,ed) for(ll (i)= (num); (i) >= ed; --(i))
#define endl "\n"
const int mod =1e9+7;
ll n,W;

void max_(ll &a,ll b)
{
    a=max(a,b);
}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    cin>>n>>W;
    vector<ll> dp(W+1);
    for(int item=0;item<n;++item)
    {
        ll w,val;
        cin>>w>>val;
        for(int i=W-w;i>=0;--i) max_(dp[i+w],dp[i]+val);
    }
    sort(dp.begin(),dp.end());
    cout<<dp.back()<<endl;
    // for(auto x:dp) cout<<x<<" ";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include "stdio.h"
#include <vector>
#include <functional>
#include "math.h"
#include <set>
#include <iomanip>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int H,W,K;
vector<string> a;
vector<vector <int> > ans;
string S;

int main()
{
	cin >> S;

	if(S=="SUN"){
		cout << 7 << endl;
	}
    else if(S=="MON"){
		cout << 6 << endl;
    }
    else if(S=="TUE"){
		cout << 5 << endl;
    }
    else if(S=="WED"){
		cout << 4 << endl;
    }
    else if(S=="THU"){
		cout << 3 << endl;
    }
    else if(S=="FRI"){
		cout << 2 << endl;
    }
    else if(S=="SAT"){
		cout << 1 << endl;
    }


	return 0;

}



Measured memory_bytes: 256
#!ruby -na
a,b,c=$F.map(&:to_i)
exit if[a,b,c]==[-1,-1,-1]
puts a==-1||b==-1??F:a+b>=80??A:a+b>=65??B:a+b>=50??C:a+b>=30?c>=50??C:?D:?F

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

int main(){
  int s, a, b, c;
  cin >> s;
  a = s / 100;
  b = (s - 100 * a) / 10;
  c = (s - 100 * a - 10 * b);
  cout << a + b + c << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;
//nの最大値が1e5の時とかは使える
const int MAX = 510000;


long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理 O(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;
  }
}

// 二項係数計算
long long COM(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;
}


// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
  return modpow(a, mod - 2, mod);
}


int main(){
  COMinit();
  ll n,m;
  cin >> n >> m;
  vector<ll> vec(n+1,0);
  vector<ll> powp(n+1,1);
  vec[0] = 1;
  rep(i,n){
    vec[i+1] = vec[i] * (m-i);
    vec[i+1] %= mod;
  }
  vector<ll> arr(n,1);
  ll ans = vec[n] * vec[n] % mod;
  ll x = vec[n] * vec[n] % mod;
  ll y;
  rep(i,n){
    x = x * inv[m - i] % mod;
    y = x * COM(n,i+1) % mod;
    if(i % 2 == 0){
       ans = (ans - y + mod) % mod;
    }else{
      ans = (ans + y) % mod;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 26948
#include <iostream>
#include <vector>
typedef long long int ll;
using namespace std;

ll p = 1000000007;
ll rui(ll a, ll b){
  std::vector<int> v;
  while(b>0){
    v.push_back((b%2==0?0:1));
    b/=2;
  }
  ll ret = 1;
  for(int i=0;i<v.size();i++){
    if(v[i]==1) ret = (ret * a)%p;
    a = (a * a)%p;
  }
  return ret;
}
ll roll(ll a, ll b, ll c){
  ll ret = 0;
  for(ll i=a;i<=b;i++) ret = (ret + rui(i, c))%p;
  return ret;
}

int main(int argc, char const *argv[]) {
  ll n, c;std::cin >> n >> c;
  std::vector<ll> A(n), B(n);
  for(int i=0;i<n;i++) scanf("%lld", &A[i]);
  for(int i=0;i<n;i++) scanf("%lld", &B[i]);
  vector<vector<ll>> dp(n+1, vector<ll> (c+1, 0)), table(401, vector<ll> (401, 0));
  for(int i=0;i<=400;i++) table[i][0] = 1;
  for(int i=1;i<=400;i++) for(int j=1;j<=400;j++) table[i][j] = (table[i][j-1] * i)%p;
  for(int i=1;i<=400;i++) for(int j=0;j<=400;j++) table[i][j] = (table[i][j] + table[i-1][j])%p;
  //for(int j=0;j<=c;j++) for(int i=1;i<=n;i++) std::cout << i<< " " << j << " " <<  table[i][j] << '\n';
  dp[0][0] = 1;
  for(int i=1;i<=n;i++){
    for(int j=0;j<=c;j++){
      for(int k=0;k<=c-j;k++){
        ll a;
        if(k==0) a = B[i-1] - A[i-1] + 1;
        else a = (table[B[i-1]][k]-(A[i-1]!=1?table[A[i-1]-1][k]:0)+p)%p;
        //std::cout << i << " " << j << " " << k << " "<< a << '\n';
        dp[i][j+k] = (dp[i][j+k] + (dp[i-1][j]*a)%p)%p;
      }
    }
  }


  std::cout << dp[n][c] << '\n';
  return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    void zero(int n){
        for(int i=0;i<n;i++){
            par[i]=i;
        }
        return;
    }
    bool all_same(int n){
        int g=root(0);
        rep2(i,n-1){
            if(root(i)!=g){
                return false;
            }
        }
        return true;
    }
};

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

    UnionFind uf(n);

    vector<pair<int,int>>p(m);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        p[i]=make_pair(a,b);
    }
    int ans=0;

    rep(k,m){
        rep(i,m){
            if(k==i)continue;
            int a=p[i].first;
            int b=p[i].second;
            uf.unite(a,b);
        }
        if(!uf.all_same(n)){
            ans++;
        }
        uf.zero(n);
    }

    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ull n;cin >> n;
  string s;cin >> s;
  map<char,int> m;
  ull ans = 0;

  ull a=0,b=0,c=0;
  for(ull i = 0;i < sz(s) ;i++)
  {
    if(s[i] == 'R') a++;
    else if(s[i] == 'G') b++;
    else c++;
  }

  ans = a * b * c;

  ull dis = 0;
  for(ull i = 0;i < n;i++)
  {
    for(ull j = i + 1;j < n; j++)
    {
      ull k = (j - i) + j;
      if(k >= n) break;
      if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i])
        dis++;
    }
  }

  cout << (ull)(ans - dis) << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main()
{

	int n;
	stack< int > out;

	while( true ) {

		cin >> n;
		if( n == -1 ) break;
		do {
			
			out.push( n % 4 ); n /= 4;

		} while( n );

		while( !out.empty() ) { cout << out.top(); out.pop(); }

		cout << endl;

	}

	return 0;

}

Measured memory_bytes: 1200
#include<stdio.h>
#include<stdlib.h>

int main(){
    const int n_colors = 10000;
    int N;
    int *slimes;
    int i;int change=0;
    
    scanf("%d", &N);
    slimes = (int*)calloc(N, sizeof(int));
    for(i=0;i<N;i++)
        scanf("%d", slimes+i);
    
    for(i=1;i<N;i++){
        if(slimes[i-1]==slimes[i]){
            slimes[i] = (slimes[i] + 1)%n_colors;
            if(slimes[i]==slimes[i+1]){
                slimes[i] += (slimes[i] + 1)%n_colors;
            }
            change += 1;
        }
    }
    printf("%d\n", change);
    return 0;
}

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

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a == b + c || b == c + a || c == a + b)
        printf("Yes\n");
    else
        printf("No\n");
}

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

using namespace std;

const int N = 3005;

string a, b;

int dp[N][N];

int main() {

	cin >> a >> b;
	int n = a.length();
	int m = b.length();

	a = ' ' + a;
	b = ' ' + b;

	for (int i = 1; i <= n; i ++) {
		for (int j = 1; j <= m; j ++) {
			if (a[i] == b[j]) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	int i = n, j = m;
	string ans = "";

	while (i > 0 && j > 0) {
		if (a[i] == b[j]) {
			ans += a[i];
			i --;
			j --;
		}
		else if (dp[i - 1][j] > dp[i][j - 1]) {
			i --;
		}
		else {
			j --;
		}
	}

	reverse(ans.begin(), ans.end());

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 35456
x = int(input())
l1 = tuple(map(int,input().split()))
l2 = tuple(map(int,input().split()))
li =[]
for i in l1:
    li.append(i)
li.sort()
from collections import defaultdict
dd = defaultdict(int)
from itertools import product, permutations,combinations
c = 1
for i in permutations(li,x):
    dd[i] = c
    c += 1
print(abs(dd[l1]-dd[l2]))

Measured memory_bytes: 10736
using System;
class Program
{
  static void Main(string[] args)
  {
    // スペース区切りの整数の入力
    string[] input = Console.ReadLine().Split(' ');
    int _N = int.Parse(input[0]);
    int _A = int.Parse(input[1]);
    int _B = int.Parse(input[2]);
    
    // int d=0;
    // if (_N*_A >_B){

    //   }else{

    //   }
    Console.WriteLine(Math.Min(_N * _A,_B));
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
char a[1009][1009];
int m, n;
int f[3109][1009];
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> m >> n;
    for(int i = 1; i <= m; ++ i)
    {
        for(int j = 1; j <= n; ++ j)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 1; i <= m; ++ i)
    {
        f[i][0] = 0;
    }
    for(int j = 1; j <= n; ++ j)
    {
        f[0][j] = 0;
    }
    for(int i = 1; i <= m; ++ i)
    {
        for(int j = 1; j <= n; ++ j)
        {
            if(i == 1 && j == 1) f[i][j] = 1;
            else
            {
                if(a[i][j] == '.') f[i][j] = ((f[i - 1][j] % mod) + (f[i][j - 1] % mod)) % mod;
                else f[i][j] = 0;
            }
        }
    }
    cout << f[m][n];
}


Measured memory_bytes: 7424
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std ;

int main(){
double r,s,l ;
cin >> r ;

if(r>=0){
s = M_PI*r*r ;
l = 2*M_PI*r ;

printf("%lf %lf", s,l) ;

return 0 ;

}
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t,n,a,b;
	t = 1;
	while(t--) {
	 cin >> n;
	 if(n == 1) {
	  cout << "Hello World" << endl;
     }
	 else {
	  cin >> a >> b;
	  cout << a + b << endl;
     }
	}
	return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
int n,x[100],i,j,q,r=-1;
int main(){
    scanf("%d",&n);
    for(i=0;i<n;i++)scanf("%d",&x[i]);
    for(i=1;i<=100;i++){
        for(q=j=0;j<n;j++)q+=(x[j]-i)*(x[j]-i);
        if(r==-1||r>q)r=q;
    }
    printf("%d",r);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
	cin >> s;
	long long sum = 0;
	for(int i = 0; i < s.size(); i++) {
		for(int j = i + 1; j <= s.size(); j++) {
			int l = max(i - 1, 0), r = max((int)s.size() - j - 1, 0);
			sum += stoll(s.substr(i, j - i)) * (1 << l) * (1 << r);
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    
    public static void main(String... args) {
        Scanner scanner = new Scanner(System.in);
        
        String input = scanner.nextLine();
        
        int target = Integer.parseInt(input);
        StringBuilder builder = new StringBuilder();
        for (int i=1; i <= target; i++) {
            int x = i;
            while (x > 0) {
                if (x % 3 == 0 && x == i){
                    builder.append(" "+i);
                    break;
                } else if (x % 10 == 3) {
                    builder.append(" " + i);
                    break;
                } else {
                    x = x / 10;
                }
            }
        }
        System.out.println(builder.toString());
    }
}


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

ll n;
ll a[1000000];
ll cnt=0;

void insertionSort(ll a[],ll n,ll g){
    for(ll i=g;i<n;i++){
        ll v=a[i];
        ll j=i-g;
        while(j>=0&&a[j]>v){
            a[j+g]=a[j];
            j=j-g;
            cnt++;
        }
        a[j+g]=v;
    }
}

void shellSort(ll a[],ll n){
    cnt=0;
    ll m=(long long)floor(log(2*n+1)/log(3));
    cout<<m<<endl;
    ll G[100]={};
    for(int i=0;i<m;i++){
        G[(m-1)-i]=(pow(3,i+1)-1)/2;
    }
    rep(i,m){
        insertionSort(a,n,G[i]);
        if(i!=m-1){
            cout<<G[i]<<" ";
        }else{
            cout<<G[i]<<endl;
        }
    }
}
        

int main(){
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    shellSort(a,n);
    cout<<cnt<<endl;
    rep(i,n){
        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 11200
#include<cstdio>
int main(){
	char n[5];
	while(~scanf("%s",n))
	{
		if(n[0]=='M'&&n[1]=='O')
		printf("6\n");
		if(n[0]=='T'&&n[1]=='U')
		printf("5\n");
				if(n[0]=='W'&&n[1]=='E')
		printf("4\n");
				if(n[0]=='T'&&n[1]=='H')
		printf("3\n");
				if(n[0]=='F'&&n[1]=='R')
		printf("2\n");
				if(n[0]=='S'&&n[1]=='A')
		printf("1\n");
				if(n[0]=='S'&&n[1]=='U')
		printf("7\n");
	}
}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> R(n);
  for (int i = 0; i < n; i++) cin >> R[i];
  int minp = R[0];
  int maxp = -2000000000;
  for (int i = 1; i < n; i++){
    maxp = max(maxp, R[i] - minp);
    minp = min(minp, R[i]);
  }
  cout << maxp << endl;
  return 0;
}



Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

const int N = 3002;
const int MOD = int(1e9 + 7);
const ll R2 = (MOD + 1) / 2;

ll f[N][N];
int a[N];
int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);

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

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            f[i][j] = a[i] < a[j];
        }
    }

    ll mul = 1;

    for (int i = 0; i < q; ++i) {
        mul = (mul * 2) % MOD;
        int x, y;
        cin >> x >> y;

        for (int j = 1; j <= n; ++j) {
            if (j != x && j != y) {
                f[j][x] = f[j][y] = (f[j][x] + f[j][y]) * R2 % MOD;
                f[x][j] = f[y][j] = (f[x][j] + f[y][j]) * R2 % MOD;
            }
        }

        f[x][y] = f[y][x] = (f[x][y] + f[y][x]) * R2 % MOD;
    }

    ll ans = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j < i; ++j) {
            ans += f[i][j];
        }
    }

    ans %= MOD;

    cout << (ans * mul) % MOD << "\n";
}



Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define ll long long
using namespace std;
int n; ll sg=0;
int main(){
	scanf("%d",&n);
	rep (i,1,n){
		ll a,k; scanf("%lld%lld",&a,&k);
		while (a%k){
			a-=a/k+1;
			a=a/k*k+a%k%(a/k+1);
		}
		sg^=a/k;
	}
	if (sg) puts("Takahashi"); else puts("Aoki");
	return 0;
}

Measured memory_bytes: 384
/// wa ^3^

#pragma GCC optimize("O3")

#include<iostream>
#include<iomanip>
                           
using namespace std;

const int MOD = 1e9 + 7;

const int N = 2e5+10;

int cnt[N], a[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int dp = -1, r = 0;
    for (int x; n--;) {
        cin >> x;
        if (x != dp)
            a[r++] = x;
        dp = x;            
    }
    dp = 1;
    for (int i = 0; i < r; ++i) {
        int x = a[i];
        cnt[x] += dp;
        if (cnt[x] >= MOD)
            cnt[x] -= MOD;
        dp = cnt[x];    
    }
    cout << dp;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>

int main() {
  int N;
  std::cin >> N;
  int flag = 0;
  for (int i=0; i<N+1; i +=4 ) {
    for (int j=0; j+i<N+1; j += 7) {
      if (i+j == N) {
        flag=1;
        break;
      }
    }
    if (flag) {
      break;
    }
  }
  if (flag) {
    std::cout << "Yes" << std::endl;
  }
  else {
    std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
int main()
{
   int S,h,m,s;

   scanf("%d",&S);

   s = S%60;
   S -= s;
   m = (S/60)%60;
   S -= m*60;
   h = S/3600;

   printf("%d:%d:%d\n",h,m,s);

   return 0;
}
   

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<ll, vector<ll>, greater<ll>> PQ_ASK;
const int mod = 1000000007;

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

    map<int, int> count;
    rep(i, n) {
        int a;
        cin >> a;
        count[a]++;
    }

    int sum = 0;
    for (auto e : count) {
        sum += (e.second - 1);
    }
    int ans = count.size();
    if (sum % 2 == 1) {
        ans -= 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4992
#E
n,m,k = list(map(int,input().split()))
fac = [1]*n
finv = [1]*n
inv = [1]*n
MOD = 998244353
for i in range(2,n):
    fac[i] = fac[i-1]*i%MOD
    inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
    finv[i] = finv[i-1]*inv[i]%MOD
def comb(n,k):
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD

ans = 0
for i in range(k+1):
#     print(comb(n-1,i),m*(m-1)**(n-i-1))
    ans += comb(n-1,i)*m*pow(m-1,n-i-1,MOD)%MOD
    ans %= MOD
print(ans)

Measured memory_bytes: 32616
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"unicode/utf8"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var K int
	scanner.Scan()
	K, _ = strconv.Atoi(scanner.Text())
	var S string
	scanner.Scan()
	S = scanner.Text()
	fmt.Println(solve(K, S))
}
func solve(K int, S string) string {
	slen := utf8.RuneCountInString(S)
	if slen <= K {
		return S
	}
	return S[:K] + "..."
}


Measured memory_bytes: 1756
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
 string  s;
      
  cin >> s;
  
int b =0 ,c=0,d=0,e =0;
  
  for(int i=0;i<s.size();i++){
    if(s[i] =='N'){
      b++;
    }
    if(s[i] =='W'){
      c++;
    }
    if(s[i]=='S'){
      d++;
    }
       if(s[i] =='E'){
         e++;
       }
  }
  
  
  if(((b!=0)&&(d!=0)&&(c!=0)&&(e!=0))||((b==0)&&(d==0)&&(c!=0)&&(e!=0))||((b!=0)&&(d!=0)&&(c==0)&&(e==0))){
    cout <<"Yes" << endl;
  }
  
  else {
    cout <<"No" << endl;
  }
}
 


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b;
  int big,small;
  int i=0;
  
  scanf("%d %d",&a,&b);
  
  if(a<=b){
    small = a;
    big = b;
  }else {
    small = b;
  	big = a;
  }
  
  for(i;i<big;i++){
    printf("%d",small);
  }
  
  puts("");
  
  return 0;
} 

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

namespace ConsoleApp
{
    class Program
    {

        static void Main(string[] args)
        {
            var ar = ReadLine().Split().Select(long.Parse).ToArray();

            var n = ar[0];
            var a = ar[1];
            var b = ar[2];
            
            long c = 0;
            var amari = n % (a + b);

            c = a * (long)Math.Floor(1.0 * n / (a + b));
            c += (amari <= a ? amari : a);

            WriteLine(c);

        }



    }

}


Measured memory_bytes: 13396
N,M,X = map(int,input().split())
array = [ list(map(int,input().split())) for _ in range(N) ]
ans = 10**18
for i in range ( 2**N ):
  price = 0
  skill = [0]*M
  count = 0
  for k in range(N):
    if ( i >> k ) & 1:
      price += array[k][0]
      for j in range (M):
        skill[j] += array[k][j+1]
  for t in range(M):
    if skill[t] < X:
      break
    else:
      count += 1
    if count == M:
      ans = min(price,ans)
      
print( -1 if ans == 10**18 else ans)

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

int main() {
    int n;
    string s;
    cin >> s;
    n = s.size();
    vector<int> ans(n);
    rep(ri,2){
        {
            int cnt = 0;
            rep(i,n){
                if(s[i] == 'R'){
                    cnt++;
                }else{
                    ans[i] += cnt/2;
                    ans[i-1] += (cnt+1)/2;
                    cnt = 0;
                }
            }
        }

        reverse(s.begin(),s.end());
        reverse(ans.begin(),ans.end());
        rep(i,n){
            if(s[i] == 'L') s[i] = 'R';
            else s[i] = 'L';
        }
    }
    rep(i,n){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 1024
arr = Array.new(5)
5.times do |i|
	arr[i] = gets.chomp.to_i
end

min = 10
arr.each do |a|
	ngo = a.to_s[-1].to_i 
	min = ngo if min > ngo && ngo != 0
end

cnt = 0
arr.each do |a|
	cnt += (a / 10.0).ceil * 10
end
cnt -= (10 - min) if min != 10
puts cnt




Measured memory_bytes: 14360
//ヘッダー
#include<bits/stdc++.h>
using namespace std;

//型定義
typedef long long ll;

//定数
const ll INF=1e+18;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

//省略
using vi  = vector<int>;
using vii = vector<vector<int>>;
using vl  = vector<ll>;
using vll = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

// UnionFind
struct UnionFind {
    vector< int > data;
    
    UnionFind(int sz) {
        data.assign(sz, -1);
    }
 
    bool unite(int x, int y) {//要素xとyの各々の木を併合（もともと同じ木ならfalse）
        x = find(x), y = find(y);
        if(x == y) return (false);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }
    
    int find(int k) {//要素kが属する木の根を得る
        if(data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }
    
    int size(int k) {//要素kが属する木の要素数
        return (-data[find(k)]);
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = find(x);
        int ry = find(y);
        return rx == ry;
    }

};

int main(){
    int N,Q;
    cin>>N>>Q;
    UnionFind tree(N);
    REP(i,Q){
        int t,u,v;
        cin>>t>>u>>v;
        if(t==0){
            tree.unite(u,v);
        }else{
            if(tree.same(u,v)){
                cout<<"1"<<endl;
            }else{
                cout<<"0"<<endl;
            }
        }
    }
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long x,k,d,cnt,ans;
  cin >> x >> k >> d;
  if(x < 0) x = -x;
  cnt = x / d;
  if(k > cnt){
    ans = abs(x - cnt * d - ((k-cnt) % 2) * d);
  }else{
    ans = x - k * d;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long LL;
const int N = 2e5 + 50;
const int mod = 1e9 + 7;
const int I2 = (mod + 1) / 2;

int n;
pair <int, int> a[N];

inline LL Pow(LL x, LL exp) {
  LL res = 1;
  for (; exp; exp >>= 1, x = x * x % mod)
    if (exp & 1) res = res * x % mod;
  return res;
}

LL tag[N << 2], sum[N << 2], mono[N << 2];

inline void tagdown(int x) {
  if (tag[x] != 1) {
    (tag[x << 1] *= tag[x]) %= mod;
    (sum[x << 1] *= tag[x]) %= mod;
    (tag[x << 1 | 1] *= tag[x]) %= mod;
    (sum[x << 1 | 1] *= tag[x]) %= mod;
    tag[x] = 1;
  }
}

#define mid ((L + R) >> 1)

inline void Set(int p, int v, int x = 1, int L = 1, int R = n) {
  if (L == R) {
    mono[x] = 1; sum[x] = v; return;
  }
  tagdown(x);
  if (p <= mid) Set(p, v, x << 1, L, mid);
  else Set(p, v, x << 1 | 1, mid + 1, R);
  sum[x] = sum[x << 1] + sum[x << 1 | 1];
  sum[x] >= mod ? sum[x] -= mod : 0;
  mono[x] ++;
}

inline void Add(pair <LL, int> &a, pair <LL, int> b) {
  a.first += b.first; a.second += b.second;
}

inline pair <LL, int> Sum(int l, int r, int x = 1, int L = 1, int R = n) {
  if (l <= L && R <= r) return make_pair(sum[x], mono[x]);
  tagdown(x);
  pair <LL, int> res;
  if (l <= mid) res = Sum(l, r, x << 1, L, mid);
  if (r > mid) Add(res, Sum(l, r, x << 1 | 1, mid + 1, R));
  return res;
}

inline void Mul(LL val) {
  tag[1] = tag[1] * val % mod;
  sum[1] = sum[1] * val % mod;
}

LL pre[N];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i ++) {
    scanf("%d", &a[i].first); a[i].second = i;
  }
  sort(a + 1, a + n + 1);
  LL ans = 0;
  for (int i = pre[0] = 1; i <= n; i ++)
    pre[i] = pre[i - 1] * (a[i].first - i + 1) % mod;
  if (!pre[n]) {
    puts("0"); return 0;
  }
  for (int i = 0; i < (N << 2); i ++) tag[i] = 1;
  LL suf = 1;
  for (int i = n; i; i --) {
    pair <LL, int> tmp = Sum(a[i].second, n);
    tmp.first %= mod;
    LL fix = (a[i].first - i) * pre[i] % mod * I2 % mod;
    ans += tmp.first * fix % mod;
    ans -= (sum[1] - tmp.first) * fix % mod;
    ans += (mono[1] - tmp.second) * pre[n] % mod;
    Mul(a[i].first - i);
    Set(a[i].second, suf);
    suf = suf * (a[i].first - i + 1) % mod;
  }
  ans = (ans % mod + mod) % mod;
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 22144
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

double median(vector<int> v) {
  int N = v.size();
  sort(v.begin(), v.end());
  if (N % 2 == 0) {
    double v1 = v[N/2 - 1];
    double v2 = v[N/2];
    return (v1 + v2) / 2;
  } else {
    return v[N/2];
  }
}

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i] >> B[i];
  }

  if (N % 2 == 0) {
    cout << static_cast<int>((median(B)-median(A))*2) + 1 << endl;
  } else {
    cout << static_cast<int>((median(B)-median(A))) + 1 << endl;
  }
}


Measured memory_bytes: 6432
N = int(input())
S = input()
d = {}
MOD = 10 ** 9 + 7
for key in S:
    if key in d:
        d[key] += 1 
    else:
        d[key] = 1 
ans = 1
for v in d.values():
    ans *= v+1
    ans %= MOD
print(ans - 1)

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

using namespace std;

struct w_unionfind {
    using diff_from = pair<int, int>;
    using result = pair<int, bool>;
    
    vector<diff_from> uf;
    
    w_unionfind(int n) : uf(n) {
        for(int i=0; i<n; i++) uf[i] = diff_from(i, 0);
    }
    
    int root(int i) {
        if(uf[i].first==i) return i;
        int r = root(uf[i].first);
        uf[i] = diff_from(r, uf[i].second + uf[uf[i].first].second);
        return r;
    }
    
    void relate(int i, int j, int d) {
        int ri = root(i);
        int rj = root(j);
        if(ri != rj) {
            uf[rj] = diff_from(ri, uf[i].second + d - uf[j].second);
        }
    }

    result diff(int i, int j) {
        int ri = root(i);
        int rj = root(j);
        if(ri != rj) return result(0, false);
        return result(uf[j].second - uf[i].second, true);
    }
    
};

int main() {
    int n, q;
    cin >> n >> q;
    w_unionfind uf(n);
    while(q--) {
        int c;
        cin >> c;
        if(c) {
            int x, y;
            cin >> x >> y;
            auto&& r = uf.diff(x, y);
            if(r.second) cout << r.first << endl;
            else cout << "?" << endl;
        } else {
            int x, y, z;
            cin >> x >> y >> z;
            uf.relate(x, y, z);
        }
    }
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	ll N;
	cin>>N;
	vector<ll> A;
	for (ll i = 1; i*i<= N; ++i){
		if(N%i == 0){
			A.push_back(i);
			A.push_back(N/i);
		}
	}
	ll len = A.size();
	sort(all(A));
	print(A);
	ll ans= 0;
	for (int i = 0; i < len; ++i){
		ll M = A[i]-1;
		if(M!=0&&N%M!=0&&N%M == N/M){
				ans+=M;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;

#define LEN(x) (int)x.size()
#define ALL(x) x.begin(), x.end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
using vpii = vector<pii>;

template<typename T, typename M = __gnu_pbds::null_type>
using ordered_set = __gnu_pbds::tree<T, M, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

template<typename T>
const T INF = (is_same<T, int>::value ? 1e9 : 1e18);
const int MOD = 1e9 + 7;
const double EPS = 1e-9;

inline int fcmp(double x, double y)
{ return (x < y + EPS ? (x < y - EPS ? -1 : 0) : 1);}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n; cin >> n;
    ll ans = 0;
    for(int i = 1; i < n; i++)
        ans += (n - 1) / i;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif


string get_half(string& str, int k) {
    int offset = 0;
    int pos = 0;
    for(int i = 0; i < str.length(); i++) {
        offset += (str[i] != 'x');
        if(k == offset) {
            pos = i;
            break;
        }
    }
    return str.substr(0, pos+1);
}


int main(void) {
    string str;
    string str_x;
    cin >> str;
    int len = str.length();
    int sum = 0;
    for(int i = 0; i < len; i++) {
        if(str[i] != 'x') {
            sum++;
            str_x.push_back(str[i]);
        }
    }
    if(str_x.size() == 0) {
        cout << 0 << endl;
        return 0;
    }

    for(int i = 0; i < str_x.length(); i++) {
        if(str_x[i] != str_x[str_x.length()-1-i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    debug("%d\n", sum);
    vector<string> half(2);
    half[0] = get_half(str, (sum+1)/2);
    reverse(str.begin(), str.end());
    half[1] = get_half(str, (sum+1)/2);
    debug("%s vs %s\n", half[0].c_str(), half[1].c_str());

    vector<int> map(len+1);
    for(int k = 0; k < 2; k++) {
        int res = 0;
        for(int i = 0, idx = 0; i < half[k].length(); i++) {
            if(half[k][i] != 'x') {
                map[idx] = max(map[idx], res);
                idx++;
                res = 0;
            } else {
                res++;
            }
        }
    }

    int x_sum = 0;
    ps(map);
    for(int i = 0; i <= len; i++) {
        x_sum += map[i];
    }

    int ans_len = (str_x.length()+1)/2 + x_sum;
    debug("result length: %d\n", ans_len);
    cout << (ans_len - half[0].length()) + (ans_len - half[1].length()) << endl;
    return 0;
}

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++){
        if(s[i] == ',') cout << " ";
        else cout << s[i];
    }    
}

Measured memory_bytes: 256
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    mod=10**9+7
    n,m=map(int,readline().split())
    a=[int(readline()) for _ in range(m)]
    flags=[True]*(n+1)
    for i in a:
        flags[i]=False

    dp=[0]*(n+1)
    dp[0]=1
    for i in range(1,n+1):
        if flags[i]==False:
            continue
        elif i==1:
            dp[i]+=dp[i-1]
        else:
            dp[i]+=dp[i-1]+dp[i-2]
        dp[i]%=mod

    print(dp[-1])
        
if __name__=="__main__":
    main()

Measured memory_bytes: 8616
using System;

namespace AtCoderConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            // 標準入力から1行取得
            string input = Console.ReadLine();

            // 4つの変数を宣言
            int a, b, c, d;

            // 代入
            a = int.Parse(input.Split(' ')[0]);
            b = int.Parse(input.Split(' ')[1]);
            c = int.Parse(input.Split(' ')[2]);
            d = int.Parse(input.Split(' ')[3]);

            int count = 0;
            for(int i = 1; i <= 100; i++)
            {
                if (a <= c)
                {
                    if (i >= a && i <= b && i > c && i <= d)
                    {
                        count++;
                    }
                }
                else
                {
                    if (i > a && i <= b && i >= c && i <= d)
                    {
                        count++;
                    }
                }
            }

            // 標準出力に出力
            Console.WriteLine(count);
        }
    }
}


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

int main() {
    int x, y, z;
    cin >> x >> y >> z;

    int num = x / (y + z);
    int space = num * (y + z);

    if (space + z <= x) {
        cout << num << endl;
    } else {
        cout << num - 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
program main
  implicit none

  integer :: a, b, c, d ,e, k, l

  
  read(*,*) a, b, c, d, e, k

  l = e-a

  if(l <= k) then
     write(*,*) 'Yay!'
  else
     write(*,*) ':('

  end if
end program main



Measured memory_bytes: 2860
#include<bits/stdc++.h>
#define ll long long
#define N 200010
#define INF 1e9
using namespace std;
template <typename T> void read(T &x){
	x=0;char c=getchar();int fh=1;
	while (!isdigit(c)){if (c=='-')fh=-1;c=getchar();}
	while (isdigit(c))x=x*10+c-'0',c=getchar();
	x*=fh;
}
ll n,d,a[N],ansn,f[N],nv;
struct Info{int x,y;ll di;}v[N*50];
bool comp(Info x,Info y){return x.di<y.di;}
int que(int x){if (f[x]!=x) f[x]=que(f[x]);return f[x];}
void work(int l,int r){
	if (l>=r) return ;
	int mid=(l+r)/2,nm=l;
	work(l,mid);work(mid+1,r);
	for (int i=l;i<=mid;i++)if (a[i]-i*d<a[nm]-nm*d)nm=i;
	for (int i=mid+1;i<=r;i++){v[++nv].x=nm;v[nv].y=i;}
	nm=r;
	for (int i=mid+1;i<=r;i++)if (a[i]+i*d<a[nm]+nm*d)nm=i;
	for (int i=l;i<=mid;i++){v[++nv].x=nm;v[nv].y=i;}
}
int main(){
	read(n);read(d);
	for (int i=1;i<=n;i++)read(a[i]);
	work(1,n);
	for (int i=1;i<=nv;i++) v[i].di=a[v[i].x]+a[v[i].y]+d*(abs(v[i].x-v[i].y));
	sort(v+1,v+nv+1,comp);
	for (int i=1;i<=n;i++)f[i]=i;
	for (int i=1;i<=nv;i++){
		int nx=que(v[i].x),ny=que(v[i].y);
		if (nx!=ny){f[nx]=ny;ansn+=v[i].di;}
	}
	cout<<ansn<<endl;
	return 0;
}

Measured memory_bytes: 59776
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
int main()
{
    int X, t;
    cin >> X >> t;
    cout << max(0, X - t) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <queue>
using namespace std;

vector<int> g[100003];
int memo[4][100003];

struct E{
	int p,c;
};

int main() {
	// your code goes here
	int n,m;
	cin>>n>>m;
	memset(memo,0,sizeof(memo));
	for(int i=0;i<m;i++){
		int u,r;
		cin>>u>>r;
		g[u].push_back(r);
	}
	int s,t;
	cin>>s>>t;
	
	

	int ans=-1;
	queue<E> qu;
	E e1;
	e1.p=s;
	e1.c=0;
	qu.push(e1);
	
	while (qu.empty()==false){
		E e1=qu.front();
		qu.pop();
		//cout<<"\n"<<e1.p<<" "<<e1.c<<")";
		if(e1.c%3==0&&e1.p==t){
			ans=e1.c/3;
			break;
		}
		
		if(memo[e1.c%3][e1.p]!=0){
			continue;
		}
		
		memo[e1.c%3][e1.p]=1;
		
		for(int i=0;i<g[e1.p].size();i++){
			E e2;
			e2.p=g[e1.p][i];
			e2.c=e1.c+1;
			qu.push(e2);
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

    string in , comparing;
    cin>>in>>comparing;
    in+=in;
    if (in==comparing)
        cout<<"Yes";
    else
    {
        size_t found = in.find(comparing);
        if (found == -1)
            cout<<"No";
        else
            cout<<"Yes";
    }

}



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

using namespace std;
int main() {
  string S;
  cin >> S;

  int a, b;
  a = atoi(S.substr(0, 2).c_str());
  b = atoi(S.substr(2, 2).c_str());

  bool hantei_YYMM;
  bool hantei_MMYY;
  hantei_YYMM = false;
  hantei_MMYY = false;
  if (b >= 1 && b <= 12) {
    hantei_YYMM = true;
  }
  if (a >= 1 && a <= 12) {
    hantei_MMYY = true;
  }

  if (hantei_YYMM == true && hantei_MMYY == true) {
    cout << "AMBIGUOUS" << endl;
  } else if (hantei_YYMM == false && hantei_MMYY == false) {
    cout << "NA" << endl;
  } else if (hantei_YYMM == true) {
    cout << "YYMM" << endl;
  } else {
    cout << "MMYY" << endl;
  }

  return 0;
}


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

int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int sum;
  
  if(k>a){
    sum=a;
    k-=a;
  }else{
    sum=k;
    cout << sum << endl;
    return 0;
  }
  k-=b;
  if(k<0){
    cout << sum << endl;
    return 0;
  }else{
    sum-=k;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 3588
H,W,A,B = map(int,input().split())

s = [[] for j in range(H)]

for row in range(H):
    if row <= B-1:
        s[row] += [0]*A + [1]*(W-A)
    else:
        s[row] += [1]*A + [0]*(W-A)

    res = ''.join(map(str,s[row]))
    print(res)


Measured memory_bytes: 12916
from collections import deque

mod = 10**9+7

h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

cnt = [[0]*w for _ in range(h)]
cnt[0][0] = 1

D = deque()
D.append((0, 0))

dxdy = [(0, 1), (1, 0)]

appended =  [[False]*w for _ in range(h)]
appended[0][0] = True
while D:
  p = D.popleft()
  if p == (h-1, w-1):
    break
  for k in range(2):
    nx = p[0] + dxdy[k][0]
    ny = p[1] + dxdy[k][1]
    if 0<=nx<h and 0<=ny<w and maze[nx][ny]==".":
      cnt[nx][ny] += cnt[p[0]][p[1]]
      cnt[nx][ny] %= mod
      if appended[nx][ny]==False:
        D.append((nx, ny))
        appended[nx][ny] = True

print(cnt[h-1][w-1])

Measured memory_bytes: 137236
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

int ary[105];
int main() {
    int a;
    while(cin>>a) {
        ary[a]++;
    }
    int maxi = *max_element(ary,ary+105);
    rep(i,105) {
        if(maxi==ary[i]) {
            cout<<i<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
long double distance(long x,long y)
{
	long double ans=sqrt(x*x+y*y);
	return ans;
}
void solve()
{
	int count=0;
	long n,d;
	cin>>n>>d;
	for(int i=0;i<n;i++)
	{
		long x,y; cin>>x>>y;
		if(distance(x,y)<=d)
			count++;
	}
	cout<<count<<endl;
}
int main()
{
	solve();
}

Measured memory_bytes: 3640