akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int in[3]={},dp[100][100][100],n=3,inf=10000;
	FOR(i,0,100)FOR(j,0,100)FOR(k,0,100)dp[i][j][k]=inf;
	FOR(i,0,n)cin>>in[i];
	dp[in[0]][in[1]][in[2]]=0;
	FOR(a,in[0],90){
		FOR(b,in[1],90){
			FOR(c,in[2],90){
				dp[a+2][b][c]=min(dp[a+2][b][c],dp[a][b][c]+1);
				dp[a][b+2][c]=min(dp[a][b+2][c],dp[a][b][c]+1);
				dp[a][b][c+2]=min(dp[a][b][c+2],dp[a][b][c]+1);
				dp[a+1][b+1][c]=min(dp[a+1][b+1][c],dp[a][b][c]+1);
				dp[a+1][b][c+1]=min(dp[a+1][b][c+1],dp[a][b][c]+1);
				dp[a][b+1][c+1]=min(dp[a][b+1][c+1],dp[a][b][c]+1);
			}
		}
	}
	FOR(i,0,52){
		if(dp[i][i][i]!=inf){
			cout<<dp[i][i][i]<<endl;
			break;
		}
	}
    return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    int k,a,b; cin >> k;
    cin >> a >> b;
    FOR(i,a,b+1){
        if(i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}


Measured memory_bytes: 3632
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;
static import std.ascii;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long r1, c1, r2, c2;
    scan(r1, c1, r2, c2);

    auto fact = new long[](r2 + c2 + 2);
    fact[0] = 1;
    foreach (i; 1 .. fact.length)
        fact[i] = fact[i - 1] * i % MOD;
    auto fact_inv = new long[](fact.length);
    foreach (i; 0 .. fact_inv.length)
        fact_inv[i] = powmod(fact[i], MOD - 2, MOD);

    long combination_mod(long n, long k)
    {
        if (n < k)
            return 1;
        return (fact[n] * fact_inv[k] % MOD) * fact_inv[n - k] % MOD;
    }

    long g(long r, long c)
    {
        long ans;
        foreach (y; 0 .. r + 1)
        {
            ans = (ans + combination_mod(y + c + 1, y + 1)) % MOD;
        }
        return ans;
    }

    writeln((MOD * 2 + g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)) % MOD);
}

T powmod(T = long)(T x, T n, T m)
{
    if (n < 1)
        return 1;
    if (n & 1)
    {
        return x * powmod(x, n - 1, m) % m;
    }
    T tmp = powmod(x, n / 2, m);
    return tmp * tmp % m;
}


Measured memory_bytes: 33660
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin
import math

# 標準入力をスペースで区切って、intに変換 listに収納
int_list  = [int(x) for x in stdin.readline().rstrip().split()]

A = int_list[0]
B = int_list[1]

plug=1
cnt=0
while True:
    if plug>=B:
        break
    plug+= A - 1
    cnt+=1

print(cnt)


Measured memory_bytes: 2940
#include <iostream>

int main() {
  // 入力
  int a, b;
  std::cin >> a >> b;

  // 2の倍数 * c = 偶数
  if (a * b % 2 == 1) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.at(2) == s.at(3) && s.at(4) == s.at(5)){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import heapq

n,m,s,t = map(int,input().split())
s -= 1
t -= 1

dic = {}

for i in range(m):

    u,v,a,b = map(int,input().split())
    u -= 1
    v -= 1

    if u not in dic:
        dic[u] = []
    if v not in dic:
        dic[v] = []

    dic[u].append([v,a,b])
    dic[v].append([u,a,b])



q = [[0,t]]

yen = [float("inf")] * n
yen[t] = 0

yenwait = [True] * n

while len(q) > 0:

    du = heapq.heappop(q)

    for vab in dic[du[1]]:

        if yen[vab[0]] > yen[du[1]] + vab[2]:
            yen[vab[0]] = yen[du[1]] + vab[2]
            heapq.heappush(q,[yen[vab[0]] , vab[0]])

sunk = yen.copy()


q = [[0,s]]

yen = [float("inf")] * n
yen[s] = 0

yenwait = [True] * n

while len(q) > 0:

    du = heapq.heappop(q)

    for vab in dic[du[1]]:

        if yen[vab[0]] > yen[du[1]] + vab[1]:
            yen[vab[0]] = yen[du[1]] + vab[1]
            heapq.heappush(q,[yen[vab[0]] , vab[0]])


cost = []

for i in range(n):
    cost.append( yen[i] + sunk[i] )

costq = []

for i in range(n):
    heapq.heappush(costq , [cost[i] , i])

for i in range(n):

    while costq[0][1] < i:
        heapq.heappop(costq)

    print (10 ** 15 - costq[0][0])





Measured memory_bytes: 82340
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  int ans = N%1000;
  if(ans != 0){
    ans = 1000 - ans;
  }
  cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	string ans = "No";
	if(s[2]==s[3]&&s[4]==s[5]) ans = "Yes";
	cout << ans << endl;
	return 0;
}

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

