akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
ll power(ll x,ll y){
    ll res=1;
    while(y){
        if(y&1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y/=2;
    }
    return res;
}
int main(){
FASTIO;
ll n;
cin>>n;
ll total=power(10,n);
total=(total-power(9,n)+mod)%mod;
total=(total-power(9,n)+mod)%mod;
total=(total+power(8,n))%mod;
cout<<total<<endl;
}


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

#define FOR(i,s,e) for(int i=(s);(i)<(int)(e);++(i))
#define REP(i,e) FOR(i,0,e)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define ppb(x) pop_back(x)
#define mp make_pair
#define mt make_tuple
#define t0(t) get<0>((t))
#define t1(t) get<1>((t))
#define t2(t) get<2>((t))

typedef long long ll;
const int N = 1e6;
const int M = 1e6;
int n;
int a[N], f[M+1];
int p[M+1];

void seive(int m) {
  vector<int> is_p(m+1,1);
  memset(p, 0, sizeof(p));
  int ip = 0;
  REP(i,m+1) is_p[i] = 1;
  is_p[0] = is_p[1] = 0;
  FOR(i,2,m+1) {
    if (is_p[i]) {
      p[ip++] = i;
      for (int j=i*2; j<=m; j+=i) is_p[j] = 0;
    }
  }
}

int gcd(int small, int large) {
  if (small == 0) return large;
  return gcd(large%small, small);
}

int main() {
  memset(f, 0, sizeof(f));
  fscanf(stdin, "%d ", &n);
  REP(i,n) {
    fscanf(stdin, "%d ", a+i);
    f[a[i]]++;
  }

  seive(M);
  int pairwise = 1;
  REP(i,M+1) {
    if (p[i] == 0) break;
    int cnt = 0;
    for (int j=p[i]; j<=M; j+=p[i]) cnt += f[j];
    if (cnt > 1) pairwise = 0;
  }
  if (pairwise) {
    puts("pairwise coprime");
    return 0;
  }

  int g = 0;
  REP(i,n) g = g < a[i] ? gcd(g, a[i]) : gcd(a[i], g);
  if (g == 1) {
    puts("setwise coprime");
    return 0;
  }

  puts("not coprime");
  return 0;
}


Measured memory_bytes: 18860
#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 A,B,C,D;

ll i, j, k;
int main(){
    scanf("%lld%lld%lld%lld", &A, &B,&C,&D);
    i = (A - 1) / D + 1;
    j = (C - 1) / B + 1;
    if(i>=j){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

struct unionfindtree {
    vector<ll> par,rank;
    unionfindtree(int n):par(n,-1),rank(n,0) {}
    int root(int n) {
        if(par[n] < 0) return n;
        else return par[n] = root(par[n]);
    }
    bool same(int i,int j) {
        return root(i) == root(j);
    }
    void unite(int i,int j) {
        int ri = root(i);
        int rj = root(j);
        if(ri == rj) return;

        if(rank[ri] < rank[rj]) {
            par[rj] += par[ri];
            par[ri] = rj;
        } else {
            par[ri] += par[rj];
            par[rj] = ri;
            if(rank[ri] == rank[rj]) rank[ri]++;
        }
    }
};

int main() {
    ll n,m;
    cin >> n >> m;
    vector<P> dc(m);
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        dc[i] = {a,b};
    }
    unionfindtree br(n);
    ll now = n*(n-1)/2;
    vector<ll> ans(m);
    rrep(i,m) {
        ans[i] = now;
        int na = dc[i].first;
        int nb = dc[i].second;
        if(br.same(na,nb)) continue;
        now -= br.par[br.root(na)]*br.par[br.root(nb)];
        br.unite(na,nb);
    }
    rep(i,m) cout << ans[i] << endl;
}

Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;

	vector<vector<int> > res(N, vector<int>(N));

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			int t = (i ^ j);
			res[i][j] = 1;
			while (t % 2 == 0) {
				t /= 2;
				res[i][j]++;
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = i + 1; j < N; j++) {
			cout << res[i][j];
			if (j < N - 1) cout << " ";
		}
		cout << endl;
	}

}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;

template <typename T>
bool chmax(T & a, const T & b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}

template <typename T>
bool chmin(T & a, const T & b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}

