akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf pop_front()
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define mod 1000000007
#define inf 1000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define vll vector<lli>
#define stp setprecision(15)
#define eps 0.000001
#define endl '\n'
#define ll lli
 
using namespace std ;
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define N 200010


int main() 
{ 

/////////////////////////////////////
    
    fastio; 

    string s,t;
    cin>>s>>t;

    lli occ[26] = {0} , occ2[26]={0};

    vll v[26];

    loopl(i,0,s.size())
    {
        v[s[i]-'a'].pb(i);
    }

    loopl(i,0,s.size())
    {
        occ[s[i]-'a']++;
    }


    loopl(i,0,t.size())
    {
        if(occ[t[i]-'a'] == 0)
        {
            cout<<-1;
            return 0;
        }
    }

    lli ans=0,curr=-1;

    loopl(i,0,t.size())
    {
        lli j = t[i]-'a';
        auto k = ub(v[j].begin() , v[j].end() , curr);
        if(k == v[j].end())
        {
            ans += s.size() - (curr - v[j][0]);
            curr = v[j][0];
        }

        else
        {
            ans += *k - curr;
            curr = *k;
        }
    }

    cout<<ans<<endl;

} 

Measured memory_bytes: 1736
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N;
    i64 K;
    cin>>N>>K;
    Pi p[N];
    REP(i,N) cin>>p[i].first>>p[i].second;
    sort(p,p+N);
    REP(i,N) {
        K -= p[i].second;
        if (K<=0) {
            cout<<p[i].first<<endl;
            return 0;
        }
    }
}


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

using namespace std;

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

#define INF 2<<29
#define F first
#define S second

int main(){
  int n;
  int x,y,b,p;
  int sum1,sum2;
  
  scanf("%d",&n);
  
  for(int i=0;i<n;i++){
    scanf("%d %d %d %d",&x,&y,&b,&p);
    
    sum1=x*b+y*p;
    b=max(5,b);
    p=max(2,p);
    sum2=(x*b+y*p)*4/5;

    printf("%d\n",min(sum1,sum2));
  }
  
  return (0);
}



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

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

	int s = 0;
	while (m--) {
		int d;
		cin >> d;
		s += d;
	}

	if (s > n) {
		cout << -1 << endl;
	} else {

		cout << (n - s) << endl;
	}
}

Measured memory_bytes: 3592
N, K = map(int, input().split())
S = list(list(input()))

a = []
temp = S[0]
s = []
ans = 0

if len(S) > 1 and temp == S[1]:
    hantei = True
    a.append(temp)
else:
    hantei = False
    s.append(list(S[0]))

for i in range(1, N):
    if temp == S[i]:
        ans += 1
    if hantei and temp != S[i]:
        s.append(a)
        a = []
        hantei = False
    if temp != S[i] or hantei:
        hantei = True
        a.append(S[i])
        temp = S[i]
if len(S) > 1:
    s.append(a)

length = len(s)
for i in range(K):
    if length > 2:
        ans += 2
        length -= 2
    elif length == 2:
        ans += 1
        break

print(ans)


