akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T>ostream&operator<<(ostream &o,const vector<T>&t){o<<'[';FOR(i,t){if(i!=t.begin())o<<',';o<<*i;}return o<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)output(a[i],i!=n-1?',':10);}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}

char a[100001];
vector<int> g[100000];

int main() {
  int n,m;
  while(cin>>n>>m) {
    REP(i,n) g[i].clear();
    REP(i,n) cin >> a[i];
    REP(i,m) {
      int s,t;
      input(s,t);
      g[s].push_back(t);
      g[t].push_back(s);
    }
    REP(i,n) {
      if (a[i] != '?') continue;
      set<char> S;
      FOR(it, g[i]) {
        S.insert(a[*it]);
      }
      for (char c='a'; c<='z';++c) {
        if (S.count(c) == 0) {
          a[i] = c;
          break;
        }
      }
    }
    a[n] = 0;
    cout << a << endl;
  }
}


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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define pb push_back
#define INF 1000000000000000000
#define PI 3.14159265358979323846
#define f first
#define s second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef vector<pii> vii;

int main()
{
    FAST_IO;

    int a, p;
    cin >> a >> p;

    cout << (a*3+p)/2;

    return 0;
}


Measured memory_bytes: 256
using System;
class aoj
{
    static void Main()
    {
        int[, , ] k = new int[50, 11, 11];
        int[] m = new int[50];
        int s = 0;
        for (;;)
        {
            string a = Console.ReadLine();
            if (a == "0")
            {
                break;
            }
            int b = int.Parse(a);
            int[,] d = new int[b+1,b+1];
            for(int i = 0; i < b; i++)
            {
                int e = 0;
                string[] c = Console.ReadLine().Split(' ');
                for(int j = 0; j < b; j++)
                {
                    d[i, j] = int.Parse(c[j]);
                    k[s, i, j] = d[i, j];
                    e += d[i, j];
                }
                d[i, b] = e;
                k[s, i, b] = e;
            }
            int h = 0;
            for (int i = 0; i <= b; i++)
            {
                int e = 0;
                for (int j = 0; j < b; j++)
                {
                    e += d[j, i];
                }
                d[b,i] = e;
                k[s, b, i] = e;
                h += e;
            }
            h = h / 2;
            d[b, b] = h;
            m[s] = b;
            k[s, b, b] = d[b, b];
            s++;
           
        }
        for(int i = 0; i < s; i++)
        {
            for(int j = 0; j <= m[i]; j++)
            {
                for(int x = 0; x <= m[i]; x++)
                {
                    Console.Write("{0,5}" , k[i, j, x]);
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 9260
#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define LIMIT 1201

int main() {
    char ss[LIMIT];
    fgets(ss, LIMIT, stdin);

    char *ln = strchr(ss, '\n');
    if (ln != NULL) {
        *ln = '\0';
    }
    int len = strlen(ss);
    for (int i=0; i<len; ++i) {
        if (isalpha(ss[i])) {
            if (ss[i] >= (int)'A' && ss[i] <= (int)'Z') {
                ss[i] += (int)'a' - (int)'A';
            } else {
                ss[i] += (int)'A' - (int)'a';
            }
        }
    }
    printf("%s\n", ss);
    return 0;
}



Measured memory_bytes: 2076
k,n = map(int,input().split())
A = list(map(int,input().split()))


max_d = 0
max_index = 0
for i in range(n-1):
    if A[i+1] - A[i] > max_d:
        max_d = A[i+1]-A[i]
        max_index = i

if k-A[n-1]+A[0] > max_d:
    max_d = k-A[n-1]+A[0]
    max_index = n-1

min_distance = 0

if(max_index != n-1):
    min_distance = A[max_index]+k-A[max_index+1]
else:
    min_distance = A[n-1]-A[0]

print(min_distance)


Measured memory_bytes: 26444
#include<stdio.h>
#include<stdlib.h>
int main(void){
int ae[6],k,i,j;
for(i=0;i<5;i++){
   scanf("%d",&ae[i]);
   }
scanf("%d",&k);

for(i=0;i<4;i++){
  for(j=i+1;j<5;j++){
    if(k<(ae[j]-ae[i])){printf(":(\n");exit(0);}
  }
}
printf("Yay!\n");

return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
  
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (a[i] + a[j] > a[k] && a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) {
                    ans++;
                }
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 3532
package main

import "fmt"

func main() {
	// Code for A - Eating Symbols Easy
	var S string
	fmt.Scanf("%s", &S)

	var answer int
	for i := 0; i < len(S); i++ {
		if S[i] == '+' {
			answer++
		} else {
			answer--
		}
	}
	fmt.Println(answer)
}


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

int main(){
    int N;
    cin >> N;
    Graph G(N);
    rep(i, N){
        int u, k;
        cin >> u >> k;
        u--;
        rep(j, k){
            int v;
            cin >> v;
            v--;
            G[u].push_back(v);
        }
    }

    vector<int> dist(N, -1);
    dist[0] = 0;

    queue<int> que;
    que.push(0);

    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int i = 0; i < G[v].size(); i++){
            int v2 = G[v][i];
            if(dist[v2] != -1) continue;
            dist[v2] = dist[v] + 1;
            que.push(v2);
        }
    }

    rep(i, N){
        cout << i + 1 << ' ' << dist[i] << endl;
    }
}


Measured memory_bytes: 3160
#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vp = vector<Pl>;
using vvp = vector<vp>;

const int INF = 1<<29;
const long long LINF=1LL<<59;

const long long MOD = 2;


int main(){
  // Failed to predict input format
  ll N,M;
  cin >> N >> M ;
  vvl s(M);
  rep(i,M){
    int k; cin >> k ;
    s[i].resize(k);
    rep(j,k){
      cin >> s[i][j] ;
      s[i][j]--;
    }
  }
  vl p(M);
  rep(i,M) cin >> p[i] ;
  ll ans = 0;
  rep(x,1<<N){
    bool ok = true;
    rep(i,M){
      ll cnt = 0;
      for(auto ss:s[i]) if((x>>ss)&1) cnt++;
      ok &= (cnt%2==p[i]);

    }
    if(ok) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define X first
#define Y second
typedef long long ll;
typedef pair<ll,ll> pll;

#define N 105
ll n, w[N], fsum[N], rsum[N];

int main(int argc, char const *argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(NULL);
    cin >> n;
    for (ll i=0; i<n; i++) cin >> w[i];
    fsum[0]=w[0];
    for (ll i=1; i<n; i++) fsum[i] = fsum[i-1] + w[i];
    rsum[n-1]=w[n-1];
    for (ll i=n-2; i>=0; i--) rsum[i] = rsum[i+1] + w[i];
    ll mn = LONG_MAX;
    for (ll i=0; i<n-1; i++) if (abs(fsum[i]-rsum[i+1])<mn)
        mn = abs(fsum[i]-rsum[i+1]);
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
V = list(map(int,input().split()))
V1 = Counter(V[0:N:2])
V2 = Counter(V[1:N:2])

"""
まず大きく2つの場合分けができる
・V1とV2の最多数値が違う場合
・V1とV2の最多数値が同じ場合
前者の場合は、普通にNからそれぞれの最多数値を引けばよい。

後者の場合は、V1の方をセカンダリの数字に合わせるパターンと、V2の方をセカンダリの数字に合わせるパターンそれぞれ試して
変更回数が少ない方を採用する。
"""
V1 = [(v,k) for k,v in V1.items()]
V1.sort(reverse=True)
V1.append((0,10**5+1))
V2 = [(v,k) for k,v in V2.items()]
V2.sort(reverse=True)
V2.append((0,10**5+1))

if V1[0][1] != V2[0][1]:
    ans = N - V1[0][0] - V2[0][0]
else:
    candi1 = N - V1[1][0] - V2[0][0]
    candi2 = N - V1[0][0] - V2[1][0]
    ans = min(candi1,candi2)

print(ans)

Measured memory_bytes: 103168
import sys
input = sys.stdin.readline
def inpl(): return list(map(int, input().split()))

INF = 10**10
N = int(input())
rans = INF
T = 0
for _ in range(N):
    a, b = inpl()
    T += a
    if a>b:
        rans = min(rans, b)
if rans != INF:
    print(T-rans)
else:
    print(0)

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

    int N; cin >> N;

    string S;
    cin >> S;
    int ans = 0;


    for(int offset = 1; offset < N; offset++){
        int len = 0;
        int start = offset;
        for(int i = offset; i < N; i++) {
            ans = max(ans, len);
            if(i-offset == start) break;
            if(S[i-offset] != S[i]) {
                len = 0;
                start = i+1;
            } else {
                len++;
            }
        }
        ans = max(ans, len);

    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
'use strict'
// import bigInt from 'big-integer'

const procBitPatterns = (num, func) => {
    for (let bit = 0; bit < (1 << num); bit++) {
        const bitPatterns = []
        for (let i = 0; i < num; i++) {
            if (bit & (1 << i)) bitPatterns.push(1)
            else bitPatterns.push(0)
        }
        func(bitPatterns)
    }
}


const main = (input) => {
    input = input.trim()
    const nums = input.split("")
    const plusNum = nums.length - 1
    let answer = 0
    procBitPatterns(plusNum, (bitPatterns) => {
        let tmpStrs = [nums[0]]
        for (let j = 0; j < bitPatterns.length; j++) {
            const num = nums[j + 1]
            if (bitPatterns[j]) {
                tmpStrs.push(num)
            } else {
                tmpStrs[tmpStrs.length - 1] += num
            }
        }
        answer += tmpStrs.reduce((acc, cur) => acc + parseInt(cur, 10), 0)
    })

    console.log(answer)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main(){
  int N;
  cin >> N;
  bool works = false;
  for (int i=1; i<=9; i++){
    for (int j=1; j<=9; j++){
      if (i*j == N) works = true;
    }
  }
  if (works) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char s;
  int v;
};

struct Card L[MAX/2+2], R[MAX/2+2];

void merge(struct Card A[], int n, int left, int mid, int right){
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].v = R[n2].v = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ){
    if ( L[i].v <= R[j].v ){
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right ){
  int mid;
  if ( left+1 < right ){
    mid = (left + right)/2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r){
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ){
    if ( A[j].v <= x.v ){
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i+1]; A[i+1] = A[r]; A[r] = t;
  return i+1;
}

void quickSort(struct Card A[], int n, int p, int r){
  int q;
  if ( p < r ){
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

int main(){
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char N[10];
  int stable = 1;
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", N, &v);
    A[i].s = B[i].s = N[0];
    A[i].v = B[i].v = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n-1);

  for ( i = 0; i < n; i++ ){
    if ( A[i].s != B[i].s ) stable = 0;
  }

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    printf("%c %d\n", B[i].s, B[i].v);
  }
}



Measured memory_bytes: 4016
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 1000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
//#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;   


int32_t main() 
{ 
    fastio
    int n;
    cin>>n;
    vector<ll> vec(n);
    for(auto& it : vec) cin>>it;
    int q;
    cin >>q;

    ll sum = 0;
    map<ll, ll> mp;
    for(int i = 0; i<n; ++i) {
        mp[vec[i]]++;
        sum += vec[i];
    }

    while(q--) {
        ll b, c;
        cin>>b>>c;
        ll now = mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        sum -= now*b;
        sum += now*c;
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 10116
#include<iostream>

using namespace std;

int main(void){
    int a,b,s=0;
    cin >> a >> b;
    s = a + b;
    if(a % 3 == 0){
        cout << "Possible";
    }else if (b % 3 == 0)
    {
        cout << "Possible";
    }else if (s % 3 == 0)
    {
        cout << "Possible";
    }else{
        cout << "Impossible";
    }
    
    
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String []args){
		Scanner sc=new Scanner(System.in);
		int a,b,c;
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		
		if(a<b&&b<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

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

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int array[] = new int[M];

		for(int i = 0; i < M; i++) {
			array[i] = sc.nextInt();
		}
		int x = 0;
		for(int j = 0; j < M; j++) {
			if(array[j] < X) {
				x += 1;
			}else {
				x += 0;
			}
		}

		System.out.println(Math.min(x, M-x));
	}

}


Measured memory_bytes: 23252
import java.util.*;
import java.math.*;
class Main{
	public static void main(String[] args){
		Scanner s=new Scanner(System.in);
		while(s.hasNext()){
			int a=s.nextInt();
			int b=s.nextInt();
			int c=s.nextInt();
			int d=s.nextInt();
			if(a+b+c+d==0)System.exit(0);
			if(c==0){
				if(a==1)System.out.print("1.");
				else System.out.print("0.");
				int now=1;
				if(a==1)now=0;
				for(int i=0;i<d;i++){
					now*=10;
					System.out.print(now/a);
					now%=a;
				}
				System.out.println();
			}else{
				BigInteger kaijo=new BigInteger("1");
				for(int i=1;i<a;i++)kaijo=kaijo.multiply(new BigInteger(""+i));
				BigInteger bunbo=kaijo.multiply(new BigInteger(""+a));
				BigInteger bunshi=BigInteger.ZERO;
				for(int i=1;i<=a;i++){
					bunshi=bunshi.add(kaijo.divide(new BigInteger(""+Math.max(1,i-1))));
				}
				if(a<3)System.out.print("1.");
				else System.out.print("0.");
				if(a<3)bunshi=BigInteger.ZERO;
				for(int i=0;i<d;i++){
					bunshi=bunshi.multiply(new BigInteger(""+10));
					System.out.print(bunshi.divide(bunbo).toString());
					bunshi=bunshi.mod(bunbo);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;


int main() {
  int N;
  cin >> N;
  vi A(N);
  map<int,int> mp;
  rep(i,N) {
    cin >> A[i];
    mp[A[i]]++;
  }
  int cnt = 0;
  vi used(1001000,0);
  for(auto k:mp) {
    if(used[k.first]) continue;
    if(k.second==1) {
      cnt++;
    }
    for(int x=k.first;x<1001000;x += k.first) {
      used[x]++;
    }
  }
  cout << cnt << endl;
  return 0;
}

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

const int MAXN = 500010;

template<typename T> inline T read() {
	T x(0), f(1);
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n, K, p[MAXN];
int P[MAXN];

namespace Seg_T{
#define ls(p) (p<<1)
#define rs(p) (p<<1|1)
#define mid ((l+r)>>1)
	int Max[MAXN<<2];

	inline int query(int p, int l, int r, int x, int y) {
		if(x > y) return 0;
		if(l == x && r == y) return Max[p];
		if(y <= mid) return query(ls(p), l, mid, x, y);
		if(x > mid) return query(rs(p), mid+1, r, x, y);
		return max(query(ls(p), l, mid, x, mid), query(rs(p), mid+1, r, mid+1, y));
	}

	inline void modify(int p, int l, int r, int c, int v) {
		if(l == r) {
			Max[p] = v;
			return;
		}
		if(c <= mid) modify(ls(p), l, mid, c, v);
		else modify(rs(p), mid+1, r, c, v);
		Max[p] = max(Max[ls(p)], Max[rs(p)]);
	}
}

int e, ans[MAXN], cnt;
vector<int> G[MAXN];
inline void Add(int u, int v) {
	//printf("%d %d\n", u, v);
	G[u].push_back(v);
}

void dfs(int u) {
	ans[++cnt] = u;
	sort(G[u].begin(), G[u].end());
	for(int i = 0; i < (int)G[u].size(); i++) dfs(G[u][i]);
}

int main() {
	n = read<int>(), K = read<int>();
	for(int i = 1; i <= n; i++) {
		p[i] = read<int>();
		P[p[i]] = i;
	}

	P[n+1] = n+1;
	Add(n+1, P[1]);
	Seg_T::modify(1, 1, n, P[1], 1);
	for(int i = 2; i <= n; i++) {
		int j = Seg_T::query(1, 1, n, P[i]+1, min(n, P[i]+K-1));
		if(!j) j = n+1;
		Add(P[j], P[i]);
		Seg_T::modify(1, 1, n, P[i], i);
	}

	dfs(n+1);

	for(int i = 2; i <= cnt; i++) p[ans[i]] = i-1;
	for(int i = 1; i <= n; i++) 
		printf("%d\n", p[i]);
	return 0;
}


Measured memory_bytes: 65920
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <functional>
#define int long long 
#define pi pair<int,int> 
#define endl "\n"
using namespace std ;

const int inf = 1e15 ;
const int size = 1e5 + 5 ;



int32_t main() 
{


   /*  #ifndef ONLINE_JUDGE 
     freopen("input.txt","r",stdin);
     freopen("output.txt","w",stdout);
     #endif */
     int n , k ;
     cin >> n >> k ;
     int dp[size] ;
     vector<int>a(n+1);
     for(int i = 1  ; i <= n ; i++ )cin >> a[i] ;
     for(int i = 1; i <= n ;i ++ )dp[i] = 1e15 ;
     dp[1] = 0 ;
     for(int i = 2 ; i <= n ; i++ )
     {
         for(int j = max(i-k,1LL); j < i ; j++)
         {
             int h = a[i] - a[j] ; if(h < 0 ) h  = - h ;
             dp[i] = min(dp[i],h+dp[j]);
         }
         // cout<<dp[i]<<endl;
     }
     cout<<dp[n]<<endl;
}


Measured memory_bytes: 1792
type
  p = array [0..2] of Integer;
var
  a, b, i, max : Integer;
  q : p;
begin
  read(a);
  read(b);
  
  q[0] := a + b;
  q[1] := a - b;
  q[2] := a * b;
  max := q[0];
   
  for i := 1 to 2 do
    begin
    if q[i] > max then
      max := q[i];  
    end;
  write(max);
end.

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

using namespace std;

int main(){
	int n;
	int ans = 100000;
	cin >> n;
	while (n){
		n--;
		ans *= 1.05;
		if ((ans % 1000) != 0) ans += (1000 - ans % 1000);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1160
import math


def main():
    n = int(input())
    res = f(1, n)
    for i in range(int(math.sqrt(n)), 0, -1):
        if n % i == 0:
            this_f = f(i, n // i)
            if this_f <= res:
                res = this_f
            else:
                break
    print(res)


def f(a, b):
    return max(len(str(a)), len(str(b)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

long long N, M, A[1 << 18], S;

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	sort(A, A + N);
	for (int i = 0; i < N - M; i++) S += A[i];
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 1792
n,k = map(int, input().split())

if k%2 == 1:
    kcnt = n//k
    ans = pow(kcnt,3)
    print(ans)

else:
    kcnt = n//k
    ans = pow(kcnt,3)

    kcnt2 = 0
    for i in range(1,n+1):
        if i%k == (k//2): kcnt2 += 1
    ans += pow(kcnt2,3)
    print(ans)

Measured memory_bytes: 63364
x,n = map(int, input().split())
p = list(map(int, input().split()))
p = [i-x for i in p]
p.sort()
ans = -n
for i in range(n):
  if -i not in p:
    ans = -i
    break
  elif i not in p:
    ans = i
    break
print(x+ans)

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll dp[N], tree[4*N], lazy[4*N];

ll add(ll a, ll b) {
  a += b;
  if(a >= MOD)
    a -= MOD;
  if (a < 0)
    a += MOD;
  return a;
}

void propagate(int node, int start, int end) {
  if(!lazy[node])
    return;
  tree[node] += (ll)(end - start + 1) * lazy[node];
  tree[node] = add(tree[node], 0);
  if(start != end) {
    lazy[node * 2] = add(lazy[node * 2], lazy[node]);
    lazy[node * 2 + 1] = add(lazy[node * 2 + 1], lazy[node]);
  }
  lazy[node] = 0;
}

void update(int node, int start, int end, int l, int r, int v) {
  propagate(node, start, end);
  if(start > r || end < l)
    return;
  if(start >= l && end <= r) {
    lazy[node] = v;
    propagate(node, start, end);
    return;
  }
  int mid = (start + end) / 2;
  update(node * 2, start, mid, l, r, v);
  update(node * 2 + 1, mid + 1, end, l, r, v);
  tree[node] = add(tree[node * 2], tree[node * 2 + 1]);
}

ll query(int node, int start, int end, int l, int r) {
  propagate(node, start, end);
  if(start > r || end < l)
    return 0;
  if(start >= l && end <= r)
    return tree[node];
  int mid = (start + end) / 2;
  ll p1 = query(node * 2, start, mid, l, r);
  ll p2 = query(node * 2 + 1, mid + 1, end, l, r);
  p1 = add(p1, p2);
  return p1;
}

ll arr[N];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  int n, k, x;
  cin >> n >> k;
  dp[0] = 1;
  update(1, 0, N, 0, 0, 1);
  for (int i = 0; i < n; ++i) {
    cin >> x;
    memset(arr, 0, sizeof arr);
    for (int j = k; j >= 0; --j) {
//      for (int l = min(x, k - j); l >= 1; --l)
//        dp[l + j] = add(dp[l + j], dp[j]);
      int L = 1 + j, R = min(x, k - j) + j, val = dp[j];
      if(L <= R && val)
        arr[L] = add(arr[L], val), arr[R + 1] = add(arr[R + 1], -val);
    }
    int sum = 0;
    for (int j = 1; j <= k; ++j) {
      sum = add(sum, arr[j]);
      dp[j] = add(dp[j], sum);
    }
  }
  cout << dp[k];
//  cout << query(1, 0, N, k, k) << '\n';
  return 0;
}


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

using namespace std;

int main(){
    int N,M,C;
    int ans =0;
    int count=0;
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<vector<int>> A(N,vector<int> (M));
    
    for(int i=0;i<M;i++){
        cin >> B.at(i);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin >> A.at(i).at(j);
        }
    }

    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            ans += (A.at(i).at(j))*B.at(j);
        }
        if(ans+C > 0){
            count++;
        }
        ans=0;
    }
    
    cout << count << endl;

}


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

int main(){
  bool flag=false;//この区間は数えた→true
  string s,s1;
  ll sum=0,count=0;
  cin >> s;
  r(i,s.length()){
    if(s[i]=='A')s1+='A';
    else if(i==s.length()-1)s1+='D';
    else if(s[i]=='B'&&s[i+1]=='C'){
      s1+='B';	i++;
    }
    else s1+='D';
  }
  r(i,s1.length()){
    if(s1[i]=='D')flag=false;
    else if(s1[i]=='B'&&flag)count--;
    else if(s1[i]=='A'&&flag==false){
      flag=true;
      for(int j=i+1;j<s1.length();j++){
      if(s1[j]=='B'){
        sum++; count++;
      }
      if(s1[j]=='D')break;
    }
    }
    else if(s1[i]=='A')sum+=count;
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 776
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  int n, p[200000], mini[200000], ans = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }
  mini[0] = p[0];
  for (int i = 1; i < n; i++) {
    mini[i] = min(mini[i - 1], p[i]);
  }
  for (int i = 0; i < n; i++) {
    if (mini[i] == p[i]) {
      ans++;
    }
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 1664
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

#define Len 10001

void swap(char s[], int l, int st, int e){
    
    for (int i = 0; i < l; i++){
        char tmp = s[st + i];
        s[st + i] = s[e + i];
        s[e + i] = tmp;
    }
}

int LeftIsSmall(char s[], int l, int st, int e){
    for(int i = 0; i < l; i++){
        if(s[st + i] > s[e + i]) return 0;
        if(s[st + i] < s[e + i]) return 1;       
    }
    return 1;
}

int main()
{
    int n, l;
    
    scanf("%d", &n); 
    scanf("%d", &l); 

    char s[n * l];

    for (int i = 0; i < n; i++){
        char tmp[l];
        scanf("%s", tmp);
        
        for (int j = 0; j < l; j++){
            s[(i * l) + j] = tmp[j];
        }
    }

    
    for (int i = 0; i < n*l - l; i += l){
        for (int j = n*l - l; j > i; j -= l){
            if (LeftIsSmall(s, l, j - l, j) == 0){
                swap(s, l, j - l, j);
            }
        }
    }

    for (int i = 0; i < n*l; i++){
        putchar(s[i]);
    }
    putchar('\n');
}  

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
   int r;
   cin>>r;
   if(r<1200)cout<<"ABC\n";
   else if(r<2800)cout<<"ARC\n";
   else cout<<"AGC\n";
    return 0;
}


Measured memory_bytes: 256
// "header" {{{
#pragma GCC optimize("Ofast")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <tuple>
#include <iomanip>
#include <climits>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int int64_t
#define Fixed fixed << setprecision(10)
#define moke_pair make_pair

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int64_t mod1 = 1000000007;
constexpr int64_t mod2 = 998244353;

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

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class T,class U> using umap = unordered_map<T,U>;

inline int64_t updiv(int64_t n,int64_t d){ return ((n + d -1) / d); }
inline int square(int a){ return a * a; }
// }}}

signed main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int n;
    double p;
    cin >> n;
    vector<vector<double> > dp(n+1,vector<double>(n+1));
    dp[0][0] = 1;

    reps(i,n){
        cin >> p;
        rep(j,n+1){
            if(j > 0){
                dp[i][j] = dp[i-1][j-1] * p + dp[i-1][j] * (1 - p);
            }else{
                dp[i][j] = dp[i-1][j] * (1 - p);
            }
        }
    }

    double res = 0;
    for(int i = n;i > n / 2;--i){
        res += dp[n][i];
    }

    printf("%0.12lf\n",res);

    return 0;
}


Measured memory_bytes: 70784
// Problem : A - Five Variables
// Contest : AtCoder - AtCoder Beginner Contest 170
// URL : https://atcoder.jp/contests/abc170/tasks/abc170_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
using namespace std;
int main()
{
 for(int i=1;i<=5;i++)
 {
  int x;
  cin>>x;
  if(x==0)cout<<i<<endl;
 }
 return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
#include<queue>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	sort(x.begin(), x.end());
	int ans = 10000000;
	for (int i = x[0]; i <= x[n - 1]; i++) {
		int ansi = 0;
		rep(j, n) {
			ansi += abs(i - x[j])*abs(i - x[j]);
		}
		ans = min(ans, ansi);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))

import itertools

ans = 0
for tmpr in itertools.combinations(list(range(len(L))),3):
    a,b,c = L[tmpr[0]],L[tmpr[1]],L[tmpr[2]]
    if a!=b and b!=c and a!=c:
        if a+b>c and a+c>b and b+c > a:
            ans+=1
   
print(ans)

Measured memory_bytes: 67892
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;

int main(){
    string S;
    cin >> S;
    if(S.at(0)==S.at(1) && S.at(1)==S.at(2)) cout << "No";
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter

def primeFactors(n):
    res = []
    while n%2==0:
        res.append(2)
        n //= 2
    x = 3
    while n>1 and n>=x*x:
        while n%x==0:
            res.append(x)
            n //= x
        x += 2
    if n>1:
        res.append(n)
    return res

n = int(input())
pl = primeFactors(n)

res = 0
cd = Counter(pl)
for k in cd:
    c = cd[k]
    i = 1
    while c-i>=0:
        c -= i
        res += 1
        i += 1
print(res)


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

int main() {
  string s;
  cin >> s;
  int ans = 0;
  if(s[0] == '1') ans++;
  if(s[1] == '1') ans++;
  if(s[2] == '1') ans++;
  cout << ans << endl;
}


Measured memory_bytes: 256
a,b=(int(x) for x in input().split())

for i in range(1,1010):
#	print (i)
	ia=int(i*0.08)
	ib=int(i*0.1)
#	print (ia,ib)
	if ia==a and ib==b:
		print (i)
		exit()
else:
	print (-1)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }

    ll ans = 0;
    rep(i, n-1) {
        if(p[i] == i) {
            swap(p[i], p[i+1]);
            ans++;
        }
    }
    if(p[n-1] == n-1) {
        ans++;
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
using namespace std;
const int N=5e2+5;

int n,m;
int w,h;

int tab[N][N];

int main()
{
    int i,j;
    long long sum=0;
    cin>>n>>m>>h>>w;

    if(n%h==0 && m%w==0)
        {
            cout<<"No"<<endl;
            return 0;
        }

    for(i=1;i<=n;i++)
        for(j=1;j<=m;j++)
        {
            if(i%h==0 && j%w==0)
                tab[i][j]=-(h*w-1)*4000-1;
            else
                tab[i][j]=4000;

             sum+=tab[i][j];
        }


       if(sum<=0)
    {
            cout<<"No"<<endl;;
        return 0;
    }

    cout<<"Yes"<<endl;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
            printf("%d ",tab[i][j]);
        printf("\n");
    }

        return 0;
    }


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

#define fo(i,s,t) for(int i =s; i<=t;++i)
const int maxn = 100050;

int sg[maxn];
vector<int> nex[maxn];
int n, ans;

void dfs(int x,int fa=0)
{
	for(auto p:nex[x]) if(p!=fa) {dfs(p,x);sg[x]^=(sg[p]+1);}
}
int main()
{
	scanf("%d",&n);
	fo(i,1,n-1)
	{
		int u, v;
		scanf("%d%d",&u,&v);
		nex[u].push_back(v);
		nex[v].push_back(u);
	}
	dfs(1);
	if(sg[1]) puts("Alice");
	else puts("Bob");
	return 0;
}


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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	
	int a,b;
	cin>>a>>b;
	if(a+b<10)
		cout<<a+b;
	else
		cout<<"error";

    return 0;
}

Measured memory_bytes: 256
# メモ化再帰ｓ
# def rec(i,j):
#     if dp[i][j] >= 0:
#         return dp[i][j]
#     res = 0
#     if i == n:
#         res = 0
#     elif j < w[i]:
#         res = rec(i+1,j)
#     else:
#         res = max(rec(i+1,j),rec(i+1,j-w[i])+v[i])
#     dp[i][j] = res
#     return res

# def main():
#     global n,w,v,dp
#     n = int(input())
#     w,v = [0]*n,[0]*n
#     for i in range(n):
#         w[i],v[i] = map(int,input().split())
#     W = int(input())
#     dp = [[-1]*(W+1) for _ in range(n+1)]
#     print(rec(0,W))

# DP
def main():
    global n,w,v,dp
    n,W = map(int,input().split())
    w,v = [0]*(n),[0]*(n)
    for i in range(n):
        w[i],v[i] = map(int,input().split())
    dp = [[0]*(W+1) for _ in range(n+1)]
    for i in range(1,n+1):
        for j in range(1,W+1):
            if j < w[i-1]:
                dp[i][j] = dp[i-1][j]
            else:
                dp[i][j] = max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1])
    print(dp[n][W])


if __name__ == '__main__':
    main()

"""
in
4 5
2 3
1 2
3 4
2 2

out
7
"""

Measured memory_bytes: 118512
A, B, C, K = map(int, input().split())

nokori = K - A - B

wa = 0
while True:
    if A >= K:
        wa += K
        break
    else:
        wa += A
    if C >= nokori:
        wa -= nokori
        break
    else:
        wa -= C
        break

print(wa)

Measured memory_bytes: 9184
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int Y = scanner.nextInt();

        if (Y % 1000 != 0) {
            System.out.println("-1 -1 -1");
            return;
        }

        Y /= 1000;
        for (int i = 0; i <= N; i++) {
            for (int j = 0; j <= N - i; j++) {
                int k = N - i - j;
                if (i * 10 + j * 5 + k == Y) {
                    System.out.printf("%d %d %d", i, j, k);
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
}


Measured memory_bytes: 23892
#include<stdio.h>
int main(){
  while(1){
    int a,b,ans;
    char c;
    scanf("%d %c %d", &a, &c, &b);
    if ( c == '?') break;
    if ( c == '+'){
      ans=a+b;
    }
    if (c == '-'){
      ans=a-b;
    }
    if (c == '*'){
      ans=a*b;
    }
    if (c == '/'){
      ans=a/b;
    }
    printf("%d\n", ans);
  }
    return 0;
  }



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

int main()
{
  std::string data;
  std::cin >> data;
  
  int count = 0, res = 0;
  for (char c : data) {
    if (c == 'R') count++;
    else {
        count = 0;

    }

    res = std::max(res, count);
    
  }
  std::cout << res;
  return 0;
}

Measured memory_bytes: 3552
n=int(input())
lst=list(map(int,input().strip().split()))
lst1=list(set(lst))
ans=0 
for i in range(1,n):
    if(lst[i-1]>lst[i]):
        a=(lst[i-1]-lst[i])
        lst[i]+=a 
        ans+=a
print(ans)

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

int main()
{
  int N, ans = 0, on = 1;
  cin >> N;
  vector<int> A(N + 1);
  vector<bool> Visited(N + 1, 0);
  for (int i = 1; i <= N; i++)
  {
    cin >> A.at(i);
  }
  while (true)
  {
    ans++;
    int nxt = A.at(on);
    if (Visited.at(nxt))
    {
      ans = -1;
      break;
    }
    else
    {
      Visited.at(nxt) = true;
      on = nxt;
      if (on == 2)
      {
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if(self.root[x] < 0):
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if(x == y):
            return 
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]
      
N,M = map(int,input().split())
List=list(map(int,input().split()))

List2=[list(map(int,input().split())) for i in range(M)]
uf = UnionFind(N+1)

for i in range(M):
  a = List2[i][0]
  b = List2[i][1]  
  uf.Unite(a, b)
  
cnt = 0
for i,w in enumerate(List):
  if uf.Find_Root(i+1) == uf.Find_Root(w):
    cnt += 1
  
print(cnt)

Measured memory_bytes: 104428
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<ll> > Graph;
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; }
const ll INF = 1e9;


int main(){
    ll n,k;
    cin >> n >> k;
    vector<P>v(n);
    rep(i,n){
        ll a,b;cin >> a >> b;
        v[i]={a,b};
    }
    ll now = 0;
    sort(v.begin(),v.end());
    rep(i,n){
        now += v[i].second;
        if(now>=k){
            cout << v[i].first << endl;
            return 0;
        }
    }

}


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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define GOOGLE 0
#define MULTIPLE_TC 0

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  int n, i, j;
  cin >> n;
  set<string> s;
  for(i = 0; i < n; i++){
    string t; cin >> t;
    s.insert(t);
  }
  cout << (int)s.size() << '\n';
}

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

  pre();

  int t = 1, T;

  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}


Measured memory_bytes: 19376
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
    #include "debug.h"
#endif
 
#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const int N = 1e6 + 5;
vector<int> val;
vector<int> v(N);
int n;
 
void solve()
{
    int gcd = 0;
    for(int i : val)
    {
        v[i]++;
        gcd = __gcd(gcd, i);
    }
 
    if(gcd != 1)
    {
        cout << "not coprime\n";
        return;
    }
 
    for(int i = 2; i < N; i++)
    {
        for(int j = i + i; j < N; j += i)
            v[i] += v[j];
        
        if(v[i] > 1)
        {
            cout << "setwise coprime\n";
            return;
        }
    }
 
    cout << "pairwise coprime\n";
}
 
int main()
{
    fast();
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int a; cin >> a;
        val.pb(a);
    }
    solve();
}

Measured memory_bytes: 11312
import math

n,m=map(int,input().split())
A=list(reversed(sorted(map(int,input().split()))))
L=[math.log2(a) for a in A]
L.append(-1)

now=int(L[0]) #log2のどこまで使うか
for i in range(n):
    cnt=m//(i+1)
    d=now-int(L[i+1])
    if cnt<d:
        now-=cnt
        m=m%(i+1)
        break
    else:
        m-=d*(i+1)
        now=int(L[i+1])

for k in range(i+1):
    A[k]/=2**(int(L[k])-now)

A=list(reversed(sorted(A)))
for i in range(min(n,m)):
    A[i]/=2
for i in range(n):
    A[i]=int(A[i])
print(sum(A))

Measured memory_bytes: 15020
import java.util.*;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int a[],n;
        n = sc.nextInt();
        a = new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();
        }
        for(int i=1;i<n;i++){
            int j=i;
            print(a);
            while(j>0){
                if(a[j-1]>a[j]){
                    int k = a[j-1];
                    a[j-1] = a[j];
                    a[j] = k;
                    j--;
                }else{
                    break;
                }
            }
        }
        print(a);
    }
    
    public static void print(int a[]){
        int n=a.length;
        System.out.print(a[0]);
        for(int i=1;i<n;i++){
            System.out.print(" "+a[i]);
        }
        System.out.println("");
    }
}


Measured memory_bytes: 34132