akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

struct DICE {
	
	int top;
	int bottom;
	int east;
	int west;
	int north;
	int south;
	
};
typedef struct DICE Dice;

Dice makeDice(int a[]);
Dice toEast(Dice dice);
Dice toWest(Dice dice);
Dice toNorth(Dice dice);
Dice toSouth(Dice dice);

void printDice(Dice dice) {
	printf("N:%d, E:%d, S:%d, W:%d, top:%d, bottom:%d\n", dice.north, dice.east, dice.south, dice.west, dice.top, dice.bottom);
}

int main() {
	int i;
	int a[6];
	char numbers[31];
	char orders[102];
	
	fgets(numbers,sizeof(numbers), stdin);
	sscanf(numbers, "%d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]);
	Dice dice = makeDice(a);
	
//	printDice(dice);
	
	fgets(orders, sizeof(orders), stdin);
	
	
	for (i = 0; i < strlen(orders); i++) {
		if (orders[i] == 'E') {
			dice = toEast(dice);
		} else if (orders[i] == 'W') {
			dice = toWest(dice);
		} else if (orders[i] == 'N') {
			dice = toNorth(dice);
		} else if (orders[i] == 'S') {
			dice = toSouth(dice);
		}
		
//		printDice(dice);
	}
	
	printf("%d\n", dice.top);
	
	return 0;
}

Dice makeDice(int a[]) {
	
	Dice dice;
	
	dice.top = a[0];
	dice.south = a[1];
	dice.east = a[2];
	dice.west = a[3];
	dice.north = a[4];
	dice.bottom = a[5];
	
	return dice;
	
}

Dice toEast(Dice dice) {
	
	int temp = dice.top;
	
	dice.top = dice.west;
	dice.west = dice.bottom;
	dice.bottom = dice.east;
	dice.east = temp;
	
	return dice;
}

Dice toWest(Dice dice) {
	
	int temp = dice.top;
	
	dice.top = dice.east;
	dice.east = dice.bottom;
	dice.bottom = dice.west;
	dice.west = temp;
	
	return dice;
	
}

Dice toNorth(Dice dice) {
	
	int temp = dice.top;
	
	dice.top = dice.south;
	dice.south = dice.bottom;
	dice.bottom = dice.north;
	dice.north = temp;
	
	return dice;
	
}

Dice toSouth(Dice dice) {
	
	int temp = dice.top;
	
	dice.top = dice.north;
	dice.north = dice.bottom;
	dice.bottom = dice.south;
	dice.south = temp;
	
	return dice;
	
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string S;
    cin >> S;
    vec A(26, 0);

    REP(i,0,SZ(S)) ++A[S[i]-'a'];
    bool f = true;
    REP(i,0,26) {
        if(A[i] == 0) {
            PR((char)('a'+i));
            f = false;
            break;
        }
    }
    if(f) PR("None");

    return 0;
}

/*



*/

Measured memory_bytes: 3760
S = str(input())
T = str(input())
dif = len(S) - len(T) + 1
lis = []

for i in range(dif):
  ng = 0
  S_new = S[i:i+len(T)]
  for j in range(len(T)):
    if S_new[j] != T[j]:
      ng += 1
  lis.append(ng)
print(min(lis))

Measured memory_bytes: 8968
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];int b[n];
  for(int i=0;i<n;i++){
    b[i]=0;
  }
  for(int i=0;i<n;i++){
    cin >>a[i];
  }
sort(a,a+n);int ans=0;int c=1;
for(int i=0;i<n;i++){
  if(a[i]==a[i+1]){
    c++;
  }
  else{
    if(c%2) {
      ans++;
    }
    c=1;
  }
}
cout << ans<<endl;
}


Measured memory_bytes: 1024
(N,M,P),*E=[list(map(int,s.split()))for s in open(0)]
D=[0]*2+[-9e9]*N
def f():
	for _ in D:
		for (a,b,c)in E:D[b]=max(D[b],D[a]+c-P)
f()
s=D[N]
f()
print([max(s,0),-1][s<D[N]])

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

int main() {
  int g[]={-1,0,2,0,1,0,1,0,0,1,0,1,0};
  int a,b;
  cin >> a >> b;
  cout << ( g[a]==g[b] ? "Yes" : "No" ) << '\n';
  return 0; 
}


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

typedef long long ll;
const int N = 5;
const string march = "MARCH";

ll n, ans, cnt[N];
string s;

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	while(n--) {
		cin >> s;
		for (int i = 0; i < N; i++)
			if(s[0] == march[i])
				cnt[i]++;
	}
	for (int i = 0; i < N; i++)
		for (int j = i + 1; j < N; j++)
			for (int k = j + 1; k < N; k++)
				ans += cnt[i] * cnt[j] * cnt[k];
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
from math import gcd
N=int(input())
A=list(map(int, input().split()))


A=sorted(A)
gcda=A[0]
gcdais=True
gcdb=A[0]
MAX=max(A)
counts=[0]*MAX
counts[A[0]-1]+=1
for i in range(1,N):
    
    a=A[i]
    gcdb=gcd(gcdb, a)
    counts[a-1]+=1