Measured memory_bytes: 15896
using System;
class Program
{
  static void Main (string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int A = int.Parse(input[0]);
    int B = int.Parse(input[1]);
    int C = int.Parse(input[2]);
    Console.WriteLine(((B/A) <= C) ? (B/A) : (C));
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


signed main(){
	int n; cin>>n;
	VL a(n);

	ll sum = 0;
	rep(i,n){
		ll b; cin>>b; sum+=b;
		a[i]=sum;
		cerr<<sum<<' ';
	}
	cerr<<endl;
	ll ans = LINF;
	rep(i,n-1){
		chmin(ans,abs(a[n-1]-a[i]*2));
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
	
		int N = keyboard.nextInt();
		
		int[]A = new int[N];
		Set<Integer> sp = new HashSet<Integer>();
		
		for(int i = 0; i<N; i++) {
			A[i] = keyboard.nextInt();
			sp.add(A[i]);
		}
		
		boolean flag = true;  
		
//		全部０（何個でも良い）
		for(int z = 0; z<N; z++) {
			if(A[z] != 0) {
				flag = false;
			}
		}
		
		if(flag == false) {
//			Nが３の倍数個であるとき
			if(N % 3 == 0) {
//				aが３種類であるとき
				if(sp.size() == 3) {
//					a1^a2 == a3である、かつ各aの個数が等しい
					Integer[]a = sp.toArray(new Integer[0]);
					if((a[0]^a[1]) == a[2]) {
						Arrays.sort(A); 
						if(A[0] == A[N/3-1] && A[N/3] == A[2*N/3-1] && A[2*N/3] == A[N-1]) {
							flag = true;
						}
					}
				}else if(sp.size() == 2){
//				aが２種類であるとき
					Integer[]a = sp.toArray(new Integer[0]);
					if(a[0]== 0) {
						Arrays.sort(A); 
						if(A[0] == A[N/3-1] && A[N/3] == A[N-1]) {
							flag = true;
						}
					}
				}
			}
		}
		String ans = "";
		if(flag) {
			ans = "Yes";
		}else {
			ans = "No";
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 63576
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n;
	cin >> n;
	cout << ((n<1200)?"ABC":"ARC") << endl;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;
using static Prog;
using NX = System.Int64;

public class Solver
{
    NX R, S, P;
    public void Solve()
    {
        NX N = NextInt(), K = NextInt();
        R = NextLong(); S = NextLong(); P = NextLong();
        string T = NextString();
        NX ans = 0;
        int[] log = new int[N];
        for (int i = 0; i < N; i++)
        {
            if (i < K)
            {
                if (T[i] == 'r') { ans += P; log[i] = 2; }
                else if (T[i] == 's') { ans += R; log[i] = 0; }
                else if (T[i] == 'p') { ans += S; log[i] = 1; }
            }
            else if (i < N)
            {
                if (T[i] == 'r' && log[i - K] != 2) { ans += P; log[i] = 2; }
                else if (T[i] == 's' && log[i - K] != 0) { ans += R; log[i] = 0; }
                else if (T[i] == 'p' && log[i - K] != 1) { ans += S; log[i] = 1; }
                else log[i] = -1;
            }
        }
        Console.WriteLine(ans);
    }
}


public class Prog
{
    public struct Pair { public int x, y; public Pair(int a, int b) { x = a; y = b; } }
    public const long MOD = 1000000007;
    public const int INF = 1000000007;

    static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        new Solver().Solve();
        Console.Out.Flush();
        return;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 14176
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main()
{
    int n, m, i, j;
    scanf("%d", &n);
    scanf("%d", &m);
    int a[n+1];
    int c[n];
    for(i = 0; i < m; i++) { 
        scanf("%d", c+i);
    }
    a[0] = 0;
    for(i = 1; i < n + 1; i++) { 
        a[i] = 50001;
        for(j = 0; j < m; j++) { 
            if (i - c[j] >= 0 ) {
                if (a[i] > (1 + a[i - c[j]])) {
                    a[i] =  1 + a[i - c[j]];
                }
            }
        }
    }
    printf("%d\n", a[n]);
    return 0;
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  vector<int64> a(n);
  REP(i,n)cin >> a[i];
  int64 s = 0;
  REP(i,n)s ^= a[i];
  REP(i,n)a[i] &= ~s;
  // REP(i,n){
  //   cout << bitset<60>(a[i]) << endl;
  // }
  int32 r = 0;
  FORR(d,61,0){
    int32 i;
    for(i = r; i < n; ++i){
      if((a[i]>>d)&1){
        swap(a[r],a[i]);
        break;
      }
    }
    if(i == n)continue;
    REP(j,n){
      if(j == r)continue;
      if((a[j]>>d)&1)a[j] ^= a[r];
    }
    r++;
  }
  // REP(i,n){
  //   cout << bitset<60>(a[i]) << endl;
  // }
  int64 ad = 0;
  REP(i,n)ad ^= a[i];
  ANS(s + (ad << 1));
  return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

vector<vector<pair<int, int> > > edge;//edge[i][j] firstがiからj番目のノード、secondがその重み
vector<int> d(100005,INF);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    rep(i,9){
		char a;
		cin >> a;
		if(i == 0 || i == 4 || i == 8){
			cout << a;
		}
	}
	cout << endl;
	
}

Measured memory_bytes: 640
n = int(input())
w=[]
for i in range(n):
    w.append(input())
flag = True 
if len(w)==len(set(w)):
    for i in range(n-1):
        if w[i][-1]!=w[i+1][0]:
            flag = False
            break
else:
    flag = False
if flag:
    print("Yes")
else:
    print("No")


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

using namespace std;

int F[101][11];
int P[101][11];

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=10;j++)
            cin>>F[i][j];
    for(int i=1;i<=n;i++)
        for(int j=0;j<=10;j++)
            cin>>P[i][j];

    int sol=INT_MIN;
    for(int i=1;i<=1023;i++)
    {
        int x[n+1]={0};
        for(int j=0;j<10;j++)
        {
            //cout<<i<<" "<<j<<" "<<(1<<(k))<<" "<<(i&(1<<(k)))<<" "<<endl;
            if((i&(1<<j))!=0)
            {
                for(int k=1;k<=n;k++)
                    if(F[k][j+1]==1)
                        x[k]++;

                //cout<<k<<" up ";
            }
        }
        //cout<<endl;
        int val=0;
        for(int k=1;k<=n;k++)
        {
            val+=P[k][x[k]];
        }
        sol=max(sol,val);
    }
    cout<<sol;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a, b, c;
    int x1, x2, x3;

    scanf("%d %d %d", &a, &b, &c);
    
    if (b <= a) {x1 = a; a = b; b = x1;};
    if (c <= b) {x2 = b; b = c; c = x2;};
    if (b <= a) {x3 = a; a = b; b = x3;};

    printf("%d %d %d\n", a, b, c);

    return 0;
}


Measured memory_bytes: 2072
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち

import numpy as np
from functools import partial
array = partial(np.array, dtype=np.int64)
zeros = partial(np.zeros, dtype=np.int64)
full = partial(np.full, dtype=np.int64)

ra = range
enu = enumerate


def a_int(): return int(read())


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import

from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce

K = np.array(list(map(int, list(input()))))
D = a_int()

'''
ある数xにおいて総和がDの倍数であるかの判定
x[0]+x[1]...+x[n] ≡ 0 (mod D) 各桁の和にMODを取れば良い。つまり桁ごとに処理できる

dp[i,j,k] ... K[:i]以下の整数のうち、k=mod Dとなるような数字の個数。j==1は上位桁が一致している場合の通りの個数。j==0は上位桁が一致しなくなったときの個数。

遷移
for l in range(10):
    dp[i+1,0,(k+l)%D] += dp[i,0,k] #1~9を考慮可能
for l in range(K[i]):
    dp[i+1,0,(k+l)%D] += dp[i,1,k] #1~K[i]-1をつけるとぴったりにならないグループへ行く

dp[i+1,1,(k+K[i])%D] += dp[i,1,k]
'''
# print(K, D)

from numba import njit


@njit('(i8[:],i8)', cache=True)
def solve(K, D):
    N = K.shape[0]
    dp = np.zeros((N + 1, 2, D), dtype=np.int64)
    dp[0, 1, 0] = 1
    for i in range(N):  # 各桁について
        for k in range(D):  # 各あまりについて処理
            for l in range(10):  # 各数字について処理
                dp[i + 1, 0, (k + l) % D] += dp[i, 0, k]  # 1~9を考慮可能
                if l < K[i]:
                    dp[i + 1, 0, (k + l) % D] += dp[i, 1, k]
                    # 1~K[i]-1をつけるとぴったりにならないグループへ行く
                dp[i + 1, 0, (k + l) % D] %= MOD
            # ぴったりグループ
            if dp[i, 1, k]:
                dp[i + 1, 1, (k + K[i]) % D] += dp[i, 1, k]
            # dp[i + 1, 1, (k + K[i]) % D] %= MOD

    print((dp[-1, :, 0].sum() - 1) % MOD)  # -1は0の分


solve(K, D)


Measured memory_bytes: 130920
import sys
from itertools import combinations

fin = sys.stdin.readline
L, R = [int(elem) for elem in fin().split()]

all_ij = list(range(L, min(R+1, L+2021)))

min_mod = 2020
for each_ij in combinations(all_ij, 2):
    result = (each_ij[0] * each_ij[1]) % 2019
    if result < min_mod:
        min_mod = result
        if min_mod == 0:
            break

print(min_mod)


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

int main()
{
    int y,x,n,ans = 0;
    scanf("%d",&n);
    scanf("%d",&x),n--;
    for(int i = 0;i < n;++i){
        scanf("%d",&y);
        ans += x*y;
        x += y;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
typedef long long ll;
using namespace std;

int d[1000000];
struct edge {
	int to;
	int cost;
};

void dfs(int node, const vector<vector<edge> >& v, int pcolor) {
	d[node] = pcolor;
	for (int i = 0; i < v[node].size(); i++) {
		int next_node = v[node][i].to;
		if (d[next_node] == -1) {
			int color = pcolor;
			if (v[node][i].cost % 2 == 1) { color = 1 - color; }
			dfs(next_node, v, color);
		}
	}
}
int main() {
	int n; cin >> n;
	vector<vector<edge> > tree(n);
	for (int i = 0; i < n; i++) { d[i] = -1; }
	for (int i = 0; i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		edge e = { v - 1, w };
		edge re = { u - 1, w };
		tree[u - 1].emplace_back(e);
		tree[v - 1].emplace_back(re);
	}

	dfs(0, tree, 0);

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

	return 0;
}


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

int n;
long long a, b;
long long *h;

long long bin_search();
bool condition(long long);

int main()
{
    scanf("%d%lld%lld", &n, &a, &b);
    a -= b;
    h = new long long[n];
    for (int i = 0; i < n; i++)
        scanf("%lld", h + i);

    std::sort(h, h + n);
    printf("%lld\n", bin_search());

    delete[] h;

    return 0;
}

long long bin_search()
{
    long long left{-1}, right{(h[n - 1] + b - 1) / b};
    while (left + 1 < right)
    {
        long long mid = (left + right + 1) / 2;
        if (condition(mid)) right = mid;
        else left = mid;
    }
    return right;
}

bool condition(long long number)
{
    long long sum_a{};
    for (auto it = std::upper_bound(h, h + n, number * b); it != h + n; it++)
    {
        sum_a += (*it - number * b + a - 1) / a;
        if (sum_a > number) return false;
    }
    return true;
}

Measured memory_bytes: 1024
import itertools
H,W= [int(x) for x in input().split()]
meiro=[list(input())for _ in range(H)]
#print(meiro)
ans=0
dx = [1,0,-1,0]
dy=[0,1,0,-1]
for i in range(H):
  for j in range(W):
    result=[[0]*W for _ in range(H)]
    cnt=0
    #print(i,j)
    if meiro[i][j]=="#":
      continue
    elif meiro[i][j]==".":
      stk =[[i,j]]
      result[i][j]=1
      while stk:
        x,y = stk.pop(0)
        
        for r in range(4):
          xx,yy=x+dx[r],y+dy[r]
          if yy<0 or xx<0 or W<=yy or H<=xx or meiro[xx][yy]=="#" or result[xx][yy]!=0:
            continue
          result[xx][yy]=result[x][y]+1
          stk.append([xx,yy])
      for l in range(H):
        for t in range(W):
          ans = max(ans,result[l][t])
print(ans-1)

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

using namespace std;

int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) {
		cout << "Bad" << endl;
	} else {
		cout << "Good" << endl;
	}
}


Measured memory_bytes: 256
l,r  = map(int,input().split())
small = l // 2019
big = r // 2019
num = [l % 2019,r % 2019,l % 2019 + 1,r % 2019 - 1]
num.sort()
num = list(set(num))
mod = 2020
if big - small >= 1:
    print(0)
else: 
    for i in range(l % 2019,r % 2019):
        for j in range(i + 1,r % 2019 + 1):
            mod = min((i * j) % 2019,mod)
    print(mod)

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;
#define MAXN 100005
#define MAXM 500005
#define INF 0x7fffffff
#define ll long long

int A[MAXN];
inline int read(){
	int x=0,f=1;
	char c=getchar();
	for(;!isdigit(c);c=getchar())
		if(c=='-')
			f=-1;
	for(;isdigit(c);c=getchar())
		x=x*10+c-'0';
	return x*f;
}

int main(){
	int N=read(),ans=0;
	for(int i=1;i<=2*N;i++)
		A[i]=read();
	sort(A+1,A+1+2*N);
	for(int i=1;i<=2*N;i+=2)
		ans+=A[i];
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int V = 1e5 + 100;
int n, we, w[N], v[N];
long long dp[N][V];

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

	cin >> n >> we;

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

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < V; j++) {
			dp[i][j] = LLONG_MAX;
		}
	}

	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < V; j++) {
			if (dp[i][j] == LLONG_MAX) continue;
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
			dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + (long long) w[i]);
		}
	}

	int ans = 0 ;
	for (int i = V - 1; i > 0; i--) {
		if (dp[n][i] <= we) {
			ans = i;
			break;
		}
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 85732
import sys 
sys.setrecursionlimit(100000) 

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

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

def tdc(p, v):
    if G[v] == [p]:
        dp[v] = 1
        return 1
    res = 1
    fm = [1]
    bm = []
    C = list(set(G[v]) - set([p]))
    for u in C:
        val = 1+tdc(v, u)
        val %= M
        res *= val
        res %= M
        fm.append(res)
        bm.append(val)
    dp[v] = res
    bm.append(1)
    for i in range(len(bm)-1, 0, -1):
        bm[i-1] *= bm[i]
        bm[i-1] %= M
    fm_bm[v] = [fm, bm]
    return dp[v]

r = 0       
tdc(-1, r)

ans = [0]*N
ans[r] = dp[r]

def buc(p, v, a):
    if G[v] == [p]: return 0
    C = list(set(G[v]) - set([p]))
    fm, bm = fm_bm[v]
    for i, u in enumerate(C):
        rev_dp = fm[i]*bm[i+1]%M
        rev_dp = rev_dp*a%M+1 
        ans[u] = dp[u]*rev_dp%M
        buc(v, u, rev_dp)

buc(-1, r, 1)
print('\n'.join(map(str, ans))) 

Measured memory_bytes: 145200
#include<bits/stdc++.h>
#define ll long long
#define inf 1e17 

using namespace std;

int n,m,a,b;
vector<vector<int> > arr(100000+10);
ll dp[100000+10];
ll indegree[100000+10];
void topo(int i,bool vis[],vector<int> &ans)
{
	vis[i]=true;
	for(int j=0;j<arr[i].size();j++)
	{
		if(!vis[arr[i][j]])
		{
			topo(arr[i][j],vis,ans);
		}
	}
	ans.push_back(i);
}


void dfs(int i,bool vis[])
{
	vis[i]=1;
	for(int j=0;j<arr[i].size();j++)
	{
		dp[arr[i][j]]=max(dp[arr[i][j]],dp[i]+1);
		if(!vis[i])
		{
		  dfs(arr[i][j],vis);
		}
	}
}




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

    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
    	cin>>a>>b;
    	arr[a].push_back(b);
	}

 vector<int> ans;
 bool vis[n+1];
 memset(vis,false,sizeof(vis));
 
 for(int i=1;i<=n;i++)
 {
 	if(!vis[i])
 	{
 		topo(i,vis,ans);
	 }
 }
 reverse(ans.begin(),ans.end());

  memset(vis,false,sizeof(vis));
 for(int j=0;j<ans.size();j++)
 {
 	if(!vis[ans[j]])
 	{
 	dfs(ans[j],vis);	
	}
 }
 
	ll maxi=-inf;
    for(int i=1;i<=n;i++)maxi=max(dp[i],maxi);
    cout<<maxi<<endl;
    

	return 0;
}

