akhauriyash/Code-Regression huggingface dataset:
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

r = load()

print(2 * r * math.pi)

Measured memory_bytes: 9460
import itertools as iter

def main():
    n, k = list(map(int, input().split()))
    p = [0]
    p.extend(list(iter.accumulate([(1+int(x))/2 for x in input().split()])))
    #print(p)
    
    s = []
    for i in range(n-k+1):
        s.append(p[i+k]-p[i])
    #print(s)
    print(max(s))
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 23616
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public Main(int opt1, int opt2) {
		Map<Integer, Integer> map = new HashMap<>();
		map.put(1, 1);
		map.put(2, 2);
		map.put(3, 3);
		map.remove(opt1);
		map.remove(opt2);
		String res = map.values().toString();
		System.out.println(res.substring(1,2));

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int opt1 = sc.nextInt();
		int opt2 = sc.nextInt();
		Main m = new Main(opt1, opt2);

	}
	
}


Measured memory_bytes: 22612
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


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


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

s = list(map(int, input()))
cnt = 0
# print(s)
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        if s[i] == 0:
            s[i+1] = 1
            cnt += 1
        if s[i] == 1:
            s[i+1] = 0
            cnt += 1
print(cnt)


Measured memory_bytes: 45148
# 範囲の絞り込みが甘い場合の、所要時間を調べるためのテストコード
N, Y = gets.split.map(&:to_i)

for yukichi in 0..N
	for higuchi in 0..N
		noguchi = N - yukichi - higuchi
		next if noguchi < 0

		if yukichi*10000 + higuchi*5000 + noguchi*1000 == Y
			print "#{yukichi} #{higuchi} #{noguchi}"
			exit
		end
	end
end

print "-1 -1 -1"

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

int main() {
  string a,b; cin >>a >>b;
  bool ans = false;
  if (a.at(0)==b.at(2) && a.at(1)==b.at(1) && a.at(2)==b.at(0)){
    ans = true;
  }
  
  //cout <<ans <<endl;
  
  if (ans) cout <<"YES" <<endl;
  else cout <<"NO" <<endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)

void printVec(std::vector<int> & vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec1(std::vector<string>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}
void printVec2(std::vector<Int>& vec)
{
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it)
	{
		std::cout << *it << " ";
	}
	cout << '\n';
}

Int gcd(Int a, Int b)
{
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b)
{
	return a / gcd(a, b) * b;
	//a*bは64bit integer overflow
}

bool integer(double num)
{
	return floor(num) == num;
}

Int fact(int num)
{
	if (num == 0)
		return 1;
	else
		return num * fact(num - 1);
}

int main() {
	Int n,k;cin >> n >> k;
	
	vector<int> a(n), b;
	for (int i = 0; i <n;i++){
		cin >> a[i];
	}
	Int cnt = 0,cnt2=0;
	Int ans = 0;
	for (int i = 0; i <n;i++){
		int num = a[i];
		cnt = 0;
		cnt2 = 0;
		for (int j = i+1; j <n;j++){
			if(num>a[j])cnt++;
		}
		for (int k = 0; k <n;k++){
			if(num>a[k])cnt2++;
		}
		// ans += (cnt% MOD) * k % MOD;
		// ans += (cnt2% MOD) * k*(k-1)/2 % MOD;//WA
		ans += k * cnt % MOD;
		ans += k * (k - 1) / 2 % MOD * cnt2 % MOD;//WA

		// ans += k * (k - 1) / 2 % MOD * cnt2 % MOD + k * cnt % MOD;//AC
		ans%=MOD;
	}

	cout << ans;

	cout << endl;
	return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
n = int(input())
def f(l,m):
    if m == []:
      return l
    else:
      m2 = []
      for s in m:
          y,x = s[0],s[1]
          l[y][x] = '0'
          for i in range(y-3,y+4):
              if 0<=i<=7 and l[i][x] == '1':
                  m2.append((i,x))
          for i in range(x-3,x+4):
              if 0<=i<=7 and l[y][i] == '1':
                  m2.append((y,i))
      return f(l,m2)
c = 0
while n > 0:
    c += 1
    input()
    l = []
    for i in range(8):
      l.append([j for j in input()])
    x = int(input())-1
    y = int(input())-1
    a = f(l,[(y,x)])
    print('Data ' + str(c) + ':')
    for i in a:
      b = ''
      for j in i:
        b += j
      print(b)
    n -= 1

Measured memory_bytes: 7768
#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 rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n,m,x;
    cin >> n >> m >> x;
    int fr=0,ba=0;
    rep(_,m) {
        int a;
        cin >> a;
        if(a < x) fr++;
        else ba++;
    }
    cout << min(ba,fr) << endl;
}


