akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
#include <ostream>
using namespace std;
#define rep(i, N) for(int i=0; i<N; ++i)
using ul = unsigned long;
using ll = long long;
#define MAX 1000000

int main() {
    int x;
    cin >> x;
    int x100 = x / 100;
    int x10 = x % 100;
    int x5 = x10 / 5;
    int x5_2 = x10 % 5;
    int x4 = x5_2 / 4;
    int x4_2 = x5_2 % 4;
    int x3 = x4_2 / 3;
    int x3_2 = x4_2 % 3;
    int x2 = x3_2 / 2;
    int x2_2 = x3_2 % 2;
    int x1 = x2_2 / 1;
    cerr << "x100: " << x100 << endl;
    cerr << "x10: " << x10 << endl;
    cerr << "x5: " << x5 << endl;
    cerr << "x4: " << x4 << endl;
    cerr << "x3: " << x3 << endl;
    cerr << "x2: " << x2 << endl;
    cerr << "x1: " << x1 << endl;

    if ((x100 - x5 - x4 - x3 - x2 - x1) >= 0) cout << '1' << endl;
    else cout << '0' << endl;
}


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

mod = 10 ** 9 + 7

ans = 0
n = ((N * (N+1)) // 2) % mod
for i in range(K,N+2):
    if i == N+1:
        ans += 1
        continue
    t = (((N-i) * (N+1-i)) // 2) % mod
    ans +=  (n - t + 1) % mod
    ans -= (((i-1) * i)//2) % mod 
    ans %= mod

print(ans)
    

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
int n;
long long a[100001],Min=10000000000;
int r;
int main() {
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<n;i++){
        if(Min>abs(a[n-1]/2.0-a[i])){
            Min=abs(a[n-1]/2.0-a[i]);
            r=i;
        }
    }
    cout<<a[n-1]<<" "<<a[r]<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int num;
    cin >> num;
    vector<int> A;
    vector<int> B;
    vector<int> C;

    for (int i = 0; i < num; i++) {
        int val;
        cin >> val;
        A.push_back(val);
    }

    for (int i = 0; i < num; i++) {
        int val;
        cin >> val;
        B.push_back(val);
    }

    for (int i = 0; i < num - 1; i++) {
        int val;
        cin >> val;
        C.push_back(val);
    }

    int total = 0;
    int prevIndex = -100;
    for (int i = 0; i < num; i++) {
        int index = A[i] - 1;
        total += B[index];

        if (i != 0 && prevIndex + 1 == index) {
            total += C[prevIndex];
        }
        prevIndex = index;
    }

    cout << total << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(a, b);

    int c = a * 2, d = b * 2;
    int cnt = 0;
    while (1) {
        if (cnt % 2 == 0) {
            // sente UKU
            d -= min(a, c);
        } else {
            c -= (d / 2) + (d % 2);
        }
        if (c > 0 && d > 0) 
            cnt++;
        else 
            break;
    }

    int ans = 0;
    c = a * 2; d = b * 2;
    while (1) {
        if (ans % 2 == 0) {
            // sente UKU
            d -= (c / 2) + (c % 2);
        } else {
            c -= min(b, d);
        }
        if (c > 0 && d > 0) 
            ans++;
        else 
            break;
    }

    std::cout << min(ans, cnt) << std::endl;



    return 0;
}



Measured memory_bytes: 3152
// ConsoleApplication1.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include<cmath>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<iostream>
#include<queue>
typedef long long  i64;
using namespace std;


int main() {
	int n;
	i64 k;
	vector<pair<i64, i64>> vec;
	scanf("%d%lld", &n, &k);
	for (int i = 0; i < n; ++i) {
		i64 a, b;
		scanf("%lld%lld", &a, &b);
		vec.push_back({ a,b });
	}
	sort(vec.begin(), vec.end());
	i64 cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (cnt + vec[i].second >= k) {
			printf("%lld", vec[i].first);
			return 0;
		}
		else {
			cnt += vec[i].second;
		}
	}
	return 0;
}

Measured memory_bytes: 2420
N = int(input())
s1 = input()
s2 = input()
mod = 1000000007
ans = 1
tate = True
if s1[0]==s2[0]:
    ans *= 3
    s1 = s1[1:]
else:
    ans *= 6
    s1 = s1[2:]
    tate = False
while len(s1) > 1:
    if s1[0] == s1[1]:
        s1 = s1[2:]
        if tate:
            ans *= 2
        else:
            ans *= 3
        ans %= mod
        tate = False
    else:
        if tate:
            ans *= 2
            ans %= mod
        s1 = s1[1:]
        tate = True
if tate and len(s1) == 1:
    ans *= 2
    ans %= mod
print(ans)

Measured memory_bytes: 3064
def myAnswer(A:int,B:int,C:int) -> int:
   MAX = max(A,B,C)
   ABC = sorted([A,B,C])
   counter = 0
   while ABC[0] != ABC[1] or ABC[1] != ABC[2]:
      if(ABC[1] == ABC[2]):
         ABC[0] += 2
         ABC.sort()
         counter +=1
      else:
         ABC[0] += 1
         ABC[1] += 1
         ABC.sort()
         counter += 1
   return counter


def modelAnswer():
   tmp=1
def main():
   A,B,C = map(int,input().split())
   print(myAnswer(A,B,C))
if __name__ == '__main__':
   main()

Measured memory_bytes: 3064
from collections import defaultdict
import queue


class Graph:
    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


N = int(input())
g = Graph()
q = queue.Queue()
ans = [-1] * N
ans[0] = 0  # 最初の色はどちらでも良いので 0 とする
q.put(0)

for i in range(N-1):
    src, dst, weight = map(int, input().split())
    src -= 1
    dst -= 1
    g.add_edge(src, dst, weight % 2)
    g.add_edge(dst, src, weight % 2)

while not q.empty():
    v = q.get()
    for i in range(len(g.graph[v])):
        u, w = g.graph[v][i]

        # 来てたならスキップ
        if ans[u] != -1:
            continue

        ans[u] = (ans[v] + w) % 2  # w is 0 or 1
        q.put(u)

for a in ans:
    if a < 0:
        a = 0
    print(a)

Measured memory_bytes: 88660
import sys
from scipy.sparse.csgraph import floyd_warshall
from itertools import permutations
read = sys.stdin.read
readline = sys.stdin.readline

N, M, R = map(int, readline().split())
r = list(map(int, readline().split()))

INF = float('inf')
graph = [[INF] * (N + 1) for _ in range(N + 1)]
ABC = map(int, read().split())

for i in range(N + 1):
    graph[i][i] = 0

for A, B, C in zip(*[iter(ABC)] * 3):
    graph[A][B] = C
    graph[B][A] = C

distance = floyd_warshall(graph, directed=False)
answer = 10 ** 9
for tour in permutations(r):
    tmp = 0
    for i, j in zip(tour, tour[1:]):
        tmp += distance[i][j]

    if tmp < answer:
        answer = tmp

print(int(answer))

Measured memory_bytes: 22260
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#define sz(x) ((ll)(x).size());
#define pb push_back;
#define all(x) (x).begin(),(x).end()
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N, K; cin >> N >> K;
    vll a(N); 
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    bool dp[K+1];
    ll i = 0;
    while(i<K+1){
        if(i < a[0]){
            dp[i] = false;
        }
        else{
            bool k = false;
            for(auto x: a){
                if(i-x >= 0){
                    if(dp[i-x] == false){
                        k = true;
                    }
                }
            }
            if(k){dp[i] = true;}
            else{dp[i] = false;}
        }
        i++;
    }
    if(dp[K]){cout << "First";}
    else{cout << "Second";}
}

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