Measured memory_bytes: 9208
N = int(input())
S = [input() for _ in range(N)]

ab = 0
lastA = 0
onlylastA = 0
firstB = 0
onlyfirstB = 0
for s in S:
    ab += s.count('AB')
    if s[-1] == 'A' and s[0] != 'B':
        lastA += 1
        onlylastA += 1
    if s[0] == 'B' and s[-1] != 'A':
        firstB += 1
        onlyfirstB += 1
    if s[-1] == 'A' and s[0] == 'B':
        lastA += 1
        firstB += 1

ans = ab + min(lastA,firstB)
if lastA != 0 and onlylastA == 0 and onlyfirstB == 0:
    ans = max(ans-1,0)
print(ans)

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;cin>>N;
    string a;cin>>a;
    set<string> S;
    S.insert(a);
    bool flag=0;
    for(int i=2;i<N+1;i++){
        string b;cin>>b;
        S.insert(b);
        if(S.size()!=i)flag=1;
        if(a[a.size()-1]!=b[0])flag=1;
        a=b;
    }
    if(flag)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
   ll k;
   cin>>k;
   if(k%2==0)cout<<-1<<endl;
   else
   {
      ll ans=1;
      ll x=7;
      while(x%k!=0)
      {
          if(ans>k){cout<<-1<<endl;return;}
          x*=10;
          x+=7;
          x%=k;
          ans++;
          
      }
      cout<<ans<<endl;
   }
}