Measured memory_bytes: 256
from collections import Counter
N=int(input())
S=[input() for i in range(N)]
if 'AC' in S:
    print('AC','x',Counter(S)['AC'])
else:
    print('AC','x',0)
if 'WA' in S:
    print('WA','x',Counter(S)['WA'])
else:
    print('WA','x',0)
if 'TLE' in S:
    print('TLE','x',Counter(S)['TLE'])
else:
    print('TLE','x',0)
if 'RE' in S:
    print('RE','x',Counter(S)['RE'])
else:
    print('RE','x',0)

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

int main() {
  int N,K,A=0;
  string S;
  cin >> N >> K >> S;
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    if(S[i] == S[i+1]){
      A ++;
    }
  }
  while(K > 0 && A < N-1){
    if(N - 2 == A && K > 0){
      A += 1;
      break;
    }
    A += 2;
    K --;
  }
  cout << A <<endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, n) for (int i = 0; i < ((int)(n)); i++) // 0-indexed昇順

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size() << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;
    string A, B;
    cin >> A >> B;
    for(int i=0; i<N; i++){
        cout << A.at(i) << B.at(i); 
    }
    cout << endl;
}

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

using namespace std;

int x, a, b, n;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> x >> a >> b >> n;
	string s;
	for(int i = 0; i < n; i++){
		cin >> s;
		if(s == "nobiro") x = max(0, x+a);
		if(s == "tidime") x = max(0, x+b);
		if(s == "karero") x = 0;
	}
	cout << x << endl;
	
	return 0;
}


Measured memory_bytes: 3216
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int N=16;
inline void MOD(int &x) {if (x>=mod) x-=mod;}
int power_mod(int a,int b) 
{
	int ans=1;
	while (b)
	{
		if (b&1) ans=(ll)ans*a%mod;
		a=(ll)a*a%mod;
		b>>=1;
	}
	return ans;
}





int n,m,A[20],up,jc[(1<<N)+5],ny[(1<<N)+5];
int C(int n,int m) 
{
	if (n<m) return 0;
	return (ll)jc[n]*ny[m]%mod*ny[n-m]%mod;
}
int dp[20][(1<<N)+5],bit[(1<<N)+5];