def solve(X: int):
    print(X // 500 * 1000 + X % 500 // 5 * 5)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)


if __name__ == '__main__':
    main()


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

const int INF = 1e9;
using lint = long long;
const lint LINF = 1e18;
#define bit(n) ((lint)1 << n);

const lint MOD = 1e9 + 7;
// const lint MOD = 998244353;

struct union_find {
    int n;
    vector<int> pars, sizes;

    union_find(int n): pars(n), sizes(n) {
        for (int i = 0; i < n; i++) {
            pars[i] = i;
            sizes[i] = 1;
        }
    }

    int root(int i) {
        if (pars[i] == i) {
            return i;
        } else {
            pars[i] = root(pars[i]);
            return pars[i];
        }
    }
    bool is_same(int i, int j) {
        return root(i) == root(j);
    }
    void unite(int i, int j) {
        if (!is_same(i, j)) {
            sizes[root(i)] += sizes[root(j)];
            pars[root(j)] = root(i);
        }
    }
    int size(int i) {
        return sizes[root(i)];
    }
};

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

    int n, m;
    cin >> n >> m;
    union_find uf(n);
    for (int i = 0; i < m; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        uf.unite(x - 1, y - 1);
    }

    set<int> num;
    for (int i = 0; i < n; i++) {
        num.insert(uf.root(i));
    }
    cout << num.size() << endl;

    return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	rep(i, n) cin >> x[i];
	int ans = 2000000000;
	for (int i = 0; i < n - k + 1; i++) {
		int a = min(abs(x[i]), abs(x[i + k - 1]));
		ans = min(ans, a + x[i + k - 1] - x[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())
K = int(input())
x = list(map(int, input().split()))

m = K / 2
ans = 0
for i in range(N):
    if x[i] < m:
        ans += 2 * x[i]
    else:
        ans += 2 * (K - x[i])
print(ans)

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

int main(){

    int n;
    cin >> n;
    vector<int> h(n);
    int highest=0;
    for(int i=0; i<n; i++){
        cin >> h.at(i);
        highest=max(highest,h.at(i));
    }

    int count=0;
    bool grow=false;
    for(int i=0; i<highest; i++){
        for(int j=0; j<n; j++){
            if(h.at(j)>i) grow=true;
            if(grow){
                if(h.at(j)<=i || j==n-1){
                    count++;
                    grow=false;
                }
            }
        }
    }

    cout <<count << endl;
}

Measured memory_bytes: 3628
def main():
    X, N = map(int, input().split())
    p = list(map(int, input().split()))

    if not p:
        return X
    a = max(p) + 1
    b = max(p) + 1
    for i in range(max(p) + 1, min(p) - 2, -1):
        if i in p:
            continue
        if abs(X - i) <= a:
            a = abs(X - i)
            b = min(b, i)
    return b


print(main())


Measured memory_bytes: 9132
n = int(input())
listA = [int(input()) for i in range(n)]
a = listA[0]
b = 0
for j in range(n):
  if a != 2:
    a = listA[a-1]
    b = b+1
  elif a == 2:
    b = b+1
    break
if b == n:
  print(-1)
else:
  print(b)



Measured memory_bytes: 7084
num=int(input())
h=num//3600 #if num//3600!=0 else ''
h_mod=num%3600
m=h_mod//60 #if h_mod//60!=0 else ''
s=h_mod%60 #if h_mod%60 !=0 else ''
print('{}:{}:{}'.format(h,m,s))


Measured memory_bytes: 5584
/*
  coded by: mi_ni_
  "LIVE LONG AND PROSPER"
*/
 
#include <bits/stdc++.h>
using namespace std;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define newl '\n'
#define TEST_CASE(fun) int tc; cin>>tc; while(tc--){ fun(); }
#define TEST_CASE_2 int tc; cin>>tc; for(int i=1;i<=tc;i++)
#define TEST_CASE_3(fun) int tc; cin>>tc; for(int i=1;i<=tc;i++){ cout<<"Case #"<<i<<": "; fun(); }
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define forab(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define forabr(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define trav(i,x) for(auto& i:x)

using ll=long long int;
using ull=unsigned long long int;
using ld=long double;
using pii=pair<int, int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using vii=vector<pii>;
using vll=vector<pll>;

const ld pi=acosl(-1);
const int inf=(int)1e9+7;
const ll llinf=(ll)1e18+7;
const ld eps=1e-7;

//other
template<typename T> inline bool powerof2(T a){ return (a&&(!(a&(a-1)))); }
template<typename T> inline T log_2(T a){ T res=-1; while(a){ a/=2; res++; } return res; }

//make sure to choose TEST_CASE in main for multiple test cases
void solve(){
	int n;
	cin>>n;
	vl arr(n);
	trav(i,arr) cin>>i;
	trav(i,arr){
		if(i==0){
			cout<<0<<newl;
			return;
		}
	}
	ll ans=1;
	trav(i,arr){
		ll check=((ll)1e18/i);
		if(ans>check){
			cout<<-1<<newl;
			return;
		}
		ans*=i;
		if(ans>(ll)1e18){
			cout<<-1<<newl;
			return;
		}
	}
	cout<<ans<<newl;
}

int main(){
	FAST_IO
	cout<<fixed<<setprecision(15);
	cerr<<fixed<<setprecision(10);
	//init_fact();
	//TEST_CASE(solve)
	//TEST_CASE_2{}
	//TEST_CASE_3(solve)
	solve();
	return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>


using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SRTVG(v) sort(v.begin(),v.end(),greater<>())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007
#define INF INT_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}

//int atcoder() {
//    int n;
//    cin >> n;
//    Vi a(n);
//    REP(i,0,n) cin >> a[i];
//    int ans=-INF;
//
//    REP(i,0,n){
//        int tak=-INF,aok=-INF;
//        for(int j=0; j<n; j++){
//            int ttak=0,taok=0;
//            for(int k=min(i,j); k<=max(i,j); k++){
//                if((k-min(i,j))%2==0) ttak+=a[k];
//                if((k-min(i,j))%2==1) taok+=a[k];
//            }
//            if(taok>aok){
//                aok=taok;
//                tak=ttak;
//            }
//        }
//        if(tak>ans) ans=tak;
//    }
//
//    cout << ans << ENT;
//    return 0;
//}

int atcoder(){
    ll n,m;
    cin >> n >> m;
    ll k = m/n;
    
    for(;; k--){
        if(m%k==0) break;
    }
    cout << k << ENT;
    return 0;
}


signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    atcoder();
    return 0;
}


Measured memory_bytes: 256
n = int(input())
if n < 105:
	print(0)
	exit()
c = 0
for i in range(105, n+1, 2):
	t = 0
	for j in range(1, n+1):
		if i % j == 0:
			t += 1
	if t == 8:
		c += 1
print(c)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n, i;
  cin >> n;
  double v[n], ans=0;
  for(i=0; i<n; i++)
    cin >> v[i];
  sort(v, v+n);
  ans=v[0];
  for(i=0; i<n-1; i++)
    ans=(ans+v[i+1])/2;
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = (ll)(n) - 1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1LL << 62)

#define PI (acos(-1))
#define print(x) cout << x << endl
 
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll countDigit(ll n) { return floor(log10(n) + 1); } 
typedef pair <ll,ll> P;
static const ll dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) 
{ 
    for (int i = 0; i < (int)v.size(); ++i) os << v[i] << " ";  
    return os; 
}

template <typename T1, typename T2> 
ostream& operator<<(ostream& os, const map<T1, T2>& m) 
{ 
    for (auto p : m) os << "<" << p.first << ", " << p.second << "> "; 
    return os; 
}


map<ll, ll> primeFactors(ll n)
{
    map<ll, ll> ret;
    while (n % 2 == 0)
    {
        if( ret.find(2) != ret.end() ) {
            ret[2]++;
        }
        else
        {
            ret[2] = 1;
        }
        n = n / 2;
    }
    for (ll i = 3; i <= sqrt(n); i = i+2)
    {
        while (n%i == 0)
        {
            if( ret.find(i) != ret.end() ) {
            ret[i]++;
        }
        else
        {
            ret[i] = 1;
        }
            n = n / i;
        }
    }
    if (n > 2)
        {
            if( ret.find(n) != ret.end() ) {
            ret[n]++;
        }
        else
        {
            ret[n] = 1;
        }
        }
    return ret;
}

int main()
{
    ll A, B;
    cin >> A >> B;
    map<ll,ll> pfA = primeFactors(A);
    map<ll,ll> pfB = primeFactors(B);
    map<ll,ll> uni;
    for(P p : pfA) {
        if(pfB[p.first] != 0) {
            uni[p.first] = min(pfB[p.first], p.second);
        }
    }
    print(uni.size()+1);
    return 0;
}

Measured memory_bytes: 256
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let n:usize = read_line().trim().parse().unwrap();
    let arr: Vec<usize> = read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();

    let mut mp1 = HashMap::new();
    let mut mp2 = HashMap::new();

    for i in 0..n {
        let key = arr[i];
        if i%2 == 0 {
            let val = mp1.get(&key).unwrap_or(&0) + 1;
            mp1.insert(key, val);
        } else {
            let val = mp2.get(&key).unwrap_or(&0) + 1;
            mp2.insert(key, val);
        }
    }

    let mut vals1: Vec<(&usize,&usize)>= mp1.iter().collect();
    let mut vals2: Vec<(&usize,&usize)> = mp2.iter().collect();
    vals1.sort_by(|e1,e2| e2.1.cmp(&e1.1));
    vals2.sort_by(|e1,e2| e2.1.cmp(&e1.1));

    if (vals1[0].0 != vals2[0].0) {
        println!("{}", n - vals1[0].1 - vals2[0].1);
    } else {
        if vals1.len() == 1 && vals2.len() == 1 {
            println!("{}", n/2);
        } else if vals1.len() == 1 {
            println!("{}", n/2 - vals2[1].1);
        } else if vals2.len() == 1 {
            println!("{}", n/2 - vals1[1].1);
        } else {
            println!("{}", cmp::min(n - vals1[0].1 - vals2[1].1, n - vals1[1].1 - vals2[0].1));
        }
    }
}


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

#define int long long
using ll = long long;
using ld = long double;
using intpair = pair<int, int>;
using intmap = map<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
const int MOD = 1e9 + 7;
inline int mod (ll a, int m = MOD) { return (a % m + m) % m; }
inline bool bit (ll b, ll i) { return b & (1 << i); }
inline ll ceiv (ll a, ll b) { return (a + b - 1) / b; }
//struct Fast {Fast(){cin.tie(0);ios::sync_with_stdio(0);}} fast;

#define debug(x) cerr << #x << ": " << x << '\n'
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()

signed main(){
    int n, m;
    cin >> n >> m;
    vi a(n+1,0);
    rep(i,n) cin >> a[i+1];
    rep(i,n) a[i+1] += a[i];
    
    intmap modtable;
    for(int i : a){
        modtable[i % m]++;
    }
    
    int ans = 0;
    for(auto [_, i] : modtable){
        ans += i * (i-1) / 2;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 7924
#include<bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int main()
    {
        string s[3];
        for(int i=0;i<3;i++){
            cin>>s[i];
        }
        char top{},ans{};
        while(true){
            if(s[top].empty()){
                ans=top;
                break;
            }
            int next;
            if(s[top][0] == 'a'){
                next = 0;
            }else if(s[top][0] == 'b'){
                next = 1;
            }else if(s[top][0]=='c'){
                next = 2;
            }
            s[top] = s[top].substr(1);
            top = next;
        }
            if(ans==0)cout<<"A"<<endl;
        else if(ans==1)cout<<"B"<<endl;
        else cout<<"C"<<endl;
        return 0;
    }

Measured memory_bytes: 256
import java.io.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String str = br.readLine();
    String keyence = "keyence";
    String start;
    String end;
    
    for(int i=0; i<=keyence.length(); i++){
      start = keyence.substring(0, i);
      end = keyence.substring(i, keyence.length());
      Pattern pattern = Pattern.compile("^" + start + ".*" + end + "$");
      Matcher matcher = pattern.matcher(str);
      if (matcher.matches()){
        System.out.println("YES");
        return;
      }
    }
    System.out.println("NO");
  }
}


Measured memory_bytes: 23252
def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    loop = [1]
    arrived = [0] * N
    now = 1
    arrived[now - 1] = 1

    for i in range(K):
        now = A[now - 1]
        if arrived[now - 1] == 0:
            arrived[now - 1] = 1
            loop.append(now)
        else:
            loop = loop[loop.index(now):]
            arrive = loop[(K - (i + 1)) % len(loop)]
            print(arrive)
            return

    print(now)

resolve()

Measured memory_bytes: 32272
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a=0,b=0,c=0;
  cin>>a>>b>>c;
  int d=a-b;
  if(d<c){
    cout<<c-d<<endl;
  }
  else if(d>=c){
    cout<<'0'<<endl;
  }
}


Measured memory_bytes: 3620
#include <iostream>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

using ll = long long;

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

	int n; string s[2]; cin >> n >> s[0] >> s[1];
	REP(i, 0, 2 * n) cout << s[i & 1][i >> 1];
}