for i in range(1,MAX):
    count=0
    now=i+1
    while now<=MAX:
        if counts[now-1]!=0:
            count+=counts[now-1]
        now+=(i+1)
    if count>=2:
        gcdais=False
    #print(count)
    
#print(counts)
if gcdais:
    print("pairwise coprime")
elif gcdb==1:
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 202524
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();

		S = S.replaceAll("eraser", "");
		S = S.replaceAll("erase", "");
		S = S.replaceAll("dreamer", "");
		S = S.replaceAll("dream", "");



		if (S.length() == 0){
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

		sc.close();
	}
}

Measured memory_bytes: 16200
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    string S;
    cin >> S;

    bool f = true;
    REP(i, S.size()) {
        if (i & 1) {
            f &= (S[i] != 'R');
        } else {
            f &= (S[i] != 'L');
        }
    }

    if (f) print("Yes");
    else print("No");
    
}


Measured memory_bytes: 3624
n, m = [int(x) for x in input().split()]
l = [0] * m
r = [0] * m
for i in range(m):
    l[i], r[i] = map(int, input().split())

L = max(l)
R = min(r)

if L <= R:
    print(R - L + 1)
else:
    print(0)

Measured memory_bytes: 10868
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        int a = Integer.parseInt(st.nextToken());
        int p = Integer.parseInt(st.nextToken());
        System.out.println((a*3+p)/2);
    }

}
/*

 */

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
vector<vector<ll>> tree;
vector<ll> c;
vector<ll> ans;
queue<ll> q;


void dfs(ll t,ll p){
    ll n = q.front();q.pop();
    ans[t] = n;
    for(ll child:tree[t]){
        if(child == p){
            continue;
        }
        dfs(child,t);
    }

}