bool is_rocks(string s,int l,int r){
    for(int i = l;i < r;i ++){
        if(s[i]=='#' && s[i+1]=='#') return true;
    }
    return false;
}
bool is_3airs(string s,int l,int r){
    for(int i = l;i < r-1;i ++){
        if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.') return true;
    }
    return false;
}

int main(){
    int n,a,b,c,d;
    bool isp;
    string s;
    cin >> n >> a >> b >> c >> d >> s;
    a --,b --,c --,d --;

    if(b<c && c<d){
        if(is_rocks(s,a+1,d-1)) isp = false;
        else isp = true;
    }else if(b>c){
        if(is_rocks(s,a+1,c-1) || is_rocks(s,b+1,d-1)) isp = false;
        else isp = true;
    }else{
        if(is_rocks(s,a+1,c-1) || !is_3airs(s,b-1,d+1)) isp = false;
        else isp = true;
    }
    if(isp) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 900
#include "iostream"
#include <string.h>
using namespace std;
 
int main(){
 
  string S;
  int N, ans=0;
  
  cin >> N;
  cin >> S;
  
 for(int i=0; i<N-2; i++){
  
   if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
   	ans++;
   }
   
   
 }
   
  cout << ans;
   
   
  return 0;
  
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define REP(i, start, end) for (int i = start, i##Len = (end); i < i##Len; ++i)
#define REPR(i, start, end) for (int i = start, i##Len = (end); i > i##Len; --i)
using ll = long long;
using namespace std;

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, 0, n)
        cin >> a[i];
    REP(i, k, n)
    {
        cout << (a[i] > a[i - k] ? "Yes" : "No") << "\n";
    }
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b){
    return a * b / gcd(a,b);
}

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    ll N;
    cin >> N;

    vector<ll> v(5);
    for (int i = 0; i < 5; i++) {
        cin >> v[i];
    }

    sort(all(v));
    cout << (N + v[0] - 1) / v[0] + 4 << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


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

int main(){
  int k, s;
  cin >> k >> s;
  int ans=0;
  rep(x,k+1)rep(y,k+1){
    int z = s - x - y;
    if(0<=z && z<=k) ans++;
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
A, B = gets.split(" ").map(&:to_i)

ans = 0
if A >= B
  ans += A
  if A - 1 >= B
    ans += A - 1
  else
    ans += B
  end
else
  ans += B
  if B - 1 >= A
    ans += B - 1
  else
    ans += A
  end
end

puts ans


Measured memory_bytes: 1788
import kotlin.math.max

fun main() {
    val (n, limit) = readLine()!!.split(" ").map { it.toInt() }
    val ws = mutableListOf<Int>(0)
    val vs = mutableListOf<Long>(0L)

    repeat(n) {
        val (w, v) = readLine()!!.split(" ").map { it.toInt() }
        ws.add(w)
        vs.add(v.toLong())
    }

    val dp = Array(n + 1) { Array(limit + 1) { 0L } }
    for (i in 1..n) {
        for (j in 1..limit) {
            val curr = ws[i]
            if (j >= curr) {
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - curr] + vs[i])
            } else {
                dp[i][j] = dp[i-1][j]
            }
        }
    }

    println(dp[n][limit])

}

Measured memory_bytes: 350596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define DEBUG
#ifdef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <typename Arg1>
	void __f(const char* name, Arg1&& arg1){
		cerr << name << " : " << arg1 << std::endl;
	}
	template <typename Arg1, typename... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
	}
#else
#define debug(...)
#endif
#define FOR(i,a,b) 	for(int i=a;i<b;++i)
#define RFOR(i,a,b) 	for(int i=a;i>=b;--i)
#define ln 		"\n"
#define mp make_pair
#define pb push_back
#define sz(a)	ll(a.size())
#define F first
#define S second
#define all(c)	c.begin(),c.end()
#define rall(c) c.rbegin(), c.rend()
#define trace(c,x) for(auto &x:c)
#define pii pair<ll,ll>
#define init(a, x) memset(a,x,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef	priority_queue<pii,std::vector<pii>,greater<pii> > revpr;

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> pbds;
// ordered_set X
//K-th smallest
//*X.find_by_order(k-1)
//NO OF ELEMENTS < A
//X.order_of_key(A)
const int L=1e6+7;
ll n, h[L], dp[L];
ll solve(int i)
{
	if(i==n-1)return 0;
	if(i>=n)return INT_MAX;
	if(dp[i] != -1)return dp[i];
	ll &ret = dp[i];
	ret = INT_MAX;
	ret = solve(i+1) + abs(h[i]-h[i+1]);
	ret = min(ret,solve(i+2) + abs(h[i]-h[i+2]));
	return ret;
}
void fff()
{
	cin >> n;
	init(dp, -1);
	FOR(i,0,n)cin >> h[i];
	cout<<solve(0)<<ln;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	//int t;cin >> t;while(t--)
	fff();
	return 0;
}