int32_t main()
{
	IOS
	ll T = 1;
// 	cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

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

int main(){
  set<int> S;
  int q, query, x;
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> query >> x;
    if(query == 0){
      S.insert(x);
      cout << S.size() << endl;
    }else{
      auto it = S.find(x);
      if(it != S.end()){
        cout << 1 << endl;
      }else{
        cout << 0 << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 12384
HP,n = map(int,input().split())
s = [tuple(map(int,input().split())) for i in range(n)]

#dp[damage] := モンスターにdamageを与える最小コスト
dp = [float('inf')]*(HP+1) #0~HP
dp[0] = 0
for damage, cost in s:
    for hp in range(HP):
        next_idx = min(hp+damage, HP)
        dp[next_idx] = min(dp[next_idx], dp[hp]+cost)
print(dp[-1])

Measured memory_bytes: 52700
import math
import os
import sys
from collections import deque
# from fractions import gcd
input = sys.stdin.readline

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


def main():
    N = int(input())
    graph = [[] for i in range(N+1)]
    colors = [-1] * (N + 1)
    init = -1
    display_order = []

    for i in range(N-1):
        u, v = map(int, input().split())
        graph[u].append(v)
        graph[v].append(u)
        display_order.append(v-1)

    q = deque()
    q.append((1, 0))
    visited = [False] * (N + 1)
    visited[1] = True

    while len(q) != 0:
        idx, color = q.popleft()
        nxt = graph[idx]
        cnt = 1
        # print('visiting', nxt)
        for e in nxt:
            if colors[e] == -1 and not visited[e]:
                if cnt == color:
                    cnt += 1
                    colors[e] = cnt
                    q.append((e, cnt))
                    visited[e] = True
                    cnt += 1
                else:
                    colors[e] = cnt
                    q.append((e, cnt))
                    visited[e] = True
                    cnt += 1

    print(max(colors))
    # print(*colors)
    # print(*display_order)
    for i in display_order:
        # print(i)
        print(colors[i+1])
    # for i in range(2, len(colors)):
    #     print(colors[i])


if __name__ == '__main__':
    main()


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

#define int long long int
#define pb push_back
#define MAX 100005
#define mod (int)(1e18+7)
#define sp fixed<<setprecision(12)
/*
vector<int> primes;
bool is_prime[MAX];
void sieve(){
    is_prime[0]=is_prime[1]=true;
    for(int i=4;i<MAX;i+=2){
        is_prime[i]=true;
    }
    for(int i=3;i*i<MAX;i+=2){
        if(!is_prime[i]){
            for(int j=i*i;j<MAX;j+=i){
                is_prime[j]=true;
            }
        }
    }
    
}

int power(int a,int n,int p){
    int res=1;
    while(n){
        if(n&1){
            res=(res*a)%p;
            n--;
        }else{
            a=(a*a)%p;
            n/=2;
        }
    }
    return res;
}
*/

void minWindow(string &s, string &t) {
        int n=s.length();
        int m=t.length();
        if(m>n){
            cout<<"No String\n";
            return;
        }
        int hash_s[256]={0};
        int hash_t[256]={0};
        for(int i=0;i<m;i++){
            hash_t[t[i]]++;
        }
        int start=0,start_indx=-1,min_len=INT_MAX;
        int count=0;
        for(int last=0;last<n;last++){
            hash_s[s[last]]++;
            if(hash_t[s[last]]!=0 and hash_s[s[last]]<=hash_t[s[last]]){
                count++;
            }
            if(count==m){
                while( (hash_s[s[start]] > hash_t[s[start]]) or (hash_t[s[start]]==0) ){
                    if((hash_t[s[start]]!=0) and hash_s[s[start]] > hash_t[s[start]]){
                        hash_s[s[start]]--;
                    }
                    start++;
                }
                int curr_len=last-start+1;
                if(curr_len < min_len){
                    min_len=curr_len;
                    start_indx=start;
                }
            }
        }
        if(start_indx==-1){
            cout<<"No String\n";
            return;
        }
        cout<<s.substr(start_indx,min_len)<<"\n";
}

int32_t main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    //double    pi=3.14159265358979323846;

    int t=1;
    //cin>>t;
    //int it=1;
    while(t--){
        int n;
        cin>>n;
        int f[n+1]={0};
        for(int i=1;i<sqrt(n-2);i++){
            for(int j=1;j<sqrt(n-2);j++){
                for(int k=1;k<sqrt(n-2);k++){
                    if((i*i+j*j+k*k+k*i+k*j+i*j)<=n){
                        f[(i*i+j*j+k*k+k*i+k*j+i*j)]+=1;
                    }
                }
            }
        }
        for(int i=1;i<=n;i++){
            cout<<f[i]<<"\n";
        }
    }

    return 0;
    
}

Measured memory_bytes: 3696
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>

#define rep(i, n) for (int i = 0; i < (int)(n)); i++)

using namespace std;

int main() {
    int m;
    cin >> m;
    cout << 48-m << endl;
}


Measured memory_bytes: 256
<?php
//(map座標全てに0を入れる) $map[$c][$y][$x]として、ブロックがある座標を１に。
//スタート地点上にあるブロックの「色」を調べる。なければNG。その色のブロックの座標のみたどる。
//スタート地点から深さ優先探索でmove。ゴールまでたどり着ければOK。ダメならNG

$move = array(array(1,0),array(0,1),array(-1,0),array(0,-1));

//dfs
function dfs($c, $y, $x){
	global $move;
	global $map;
	global $goal_flag;
	global $yg;
	global $xg;

	if ($y === $yg && $x === $xg){	//終了条件
		$goal_flag = 1;
		return;
	}

	$map[$c][$y][$x] = 0;	//再訪防止
	for ($i=0; $i<=3; $i++){	//上下左右を調査
		$y2 = $y + $move[$i][1];
		$x2 = $x + $move[$i][0];
		if (!empty($map[$c][$y2][$x2]) && $map[$c][$y2][$x2]===1){
			dfs($c, $y2, $x2);
		}
	}
	return;
}

while(1){
	//初期化
	$goal_flag = 0;
	$map = array();
	$usecolor = 0;		//たどる色

	//ファイル読み込み
	fscanf(STDIN, '%d %d', $w, $h);
	//終了判定
	if ($w==0 && $h==0){
		break;
	}
	fscanf(STDIN, '%d %d', $xs, $ys);
	fscanf(STDIN, '%d %d', $xg, $yg);
	fscanf(STDIN, '%d', $n);
	for ($i=0; $i<$n; $i++){
		fscanf(STDIN, '%d %d %d %d', $c, $d, $xblock, $yblock);
		//ブロックがある座標を１に
		if ($d === 0){		//方向転換なし
			for ($p=0; $p<=3; $p++){
				for ($q=0; $q<=1; $q++){
					$map[$c][$yblock + $q][$xblock + $p] = 1;
				}
			}
		} else {
			for ($p=0; $p<=1; $p++){
				for ($q=0; $q<=3; $q++){
					$map[$c][$yblock + $q][$xblock + $p] = 1;
				}
			}
		}
	}

	//スタート地点上の色判定
	for ($c=1; $c<=5; $c++){
		if (!empty($map[$c][$ys][$xs]) && $map[$c][$ys][$xs] === 1){
			$usecolor = $c;
			break;
		}
	}

	//スタート地点から探索
	if ($usecolor !== 0){
		dfs($usecolor, $ys, $xs);
	}
	//出力
	if ($goal_flag === 1){
		echo 'OK';
	} else {
		echo 'NG';
	}
	echo PHP_EOL;
}

Measured memory_bytes: 6780
#include<stdio.h>
int main(){
  
  int N,arr[100],i,V,j=0,m;
  
  scanf("%d",&N);
  
  for(i=0;i<N;i++)  
    scanf("%d",&arr[i]);
  
   for(i=0;i<N;i++){  
    printf("%d",arr[i]);
    if(i!=N-1) printf(" ");
    if(i==N-1) printf("\n");
  }
  
  
  for(i=1;i<N;i++){
    
    V=arr[i];
    j=i-1;
    while(j>=0 && arr[j]> V){
      arr[j+1]=arr[j];
      j--;
      arr[j+1]=V;
      
    }
   for(m=0;m<N;m++){  
	printf("%d",arr[m]);
	if(m!=N-1) printf(" ");
	if(m==N-1) printf("\n");
      } 
  }
   
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

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

	int64_t minCapacity = numeric_limits<int64_t>::max();
	for (int32_t i = 0; i < 5; i++) {
		int64_t capacity;
		cin >> capacity;
		minCapacity = min(minCapacity, capacity);
	}

	cout << (5 + (N - 1) / minCapacity) << endl;

	return 0;
}


Measured memory_bytes: 256
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

int main() {
  string s;
  cin >> s;
  bool found = false;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '7') found = true;
  }
  cout << (found ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3668
S = input()
N = len(S)
def strong(word):
    n = len(word)
    flag = True
    for i in range(n):
        if word[i] != word[-i-1]:
            flag = False
            break
        else:
            continue
    return flag
if strong(S) and strong(S[0:int((N-1)/2)]):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	long long n, m, i, j, k, ans, x, y, MOD = 1000000007, v;

	cin >> n >> m;
	vector<long long> a(n), b(m);
	vector<long long>::iterator pa, pb;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	for (i = 0; i < m; i++) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());

	bool valid = true;
	for (i = 1; i < n; i++) {
		if (a[i] == a[i - 1]) valid = false;
	}
	for (i = 1; i < m; i++) {
		if (b[i] == b[i - 1]) valid = false;
	}

	if (!valid) ans = 0;
	else {
		ans = 1;
		for (i = n * m; i >= 1; i--) {
			pa = lower_bound(a.begin(), a.end(), i);
			pb = lower_bound(b.begin(), b.end(), i);

			if ((pa == a.end()) || (pb == b.end())) {
				ans = 0;
				break;
			}

			if ((*pa == i) && (*pb == i)) v = 1;
			else if (*pa == i) {
				v = b.end() - pb;
			}
			else if (*pb == i) {
				v = a.end() - pa;
			}
			else {
				x = a.end() - pa;
				y = b.end() - pb;
				v = (x * y - (n * m - i)) % MOD;
			}

			ans = (ans * v) % MOD;
		}
	}

	cout << ans % MOD << "\n";
	return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text.RegularExpressions;
using System.Threading;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();
          switch(S)
            {
                case "ABC":
                    Console.WriteLine("ARC");
                    break;
                case "ARC":
                    Console.WriteLine("ABC");
                    break;
            }
        }
    }
}