using namespace std;
int main(){
	ll K = 100;
	ll X;
	ll cnt = 0;
	cin >> X;
	while (1) {
		cnt++;
		K *= 1.01;
		if (K >= X)break;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int cnt[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    rep(i, M) {
        int s, t;
        cin >> s >> t;
        s--; t--;
        cnt[s]++;
        cnt[t]++;
    }
    //rep(i, N) cout << i << " " << cnt[i] << endl;
    rep(i, N) {
        if(cnt[i] % 2 != 0) {cout << "NO" << endl; return 0;}
    }
    cout << "YES" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    int x,a,b;
    cin>>x>>a>>b;
    x-=a;
    x-=x/b*b;
    cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
//It is so troublesome that I include bits/stdc++.h !
using namespace std;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const long long INF = 100100100100100;
const long long MOD = 1000000007;
typedef pair<int,int> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //最下位ビット(*N)が1の時は単独でNをかける
    if (M & 1) res = (res * N) % MOD;

    return res %= MOD;
}

int gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    //setにlower_bound()が使えるかの実験
    /*
    set<int> SS;
    SS.insert(1);
    SS.insert(2);
    SS.insert(5);
    SS.insert(7);
    SS.insert(8);
    SS.insert(15);
    SS.insert(30);
    int it = *SS.lower_bound(6);
    cout << it << endl;
    */

    
    int N;cin >> N;
    string S;cin >> S;
    int Q;cin >> Q;
    //各アルファベットの場所を表す
    vector<set<int>> alpha(26); 
    for(int i = 0;i<S.size();i++){
        char C = S.at(i);
        alpha.at(C-'a').insert(i);
    }

    for(int i = 0;i<Q;i++){
        int type;cin >> type;
        if(type == 1){
            int index;cin >> index;index--;
            char to;cin >> to;
            char from = S.at(index);
            alpha.at(from-'a').erase(index);
            alpha.at(to-'a').insert(index);
            S.at(index) = to;
        }
        if(type == 2){
            //各アルファベットについて(l,r)の中に含まれるか
            int L,R;cin >> L >> R;L--;R--;
            int ans = 0;
            for(int j = 0;j<26;j++){
                auto it = alpha.at(j).lower_bound(L);
                //存在しないときは末尾のイテレータを指す
                if(it == alpha.at(j).end()) continue;
                if(*it <= R) ans++;
            }
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 27244
"use strict";

const main = (input) => {
    const spi = input.split('\n');
    const [n, k] = spi[0].split(' ').map(e => parseInt(e));
    const p = spi[1].split(' ').map(e => parseInt(e));

    p.sort(function(a, b){
        return a - b;
    });

    let ans = 0;
    for (let i = 0; i < k; i++) {
        ans += p[i];
    }

    console.log(ans);
};

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


Measured memory_bytes: 29744
# encoding:utf-8

import copy
import numpy as np
import random

s = list(str(input()))
t = list(str(input()))

s.sort()
t.sort(reverse=True)
# print(s,t)

ans = False
min_str = min(len(s),len(t))
for i in range(min_str):
    if s[i]==t[i]:
        if min_str-1 == i and len(t)>len(s):
            ans = True
    elif s[i]>t[i]:
        ans = False
        break
    else:
        ans = True
        break

if ans:
    print("Yes")
else:
    print("No")


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

int main()
{
  int n, x, minv, profit = -1000000000;
  cin >> n;

  // 最初の価格を minv の初期値とする
  cin >> minv;
  
  for (int i = 0; i < n - 1; i++)
  {
    cin >> x;
    
    // 今売る場合、最大利益は現在価格 x から minv を引いたもの
    // これと過去の最大利益を比べ、大きい方を記録しておく
    profit = max(x - minv, profit);

    // x が過去最低額の場合、minv を更新する
    minv = min(x, minv);
  }

  cout << profit << endl;

  return 0;
}



Measured memory_bytes: 3108
N=int(input())
A=list(map(int,input().split()))

L=[0]*9
for a in A:
    if a//400<=7:
        L[a//400]=1
    else:
        L[8]+=1

if sum(L[:-1])==0:
    print(1,sum(L))
else:
    print(sum(L[:-1]),sum(L))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}
 
ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
using namespace std;

void solve()
{
  string s;
  cin >> s;
  bool ok = false;
  rep(i, s.size())
  {
    if(s[i]=='7')
      ok = true;
  }
  if(ok)
    cout << "Yes";
  else
    cout << "No";
}

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


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

int main() {
  int x, a, b;
  cin >> x >> a >> b;
  int tmp = b - a;
  if (tmp <= 0) return cout << "delicious" << "\n", 0; 
  if (tmp <= x) return cout << "safe" << "\n", 0;
  cout << "dangerous" << "\n";
}

Measured memory_bytes: 3640
n = int(input())
s = "abcdefghij"

class Node:
    __slots__ = ["string", "index"]
    def __init__(self, string, index):
        self.string = string
        self.index = index

    def get_children(self):
        parent = self.string
        out = [None]*(self.index+1)
        for i, c in enumerate(s[:self.index+1], 1):
            out[i-1] = Node(parent+c, max(i, self.index))
        return out

root = Node("a", 1)
children = [root]
for _ in range(n-1):
    parents, children = children, []
    for parent in parents:
        children.extend(parent.get_children())
for child in children:
    print(child.string)

Measured memory_bytes: 21828
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
T = [i() for _ in range(N)]
num = 1
for i in range(N):
    num = lcm(num,T[i])
print(num)

Measured memory_bytes: 77460
#include <iostream>

using namespace std;

int main(){
    long H, M, ans;

    cin >> H >> M;
    if(H==1 || M==1) {
        ans = 1;
    }else if(H%2==0){
        ans = H/2 * M;
    }else if(M%2 == 0){
        ans = M/2 *H;
    }else{
        ans = (H-1)/2*M + (M+1)/2;
    }

    cout << ans << endl;

    return 0;
}

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

int main()

{
    int n,i,number,cnt=0,j;

    cin >> n;

    i = n;

    while(1)
    {
        for(j=1; j<=i; j++)
        {
            if(i>2&&i%j==0)
            {
                cnt++;
            }
        }

        if(i==2)
        {
            cout << 2 << " " ;

            break;
        }

        else if(cnt!=2)
        {
           cnt=0;
           i++;
           continue;
        }

        else if(cnt==2)
        {
            cout << i << " " ;

            break;
        }
    }
}


Measured memory_bytes: 3592
#include <iostream>

int main() {
    int n;
    std::cin >> n;
    int l, i = 0, min = 0, max = 0;
    while (std::cin >> l) {
        if (i == 0) {
            min = l;
            max = l;
        }
        if (l < min) {
            min = l;
        }
        if (max < l) {
            max = l;
        }
        i++;
        if (i >= n)
            break;
    }
    std::cout << max-min << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
main(){
	int a[4],ar[3],n=2;
	for(;n;n--){
	scanf("%d%d%d%d",a,a+1,a+2,a+3);
	ar[n]=*a+a[1]+a[2]+a[3];
	}
	printf("%d\n",ar[1]>ar[2]?ar[1]:ar[2]);
}

Measured memory_bytes: 0
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    String othello;
    char[] field;
    int i;

    othello = sc.next();
    field = new char[othello.length()];
    for(i = 0;i < field.length;i++){
      field[i] = othello.charAt(i);
    }

    if(field[0] == 'x' && field[field.length - 1] == 'x'){
      System.out.println("x");
    }else{
      System.out.println("o");
    }

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

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

int main() {
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    vector<ll> v(4);
    v[0]=a*c;
    v[1]=a*d;
    v[2]=b*c;
    v[3]=b*d;
    sort(v.begin(),v.end());
    cout<<v[3]<<endl;
    
}
// 0 0 1 3 5
// 0 0 2 4 6 

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
from collections import deque
def main():
    S = input().rstrip("\r\n")
    Q = int(input())
    d = deque(S)
    reverse = False
    for _ in range(Q):
        q = input().rstrip("\r\n")
        if q == "1":
            reverse = not reverse
        else:
            _, f, c = q.split()
            if (f == "1" and not reverse) or (f == "2" and reverse):
                d.appendleft(c)
            else:
                d.append(c)
    l = list(d)
    if reverse:l.reverse()
    print("".join(l))
if __name__ == "__main__":
    main()

Measured memory_bytes: 67360
#![allow(dead_code, unused_variables, unused_macros, unused_imports)]

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes .by_ref() .map(|r|r.unwrap() as char) .skip_while(|c|c.is_whitespace()) .take_while(|c|!c.is_whitespace()) .collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} }; ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => { let mut $var = read_value!($next, $t); input_inner!{$next $($r)*} }; }
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input! {
        n: usize,
        mut m: i64,
        mut d: [(i64, i64); n],
    }

    let mut ans = 0;
    d.sort_by(|&(a1, _), &(a2, _)| a1.cmp(&a2));
    for &(a, b) in d.iter() {
        if m > b {
            ans += a * b;
            m -= b;
        } else {
            ans += a * m;
            break;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 6396
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
int main()
{
    long a,b;
    cin>>a>>b;
    if(a+b<10)cout<<a+b;
    else cout<<"error";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;

int main(){
	stack<int> s;
	int n;
	while(cin>>n){
		if(n == 0){
			cout << s.top() << endl;
			s.pop();
		}else{
			s.push(n);
		}
	}
	return 0;
}

Measured memory_bytes: 1196
N = int(input())
A = list(map(int, input().split()))
MOD = 10 ** 9 + 7

bucket = [0] * 61
for num in A:
    for j in range(60):
        if (num >> j) & 1:
            bucket[j] += 1
# print(bucket)

ans = 0
res = 1
for i, one in enumerate(bucket):
    temp = (bucket[i] * (N - bucket[i]) * res) % MOD
    # print(temp)
    ans = (ans + temp) % MOD
    res = (res * 2) % MOD
print(ans)

Measured memory_bytes: 125496
n = int(input())
a = list(map(int,input().split()))
b = []
wk = wk1 = 0

for i in range(n):
    if a[i]%2 == 0:
        b.append(a[i])

for j in range(len(b)):
    if b[j]%3 == 0 or b[j]%5 == 0:
        wk = 1
    else:
        wk1 = 1
if wk1 == 1:
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll mod=1e9+7;
const int inf=1<<30;

map<i_i,ll> mp;

i_i sm(int i){
  int m=i%10;
  string t=to_string(i);
  int s=t[0]-'0';
  return i_i(s,m);
}

int main(){
  int N; cin >> N;
  for(int i=1;i<=N;i++){
    mp[sm(i)]++;
  }
  ll ans=0;
  for(int i=1;i<=N;i++){
    ans+=mp[i_i(sm(i).second,sm(i).first)];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
int pariton(int*,int,int);
int main(){
  int A[N],n,r,x;
  int i,j;
  scanf("%d",&n);  
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  x = A[n-1];
  r=partition(A,0,n-1);
  printf("%d",A[0]);
  for(i=1;i<n;i++){
    if(i == r) printf(" [%d]",A[i]);
    else printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}

int partition(int *A,int p,int r){
  int x,n;
  int i,j;
  int tmp1,tmp2;
  n=r;
  x = A[r];
  i = p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i=i+1;
      tmp1=A[i];
      A[i]=A[j];
      A[j]=tmp1;
    }
  }
  tmp2=A[i+1];
  A[i+1]=A[r];
  A[r]=tmp2;
  return i+1;
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
#define FORA(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int mod=1000000007;
typedef long long ll;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,x=0,m=mod;
cin>>n;
int a[n],b[n];
FOR(i,n)
{
	cin>>a[i];
     m=min(m,a[i]);
     b[i]=m;
 } 
 FOR(i,n)
{
if(a[i]==b[i])
{
	x++;
}

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





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

using namespace std;

int gcd(int x, int y) {
  if(x < y) {
    swap(x,y);
  }
  int r;
  while(y > 0) {
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  int n,X;
  cin >> n >> X;
  int x[n];
  for(int i = 0; i < n; i++) {
    cin >> x[i];
  }
  long long ans = abs(X - x[0]);
  for(int i = 0; i < n; i++) {
    long long tmp = abs(X-x[i]);
    ans = gcd(tmp,ans);
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<string> s(n), t;
  for (int i = 0; i < n; i++) {
    cin >> s.at(i);
    t.push_back(s.at(i));
  }
  sort(t.begin(), t.end()); sort(s.begin(), s.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  vector<pair<string, int>> p(t.size());
  int max_num = 0;
  vector<string>::iterator itr = s.begin();
  int k = 0;
  
  for (int j = 0; j < t.size(); j++) {
    int n_count = 0;
    
    while (true) {
      if (s.at(k) == t.at(j)) n_count++;
      else break;
      k++;
      if (k >= n) break;
    }
    
    //size_t n_count = count(itr, s.end(), t.at(j));
    //itr = itr + n_count;
    p.at(j) = make_pair(t.at(j), n_count);
    max_num = max(max_num, n_count);
  }
  //sort(p.begin(), p.end());
  
  for (int j = 0; j < t.size(); j++) {
    if (p.at(j).second == max_num) {
      cout << p.at(j).first << endl;
    }
  }
  
  return 0;
}



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

using namespace std;
const int mod = 1e9+7;
int ad(int x,int y) { x+=y; return x>=mod?x-mod:x; }
int sb(int x,int y) { x-=y; return x<0?x+mod:x; }
int mu(int x,int y) { return 1ll*x*y%mod; }
int ksm(int a,int b) {
	int ans = 1;
	for(;b;b>>=1,a=mu(a,a))
		if(b&1) ans = mu(ans,a);
	return ans;
}
int fac[4000005],piv[4000005],n,k;
int GC(int a,int b) {
	if(a<b) return 0;
	return mu(fac[a],mu(piv[b],piv[a-b]));
}
int f[2005][2005];
int main() {
	scanf("%d%d",&n,&k);
	if(k==1) {
		puts("1"); return 0;
	}
	fac[0] = 1;
	for(int i=1;i<=n*k;i++) fac[i] = mu(fac[i-1],i);
	piv[n*k] = ksm(fac[n*k],mod-2);
	for(int i=n*k-1;i>=0;i--) piv[i] = mu(piv[i+1],i+1);
	f[0][0] = 1;
	for(int i=1;i<=n;i++) {
		f[i][0] = 1;
		for(int j=1;j<=i;j++) {
			f[i][j] = ad(f[i-1][j],mu(GC((n-i)+(n-j+1)*(k-1)-1,k-2),mu(f[i][j-1],n-j+1)));
		}
	}
	printf("%d",f[n][n]);
}

Measured memory_bytes: 46336
#include <iostream>

using namespace std;

int main(void)
{
	int num, limit, sum = 0;
	int donut, min_donut = 1000;

	cin >> num >> limit;

	for (int i = 0; i < num; i++)
	{
		cin >> donut;
		sum += donut;

		if (donut < min_donut)
		{
			min_donut = donut;
		}

	}

	cout << num + (limit - sum) / min_donut << endl;
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

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

    int ans;

    if(b % a == 0){
        ans = a + b;
    }else{
        ans = b - a;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe";
    else cout<<"safe";
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
*/

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define int long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

const int maxw = 20010;
struct box{
	int w,s,v;
	bool operator <(const box other )
	{
		return w + s < other.w + other.s;
	}
};
	
int32_t main()
{
	IOS
	int n;cin>>n;
	vector<box>a(n);
	for(int i=0;i<n;i++)
	cin>>a[i].w>>a[i].s>>a[i].v;
	
	sort(a.begin(),a.end());
	
	vector<int>dp(maxw);
	for(int i=0;i<n;i++)
	{
		for(int j=a[i].s;j>=0;j--)
		{
			if( j + a[i].w <= maxw )
			{
				dp[j+a[i].w] = max( dp[j+a[i].w] , dp[j] + a[i].v );
			}
		}
	}
	int maxv = 0;
	for(int i=0;i<maxw;i++)
	maxv=max(maxv,dp[i]);
	
	cout << maxv << endl;
	
}


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

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  string ans = "";
  ans += a[0] - 'a' + 'A';
  ans += b[0] - 'a' + 'A';
  ans += c[0] - 'a' + 'A';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
while True:
  m,f,r = map(int, input().split())
  if m==-1 and f==-1 and r==-1:
    break

  if m==-1 or f==-1:
    print('F')
  elif m+f>=80:
    print('A')
  elif 65<=m+f:
    print('B')
  elif 50<=m+f:
    print('C')  
  elif 30<=m+f:
    if r>=50:
      print('C')
    else:
      print('D')
  else:
    print('F')


Measured memory_bytes: 5592
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int R=0;
    cin >>R;
    string contest;
    if(R<1200)
    {
        contest = "ABC";
    }
    else if(R<2800){
        contest ="ARC";
    }
    else{
        contest ="AGC";
    }
    cout << contest << endl;
    
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
0-1 BFS
"""



from collections import deque
N = int(input())
INF = 10**9

A = [int(input()) for _ in range(N)] + [0]*6
B = [INF]*(N+6)
B[0] = 0

Q = deque([[0, 0]])

while Q:
    x, y = Q.popleft()
    if x >= N-1:
        print(y)
        break
    if B[x] < y:
        continue

    if A[x] == 0:
        for i in range(1, 7):
            if y + 1 < B[x+i]:
                B[x+i] = y + 1
                Q.append([x+i, y+1])
    else:
        if y < B[x+A[x]]:
            B[x+A[x]] = y
            Q.appendleft([x+A[x], y])


Measured memory_bytes: 8964
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>
#include <stack>

using namespace std;

#define rep(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

string in;

int dfs(int l, int r, int P, int Q, int R){
  int N = in.length(),i,res=0;

  if(l + 1 == r){
    if(in[l] == '0' || in[l] == '1' || in[l] == '2') return in[l]-'0';
    if(in[l] == 'P') return P;
    if(in[l] == 'Q') return Q;
    if(in[l] == 'R') return R;
  }
  if(in[l] == '-'){
    return 2 - dfs(l+1,r,P,Q,R);
  }
  if(in[l] == '('){
    int op = 0;
    for(i = l+1; i < r-1; i++){
      if(in[i] == '(') op++;
      if(in[i] == ')') op--;
      if(op == 0 && (in[i] == '*')) return min(dfs(l+1,i,P,Q,R),dfs(i+1,r-1,P,Q,R));
      if(op == 0 && (in[i] == '+')) return max(dfs(l+1,i,P,Q,R),dfs(i+1,r-1,P,Q,R));
    }
  }
}

int main(){
  int i;

  while(1){
    cin >> in;
    if(in == ".") break;

    int j,k,ans=0;
    rep(i,3) rep(j,3) rep(k,3){
      if(dfs(0,in.length(),i,j,k) == 2) ans++;
    }

    cout << ans << endl;
  }

  return 0;
}

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

using namespace std;

typedef long long ll;

template< typename Monoid >
struct SegmentTree {
  using F = function< Monoid(Monoid, Monoid) >;

  int sz;
  vector< Monoid > seg;

  const F f;
  const Monoid M1;

  SegmentTree(int n, const F f, const Monoid &M1) : f(f), M1(M1) {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x) {
    seg[k + sz] = x;
  }

  void build() {
    for(int k = sz - 1; k > 0; k--) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x) {
    k += sz;
    seg[k] = x;
    while(k >>= 1) {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b) {
    Monoid L = M1, R = M1;
    for(a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
      if(a & 1) L = f(L, seg[a++]);
      if(b & 1) R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const {
    return seg[k + sz];
  }
};



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

	int n;
	cin >> n;
	
	string s;
	cin >> s;

	vector<SegmentTree<int>> seg(
		26, SegmentTree<int>(n, [](int a, int b) { return a + b; }, 0)
	);

	rep(i, n){
		int v = seg[s[i] - 'a'].query(i, i+1);
		seg[s[i] - 'a'].update(i, v + 1);
	}
	int q;
	cin >> q;

	rep(i, q){
		int t;
		cin >> t;
		if(t == 1){
			int x;
			char c2;
			cin >> x >> c2;
			x--;

			char c1 = s[x];
			int v1 = seg[c1 - 'a'].query(x, x+1);
			seg[c1 - 'a'].update(x, v1 - 1);
			
			s[x] = c2;
			int v2 = seg[c2 - 'a'].query(x, x+1);
			seg[c2 - 'a'].update(x, v2 + 1);
		}else{
			int l, r;
			cin >> l >> r;
			l--;
			r--;

			int ans = 0;
			for(int j = 0; j < 26; j++){
				int v = seg[j].query(l, r+1);
				if(v > 0) ans++;
			}

			cout << ans << endl;
		}
	}
	

}


Measured memory_bytes: 111644
#include<bits/stdc++.h>
#include<cstring>
#define N 3005
using namespace std;
const int mod=1e9+7;
int n,m;
char t[N];
int s[N],val[N],dp[2][N];
int main(){
	//freopen("in.txt","r",stdin);
	scanf("%d%d%s",&n,&m,t+1);
	for(int i=1;i<=n;i++) s[i]=t[i]-'0'+s[i-1];
	int cnt=0;
	for(int i=1,ml,mr;i<=m;i++)
		scanf("%d%d",&ml,&mr),val[ml]=max(val[ml],mr);
	for(int i=1;i<=n;i++) val[i]=max(max(i,val[i]),val[i-1]); 
	int now=0;
	dp[now][0]=1;
	for(int i=1;i<=n;i++,now^=1){
		memset(dp[now^1],0,sizeof(dp[0]));
		for(int j=max(0,s[val[i]]-(val[i]-i));j<=s[val[i]];j++)
			dp[now^1][j]=(dp[now][j]+ (j==0?0:dp[now][j-1]) )%mod;
	}
	cout<<dp[now][s[n]]<<endl;
	return 0;
}

Measured memory_bytes: 256
<?php
// C
fscanf(STDIN, '%d %d', $k, $n);
$a = array_map('intval', explode(' ', trim(fgets(STDIN))));
$max = 0;
for ($i = 0; $i < $n; $i++) {
    if ($i !== 0) {
        $max = max($a[$i] - $a[$i - 1], $max);
    } else {
        $max = max($k + $a[$i] - $a[$n - 1], $max);
    }
}
echo $k - $max;

Measured memory_bytes: 27248
#include<stdio.h>

int main(){
  char c[3];
  
  scanf("%c %c %c", &c[0], &c[1], &c[2]);
  
  if(c[0] == c[1] && c[1] == c[2]){
    printf("No");
  }
  else if(c[0] == c[1] || c[0] == c[2] || c[1] == c[2]){
    printf("Yes");
  }
  else{
    printf("No");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

long int longabs(long int); //ライブラリにあるabsはint型を受け取る関数

int main(){
  long int min=100,x,n,k;
  int i;
  scanf("%ld %ld",&n,&k);
  
  if(longabs(n-(n/k)*k)>longabs(n-((n/k)+1)*k))
    printf("%ld",longabs(n-((n/k)+1)*k));
  else
    printf("%ld",longabs(n-(n/k)*k));
}

long int longabs(long int a){
  if(a<0)
    return -a;
  else
    return a;
}

Measured memory_bytes: 128
#include<stdio.h>
#define N 36
 
typedef struct{
  char a;
  int b;
}trump;
 
int main(){
 
  int n,minnn,i,j;
  trump Hira[N],d[N],s;
 
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c%d",&Hira[i].a,&Hira[i].b);
    d[i]=Hira[i];
  }
 
  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(Hira[j].b<Hira[j-1].b){
	s=Hira[j];
	Hira[j]=Hira[j-1];
	Hira[j-1]=s;
      }
    }
  }
  for(i=0;i<n-1;i++){
    printf("%c%d ",Hira[i].a,Hira[i].b);
  }
  printf("%c%d\n",Hira[n-1].a,Hira[n-1].b);
  printf("Stable\n");
 
  for(i=0;i<n;i++){
    minnn=i;
    for(j=i;j<n;j++){
      if(d[j].b<d[minnn].b){ 
	minnn=j;
      }    
    }
    if(i!=minnn){
      s=d[i];
      d[i]=d[minnn];
      d[minnn]=s;
    }
  }
 
  for(i=0;i<n-1;i++){
    printf("%c%d ",d[i].a,d[i].b);
  }
  printf("%c%d\n",d[n-1].a,d[n-1].b);
  for(i=0;i<n;i++){
    if(Hira[i].a!=d[i].a){ 
      j=0; break;
    }
    else if(Hira[i].a==d[i].a) j=1;
  }
  if(j==0)  printf("Not stable\n");
  else if(j==1)  printf("Stable\n");
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> D(N);
  for(int i=0;i<N;i++)  cin >> D.at(i);
  int M;
  cin >> M;
  vector<int> T(M);
  for(int i=0;i<M;i++)  cin >> T.at(i);

  map<int,int> mp;
  for(int i=0;i<N;i++)  mp[D.at(i)]++;
  for(int i=0;i<M;i++){
    if(!mp.count(T.at(i))){
      cout << "NO" << endl;
      return 0;
    }
    if(mp.at(T.at(i))==0){
      cout << "NO" << endl;
      return 0;
    }
    mp[T.at(i)]--;
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 11136
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int A=sc.nextInt();
    int B=sc.nextInt();
    int C=sc.nextInt();
    
    if(A-B==0&&C-A!=0) System.out.println("Yes");
    else if(A-C==0&&B-A!=0) System.out.println("Yes");
    else if(B-C==0&&C-A!=0) System.out.println("Yes");
    else System.out.println("No");
  }
}

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

typedef long long ll;

int main() {
    vector<int> A(3);
    rep(i, 3) cin >> A[i];
    int ans = 0;
    sort(A.begin(), A.end());
    while (A[0] < A[2]) {
        ans++;
        if (A[0] != A[1]) A[0] += 2;
        else {
            A[0]++;
            A[1]++;
        }
        sort(A.begin(), A.end());
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#include<stack>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    vector<string>vs(n);
    for(int i=0;i<n;i++)cin>>vs[i];
    vector<pair<int,int> >sp;
    vector<pair<int,char> >sta;
    if(n==1){
      cout<<vs[0]<<endl;
    }else{
      for(int i=0;i<n;i++){
	string str=vs[i];
	if(!sta.empty()&&(str.size()!=(sta[sta.size()-1].F+1))){
	  if(sta[sta.size()-1].S=='+'){
	    int sum=0;
	    while(sp[sp.size()-1].S==sta[sta.size()-1].F+1){
	      int num=sp[sp.size()-1].F;
	      sp.pop_back();
	      sum+=num;
	    }
	    //cout<<sum<<endl;
	    sp.pb(mp(sum,sta[sta.size()-1].F));
	    sta.pop_back();
	  }else if(sta[sta.size()-1].S=='*'){
	    int sum=1;
	    while(sp[sp.size()-1].S==sta[sta.size()-1].F+1){
	      int num=sp[sp.size()-1].F;
	      sp.pop_back();
	      sum*=num;
	    }
	    //cout<<sum<<endl;
	    sp.pb(mp(sum,sta[sta.size()-1].F));
	    sta.pop_back();
	  }
	  i--;
	}else if(str[str.size()-1]=='+'){
	  sta.pb(mp(str.size(),'+'));
	}else if(str[str.size()-1]=='*'){
	  sta.pb(mp(str.size(),'*'));
	}else{
	  if((sta.empty())||(str.size()==(sta[sta.size()-1].F+1))){
	    char ccc=str[str.size()-1];
	    int nnn=ccc-'0';
	    sp.pb(mp(nnn,str.size()));
	  }
	}
      }
      while(sta.size()!=1){
	if(sta[sta.size()-1].S=='+'){
	  int sum=0;
	  while(sp[sp.size()-1].S==sta[sta.size()-1].F+1){
	    int num=sp[sp.size()-1].F;
	    sp.pop_back();
	    sum+=num;
	  }
	  sp.pb(mp(sum,sta[sta.size()-1].F));
	  sta.pop_back();
	}else if(sta[sta.size()-1].S=='*'){
	  int sum=1;
	  while(sp[sp.size()-1].S==sta[sta.size()-1].F+1){
	    int num=sp[sp.size()-1].F;
	    sp.pop_back();
	    sum*=num;
	  }
	  sp.pb(mp(sum,sta[sta.size()-1].F));
	  sta.pop_back();
	}
      }
      int ans=0;
      if(sta[0].S=='+'){
	for(int i=0;i<sp.size();i++){
	  ans+=sp[i].F;
	  //cout<<sp[i].F<<endl;
	}
      }else{
	ans=1;
	for(int i=0;i<sp.size();i++){
	  ans*=sp[i].F;
	//cout<<sp[i].F<<endl;
	}
      }
      //cout<<sta.size()<<" "<<sp.size()<<endl;
      cout<<ans<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
int main(void){
 
    int N,L,min = 1000,c=0;
    cin >> N >> L;

    for(int i=1;i<=N;i++){
        if(min > abs(L + i -1)) min = abs(L + i -1);
        c += (L + i - 1);
    }
    if(c >= 0){
        cout << c - min <<endl;
    }
    else{
        cout << c + min << endl;
    }
    
}

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

#標準出力からの読み込み

input_1 = input()
a = int(input_1.split(" ")[0])
b = int(input_1.split(" ")[1])
c = int(input_1.split(" ")[2])
k = int(input_1.split(" ")[3])

max_value = 0

if k <= a:
    max_value = k
elif k <= b:
    max_value = a
else:
    max_value = a - (k - a - b)

print(max_value)


Measured memory_bytes: 9132
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

double length(double x1, double y1, double x2, double y2) {
    return sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));
}

double round(double d) {
    if (d < 0) {
        d *= 1000;
        d -= 0.5;
        int i = d;
        d = i / 1000.0;
    } else {
        d *= 1000;
        d += 0.5;
        int i = d;
        d = i / 1000.0;
    }

    return d;
}

int main() {

    int n;
    cin >> n;

    double x1, y1, x2, y2, x3, y3, px, py, r;
    for (int i = 0; i < n; ++i) {
        cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

        px = ((y1 - y3) * (pow(x1, 2) - pow(x2, 2) + pow(y1, 2) - pow(y2, 2)) - (y1 - y2) * (pow(x1, 2) - pow(x3, 2) + pow(y1, 2) - pow(y3, 2))) / ((x1 - x2) * (y1 - y3) - (x1 - x3) * (y1 - y2)) / 2.0;
        py = ((x1 - x3) * (pow(x1, 2) - pow(x2, 2) + pow(y1, 2) - pow(y2, 2)) - (x1 - x2) * (pow(x1, 2) - pow(x3, 2) + pow(y1, 2) - pow(y3, 2))) / ((x1 - x3) * (y1 - y2) - (x1 - x2) * (y1 - y3)) / 2.0;
        r = length(x1, y1, px, py);

        px = round(px);
        py = round(py);
        r = round(r);

        cout << fixed << setprecision(3) << px << " " << py << " " << r << endl;
    }

    return 0;
}

Measured memory_bytes: 1288
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int n;
	cin >> n;
	map<string, int> pl;
	int sum = 0;
	rep(i, n) {
		string tit;
		int tim;
		cin >> tit >> tim;
		sum += tim;
		pl[tit] = sum;

	}
	string x;
	cin >> x;

	int ans = sum - pl[x];
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main(){ 
long long int a;
 long long int b;
    cin>>a;
    b=a/11;
    if(a%11>6)cout<<2*b+2;
    else if(a%11==0)cout<<2*b;
    else cout<<2*b+1;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
int val[200005];
int head[200005], nxt[400005], to[400005], cnt;
int vis[200005];
int vis2[200005];
int vis3[200005];
void add(int f, int t) {
    nxt[++cnt] = head[f];
    head[f] = cnt;
    to[cnt] = t;
    return ;
}
int res;
int yo[200005];
void dfs1(int u, int fa) {
    vis[u] = 1;
    yo[val[u]] = 1;
    for (int i = head[u]; i; i = nxt[i]) {
        int v = to[i];
        if (vis[v]) continue;
        dfs1(v, u);
    }
    return ;
}


void dfs2(int u, int fa) {
    if (yo[u]) {
        res++;
    }
    vis2[u] = 1;
    for (int i = head[u]; i; i = nxt[i]) {
        int v = to[i];
        if (vis2[v]) continue;
        dfs2(v, u);
    }
    return ;
}


void dfs3(int u, int fa) {
    yo[val[u]] = 0;
    vis3[u] = 1;
    for (int i = head[u]; i; i = nxt[i]) {
        int v = to[i];
        if (vis3[v]) continue;
        dfs3(v, u);
    }
    return ;
}


int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &val[i]);
    }
    for (int i = 1; i <= m; ++i) {
        int u, v;
        scanf("%d%d", &u, &v);
        add(u, v);
        add(v, u);
    }
    for (int i = 1; i <= n; ++i) {
        if (!vis[i]) {
            dfs1(i, 0);
            dfs2(i, 0);
            dfs3(i, 0);
        }
    }
    printf("%d", res);
    return 0;
}

Measured memory_bytes: 8320
//?度?n 的数列a 中任意几个元素相加能否得到 k,能得到?出yes  ，否??出no

#include <iostream>
#include <cstdio>
using namespace std;
int n,m;
int a[10000];
int solve(int i,int p)
{
    if(p == 0)
        return 1;
    if(i >= n)   //没有找到
        return 0;
    int res = solve(i+1,p)||solve(i+1,p-a[i]);
    return res;
}
int main()
{
    int k;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    scanf("%d",&m);
    for(int j=0;j<m;j++)
    {
        scanf("%d",&k);
        if(solve(0,k))
            printf("yes\n");
        else
            printf("no\n");
    }
    return 0;
}

Measured memory_bytes: 3112
solve x 0 d = abs x
solve x k d
    | xdd >= k = x' - (k*d)
    | even k' = xdm
    | otherwise = abs $ xdm - d
        where
            x' = abs x
            xdd = div x' d
            xdm = mod x' d
            k' = k - xdd


main = do
    [x,k,d] <- map read . words <$> getLine :: IO [Integer]
    print $ solve x k d


Measured memory_bytes: 3860
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int n, m;
vi adj[MX + 5];
bool visited[MX + 5];
int cnt = 0, best = 0;

void dfs(int x){
    if(visited[x] == true) return;
    visited[x] = true;
    cnt++;
    for(auto it : adj[x]){
        dfs(it);
    }
}

int main(){

    setIO();

    cin >> n >> m;

    while(m--){
        int x, y;
        cin >> x >> y;

        adj[x].pb(y), adj[y].pb(x);
    }

    for(int i = 1; i <= n; i++){
        cnt = 0;
        if(visited[i] == false){
            dfs(i);
        }
        best = max(best, cnt);
    }

    cout << best;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;


ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}



/******************************************
** A main function is start from here  ****
*******************************************/
int main(){
  string S;
  cin >> S;
  int n = S.size();
  char tmp = S[0];
  ll ans=0;
  for(int i=1;i<n;i++){
    if(tmp!=S[i]){
      ans++;
      tmp = S[i];
    }
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define LL long long 
#define LD long double
int n,ans,a[10005],vis[10005],b[10005],st[10005];
bool check(int *A,int *B)
{
	for(int i=1;i<=n;i++)
		if(A[i]!=B[i])return 0;
	return 1;
}
int ansa,ansb,tot;
void dfs(int now)
{
	if(now==n+1)
	{
		tot++;
		if(check(st,a))ansa=tot;
		if(check(st,b))ansb=tot;	
	}
	for(int i=1;i<=n;i++)
	{
		if(vis[i])continue;
		vis[i]=1;
		st[now]=i;
		dfs(now+1);
		vis[i]=0;
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	dfs(1);
	cout<<abs(ansa-ansb)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long double PI=acos(-1);
int main() {
  long double a,b,h,m;
  cin>>a>>b>>h>>m;
  long double kakudo=0;
  long double kotae=0;
  kakudo=2*PI/12*h+2*PI/12/60*m-2*PI/60*m;
  //cout<<kakudo<<endl;
  //if(kakudo<0)kakudo*=-1;
  //cout<<cos(kakudo)<<endl;
  kotae=a*a+b*b-2*a*b*cos(kakudo);
  //cout<<kotae<<endl;
  kotae=sqrt(kotae);
  cout<<fixed<<setprecision(19)<<kotae<<endl;
  return 0;
}


Measured memory_bytes: 4136