Measured memory_bytes: 256
#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>;

int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];
    vector<int> arr(n);
    rep(i,n) arr[i] = i;
    int cnt = 0;
    double sum = 0;
    double ans;

    do{
        rep(i,n-1) sum += sqrt(pow((x[arr[i]]-x[arr[i+1]]),2.0) + pow((y[arr[i]]-y[arr[i+1]]),2.0));
        cnt++;
    }while(next_permutation(arr.begin(), arr.end()));
    
    ans = sum / cnt;
    cout << setprecision(10) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s=list(input())
ans=""
l=len(s)
n=0
for i in range(l):
  if s[i]=="0"or s[i]=="1":
    ans+=s[i]
    n+=1
  elif s[i]=="B" and n==0:
    pass
  else:
    ans= ans[:n-1]
    n-=1
print(ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
//#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
//#include <list>
#include <iomanip>
//#include <stdlib.h>
//#include <cctype>

using namespace std;

const int MAX_N = 1000000;
#define IOS ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define prec std::cout << std::fixed << std::setprecision(15);
#define endl "\n"
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define ssort(z) sort(z.begin(), z.end())
#define rsort(z) sort(z.rbegin(), z.rend())
#define eerase(z) z.erase(unique(z.begin(), z.end()), z.end())
#define ccnt(z, w) count(z.begin(), z.end(), w)
//typedef pair<int,int> P;

template <typename T>
void printV(const std::vector<T>& v, const char * const separator = " ")
{
    if(!v.empty())
    {
        std::copy(v.begin(),
                  --v.end(),
                  std::ostream_iterator<T>(std::cout, separator));
        std::cout << v.back() << "\n";
    }
}


Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

Int lcm(Int a, Int b) {
    return a / gcd(a, b) * b;
    //a*bは64bit integer overflow
}

int Max(int a, int b, int c) {
    int temp = max(a, b);
    return max(temp, c);
}

int Min(int a, int b, int c) {
    int temp = min(a, b);
    return min(temp, c);
}

bool integer(double num) {
    return floor(num) == num;
}

Int fact(int num) {
    if (num == 0)
        return 1;
    else
        return num * fact(num - 1);
}

void y() {
    cout << "Yes" << endl;
    exit(0);
}

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

void Y() {
    cout << "YES" << endl;
    exit(0);
}

void N() {
    cout << "NO" << endl;
    exit(0);
}

Int yakusu(int n) {
    int cnt = 0;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            cnt++;
            if (i * i != n) cnt++;
        }
    }
    return cnt;
}