Measured memory_bytes: 16844
import math
k = int(input())
ans = 0
# def gcd(a,b):
#     s = max(a,b)
#     gcd = 0
#     for p in range(1,s+1):
#         if a%p==0 and b%p == 0:
#             gcd = p
#     return gcd
for a in range(1,k+1):
    for b in range(1,k+1):
        gcdab = math.gcd(a,b)
        for c in range(1,k+1):
            # print(a,b,c,fractions.gcd(gcdab,c))
            ans += math.gcd(gcdab,c)
print(ans)


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

int main(){
    int a;
    string s;
    cin >> a;
    cin >> s;
    if(a < 3200) cout << "red" << endl;
    else cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for(register int i = x; i <= y; ++ i)
#define repd(i,x,y) for(register int i = x; i >= y; -- i)
typedef long long ll;
using namespace std;
template<typename T>inline bool chkmax(T&x,T y) { return x < y ? x = y,1 : 0; }
template<typename T>inline bool chkmin(T&x,T y) { return x > y ? x = y,1 : 0; }
template<typename T>inline void read(T&x)
{
	char c;int sign = 1;x = 0;
	do { c = getchar(); if(c == '-') sign = -1; }while(!isdigit(c));
	do { x = x * 10 + c - '0'; c = getchar(); }while(isdigit(c));
	x *= sign;
}

ll a,b,c;

int main()
{
	read(a); read(b); read(c);
	cout << b + min(a+b+1,c);
	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);
		
		for(; scanner.hasNext();)
		{
			int d = scanner.nextInt();
			
			int s = 0;
			for(int i=0; i<600; i+=d)
			{
				s += d * (i*i);
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 25736
import heapq
X,Y,Z,K=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
B=[int(i) for i in input().split()]
C=[int(i) for i in input().split()]
A.sort(key=lambda x:-x)
B.sort(key=lambda y:-y)
C.sort(key=lambda z:-z)
pri=[]
def dp(x,y,z):
  return A[x]+B[y]+C[z]

def priq(a,b,c):
  d=-dp(a,b,c)
  if tuple([d,a,b,c]) not in pri:
    heapq.heappush(pri,(d,a,b,c))

heapq.heappush(pri,(-dp(0,0,0),0,0,0))

for i in range(K):
  d,x,y,z=heapq.heappop(pri)
  print(-d)
  if x<X-1:
    priq(x+1,y,z)
  if y<Y-1:
    priq(x,y+1,z)
  if z<Z-1:
    priq(x,y,z+1)

Measured memory_bytes: 3828
#include <iostream>
#include <cstring>

using namespace std;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)

int a[1005][1005];
int dp[1005][1005]; // dp[i][j] := N-1???????????§???(i, j)??????????????£??????

int main()
{
	omajinai;

	int H, W, N;
	
	while (cin >> H >> W >> N, H) {
		memset(dp, 0, sizeof dp);

		rep(i, H) rep(j, W) cin >> a[i][j];

		dp[0][0] = N - 1;

		rep(i, H) rep(j, W) {
			if (i == 0 && j == 0) continue;

			if (i - 1 >= 0) {
				bool f = (dp[i - 1][j] % 2 == 0 ? a[i - 1][j] : !a[i - 1][j]) == 0;
				dp[i][j] += (f ? (dp[i - 1][j] / 2) : (dp[i - 1][j] + 1) / 2);
			}

			if (j - 1 >= 0) {
				bool f = (dp[i][j - 1] % 2 == 0 ? a[i][j - 1] : !a[i][j - 1]) == 1;
				dp[i][j] += (f ? dp[i][j - 1] / 2 : (dp[i][j - 1] + 1) / 2);
			}
		}

		rep(i, H) rep(j, W) {
			a[i][j] ^= dp[i][j] % 2;
		}

		int y = 0, x = 0;

		while (y < H && x < W) {
			(a[y][x] ? x : y)++;
		}

		cout << y + 1 << ' ' << x + 1 << endl;
	}
}

Measured memory_bytes: 10944
#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 <math.h>
using namespace std;
int main(){
    int p = 0;
   vector<vector<int>> a(3,vector<int>(3));
   vector<vector<int>> c(3,vector<int>(3,0));
   for(int i = 0; i < 3; i++){
       for(int j = 0; j < 3; j++){
           cin >> a.at(i).at(j);
       }
   }
   int n;
   cin >> n;
   vector<int> b(n);
   for(int i = 0; i < n; i ++){
       cin >> b.at(i);
   }
   for(int i = 0; i < 3; i++){
       for(int j = 0; j < 3; j++){
           for(int k = 0; k < n; k++){
                if(a.at(i).at(j)==b.at(k)){
                    c.at(i).at(j)=1;
                    break;
                }
           }
       }
   }
   for(int i = 0; i < 3; i++){
       if(c.at(i).at(0)==1 && c.at(i).at(1)==1){
           if(c.at(i).at(2)==1){
               p = 1;
               break;
           }
       }
       if(c.at(0).at(i)==1 && c.at(1).at(i)==1){
           if(c.at(2).at(i)==1){
               p = 1;
               break;
           }
       }
   }
   if(c.at(1).at(1)==1){
       if(c.at(0).at(0)==1 && c.at(2).at(2)==1){
           p = 1;
       }
       if(c.at(0).at(2)==1 && c.at(2).at(0)==1){
           p = 1;
       }
   }
   if(p == 1){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
}

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

from bisect import bisect_left

ans = 0
for i in range(1 + min(n, k)):
    for j in range(1 + min(n, k) - i):
        if i == j == 0:
            ans = max(ans, 0)
        else:
            remk = k - i - j
            _v = v[:i] + v[n-j:]
            _v.sort()
            max_i = min(remk, bisect_left(_v, 0))
            ans = max(ans, sum(_v[max_i:]))

print(ans)


Measured memory_bytes: 40688
# -*- coding: utf-8 -*-
# 整数の入力
n = int(input())
word_list = []

for i in range(n):
  word_list.append(input())
    
w_dictionary = {} 
for i in range(n):
  if word_list[i] not in w_dictionary:
    w_dictionary[word_list[i]] = 1
  else:
    w_dictionary[word_list[i]] += 1

score_sorted = sorted(w_dictionary.items(), key=lambda x:-x[1])
max_score = score_sorted[0][1]

key_sorted = sorted(w_dictionary.items())
for key,value in key_sorted:
  if value == max_score:
    print(key)

Measured memory_bytes: 60044
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    int i,j,k,n,m,ans=Mod;
    string s1,s2;
    cin >> s1 >> s2;
    n = s1.size();
    m = s2.size();
    for(i=0; i<=n-m; i++)
    {
        int ct=0;
        for(j=0,k=i; j<m; j++,k++)
        {
            if(s1[k]!=s2[j])
                ct++;
        }
        ans = min(ans,ct);
    }
    cout <<ans<<endl;
    return ;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
   // cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}




Measured memory_bytes: 3656
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

void add_mod(int &a, int b, int m) {
  a += b;
  if (a >= m) a -= m;
}

const int mod = 998244353, inv3 = (mod + 1) / 3;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> vals(n);
  for (int i = 0; i < n; ++i)
    scanf("%d", &vals[i]);
  const int tsum = accumulate(vals.begin(), vals.end(), 0);

  vector<int> dp(2 * tsum + 1), next_dp(2 * tsum + 1);
  dp[0 + tsum] = 1;
  for (int i = 0; i < n; ++i) {
    fill(next_dp.begin(), next_dp.end(), 0);
    for (int s = -tsum; s <= tsum; ++s) {
      if (dp[s + tsum] == 0) continue;
      add_mod(next_dp[s + vals[i] + tsum], dp[s + tsum], mod);
      add_mod(next_dp[s - vals[i] + tsum], dp[s + tsum], mod);
      add_mod(next_dp[s - vals[i] + tsum], dp[s + tsum], mod);
    }
    swap(dp, next_dp);
  }

  vector<int> dp2(2 * tsum + 1), next_dp2(2 * tsum + 1);
  dp2[0 + tsum] = 1;
  for (int i = 0; i < n; ++i) {
    fill(next_dp2.begin(), next_dp2.end(), 0);
    for (int s = -tsum; s <= tsum; ++s) {
      if (dp2[s + tsum] == 0) continue;
      add_mod(next_dp2[s + vals[i] + tsum], dp2[s + tsum], mod);
      add_mod(next_dp2[s + tsum], dp2[s + tsum], mod);
    }
    swap(dp2, next_dp2);
  }

  int ninvalid = 0;
  for (int s = 0; s <= tsum; ++s) {
    add_mod(ninvalid, dp[s + tsum], mod);
    add_mod(ninvalid, dp[s + tsum], mod);
    add_mod(ninvalid, dp[s + tsum], mod);
  }

  if (tsum % 2 == 0) {
    ninvalid = (ninvalid - 3LL * dp2[tsum / 2 + tsum]) % mod;
    if (ninvalid < 0) ninvalid += mod;
  }

  int ngood = 1;
  for (int i = 0; i < n; ++i)
    ngood = 3LL * ngood % mod;
  ngood -= ninvalid;
  if (ngood < 0) ngood += mod;

  printf("%d\n", ngood);

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

  ll n[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
  ll k;cin>>k;

out(n[k-1]);


  return 0;
}


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

typedef long long ll;
typedef vector<int> vi;

const double PI=acos(-1.0);

int N; vi u,v,w;
int color[100010]; vector<pair<int,int>> connect[100010]; int is_checked[100010];
int input()
{
    cin>>N;
    for(int i=0;i<N-1;++i){
        int a,b,c;
        cin>>a>>b>>c;
        u.emplace_back(a);
        v.emplace_back(b);
        w.emplace_back(c);
    }
}

void bfs(int node)
{
    for(auto p:connect[node]){
        if(!is_checked[p.first]){
            if(p.second%2) color[p.first]=(color[node]+1)%2;
            else color[p.first]=color[node];
            is_checked[p.first]=1;
            bfs(p.first);
        }
        else continue;
    }
}

int solve()
{
    for(int i=0;i<N-1;++i){
        connect[u[i]].emplace_back(make_pair(v[i],w[i]));
        connect[v[i]].emplace_back(make_pair(u[i],w[i]));
    }
    for(int i=0;i<100010;++i){
        is_checked[i]=0;
    }

    color[u[0]]=0;
    is_checked[u[0]]=1;
    for(auto p:connect[u[0]]){
        if(!is_checked[p.first]){
            if(p.second%2) color[p.first]=(color[u[0]]+1)%2;
            else color[p.first]=color[u[0]];
            is_checked[p.first]=1;
            bfs(p.first);
        }
        else continue;
    }

    for(int i=0;i<N;++i){
        cout<<color[i+1]<<"\n";
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 10476
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  lint n, d, a;
  cin >> n >> d >> a;
  vector<pli> v(n);
  v1li b(n+1), x(n); b[0] = 0;
  rep(i, n) cin >> v[i].fi >> v[i].se;
  sort(v.begin(), v.end());
  rep(i, n) x[i] = v[i].fi;
  rep(i, n){
    v[i].se -= a * (b[i]-b[lower_bound(x.begin(), x.end(), v[i].fi-2*d)-x.begin()]);
    b[i+1] = b[i];
    if(v[i].se > 0) b[i+1] += (v[i].se-1)/a + 1;
  }
  cout << b[n] << endl;
  return 0;
}

Measured memory_bytes: 6528
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] val = new int[N];
    for(int i = 0; i < N; i++){
      val[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(val);
    
    long ans = 0;
    for(int i = 0; i < N-2; i++){
      for(int j = i+1; j < N-1; j++){
        long A = val[i];
        long B = val[j];
        int ub = N-1;
        int lb = j+1;
        if(ub == lb){
          if(A+B > val[ub]){
            ans++;
          }
        }else{
          while(ub != lb+1){
            int M = (ub+lb)/2;
            if(A+B > val[M]){
              lb = M;
            }else{
              ub = M;
            }
          }
          if(A+B > val[ub]){
            ans += ub-j;
          }else if(A+B > val[lb]){
            ans += lb-j;
          }
        }
      }
    }   
    System.out.println(ans);
  }
}

Measured memory_bytes: 25312
using System;

namespace A
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();

			if (s[0] == s[1] && s[1] == s[2])
			{
				Console.WriteLine("No");
			}
			else
			{
				Console.WriteLine("Yes");
			}
		}
	}
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <algorithm>
int main() {
	int n, a[100000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", a + i);
	unsigned long long order1 = 0, order2 = 0;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if ((i & 0x1) && (0 < sum)) {
			order1 += sum + 1;
			sum = -1;
		}
		if (!(i & 0x1) && (sum < 0)) {
			order1 -= sum - 1;
			sum = 1;
		}
		if (sum == 0) {
			order1++;
			sum = (i & 0x1) ? -1 : 1;
		}
	}
	sum = 0;
	for (int i = 0; i < n; i++) {
		sum += a[i];
		if (!(i & 0x1) && (0 < sum)) {
			order2 += sum + 1;
			sum = -1;
		}
		if ((i & 0x1) && (sum < 0)) {
			order2 -= sum - 1;
			sum = 1;
		}
		if (sum == 0) {
			order2++;
			sum = (i & 0x1) ? 1 : -1;
		}
	}
	printf("%lld\n", std::min(order1, order2));
}

Measured memory_bytes: 512
N,K = map(int,input().split())
S = input()
X = []
Y = []

i = 0
count = 0
while i != len(S):
    if S[i] != S[i-1] and i != 0:
        X.append(count)
        Y.append(S[i-1])
        count = 1
    else:
        count += 1
    i += 1
X.append(count)
Y.append(S[-1])

ans = 0
zero_counter = 0
val = 0
j = 0 
for i in range(len(X)):
    if Y[i] == '0':
        zero_counter += 1
    val += X[i]
    while zero_counter > K:
        val -= X[j]
        if Y[j] == '0':
            zero_counter -= 1
        j += 1
    if ans < val:
        ans = val
print(ans)


Measured memory_bytes: 55024
/*ॐॐ*/
/* I have already deleted My old account because somebody stole my code
and i have no idea how. If you are copying this code atleast make it look different.
Change variable names or change some Data structres or anything just make sure MOSS do not
Detect Anything.
Yours Faithfully
Shobhit Yadav */

/* I do not fear this new challenge. Rather like a true warrior I will rise to meet it. 
                                       -Prince Vegeta  */

 /* “Strength is the only thing that matters in this world. Everything else is just a delusion for the weak.” – Vegeta */

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



ll N;
/*ll freq[200005];*/
void solve(){
   /*memset(freq,0,sizeof(freq));*/
   cin>>N;
   double X[N] , Y[N];
   double sum = 0;
   for(ll i = 0 ; i<N ; i++){
     cin>>X[i]>>Y[i];
   }


for(ll i = 0 ; i<N ; i++){
	for(ll j = i+1 ; j<N ; j++){
		sum += (2*sqrt(pow(X[j]-X[i] , 2) + pow(Y[j] - Y[i] , 2)))/N;
	}
}

  cout << fixed << setprecision(10) << sum <<'\n';



   

}



int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
   solve();

  return 0;
}


