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

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

    for (int i = 0; i < n; i++)
    {
        cout << s[i] << t[i];
    }
    cout << endl;

    return 0;
    
}

Measured memory_bytes: 256
import sys

def main():
	n = int(input())
	a = list(map(int,input().split()))
	a.sort()
	a = listtodict(a)
	cost=0
	for k,v in a.items():
		if(k!=v):
			cost += v if(v<k) else v-k
	print(cost)

def listtodict(a):
	b = {}
	for i in a:
		try:
			b[i] += 1
		except:
			b[i] = 1
	return b

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()

Measured memory_bytes: 18164
#include<iostream>
#include<string>
using namespace std;
int main(){
	long long n;
	cin>>n;
	long long b=-100000000000;
	long long c=0;
	long long d=100000000000;
	for(int i=0;i<n;i++){
		long long a;
		cin>>a;
		if(a>b){
				b=a;
		}
		if(a<d){
				d=a;
		}
		c+=a;
	}
	cout<<d<<" "<<b<<" "<<c<<endl;
}


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

int main(void){
    string s;
     // 入力
     cin >> s;

     // 隣り合う文字を比較して判定
    bool isgood = true;
    if (s[0] == s[1]) isgood = false;
    if (s[1] == s[2]) isgood = false;
    if (s[2] == s[3]) isgood = false;
    // 出力
    if (isgood) {
    cout << "Good" << endl;
    } else {
    cout << "Bad" << endl; }
    return 0;
}

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