/*   kokomade  */

int cnt = 0;
bool is_prime[ 50000 + 1 ];
vector<int> P;
void Eratosthenes( const int N )
{
    for( int i = 0; i <= N; i++ )
    {
        is_prime[ i ] = true;//初期化
    }
    for( int i = 2; i <= N; i++ )
    {
        if( is_prime[ i ] )
        {
            for( int j = 2 * i; j <= N; j += i )
            {
                is_prime[ j ] = false;
            }
            P.emplace_back( i );
        }
    }
}

int main() {
    IOS;
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" ";
    if(a+b-n>0)cout<<a+b-n;
    else cout<<0;



    cout<<endl;
    return 0;
}

/*
テレビも無ェ ラジオも無ェ
自動車もそれほど走って無ェ
ピアノも無ェ バーも無ェ
巡査 毎日ぐーるぐる
朝起ぎで 牛連れで
二時間ちょっとの散歩道
電話も無ェ 瓦斯も無ェ
バスは一日一度来る
俺らこんな村いやだ 俺らこんな村いやだ
東京へ出るだ 東京へ出だなら
銭コァ貯めで 東京でベコ(牛)飼うだ
*/


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {

  int a, b;
  cin>>a>>b;
  cout<<(a+b)%24<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int64 n, m; cin >> n >> m;
	vector<int64> p(m);
	vector<string> s(m);
	if (m == 0) {
		cout << 0 << " " << 0 << endl;
		return;
	}
	rep (i, m) {
		int tmp_p; cin >> tmp_p;
		tmp_p--;
		p[i] = tmp_p;
		cin >> s[i];
	}
	int64 ans_cnt = 0;
	int64 pena_cnt = 0;
	vector<int64> ac_cnt(n);
	vector<int64> wa_cnt(n);
	rep (i, m) {
		if (s[i] == "AC") {
			if (ac_cnt[p[i]] >= 1) {
				continue;
			} else {
				ac_cnt[p[i]]++;
				ans_cnt++;
				pena_cnt += wa_cnt[p[i]];
			}
		} else {
			if (ac_cnt[p[i]] <= 0) {
				wa_cnt[p[i]]++;
			} else {
				continue;
			}
		}
	}
	cout << ans_cnt << " " << pena_cnt << endl;
	return;
}