int main() {
    ll N;
    cin >> N;
    tree.resize(N);
    for(int i=0;i<N-1;i++){
        ll a,b;
        cin >> a >> b;
        --a;--b;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    c.resize(N);
    for(int i=0;i<N;i++){
        cin >> c[i];
    }
    sort(c.rbegin(),c.rend());
    ll num =0;
    q.push(c[0]);
    for(int i=1;i<N;i++){
        num += c[i];
        q.push(c[i]);
    }
    cout << num << endl;
    ans.resize(N);
    dfs(0,-1);
    for(int i=0;i<N;i++){
        cout << ans[i] <<" ";
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 4432
n, X = map(int, input().split())
x = input().split()
x = [int(m) for m in x]

z = x
z.append(X)
z.sort()

w = []

for i in range(n + 1):
    if i != 0:
        w.append(z[i] - z[i - 1])

n1=len(w)

#ユークリッド互除法の関数の定義
def gcd(a,b):
    if b==0:
        return a
    return gcd(b,a%b)


if n1==1:
    print(w[0])
else:
    element = gcd(w[0], w[1])
    if n1==2:print(element)
    else:
        for i in range(2,n1):
            element=gcd(element,w[i])
        print(element)

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

using ll = long long;

ll gcd(ll a, ll b) {
	while(b) {
		ll tmp = b;
		b = a % b;
		a = tmp;
	}
	return a;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll a, b;
	cin >> a >> b;
	ll ans = a*b / gcd(a, b);
	cout << ans << endl;
}


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


int main() {
    string S;
    cin >> S;
    int ans = -1;
    int cnt = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            cnt++;
        }else{
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
long double pi=3.14159265358979323846L;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m;cin>>n>>m;
    ll kai[n+1];
    fill(kai,kai+n+1,0);
    ll ans=0;
    ll cnt=0;
    rep(i,0,m){
        ll p;cin>>p;
        string s;cin>>s;
        if(s=="AC"){
            if(kai[p]>=0){
                ans+=kai[p];
                cnt++;
                kai[p]=-1;
            }
        }
        else{
            if(kai[p]>=0)kai[p]++;
        }
    }
    cout<<cnt<<" "<<ans<<endl;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define ll long long

template<class T>
void changeMax(T&a, const T b){if(a < b) a = b;}
template<class T>
void changeMin(T&a, const T b){if(a > b) a = b;}


template<class T>
void changeIdxMax(T&a, const T b, int&i, int j){
  if(a < b){
    a = b;
    i = j;
  }
}
template<class T>
void changeIdxMin(T&a, const T b, int&i, int j){
  if(a > b){
    a = b;
    i = j;
  }
}




int main(){
  ll n; cin   >> n;
  vector<ll> v(n);
  for(auto&&e:v)cin >> e;
  int x = v[0];
  for(int i = 1; i < n; ++i)
    if(i % 2)x -= v[i];
    else x += v[i];

  cout << x;
  int pre = x; 
  for(int i = 1; i < n; ++i){
    pre = v[i - 1] - (pre/2);
    pre *= 2;
    cout << ' ' << pre;
  }
  cout << endl;
    
  return 0;
}


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

int main() {
  int64_t N,K,sum;
  sum = 0;
  cin >> N >> K;
  vector<int64_t>vec(N+2,0);
  if(K==1){
    vec.at(0)=N+1;
    for(int64_t i = 2;i<N+2;i++){
      vec.at(i)=((i*(2*N-i+1)-(i*(i-1)))/2)+1;
    }
    for(int64_t i = 0;i<N+2;i++){
      sum += vec.at(i);
    }
  }
  else if(K>1){
    for(int64_t i = K;i<N+2;i++){
      vec.at(i)=((i*(2*N-i+1)-(i*(i-1)))/2)+1;
    }
    for(int64_t i = 0;i<N+2;i++){
      sum += vec.at(i);
    }
  }
  cout << sum % 1000000007LL <<endl;
    
}



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

int main() {
  int i, j, printi, l, num=0, flag, temp;
  int array[100];

  scanf("%d", &l);
  for(i=0 ; i<l ; i++) {
    scanf("%d", &array[i]);
  }

  flag = 1;
  while(flag) {
    flag = 0;

    for(j=l-1 ; j>0 ; j--) {
      if(array[j] < array[j-1]) {
	temp = array[j-1];
	array[j-1] = array[j];
	array[j] = temp;

	flag = 1;
	num++;
      }
    }
  }

  for(printi = 0 ; printi < l; printi++) {
    printf("%d", array[printi]);
    if(printi != l-1) printf(" ");
  }
  printf("\n");

  printf("%d\n", num);
  
  return 0;
}



Measured memory_bytes: 2756
while True:
    n=int(input())
    if n == 0: break

    ans=-1e100
    l=[]

    for _ in range(n):
        l.append(int(input()))
    for i in range(n):
        s=0
        for j in range(i,n):
            s+=l[j]
            if ans < s: ans = s
    print(ans)

Measured memory_bytes: 6784
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

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

const ll MOD=1000000007;


int main(void)
{
	int n, k;

	while(scanf("%d%d", &n, &k)==2)
	{
		vi a(n);
		vi c(2000+1);
		ll a1=0, a2=0;

		for(int i=0;i<n;i++) scanf("%d", &a[i]);
		for(int i=n-1;i>=0;i--)
		{
			for(int j=a[i];j<=2000;j++) c[j]++;
			a1+=c[a[i]-1];
		}

		for(int i=0;i<n;i++)
		{
			a2+=c[a[i]-1];
		}
//		printf("a1=%lld a2=%lld\n", a1, a2);
		ll x=(k*(k-1LL)/2)%MOD;
		ll ans=(a1*k+a2*x)%MOD;

		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#define INF 10000000000
#define MOD 1000000007
using namespace std;
using ll = long long;
int main() {    
    ll cnt[4]={};
    for(ll i=0;i<3;i++){
        ll x,y;
        cin >> x >> y;
        x--;y--;
        cnt[x]++;
        cnt[y]++;
    }
    bool ans = false;
    for(ll i=0;i<4;i++){
        if(cnt[i]==3){
            ans = true;
        }
        if(cnt[i]==0){
            ans = true;
        }
    }
    if(ans==true){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, X;
    cin >> N >> X;
    int m = 1000000, s = 0;
    for(int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        s += tmp;
        m = min(tmp, m);
    }
    cout << N + (X - s) / m << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
const int maxn=10000+5;
int n,q;
int p[maxn],r[maxn];
void init(int n)
{
    for(int i=0;i<n;i++)
    {
        p[i]=i;
        r[i]=0;
    }
}
int fnd(int x)
{
    if(x==p[x]) return x;
    return p[x]=fnd(p[x]);
}
bool is_same(int x,int y)
{
    x=fnd(x);
    y=fnd(y);
    return x==y;
}
void unite(int x,int y)
{
    x=fnd(x);
    y=fnd(y);
    if(r[x]>r[y])
    {
        p[y]=x;
    }
    else
    {
        p[x]=y;
        if(r[x]==r[y]) r[y]++;
    }
}
int main()
{
//    freopen("in.txt","r",stdin);
    scanf("%d%d",&n,&q);
    int op,x,y;
    init(n);
    while(q--)
    {
        scanf("%d%d%d",&op,&x,&y);
        switch(op)
        {
        case 0:
            {
                unite(x,y);
                break;
            }
        case 1:
            {
               printf("%d\n",is_same(x,y)?1:0);

                break;
            }
        }
    }
    return 0;

}

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

int main(){
  int n;
  cin>>n;
  int max=0;
  int sum=0;
  int tmp;
  for(int i=0;i<n;i++){
    cin>>tmp;
    if(max<tmp)max=tmp;
    sum+=tmp;
  }

  sum-=(int)(max/2);

  cout<<sum<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			while(sc.hasNextLine()){
				
				String s = sc.nextLine();
				if(s.equals("")) break;
				
				int JOI=0;
				int IOI=0;
				for(int i=0;i<s.length();i++) {
					if(s.indexOf("JOI",i)!=-1) {
						JOI++;
						i=s.indexOf("JOI",i)+1;
					}
				}
				
				for(int i=0;i<s.length();i++) {
					if(s.indexOf("IOI",i)!=-1) {
						IOI++;
						i=s.indexOf("IOI",i)+1;
					}
				}
		
				System.out.println(JOI);
				System.out.println(IOI);
			}
		}
	}

}




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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(3,0);
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[x-1]++;
    }
    int N=n+5;
    double dp[N][N][N];
    //dp[i][j][k]:1枚の皿がi枚、2枚の皿がj枚、3枚の皿がk枚あったときの期待値
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++)dp[i][j][k]=0;
        }
    }
    for(int k=0;k<N-1;k++){
        for(int j=0;j<N-1;j++){
            for(int i=0;i<N-1;i++){
                if(i==0&&j==0&&k==0)continue;
                dp[i][j][k]=n;
                if(i!=0)dp[i][j][k]+=dp[i-1][j][k]*i;
                if(j!=0)dp[i][j][k]+=dp[i+1][j-1][k]*j;
                if(k!=0)dp[i][j][k]+=dp[i][j+1][k-1]*k;
                dp[i][j][k]/=(i+j+k);
            }
        }
    }
    cout<<setprecision(20)<<dp[a[0]][a[1]][a[2]]<<endl;
}


Measured memory_bytes: 221952
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
    
    string s,t;
    ll i,ans=0;
    cin>>s>>t;
    for(i=0;i<s.length();i++)
    {
    	if(s[i]!=t[i]) ans++;
    }
    cout<<ans;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e5 + 5;

void solve(){
	int n, k;
	scanf("%d%d", &n, &k);
	printf("%d\n", (n - 1 + k - 2) / (k - 1));
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
// 12/11/2016
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

string s;

ll has[30];

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> s;
	
	for (int i=0; i<sz(s); i++) {
		has[s[i] - 'a']++;
	}
	
	ll n = sz(s);
	ll ans = n * (n + 1) / 2ll;
	for (int i=0; i<26; i++) if (has[i]) {
		ans -= (has[i] * (has[i] + 1)) / 2ll;
	}
	
	cout << ans + 1;


}


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

#define ll long long
#define rep(i,N) for(ll i=0; i<N; i++)
const int mx = 2e5;
const ll llmx = 2e18;

int main(void){
  
  ll N,M,X;
  cin >> N >> M >> X;
  ll books[12][13];
  rep(i,N){
    rep(j,M+1){
      cin >> books[i][j];
    }
  }
  vector<int> kekka;
  int chishiki[M];
  ll mokuhyou = pow(2,N);
  for(int i=0; i<mokuhyou; i++){
    rep(k,M) chishiki[k] = 0;
    ll cost=0;
    
    for(int j=0; j<N; j++){
      if(i&(1<<j)){
        //cout << "1";
        cost+=books[j][0];
        rep(k,M) chishiki[k]+=books[j][1+k];
      }else{
        //cout << "0";
      }
    }
    
    bool oboeta=true;
    for(int l=0; l<M; l++){
      //cout << chishiki[l] << " ";
      if(chishiki[l]<X) oboeta =false;
    }
    //cout << "\n";
    
    if(oboeta) kekka.push_back(cost);
    //cout << "\n";
  }
  
  ll min=llmx;
  rep(i,kekka.size()){
    //cout << kekka[i] << "\n";
    if(kekka[i]<min) min = kekka[i];
  }
  if(min==llmx){
    cout << -1;
  }else{
    cout << min;
  }
  
  return 0;
}


Measured memory_bytes: 4132
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h;//高さ
  int w;//横幅
  cin >> h >> w;

  string board[50];

  for(int i = 0; i < h; ++i) {
    cin >> board[i];
  } 

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

  for(int i = 0; i < h; ++i) {
    for(int j = 0; j < w; ++j) {
      if(board[i][j] == '#') continue;

      int num = 0;
      for(int d = 0; d < 8; ++d) {
        const int ni = i + dx[d];
        const int nj = j + dy[d];
        if(ni < 0 or h <= ni) continue;
        if(nj < 0 or w <= nj) continue;
        if(board[ni][nj] == '#') num++;
      }
      board[i][j] = char(num + '0');
    }
  }
  for(int i = 0; i < h; ++i) {
    cout << board[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 3640
// g++ -std=gnu++1y -O2 -I/opt/boost/gcc/include -L/opt/boost/gcc/lib -o ./a.out ./X.cpp & a.out //
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ull unsigned long long


using namespace std;

int h[100005];

vector<int> adj[100005];

int main()
{
    ios_base::sync_with_stdio(false);	
    cin.tie(NULL); cout.tie(NULL);
    
    int n, m; cin >> n >> m;
    
    for(int i = 1; i < n+1; i++)
    {
		int x; cin >> x;
		h[i] = x;
	}
	
	for(int i = 0; i < m; i++)
	{
		int u, v; cin >> u >> v;
		
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int ans = 0;
	for(int i = 1; i < n+1; i++)
	{
		int ok = true;
		for(int v : adj[i])
		{
			if(h[v] >= h[i]) ok = 0;
		}
		if(ok) ans++;
	}
	
	cout << ans << '\n';
    
    
    return 0;
}



Measured memory_bytes: 9136
import java.util.*;
import static java.lang.System.*;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  
	  int N = sc.nextInt();
	  int M = sc.nextInt();
	  long [] DP = new long[N + 1]; //動的計画法

	  for(int i=0; i<M; i++) {
		  int n = sc.nextInt();
		  DP[n] = -1;
	  }
	  DP[0] = 1;
	  if(DP[1] != -1)DP[1] = 1;
	  else DP[1] = 0;
	  
	  for(int i=2; i<=N; i++) {
		  if ( DP[i] == -1) DP[i] = 0;
		  else {
			  DP[i] = DP[i-1] + DP[i-2];
			  DP[i] %= 1000000007;
		  }
	  }
	  long ans = DP[N] % 1000000007;
	  out.println(ans);
  }
}

Measured memory_bytes: 47696
n,m = map(int,input().split())
l = [1]*(n+1)
#kubaru_dp = [1]*n

for i in range(m):
    a = int(input())
    l[a] = 0

# l = [1,1,1,0,1,1,1]
for i in range(2,n+1):
    if l[i]==0:
        continue
    l[i] = (l[i-1]+l[i-2])%(10**9+7)
else:
    print(l[-1]%(10**9+7))


Measured memory_bytes: 6900
#include <cstdio>

using namespace std;

inline int suit_to_id(char c) {
  switch (c) {
    case 'S':
      return 0;
    case 'H':
      return 13;
    case 'C':
      return 26;
    case 'D':
      return 39;
  }
  // should not reach here
  return 0;
}

inline char id_to_suit(int i) {
  switch (i) {
    case 0 ... 12:
      return 'S';
    case 13 ... 25:
      return 'H';
    case 26 ... 38:
      return 'C';
    case 39 ... 51:
      return 'D';
  }
  // should not reach here
  return 'S';
}

int main() {
  // 0..12 => S1..S13
  // 13..25 => H1..H13
  // 26..38 => C1..C13
  // 39..51 => D1..D13
  char bits[8] = {0};

  int n;
  scanf("%d\n", &n);

  char c;
  int x;
  for (int i = 0; i < n; ++i) {
    scanf("%c %d\n", &c, &x);
    const int offset = suit_to_id(c);
    const int bitpos = offset + x - 1;
    bits[bitpos / 8] |= (1 << (bitpos % 8));
  }

  for (int i = 0; i < 52; ++i) {
    int y = 1 << (i % 8);
    if (!(bits[i/8] & y)) {
      const char s = id_to_suit(i);
      const int v = i - suit_to_id(s) + 1;
      printf("%c %d\n", s, v);
    }
  }

  return 0;
}

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

int main() {
  int a;

  // 変数aで入力を受け取る
  cin >> a;

  if (a%2 == 0) {
    cout << a/2 << endl;
  }
  else {
    cout << a/2 + 1 << endl;
  }
    
}

Measured memory_bytes: 256
N,M,Q = map(int,input().split())
S = [[0]*(N+1) for _ in range(N+1)]
ans = [0]*Q

for i in range(M):
    l,r = map(int,input().split())
    S[l][r] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        S[i][j] += S[i-1][j]+S[i][j-1]-S[i-1][j-1]

for i in range(Q):
    p,q = map(int,input().split())
    ans[i] = S[q][q] - S[p-1][q] - S[q][p-1] + S[p-1][p-1]

print("\n".join(map(str,ans)))

Measured memory_bytes: 23816
// {{{
// vim:filetype=cpp foldmethod=marker foldmarker={{{,}}}
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
#define MP  make_pair
#define PB  push_back
using namespace std;
typedef long long ll;

int vx[]={1,0,-1,0},vy[]={0,1,0,-1};
// }}}

vector<int> par,rank;
vector<pair<int,pair<int,int> > > edge;
int find(int n){
    if(par[n]==n) return n;
    else return par[n]=find(par[n]);
}
void unite(int a,int b){
    int pa=find(a),pb=find(b);
    par[pa]=pb;
//    if(pa==pb) return;
//    if(rank[pa]>rank[pb]) swap(pa,pb);
//    par[pa]=pb;
//    if(rank[pa]==rank[pb]) rank[pb]++;
}
int main(){
    int n,m;
    for(;;){
        scanf("%d\n",&n);
        if(n==0) break;
        scanf("%d\n",&m);
        int a,b,d;
        edge=vector<pair<int,pair<int,int> > >(m);
        for(int i=0;i<m;i++){
            scanf("%d,%d,%d\n",&a,&b,&d);
            d=d/100-1;
            edge[i]=MP(d,MP(a,b));
        }
        par=vector<int>(n);
        rank=vector<int>(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
        sort(ALL(edge));
        int ret=0;
        for(int i=0;i<edge.size();i++){
            int a=edge[i].second.first,b=edge[i].second.second,d=edge[i].first;
            if(find(a)!=find(b)){
                ret+=d;
                unite(a,b);
            }
        }
        printf("%d\n",ret);
    }
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        int n = sc.nextInt();
        int data[][] = new int[n][20];
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            for (int j = 0; j < 20; j++) {
                data[i][j] = a % 2;
                a /= 2;
            }
        }

        for (int i = 0; i < 20; i++) {
            int end1 = n - 1;
            int end2 = n - 1;
            for (int j = n - 1; j >= 0; j--) {
                if (data[j][i] == 1) {
                    end1 = end2;
                    end2 = j - 1;
                    data[j][i] = end1;
                } else {
                    data[j][i] = end1;
                }
            }
        }

        long ans = 0;
        for (int i = 0; i < n; i++) {
            ans += ((Arrays.stream(data[i]).min().getAsInt() - i) + 1);
        }

        System.out.println(ans);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        new Main().main(sc);
        sc.close();
    }
}


Measured memory_bytes: 113104
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define LL long long;
#define ULL unsigned long long;
using namespace std;

int main() {
	long n,t,s=0,u=0,v=0;
	cin>>n>>t;
	int a[n];
	REP(i,n) {
		cin>>a[i];
	}

	s = a[0];
	FOR(i,1,n) {
		if(0 > a[i] - s) {
			s = a[i];
		} else if(u == a[i] - s) {
			v++;
		} else if(u < a[i] - s) {
			u = a[i] - s;
			v = 0;
		}
	}

	cout << v + 1 << endl;
}

Measured memory_bytes: 640
#!/usr/bin/python3

n = int(input())
a = list(map(int, input().split()))

counts = {}

for ai in a:
    if ai in counts:
        counts[ai] += 1
    else:
        counts[ai] = 1

tbcomb = 0
for k in counts:
    c = counts[k]
    if c >= 2:
        tbcomb += c * (c - 1) // 2

for i in range(n):
    c = counts[a[i]]
    if c == 1:
        print(tbcomb)
    elif c == 2:
        print(tbcomb - 1)
    else:
        print(tbcomb - (c * (c - 1) // 2) + ((c - 1) * (c - 2) // 2))


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

int func(int, int, int, int);

int main()
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    cout << func(a, b, c, x) << endl;
}

int func(int a, int b, int c, int x)
{
    if (x < 0 || a < 0 || b < 0 || c < 0) {
        return 0;
    } else if (x == 0) {
       return 1;
    } else {
        return func(a - 1, b, c, x - 500) + func(0, b - 1, c, x - 100) + func(0, 0, c - 1, x - 50);
    }
}


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

int N, M, X;
vector<int> C, E;
vector<vector<int>> A;

int main()
{
  cin >> N >> M >> X;
  C.resize(N);
  E.resize(M, 0);
  A.resize(N, vector<int>(M));
  for (int i = 0; i < N; i++)
  {
    for (int j = -1; j < M; j++)
    {
      int n;
      cin >> n;
      if (j == -1)
      {
        C.at(i) = n;
      }
      else
      {
        A.at(i).at(j) = n;
      }
    }
  }
  int min_cost = 10000000, tmp;
  for (int bit = 0; bit < (1 << N); bit++)
  {
    for (int j = 0; j < M; j++)
    {
      E.at(j) = 0;
    }
    tmp = 0;
    for (int i = 0; i < N; i++)
    {
      if (bit & (1 << i))
      {
        tmp += C.at(i);
        for (int j = 0; j < M; j++)
        {
          E.at(j) += A.at(i).at(j);
        }
      }
    }
    bool flag = true;
    for (int j = 0; j < M; j++)
    {
      if (E.at(j) < X)
      {
        flag = false;
        break;
      }
    }
    if (flag)
    {
      min_cost = min(min_cost, tmp);
    }
  }
  if (min_cost == 10000000)
  {
    min_cost = -1;
  }
  cout << min_cost << endl;
}



Measured memory_bytes: 3648
from scipy.sparse import*
n,*t=map(int,open(0).read().split())
c=sorted(t[-n:])
f=[1]*n
for i in csgraph.depth_first_order(csr_matrix((f[1:],(t[:-n:2],t[1:-n:2])),[n+1]*2),1,0,0):n-=1;f[i-1]=c[n]
print(sum(c[:-1]),*f)

Measured memory_bytes: 29112
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2

using namespace std;

int MOD = 1000000007;
string s;


signed main(){

    cin >> s;

    int ans = 1000010;
    rep(i,s.size()-1){
        if(s[i] != s[i+1]){
            ans = min(ans,max((int)(i+1),(int)(s.size()-(i+1))));
        }
    }
    if(ans == 1000010){
        cout << s.size() << endl;
      return 0;
    }

    cout << ans << endl;

    
    return 0;
}
// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl 

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less

#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define FASTIO ios::sync_with_stdio(0); cin.tie(0);
#define show(x) cerr << #x << " = " << x << "\n"
#define mem( a , b ) memset( a , b , sizeof a )
#define popcnt(x) __builtin_popcount(x)
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define SZ(a) (int)a.size()
#define ll  long long
#define ld  long double
#define vii vector  <ll>
#define dqi deque   <ll>
#define sii set     <ll>
#define vpi vector  <pii>
#define mii map     <ll,ll>
#define pii pair    <ll,ll>
#define pi  pair    <int,int>
#define pb  push_back
#define F   first
#define S   second
#define L   length()
#define OO  (ll)1e18
#define EPS 1e-9
using namespace std;
using namespace __gnu_pbds;
void ONLINE__JUDGE();

typedef tree<ll, null_type, less<ll>, rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
pii swapii( pii pr ){ return { pr.S , pr.F }; }
ll binEXP( ll x , ll pw , ll MOD = LLONG_MAX );
int dx[] = {  0 ,  0 , -1 , +1 , -1 , +1 , -1 , +1 };
int dy[] = { -1 , +1 ,  0 ,  0 , -1 , +1 , +1 , -1 };

const ll MOD = 1e9 + 7;
const ll MAX = 1e2 + 9;

ll x ; multiset<ll> s; vii vec;
int main()
{
    FASTIO// ONLINE__JUDGE();

    cin >> x;
    for ( int i = 0; i < x; i++ )
    {
        ll j; cin >> j; s.insert(j);
        vec.pb(j);
    }

    for ( ll i : vec ){
        auto it = s.find(i);
        s.erase(it);
        cout << *s.rbegin() << "\n";
        s.insert(i);
    }
    return 0;
}


void ONLINE__JUDGE()
{
    #ifndef ONLINE_JUDGE
    freopen( "inp.c"         , "r" , stdin  );
    //freopen( "OutPut.txt"   , "w" , stdout );
    #endif // ONLINE_JUDGE
}

ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }


Measured memory_bytes: 12528
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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; }

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	string s;
	cin >> s;
	int a[50000] = {};
	for (int i = 0; i < 4; i++) {
		a[s.at(i)]++;
	}
	int cnt = 0;
	for (int i = 0; i < 50000; i++) {
		if (a[i] == 2) cnt++;
	}
	ansYes(cnt == 2);
}


