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

int main() {

char ch;    
  while(1) {
    scanf("%c", &ch); 
    if ('a' <= ch && ch <= 'z') {
      ch = ch - 32;
    } else if ('A' <= ch && ch <= 'Z') {
      ch = ch + 32;
    }
    printf("%c", ch);
    if ( ch == '\n') break;
  }

return 0;
}



Measured memory_bytes: 3152
from collections import Counter
H, W = map(int,input().split())
C = []
V = 10
for _ in range(V):
    C.append(list(map(int,input().split())))
for k in range(V):
    for i in range(V):
        for j in range(V):
            C[i][j] = min(C[i][j], C[i][k] + C[k][j])
A = []
for _ in range(H):
    A += list(map(int,input().split()))
count = Counter(A)
ans = 0
for i in range(V):
    ans += count[i] * C[i][1]
print(ans)

Measured memory_bytes: 3828
n = int(input())
XY = []
ans = 0

for i in range(n):
    z = []
    
    for j in range(int(input())):
        x,y = map(int,input().split())
        z.append([x,y])
        
    XY.append(z)
        
for i in range(2**n):
    honest = 0
    mujunn = 0
    
    for j in range(n):
        if (i>>j) & 1:
            honest += 1
            
            for k in XY[j]:
                x = k[0] - 1
                y = k[1]
                
                if (i>>x)&1 != y:
                    mujunn = 1
                
    if mujunn == 0:
        ans = max(ans,honest)
        
print(ans)

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

using namespace std;

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

  int a, b;
  cin >> a >> b;
  int n = 1;
  int ans = -1;
  while (n <= 1000)
  {
    if (floor(n * 0.08) == a && floor(n * 0.1) == b)
    {
      ans = n;
      break;
    }
    n++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
#define mod 1000000007
using ll = long long;
using namespace std; 

int main(){
    ll n,d; cin >> n >> d;
    ll ans=0;
    for (ll i=0;i<n;i++){
        ll x,y; cin >> x >> y;
        ll s=x*x+y*y;
        if (sqrt(s)<=d) ans++;
    }
    cout << ans << "\n";
    
}



Measured memory_bytes: 3684
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
    map<long long int,long long int> x;
    long long int ans=0,n,a[200010],i;
    scanf("%lld\n",&n);
    for(i=0;i<n;i++){
        scanf("%lld ",&a[i]);
        a[i]=a[i]+i;
        x[a[i]]++;
    }
    for(i=0;i<n;i++){
        ans+=x[i*2-a[i]];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 28036
MOD = 10**9 + 7
N,M,K= map(int,input().split())

MOD = 10**9 + 7
num = 2000020
fact = [1] * (num+1)
ifact = [1] * (num+1)

for i in range(1,num+1):
    fact[i] = (fact[i-1] * i) % MOD
ifact[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(1,num+1)[::-1]:
    ifact[i-1] = (ifact[i] * i)% MOD

memo = {}
def nCr2(n,r):
    if (n,r) in memo:
        return memo[(n,r)]
    else:
        memo[(n,r)] = (fact[n] * ifact[r] * ifact[n-r]) % MOD
        return memo[(n,r)]

def nCr(n,r):
    if r > n:
        return 0
    return (fact[n] * ifact[r] * ifact[n-r]) % MOD

ans = 0
ans1 = 0
ans2 = 0

for j in range(2,K+1):
    ans1 += M**2 * nCr(2*(M-1),j-2)* nCr((N-2)*M, K-j) 
    ans1 %= MOD
ans1 *= sum((i*(N-i) for i in range(1,N)))

for j in range(2,K+1):
    ans2 += N**2 * nCr(2*(N-1),j-2) * nCr((M-2)*N, K-j)
    ans2 %= MOD
ans2 *= sum((i*(M-i) for i in range(1,M)))

ans = (ans1 + ans2) % MOD
'''

for i in range(1,N):
    print(i)
    for j in range(2,K+1):
        for k in range(1,j):
            ans += i * (N-i) *k*(j-k)*nCr(M,k) * nCr(M,j-k)* nCr((N-2)*M, K-j) 
            ans %= MOD

for i in range(1,M):
    print(i)
    for j in range(2,min(K,2*N)+1):
        for k in range(1,j):
            ans += i * (M-i) * k* (j-k) * nCr(N,k) * nCr(N,j-k) * nCr((M-2)*N, K-j)
            ans %= MOD
'''

print(ans)


Measured memory_bytes: 112640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		for(int i = 0; i < n; i++) {
			Ground ground = new Ground();
			int out = 0;
			String s;
			
			while(out < 3) {
				s = scanner.nextLine();
				if (s.equals("OUT")) {
					out++;
				} else if (s.equals("HIT")) {
					ground.hit();
				} else if (s.equals("HOMERUN")) {
					ground.homerun();
				}
			}
			System.out.println(ground.getScore());
		}
	}

	private static class Ground {
		boolean isFirst;
		boolean isSecond;
		boolean isThird;
		int score;
		int runners;
		
		private void countRunners() {
			runners = 0;
			if (isFirst) {runners++;}
			if (isSecond) {runners++;}
			if (isThird) {runners++;}
		}

		public void clearRunners() {
			isFirst = false;
			isSecond = false;
			isThird = false;
			runners = 0;
		}

		public int getScore() {
			return score;
		}
		public void hit() {
			if (!isFirst) {
				isFirst = true;
			} else {
				if (!isSecond) {
					isSecond = true;
				} else {
					if (!isThird) {
						isThird = true;
					} else {
						score++;
					}
				}
			}
			countRunners();
		}
		
		public void homerun() {
			score += runners + 1;
			clearRunners();
		}
	}
}

Measured memory_bytes: 17328
n = int(input())
A = list(map(int, input().split()))
q = int(input())
mi = map(int, input().split())
t = {}

def solve(i, m):
    if (m == 0):
        return True
    if (i >= n):
        return False
    if (i,m) in t:
        return t[(i,m)]
    res = solve(i + 1, m) or solve(i + 1, m - A[i])
    t[(i,m)] = res
    return res

for m in mi:
    if solve(0, m):
        print("yes")
    else:
        print("no")

Measured memory_bytes: 11932
import sys
N,M=map(int,input().split())
A=list(set(map(int,input().split())))
N=len(A)
A=[a//2 for a in A]

def f(x):
    cnt=0
    while x%2==0:
        x//=2
        cnt+=1
    return cnt
C=f(A[0])
for a in A:
    if f(a)!=C:
        print(0)
        sys.exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x
LCM=A[0]
for i in range(1,N):
    LCM=lcm(LCM,A[i])
if LCM>M:
    ans=0
else:
    M//=LCM
    ans=(M+1)//2
print(ans)

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

/*
提出前に確認!
- setとmultisetを間違えない
*/

int gcd(int x, int y)
{
	if (y == 0) return (x);
	return (gcd(y, x % y));
}

int	main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	//とりあえず先にsetwise判定
	int res = 0;
	for (int i = 0; i < n; i++) res = gcd(res, a[i]);
	bool is_setwise = (res == 1);
	//素数を全部求める
	vector<bool> is_prime(1e6 + 1, true);
	is_prime[0] = false; is_prime[1] = false;
	vector<int> prime_list;
	for (int i = 2; i * i <= 1e6; i++)
	{
		if (is_prime[i])
		{
			prime_list.push_back(i);
			for (int j = 2; (long long)j * i <= 1e6; j++) is_prime[j * i] = false;
		}
	}
	//78498
	map<int, bool> used_prime;
	//pairwise判定
	bool is_pairwise = true;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < prime_list.size(); j++)
		{
			if (a[i] == 1) break ;
			if (a[i] % prime_list[j] == 0)
			{
				if (used_prime[prime_list[j]] == true) is_pairwise = false;
				used_prime[prime_list[j]] = true;
				while (a[i] % prime_list[j] == 0) a[i] /= prime_list[j];
			}
		}	
		if (a[i] != 1)
		{
			if (used_prime[a[i]] == true) is_pairwise = false;
			used_prime[a[i]] = true;
		}
	}
	if (is_pairwise) cout << "pairwise coprime" << endl;
	else
	{
		if (is_setwise == true) cout << "setwise coprime" << endl;
		else cout << "not coprime" << endl;
	}
	return (0);
}