int main() {
	solve();
  return 0;
}

Measured memory_bytes: 8064
n, m = map(int, input().split())
l = [0] * m
r = [0] * m


for i in range(m):
    l[i], r[i] = map(int, input().split())


if max(l) > min(r):
    print(0)
else:
    print(min(r) - max(l) + 1)


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

int main(){
  string S;
  cin >> S;
  int pre = S.at(0) - '0';
  int cnt = 0;
  int cur;
  for (int i = 1; i < S.size(); i++) {
    cur = S.at(i) - '0';
    if (pre == cur) {
      cnt++;
    };
    pre = !pre;
  }
  cout << cnt << endl;
}


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

using namespace std;
using ll = long long;

int main(void){
	int l=0,s=0;
	int h=0,m=0;
	cin >> l >> s >> h >> m;

	long double theta = 0;

	theta = (long double)h/12 + (long double)m/60/12 - (long double)m/60;
	theta = theta*PI*2;
	theta = abs(theta);

	double ans = 0;
	ans = pow((long double)l,2) + pow((long double)s,2) - (long double)(2*l*s)*cosl(theta);
	ans = sqrt(ans);
	cout << setprecision(20) << ans << endl;
}



Measured memory_bytes: 4168
import sys

n = int( sys.stdin.readline() )
s = [ False ] * 13
h = [ False ] * 13
c = [ False ] * 13
d = [ False ] * 13
for i in range( 0, n ):
	pattern, num = sys.stdin.readline().split( " " )
	if "S" == pattern:
		s[ int( num )-1 ] = True
	elif "H" == pattern:
		h[ int( num )-1 ] = True
	elif "C" == pattern:
		c[ int( num )-1 ] = True
	elif "D" == pattern:
		d[ int( num )-1 ] = True