Measured memory_bytes: 384
// In The Namw Of Allah
#include <bits/stdc++.h>
using namespace std;

const int N = 2e5 + 10;
typedef pair <int, int> pii;
typedef long long ll;

int a[N];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)	cin >> a[i];
	sort(a, a + n);
	if(a[n - 1] - a[0] > 1)
		cout << "No\n";
	else {
		if(a[n - 1] == a[0]) {
			if(a[0] == n - 1 || a[0] * 2 <= n)	cout << "Yes\n";
			else	cout << "No\n";
		}
		else {
			int c = 0;
			for (int i = 0; i < n; i++)
				c += (a[i] == a[0]);
			int t = n - c;
			if(a[n - 1] <= c + t / 2 && a[n - 1] > c)	cout << "Yes\n";
			else	cout << "No\n";
		}
	}
}

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

#define FOR(i,a,n) for (int i = a; i < (int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define whole(f,x,...) ([&](decltype((x)) whole) { \
    return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
template<typename T> bool chmin(T &a, const T &b) {if (a > b) { a = b; return true; }return false;}
template<typename T> bool chmax(T &a, const T &b) {if (a < b) { a = b; return true; }return false;}

using ll = int_fast64_t;

constexpr ll INF = (1e9);
constexpr ll MOD = (1e9+7);

