akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define LEN 300
#define TRUE 1
#define FALSE -1
 
int solve(int, int);
int n, A[LEN];
int flag;
 
int main()
{
  int q, M;
  int i, j, k;
 
  scanf("%d", &n);
  for(i=0; i<n; i++)scanf("%d", &A[i]);
 
  scanf("%d", &q);
  for(i=0; i<q; i++)
    {
      scanf("%d", &M);
      flag=FALSE;
 
      solve(-1, M);
      if(flag==TRUE)printf("yes\n");
      else printf("no\n");
    }
 
 
  return 0;
}
 
int solve(int i, int m)
{
  if(i>n)return FALSE;
  else if(m<0)return FALSE;
  else if(m==0 || m-A[i+1]==0)
    {
      flag=TRUE;
      return TRUE;
    }
  else
    {
      //not use A[i]
      solve(i+1, m);
      //use A[i]
      solve(i+1, m-A[i]);
    }
}

Measured memory_bytes: 580
// AOJ 1137
#include<iostream>
#include<string>
#include<map>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

string cdr(string s) {
  if (s.size() == 1) {
    return "";
  } else {
    return s.substr(1);
  }
}

string reverse(string s) {
  string ret;
  for (int i = s.size() - 1; i >= 0; i--) {
    ret.push_back(s[i]);
  }
  return ret;
}

pair<int, string> cut_ixcm(string ixcm) {
  char prefix = ixcm[0];
  int factor;

  if (prefix == 'i') { factor = 1; }
  else if (prefix == 'x') { factor = 10; }
  else if (prefix == 'c') { factor = 100; }
  else if (prefix == 'm') { factor = 1000; }

  if (ixcm.size() == 1) {
    return make_pair(1 * factor, "");
  }
   
  char numeral = ixcm[1];
  if ('0' <= numeral and numeral <= '9') {
    return make_pair(factor * (numeral - '0'), cdr(cdr(ixcm)));
  } else {
    return make_pair(factor, ixcm.substr(1));
  }
}

int mcxi2int(string mcxi) {
  int ret = 0;
  string ixcm = reverse(mcxi);
  while (!ixcm.empty()) {
    pair<int, string> p = cut_ixcm(ixcm);
    ixcm = p.second;
    ret += p.first;
  }
  return ret;
}

string int2mcxi(int n) {
  int i = n % 10, x = (n % 100) / 10, c = (n % 1000) / 100, 
      m = n / 1000;
  string ret;
  
  ret += ((m < 2 ? "" : to_string(m)) + (m == 0 ? "":"m"));
  ret += ((c < 2 ? "" : to_string(c)) + (c == 0 ? "":"c"));
  ret += ((x < 2 ? "" : to_string(x)) + (x == 0 ? "":"x"));
  ret += ((i < 2 ? "" : to_string(i)) + (i == 0 ? "":"i"));

  return ret;
}


string solve(string s1, string s2) {
  return int2mcxi(mcxi2int(s1) + mcxi2int(s2));
}