for i in range( 0, 13 ):
	if not s[i]:
		print( "S {:d}".format( i+1 ) )
for i in range( 0, 13 ):
	if not h[i]:
		print( "H {:d}".format( i+1 ) )
for i in range( 0, 13 ):
	if not c[i]:
		print( "C {:d}".format( i+1 ) )
for i in range( 0, 13 ):
	if not d[i]:
		print( "D {:d}".format( i+1 ) )

Measured memory_bytes: 6752
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Sum_and_Average
{
    class Program
    {
        static void Main(string[] args)
        {
            double sum = 0;
            double nums = 0;
            double count = 0;
            while (true)
            {
                string input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) break;
                string[] temp = input.Split(',');
                double p = double.Parse(temp[0]);
                double n = double.Parse(temp[1]);
                sum += p * n;
                nums += n;
                count++;
            }

            Console.WriteLine(sum);
            Console.WriteLine("{0,0:F0}", nums / count);

        }
    }
}



Measured memory_bytes: 13932
object Main extends App {
  
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt()
  val a = Array.fill(n)(sc.nextInt)
  val sorted = a.sorted
  val last1 = sorted(n-1)
  val last2 = sorted(n-2)
  a.foreach(i => println(calc(i)))
  
  def calc(i: Int): Int = if (i == last1) last2 else last1
}