Measured memory_bytes: 3824
r = /[qwertasdfgzxcvb]/;
loop {
    s = gets.chomp
    break if s == '#'
    count = 0
    right = (r === s[0])
    s.each_char{|c|
        count += 1 if right ^ (right = (r === c))
    }
    p count
}

Measured memory_bytes: 6220
#include <iostream> 
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main() {

  int H, N;
  
  cin >> H >> N;
  vector<int> dp(N);
  for(int i = 0; i < N; i++) {
       
       cin >> dp[i];
  }
   int sum = 0;
   
   sum = accumulate(dp.begin(), dp.end(), 0);
   if(H - sum <= 0) {
   	 cout << "Yes" <<"\n";
   }
   else {
   	cout << "No" << "\n";
   }
  return 0;
     }

Measured memory_bytes: 640
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d",&a);
	scanf("%d",&b);
	if(a>b){
		printf("a > b\n");
	}
	else if(a<b){
		printf("a < b\n");
	}
	else{
		printf("a == b\n");
	}
return 0;
}


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

int n,su[100001];
int dap[2] = {0, 0};
int main(){
	int cntt = 0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d", &su[i]);
	sort(su, su+n, greater<int>());
	for(int i=0;i<n-1;i++){
		if(su[i] == su[i+1]){
			//printf("%d ", su[i]);
			dap[cntt++] = su[i];
			i++;
		}
		if(cntt == 2) break;
	}
	long long cal = dap[0]; cal *= dap[1];
	printf("%lld\n", cal);
}

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