int main()
{
	scanf("%d%d",&n,&m);
	up=1<<n;
	for (int i=1;i<=m;i++) scanf("%d",&A[i]);
	
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for (int i=2;i<=up;i++) 
	jc[i]=(ll)jc[i-1]*i%mod,ny[i]=(mod-mod/i)*ny[mod%i]%mod;
	for (int i=2;i<=up;i++) ny[i]=(ll)ny[i-1]*ny[i]%mod;
	
	
	
	//puts("");
	
	dp[m+1][0]=1;
	for (int i=m+1;i>=2;i--) 
		for (int s=0;s<up;s++) if (dp[i][s]) 
		{
			MOD(dp[i-1][s]+=dp[i][s]);
			for (int x=0;x<n;x++) if (!(s&(1<<x))) 
			MOD(dp[i-1][s|(1<<x)]+= 
			(ll)dp[i][s] * C( up-A[i-1]-s , (1<<x)-1 ) %mod ); 
		}
	
	int ans=0,tmp;
	for (int s=0;s<up;s++) 
	{
	//	printf("dp[%d]=%d\n",s,dp[1][s]);
		
		bit[s]=bit[s>>1]+(s&1);
		tmp=(ll)dp[1][s]*jc[up-s-1]%mod;
		for (int i=0;i<n;i++) if (!(s&(1<<i))) tmp=(ll)tmp*ny[1<<i]%mod;
		if (bit[s]&1) MOD(ans+=mod-tmp);else MOD(ans+=tmp);
	}
	
	ans=(ll)ans*up%mod;
	for (int i=0;i<n;i++) ans=(ll)ans*jc[1<<i]%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4608
N, K = map(int, input().split())
S = list(input()+"X")

temp = S[0]
cnt = 1
c_cnt = 1
ans = 0

for i in range(1, N+1):
  if temp == S[i]:
    cnt += 1
  else:
    ans += cnt - 1
    cnt = 1
    c_cnt += 1
    temp = S[i]
  #print(ans, cnt, c_cnt, temp)

#最後の余計な分
c_cnt -= 1

if c_cnt//2 <= K:
  if c_cnt%2 == 0:
    ans += (c_cnt//2) * 2 - 1
  else:
    ans += (c_cnt//2) * 2
else:
  ans += K * 2

print(ans)

Measured memory_bytes: 4084
// Example program
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    char s[5], t[5];
    
    cin.get(s,5);
    cin.get();
    cin.get(t,5);
    
    int cnt=0;
    
    
    for (int i=0; i<3; i++)
    if (s[i]==t[i]) cnt++;
    
    cout<<cnt;
}


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

int main() {
  int w;
  string s;
  cin >> s;
  cin >> w;
  for (int i = 0; i < s.size(); i++) {
    if (i%w == 0) {
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  lli x,k,d;
  cin>>x>>k>>d;
  if(abs(x)/d>=k){
      cout<<abs(x)-k*d;
  }else {
      lli xx=x%d;
      lli yy=min(abs(xx+d),abs(xx-d));
      lli c=(xx-x)/d;
      if((k-c)%2) cout<<abs(yy);
      else cout<<abs(xx);
  }
  nline;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
  int N;
  cin>>N;
  int sum=0;
  rep(i,N){
  if((i+1)%3!=0 && (i+1)%5!=0){
    sum+=i+1;
  }
  }
  cout<<sum;
}


Measured memory_bytes: 3632
///int ->(-2147483648<->2147483647)
///unsigned int(0<->4294967295)
///long long int (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)
///unsigned long long int (0 to 18,446,744,073,709,551,615)
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stdio.h>
#include<map>
#include<math.h>
#include<algorithm>
#include<string>
#include<utility>
#include<stack>
#include<cstring>
#include<iterator>
#include<unordered_map>
#include<unordered_set>
#include<set>
#include<iomanip> ///setprecision
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define OPEN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","r",stdin)
#define INF 1000000000
#define ll long long
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define pdd pair<double,double>
#define vi vector<int>
#define vll vector<long long>
#define vc vector<char>
#define vd vector<double>
#define sci(value) scanf("%d%*c",&value)
#define scl(value) scanf("%lld%*c",&value)
#define pi  (2*acos(0))
#define pb push_back
#define valid(value123,value234,limitrow,limitcol) value123>=0&&value123<limitrow&&value234>=0&&value234<limitcol
//int fx[]= {0,0,1,-1,-1,1,-1,1};//kings move
//int fy[]= {1,-1,0,0,-1,1,1,-1};//kings move
//int fx[]={-2,-2,-1,-1, 1,1, 2,2};  // Knights Move
//int fy[]={-1, 1,-2, 2,-2,2,-1,1}; // Knights Move
//ll powFunction(ll a,ll b){if(b==0)return 1;ll re=powFunction(a,b/2);re=(re*re);if(b&1)re=(re*a);return re;}
///ll digitSum(ll a){ll ans=0;while(a){ans+=(a%10);a/=10;}return ans;}

#define MX 100005
#define mod 1000000007
struct data
{
    int a,b,c;
}arr[MX];
int dp[MX][3];
int main()
{
    int n;
    sci(n);
    for(int i=0;i<n;i++)
    {
        sci(arr[i].a),sci(arr[i].b),sci(arr[i].c);
    }
    dp[0][0]=arr[0].a;
    dp[0][1]=arr[0].b;
    dp[0][2]=arr[0].c;
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1]+arr[i].a,dp[i-1][2]+arr[i].a);
        dp[i][1]=max(dp[i-1][0]+arr[i].b,dp[i-1][2]+arr[i].b);
        dp[i][2]=max(dp[i-1][0]+arr[i].c,dp[i-1][1]+arr[i].c);
    }
    printf("%d\n",max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])));
}




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

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

  vector<int> t(N);
  for (int i = 0; i < N; i++) cin >> t.at(i);

  long long tot = T;
  for (int i = 0; i < N - 1; i++) {
    tot += min(T, t.at(i + 1) - t.at(i));
  }

  cout << tot << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