int main() {
  ll n, m; cin >> n >> m;
  if (n < m) swap(n, m);
  if (n == 1) cout << 1 << endl;
  else if (m == 1) cout << n-2 << endl;
  else cout << (m-2)*(n-2) << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

ll mod = 998244353;
vector<int> x;
int a[301];

int main(int, char**)
{
	ll a, b, t, x, ans = 0;
	cin >> a >> b >> t;

	x = a;
	for (int i = 1; x <= t; i++) {
		if (i > t) break;
		ans += b;
		x += a;
	}

	cout << (b * (t / a))<< endl;
	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
priority_queue<int>q;
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=k;i++) scanf("%d",&a[i]);
    sort(a+1,a+1+k);
    for(int i=2;i<=k;i++) q.push(a[i]-a[i-1]);
    n--;
    while(!q.empty()&&n--) q.pop();
    int ss=0;
    while(!q.empty()) ss+=q.top(),q.pop();
    cout<<ss<<endl;
}


Measured memory_bytes: 1276
def resolve():
    n=int(input())
    d,x=map(int, input().split())
    l=[int(input()) for i in range(n)]
    tabeta=0
    for i in range(n):
        cnt=1
        while cnt<=d:
            cnt+=l[i]
            tabeta+=1
    print(x+tabeta)