int main()
{
  string w;
  int count = 0;
  cin >> w;
  transform(w.begin(), w.end(), w.begin(), ::tolower);
  while (1)
  {
    string t;
    cin >> t;
    if (t == "END_OF_TEXT")
      break;
    transform(t.begin(), t.end(), t.begin(), ::tolower);
    if (t == w)
      count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3236
#include<iostream>
#include<stdio.h>
using namespace std ;
int numOfCandies[2][102] ;
int path[2][102] ;
int main(){
//freopen("in.txt","r",stdin ) ;
int n ; scanf("%d",&n) ;
for(int i=0 ; i<2 ; i++){
   for(int j=0 ; j<n ; j++){
    scanf("%d",&numOfCandies[i][j]) ;

    }
}
path[0][0]=numOfCandies[0][0] ;
path[1][0]=numOfCandies[1][0]+numOfCandies[0][0] ;
for(int i =1 ; i<n ; i++){
 path[0][i]=path[0][i-1]+numOfCandies[0][i] ;
}
for(int j=1; j<n ; j++ ){

     path[1][j]=max(path[1][j-1],path[0][j])+numOfCandies[1][j] ;
}
printf("%d",path[1][n-1]) ;




}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

from heapq import heappop, heappush

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

q = []
push = lambda x,i: heappush(q, (-x<<30)+i)
for i,x in enumerate(B):
    push(x,i)

answer = 0
mask = (1<<30)-1
while q:
    i = heappop(q)&mask
    x = B[i]
    dx = x-A[i]
    if dx < 0:
        answer = -1
        break
    if dx == 0:
        continue
    left = i-1 if i >= 1 else N-1
    right = i+1 if i < N-1 else 0
    nbd = B[left] + B[right]
    t = dx // nbd
    if t == 0:
        answer = -1
        break
    B[i] -= nbd * t
    answer += t
    push(B[i],i)

print(answer)

Measured memory_bytes: 110932
#include<stdio.h>
#include<string.h>

int main(){
    int b[128]={0},i;
    char s[32];
    scanf("%s",s);
    for(i = 0;i < strlen(s);i++){b[s[i]]++;}
    for(i = 'a';i <= 'z';i++){
        if(b[i] > 1){printf("no\n");return 0;}
    }
    printf("yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
/* ------------------------------------------------ */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ------------------------------------------------ */
int main() {
    int a, b;
    cin >> a >> b;
    if(a  <= 8 && b <= 8) cout << "Yay!" << endl;
    else cout << ":(" << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> v(n);
  int sum=0;
  int mx=0;
  for (int i=0;i < n;i++){
    cin >> v.at(i);
    sum+=v.at(i);
    mx=max(mx,v.at(i));
  }
  if (sum-mx > mx) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}
  

Measured memory_bytes: 256
a = [list(int(i) for i in input().split()) for i in range(3)]
f = [[0 for i in range(3)] for i in range(3)]
n = int(input())
b = []
flag = False

for i in range(n):
  b.append(int(input()))
  
for i in b:
  for j in range(3):
    for k in range(3):
      if i == a[j][k]:
        f[j][k] = 1

if sum(f[0]) == 3 or sum(f[1]) == 3 or sum(f[2]) == 3:
  flag = True

for i in range(3):
  tmp = []
  for j in range(3):
    tmp.append(f[j][i])
  if sum(tmp) == 3:
    flag = True
    
if f[0][0] == 1 and f[1][1] == 1 and f[2][2] == 1:
  flag = True

if f[0][2] == 1 and f[1][1] == 1 and f[2][0] == 1:
  flag = True

if flag == True:
  print("Yes")
else:
  print("No")
  

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n;
    int a[100010], b[100010];
    cin >> n;
    for (int i = 0; i <= n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    int cnt = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] <= b[i])
        {
            cnt += a[i];
            cnt += min(a[i + 1], b[i] - a[i]);
            a[i + 1] -= min(a[i + 1], b[i] - a[i]);
        }
        else
        {
            cnt += b[i];
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define ll long long
int main(){
    int n,k;
    cin>>n>>k;
    int l[50];
    for(int i=0;i<n;i++)cin>>l[i];
    sort(l,l+n);
    int ans=0;
    for(int i=n-1;i>n-1-k;i--)ans+=l[i];
    cout<<ans<<endl;
    return 0;
}



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

#define ff              first
#define ss              second
#define ll            long long

#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void sb()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int main()
{
	//sb();

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



return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;
	int ans = 700;
	for (int i = 0; i < s.size(); i++)
		if (s[i] == 'o')
			ans += 100;

	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
	int N, index = 0;
	cin >> N;
	vector<int> A(N - 1);
	for (int count = 0; count < N - 1; count++)
	{
		cin >> A.at(count);
	}
	sort(A.begin(), A.end());
	for (int count = 0; count < N; count++)
	{
		int counter = 0;
		while (true)
		{
			if (index > N - 2 || A.at(index) != count + 1)
			{
				break;
			}
			else
			{
				counter++;
				index++;
			}
		}
		cout << counter << endl;
	}
}

Measured memory_bytes: 4016
#include<stdio.h>
#include<stdlib.h>
int main()
{
    int a,b,c;
    scanf("%d",&a);
    c=1;
    for(b=1;b<=9;b++)
    {
        if(a==b*c)
            {
                printf("Yes");
                exit(0);
            }
        else
        {
            for(c=1;c<=b;c++)
            {
                if(a==b*c)
                    {
                        printf("Yes");
                        exit(0);
                    }
            }
        }

    }printf("No");
    return 0;
}



Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1

i64 gcd(i64 a, i64 b) { return b ? gcd(b, a % b) : a; }
i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }

template <typename U>
map<U, int> doPrimeFactorization(U n) {

  map<U, int> rs;
  U a = 1;

  while (!(n & 1)) {
    n >>= 1;
    rs[2]++;
  }

  for (U i = 3; i * i <= n; /*NOP*/) {
    auto q = n / i;
    auto r = n - i * q;
    if (r == 0) {
      rs[i]++;
      n = q;
    }
    else {
      i += 2;
    }
  }

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

  return move(rs);
}

// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  int all;
  set<int> ps;

  bool pca = true;

  F0R(i, N) {
    int a;
    cin >> a;
    if (pca) {
      auto pf = doPrimeFactorization(a);
      for (auto& p : pf) {
        if (ps.find(p.first) != ps.end()) {
          pca = false;
          break;
        }
        ps.insert(p.first);
      }
    }

    if (!i) {
      all = a;
    }
    else {
      all = gcd(all, a);
    }
  }

  cout << (pca ? "pairwise coprime" : all == 1 ? "setwise coprime" : "not coprime");
}
#endif


Measured memory_bytes: 7332
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, a[200010];
int d[200010][5];

signed main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> a[i];
	d[0][1] = d[0][2] = d[0][3] = d[0][4] = INF;
	for (int i = 1; i <= n; i++) {
		if (a[i] == 0) {
			d[i][0] = d[i - 1][0];
			d[i][1] = min(d[i - 1][0], d[i - 1][1]) + 2;
			d[i][2] = min({ d[i - 1][0],d[i - 1][1],d[i - 1][2] }) + 1;
			d[i][3] = min({ d[i - 1][0],d[i - 1][1],d[i - 1][2],d[i - 1][3] }) + 2;
			d[i][4] = min({ d[i - 1][0],d[i - 1][1],d[i - 1][2],d[i - 1][3] ,d[i - 1][4] });
		}
		else if (a[i] % 2) {
			d[i][0] = d[i - 1][0] + a[i];
			d[i][1] = min(d[i - 1][0], d[i - 1][1]) + 1;
			d[i][2] = min({ d[i - 1][0],d[i - 1][1],d[i - 1][2] });
			d[i][3] = min({ d[i - 1][0],d[i - 1][1],d[i - 1][2],d[i - 1][3] }) + 1;
			d[i][4] = min({ d[i - 1][0],d[i - 1][1],d[i - 1][2],d[i - 1][3] ,d[i - 1][4] }) + a[i];
		}
		else {
			d[i][0] = d[i - 1][0] + a[i];
			d[i][1] = min(d[i - 1][0], d[i - 1][1]);
			d[i][2] = min({ d[i - 1][0],d[i - 1][1],d[i - 1][2] }) + 1;
			d[i][3] = min({ d[i - 1][0],d[i - 1][1],d[i - 1][2],d[i - 1][3] });
			d[i][4] = min({ d[i - 1][0],d[i - 1][1],d[i - 1][2],d[i - 1][3] ,d[i - 1][4] }) + a[i];
		}
	}
	cout << min({ d[n][0],d[n][1],d[n][2],d[n][3],d[n][4] }) << endl;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  string s;
  cin >> n >> k >> s;
  int diff = 0;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) diff++;
  }
  ll ans = n - 1;
  if (k * 2 > diff) {
    cout << ans << endl;
  } else {
    cout << ans - (diff - 2 * k) << endl;
  }
  return 0;
}