/*
ll gcds(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    ll r=a%b;
    if(r==0){
        return b;
    }
    while(r>0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}


ll lcms(ll a,ll b){
    ll mmr=gcds(a,b);
    a=a/mmr;
    b=b/mmr;
    return a*b*mmr;
}
*/


int main(){
    int N;
    cin>>N;
    if(N%2==1){
        cout<<N/2+1<<endl;
    }
    else{
        cout<<N/2<<endl;
    }
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let (h, w) = i.read2::<usize, usize>();
    let mut a = Vec::<Vec<bool>>::new();
    for _ in 0..h {
        a.push(
            i.read_line()
                .as_bytes()
                .iter()
                .map(|&x| x == b'#')
                .collect(),
        );
    }
    writeln!(o, "{}", solve(w, h, a)).unwrap();;
}
fn solve(w: usize, h: usize, mut a: Vec<Vec<bool>>) -> usize {
    fn set_black(x: usize, y: usize, a: &mut [Vec<bool>], blacks_next: &mut Vec<(usize, usize)>) {
        if a[y][x] {
            return;
        }
        a[y][x] = true;
        blacks_next.push((x, y));
    }

    let mut blacks = Vec::new();
    let mut blacks_next = Vec::new();
    for y in 0..h {
        for x in 0..w {
            if a[y][x] {
                blacks.push((x, y));
            }
        }
    }
    for ans in 0.. {
        for &(x, y) in &blacks {
            if y > 0 {
                set_black(x, y - 1, &mut a, &mut blacks_next);
            }
            if y + 1 < h {
                set_black(x, y + 1, &mut a, &mut blacks_next);
            }
            if x > 0 {
                set_black(x - 1, y, &mut a, &mut blacks_next);
            }
            if x + 1 < w {
                set_black(x + 1, y, &mut a, &mut blacks_next);
            }
        }
        if blacks_next.is_empty() {
            return ans;
        }
        blacks.clear();
        std::mem::swap(&mut blacks, &mut blacks_next);
    }
    unreachable!()
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }

    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