Measured memory_bytes: 61768
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)



        
def main(): #startline--------------------------------------------
    n = int(input())
    h = list(map(int,input().split()))
    inf = float("inf")
    dp = [0]*(n+1)
    dp[0] = 0
    dp[1] = abs(h[1]-h[0])
    for i in range(1,n-1):
        dp[i+1] = min(dp[i]+abs(h[i+1]-h[i]),dp[i-1]+abs(h[i+1]-h[i-1]))

    print(dp[n-1])
if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 16340
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <climits>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <iomanip>
#include <stdio.h>
using namespace std; 
#define Endl '\n'
int main()
{
	long double a;
	long double b;
	cin>>a>>b;
	cout<<static_cast<long long int>(a*b);
}

Measured memory_bytes: 3736
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
const int xx = 2e5;
const int MOD = 1e9 + 7;
vector<int>g[xx+10];
vector<int>dist , distT , par;
void dfs(int c , int p){
  for(int i : g[c]){
    if(i != p){
      par[i] = c;
      dist[i] = dist[c] + 1;
      dfs(i , c);
    }
  }
}
int Max = 0 , NMax = 0;
void dfslca(int c , int p){
  for(int i : g[c]){
    if(i != p){
      distT[i] = distT[c] + 1;
      if(distT[i] > Max){
        Max = distT[i];
        NMax = i;
      }
      dfslca(i , c);
    }
  }
}

int findroot(int node){
  int cnt = 1;
  while(1){

    int p = par[node];
    if(dist[p] <= cnt) break;
    if(p == -1) break;
    node = p;
    cnt++;
  }
  return node;
}
signed main(){

  ios::sync_with_stdio(false);cin.tie(0);

  int N , u , v;
  cin >> N >> u >> v;
  dist = distT = par = vector<int>(N+1 , 0);
  for(int i=1;i<N;i++){
    int x , y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  par[v] = -1;
  dfs(v , -1);
  int lca = findroot(u);
  int parentlca = par[lca];
  dfslca(lca , parentlca);

  // dg1(dist);
  // dg1(lca);
  // dg1(parentlca);
  // dg2(Max , NMax);

  if(Max == 0){
    NMax = u;
  }
  cout << dist[NMax] - 1 << '\n';
}

Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;

  vector<string> ans={"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};
  N%=10;
  cout << ans.at(N) << endl;

  return 0;
}

Measured memory_bytes: 3640
n = int(input())
A, B, AB = [], [], []
for i in range(n):
    ai, bi = map(int, input().split())
    A.append(ai)
    B.append(bi)
    AB.append((ai + bi, i))
AB.sort(reverse=True)
bsum = sum(B)


ans = 0
for i in range(n):
    if i % 2 == 0:
        ans += A[AB[i][1]]
    else:
        ans -= B[AB[i][1]]
print(ans)

Measured memory_bytes: 66392
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  int H, W, D; cin >> H >> W >> D;

  vector < pair<int, int> > location(H * W);

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      int A; cin >> A; A--;
      location[A] = make_pair(i, j);
    }
  }
  
  vector < vector<int> > point(D);

  for (int i = 0; i < H * W; i++){
    if (i < D){
      point[i].push_back(0);
    }else{
      pair <int, int> now = location[i], past = location[i - D];
      int P = abs(now.first - past.first) + abs(now.second - past.second);
      P += point[i % D][i / D - 1];
      point[i % D].push_back(P);
    }
  }
  

  int Q; cin >> Q;

  vector <int> L(Q), R(Q);
  for (int i = 0; i < Q; i++){
    cin >> L[i] >> R[i];
    L[i]--; R[i]--;
  }

  for (int i = 0; i < Q; i++){
    int now = R[i] % D;
    cout << point[now][R[i] / D] - point[now][L[i] / D] << endl;
  }
  
  
  
  return 0;
}