Measured memory_bytes: 10832
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
//const long long mod = 1000000007;
//const long long mod = 998244353;

int main() {
	long long N;
	scanf("%lld", &N);
	long long res = N * (N - 1) / 2;
	printf("%lld", res);
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<LL> vl;
typedef vector<vector<LL>> vvl;
typedef vector<vector<vector<LL>>> vvvl;


const int inf = 1e9+7;
const LL INF = 1e18+5;
const int mod = 1e9+7;
const int mxN = 1e5+5;
const int mxM = 1e5+5;

int main(){
    #ifndef ONLINE_JUDGE
    freopen("E:\\Coding\\Programming\\input.txt", "r", stdin);
    freopen("E:\\Coding\\Programming\\output.txt", "w", stdout);
    #endif
    int x;
    cin>>x;
    cout<<(!x)<<endl;
}

Measured memory_bytes: 3580
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1)/ (y))
#define MOD 1000000007ULL

u64 N, K;
u64 conb[2001][2001];

void init();

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

    cin >> N >> K;

    init();

    for (int i = 1; i <= K; ++i)
    {
        if (N >= K + i - 1)
        {
            cout << ((conb[N - K + 1][i] * conb[K - 1][K - i]) % MOD) << "\n";
        }
        else
        {
            cout << "0\n";
        }
    }

    return 0;
}

void init()
{
    rep (i, 2001)
    {
        rep (j, 2001)
        {
            if (i == 0 || j == 0 || i == j)
            {
                conb[i][j] = 1;
            }
            else if (i < j)
            {
                conb[i][j] = 0;
            }
            else
            {
                conb[i][j] = ((conb[i - 1][j - 1] % MOD) + (conb[i - 1][j] % MOD) % MOD);
            }
        }
    }
}