int main(){
	int n,a[101],A=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n-1;i++){
		for(int j=0;j<n-i-1;j++){
			if(a[j]<a[j+1]){
				int x=a[j];
				a[j]=a[j+1];
				a[j+1]=x;
			}
		}
	}
	if(n%2==1){
		a[n]=0;
		n++;
	}
	for(int i=0;i<n/2;i++){
		A+=a[2*i]-a[2*i+1];
	}
	printf("%d\n",A);
}


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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll X;
  cin >> X;
  int ans = 0;
  ll now = 100;
  while (now < X)
  {
    now *= 1.01;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3652
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
bool red[100005];
int num[100005];
int main(){
  int N,M;
  cin>>N>>M;
  FOR(i,0,N){
    num[i] = 1;
    if(i==0) red[i] = true;
    else red[i] = false;
  }
  FOR(i,0,M){
    int x,y;
    cin>>x>>y;
    x--;y--;
    num[x]--;
    num[y]++;
    if(red[x]){
      red[y] = true;
      if(num[x]==0){
        red[x] = false;
      }
    }
  }
  int ans = 0;
  FOR(i,0,N){
    if(red[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

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

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

    s.erase(unique(s.begin(), s.end()), s.end());
    cout << s.size() << endl;

    return 0;
}

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

int n, x;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> x;
	if(2 <= x && x <= 2*(n-1)){
		cout << "Yes\n";
		if(x <= n){
			for(int i=n; i>=2; --i){
				if(i == x) continue;
				cout << i << "\n";
			}
			cout << x << "\n" << 1 << "\n";
			for(int i=n+1; i<=2*n-1; ++i)
				cout << i << "\n";
		}else{
			for(int i=1; i<=n-1; ++i)
				cout << i << "\n";
			cout << 2*n-1 << "\n" << x << "\n";
			for(int i=n; i<=2*n-2; ++i){
				if(i == x) continue;
				cout << i << "\n";
			}
		}
	}else{
		cout << "No\n";
	}
}

Measured memory_bytes: 1536
#include <iostream>
#include <cassert>

int main()
{
  int N;
  std::cin >> N;
  assert(1 <= N and N <= 100);

  std::string s;
  std::cin >> s;
  // s.insert(s.begin(), '-');
  // assert(s.length() == 1 + N);
  assert(static_cast<int>(s.length()) == N);

  int numR = 0;
  int numB = 0;
  for (auto v : s) {
    if (v == 'R')
      ++numR;
    else if (v == 'B')
      ++numB;
    else
      assert(false);
  }
  if (numR > numB)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

//cost_map[vertex] pll -> <to, cost>
bool bellman_ford(ll s, vector<vector<pll>>& cost_map, vector<ll>& result){
    ll N = cost_map.size();
    vector<ll> d(N, MAXINF);
    d[s] = 0;
    REP(k, N){
        REP(i, N){
            if(d[i]==MAXINF)continue;
            for(auto&& v : cost_map[i]){
                if(d[v.fi] > d[i] + v.se){
                    d[v.fi] = d[i] + v.se;
                    if(k==N-1)
                        return false;
                }
            }
        }
    }
    result = d;
    return true;
}

int main(void)
{
    int N,M,P;
    cin >> N >> M >> P;
    vector<vector<pll>> cost(N);
    vector<vector<int>> m(N);
    REP(i, M){
        int a,b,c;
        cin >> a >> b >> c;
        a--;b--;
        cost[a].pb(pll(b, -c+P));
        m[b].pb(a);
    }

    //ゴールに到達できない頂点を削除
    // Rep(i, 1, N-1){
    //     queue<int> q;
    //     q.push(i);
    //     vector<int> ok(N, 0);
    //     while(!q.empty()){
    //         auto f = q.front();q.pop();
    //         ok[f] = 1;
    //         for(auto&& i : cost[f]){
    //             if(ok[i.fi])continue;
    //             q.push(i.fi);
    //         }
    //     }
    //     if(!ok[N-1]){
    //         cost[i].clear();
    //         break;
    //     }
    // }
    queue<int> q;
    q.push(N-1);
    vector<int> ok(N, 0);
    while(!q.empty()){
        auto f = q.front();q.pop();
        ok[f] = 1;
        for(auto&& i : m[f]){
            if(ok[i]) continue;
            q.push(i);
        }
    }
    REP(i, N){
        if(!ok[i])
            cost[i] = vector<pll>();
    }

    vector<ll> res;
    if(bellman_ford(0, cost, res)){
        if(res[N-1]>0) {
            pr(0);
        }else{
            pr(-res[N-1]);
        }
    }else{
        pr(-1);
    }
}

Measured memory_bytes: 5888
n, k = map(int, input().split())
a = [0] + [int(i) for i in input().split(" ")]
b = [0,1] + [0]*(n-1)
c = [1]
nex = 1
for i in range(1,n+1):
    nex = a[nex]
    if b[nex] == 1:
        whe = c.index(nex)
        lo = len(c)-whe
        break
    b[nex] = 1
    c.append(nex)
if whe+1 >= k:
    print(c[k])
else:
    k_ = k - whe
    print(c[whe:][k_%lo])

Measured memory_bytes: 32284
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))

using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };


ll m = 1000000007;

const int MOD = 1000000007;

ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}