Measured memory_bytes: 22772
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
int main() {
    string t;
    cin >> t;
    for(int i=0;i<t.length();i++){
        if(t[i] == '?'){
            t[i] = 'D';
        }
    }
    cout << t << endl;
    return 0;
}

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

const int inf = 1e8;

int main(){
  int n,m,q;
  while(cin >> n, n){
    vector< vector<string> > name(n);
    vector< vector<int> > price(n);
    rep(i,n){
      int k;
      cin >> k;
      name[i].resize(k); price[i].resize(k);
      rep(j,k)cin >> name[i][j] >> price[i][j];
    }

    int sum = 0;
    vector<int> mask(n+1,0);
    cin >> q;
    rep(i,q){
      string item;
      int minv = inf;
      cin >> item;
      rep(j,n)rep(k,name[j].size()){
	if(item == name[j][k])minv = min(minv, price[j][k]);
      }
      sum += minv;

      rep(j,n)rep(k,name[j].size()){
	if(item == name[j][k] && minv == price[j][k])mask[j+1] |= 1<<i;
      }
    }

    n++;
    vector< vector<pii> > g(n);
    cin >> m;
    rep(i,m){
      int s,t,d;
      cin >> s >> t >> d;
      g[s].push_back(pii(d,t));
      g[t].push_back(pii(d,s));
    }

    vector<int> dis(n<<q,inf);
    dis[0] = 0;
    priority_queue< pii,vector<pii>,greater<pii> > pq;
    pq.push(pii(0,0));

    while(pq.size()){
      pii p = pq.top(); pq.pop();
      int cur = p.second, cost = p.first;
      if(dis[cur] < cost)continue;
      if( cur == (1<<q)-1 )break;

      for(pii e : g[cur>>q]){
	int nc = cost + e.first, u = e.second;
	int nxt = u<<q | (cur%(1<<q)) | mask[u];
	if(dis[nxt] > nc){
	  dis[nxt] = nc;
	  pq.push(pii(nc,nxt));
	}
      }
    }
    if(dis[(1<<q)-1] == inf)cout << "impossible" << endl;
    else cout << sum << " " << dis[(1<<q)-1] << endl;
  }
}