resolve()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S;
    cin >> S;
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'A'){
            cnt++;
            if(ans < cnt){
               ans = cnt;
            }
        }
        else if(S[i] == 'C'){
            cnt++;
            if(ans < cnt){
               ans = cnt;
            }
        }
        else if(S[i] == 'G'){
            cnt++;
            if(ans < cnt){
               ans = cnt;
            }
        }
        else if(S[i] == 'T'){
            cnt++;
            if(ans < cnt){
               ans = cnt;
            }
        }
           else{
            cnt = 0;
            }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3568
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring> 
#include <sstream>
#include <algorithm>
#include <cstdlib>
 
using namespace std;
 
int func(string str, int cnt);
 
string InToString(int number);
 
int main()
{
    int Q, ans;
    string str;
    cin >> Q;
    for(int i = 0; i < Q; i++){
        cin >> str;
        ans = func(str, 0);
        cout << ans << endl;
        }
    return 0;
}
 
int func(string str, int cnt)
{
    int l = (int)str.size();
    if(l < 2) return cnt;
    else {
        string a, b;
        int c, d, e;
        int max = 0;
        for(int j = 1; j < l; j++){
            a = str.substr(0, j);
            b = str.substr(j, l-j);
            c = stoi(a);
            d = stoi(b);
            e = c * d;
            if(e > max) max = e;
        }
        cnt++;
        return func(InToString(max), cnt);
    }
}
 
string InToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
inline ll read() {
    ll x=0,f=1; char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())
        if(ch=='-')f=-f;
    for(;ch>='0'&&ch<='9';ch=getchar())
        x=x*10+ch-'0';
    return x*f;
}
inline void chkmin( int &a,int b ) { if(a>b) a=b; }
inline void chkmax( int &a,int b ) { if(a<b) a=b; }
#define _ read()
const ll mod = 1e9+7;
int n; ll f[105][5][5][5][5];
inline bool judge2( int a,int b,int c) { return a==1&&b==2&&c==3; }
inline bool judge( int a,int b,int c ) {
	return (a==1&&b==2&&c==3)||(a==1&&b==3&&c==2)||(a==2&&b==1&&c==3);
}
inline bool check( int a,int b,int c,int d ) {
	return !(judge(a,b,c)||judge(b,c,d)||judge2(a,c,d)||judge2(a,b,d));
}
int main() {
	n=_;
	// int res=0;
	// for( int i=1;i<=4;i++ )
	// 	for( int j=1;j<=4;j++ )
	// 		for( int k=1;k<=4;k++ ) 
	// 			if(check(i,j,k,0));else ++res;
				// cout<<res<<"\n";
	if(n==3) cout<<61; 
	else {
		for( int i=1;i<=4;i++ )
		for( int j=1;j<=4;j++ ) 
		for( int k=1;k<=4;k++ ) 
		for( int l=1;l<=4;l++ ) 
		if(check(i,j,k,l)) f[4][i][j][k][l]=1;
		for( int i=5;i<=n;i++ ) {
			for( int j=1;j<=4;j++ )
			for( int k=1;k<=4;k++ ) 
			for( int l=1;l<=4;l++ ) 
			for( int p=1;p<=4;p++ ) 
			for( int q=1;q<=4;q++ ) 
			if(check(j,k,l,p)&&check(k,l,p,q)) 
				f[i][k][l][p][q]=(f[i][k][l][p][q]+f[i-1][j][k][l][p])%mod;
		}
		ll res=0;
		for( int i=1;i<=4;i++ )
		for( int j=1;j<=4;j++ ) 
		for( int k=1;k<=4;k++ ) 
		for( int l=1;l<=4;l++ ) 
		if(check(i,j,k,l)) {
			res=(res+f[n][i][j][k][l])%mod;
			// printf("%d %d %d %d\n",i,j,k,l);
		}
		cout<<res<<"\n";
	}
}

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

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		String S;
		Scanner sc = new Scanner(System.in);
		S = sc.next();
		char s_3;
		char s_4;
		char s_5;
		char s_6;
		s_3 = S.charAt(2);
		s_4 = S.charAt(3);
		s_5 = S.charAt(4);
		s_6 = S.charAt(5);
		if (s_3 == s_4) {
			if (s_5 == s_6) {
				System.out.println("Yes");
			} else
				System.out.println("No");
		} else
			System.out.println("No");
	}

}

Measured memory_bytes: 23252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b;
    cin >> a >> b;

    int num = a + b;
    if(a % 3 == 0 || b % 3 == 0 || num % 3 == 0){
        p("Possible");
    }else{
        p("Impossible");
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;
    double tmpa, tmpb;
    tmpa = 30 * h + 0.5*m;
    tmpb = 6 * m;//固定
    double k;
    k = abs(tmpa - tmpb);
    k = min(360 - k, k);
    //cout << k << endl;
    double res;
    k = (k * M_PI)/180;
    res = a*a + b*b - 2*a*b*cos(k);
    //cout << cos(k) << endl;
    //cout << res << endl;
    res = sqrt(res);
    cout << fixed << setprecision(20) <<res << endl;

}

Measured memory_bytes: 4224