long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}

int a[100];
int main() {
	m0(a);
	int N, M;
	cin >> N >> M;
	REP(i, M) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		a[x]++; a[y]++;
	}
	REP(i, N) {
		cout << a[i] << endl;
	}
}


Measured memory_bytes: 256
n = int(input())
Taro = 0
Hanako = 0
for i in range(n):
    A,B = input().split()
    if A > B:
        Taro += 3
    elif A < B:
        Hanako += 3
    elif A == B:
        Taro += 1
        Hanako += 1
print(Taro,Hanako)


Measured memory_bytes: 5596
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.fi << ", " << p.se << ']';
	return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
	cout << "{ ";
	for (const auto &v : c)
		cout << v << ' ';
	cout << '}' << ln;
}

const int N = 2e6 + 5;
long long inv[N], fact[N], ifact[N];
void pre()
{
	inv[1] = fact[0] = fact[1] = ifact[0] = ifact[1] = 1;
	for (int i = 2; i < N; i++)
	{
		inv[i] = mul(MOD - MOD / i, inv[MOD % i], MOD);
		fact[i] = mul(i * 1ll, fact[i - 1], MOD);
		ifact[i] = mul(inv[i], ifact[i - 1], MOD);
	}
	return;
}

long long nCr(long long n, long long r)
{
	if (n >= 0 && r >= 0 && n >= r)
		return mul(fact[n], mul(ifact[r], ifact[n - r], MOD), MOD);
	return 0;
}

void solve()
{
	ll r1, c1, r2, c2;
	cin >> r1 >> c1 >> r2 >> c2;
	pre();
	ll ans = 0;
	for (ll i = r1; i < r2 + 1; i++)
		ans = add(ans, add(nCr(i + c2 + 1, i + 1), MOD - nCr(i + c1, i + 1), MOD), MOD);
	cout << ans << ln;
	return;
}

int main()
{
	FASTIO;
#ifdef file_input
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	clock_t start, stop;
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
#ifdef measure_time
	start = clock();
#endif
	for (int tc = 1; tc < t + 1; tc++)
		solve();
#ifdef measure_time
	stop = clock();
	cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
	return 0;
}


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