Measured memory_bytes: 512
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()

    if N == 1 and M == 1:
        print(1)
    elif N == 1:
        print(M - 2)
    elif M == 1:
        print(N - 2)
    else:
        print((N - 2) * (M - 2))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10108
ABCD = input()

def calc(calc_str):
    tmp = ""
    x, y = 0, 0
    calc_str = "0+" + calc_str
    for i in calc_str:
        if i == "+":
            tmp = i
        elif i == "-":
            tmp = i
        else:
            y = int(i)
            if tmp == "+":
                x = x + y
            elif tmp == "-":
                x = x - y
    return x

def create(A):
    for i in ("+", "-"):
        for t in ("+", "-"):
            for k in ("+", "-"):
                calc_str = A[0] + i + A[1] + t + A[2] + k + A[3]
                if calc(calc_str) == 7:
                    print(calc_str+"=7")
                    return

create(ABCD)


Measured memory_bytes: 3064
#include <iostream>
//#include <iomanip>
//#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
#include <string>
//typedef long long LL;
using namespace std;

int main(){
    int n;
    int k;
    int r;
    int s;
    int p;
    string t;

    int ans=0;

    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;

    vector<int> history(n+1);
    for(int i=0; i<n; i++){
        if(i<k){
            ans += (t[i]=='r') ? p : (t[i]=='s' ? r : s);
            history[i] = t[i];
        }else{
            if(history[i-k]==t[i]){
                if((i+k)<=n){
                    history[i] = (t[i+k]=='r' ? 's' : (t[i+k]=='s') ? 'p' : 'r');
                }
            }else{
                ans += (t[i]=='r') ? p : (t[i]=='s' ? r : s);
                history[i] = t[i];                
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 896
// 400
fun bd095(args: Array<String>) {
    val numList = args[1].split(" ").map { it.toInt() }
    val max = numList.max()!!
    var x = 0
    var diff = Int.MAX_VALUE
    numList.forEach {
        if (diff > Math.abs((max / 2) - it) && max != it) {
            diff = Math.abs((max / 2) - it)
            x = it
        }
    }
    println("$max $x")
}

fun main(args: Array<String>) {
    bd095(readLineList())
}

fun readLineList(): Array<String> {
    val lineList = mutableListOf<String>()
    while (true) {
        val line = readLine()
        if (line.isNullOrBlank()) {
            break
        } else {
            lineList.add(line!!)
        }
    }
    return lineList.toTypedArray()
}

Measured memory_bytes: 51792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 500000

struct Node{
  int key;
  struct Node *r, *l, *p;
};
void insert(int);
void inOrder(struct Node *);
void preOrder(struct Node *);
struct Node *root, *NIL;

void insert(int n) {
  struct Node *y = NIL;
  struct Node *x = root;
  struct Node *z;

  z = (struct Node *)malloc(sizeof(struct Node));
  z->key = n;
  z->l = NIL;
  z->r = NIL;

  while ( x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->l;
    }
    else{
      x = x->r;
    }
  }
  z->p = y;
  if (y == NIL) {
    root = z;
  }else{
    if (z->key < y->key) {
      y->l = z;
    }else{
      y->r = z;
    }
  }
}
void inOrder(struct Node *v){
  if (v == NIL) {
    return;
  }
  inOrder(v->l);
  printf(" %d",v->key);
  inOrder(v->r);
}
void preOrder(struct Node *v){
  if (v == NIL) {
    return;
  }
  printf(" %d",v->key);
  preOrder(v->l);
  preOrder(v->r);
}

struct Node * find(struct Node *u, int k){
  while (u != NIL && k != u-> key) {
    if(k < u->key ) u = u->l;
    else u = u->r;
  }
  return u;
}

int main() {
  int i,m,z;
  char command[10];
  struct Node *t;
  scanf("%d",&m);
  for (i = 0; i < m ; i++) {
    scanf("%s",command);
    if (command[0] == 'f'){
      scanf("%d",&z);
      struct Node *t = find(root, z);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if (strcmp(command,"insert")==0) {
      scanf("%d",&z);
      insert(z);
    }
    else if (strcmp(command,"print")==0) {
      inOrder(root);
      printf("\n");
      preOrder(root);
      printf("\n");
    }
  }
  return 0;
}



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

using namespace std;

int a, b;
int d[5];

int main()
{
    for(int i = 0; i < 3; ++i)
    {
        cin >> a >> b;
        d[a]++; d[b]++;
    }
    int cnt = 0;
    for(int i = 1; i <= 4; ++i)
    {
        cnt += d[i]&1;
    }
    cout << (cnt <= 2 ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double PI = acos(-1.0), EPS = 1e-10;

int main() {
	int cnt = 0;
	int N; cin >> N;
	rep(i,N) {
		int p; cin >> p;
		bool f = true;
		for(int j = 2; j * j <= p; j++)
			if(p % j == 0) {
				f = false;
				break;
			}
		if(f) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 824
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use std::collections::*;

fn main() {
    input! {
        x:[i32;5]
    }
    let ans = x.iter().enumerate().find(|(_, &n)| n == 0).unwrap().0 + 1;
    println!("{}", ans);
}

Measured memory_bytes: 2108
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, P: "List[int]", C: "List[int]"):
    res = - 10 ** 10
    for i in range(N):
        lmax = - 10 ** 10
        nlmax = 0
        cp = P[i] - 1
        cl = 1
        cs = C[cp]
        css = []
        css.append(cs)
        while cp != i:
            if cs > lmax and cl <= K:
                lmax = cs
                nlmax = cl
            cp = P[cp] - 1
            cl += 1
            cs += C[cp]
            css.append(cs)
        if cs > lmax and cl <= K:
            lmax = cs
            nlmax = cl
        syc = cs
        length = cl
        # nloop = max(0, (K - nlmax) // length)
        nloop = max(0, K // length - 1)
        x = K % length
        if K // length >= 1:
            nokori = lmax
            for j in range(x):
                nokori = max(nokori, syc + css[j])
        else:
            nokori = lmax
        res = max(res, max(lmax, syc * nloop + nokori))
        # print((i, syc, lmax, nlmax, length))
    print(res)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, K, P, C)

if __name__ == '__main__':
    main()

Measured memory_bytes: 83876
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
  int N,K;cin>>N>>K;
  std::vector<int> h(N),dp(N,1e12);
  for(int i=0;i<N;i++)cin>>h[i];
  dp[0]=0;
  for(int i=1;i<N;i++){
    for(int j=1;j<=min(K,i);j++){
      dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout<<dp[N-1]<<endl;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();

        int l = Math.abs(a-c);
        int m = Math.abs(a-b);
        int n = Math.abs(b-c);

        if(l <= d){
            System.out.println("Yes");
        }else{
            if(m <= d && n <= d){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}

Measured memory_bytes: 21844
s = input()
if s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
elif s == "SAT":
  print(1)
else:
  print(7)

Measured memory_bytes: 8996
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
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;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  string s; cin >> s;
  rep(j,4){
    vector<int> v(n,-1);
    if(j==0) {v[0]=1; v[1]=1;}
    if(j==1) {v[0]=1; v[1]=0;}
    if(j==2) {v[0]=0; v[1]=1;}
    if(j==3) {v[0]=0; v[1]=0;}
    bool f=1;
    rep(i,n){
      if(v[i]==1&&s[i]=='o'||v[i]==0&&s[i]=='x'){
        if(i==0) v[n-1]=v[1];
        if(i==n-2){
          if(v[n-3]!=v[n-1]) f=0;
          else continue;
        }
        if(i==n-1&&v[n-2]!=v[0]) f=0;
        if(0<i&&i<n-1) v[i+1]=v[i-1];
      }
      else{
        if(i==0) v[n-1]=1-v[1];
        if(i==n-2){
          if(v[n-3]==v[n-1]) f=0;
          else continue;
        }
        if(i==n-1&&v[n-2]==v[0]) f=0;
        if(0<i&&i<n-1) v[i+1]=1-v[i-1];
      }
    }
    if(f){
      rep(i,n){
        if(v[i]==1) cout << 'S';
        else cout << 'W';
      }cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 1016
h,w,k=[int(j) for j in input().split()]
s=[input() for i in range(h)]
ans=[[0]*w for i in range(h)]
p=1

for i in range(h):
    q=0
    for j in range(w):
        if s[i][j]=="#":
            q+=1
            p+=1
            if q==1:
                p-=1
        ans[i][j]=p
    if q==0:
        for j in range(w):
            ans[i][j]=-1
    if q==1:
        for j in range(w):
            ans[i][j]=ans[i][0]
    p+=1

p=1
q=1
a=[[0 for i in range(w)] for i in range(h)]
for i in range(h):
    if ans[i][0]==-1:
        continue
    for j in range(w):
        if q!=ans[i][j]:
            p+=1
        q=ans[i][j]
        a[i][j]=p

for i in range(h):
    if a[i][0]==0 and i!=0:
        for j in range(w):
            a[i][j]=a[i-1][j]
for i in range(h)[::-1]:
    if a[i][0]==0 and i!=h-1:
        for j in range(w):
            a[i][j]=a[i+1][j]

if a[0][0]!=1:
    p=a[0][0]-1
    for i in range(h):
        for j in range(w):
            a[i][j]-=p
for i in a:
    print(*i)


Measured memory_bytes: 11088
n, c = map(int, input().split())
L = [[0, 0, 0] for _ in range(n)]

rec = []

for i in range(n):
    s, t, c = map(int, input().split())
    c = c-1
    L[i][0] = s
    L[i][1] = t
    L[i][2] = c

L.sort(key=lambda x: x[0])

for i in range(n):
    s = L[i][0]
    t = L[i][1]
    c = L[i][2]
    if i == 0:
        rec.append([c, t])
    else:
        for j in range(len(rec)):
            if rec[j][0] == c and rec[j][1] <= s:
                rec[j][1] = t
                break
        else:
            rec.sort(key=lambda x: x[1])
            for k in range(len(rec)):
                if rec[k][1]+1 <= s:
                    rec[k][0] = c
                    rec[k][1] = t
                    break
            else:
                rec.append([c, t])
#print(rec)
print(len(rec))

Measured memory_bytes: 63136
#include <bits/stdc++.h>
#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 ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main()
{
    int n, t, a, m = 1000000, m_cnt=0;
    cin >> n >> t >> a;
    int h[n];
    REP(i, n){
        cin >> h[i];
        h[i] = abs((t * 1000 - h[i] * 6) - a * 1000);
        m = min(m, h[i]);
        if(m == h[i]) m_cnt = i;
    }
    cout << m_cnt + 1 << endl;
}


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

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

long long MOD = 10000000000 + 7;

int main(){
  cout << setprecision(10);
  map<ll,int> m;
  int N; cin >> N;

  for(int i = 0; i < N; i++){
    ll tmp; cin >> tmp;
    if(m.count(tmp) != 0){
      cout << "NO" << endl;
      return 0;
    }
    m[tmp]++;
  }
  cout << "YES" << endl;
}




Measured memory_bytes: 16052
import java.util.*;
import static java.lang.System.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
int a = Integer.parseInt(sc.next());
String op=sc.next();
int b = Integer.parseInt(sc.next());
if(op.equals("+")){
    out.println(a+b);
}else{
    out.println(a-b);
}
}}

Measured memory_bytes: 21332
#include"bits/stdc++.h"

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

LL modinv(LL a) {
    LL b = MOD, u = 1, v = 0;
    while (b) {
        LL t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

LL moddev(LL a, LL b){
	return a * modinv(b) % MOD;
}

void Main()
{
    LL h,w;cin>>h>>w;

    if(h == 1 || w == 1){
        cout<<1<<endl;
        return;
    }

    cout<<(h*w+1)/2<<endl;

	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,n,ans;cin>>a>>b>>n;
  if(b>n) ans=floor(1.0*a*n/b);
  else ans=floor(1.0*a*(b-1)/b);
  print(ans);
  return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S, T; cin >> S >> T;
  if (S + T.at(T.size() - 1) == T) {
    cout << "Yes\n";
  }else {
    cout << "No\n";
  }

  return 0;
}



Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>

using namespace std;

using ll = long long;
using ui = unsigned int;
const ll MOD = 1000000007;


//A
int main() {
	char S[110];
	ll K;
	scanf("%s", S);
	scanf("%lld", &K);
	ll len = strlen(S);

	ll count[4];
	memset(count, 0, sizeof(count));

	char prev_char = ' ';
	for (ll i = 0; i < std::min(4LL, K); i++) {
		for (int j = 0; j < len; j++) {
			char c = S[j];

			if (c == prev_char) {
				count[i]++;
				prev_char = ' ';
			}
			else {
				prev_char = c;
			}
		}
	}

	ll result = 0;
	if (K <= 4) {
		for (auto val : count) {
			result += val;
		}
	}
	else {
		if (count[0] == count[1] && count[1] == count[2] && count[2] == count[3]) {
			result = count[0] * K;
		}
		else if (count[0] != count[1] && count[1] == count[2] && count[2] == count[3]) {
			result = count[0] + count[1] * (K - 1);
		}
		else if (count[0] != count[1] && count[0] == count[2] && count[1] == count[3]) {
			if (K % 2 == 0) {
				result = (count[0] + count[1]) * (K / 2);
			}
			else {
				result = (count[0] + count[1]) * (K / 2) + count[0];
			}
		}
		else {
			//(T-T
			result = count[0] * K;
		}

	}

	printf("%lld\n", result);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const LL N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
LL maximums[85];
int main()
{
int n,array1[100],i;
scanf("%lld",&n);
for(LL i=0;i<n;++i){
    scanf("%lld",&array1[i]);
}
LL money=1000;
for(i=0;i<n-1;++i){
    if(array1[i]<array1[i+1]){
        LL quantity=money/array1[i];
        money+=(array1[i+1]*quantity);
        money-=(quantity*array1[i]);
    }
}
printf("%lld",money);


    return 0;
}


Measured memory_bytes: 3808
#include <cstdio>
#include <iostream>
#include <vector>

void show_data(std::vector<int>& data)
{
    printf("%d", data[0]);
    for(int i = 1; i < data.size(); i++) {
        printf(" %d", data[i]);
    }
    puts("");
}

void solve(std::vector<int>& data)
{
    show_data(data);
    for(int i = 1; i < data.size(); i++) {
        int supposed_max = data[i];
        int j = i - 1;
        while(0 <= j && supposed_max < data[j]) {
            data[j + 1] = data[j]; // copy to higher index
            j--;
        }
        data[j + 1] = supposed_max;
        show_data(data);
    }
}

int main()
{
    int input_size;
    std::cin >> input_size;
    std::vector<int> data(input_size);
    for(int i = 0; i < data.size(); i++) {
        std::cin >> data[i];
    }

    solve(data);
    return 0;
}

Measured memory_bytes: 3224
#include <bits/stdc++.h>
typedef long long lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define all(a) (a).begin(), (a).end()

using namespace std;

void execute()
{
	int N;
	int input;
	set<int> moti;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> input;
		moti.insert(input);
	}
	cout << moti.size() << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
// agc013_a
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <typeinfo>
#include <unordered_map>
#include <utility>
#include <vector>
#define loop(i, a, b) for (int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define FOR(i, a) for (auto i : a)
#define pb push_back
#define all(in) in.begin(), in.end()
#define shosu(x) fixed << setprecision(x)
#define show1d(v)                                                              \
  rep(i, v.size()) cout << " " << v[i];                                        \
  cout << endl << endl;
#define show2d(v)                                                              \
  rep(i, v.size()) {                                                           \
    rep(j, v[i].size()) cout << " " << v[i][j];                                \
    cout << endl;                                                              \
  }                                                                            \
  cout << endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def, Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def, pii> pip;
typedef vector<pip> vip;
template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int main(int argc, char *argv[]) {
  ll n, cnt = 0, status = 0;
  cin >> n;

  vi a(n);
  rep(i, n) { cin >> a.at(i); }

  rep(i, n - 1) {
    if (status == 0) {
      if (a.at(i) < a.at(i + 1))
        status = 1;
      else if (a.at(i) > a.at(i + 1))
        status = -1;
    } else {
      if (status * (a.at(i + 1) - a.at(i)) < 0) {
        cnt++;
        status = 0;
      }
    }
  }
  cnt++;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 640
N=int(input())
A=list(map(int,input().split()))
S=0
XOR=0
r=-1
ans=0
for i in range(N):
    while S==XOR and r<N:
        r+=1
        if r>=N:
            break
        S+=A[r]
        XOR^=A[r]
    ans+=r-i
    S-=A[i]
    XOR^=A[i]
print(ans)

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

using namespace std;

int main()
{
    int n;

    while (1) {
        cin >> n;
        long double sum = 0.0;
        vector<long double> vec(1000);
        long double ave = 0.0;
        if (n == 0) break;
        for (int i = 0; i < n; i++) {
            cin >> vec[i];
            sum += vec[i];
        }
        ave = sum / n;
        sum = 0.0;
        for (int i = 0; i < n; i++) {
            sum += pow(vec[i] - ave, 2);
        }
        cout << fixed << setprecision(20) << sqrtl(sum / n) << endl;
    }
}


Measured memory_bytes: 3252
//
//
///
//

#include "bits/stdc++.h"
using namespace std;
#define ri(a,b,c) for(int a=(b);a<(c);++a)
typedef long long ll;
#define fcout cout << fixed << setprecision(10)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z;
    cin>>a;
















    cout<<(a%2?a*2:a)<<"\n";

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <math.h>
using namespace std;

typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(a) a.begin(),a.end()

int main() {
	int ans = 0;
	rep(i, 2) {
		char c;
		cin >> c;
		if (c == '9') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int gcd(int a, int b){
    while(b != 0){
        int c = b;
        b = a % b;
        a = c;
    }
    return a;
}

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> A(N);

    rep(i, N){
        int tmp;
        cin >> tmp;
        A.at(i) = abs(tmp - X);
    }
    
    int ans = A.at(0);
    rep(i, N){
        ans = gcd(ans, A.at(i));
    }

    cout << ans << endl;

}

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

class Main {
  public static void main(String[] args) throws Exception{
    try (Scanner sc = new Scanner(System.in)){
      int N = sc.nextInt();
      int count = 0;
      int[] list = new int[N];
      for (int i = 0; i < N; i++) {
        list[i] = sc.nextInt();
      }
      int pre = list[0];
      for (int i = 1; i < list.length; i++) {
        if (pre == list[i]) {
          for (int j = 1; j < 10000; j++) {
            if (j != list[i-1] && j != list[(i+1) % list.length]) {
              list[i] = j;
              pre = list[i];
              count += 1;
              break;
            }
          }
        } else {
          pre = list[i];
        }
      }
      System.out.println(count);
      //while(check(list))
    }
  }
}


Measured memory_bytes: 23764
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int ans = c-a+b;
		if(ans < 0) ans = 0;
		System.out.println(ans);
				}

}


Measured memory_bytes: 22868
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)

	c := 0
	for i := 0; i <= N; i++ {
		if i%2 == 0 {
			continue
		}
		tmp := 0
		for num := 1; num <= N; num++ {
			if i%num == 0 {
				tmp++
			}
		}
		if tmp == 8 {
			c++
		}
		// fmt.Println(i, tmp)
	}
	fmt.Print(c)
}


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

int main(void){
    int H,W,N,a,b,dx[9]={-1,-1,-1,0,0,0,1,1,1},dy[9]={-1,0,1,-1,0,1,-1,0,1};
    cin>>H>>W>>N;
    ll cnt[10]={(ll)(H-2)*(W-2)};
    map<pair<int,int>,int> mp;
    rep(i,N){
        cin>>a>>b;
        rep(j,9){
            int x=a+dx[j],y=b+dy[j];
            if(x<=1 || x>=H || y<=1 || y>=W)continue;
            cnt[mp[{x,y}]++]--;
            cnt[mp[{x,y}]]++;
        }
    }
    rep(k,10)cout<<cnt[k]<<endl;
    return 0;
}


Measured memory_bytes: 56448
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=10000004,mod=998244353;
ll fac[N],pw[N/2],ni[N];
ll c(int a,int b){
	return fac[a]*ni[b]%mod*ni[a-b]%mod;
}
ll ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int n=read(),ans=0;
	For(i,fac[0]=1,n)fac[i]=fac[i-1]*i%mod;
	ni[n]=ksm(fac[n],mod-2);
	Rep(i,n,1)ni[i-1]=ni[i]*i%mod;
	For(i,pw[0]=1,n/2)pw[i]=pw[i-1]*2%mod;
	For(i,n/2+1,n)ans=(ans+c(n,i)*pw[n-i+1])%mod;
	cout<<(ksm(3,n)-ans+mod)%mod<<endl;
}


Measured memory_bytes: 195584
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	vector<long long int >a;
	vector<long long int >b;
	for (int i = 0; i <= n; i++) {
		int in;
		cin >> in;
		a.push_back(in);
	}
	for (int i = 0; i < n; i++) {
		int in;
		cin >> in;
		b.push_back(in);
	}
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		long long int zero = 0;
		if (b[i] >= a[i]) {
			b[i] = b[i] - a[i];
			long long int kara = a[i + 1];
			a[i + 1] = max(zero, a[i + 1] - b[i]);
			ans = ans + a[i] + kara - a[i + 1];
		}
		else {
			ans = ans + b[i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 2548
import sys
s=list(input())

for i in range(1,len(s)):
  if s[i-1]==s[i]:
    print(i,i+1)
    sys.exit(0)
  
for i in range(2,len(s)):
  if s[i-2]==s[i]:
    print(i-1,i+1)
    sys.exit(0)
    
print(-1,-1)

Measured memory_bytes: 3956
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String str[] = br.readLine().split(" ");

		long n = Long.parseLong(str[0]);
		long k = Long.parseLong(str[1]);

		long m = n % k;
		if (m == 0) {
			System.out.println("0");
		} else {
			long min = Math.min(m, k - m);
			System.out.println(min);
		}
	}
}

Measured memory_bytes: 32368
//بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ
#include <bits/stdc++.h>
using namespace std;
int tree(int a[], int l, int r, int i, int p, int q){
    if(p >= l && q <= r) return a[i];
    else if(p > r || q < l) return 0;
    else return __gcd(tree(a, l, r, 2*i+1, p, p + ((q - p) / 2)), tree(a, l, r, 2*i+2,p + ((q - p) / 2) + 1, q));
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int s;
    cin >> s;
    int n = (int)round(pow(2, ceil(log2(s))));
    int a[2*n-1]{};
    for(int i = 0; i < s; i++) cin >> a[i];
    reverse(a, a+n);
    int m = n, o = 0;
    for(int i = n/2; i > 0; i /= 2){
        for(int j = 0; j < i; j++) a[m+j] = __gcd(a[o+j*2], a[o+j*2+1]);
        o = m, m += i;
    }
    reverse(a, a+(2*n-1));
    int x = max(tree(a, 0, s-2, 0, 0, n-1), tree(a, 1, s-1, 0, 0, n-1));
    x = max(x, tree(a, 0, s-1, 0, 0, n-1));
    for(int i = 1; i < s-1; i++) x = max(x, __gcd(tree(a, 0, i-1, 0, 0, n-1), tree(a, i+1, s-1, 0, 0, n-1)));
    cout << x;
}


Measured memory_bytes: 1280