Measured memory_bytes: 2316
n,m=map(int,input().split())
List=[]
for i in range(m):
    a,b=map(int,input().split())
    List.append([a,b])
    List.append([b,a])
ans=0
for i in range(1,n+1):
    for j in range(len(List)):
        if i==List[j][0]:
            ans+=1
    print(ans)
    ans=0

Measured memory_bytes: 41712
import sys
input = lambda: sys.stdin.readline().rstrip()
tdlist = lambda i, j, value=0: [[value] * j for _ in range(i)]

INF = float("inf")
n, w = map(int, input().split())
v = 10**5
items = [tuple(map(int, input().split())) for _ in range(n)]
dp = tdlist(n+1, v+1, INF)
dp[0][0] = 0

for i, (weight, value) in enumerate(items):
    for j in range(v+1):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        if j + value <= v:
            dp[i+1][j+value] = min(dp[i+1][j+value], dp[i][j] + weight)

for i in range(v+1)[::-1]:
    if dp[n][i] <= w:
        print(i)
        break

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

const int MAX_N = 100005;
int p[MAX_N], mark[MAX_N];

int find(int x) {
    while (!mark[x]) {
        x = p[x];
    }
    return x;
}

int main() {
    int n, q;
    while (cin >> n >> q) {
        if (n == 0 && q == 0) break;
        for (int i = 1; i <= n; ++i) mark[i] = 0;
        mark[1] = 1;
        p[1] = 1;

        for (int i = 2; i <= n; ++i) cin >> p[i];
        long long res = 0;
        char c;
        int t;

        while (q--) {    
            cin >> c >> t;
            if (c == 'M') mark[t] = 1;
            else res += find(t);
        }
        cout << res << "\n";
    }
}


Measured memory_bytes: 3884
#include <cstdint>
#include <iostream>
#include <map>

int main(void)
{
    std::map<std::string, uint32_t> blue;
    uint32_t n;
    std::cin >> n;
    for (uint32_t i=0; i < n; ++i) {
        std::string s;
        std::cin >> s;
        blue[s] = (blue.count(s) == 0) ? 1 : blue[s] + 1;
    }

    std::map<std::string, uint32_t> red;
    uint32_t m;
    std::cin >> m;
    for (uint32_t i=0; i < m; ++i) {
        std::string s;
        std::cin >> s;
        red[s] = (red.count(s) == 0) ? 1 : red[s] + 1;
    }

    int32_t max = 0;

    for (auto x : blue) {
        int32_t num = x.second - red[x.first];
        if (num > max) max = num;
    }

    if (max < 0) max = 0;

    std::cout << max << std::endl;

    return 0;
}

Measured memory_bytes: 380
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int r;
cin>>r;
double pi = 3.1415926535897;
cout<<2*pi*r;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring

Measured memory_bytes: 3840
#include <iostream>
#include <cmath>
#include <cstdio>
#include <utility>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
using namespace std;