Measured memory_bytes: 6912
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            for (int i = 0; i < n; i++) {
                int num = in.nextInt();
                // if it is even number
                if ((num & 1) == 0){
                    if (!(num % 3 == 0 || num % 5 == 0)){
                        out.println("DENIED");
                        return;
                    }
                }
            }
            out.println("APPROVED");
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


Measured memory_bytes: 22356
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
#include <tuple>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    deque<int> deque;
    for (int i = 0; i < n; i++) {
        int p = lower_bound(deque.begin(), deque.end(), a[i]) - deque.begin();
        if (p == 0) deque.push_front(a[i]);
        else deque[p - 1] = a[i];
    }
    int res = deque.size();

    cout << res << endl;
}


Measured memory_bytes: 1024
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int main()
{
	int a,b,c;
	read(a);read(b);read(c);
	cout<<min(c,b/a);
	return 0;
}









Measured memory_bytes: 2304
#include <stdio.h>
int main(){
    int n;
    int p[30];
    scanf("%d",&n);
    int i;
    for(i=1;i<=n;i++){
        scanf("%d",&p[i]);
    }
    int c;
    c=0;
    for(i=2;i<=n-1;i++){
        if(p[i]<p[i-1]&&p[i]>p[i+1]){
            c=c+1;
        }
        if(p[i]<p[i+1]&&p[i]>p[i-1]){
            c=c+1;
        }
    }
    printf("%d",c);
}

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

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

  map<int, int> p;

  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (p.count(a))
      p.erase(a);
    else
      p[a] = 1;
  }

  cout << p.size() << endl;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

static const int INTINF = (2147483647);
static const ll LLINF = (9223372036854775807);
static const int MAX = 100001;
static const ll MOD = 1000000007;

namespace Printer{
    void print(vector<int> v){
        rep(i, v.size()){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    void print(vector<vector<int> > vv){
        rep(i, vv.size()){
            rep(j, vv[i].size()){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void print(pair<int, int> p){
        cout << "(" << p.first << ", " << p.second << ")" << endl;
    }
};

//--global--//



//----------//

void p(ll a, ll b){
    cout << a << " " << b << endl;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//

    ll n, k;
    ll r, s, p;
    string t;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;

    bool *used;
    used = new bool[MAX];
    fill(used, used+MAX, false);
    ll ans = 0;
    rep(i, n){
        if(t[i] == 'r'){
            if(i-k <0 || (i - k >= 0 && !(t[i-k] == t[i] && used[i-k]))){
                ans += p;
                used[i] = true;
            }
        }
        else if(t[i] == 's'){
            if(i-k <0 || (i - k >= 0 && !(t[i-k] == t[i] && used[i-k]))){
                ans += r;
                used[i] = true;
            }
        }
        else{
            if(i-k <0 || (i - k >= 0 && !(t[i-k] == t[i] && used[i-k]))){
                ans += s;
                used[i] = true;
            }
        }
    }

    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 512
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    dp = [[0] * 3 for _ in range(n)]
    for i in range(n):
        a, b, c = list(map(int, readline().split()))
        if i == 0:
            dp[i][0] = a
            dp[i][1] = b
            dp[i][2] = c
        else:
            dp[i][0] = max(dp[i-1][1] + a, dp[i-1][2] + a)
            dp[i][1] = max(dp[i-1][0] + b, dp[i-1][2] + b)
            dp[i][2] = max(dp[i-1][0] + c, dp[i-1][1] + c)
    print(max(dp[-1]))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 54108