int main() {
  int n;
  cin >> n;
  REP(i, n) {
   string num1, num2;
   cin >> num1 >> num2;
   cout << solve(num1, num2) << endl;
  }
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;

int main()
{
    int N, M, i, max;

    //vector<string> words;

    map<string, int> words;

    cin >> N;

    vector<string> s = vector<string>(N, "");

    for (i = 0; i < N; i++)
    {
        cin >> s[i];
    }

    cin >> M;

    vector<string> t = vector<string>(M, "");

    for (i = 0; i < M; i++)
        cin >> t[i];

    for (i = 0; i < N; i++)
        words[s[i]]++;

    for (i = 0; i < M; i++)
        words[t[i]]--;

    max = 0;
    for (auto itr = words.begin(); itr != words.end(); itr++)
    {
        if (max < itr->second)
            max = itr->second;
    }

    cout << max << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX 246999

int elatosthenes[MAX];

void prime(void) {
    int i, j;
    for(i = 2; i < MAX / 2; i++) {
        if(!elatosthenes[i]) {
            for(j = 2; i*j < MAX; j++) {
                elatosthenes[i*j] = 1;
            }
        }
    }
}

int main(void) {
    int n, count, i;
    prime();
    scanf("%d",&n);
    while(n) {
        count = 0;
        for(i = n+1; i <= 2*n; i++) {
            if(!elatosthenes[i]) {
                count++;
            }
        }
        printf("%d\n",count);
        scanf("%d",&n);
    }
    return 0;
}
   

Measured memory_bytes: 1564
// https://atcoder.jp/contests/abc101/tasks/arc099_a

#include <algorithm>
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

#define EPS (1e-7)
#define INF (1e9)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, pos = 0;
    vector<int> v;
    cin >> n >> k;
    v.resize(n);

    for (int i = 0; i < n; i++) {
        cin >> v[i];
        if (v[i] == 1) {
            pos = i;
        }
    }

    // // 1に対して左側を変更する回数
    // int ans = 0;
    // int left = pos;
    // int right = pos;
    // while (left > 0) {
    //     left -= (k - 1);
    //     ans++;
    // }
    // // 1に対して右側を変更する回数
    // while (right < n - 1) {
    //     right += (k - 1);
    //     ans++;
    // }
    int ans = ceil((double)(n - 1) / (k - 1));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e6 + 3;

int n, hm[N], dz[N];
bool zloz[N];

signed main() {
  init_ios();
  hm[1] = 1;
  for (int i = 2; i < N; ++i)
    if (!zloz[i]) {
      dz[i] = i;
      for (int j = 2*i; j < N; j += i) {
        zloz[j] = true;
        if (dz[j] == 0)
          dz[j] = i;
      }
    }
  for (int i = 2; i < N; ++i) {
    int p = dz[i];
    int cnt = 0;
    int val = i;
    while (val%p == 0) {
      ++cnt;
      val /= p;
    }
    hm[i] = (cnt+1)*hm[val];
  }
  int res = 0;
  cin >> n;
  for (int c = 1; c < n; ++c)
    res += hm[n-c];
  cout<<res<<"\n";
}

Measured memory_bytes: 20256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main()
{
	int d;
	cin >> d;
	switch(d) {
	case 25:
		cout << "Christmas" << endl;
		break;
	case 24:
		cout << "Christmas Eve" << endl;
		break;
	case 23:
		cout << "Christmas Eve Eve" << endl;
		break;
	case 22:
		cout << "Christmas Eve Eve Eve" << endl;
		break;
	default:
		cout << "Error" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


N = int(input())
A = [int(_) for _ in input().split()]
GCD = gcd(A[0], A[1])

for i in range(1, N-1):
    GCD = gcd(GCD, A[i+1])

print(GCD)

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

int main(){
    int n,m;
    cin >> n >> m;
    int l,r;
    int lmax = 1, rmin = n;

    for(int i = 0;i < m;i ++){
        cin >> l >> r;
        lmax = max(lmax,l);
        rmin = min(rmin,r);
    }

    if(lmax <= rmin){
        cout << rmin - lmax + 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int n,d;cin>>n>>d;
  vector<int> A[n];
  for(int i = 0; n > i; i++){
    for(int j = 0; d > j; j++){
      int t;cin>>t;
      A[i].push_back(t);
    }
  }
  int ans = 0;
  for(int i = 0; n > i; i++){
    for(int j = i+1; n > j; j++){
      int z = 0;
      for(int k = 0; d > k; k++){
        z += (A[i][k]-A[j][k])*(A[i][k]-A[j][k]);
      }
      int i = 0;
      while(z >= i*i){
        if(i*i == z){
          ans++;
        }
        i++;
      }
    }
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
def solve(N):
    digits = [int(d) for d in str(N)]
    tmp_ans = sum(digits)
    if tmp_ans == 1:
        return 10
    else:
        return tmp_ans

# assert(solve(2) == 2) # 1 and 1
# assert(solve(10) == 10) # 5 and 5
# assert(solve(15) == 6) # 2 and 13
# assert(solve(100) == 10) # 50 and 50
# assert(solve(100000) == 10) # 50000 and 50000

N = input()
print(solve(N))


Measured memory_bytes: 2940
import math
import itertools

N = int(input())

Cities = []
for _ in range(N):
  x, y = map(int, input().split())
  Cities.append([x, y])

perm_C = itertools.permutations(Cities)

total = 0
count = 0
for route in perm_C:
  count += 1
  current = route[0]
  distance_sum = 0
  for city in route[1:]:
    distance = math.sqrt(pow(current[0]-city[0], 2) + pow(current[1]-city[1], 2))
    distance_sum += distance
  total += distance_sum

avg = total / count
print("{:.7f}".format(avg))


Measured memory_bytes: 3064
main = do
  s <- getContents
  let primes = 2 : filter (\n -> n > 1 && foldr (\x acc -> x * x > n || (n `mod` x /= 0 && acc)) True primes) [3, 5..]
  mapM_ (\n -> putStrLn . unwords $ map show $ [last $ takeWhile (< n) primes, head $ dropWhile (<= n) primes]) . map read $ lines s

Measured memory_bytes: 5324
#!/usr/bin/env python3

def prime_factor(n):
    ret, p = [], 2
    while p*p <= n:
        if n % p != 0:
            p += 1
            continue
        exp_v = 0
        while n%p == 0:
            exp_v += 1
            n //= p
        ret.append( [p, exp_v] )
        p += 1
    if n != 1: ret.append( [n, 1] )
    return ret


def extgcd(a, b):
    if b == 0:
        return [1, 0, a]
    x, y, g = extgcd(b, a%b)
    return [y, x - a//b * y, g]


def mod_inverse(a, m):
    x, y, _ = extgcd(a, m)
    return (m+x%m) % m


n = int(input())
a = [ int(x) for x in input().split() ]

MOD = 10**9 + 7

primes = {}
for aa in a:
    t = prime_factor(aa)
    for tt in t:
        v, e = tt
        primes[v] = max(e, primes.get(v, 0))

prod = 1
for k, v in primes.items():
    prod *= pow(k, v, MOD)
    prod %= MOD

ans = 0
for aa in a:
    ans += prod*mod_inverse(aa, MOD)
    ans %= MOD

print(ans%MOD)


Measured memory_bytes: 4596
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 1e5 + 10, inf = 1e9;
int n, DP[ 2 ][ 2 ];

int main() {
  int a, ans = 0;
  scanf("%d%d", &n, &a);
  int last = a; DP[ 0 ][ 0 ] = DP[ 0 ][ 1 ] = 1;
  for(int i = 1; i < n; i++) {
    scanf("%d", &a);
    DP[ 1 ][ 0 ] = min(DP[ 0 ][ 0 ] + (a < last), DP[ 0 ][ 1 ] + 1);
    DP[ 1 ][ 1 ] = min(DP[ 0 ][ 0 ] + 1, DP[ 0 ][ 1 ] + (a > last));
    last = a;
    DP[ 0 ][ 0 ] = DP[ 1 ][ 0 ];
    DP[ 0 ][ 1 ] = DP[ 1 ][ 1 ];
  }
  printf("%d\n", min(DP[ 0 ][ 0 ], DP[ 0 ][ 1 ]));
  return 0;
}


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

using namespace std;

int main(void)
{
    int a;
    long b, n;
    cin >> a >> b >> n;

    long ans;

    if (n / b > 0) {
        ans = (a * (b - 1)) / b;
    } else {
        ans = (a * n) / b - a * (n / b);
    }

    cout << ans;

    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n;
    cin >> n;
    int p[n];
    rep(i, n) cin >> p[i];
    int cnt = 0;

    for (int i = 0; i < n;)
    {
        if (p[i] == i + 1)
        {
            cnt++;
            i += 2;
        }
        else
            i++;
    }

    OP(cnt);
    return 0;
}

Measured memory_bytes: 640
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;

unordered_map<int,vector<int>>H;
vector<int>memo;
int dfs(int i){
	if(H.find(i)==H.end())return 0;
	if(memo[i]>=0)return memo[i];
	vector<int>a;
	for(auto &e:H[i])a.push_back(dfs(e));
	sort(a.begin(),a.end(),greater<int>());
	int r=0;
	for(int i=0;i<a.size();i++)r=max(r,a[i]+i+1);
	return memo[i]=r;
}
 
int main(){
	int N;
	scanf("%d",&N);
	memo.resize(N);
	for(int i=0;i<N;i++)memo[i]=-1;
	for(int i=0;i<N-1;i++){
		int a;
		scanf("%d",&a),a--;
		H[a].push_back(i+1);
	}
	printf("%d\n",dfs(0));
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll N;
ll i, j, k;
int main(){
    scanf("%lld", &N);
    j = 0;
    fornum(i,0,N){
        if((i+1)%3==0)
            continue;
        if((i+1)%5==0)
            continue;
        j += i + 1;
    }
    printf("%lld\n", j);
    return 0;
}

Measured memory_bytes: 3816
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a=sc.nextLong();
        long b=sc.nextLong();
        boolean aflag=false;
        boolean bflag=false;
        if(a%2==0){
            a++;
            aflag=true;
            
        }
        if(b%2==1){
            b--;
            bflag=true;
        }
        
        long[] ns=new long[40];
        ns[0]=b-a+1;
        for(int i=1;i<40;i++){
            ns[i]=(long)(b/Math.pow(2,i))-(long)(a/Math.pow(2,i));
            ns[i-1]-=ns[i];
        }
        boolean[] ns2=new boolean[40];
        for(int i=1;i<40;i++){
            if(ns[i]%2==1){
                ns2[i]=true;
            }
        }
        long output=0;
        for(int i=1;i<40;i++){
            if(ns2[i]){
                output=output^((long)Math.pow(2, i+1)-1);
            }
        }
        if(aflag){
            output=output^(a-1);
        }
        if(bflag){
            output=output^(b+1);
        }
        System.out.println(output);

    }
    

}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define PER(i,n) for (int i=(N-1);i>=0;--i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

const int MAX = 510000;
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;
}

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

vector<int> g[200005];
vector<ll> val(200005, 0);
vector<ll> ans(200005, 0);

void dfs(int v, int p){
    ans[v] = val[v] + (p != -1 ? ans[p] : 0);
    for(auto&& s : g[v]) {
        if(s == p) continue;
        dfs(s, v);
    }
}

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

    REP(i, N-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    REP(i, Q) {
        int p, x;
        cin >> p >> x;
        p--;
        val[p] += x;
    }

    dfs(0, -1);

    REP(i, N) cout << (i == 0 ? "" : " ") << ans[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 27264
n = gets.to_i
a = gets.chomp.split.map(&:to_i)
count = 0
for i in 0..n - 1
    minj = i
    for j in minj + 1..n - 1
        if a[minj] > a[j]
            minj = j
        end
    end
    if minj != i
        a[i], a[minj] = a[minj], a[i]
        count += 1
    end
end
puts a.join(" ")
puts count


Measured memory_bytes: 6872
#include<stdio.h>
#define max(a,b) ((a)>(b))?(a):(b)
#define min(a,b) ((a)<(b))?(a):(b)
int main(void)
{
  int n,max=0,ans=0;
  long long a,b;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%lld",&b);
    if(i>0){
      if(a>=b){
        ans++;
        if(ans>max){
          max=ans;
        }
      }else{
        ans=0;
        //max=max(max,ans);
      }
    }
    a=b;
    //printf("i=%d,ans=%d max=%d\n",i,ans,max);
  }
  printf("%d",max);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#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 SORT(v) sort(v.begin(), v.end())
#define REVERSE(v)  reverse(v.begin(), v.end())
typedef long long ll;
using namespace std;

const int MAX_N = 100001;
int memo[MAX_N];

int rec(int n) {
  if(n == 0) return 0;
  if(memo[n] != -1) return memo[n];

  int res = n;

  for(int pow6=1; pow6<=n; pow6*=6) res = min(res, rec(n-pow6)+1);
  for(int pow9=1; pow9<=n; pow9*=9) res = min(res, rec(n-pow9)+1);

  return memo[n] = res;
}


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

  REP(i,MAX_N) memo[i] = -1;
  cout<<rec(N)<<endl;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;

int main(){
	int W,H,N,x[1000],y[1000],res=0;
	scanf("%d%d%d",&W,&H,&N);
	for(int i=0;i<N;i++) scanf("%d%d",&x[i],&y[i]);
	for(int i=0;i<N-1;i++){
		int X=x[i+1]-x[i],Y=y[i+1]-y[i];
		if(X*Y>0) res+=max(abs(X),abs(Y));
		else res+=abs(X)+abs(Y);
	}
	printf("%d\n",res);
}

Measured memory_bytes: 1196
import fractions as f

N = int(input())

A = list(map(int,input().split()))

rightGCD = [0]*N
leftGCD = [0]*N

for i in range(N-1):
    leftGCD[i+1] = f.gcd(leftGCD[i],A[i])
    rightGCD[-i-2] = f.gcd(rightGCD[-i-1],A[-i-1])

#print(leftGCD)
#print(rightGCD)

ans = 0

for i in range(N):
    ans = max(ans,f.gcd(rightGCD[i],leftGCD[i]))

print(ans)


Measured memory_bytes: 16140
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
using namespace std;

const int MAXN = 101;

int cn[26];

string s[MAXN];
string ans[MAXN];;

int h, w;
int rh(int x) {
    return h - 1 - x;
}

int rw(int x) {
    return w - 1 - x;
}

void n() {
    cout << "No\n";
    exit(0);
}


int main() {
#ifdef PAUNSVOKNO
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20);

    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        cin >> s[i];
        ans[i] = s[i];
        for (int j = 0; j < w; j++) {
            cn[s[i][j] - 'a']++;
        }
    }

    for (int i = 0; i < rh(i); i++)
        for (int j = 0; j < rw(j); j++) {
            int cl = 0;
            while ((cl < 26) && cn[cl] < 4) cl++;
            if (cl == 26) {
                n();
            }

            cn[cl] -= 4;
        }

    if (h & 1) {
        for (int j = 0; j < rw(j); j++) {
            int cl = 0;
            while ((cl < 26) && cn[cl] < 2) cl++;
            if (cl == 26) {
                n();
            }

            cn[cl] -= 2;
        }
    }

    if (w & 1) {
        for (int j = 0; j < rh(j); j++) {
            int cl = 0;
            while ((cl < 26) && cn[cl] < 2) cl++;
            if (cl == 26) {
                n();
            }

            cn[cl] -= 2;
        }
    }

    cout << "Yes\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cctype>
using namespace std;
inline int read(int f = 1, int x = 0, char ch = ' ')
{
    while(!isdigit(ch = getchar())) if(ch == '-') f = -1;
    while(isdigit(ch)) x = x*10+ch-'0', ch = getchar();
    return f*x;
}
const int N = 4e3+5, P = 924844033;
int n, m;
int cut[N], h[N][N][2], g[N], f[N], fac[N];
int main()
{
    n = read(), m = read(); fac[0] = 1;
    for(int i = 1; i <= n; ++i) fac[i] = 1ll*fac[i-1]*i%P;
    for(int i = 1, p = 1; i <= m; ++i)
    {
        cut[p] = 1; p += (n-i)/m+1;
        cut[p] = 1; p += (n-i)/m+1;
    }
    for(int i = 0; i <= n<<1; ++i) h[i][0][0] = 1;
    for(int i = 1; i <= n<<1; ++i)
        for(int j = 1; j <= n; ++j)
        {
            h[i][j][0] = (h[i-1][j][0]+h[i-1][j][1])%P;
            if(!cut[i]) h[i][j][1] = h[i-1][j-1][0];
        }
    for(int i = 0; i <= n; ++i) g[i] = 1ll*(h[n<<1][i][0]+h[n<<1][i][1])*fac[n-i]%P;
    for(int i = 0, w = 1; i <= n; ++i, w = P-w) f[n] = (f[n]+1ll*w*g[i]%P)%P; 
    printf("%d\n", f[n]);
    return 0;
}

Measured memory_bytes: 124544
#input
N = int(input())
p = list(map(float, input().split()))

#output
#dp[i][j]をi番目まで選んだ時の表の枚数がj枚である確率とする。

dp = [[0] * (N+1) for _ in range(N+1)]
dp[0][0] = 1

for i in range(N): 
    for j in range(N):
        dp[i+1][j+1] += dp[i][j] * p[i]
        dp[i+1][j] += dp[i][j]*(1-p[i])

print(sum(dp[N][(N+1)//2:]))

Measured memory_bytes: 252168
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

#define keta setprecision(15) //15桁表示

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

	ll n;
	cin >> n;
	vector<ull> a(n);
	rep(i, n)
	{
		cin >> a[i];
	}
	vector<vector<ull>> ket(n, vector<ull>(61,0));
    ull ke=0; 
	for (int i = 0; i < n; i++)
	{
		ll tmp = a[i];
	    ull k = 0;
		while (tmp!=0)
		{
			ket[i][k] += (tmp & 1);
			k++;
			tmp=tmp >> 1;
		}
		ke = max(ke, k);
	}

	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < ke; j++)
		{
			ket[i][j] += ket[i - 1][j];
          ket[i][j]%=1000000007;
		}
	}

    ull ans = 0;
	for (int i = 0; i < n-1; i++)
	{
		for (int j = 0; j < ke; j++)
		{
			if ((a[i] >> j) % 2==0)
			{
				ans += ((ull)pow(2, j)%1000000007) * (ket[n - 1][j] - ket[i][j]);
				ans %= 1000000007;
			}
			else
			{
				ans += ((ull)pow(2, j)%1000000007) * ((n-(i+1))-(ket[n - 1][j] - ket[i][j]));
				ans %= 1000000007;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 155008
from collections import defaultdict

n = int(input())
s = defaultdict(int)

for i in range(n):
    s[input()] += 1

top = max(s.values())
ans = []

for k in s.keys():
    if s[k] == top:
        ans.append(k)

for a in sorted(ans):
    print(a)

Measured memory_bytes: 33372
import sys
MOD = 10**9 + 7
n, m = map(int, input().split())
a = [int(x) for x in sys.stdin.readlines()]
ans = [1 for i in range(n)]
for x in a:
    ans[x-1] = 0
for i in range(n):
    if i == 0 and ans[i] == 0:
        ans[0] = 0
    elif i == 1:
        if ans[i] == 1:
            ans[1] += ans[0]
        elif ans[i] == 0:
            ans[1] = 0
    elif i >= 2 and ans[i] == 1:
        ans[i] = (ans[i-1] + ans[i-2])%MOD

print(ans[-1])

Measured memory_bytes: 13340
#include<bits/stdc++.h>
#define ll long long
#define N 55
using namespace std;

int n;
ll a[N],ans;

int main() {

  scanf("%d",&n);
  for(int i=0;i<n;i++) {
    scanf("%lld",&a[i]);
  }
  bool flag=true;
  while(flag) {
    flag=false;
    for(int i=0;i<n;i++) {
      if(a[i]<n) continue ;
      flag=true;
      ll dv=a[i]/n;
      a[i]%=n;
      ans+=dv;
      for(int j=0;j<n;j++) {
        if(i!=j) {
          a[j]+=dv;
        }
      }
    }
  }
  printf("%lld",ans);

}


Measured memory_bytes: 256
#include <cstdio>
#define MAXN 105
int a[MAXN];
int N,cnt;
void swap(int x,int y) {
    int t=a[x];
    a[x]=a[y];
    a[y]=t;
}
void get_input() {
    scanf("%d",&N);
    for(int i=0;i<N;i++) {
        scanf("%d",&a[i]);
    }
}

void solve() {
    int flag=1;
    for(int j=0;flag;j++) {
        flag=0;
        for(int i=N-1;i>j;i--) {
            if(a[i]<a[i-1]) {
                swap(i,i-1);
                cnt++;
                flag=1;
            } 
        }
    }

}

void display_output() {
    printf("%d",a[0]);
    for(int i=1;i<N;i++) {
        printf(" %d",a[i]);
    }
    printf("\n%d\n",cnt);
}

int main() {
#ifdef debug
    freopen("in.txt","r",stdin);
#endif
    get_input();
    solve();
    display_output();
}

Measured memory_bytes: 2724
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007ll 
#define pb push_back
#define vl vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
using namespace std;
#define pi (long double)3.14159265358979323846 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 struct sch{
  ll s,e,t;
};
bool sortinrev(const struct sch &a, const struct sch &b) 
{ 
    return (a.s < b.s); 
}
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);
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1; 
    x = x % p;  
    while (y > 0) 
    {
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}
int main()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll w=0,r=0;
    ll wt=0,rt=0;
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='W')
        {
            wt++;
        }
        else
        {
            rt++;
        }
    }
    ll ans = min(wt,rt);
    for(ll i=0;i<n;i++)
    {
        if(s[i]=='W')
        {
            w++;
        }
        else
        {
            r++;
        }
        ans = min(ans,max(w,rt-r));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3748
S = input()
L = [0]
for s in S:
    L += [s]
    L += [0]
for i in range(len(L)):
    if L[i] == '<':
        L[i+1] = L[i-1]+1
for i in range(len(L)-1,-1,-1):
    if L[i] == '>':
        L[i-1] = max(L[i-1],L[i+1]+1)
ans = 0
for i in range(len(L)):
    if L[i] not in ['<','>']:
        ans += L[i]
print(ans)

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


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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;
#define X first
#define Y second
#define pb push_back

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fout << vec[i] << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr ll INF = numeric_limits<ll>::max();
constexpr ll MOD = 1e9 + 7;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e5 + 5;

int main()
{
    ll res = 0;
    ll n, d, x; cin >> n >> d >> x;
    vector<ll> a(n); cin >> a;
    for (ll i = 0; i < n; i++) {
        ll b = 1;
        while (b <= d) {
            res++;
            b += a[i];
        }
    }

    cout << res + x << endl;
    return 0;
}


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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* na, Arg1&& arg1, Args&&... args) {
    const char* c = strchr(na + 1, ',');
    cerr.write(na, c - na) << " : " << arg1 << " , ";
    __f(c + 1, args...);
}
#define SZ(v) (int)v.size()
#define endl "\n"
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) sort(ALL(v)),v.erase(unique(ALL(v)),v.end())
typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int inf = 1e9;
const LL INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 5;

void solve() {
    LL x;
    cin >> x;
    string s;
    cin >> s;
    LL n = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '.') continue;
        n = n * 10 + (s[i] - '0');
    }
    cout << (x * n)/100 << endl;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifdef LOCAL
        //freopen("input.txt", "r", stdin);
    #endif
    int t = 1;
    for (int tc = 1; tc <= t; tc++) solve();
    return 0;
}




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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
   
    int n;
    map<int, int> m;
    map<int, int>::iterator it;
    
    cin >> n;
    int t;
    cin >> t;
    m.insert(make_pair(t, 1));
    
    for (int i = 1; i < n; i++) {
        cin >> t;
        it = m.find(t);
        if (it != m.end())
            m.erase(it);
        else
            m.insert(make_pair(t,1));
    }
    cout << m.size();
    
    
    return 0;
}


Measured memory_bytes: 4992
n=gets.to_i
a=$<.map{|e|e.split.map &:to_i}
g=a.find{|x,y,h|h>0}
(0..100).each{|i|(0..100).each{|j|
    v=[g[2]+(g[0]-i).abs+(g[1]-j).abs,0].max
    puts [i,j,v]*' ' if a.all?{|x,y,h|h==[v-(x-i).abs-(y-j).abs,0].max}
}}

Measured memory_bytes: 1788
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const A = BigInt(input[0][0]);
  const B = BigInt(input[1][0]);

  if (A === B) {
    return "EQUAL";
  } else if (A > B) {
    return "GREATER";
  } else {
    return "LESS";
  }
};

console.log(main(read()));


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

using namespace std;

int n,a,b,c,d,i;

int main(){
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	
	int diff = abs(a - b);
	
	if(c > d)
	swap(c, d);
	
	n--;
	
	for(i = 0; i <= n; i++){
		long long ub = (long long)d * i - (long long)c * (n - i);
		long long lb = (long long)c * i - (long long)d * (n - i);
		
		if(ub < lb)
		swap(ub, lb);
		
		if(diff >= lb && diff <= ub)
		return 0 * printf("YES\n");
	}
	
	printf("NO\n");
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define int ll
typedef vector<int> vi;
typedef pair<int,int> pii;

struct edge { int to, cost;};

#define MAX_E 200000
#define MAX_V 100000

vector<edge> g[MAX_E];

int d[MAX_V];

bool ans1=true,ans2=false;

void dfs(int now){
  if(d[now]==-1)d[now]=0;
  int i;
  rep(i,g[now].size()){

    int next=g[now][i].to;
    int c=g[now][i].cost;
    ans2=true;
    if(d[next]==-1){
      d[next]=d[now]+c;
      dfs(next);
    }else if(d[next]!=d[now]+c){
      ans1=false;
      return;
    }
  }

}


signed main(void) {
  int i,j;
  int n,m;
  cin>>n>>m;

  vi p(n,0);  
  rep(i,m){
    int l,r,d;
    cin>>l>>r>>d;
    l--;r--;
    edge e;
    e.to=r;
    e.cost=d;
    g[l].push_back(e);
    p[r]++;
  }

  fill(d,d+n,-1);
  rep(i,n)if(p[i]==0)dfs(i);

  if(ans1 && (ans2 || m==0))
    cout<<"Yes"<<endl;
  else 
    cout<<"No"<<endl;
}


Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int main()
{
	int A, time = 0;

	for (int i = 0; i < 4; i++)
	{
		cin >> A;

		time += A;
	}

	cout << time / 60 << endl;
	cout << time % 60 << endl;

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll ca=0;
if(n==2){
cout << 0 << endl;}
else{
for(ll i=1; i<100000000; i++){
if((n-i)/i<=i){
break;}
if((n-i)%i==0){
ca+=(n-i)/i;}
}
cout << ca << endl;}}


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

int dx[] = {1, 0};
int dy[] = {0, 1};
char maze[110][110];
int h, w;
vector<vector<int>> dp(110, vector<int>(110, INF));
int dfs(int x, int y, char color)
{
	int cnt, tmp;
	if (dp[x][y] != INF) return dp[x][y];
	cnt = INF;
	rep(i, 2)
	{
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (nx > h + 1 || ny > w + 1) continue;
		if ((nx == 0 && ny > 1) || (nx > 1 && ny == 0)) continue;
		if ((nx == h + 1 && ny < w) || (nx < h && ny == w + 1)) continue;
		tmp = dfs(nx, ny, maze[nx][ny]);
		if (color == '#' && maze[nx][ny] == '.') tmp++;
		cnt = min(tmp, cnt); 
	}
	if (cnt == INF) cnt = 0;
	return dp[x][y] = cnt;
}

signed main(void)
{
	cin >> h >> w;

	for (int i = 1; i <= h; i++) 
		for (int j = 1; j <= w; j++)
			cin >> maze[i][j];
	rep(i, h + 2) maze[i][0] = maze[i][w + 1] = '.';
	rep(i, w + 2) maze[0][i] = maze[h + 1][i] = '.';
	dfs(0, 0, maze[0][0]);
	/*rep(i, h + 2)
	{
		rep(j, w + 2)
		{
			if (dp[i][j] == INF)
				cout << "INF  ";
			else
			cout << dp[i][j] << "    "; 
		}
		cout << endl;
	}*/
	cout << dp[0][0] << endl;
	return 0;
}


Measured memory_bytes: 3672
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  bool ac[n+1] = {false};
  int acnt = 0;
  int wcnt[n+1] = {0};
  int p;
  string s;
  rep(i,m){
    cin >> p >> s;
    if(!ac[p]){
      if(s == "AC"){
        acnt++;
        ac[p] = true;
      }else{
        wcnt[p]++;
      }
    }
  }

  int ans = 0;
  for(int i = 1; i < n+1; i++){
    if(ac[i]) ans += wcnt[i];
  }

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


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

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int s = Integer.parseInt(scan.next());
		int m=0;
		int h=0;
		if(s>=60){
			m=s/60;
			s=s%60;
		}
		if(m>=60){
			h=m/60;
			m=m%60;
		}
			System.out.println(h+":"+m+":"+s);
		scan.close();
	}
}

Measured memory_bytes: 17128
#include <iostream>

using namespace std;

int k, a, b;

int main(int argc, char const *argv[]) {
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3128
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		long[] arr = new long[3];
		for (int i = 0; i < 3; i++) {
			arr[i] = sc.nextInt();
			if (arr[i] % 2 == 0) {
				System.out.println(0);
				return;
			}
		}
		Arrays.sort(arr);
		System.out.println(arr[0] * arr[1]);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;


int main(){
    long long n;
    cin >> n;
    vector<pair<long long, long long> > l, r;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        long long d = 0, mn_d = 0;
        for(int j = 0; j < s.size(); ++j){
            if(s[j] == '(') d++;
            else d--;
            mn_d = min(mn_d, d);
        }
        if(d > 0) r.push_back(make_pair(mn_d, d));
        else l.push_back(make_pair(mn_d - d, -d));
    }
    long long sum = 0, d = 0;
    sort(r.rbegin(), r.rend());
    sort(l.rbegin(), l.rend());
    bool intersection = false;
    for(int i = 0; i < r.size(); ++i){
        if(r[i].first + d < 0) intersection = true;
        d += r[i].second;
        sum += r[i].second;
    }
    d = 0;
    for(int i = 0; i < l.size(); ++i){
        if(l[i].first + d < 0) intersection = true;
        d += l[i].second;
        sum -= l[i].second;
    }
    cout << (!sum && !intersection? "Yes":"No");
}

Measured memory_bytes: 19008
#N=gets.to_i
#S=gets.chomp
#A=(0...N).map{gets.to_i}
#sum=A.inject(&:+)
#B=gets.split.map(&:to_i)


r,D,x=gets.split.map(&:to_i)

10.times do |i|
  x=r*x-D
  puts x
end


Measured memory_bytes: 1788
/* ファイル名：ITP1_6_A.c	*/
/* 内容：与えられた数列を逆順に出力する	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名:main	*/
/* 処理内容:与えられた数列を逆順に出力する	*/
int main( void )
{
	/* 内部変数定義	*/
	/*入力	*/
	int n;			/* 数列の長さ			*/
	int array[100];	/* 数列を格納する配列	*/
	/* 処理	*/
	int i;	/* ループ用変数*/
	
	scanf("%d",&n);/* 数列の長さを取得	*/
	
	/* 数列を取得	*/
	for(i = 0; i < n; i++){
		scanf("%d",&array[i]);	/* 数列の要素の取得	*/
	}
	
	/* 数列を逆順で出力	*/
	for(i = (n - 1); i >= 0; i--){
		/* 最後の要素の出力ではない場合	*/
		if(i != 0){
			printf("%d ",array[i]);	/* 要素の後ろにスペースを付けて出力		*/
		}
		/* 最後の要素の出力の場合		*/
		else{
			printf("%d",array[i]);	/* 要素の後ろにスペースを付けずに出力	*/
		}
	}
	
	printf("\n");	/*改行を出力	*/
	return 0;
}



Measured memory_bytes: 2060
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    s = input()

    l = 0
    r = 0

    for char in s:
        if char == "(":
            l += 1
        else:
            if l > 0:
                l -= 1
            else:
                r += 1
    print("(" * r + s + ")" * l)


if __name__ == '__main__':
    main()


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

void print_vec(vector<int> vec) {
    cout << "{";
    for(auto s: vec) cout << s << " ";
    cout << "}" << endl;
}

int gcd(int a,int b) {
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    int lcm = 1;
    rep(i,N) lcm = (A.at(i)*lcm)/gcd(A.at(i),lcm);
    double P = 0;
    rep(i,N) P += lcm / A.at(i);
    printf("%.10f\n",lcm/P);
}

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

using namespace std;

#define ld long double
#define ll long long int
#define endl '\n'
#define check_time() cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define maxarr(A,n) *max_element(A,A+n) 
#define minarr(A,n) *min_element(A,A+n);
#define ft first
#define sd second
#define all(v) (v.begin(),v.end())
#define vll vector<ll> 
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define pb push_back
#define show(x) cout<<#x<<" "<<x<<endl;

void solve()
{
	ll n,i,count1[26]={0},count2[26]={0},flag=0;
	char str1[11],str2[11];
	cin>>str1>>str2;
	if(strlen(str1)+1!=strlen(str2))
		return;
	for(i=0;i<strlen(str1);i++)
		count1[str1[i]-'a']++;
	for(i=0;i<strlen(str2)-1;i++)
		count2[str2[i]-'a']++;
	for(i=0;i<26;i++)
	{
		if(count1[i]!=count2[i])
		{
			flag++;
			break;
		}
	}
	if(flag)
		cout<<"No"<<endl;
	else
	{
		if(str2[strlen(str2)-1]>='a' && str2[strlen(str2)-1]<='z')
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
}

int main()
{
	fastio();

	ll T=1;	//cin>>T;
	while(T--) solve();
	
	//check_time();
	return 0;   
}   



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
double ans;
int n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		int j=0;
		for(j=0;;j++){
			if(i*(1<<j)>=k)break;
		}
		ans+=1.0/(pow(2,j)*1.0);
	}
	ans/=n*1.0;
	cout<<fixed<<setprecision(12)<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
from sys import stdin

n = int(stdin.readline().rstrip())
A = [int(stdin.readline().rstrip()) for _ in range(n)]
count = 0

def sortInsert(A, n, g):
    global count
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j-g
            count += 1

        A[j+g] = v

def sortShell(A, n):
    m = [1]
    while n > 3*m[-1]+1:
        m = m + [3*m[-1]+1]
    
    m = m[::-1]
    print(len(m))
    print(*m)
    for i in range(len(m)):
        sortInsert(A, n, m[i])

sortShell(A, n)
print(count)
print(*A, sep="\n")


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

using namespace std;

int main() {
#ifdef  DEBUG
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
#endif  // for local.
  int n, ans = 0;
  int i, j; // lpc
  cin >> n;
  int d[n];
  for (i = 0; i < n; i++) {
    cin >> d[i];
  }

  for (i = 0; i < n-1; i++) {
    for (j = i+1; j < n; j++) {
      if (i == j) continue;
      ans += d[i] * d[j];
    }
  }

  cout << ans << endl;

  return 0;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    int64_t n, a, b;
    cin >> n >> a >> b;

    vector<int64_t> h(n);
    for (auto&& hh : h) {
        cin >> hh;
    }

    auto cannot_beat = [&](int64_t m) {
        int64_t t = 0;

        for (auto hh : h) {
            auto h1 = hh - m * b;
            if (h1 > 0) {
                t += (h1 - 1) / (a - b) + 1;
            }
        }

        return t > m;
    };

    auto r = irange(0L, 1000000001L);
    auto ans = *partition_point(r.begin(), r.end(), cannot_beat);

    cout << ans << endl;
}

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

const int MAXN = 200000 + 10;

int N, M;
int A[MAXN];
int answer;

int covCnt[MAXN], ptr[MAXN];

void addSeg(int x)
{
	int newL = x - covCnt[x];
	covCnt[x] ++;
	if(newL > 0)
		ptr[newL]++;
	if(newL > 0 && ptr[newL] == 1)
		answer--;
}

void removeSeg(int x)
{
	covCnt[x]--;
	int newL = x - covCnt[x];
	
	if(newL > 0)
		ptr[newL]--;
	if(newL > 0 && ptr[newL] == 0)
		answer++;
}

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

	cin >> N >> M;
	for(int i = 1; i <= N; i++)
		cin >> A[i], addSeg(A[i]);
	answer += N;

	for(int i = 1; i <= M; i++)
	{
		int x, y;
		cin >> x >> y ;
		removeSeg(A[x]);
		A[x] = y;
		addSeg(A[x]);
		cout << answer << endl ;
	}

	return 0;
}



Measured memory_bytes: 3840
#define _CRT_SECURE_NO_WARNINGS
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#define ll long long
#include<bits/stdc++.h>

using namespace std;

int gcd(int x, int y) {
	if (x % y == 0)
		return y;
	else
		return(gcd(y, x % y));
}
int main() {
	int k, a = 1, b = 1, c = 1, i = 1,ans=0;
	cin >> k;
	for(a=1;a<=k;a++){
        for(b=1;b<=k;b++){
            for(c=1;c<=k;c++){
                ans+=gcd(a,gcd(b,c));
            }
        }
    }
    cout<<ans<<endl;
}


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

int main() {
    int N, M, X, Y, i;

    scanf("%d %d %d %d", &N, &M, &X, &Y);
    vector <int> x(N);
    vector <int> y(M);

    for ( i = 0; i < N; i++)
        scanf("%d", &x.at(i));

    sort(x.begin(), x.end());
    reverse(x.begin(), x.end());


    for ( i = 0; i < M; i++)
        scanf("%d", &y.at(i));

    sort(y.begin(), y.end());

    // 条件1 X < Z <= Y
    if (X >= Y) {
        printf("War");
        return 0;
    }

    // 条件1/2 X<Z, Z<=Y
    if (x.at(0) >= y.at(0)) {
        printf("War");
        return 0;
    }

    if (X >= y.at(0)) {
        printf("War");
        return 0;
    }

    if (Y <= x.at(0)) {
        printf("War");
        return 0;
    }

    printf("No War");

    return 0;
}

Measured memory_bytes: 256