//文字列の入力
//string s = Console.ReadLine();
//整数の入力
//long n = long.Parse(Console.ReadLine());
//文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');
//整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine();
//Console.ReadKey();


Measured memory_bytes: 25752
s = list(input())
l = []
for i in range(len(s)):
	l.append(s[i])
mindiff = 10**6
for i in range(len(l)-2):
	n = int("".join(l[i:i+3]))
	diff = abs(753 - n)
	if mindiff > diff:
		mindiff = diff

print(mindiff)


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < n; i++) {
            int size = sc.nextInt();
            if(map.containsKey(size)){
                map.put(size, map.get(size)+1);
            } else {
                map.put(size, 1);
            }
        }
        System.out.println(map.size());
    }
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N,M,R;
  cin>>N>>M>>R;
  vector<int>r(R);
  for(int i=0;i<R;i++)cin>>r[i];
  for(int i=0;i<R;i++)r[i]--;
  vector<int>A(M),B(M),C(M);
  for(int i=0;i<M;i++)cin>>A[i]>>B[i]>>C[i];
  for(int i=0;i<M;i++)A[i]--,B[i]--;
  vector<vector<ll>>dp(N,vector<ll>(N,INT_MAX));
  for(int i=0;i<N;i++)dp[i][i]=0;
  for(int i=0;i<M;i++)dp[A[i]][B[i]]=C[i],dp[B[i]][A[i]]=C[i];
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }
  sort(rng(r));
  ll ans=INT_MAX;
  do{
    ll sum=0;
    for(int i=0;i<R-1;i++){
      sum+=dp[r[i]][r[i+1]];
    }
    ans=min(ans,sum);
  }while(next_permutation(rng(r)));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 768
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N = int(input())
    A = read_list()

    res = 0
    num = 1
    for i, a in enumerate(A):
        if a == num:
            num += 1
        else:
            res += 1

    if res == N:
        print(-1)
    else:
        print(res)