int main(){
    int x, a, b;
    cin >> x >> a >> b;
    vector<int> A;
    
    if (abs(x-a) < abs(x-b)) {
        cout << "A";
    } else {
        cout << "B";
    }
    return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
a = sorted(map(int, input().split()), reverse=True)

while m > 0:
    a = sorted(a, reverse=True)
    temp = a[0] // 2
    for i in range(n):
        if a[i] >= temp:
            a[i] = a[i]//2
            m -= 1
            if m <= 0:
                break
        else:
            break

count = 0
for i in a:
    count += i
print(count)

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

int main() {
    int N, D; cin >> N >> D;
    vector<vector<int>> X(N, vector<int>(D));
    int ans=0;
    float dist=0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < D; ++j) {
            cin >> X[i][j];
        }
    }

    for (int k = 0; k < N; ++k) {
        dist = 0;
        for (int i = k+1; i < N; ++i) {
            dist = 0;
            for (int j = 0; j < D; ++j) {
                dist += pow(abs(X[k][j]-X[i][j]), 2.0);
            }
            dist = sqrt(dist);
            if(ceil(dist)==floor(dist))ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	 string s;
	 cin>>s;
	 int i,n,x=0;
	 n=s.size();
	 for(i=1;i<n;i++)
	 {
	 	if(s[i]==s[i-1])
	 	{
	 		if(s[i]=='1')
			 {
			 s[i]='0';
			 }
			 else
			 {
			 	s[i]='1';
			 }
			 x++;
		}
	 }
	 cout<<x<<endl;
}

Measured memory_bytes: 3772
#include<iostream>
#include<algorithm>
#include<climits>
#include<cstring>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define scan(arg) cin>>arg
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
const int INF=1e+9;
int n,m;
int a[100010],b[100010];
struct edge{
  int to,cap,rev;
};
vector<edge> g[100010];
bool used[100010];
void add_edge(int from,int to){
  edge e;e.to=to;e.cap=1;e.rev=g[to].size();
  g[from].push_back(e);
  e.to=from;e.cap=1;e.rev=g[from].size()-1;
  g[to].push_back(e);
}
int dfs(int v,int t,int f){
  if(v==t) return f;
  used[v]=true;
  rep(i,g[v].size()){
    edge &e=g[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap-=d;
	g[e.to][e.rev].cap+=d;
	return d;
      }
    }
  }
  return 0;
}
int max_flow(int s,int t){
  int flow=0;
  while(1){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0) return flow;
    flow+=f;
  }
}


int main(){
  cin>>n>>m;
  rep(i,m){
    cin>>a[i]>>b[i];
    a[i]--;
    b[i]--;
  }
  ll cnt[100010];
  memset(cnt,0,sizeof(cnt));
  rep(i,m){
    cnt[a[i]]++;
    cnt[b[i]]++;
  }
  bool f=false;
  int cnt4=0,x,y;
  rep(i,n){
    if(cnt[i]%2!=0){//オイラーグラフでない
      prin("No");
      return 0;
    }
    else if(cnt[i]>=6){//Yes
      f=true;
    }
    else if(cnt[i]==4){
      cnt4++;
      if(cnt4==1){
	x=i;
      }
      else if(cnt4==2){
	y=i;
      }
      else{
	f=true;
      }
    }
  }
  if(f){
    prin("Yes");
  }
  else if(cnt4==2){
    rep(i,m){
      add_edge(a[i],b[i]);
    }
    //    prin2(x,y);
    //    prin(max_flow(x,y));
    if(max_flow(x,y)==2){
      prin("Yes");
    }
    else{
      prin("No");
    }
  }
  else{
    prin("No");
  }
  
  return 0;
}


Measured memory_bytes: 9344
//just to test if this works

#include <iostream>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
int N;
long long W, weight[110], value[110]; // 品物の個数は 100 個なので少し余裕持たせてサイズ 110 に

// DPテーブル
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DPループ
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {

            // i 番目の品物を選ぶ場合
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // i 番目の品物を選ばない場合
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // 最適値の出力
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#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(){
	
	string Nstr;
	
	cin >> Nstr;
	
	ll sum = 0;
	
	for(int i = 0;i < Nstr.length();i++){
		
		sum = sum + stoi(Nstr.substr(i,1));
		
	}
	
	if( sum % 9 == 0 ){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
	
	return 0;
	
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/








int N;
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    int ans = N / 3;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        String[] data = in.readLine().split(" ");
        int[] xs = new int[data.length];
        for (int i = 0; i < data.length; i++) {
            xs[i] = Integer.parseInt(data[i]);
        }
        int ans = 0;
        for (int i = 0; i < xs.length; i++) {
            for (int j = i + 1; j < xs.length; j++) {
                for (int k = j + 1; k < xs.length; k++) {
                    if (xs[i] == xs[j] || xs[i] == xs[k] || xs[j] == xs[k]) continue;
                    if (isTriangle(xs[i], xs[j], xs[k])) {
                        ans++;
                    }
                }
            }
        }
        System.out.println(ans);
    }

    private static boolean isTriangle(int a, int b, int c) {
        return (a + b > c) && (a + c > b) && (b + c > a);
    }
}


Measured memory_bytes: 33180