Measured memory_bytes: 31616
#include<bits/stdc++.h>
#define MAX 400
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int m,a,b;
  int p[MAX];
 
  while(1){
    cin>>m>>a>>b;
    if(m+a+b==0)break;
    FOR(i,0,m)cin>>p[i];
    sort(p,p+m);
    reverse(p,p+m);
 
    int ans=0,tmp=0;
    FOR(i,a,b+1){
      if(tmp<=p[i-1]-p[i]){
        ans=i;
        tmp=p[i-1]-p[i];
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3140
/* C program for Merge Sort */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
long long dp[100][100000];
long long int v[100];
int w[100];
int n;
long long int mod=1000000007;
long long int max_q(int i,int weight){
    if(i>=n){
        return 0;
    }
    if(weight==0){
        return 0;
    }
    if(dp[i][weight]!=-1){
        return dp[i][weight] ;
    }
    if(w[i]<=weight ){
        dp[i][weight]=max(v[i]+max_q(i+1,weight-w[i]),max_q(i+1,weight));
        return dp[i][weight];
    }
    else dp[i][weight]=max_q(i+1,weight);
    
    return dp[i][weight];
}
int main() 
{ 
    int weight;
    cin>>n>>weight;
    //cout<<weight;
    for(int i=0;i<100;i++){
        for(int j=0;j<100000;j++){
            dp[i][j]=-1;
            }
    }
    for(int i =0;i<n; i++){
        cin>>w[i]>>v[i];
    }
    cout<<max_q(0,weight)<<endl;

	return 0; 
} 


Measured memory_bytes: 78336
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    x,n = LI()
    if x < n:
        print(0)
    else:
        print(10)
    return

#B
def B():
    n,x = LI()
    l = LI()
    d = 0
    ans = 1
    for i in range(n):
        d += l[i]
        if d <= x:
            ans += 1
    print(ans)
    return

#C
def C():
    w,h,x,y = LI()
    ans = w*h/2
    k = 0
    if x == w/2 and y == h/2:
        k = 1
    print(ans,k)
    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 38640
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;

template <typename T> inline void read(T &x) {
    int c = getchar();
    bool fg = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            fg = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (fg) {
        x = -x;
    }
}
const int MAXN = 550;
const int INF = 0x3f3f3f3f;

int f[MAXN][MAXN], n, m, q;

signed main() {
	read(n), read(m), read(q);
	for(int i = 1; i <= m; i++) {
		int l, r;
		read(l), read(r);
		f[l][r]++;
		f[r][l]++;
	}
	for(int i = 1; i <= n; i++) {
		for(int j = 1; j <= n; j++) {
			f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1] + f[i][j];
		}
	}
	while(q--) {
		int l, r;
		read(l), read(r);
		int ans = f[r][r] - f[r][l - 1] - f[l - 1][r] + f[l - 1][l - 1];
		printf("%d\n", ans >> 1);
	}
	return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	long long int a[n];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	long long sum=0;
	for(int i=1;i<n;i++){
		if(a[i]<a[i-1]){
			sum=sum+(a[i-1]-a[i]);
			a[i]=a[i-1];
		}
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 5160
from collections import defaultdict

dic = defaultdict(list)
n, m = map(int, (input()).split())

for i in range(1, m+1):
    k, *to_swi = map(int, input().split())
    if k == 1:
        list(to_swi)
    for swi in to_swi:
        dic[swi].append(i)

P = [0] + list(map(int, input().split()))
count = 0
for i in range(2**n):
    rights = [0] * (m + 1)
    for j in range(n):
        if (i >> j) & 1:
            for right in dic[j+1]:
                rights[right] += 1
                rights[right] %= 2

    if rights == P:
        count += 1

print(count)


Measured memory_bytes: 3444
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n; cin>>n; 
    vi a(n+1);
    for (int i=1;i<=n;i++) cin >> a[i] ; 
    int ans=0;
    for (int i=1;i<=n;i++){
        if (i!=n){
            ans += a[i]/2;
            a[i] %= 2;
            ans += min(a[i],a[i+1]);
            a[i+1] -= min(a[i],a[i+1]);
        }
        else  ans += a[i]/2;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=999999999;
bool func(int x){
   int keta=0;
   while(x>0){
      keta++;
      x/=10;
   }
   return keta%2==1;
}


int main() {
   int N;
   cin>>N;
   int ans=0;
   for(int i=1;i<=N;i++){
      if(func(i)){ans++;}
   }
   cout<<ans<<endl;
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, M, Q, p[510][510];
	memset(p, 0, sizeof(p));
	cin >> N >> M >> Q;
	rep(i, 0, M) {
		int L, R;
		cin >> L >> R;
		p[L][R]++;
	}

	rep(i, 1, N + 1) {
		rep(j, 1, N + 1) {
			p[i][j] += p[i][j - 1];
		}
	}

	rep(i, 1, N + 1) {
		rep(j, 1, N + 1) {
			p[i][j] += p[i - 1][j];
		}
	}

	rep(i, 0, Q) {
		int L, R;
		cin >> L >> R;
		cout << p[R][R] + p[L - 1][L - 1] - p[L - 1][R] - p[R][L - 1] << endl;
	}
}


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

using namespace std;

int main() {

    int s; cin >> s;
    set<int> se;

    se.insert(s);

    for (int i = 2; i < 1000000; ++i) {
        if (s % 2 == 0) {
            s = s / 2;
        } else {
            s = 3 * s + 1;
        }

        if (se.count(s) == 1) {
            cout << i << endl;
            return 0;
        }

        se.insert(s);
    }
}


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


int main() {
  string s;
  cin >> s;
  int n;
  n = s.size();
  if(s[n-1] == 's'){
    cout << s << "es";
  }
  else{
    cout << s << "s";
  }
  return 0;
}




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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int L=a+b;
  int R=c+d;
  if(L > R){
    cout << "Left" << endl;
  }
  else if(L < R){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
import math

 
def koch_curve(i, n, x1, y1, x2, y2):
    x = [0]*5
    y = [0]*5
    if i < n:
        x[0] = x1
        y[0] = y1
        x[1] = (2*x1+x2)/3.0
        y[1] = (2*y1+y2)/3.0
        x[2] = (x1+2*x2)/3.0
        y[2] = (y1+2*y2)/3.0
        x[3] = (x[2] - x[1])*math.cos(math.pi/3) - (y[2] - y[1])*math.sin(math.pi/3) + x[1]
        y[3] = (y[2] - y[1])*math.cos(math.pi/3) + (x[2] - x[1])*math.sin(math.pi/3) + y[1]
        x[4] = x2
        y[4] = y2
        koch_curve(i+1, n, x[0], y[0], x[1], y[1])
        print x[1], y[1]
        koch_curve(i+1, n, x[1], y[1], x[3], y[3])
        print x[3], y[3]
        koch_curve(i+1, n, x[3], y[3], x[2], y[2])
        print x[2], y[2]
        koch_curve(i+1, n, x[2], y[2], x[4], y[4])
        
n = int(input())
 
x1 = 0
y1 = 0
x2 = 100
y2 = 0 
print x1, y1
koch_curve(0, n, x1, y1, x2, y2)
print x2, y2
 

Measured memory_bytes: 6664
s = input()
a = int(s[:2])
b = int(s[2:])
yymm = True
mmyy = True
if a < 1 or a > 12:
    mmyy = False
if b < 1 or b > 12:
    yymm = False
if yymm and mmyy:
    print('AMBIGUOUS')
elif yymm:
    print('YYMM')
elif mmyy:
    print('MMYY')
else:
    print('NA')


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    int count = (int)S.size() + 1;
    for (int i = 0; i < (int)S.size() - (int)T.size() + 1; i++) {
        int changeCount = 0;
        for (int j = 0; j < (int)T.size(); j++) {
            if (S.at(i + j) != T.at(j)) changeCount += 1;
        }
        count = min(count, changeCount);
    }
    cout << count << endl;
}

Measured memory_bytes: 3644
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<usize>()[0];

    let mut ans = 0;

    for i in 3..n+1{
        let mut num = 0;
        for j in 1..i+1{
            if i%j == 0{
                num += 1;
            }
        }

        if num == 8 && i%2 == 1{
            ans += 1;
        }
    }

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#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 VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

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

int main(void){
	string A,B,C;
	cin>>A>>B>>C;
	
	if(A[A.length()-1]==B[0] &&B[B.length()-1]==C[0]) puts("YES");
	else puts("NO");


	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int l, r;
    int i, j;
    int mod;
    int min = 2019;

    char buf[256];
    fgets(buf, 256, stdin);
    sscanf(buf, "%d %d", &l, &r);

    if((r -l)/673 >= 1){ //2019 = 673 / 3
        //printf("673, 3 must included.\n");
        min = 0;
    }else{
        for (i = l; i <= r-1; i++){
            for (j = i+1; j <= r; j++){
                mod = ((long)i * j) % 2019;
                if (min > mod){
                    //printf("i = %d j = %d : change %d -> %d\n", i, j ,min, mod);
                    min = mod;
                }
            }
        }
    }

    printf("%d", min);

}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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 (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> L(N);
    for (auto &i : L) cin >> i;

    int ans = 0;
    rep(i, N) {
        rep(j, i) {
            rep(k, j) {
                if (L[i] == L[j] || L[i] == L[k] || L[j] == L[k]) continue;
                vector<int> v(3);
                v[0] = L[i];
                v[1] = L[j];
                v[2] = L[k];
                sort(v.begin(), v.end());
                if (v[2] < v[0] + v[1]) ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3628
/*--------------------------------
  Author: The Ace Bee
  Blog: www.cnblogs.com/zsbzsb
  This code is made by The Ace Bee
--------------------------------*/
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#define rg register
using namespace std;
template < typename T > inline void read(T& s) {
	s = 0; int f = 0; char c = getchar();
	while (!isdigit(c)) f |= (c == '-'), c = getchar();
	while (isdigit(c)) s = s * 10 + (c ^ 48), c = getchar();
	s = f ? -s : s;
}

typedef long long LL;
const int p = 1000000007;
const int _ = 410;

int n, c, a[_], b[_];
LL pw[_][_], f[_][_];

int main() {
	read(n), read(c);
	for (rg int i = 1; i <= n; ++i) read(a[i]);
	for (rg int i = 1; i <= n; ++i) read(b[i]);

	for (rg int i = 1; i < _; ++i) pw[i][0] = 1ll;
	for (rg int i = 1; i < _; ++i)
		for (rg int j = 1; j < _; ++j)
			pw[i][j] = 1ll * pw[i][j - 1] * i % p;
	
	for (rg int i = 1; i < _; ++i)
		for (rg int j = 0; j < _; ++j)
			pw[i][j] = (pw[i][j] + pw[i - 1][j]) % p;

	f[0][0] = 1;
	for (rg int i = 1; i <= n; ++i)
		for (rg int j = 0; j <= c; ++j)
			for (rg int k = 0; k <= j; ++k)
				f[i][j] = (f[i][j] + 1ll * f[i - 1][j - k] * (pw[b[i]][k] - pw[a[i] - 1][k] + p) % p) % p;

	printf("%lld\n", f[n][c]);
	
	return 0;
}


Measured memory_bytes: 2816
x, y, a, b, c = map(int, input().split())

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

# step1: sort red/green apples in descending order
p.sort(reverse=True)
q.sort(reverse=True)

# step2:clip necessary apples
p = p[:x]
q = q[:y]

# step3: sort red/green apples in ascending order
p.sort()
q.sort()

# step4: sort non-color apples in descending order
r.sort(reverse=True)

# step5:swap apples to eliminate the least delicious apple
d = []

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

print(sum(d[: x + y]))


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

int main(){
  while(true){
    double r,n,INF=9999;
    cin>>r>>n;
    if(r==0&&n==0) break;
    double xleft[41]={},xright[41]={};
    for(int i=0;i<n;i++){
      double xl,xr,h;
      cin>>xl>>xr>>h;
      for(int j=xl;j<=xr;j++){
        int k=20+j;
        if(j==xl){xright[k]=max(xright[k],h);}
        else if(j==xr){xleft[k]=max(xleft[k],h);}
        else{
          xright[k]=max(xright[k],h);
          xleft[k]=max(xleft[k],h);
        }
      /*if(h>=xleft[k]){
          xright[k]=xleft[k];
          xleft[k]=h;
        }else if(h>=xright[k]){
          xright[k]=h;
        }*/
      }
    }
    double ans=INF;
    for(int i=-20;i<=20;i++){
      double id=i;
      int k=20+i;
      if(abs(i)>r) continue;
      //cout<<"xleft"<<xleft[k]<<" "<<k<<endl;
      //cout<<"xright"<<xright[k]<<" "<<k<<endl;
      double yleft,yright;
      yleft=xleft[k]+r-sqrt(pow(r,2)-pow(id,2));
      yright=xright[k]+r-sqrt(pow(r,2)-pow(id,2));
      if(i!=-r)ans=min(ans,yleft);
      if(i!=r)ans=min(ans,yright);
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

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

ll N,K,C;
string s;
vector<ll> l,r;

int main(){
    cin >> N >> K >> C;
    cin >> s;
    ll i = 0;
    while(l.size() < K && i < N){
        if(s[i] == 'x'){
            i++;
            continue;
        }
        l.push_back(i);
        i+=C+1;
    }
    i = N-1;
    while(r.size() < K && i >= 0){
        if(s[i] == 'x'){
            i--;
            continue;
        }
        r.push_back(i);
        i-=C+1;
    }
    sort(r.begin(),r.end());
    for(int i=0;i<K;i++){
        if(l[i]==r[i]) cout << l[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 8104
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

struct Balloon{
	Balloon(){
		location = 0;
		time = 0;
	}
	Balloon(int arg_location,int arg_time){
		location = arg_location;
		time = arg_time;
	}
	int location,time;
};

int main(){

	int N,ans,last_catch,dist,dp[41][4];
	bool FLG;
	Balloon info[41];

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		ans = BIG_NUM;
		last_catch = 0;

		for(int i = 1; i <= N; i++){
			scanf("%d %d",&info[i].location,&info[i].time);
		}

		for(int i = 1; i <= N; i++){
			for(int k = 0; k <= 3; k++)dp[i][k] = BIG_NUM;
		}

		if(info[1].location > info[1].time){
			printf("NG 1\n");
			continue;
		}else{
			dp[1][1] = info[1].location;
			last_catch = 1;
		}

		for(int i = 2; i <= N; i++){
			FLG = false;
			for(int k = 0; k <= 3; k++){
				if(dp[i-1][k] == BIG_NUM)continue;

				dist = abs(info[i].location-info[i-1].location);

				switch(k){
				case 0:
					if(dist*(k+1) <= info[i].time-info[i-1].time){
						dp[i][k+1] = min(dp[i][k+1],dp[i-1][k]+dist);
						FLG = true;
					}else{
						//Do nothing
					}
					break;
				case 1:
				case 2:
					if(dist*(k+1) <= info[i].time-info[i-1].time){
						dp[i][k+1] = min(dp[i][k+1],dp[i-1][k]+dist);
						FLG = true;
					}else{
						//Do nothing
					}

					if(info[i-1].location*(k+1) + info[i].location <= info[i].time-info[i-1].time){
						dp[i][1] = min(dp[i][1],dp[i-1][k]+info[i-1].location+info[i].location);
						FLG = true;
					}
					break;
				case 3:
					if(info[i-1].location*(k+1) + info[i].location <= info[i].time-info[i-1].time){
						dp[i][1] = min(dp[i][1],dp[i-1][k]+info[i-1].location+info[i].location);
						FLG = true;
					}
					break;
				}
			}
			if(!FLG){
				break;
			}else{
				last_catch = i;
			}
		}

		if(last_catch == N){
			for(int i = 0; i <= 3; i++)ans = min(ans,dp[N][i]);
		}

		if(ans == BIG_NUM){
			printf("NG %d\n",last_catch+1);
		}else{
			printf("OK %d\n",ans+info[N].location);
		}
	}

	return 0;
}

Measured memory_bytes: 2544
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    long long int K;
    cin>>K;
    long long int now=7;
    long long int cou=1;
    if(now%K==0){
        cout<<cou<<endl;
        return 0;
    }
    while(1){
        if(now==0){
            cout<<cou<<endl;
            return 0;
        }
        now*=10;
        now+=7;
        now%=K;
        cou++;
        if(cou==10000000){
            cout<<-1<<endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d,ans=-1000000000000000001;
    cin>>a>>b>>c>>d;
    if(a*c>ans) ans=a*c;
    if(a*d>ans) ans=a*d;
    if(b*c>ans) ans=b*c;
    if(b*d>ans) ans=b*d;
    if((a<=0 && b>=0) || (c<=0 && d>=0)) 
    {
        if(0>ans) ans=0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3632
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		BigInteger modnum = BigInteger.ONE;
		for (int i = 0; i < 9; i++) {
			modnum = modnum.multiply(BigInteger.TEN);
		}
		modnum = modnum.add(BigInteger.valueOf(7));
		
		BigInteger ans = BigInteger.ONE;
		BigInteger q = BigInteger.ONE;
		BigInteger e = BigInteger.ONE;
		
		for (int i = 0; i < n; i++) {
			ans = ans.multiply(BigInteger.TEN).mod(modnum);
			q = q.multiply(BigInteger.valueOf(9)).mod(modnum);
			e = e.multiply(BigInteger.valueOf(8)).mod(modnum);
		}
		System.out.println(ans.subtract(q).subtract(q).add(e).mod(modnum));
	}
}


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

int main(){
	int n, x, i, d = 0, ans = 1;
	cin >> n >> x;
	vector<int> l(n);
	for (i = 0; i < l.size(); i++) cin >> l[i];

	for (i = 0; i < l.size(); i++){
		d += l[i];
		if (d <= x) ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}


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

namespace ABC118
{
	class Program
	{
		static void Main(string[] args)
		{
			int a, b,s ;
			var word = Console.ReadLine().Split(' ');
			a = int.Parse(word[0]);
			b = int.Parse(word[1]);
			s = 0;
			if (b % a == 0)
			{
				s = a + b;
			}
			else
			{
				s = b - a;
			}
			Console.WriteLine(s);
			Console.ReadKey();
		}
	}
}


Measured memory_bytes: 11092
<?php
fscanf(STDIN, "%d %d", $N, $X);
$L = array_merge([0], explode(" ", trim(fgets(STDIN))));
array_map(function ($a) use (&$t, &$ans, $X) { $t += $a; $ans += ($t <= $X); }, $L);
echo $ans;


Measured memory_bytes: 4856
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int a,b,v,w,t;
  cin>>a>>v;
  cin>>b>>w;
  cin>>t;
  long long int d = abs(a-b);
  long long int d1 = (v-w)*t;
  if(d<=d1)
    cout<<"YES"<<endl;
 else 
   	cout<<"NO"<<endl;
}


Measured memory_bytes: 3576
//11月30日
using System;
using System.Linq;

namespace tst
{
    
    class Program
    {
        public static void Main()
        {
            //intの羅列読み込み
            string[] text1 = Console.ReadLine().Split(' ');
            int[] S1 = text1.Select(s => int.Parse(s)).ToArray();
            string[] text2 = Console.ReadLine().Split(' ');
            int[] S2 = text2.Select(s => int.Parse(s)).ToArray();
            //処理
            if (S1[0] != S2[0])
            {
                Console.WriteLine(1);
            }
            else
            {
                Console.WriteLine(0);
            }
        }

    }
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }
template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	string S, T; cin >> S >> T;
	if (T.substr(0, S.size()) == S) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;
    vector<array<int, 3>> dp(N);
    REP(n, N) {
        int a, b, c;
        cin >> a >> b >> c;
        if (n == 0) {
            dp[n][0] = a;
            dp[n][1] = b;
            dp[n][2] = c;
        } else {
            dp[n][0] = max(dp[n-1][1], dp[n-1][2]) + a;
            dp[n][1] = max(dp[n-1][2], dp[n-1][0]) + b;
            dp[n][2] = max(dp[n-1][0], dp[n-1][1]) + c;
        }
    }
    cout << max(dp[N-1][0], max(dp[N-1][1], dp[N-1][2])) << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
int solve(int,int);
int a[20];
int n;
int main(){
  int c,d[200],i,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&c);
  for(i=0;i<c;i++){
    scanf("%d",&d[i]);
  }
    for(i=0;i<c;i++){
    k= solve(0,d[i]);
      if(k==0) printf("yes\n");
      else printf("no\n");
    }
return 0;
}




int solve(int i,int m){
  int c,b;
  if (m==0){
    return 0;
  }
  else if(i>=n){
    return 1;
  }
  else{
  c=solve(i+1,m);
  b=solve(i+1,m-a[i]);
  if(c==0||b==0){
    return 0;
  }
  else return 1;
}
}

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

int main(void) {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) {
    cin >> P[i];
  }
  vector<int> Q(N);
  rep(i, N) {
    cin >> Q[i];
  }

  // 順列パターン生成
  vector<int> v(N);
  iota(v.begin(), v.end(), 1);
  int count = 1;
  int a = 1, b = 1;
  do {
    if (P == v) {
      a = count;
    }
    if (Q == v) {
      b = count;
    }
    count++;
  } while (next_permutation(v.begin(), v.end()));

  cout << abs(a - b) << endl;

  return 0;
}

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

using namespace std;

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

const ll mod = 1000000007;

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

  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;

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

  int c = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') c++;
    else c = 0;
    if (c >= m) {
      cout << -1 << endl; // impossible
      return 0;
    }
  }

  int p = 0;
  vector<int> ans;
  while (p < n) {
    int maximum = 0;
    for (int i = p+1; i <= min(p+m, n); i++) {
      if (s[i] == '0') maximum = i - p;
    }
    ans.push_back(maximum);
    p += maximum;
  }

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

  for (auto &x: ans) cout << x << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 1096
#include<iostream>
#include<string>
#include<vector>

using namespace std;

void split(string s,vector<string> *a)
{
	string tmp;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=' ')
		{
			tmp.append(1,s[i]);
		}
		else
		{
			a->push_back(tmp);
			tmp.clear();
		}
	}
	a->push_back(tmp);
}

bool judge(vector<string> str)
{
	for(int i=0;i<str.size();i++){
		if(str[i].compare("the")==0||
			str[i].compare("this")==0||
			str[i].compare("that")==0)
		{
			return false;
		}
	}
	return true;
}

void rotate(string *s)
{
	for(int i=0;i<s->length();i++)
	{
		if('a'<=s->at(i)&&s->at(i)<='z')
		{
			if(s->at(i)=='z')
			{
				s->at(i)='a';
			}
			else
			{
				s->at(i)+=1;
			}
		}
	}
}

int main(void)
{
	string line;
	while(getline(cin,line))
	{
		vector<string> str;
		split(line,&str);
		while(judge(str))
		{
			for(int i=0;i<str.size();i++)
			{
				rotate(&str[i]);
			}
		}
		cout<<str[0];
		for(int i=1;i<str.size();i++)
		{
			cout<<" "<<str[i];
		}
		cout<<endl;
	};
}

Measured memory_bytes: 1184
n,x = map(int, input().split())

c = 0
ans = []
H = []

for i in range(n):
    w = list(map(int, input().split()))
    for j in range(x-1):
        if w[j]%2>0:
            c+=1
            tmp = [str(i+1), str(j+1), str(i+1), str(j+2)]
            ans.append(tmp)
            w[j+1]+=1
    H.append(w[x-1])
    
for i in range(n-1):
    if H[i]%2>0:
        c+=1
        tmp = [str(i+1), str(x), str(i+2), str(x)]
        ans.append(tmp)
        H[i+1]+=1
           
print(c)
        
for i in range(c):
    print(' '.join(ans[i]))

Measured memory_bytes: 47732
def resolve():
    N, D = map(int, input().split())
    P = [list(map(int, input().split())) for x in range(N)]

    cnt = 0
    for p in P:
        d = (p[0] ** 2 + p[1] ** 2) ** 0.5
        if d <= D:
            cnt += 1

    print(cnt)
resolve()

Measured memory_bytes: 107676
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	int a[n];
	for( int i = 0; i < n; ++i ){
		cin >> a[i];
	}
	vector<int> cntx(100000);
	vector<int> cnty(100000);
	for( int i = 0; i < 100000; ++i ){
		cntx[i] = 0;
		cnty[i] = 0;
	}
	for( int i = 0; i < n; i+=2 ){
		++cntx[a[i]];
		++cnty[a[i+1]];
	}
	int max_x = -1;
	int max_index = -1;
	int max_y = -1;
	int max_indey = -1;
	for( int i = 0; i < 100000; ++i ){
		if( max_x < cntx[i] ){
			max_x = cntx[i];
			max_index = i;
		}
		if( max_y < cnty[i] ){
			max_y = cnty[i];
			max_indey = i;
		}
	}
	if( max_index != max_indey ){
		cout << n - max_x - max_y << endl; 
	} else {
		sort(cntx.rbegin(), cntx.rend());
		sort(cnty.rbegin(), cnty.rend());
		// cout << cntx[0] << " " << cntx[1] << " " << cnty[0] << " " << cnty[1] << endl;
		cout << n - max( cntx[0] + cnty[1], cntx[1] + cnty[0] ) << endl;  
	}
	return 0;
}

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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, k, idx;
    int a[100000];
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        if (a[i] == 1)
            idx = i + 1;
    }

    cout << ((n - 1) + (k - 1) - 1) / (k - 1) << endl;
}


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

#define MAXN 400010

class IO{char buffer[3000001];char *h;int len;inline char gchar(){return *h++;}inline bool validdigit(char c){return c>='0' && c<='9';}public:inline void init(){len=fread(buffer,1,3000000,stdin);h=buffer;}inline int nextint(){register int i=0;register char c;do c=gchar();while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i;}inline int nextsigned(){register int i=0,f=1;register char c;do{c=gchar();if(c=='-')f=-1;}while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i*f;}inline long long nextlonglong(){register long long i=0;register char c;do c=gchar();while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i;}inline long long nextsignedlonglong(){register long long i=0,f=1;register char c;do{c=gchar();if(c=='-')f=-1;}while(!validdigit(c));do{i=i*10+c-48;c=gchar();}while(validdigit(c));return i*f;}inline char nextchar(){register char c;do c=gchar();while(c<=' ');return c;}}io;

int head[MAXN],to[MAXN],nxt[MAXN];
int no,c2,el,n,m,cnt;
char color[MAXN];
bool visit[MAXN];

void cover(int u)
{
	visit[u]=true;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(visit[v])continue;
		cover(v);
	}
}

bool dfs(int u)
{
	bool check=visit[u]=true;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(color[v]==color[u]){check=false;break;}
		if(color[v])continue;
		color[v]=color[u]^3;
		if(!dfs(v)){check=false;break;}
	}
	cover(u);
	return check;
}

int main()
{
	io.init();
	n=io.nextint();
	m=io.nextint();
	for(int i=1;i<=m;++i)
	{
		int u=io.nextint(),v=io.nextint();
		nxt[++cnt]=head[u];
		to[cnt]=v;
		head[u]=cnt;
		nxt[++cnt]=head[v];
		to[cnt]=u;
		head[v]=cnt;
	}
	for(int i=1;i<=n;++i)
	{
		if(visit[i])continue;
		if(!head[i])++no;
		else
		{
			color[i]=1;
			if(dfs(i))++c2;else ++el;
		}
	}
	printf("%lld\n",(long long)no*no+(long long)no*(n-no)*2+(long long)el*c2*2+(long long)el*el+(long long)c2*c2*2);
}

Measured memory_bytes: 8832
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

x1,x2,x3,x4,x5 = LI()

if x1 == 0:
    print(1)
elif x2 == 0:
    print(2)
elif x3 == 0:
    print(3)
elif x4 == 0:
    print(4)
else:
    print(5)

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

using namespace std;
using p = pair<long long, int>;
#define INF 100000000

int main(){
	int n,m;
	cin >> n >> m;
	vector<pair<long long, int> > h(n);
	rep(i,n){
		long long a;	cin >> a;
		h.push_back({a,i});
	}
	sort(h.begin(),h.end(),greater<pair<long long, int> >());
	
	vector<vector<int> > path(n); 
	rep(i,m){
		int a,b;
		cin >> a >> b; a--; b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	vector<int> num(n);
	rep(i,n){
		num[h[i].second] = i;
	}
	int count = 0;
	vector<bool> out(n,false);
	
	rep(i,n){
		int check = 0;
		if(!out[h[i].second]){
		 count++; out[h[i].second] = true;
		 check = -1;
		}
		int same = 0;
		if(path[h[i].second].size() == 0) continue;
		for(int attach : path[h[i].second]){
			out[attach] = true;
			if(h[i].first == h[num[attach]].first){
		        same = -1; 
		    }
		}
		if(same == -1 && check == -1)	count--;
	}
	
	cout << count << endl;
}

Measured memory_bytes: 11816
import math
A,B,H,M = map(int,input().split())
M_ras = math.radians(M * 6)
M_x = B * math.cos(M_ras)
M_y = B * math.sin(M_ras)
H_ras = math.radians(H * 30 + M * 0.5)
H_x = A * math.cos(H_ras)
H_y = A * math.sin(H_ras)
dis = math.sqrt((M_x - H_x) ** 2 + (M_y - H_y) ** 2)
print(dis)

Measured memory_bytes: 62568
N, T = map(int, input().split())
a = 0
b = 0
for i in range(N):
    c, t = map(int, input().split())
    if t <= T:
        a = c
        if b == 0 and a > 0:
            b = a
        else:
            b = min(a, b)
if b == 0:
    print("TLE")
else:
    print(b)

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BATCoder solver = new BATCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class BATCoder {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            String s = in.next();
            int longest = 0;
            int current = 0;
            for (int i = 0; i < s.length(); i++) {
                if (s.charAt(i) == 'A' || s.charAt(i) == 'C' || s.charAt(i) == 'G' || s.charAt(i) == 'T') {
                    current++;
                    if (current > longest) {
                        longest = current;
                    }
                } else {
                    current = 0;
                }
            }
            out.println(longest);
        }

    }
}



Measured memory_bytes: 21972