int main(void){
    std::string S, s1, s2;
    int N, N1;
    std::cin >> S;
    N = S.size();
    bool flag = true;
    while(flag){
        for(int i=0; i<(N-1)/2; i++){
            if(S[i] != S[N-i-1]){
                std::cout << "No" << std::endl;
                //return -1;
                flag = !flag;
                break;
            }
        }
        if(!flag){
            break;
        }
        s1 = S.substr(0, (N-1)/2);
        //std::cout << s1 << std::endl;
        N1 = s1.size();
        if(N1 == 1){
            std::cout << "Yes" << std::endl;
            return 0;
        }else if(N1 % 2 == 0){
            for(int i=0; i<N1/2; i++){
                if(s1[i] != s1[N1-i-1]){
                    std::cout << "No" << std::endl;
                    //return -1;
                    flag = !flag;
                    break;
                }   
            }
        }else{
            for(int i=0; i<(N1-1)/2; i++){
                if(s1[i] != s1[N1-i-1]){
                    std::cout << "No" << std::endl;
                    //return -1;
                    flag = !flag;
                    break;
                }
            }
        }
        if(flag){
            std::cout << "Yes" << std::endl;
            flag = !flag;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List

solve :: [Int] -> Int
solve (x:xs) = x + sum (map conv xs)
  where conv x = 10 * ceiling (fromIntegral x / 10)

compareItems :: Int -> Int -> Ordering
compareItems i1 i2
  | c1 == c2 = EQ
  | c1 < c2 = LT
  | otherwise = GT
  where conv x = if x `mod` 10 == 0 then 10 else x `mod` 10
        c1 = conv i1
        c2 = conv i2

main :: IO ()
main = do
  items <- replicateM 5 readLn
  print . solve $ sortBy compareItems items

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
int x[100010];
int n,k,ans=999999999;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%d",&x[i]);
	for(int i=0;i+k<=n;i++){
		int l=x[i];
		int r=x[i+k-1];
		ans=min(ans,r-l+min(abs(l),abs(r)));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int n, a;
    cin >> n >> a;
    
    cout << n*n - a << endl;
    
    return 0;

}

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

int main () {
  int a, b;
  cin >> a >> b;
  int ans = 0;
  rep(i, 2) {
    if (b > a) swap(a, b);
    ans += a;
    a--;
  }
  cout << ans << endl;
  return 0;
}

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

long long N;
int main(){
	long long maxi = 0;
	long long curnum = 0;
	long long height = 0;
	cin >> N;

	for(long long i = 0; i < N; i++){
		long long tmp;
		cin >> tmp;
		if(height >= tmp){
			curnum++;
			height = tmp;
		} else {
			maxi = max(maxi, curnum);
			curnum = 0;
			height = tmp;
		}
	}
	maxi = max(maxi, curnum);

	cout << maxi << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	
bool pairComparesecond(const p& firstElof, const p& secondElof)
{
    return firstElof.second > secondElof.second;
}

ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int main(){
	ll a,b;
	cin>>a>>b;
	if(b%a==0)cout<<a+b<<endl;
	else cout<<b-a<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

ll a[10101010];

ll f(ll a){
    return (1+a)*a/2;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    ll ans = 0;
    for(int i=1;i<=n;i++){
        ans += (i*f(n/i));
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		try {
			int n = sc.nextInt();

			System.out.println(n * 800 - (int)(n / 15) * 200);

		} finally {
			sc.close();
		}
	}
}

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

int main() {
	int n,m,a[100]={0},i,j,k,x,y;
	cin>>n>>m;
	for(i=1;i<=n;i++)
	{
	    cin>>k;
	    for(j=1;j<=k;j++)
	    {
	        cin>>x;
	        a[x]+=1;
	    }
	}
	y=0;
	for(i=1;i<=m;i++)
	 if(a[i]==n)
	 y++;
	cout<<y;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using Graph = vector<VecP>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) > (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define R cin>>
#define i64 unsigned long long
#define repr(i, n) REPR(i, n, 0)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define in(a) insert(a)
#define P(p) cout<<(p)<<endl;
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SORT(a) sort((a).begin(), (a).end())
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll mod = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
template<typename T> void co(T e){cout << e << "\n";}
template<typename T> void co(const vector<T>& v){for(const auto& e : v)
    { cout << e << " "; } cout << "\n";}
ll gcd(ll a, ll b) {
    if (a < b)swap(a, b);
    if (b == 0) return a;
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a * b / g;
}
bool prime(ll n) {
    for (ll i = 2; i <= sqrt(n); i++) {
        if (n%i == 0)return false;
    }
    return n != 1;
}


int pow(ll x, ll y, ll mod){
    ll ret=1;
    for(;y;y>>=1,x=1ll*x*x%mod){
        if(y&1) ret=1ll*ret*x%mod;
    }
    return ret;
}
void kill()
{
    cout << -1 << endl;
    exit(0);
}

int main() {
    sonic();
    int next, prev, total, i, t, n;
    i64 ans=0;
    R n;
    priority_queue<pii> q;
    vi A(n), B(n);
    rep(i, n)R A[i];
    rep(i, n){
        R B[i];
        q.push(make_pair(B[i], i));
    }
    while(0<q.size()) {
        i = q.top().second;
        q.pop();
        if(B[i]==A[i])continue;
        if(B[i]<A[i])kill();
        next = (i + 1 + n) % n;
        prev = (n + i - 1) % n;
        total = B[next] + B[prev];
        t = (B[i] - A[i]) / total;
        if(t==0)kill();
        ans += t;
        B[i] -= t * total;
        q.push(make_pair(B[i], i));
    }
    cout << ans << endl;
}


Measured memory_bytes: 6904
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s,t;
    cin >> s>> t;
    cout << t << s << endl;
    return 0;
}

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

void a_iai(void) {
	char c;
	cin >> c;
	string judge = "vowel";
	if ((c != 'a') && (c != 'e') && (c != 'i') && (c != 'o') && (c != 'u')) judge = "consonant";
	cout << judge << endl;
}

int main()
{
	a_iai();
    return 0;
}

Measured memory_bytes: 3588
// Problem : A - Guess The Number
// Contest : Virtual Judge - Showdown
// URL : https://vjudge.net/contest/391413#problem/A
// Memory Limit : 1048 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


/*ヽ｀、ヽ｀｀、ヽ｀ヽ｀、、ヽ ｀ヽ 、ヽ｀MOON｀ヽヽ｀ヽ、ヽ｀
ヽ｀、ヽ｀｀、ヽ 、｀｀、 ｀、ヽ｀ 、｀ ヽ｀ヽ、ヽ ｀、ヽ｀｀、
ヽ、｀｀、｀、ヽ｀｀、 、ヽヽ｀、｀、、ヽヽ、｀｀、 、 ヽ｀、 
ヽ｀｀、 ヽ｀ヽ｀、、ヽ ｀ヽ 、 MANヽ｀｀｀｀ヽヽヽ｀、、ヽ｀、、ヽ*/

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N,M;
	cin>>N>>M;
	vi ans(N,-1);
	F0R(x,M)
	{
		int in,val;
		cin>>in>>val;
		in--;
		if(ans[in]!=-1 && ans[in]!=val)
		{
			cout<<-1;
			return 0;
		}
		ans[in]=val;
	}
	if(N==1)
	{
		if(ans[0]==-1)
			ans[0]=0;
		cout<<ans[0];
		return 0;
	}
	if(ans[0]==0)
		cout<<-1;
	else
	{
		if(ans[0]==-1)
			ans[0]=1;
		cout<<ans[0];
		FOR(x,1,N)
		{
			if(ans[x]==-1)
				ans[x]=0;
			cout<<ans[x];
		}
	}
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


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

int main() {
  ll N, M;
  cin >> N >> M;

  ll ans = min(N, M / 2);
  ll tmp = M - 2 * ans;
  if (tmp > 3)
    ans += tmp / 4;
  cout << ans << endl;
}

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

using namespace std;

int main()
{
	int N, D,ans=0;

	cin >> N >> D;

	double x, y;

	for (int i = 0; i < N; i++){
		cin >> x >> y;
		double j = sqrt(x*x+y*y);
		if (j <= D)
			ans++;
	}
	
	cout << ans;

}

Measured memory_bytes: 3816
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    
    int a[n];
    vector<int> b(n);
    
    long long sum = 0;
    for(int i=0 ; i<n ; i++){
        cin >> a[i];
        b[i] = a[i] - (i+1);
        
        sum += b[i];
    }
    
    sort(b.begin(),b.end());
    
    int cen = b[n/2];
    
    long long res = 0;
    for(int i=0 ; i<n ; i++){
        res += abs(b[i] - cen);
    }
    
    
    cout << res << endl;
}


Measured memory_bytes: 1792
def main():
    n, a, b, c, d = map(int,input().split())
    s = list(input())
    if c<d:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        print('Yes')
    else:
        for i in range(a-1,c-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return
        for i in range(b-1,d-2):
            if s[i] == s[i+1] and s[i] == '#':
                print('No')
                return

        for i in range(b-1,d):
            if s[i-1] == s[i] == s[i+1] and s[i] == '.':
                print('Yes')
                return


        print('No')



if __name__ == '__main__':
    main()


Measured memory_bytes: 4868
#include <stdio.h>
int main(void){
  int a,b;
  scanf("%d%d\n",&a,&b);
  if(a<=0&&0<=b)printf("Zero");
  else if(0<=a)printf("Positive");
  else if(b<0&&(b-a)%2==0)printf("Negative");
  else if(b<0&&(b-a)%2==1)printf("Positive");
    
   return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
typedef long long ll;

int n, m, p;
vector<pair<int, int> > v[2501];
ll cost[2501];

int main() {
  cin >> n >> m >> p;
  rep(i, 0, m) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    v[a].pb(mp(b, -(c - p)));
  }
  fill(cost, cost + n, LLONG_MAX);
  cost[0] = 0;
  rep(loop, 0, 2 * n) {
    bool update = false;
    rep(i, 0, n) {
      if (cost[i] == LLONG_MAX) continue;
      rep(j, 0, (int)v[i].size()) {
        int next = v[i][j].fi;
        ll nextc = cost[i] + v[i][j].se;
        if (cost[next] > nextc) {
          cost[next] = nextc;
          if (loop >= n) {
            cost[next] = -999999999;
          }
          update = true;
        }
      }
    }
    if (update && loop == 2 * n - 1 && cost[n - 1] == -999999999) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << (-cost[n - 1] < 0 ? 0 : -cost[n - 1]) << endl;
}

///////////////////////////////////////////////////////////////////////////////////
// NOTE
///////////////////////////////////////////////////////////////////////////////////
/*
http://sigma1113.hatenablog.com/entry/2019/08/12/130042
嘘解法だったなんて今まで思いもしなかった.
でも、結構綺麗に対処できるからコード量はあんまり変わらないかも.
*/

Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int N;
  int A;
  cin >>N>>A;
  int x=N*N;
  int y=x-A;
  cout << y<< endl;
}
  

Measured memory_bytes: 256
x = input().split()
n = int(x[0]) # n == 比較文字列の長さ
q = int(x[1]) # q == 検討する回数
s = input()

        
t = [0] * n
if s[0] == "A":
    t[0] = 1
    
for i in range(0,n-1):
    if s[i:i+2] == "AC":
        
        if (i == 0) :
            t[i] =  + 1
        else:
            t[i] = t[i-1] + 1
    else :
        if i == 0:
            t[i] = 0
        else:
            t[i] = t[i-1]



def sc():
    global t
    global s
    global n
    global q
    global idbox
    maxx = 0
    count = 0
    com = [int(s)-1 for s in input().split()]
    
    
    print(t[com[1]-1] - t[com[0]-1])
        
    

    

for i in range(q):
    
    sc()


Measured memory_bytes: 6188
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
struct edge{
	int t,next,v;
}g[400001];
int i,j,k,n,m,a[200001],f[200001],d[200001],tot,h[200001];
void addedge(int x,int y){
	g[++tot].t=y;g[tot].next=h[x];h[x]=tot;
	g[++tot].t=x;g[tot].next=h[y];h[y]=tot;
	d[x]++;d[y]++;
}
bool work(int x,int fa){
	if (d[x]==1){
		f[x]=a[x];return 1;
	}
	ll i,j,k;
	for (j=k=0,i=h[x];i;i=g[i].next)
	 if (fa!=g[i].t){
	 	if (!work(g[i].t,x)) return 0;
	 	j+=f[g[i].t];k=max(k,(ll)f[g[i].t]);
	 }
	if (2*a[x]<j||k>a[x]||2*a[x]-j>a[x]) return 0;
	f[x]=2*a[x]-j;
	return 1;
}
int main(){
	scanf("%d",&n);tot=0;memset(h,0,sizeof(h));memset(d,0,sizeof(d));
	for (i=1;i<=n;i++) scanf("%d",&a[i]);
	for (i=1;i<n;i++) scanf("%d%d",&j,&k),addedge(j,k);
	if (n==2){
		puts(a[1]==a[2]?"YES":"NO");
		return 0;
	}
	for (i=1;d[i]==1;i++);
	puts(work(i,0)&&f[i]==0?"YES":"NO");
	return 0;
}

Measured memory_bytes: 12928
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: i64,
    }
    let v = 1000000000;
    let x = (v - s % v) % v;
    let y = (s + x) / v;
    println!("0 0 1000000000 1 {} {}", x, y);

}

Measured memory_bytes: 4352