if __name__ == "__main__":
    main()


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int count = 0;
	for(int x = a; x <= b; ++x) {
		if(c % x == 0) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 3112
import itertools


def abc150c_count_order():
    n = int(input())
    p = tuple(map(int, input().split()))
    q = tuple(map(int, input().split()))
    pattern = list(itertools.permutations(range(1, n + 1), n))
    print(abs(pattern.index(p)-pattern.index(q)))


abc150c_count_order()


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

#define pb push_back
#define mp make_pair
#define sqr(a) ((a) * (a)) 
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long long int li;
typedef long double ld;


int main()
{
    io();
    li k,a,b;
  cin>>k>>a>>b;
  if(a%k==0 || b%k==0)
  cout<<"OK\n";
  else
  {
    if(a/k==b/k)
      cout<<"NG\n";
    else
      cout<<"OK\n";
  }
}

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

using namespace std;

int main() {
    string s;
    cin >> s;
    int n = s.size();
    
    for(int i=1; i<n; i++) {
        if(s[i-1]==s[i]) {
            cout << i << " " << i+1 << endl;
            return 0;
        }
    }
    for(int i=2; i<n; i++) {
        if(s[i] == s[i-2]) {
            cout << i-1 << " " << i+1 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 512
program ABC067B
    implicit none
    integer(8)::N,K,i
    integer(8)::result=0
    integer(8),allocatable,dimension(:)::L
    read(5,*)N,K
    allocate(L(N))
    read(5,*)(L(i),i=1,N)
    L=iqsort(L)

    do i=0,K-1
        result=result+L(N-i)
    end do
    print'(i0)',result
contains
    recursive function iqsort(ix) result(ires)
      integer(8), allocatable :: ires(:)
      integer(8), intent(in)  :: ix(:)
      integer :: k
      if (size(ix) <= 1) then 
        ires = ix
      else  
        k = ix(size(ix) / 2)
        ires = [iqsort(pack(ix, ix < k)), pack(ix, ix == k), iqsort(pack(ix, ix > k))] 
      end if
    end function iqsort
end program ABC067B

Measured memory_bytes: 512
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int A=sc.nextInt();
		int B=sc.nextInt();
		int K=sc.nextInt();
		ArrayList<Integer> cc = new ArrayList<>(K);
		
		for(int i=0;i<K;i++) {
			cc.add(i+A);
			cc.add(B-i);
			if(A+i>=B-i) {
			cc.remove(cc.size()-1);
			break;
			}
			
		}
		Collections.sort(cc);
		int past=111111111;
		for(int i:cc) {
			if(past!=i)p(i);
			past=i;
		}
	}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 25172
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int N, M; ll dp[100005];
int main() {
  scanf("%d %d", &N, &M);
  for(int i = 1, a; i <= M; ++i) {
    scanf("%d", &a);
    dp[a] = -1;
  }
  dp[0] = 1LL;
  for(int i = 0; i <= N; ++i) {
    if(dp[i] < 0) continue;
    if(dp[i+1] > -1) dp[i+1] = (dp[i+1]+dp[i])%MOD;
    if(dp[i+2] > -1) dp[i+2] = (dp[i+2]+dp[i])%MOD;
  }
  printf("%ld\n", dp[N]);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	double a,b,v;
	cin>>a>>b>>v;
	double ans=0;
	if(a*a*b/2<=v){
		double y=2*(a*a*b-v);
		double x=a*a*a;
		ans=atan2(y,x);
	}
	else{
		double y=b*b*a;
		double x=2*v;
		ans=atan2(y,x);
	}
	printf("%.9f",ans*360/(2*M_PI));
	// your code goes here
	return 0;
}

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

int main()
{
	std::string str;
	int q;
	
	getline(std::cin, str);
	std::cin >> q;
	for (int i=0; i<q; i++) {		
		std::string tmp, dummy;
		std::string inst;
		int a, b;
		std::string p;
		
		std::cin >> inst >> a >> b;
		if (inst == "replace") std::cin >> p;
		/*
		int sp_pos1 = tmp.find(' ', 0);
		int sp_pos2 = tmp.find(' ', sp_pos1+1);
		int sp_pos3 = tmp.find(' ', sp_pos2+1); 
		
		std::string inst = tmp.substr(0, sp_pos1);
		int a = std::stoi(tmp.substr(sp_pos1+1, sp_pos2));
		int b = (sp_pos3 >= 0) ? std::stoi(tmp.substr(sp_pos2+1, sp_pos3)) : std::stoi(tmp.substr(sp_pos2+1));
		std::string p;
		if (sp_pos3 >= 0) p = tmp.substr(sp_pos3+1);
		*/
		
		//std::cout << inst << " " << a << " " << b << std::endl;
		//std::cout << dummy << std::endl;
		
		if (inst == "print") {
			std::cout << str.substr(a, b-a+1) << std::endl;
		} else if (inst == "reverse") {
			std::reverse(str.begin()+a, str.begin()+b+1);
		} else if (inst == "replace") {
			str.replace(a, b-a+1, p);
		}
	}
		
	return 0;
}




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

int main()
{
    long long int a,b,x;
    cin>>a>>b;
    x=((a*b)+1)/2;
    if(a==1 || b==1)
        cout<<1<<endl;
    else
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 256
N, K = [int(item) for item in input().split()]
N_list = [int(item) for item in input().split()]

k_list = [(i+1)/2 for i in N_list]


memo = sum(k_list[0:K])
accum_list = [memo]

for i in range(N-K):
    memo += k_list[i+K] - k_list[i]
    accum_list.append(memo)

print(max(accum_list))

Measured memory_bytes: 24676
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp1
{
    class Program
    {
        //
        static void Main(string[] args)
        {
            List<long> Ninzu = new List<long>();
            long N = long.Parse(Console.ReadLine());
            long A = long.Parse(Console.ReadLine()); Ninzu.Add(A);
            long B = long.Parse(Console.ReadLine()); Ninzu.Add(B);
            long C = long.Parse(Console.ReadLine()); Ninzu.Add(C);
            long D = long.Parse(Console.ReadLine()); Ninzu.Add(D);
            long E = long.Parse(Console.ReadLine()); Ninzu.Add(E);
 
            long minNinzu = Math.Min(Ninzu.Min(x => x), N);
 
            Console.WriteLine(((long)(Math.Ceiling((1.0 * N) / minNinzu) + 4)).ToString());
        }
 
    }
    
}

Measured memory_bytes: 13396