akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace csharp
{
    class Program
    {
        private const float V = 1.0f;

        static void Main(string[] args)
        {
            string lineStr;
            lineStr = Console.ReadLine();

            string[] arg = lineStr.Split(' ');
            int n = int.Parse(arg[0]);
            int k = int.Parse(arg[1]);

            lineStr = Console.ReadLine();
            string[] h = lineStr.Split(' ');
            int ret = 0;

            foreach (string e in h )
            {
                if ( int.Parse(e) >= k )
                    ret++;
            }


                Console.WriteLine(ret);

            return;
        }
    }
}


Measured memory_bytes: 15584
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const double PI = acos(-1);
const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

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

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;


vector<string> split(const string &s, char delim) {
    vector<string> elems;
    string item;
    for (char ch: s) {
        if (ch == delim) {
            if (!item.empty())
                elems.push_back(item);
            item.clear();
        }
        else {
            item += ch;
        }
    }
    if (!item.empty())
        elems.push_back(item);
    return elems;
}



int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    ll ans = 0;
    rep(i, n){
        REP(j, i + 1, n){
            REP(k, j + 1, n){
                if(l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) continue;
                if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]) ans++;
            }
        }
    }
    print(ans);

    

}



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

int main(){
    const int MAX_N = 2e5+10;
    ll N, K;
    int A[MAX_N], B[MAX_N];

    cin >> N >> K;
    for (int i = 0; i < N; ++i){
        int a;
        cin >> a;
        A[i] = a-1;
        B[i] = -1;
    }

    B[0] = 0;
    int v = 0, cost = 0;
    while(B[A[v]] == -1){
        B[A[v]] = ++cost;
        v = A[v];
    }

    int offset = B[A[v]];
    int mod = ++cost - offset;

    int step = K <= offset ? K : (K - offset) % mod + offset;

    int res = 0;
    for (int i = 0; i < step; ++i){
        res = A[res];
    }
    cout << res+1 << endl;

    return 0;
}

Measured memory_bytes: 5160
#include <stdio.h>
#include <algorithm>

using namespace std;

struct data{
	int start;
	int stop;
	
}listdata[100010];

bool compare(data a, data b){
	return a.stop < b.stop;
}

int main(){
	int jumlah;
	scanf ("%d",&jumlah);
	for (int a=0;a<jumlah;a++){
		scanf ("%d %d",&listdata[a].start,&listdata[a].stop);
	}
	
	sort(listdata,listdata+jumlah,compare);
	
	int count=1;
	int starsekarang=0;
	for (int a=1;a<jumlah;a++){
		//printf ("%d %d\n",listdata[a].start,listdata[a].stop);
		if (listdata[a].start > listdata[starsekarang].stop){
			starsekarang=a;
			count++;
		}
	}
	
	printf ("%d\n",count);
	
	
	return 0;
}


Measured memory_bytes: 3488
N,M=map(int,input().split())
AC=[0]*N
WA=[0]*N
wa=0
for i in range(M):
    p,s=input().split()
    p=int(p)-1
    if AC[p]==0 and s=="AC":
        AC[p]=1
        wa+=WA[p]
    WA[p]+=1
print(sum(AC),wa)

Measured memory_bytes: 4596
import collections
N = int(input())
v = list(map(int, input().split()))
if len(set(v)) == 1:
  print(int(len(v)/2))
  exit()
cov = collections.Counter(v[1::2])
cev = collections.Counter(v[::2])
mov = cov.most_common()[0][0]
mev = cev.most_common()[0][0]
ans = len(v) - cov[mov] - cev[mev]

if mov == mev:
  ans1 = len(v) - cov.most_common()[1][1] - cev.most_common()[0][1]
  ans2 = len(v) - cov.most_common()[0][1] - cev.most_common()[1][1]
  ans = min(ans1, ans2)

print(ans)

Measured memory_bytes: 20188
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

class Node{
	static bool cutfailed = false;
	Node[] adjnodes;
	Node parent;
	Node[] kids;
	int id;
	long value;
	this(int id, long value){
		this.id = id;
		this.value = value;
		}
	void add(Node nd){
		this.adjnodes ~= nd;
		nd.adjnodes ~= this;
		}
	void setRoot(){
		foreach(nd; adjnodes) nd.setParent(this);
		}
	void setParent(Node par){
		this.parent = par;
		par.kids ~= this;
		foreach(nd; adjnodes){
			if(nd.id != par.id) nd.setParent(this);
			}
		}
	void cutKids(){
		debug writeln(this.id, ">", nodes.map!(a => a.value), Node.cutfailed);
		foreach(k; kids) if(k.kids.length > 0) k.cutKids();
		long sumvalue = kids.map!(a => a.value).reduce!((a, b) => a + b);
		long maxvalue = kids.map!(a => a.value).reduce!max;
		if(this.parent){
			if(this.value > sumvalue) cutfailed = true;
			else if(this.value < maxvalue) cutfailed = true;
			else if(this.value * 2 < sumvalue) cutfailed = true;
			else{
				this.value = this.value * 2 - sumvalue;
				this.kids.length = 0;
				debug writeln("*", this.value);
				}
			}
		else{ // this is the root
			if(this.kids.length > 1){
				if(this.value * 2 == sumvalue && this.value >= maxvalue){
					this.value = 0;
					this.kids.length = 0;
					debug writeln("*", this.value);
					}
				else cutfailed = true;
				}
			else{
				if(this.value == sumvalue){
					this.value = 0;
					this.kids.length = 0;
					debug writeln("*", this.value);
					}
				else cutfailed = true;
				}
			}
		debug writeln(this.id, "<", nodes.map!(a => a.value), Node.cutfailed);
		}
	}

Node[] nodes;

void main(){
	int n = readln.chomp.to!int;
	long[] as = readln.chomp.split.map!(to!long).array;
	
//	Node[] nodes;
	for(int i = 0; i < n; i ++){
		nodes ~= new Node(i, as[i]);
		}
	
	for(int i = 0; i < n - 1; i ++){
		int[] tmp = readln.chomp.split.map!(to!int).array;
		int a = tmp[0] - 1, b = tmp[1] - 1;
		nodes[a].add(nodes[b]);
		}
	
	nodes[0].setRoot;
	
	debug nodes.map!(a => a.kids.map!(x => x.id)).writeln;
	
	nodes[0].cutKids;
	
	string ans;
	if(Node.cutfailed) ans = "NO";
	else if(nodes[0].adjnodes.length > 1 && nodes[0].value > 0) ans = "NO";
	else ans = "YES";
	
	ans.writeln;
	}


Measured memory_bytes: 43004
#include<bits/stdc++.h>
#define int long long
#include<bitset>
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
void solve() {
    int n, cap;
    cin >> n >> cap;
    int wt[n], val[n];
    for (int i = 0; i < n; ++i) cin >> wt[i] >> val[i];
    int dp[n + 1][cap + 1];
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= cap; ++j) {
            if (i == 0 or j == 0) dp[i][j] = 0;
            else if (wt[i - 1] > j) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = max(dp[i - 1][j], val[i - 1] + dp[i - 1][j - wt[i-1]]);
            }
        }
    }
//    for (int i = 0; i <= n; ++i) {
//        for (int j = 0; j <= cap; ++j) cout << dp[i][j] << " ";
//        cout << "\n";
        cout << dp[n][cap];


}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//    #ifndef ONLINE_JUDGE
//    freopen("C:\\Users\\himan\\Desktop\\Hackercup\\input.txt", "r", stdin);
//    freopen("C:\\Users\\himan\\Desktop\\Hackercup\\output.txt", "w", stdout);
//    #endif
    int tc = 1;
    //cin >> tc;
    for(int i=1;i<=tc;++i) {
        //cout<<"Case #"<<i<<": ";
        solve();
        //cout<<"\n";
    }
}


Measured memory_bytes: 82432
//AUTHOR: RAVAN_2070
//PUNE INSTITUTE OF COMPUTER TECHNOLOGY
/*                                                    
      I ♥ CLARICE STARLING...                                                               
        EXPLAINATION BELOW->
*/
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef pair<ll,ll> pii;
typedef map<ll,ll> mii;
#define MOD7 1000000007
#define MOD9 1000000009
#define pi 3.1415926535
#define Test_cases ll TC;cin>>TC;while(TC--)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define sp(x) fixed<<setprecision(x)
#define sz(x) (ll)(x.size())
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
const ll INF = (ll)2e18 + 77;
void solve()
{
   string s,t;cin>>s>>t;
   int cnt=0;
   for(int i=0;i<sz(t);i++)
   {
       if(t[i]!=s[i])cnt++;
   }
   cout<<cnt<<"\n";
}
int main()
{
   fastio
   //Test_cases
   solve();
  return 0;
}
//map<ll,ll,greater<int>> to sort in descending order ,in iterator declaration no greater<int>
//if you want to apply lowerbound on set use s.lower_bound(key),not the one used for vector
// Syntax to create a min heap for priority queue priority_queue <int, vector<int>, greater<int>>; 
//for modinverse use modularexponention(x,M-2,M);
//for "each" subtraction from ans(ans-k) if(ans<0) do ans+=MOD,ans%=MOD
//vector<vector<int>>dp(201,vector<int>(n+1)); A way to initialize vector of vector
//If wrong on pretest 2 means logically wrong


/* TIPS FOR DEBUGGING
 * Check if values are not overflowing (use long long where required)
 * Check if ranges are inclusive or not.
 * Check properly if greedy will work or not before using it.
 * Check EDGE CASES!! Seriously, even in 2B, saving 8 points by being
 * 2 minutes faster will bite you in the ass if you don't make sure
 * it works on edge cases.
 * Keep adding to this list.
*/


Measured memory_bytes: 3804
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <ctime>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define rg register
#define LL long long
#define __space putchar(' ')
#define __endl putchar('\n')
template <typename qwq> inline void read(qwq &x)
{
	x = 0;
	rg int f = 1;
	rg char c = getchar();
	while (c < '0' || c > '9')
	{
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9')
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= f;
}
template <typename qaq> inline void print(qaq x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
}
int n;
int a[2333333];
bool vis[2333333];
bool flag;
int main()
{
	read(n);
	for (rg int i = 1; i <= n; ++i)
	{
		read(a[i]);
	}
	for (rg int i = 2; i <= n; ++i)
	{
		if (a[i] > a[i - 1]) --a[i], vis[i] = true;
		if (a[i] < a[i - 1] && !vis[i - 1])
		{
			--a[i - 1];
			if (a[i] < a[i - 1] || a[i - 1] < a[i - 2])
			{
				puts("No");
				return 0;
			}
		}
		else if (a[i] < a[i - 1] && vis[i - 1])
		{
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 2432
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        String str = sc.next();
        
        int index = 0;
        int count = 0;
        for (int i = 0; i <= 9; i++) {
            
            for (int x = 0; x < n; x++) {
                if (Integer.parseInt(String.valueOf(str.charAt(x))) == i) {
                    
                    for (int j = 0; j <= 9; j++) {
                        
                        for (int y = x + 1; y < n; y++) {
                            if (Integer.parseInt(String.valueOf(str.charAt(y))) == j) {
                                
                                for (int k = 0; k <= 9; k++) {
                                    
                                    for (int z = y + 1; z < n; z++) {
                                        if (Integer.parseInt(String.valueOf(str.charAt(z))) == k) {
                                            count++;
                                            break;
                                        }
                                    }
                                }
                                break;
                            }
                        }
                    }
                    break;
                }
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 92716
#include <stdio.h>

int main(void)
{
	int i = 1;
   	while(1)
   	{
   		int a, b;
   		scanf("%d %d", &a, &b);
   		if(a == b && a == 0)
   			break;
   		else if(a < b)
   			printf("%d %d\n", a, b);
   		else 
   			printf("%d %d\n", b, a);
   		
   	}
    return 0;
}

Measured memory_bytes: 2680
#include <iostream>

using namespace std;

int main()
{
   long long K, p=0, c=0;
   cin>>K;
   if(K%2==0 ||K%5==0)
        cout<<"-1";
   else
   {
       do{
           p=(p*10+7)%K;
           ++c;
       }while(p);
       cout<<c;
   }
   
   return 0;
}


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

int main()
{
  int a[6];
  int res=0;

  rep(i,5) cin >> a[i];

  rep(i,5){
    int mod = a[i]%10;
    res += a[i] - mod;
    if(mod==0) a[i] = 10;
    else a[i] = mod;
  }
  sort(a, a+5, greater<int>());

  //cout << "===" << endl;                                                      
  //cout << res << endl;                                                        
  //rep(i,5){                                                                   
  //  cout << a[i] << endl;                                                     
  //}                                                                           
  rep(i,5){
    if(a[i]==10) res += 0;
    else if(i==4) res+= a[i];
    else res+= 10;
  }

  cout << res << endl;
}

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

using namespace std;

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

int main(){
  int k, x;
  cin >> k >> x;
  REP(i, 2 * k - 1){
    if(i != 0) putchar(32);
    printf("%d", x - k + 1 + i);
  }
  puts("");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int M = 1e9+7;
#define F(i,a,b) for(int i=a;i<b;i++)
/*

recursive definition f(n,k) = sum(f(n-1,k-t)) where t = {0,1,...a[n]}
or sum = f(n-1,max(0,t)) where t = max(0,n-a[n]) ..... k


ll f(int *a,int n,int k)
{
  if(n>=0 && k== 0) return 1;
  if(n==0 && k>0) return 0;
  if(dp[n][k] != -1) return dp[n][k];
  ll ans = 0;
  for(int i=0;i<=min(a[n],k);i++)
    ans = (ans+f(a,n-1,k-i))%M;
  dp[n][k] = ans;
  return ans;
}
*/

/*
iterative - As recursive sum is required we store prefix sum of previous array in prefix vector and calculate dp[i][j] using it;
dp[i][j] = number of ways of correctly distributing i candies to j children 

in this code https://atcoder.jp/contests/dp/submissions/14459892 i combined prefix sum in dpprefix hence saved extra W space but made definition of dp non intuitive although the former ran 50 ms faster.

int main() {
  int n,k;
  cin>>n>>k;
  int a[n+1];
  for(int i=1;i<=n;i++) cin>>a[i];
  vector<vector<ll>> dp(n+1,vector<ll> (k+1,0));
  vector<ll>prefix(k+1,0);
  prefix[0] = 1;
  for(int child=0;child<=n;child++) dp[child][0] = 1;
  for(int candies=1;candies<=k;candies++) prefix[candies] += prefix[candies-1];
  for(int child=1;child<=n;child++)
  {
    for(int candies=1;candies<=k;candies++)
    {
      ll left=0;
      if(candies-a[child]>0)
        left = prefix[candies-a[child]-1];
      dp[child][candies] = (prefix[candies] - left+M)%M;
      //prefix[candies] = (dp[child][candies]+prefix[candies-1])%M;
    }
    for(int candies=1;candies<=k;candies++)
    {
        prefix[candies] = (prefix[candies-1] + dp[child][candies])%M; 
    }
  }
  
  cout<<dp[n][k];
  return 0;
}

*/

int main() {
  int n,k;
  cin>>n>>k;
  vector<ll> dp(k+1,0);
  vector<ll>prefix(k+1,0);
  prefix[0] = 1;
  int maxcandies;
  for(int child=0;child<=n;child++) dp[0] = 1;
  for(int candies=1;candies<=k;candies++) prefix[candies] += prefix[candies-1];
  for(int child=1;child<=n;child++)
  {
    cin>>maxcandies;
    for(int candies=1;candies<=k;candies++)
    {
      ll left=0;
      if(candies-maxcandies>0)
        left = prefix[candies-maxcandies-1];
      dp[candies] = (prefix[candies] - left+M)%M;
      //prefix[candies] = (dp[child][candies]+prefix[candies-1])%M;
    }
    for(int candies=1;candies<=k;candies++)
    {
        prefix[candies] = (prefix[candies-1] + dp[candies])%M; 
    }
  }
  
  cout<<dp[k];
  return 0;
}


Measured memory_bytes: 4824
import math
def main():
    line = [int(i) for i in input().split(' ')]
    A, B, H, M = line[0], line[1], line[2], line[3]
    ang = math.fabs(((H+M/60) / 12 * 360) - (M / 60 * 360))
    angle = min(ang, 360-ang)
    ans = math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(angle)))
    print(ans)
if __name__ == "__main__":
    main()


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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int A, B;
  cin >> A >> B;
  if (A == 2 || B == 2)
    cout << "No" << endl;
  else
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    x = int(input())
    kyu = 8
    for i in range(400, 1801, 200):
        if i <= x <= i+199:
            print(kyu)
        kyu -= 1
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 10436
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define forn(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pp printf("Case %d: \n",t)
const int MAXX=1000005;
const int maxInt = 2147483647;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  int n;cin >> n;
  int a[n]={0};
  forn(i,n)cin >> a[i];
  sort(a,a+n);cout << a[n/2]-a[n/2-1]<< endl;
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
  while(1){
    int i,j,d,m,All=0;
    scanf("%d%d",&m,&d);
    if(m==0 && d==0)break;
    j=m-1;
    for(i=j;i>0;i--){
      if(i==1 || i==3|| i==5||i==7||i==8||i==10||i==12){
	All+=31;
      }else if(i==4 || i==6||i==9||i==11){
	All += 30;
    }else if(i==2){
      All+=29;
    }
    }
    All+=d;

    if(All%7==1)
      printf("Thursday\n");
    if(All%7==2)
      printf("Friday\n");
    if(All%7==3)
      printf("Saturday\n");
    if(All%7==4)
      printf("Sunday\n");
    if(All%7==5)
      printf("Monday\n");
    if(All%7==6)
      printf("Tuesday\n");
    if(All%7==0)
      printf("Wednesday\n");
  }
  return 0;
}

Measured memory_bytes: 584
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
ans=0
count=t+1000
for i in range(n):
    num=abs(a-(t-(h[i]*0.006)))
    if count>num:
        ans=i+1
        count=num
print(ans)


Measured memory_bytes: 3060
// https://ei1333.github.io/luzhiled/
// http://beet-aizu.hatenablog.com/entry/2017/01/04/113233
// http://www.prefield.com/algorithm/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vd = vector<ld>;
using vs = vector<string>;
using vb = vector<bool>;
using vvl = vector<vector<ll>>;
using vvd = vector<vector<ld>>;
using vvs = vector<vector<string>>;
using vvb = vector<vector<bool>>;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
using Graph = vector<vector<ll>>;
const ll INF = 1LL << 60;
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
const ll tl= 1000000007;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define debug cout << "line : " << __LINE__ << " debug" << endl;
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ind(...) long double __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define inc(...) char __VA_ARGS__; in(__VA_ARGS__)
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << endl;} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#define in1(A) REP(i,A.size()) in(A[i]);
#define in2(A,B) REP(i,A.size()) in(A[i],B[i]);
#define in3(s,t,u) REP(i,sz(s)){in(s[i] , t[i] , u[i]);}
#define in4(s,t,u,v) REP(i,sz(s)){in(s[i] , t[i] , u[i] , v[i]);}
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
struct Point{ ld x,y; };
ld dist(Point a, Point b){return sqrt(abs(a.x-b.x)*abs(a.x-b.x)+abs(a.y-b.y)*abs(a.y-b.y));} // ２点間の距離 
ll gcd(ll a, ll b) { return b != 0 ? gcd(b, a % b) : a; }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b;} 
ll fact(ll n){ if(n < 2) return 1; return (n * fact(n-1))%tl; } //階乗
inline ll updiv(ll a,ll b){ return (a + b - 1) / b; } //切り上げ
template<typename T,typename U>ll ceil(T a,U b){return (a + b - 1) / b;}
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
//-------------------------------------------------------------------------------------------------
int main(){
    init();
    inl(n);
    vl dp(n+1,0);
    dp[0]=1; dp[1]=1;
    FOR(i,2,n+1) dp[i]= dp[i-1]+dp[i-2];
    out(dp[n]);
}


Measured memory_bytes: 3160
/* maybemaybemaybeno */
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double lld ;
#define f(i,s,n) for(int i=s;i<(int)n;i++) 
const int MAXN = 1e5+5 ;
#define pb push_back 
#define X first 
#define Y second 
#define pii pair<int,int> 
#define pll pair<ll,ll> 
#define pli pair<ll,int> 
#define pil pair<int,ll> 
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<setprecision(10) ;
#define is(x) cout<<#x<<" : "<<x<<endl ;
// #define DEBUG
int a[MAXN] ;
bool visited[MAXN] ;
int main()
{
    fio ;
    /* ======================Start of code ================ */
    int n;cin>>n;
    f(i,1,n+1) cin>>a[i] ;
    int steps = 0 ;
    int curr = 1 ;
    while(curr!=2 && !visited[curr])
    {   
        #ifdef DEBUG 
        is(curr) ;
        #endif 
    
        steps++ ;
        visited[curr] = 1 ;
        curr = a[curr] ;
    }
    if(curr==2) cout<<steps<<"\n" ;
    else cout<<"-1\n" ;
    /* ======================End of code ================== */
}

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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll    = long long;
using pint  = pair<int, int>;
using plint = pair<ll, ll>;
#define ld long double
#define ull unsigned long long int

#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rrep1(i, n) for (int i = ((int)(n)); i > 0; --i)

#define SZ(x) ((int)(x).size())
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back

typedef pair<int, int>    pii;
typedef vector<int>       vi;
typedef vector<vi>        vii;
typedef vector<double>    vd;
typedef vector<long long> vll;

// template<class T>bool maxc(T &a, const T &b) { if (a<b) { a=b; return 1; } }
// template<class T>bool minc(T &a, const T &b) { if (b<a) { a=b; return 1; } }

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    ll n;
    cin >> n;
    ll q;
    cin >> q;
    string s;
    cin >> s;
    vll l(q);
    vll r(q);
    rep(i, q) {
        cin >> l[i];
        cin >> r[i];
    }

    // 処理
    vector<int> su(n);
    rep(i, n - 1) su[i + 1] = su[i] + (s[i] == 'A' and s[i + 1] == 'C');

    // 出力
    rep(i, q) { cout << su[r[i] - 1] - su[l[i] - 1] << endl; }

    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(void){
    ll n,sum=0;cin >> n;
    for(int i=1; i<=n; i++){
        if(i%3!=0 && i%5!=0)sum+=i;
    }
    printf("%lld", sum);
    return 0;
}

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

using namespace std;

const int N = 2e5+9;
int n, m, visited[N], sign[N];
vector<int> g[N];

void bfs (int x){
	queue<int> q;
	q.push(x);

	while (!q.empty()){
		int u = q.front();
		q.pop();

		for (int i = 0; i < (int)g[u].size(); i++){
			int v = g[u][i];

			if (!visited[v]){
				visited[v] = true;
				sign[v] = u;
				q.push(v);
			}
		}
	}
}

int main(){
#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	scanf("%d %d", &n, &m);

	for (int i = 0; i < m; i++){
		int a, b;
		scanf("%d %d", &a, &b);
		g[a].push_back(b);
		g[b].push_back(a);
	}

	bfs(1);

	bool ans = 1;

	for (int i = 2; i <= n; i++)
		if (sign[i] == 0)
			ans = false;

	if (ans){ 
		printf("Yes\n");
		for (int i = 2; i <= n; i++){
			printf("%d\n", sign[i]);
		}
	} else {
		printf("No\n-1\n");
	}

	return 0;
}

Measured memory_bytes: 13356
import itertools

n = int(input())
D = list(map(int, input().split()))

l1 = [x for x in range(n)]
l2 = [x for x in range(n)]

ans = 0
sub = 0

for v1, v2 in itertools.product(l1, l2):
    ans += D[v1] * D[v2]

for i in range(n):
    sub += D[i]*D[i]

print((ans-sub)//2)

Measured memory_bytes: 63828
S = input()
n = len(S)

def solve(i, s, suma):
  if i == n-1:
    if suma==7:
      print(s+"=7")
      exit()
  else:
    solve(i+1, s+"-"+S[i+1], suma-int(S[i+1]))
    solve(i+1, s+"+"+S[i+1], suma+int(S[i+1]))
  
  
print(solve(0, S[0], int(S[0])))

Measured memory_bytes: 3064
# include <bits/stdc++.h>
  using namespace std;
# define res(a,b,c) for (int64 a=b ; a<c ; a++)
# define ress(a,b)  for (auto a = b.begin() ; a!=b.end() ; a++) 
# define all(con) con.begin() , con.end()
# define INF (int)1e9  
# define MOD 1000000007
# define pb push_back   
# define mp make_pair
# define f first
# define s second   
# define MAX numeric_limits<int>::max() 
# define MIN numeric_limits<int64>::min()
# define mymin -1000000000000000001
# define mymax 1000000000000000001
# define watch(x) cout<<(#x)<<" is "<<(x)<<endl
# define in(x) cin>>(x)
# define inn(x,y) cin>>(x)>>(y)  
# define out(x) cout<<(x)<<"\n"  
# define outt(x,y) cout<<(x)<<" "<<(y)<<"\n"  
typedef long long int int64;
typedef unsigned long long int uint64;
typedef vector<int64> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int64,int64> pi; 
bool doubleSame(double a, double b)
{ const double eps = 1e-15; return ( abs(a-b)<= eps*abs(a) ); }

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

	vector<int64> h(n);
	for(int64 i = 0 ; i<n ; i++)
		cin>>h[i];

	vector<int64> ans(n);
	ans[0] = 0;
	ans[1] = abs(h[1]-h[0]);

	for(int i = 2 ; i<n ; i++)
		ans[i] = min(abs(h[i]-h[i-1])+ans[i-1] , abs(h[i]-h[i-2])+ans[i-2]);

	cout<<ans[n-1];
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
long long mod = pow(10,9)+7;
long long getSumPatternNum(long long n, long long k){
    // long long min = (k*(1+k))/2;
    // long long max = (k*(first+last))/2;
    long long min = k;
    //cout << "min:"<<min<<endl;
    min *= (1+k);
    //cout << "min:"<<min<<endl;
    min /= 2;
    //cout << "min:"<<min<<endl;
    if(min<0){
        int mtp;
        cin >> mtp;
    }

    long long max,first,last;
    first = n-(k-1);
    last = n;
    max = k*(first+last);
    max /= 2;
    if(max<0){
        int mtp;
        cin >> mtp;
    }

    long long ans = max - min + 1;
    //cout << "n:" << n << " k:" << k << " max:" << max << " min:" << min << endl;
    if(ans<0){
        ans += mod;
    }
    // cout << "n:" << n << " k:" << k << " max:" << max << " min:" << min << endl;
    // cout << "ans:"<<ans<<endl;
    return ans;
}
int main(){
    long long in_n,in_k;
    cin >> in_n >> in_k;
    long long answer = 0;
    long long arrayNum = in_n + 1;
    for(long long i = in_k; i<=arrayNum; i++){
        //cout << "i:"<<i<<endl;
        answer+=getSumPatternNum(arrayNum,i);
        answer%=mod;
    }
    cout << answer << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define INF (1e9)
#define N 100005
using namespace std;
typedef pair<int,int> P;
typedef pair<P,int> P2;

int n, T;
string A, B;
vector<P> G[N];
map<string,vector<int> > memo;
string s[N];
int ti[N];
string itos[N];

set<string> used;
priority_queue<P2,vector<P2>,greater<P2> > q;
P d[N];

P dijkstra(){
  
  for(int i=0;i<n;i++) d[i]=P(INF,INF);
  
  for(int i=0;i<n;i++)

    if(A==itos[i]){
      
      d[i]=P(0,0);

      q.push(P2(P(0,0),i));      
    }
    
  while(!q.empty()){

    P2 t=q.top(); q.pop();

    int cost1=t.first.first;
    int cost2=t.first.second;
    int node=t.second;

    if(itos[node]==B) return P(cost1,cost2);
    
    if(d[node]<P(cost1,cost2)) continue;
    
    if(!used.count(itos[node])){

      used.insert(itos[node]);
      
      for(int i=0;i<memo[itos[node]].size();i++){

	int next=memo[itos[node]][i];

	if(d[next]>P(cost1+T,cost2+1)){
	  d[next]=P(cost1+T,cost2+1);
	  q.push(P2(P(cost1+T,cost2+1),next));
	}
	
      }
      
    }

    for(int i=0;i<G[node].size();i++){

      int next=G[node][i].first;
      int c=G[node][i].second;
      
      if(d[next]>P(cost1+c,cost2)){
	d[next]=P(cost1+c,cost2);
	q.push(P2(P(cost1+c,cost2),next));
      }
      
    }
    
  }

  return P(-1,-1);
}

int main(){
  
  cin>>n>>T;
  cin>>A>>B;

  int cnt=0;
  
  for(int i=0;i<n;i++){
    
    int a;
    scanf("%d",&a);

    for(int j=0;j<a;j++) cin>>s[j];
    
    for(int j=0;j<a-1;j++) scanf("%d",&ti[j]);

    for(int j=0;j<a;j++){

      if(j!=a-1){
	G[cnt].push_back(P(cnt+1,ti[j]));
	G[cnt+1].push_back(P(cnt,ti[j]));
      }

      memo[s[j]].push_back(cnt);
      
      itos[cnt]=s[j];
      
      cnt++;
      
    }
    
  }

  n=cnt;

  P ans=dijkstra();

  if(ans.first==-1) cout<<-1<<endl;
  else cout<<ans.first<<' '<<ans.second<<endl;
  
  return 0;
}

Measured memory_bytes: 23956
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	int n;
	cin>>n;
	vector<int> t(n),a(n),sum(n);
	for(int i=0;i<n;i++){
		cin>>t[i]>>a[i];
		sum[i]=t[i]+a[i];
	}
	long long int tk=t[0],ao=a[0];
	long long int tmp1,tmp2;
	for(int i=1;i<n;i++){
		tmp1=((tk-1)/t[i]+1);
		tmp2=((ao-1)/a[i]+1);
		tmp1=(tmp1>tmp2)?tmp1:tmp2;
		ao=tmp1*a[i];
		tk=tmp1*t[i];
		//cout<<tk<<" "<<ao<<endl;
	}
	cout<<tk+ao<<endl;
	return 0;
}


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

#define all_of(x) std::begin(x), std::end(x)
#ifdef _GLIBCXX_DEBUG
    #define debug(x) cerr << #x << ": " << x << endl
#else
    #define debug(x) 
#endif

using namespace std;

using LL = long long;

template<typename T>
ostream& operator << (ostream& out, const vector<T>& v) {
    out << "[";
    for(const auto& x : v) {
        out << x << ", ";
    }
    return out << "]";
}
template<typename T>
istream& operator >> (istream& in, vector<T>& v) {
    for(auto& x : v) {
        in >> x;
    }
    return in;
}

template<typename S, typename T>
ostream& operator << (ostream& out, const pair<S, T>& p) {
    return out << "{" << p.first << ", " << p.second << "}";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    string S;
    cin >> S;
    if(S[S.length() - 1] == 's') {
        cout << S << "es\n";
    } else {
        cout << S << "s\n";
    }
    
    return 0;
}


Measured memory_bytes: 3660
N = int(input())
X = [tuple(map(int,input().split())) for _ in range(N)]

par = [-1 for _ in range(N)]
def find(x):
        if par[x] < 0:
            return x
        else:
            par[x] = find(par[x]) #経路圧縮
            return par[x]
def same(x,y):
        return find(x) == find(y)
def unite(x,y):
        x = find(x)
        y = find(y)
        #print(x, y)
        if x == y:
            return 0
        else:
          if par[x] > par[y]:
            x,y = y,x
          par[x] += par[y]
          par[y] = x
def size(x):
        return -par[find(x)]
    


y_list = [0 for _ in range(N)]
for x, y in X:
  y_list[x-1] = y-1
#print(y_list)

tp = N
rest = N
for i in range(N):
  y = y_list[i]
  if y > tp:
    continue
  rest -= 1
  #print(i,rest)
  if i + rest < N-1: #残っている時
    unite(y, tp)
  #print(i, y, rest, tp, par)
  j = y + 1
  while j < tp:
    rest -= 1
    unite(y, j) 
    #print(y, j, par)
    j += 1
  tp = y
#print(par)  
for x, y in X:
  print(size(y-1))
  
  
    
  
  
  
  

Measured memory_bytes: 129960
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<math.h>
using namespace std;

int main()
{
	int a;
	cin >> a;
	for (int b = 0; b < a; b++) {
		int c, d, e;
		cin >> c >> d >> e;
		int MAX = c;
		for (int f = 0; f < e; f++) {
			double g, h, s;
			cin >> g >> h >> s;
			if (g) {
				double j = c;
				for (int i = 0; i < d; i++) {
					j *= (1 + h);
					j = (int)j;
					j -= s;
				}
				MAX = max(MAX,(int)floor(j));
			}
			else {
				double j = c, o = 0;
				for (int i = 0; i < d; i++) {
					o += floor(j*h);
					j -= s;
				}
				MAX = max(MAX,int(o+j));
			}
		}
		cout << MAX << endl;
	}
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MX 200005
vector<int> g[200010];
ll res[200010];
int col[MX];
ll sum[MX];
int sz[MX];

void dfs(int u, int fa)
{
    sz[u] = 1;
    ll presum = sum[col[u]];
    ll jud = 0;
    ll settl = 0;
    for (int i = 0; i < g[u].size(); i++)
    {
        int v = g[u][i];
        if (v == fa)
            continue;
        dfs(v, u);
        sz[u] += sz[v];
        jud = sz[v] - (sum[col[u]] - presum);
        res[col[u]] -= 1ll * jud * (jud - 1) / 2;
        presum = sum[col[u]];
        settl += jud;
    }
    sum[col[u]] += settl + 1;
}
int main(int argc, char const *argv[])
{
    int n;
    int kase = 1;
    while (~scanf("%d", &n))
    {
        ll cnt = 0;
        memset(sum, 0, sizeof(sum));
        cnt = n;
        for (int i = 1; i <= n; ++i)
        {
            scanf("%d", &col[i]);
            res[col[i]]++;
            res[i] += 1ll * n * (n - 1) / 2;
        }
        int u, v;
        for (int i = 1; i < n; ++i)
        {
            scanf("%d%d", &u, &v);
            g[u].push_back(v);
            g[v].push_back(u);
        }
        dfs(1, -1);
        for (int i = 1; i <= n; ++i)
        {
            ll jud = n - sum[i];
            res[i] -= 1ll * jud * (jud - 1) / 2;
            printf("%lld\n", res[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 38184
import numpy as np
n = int(input())
digit= int(np.log10(n)//1)
tmp = 0
if digit%2==0 and n>=10:
  tmp = n-10**digit+1
elif n<10:
  tmp = n
for i in range(1,digit+1,2):
    tmp += 9*10**(i-1)
print(tmp)

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    string s; cin >> s;
    int w[s.size()] = {};
    for(int i= s.size()-1; i >=0; i--){
        if(s[i]=='W'){
            if(i==s.size()-1) w[i] = 1;
            else w[i] = w[i+1] + 1;
        }else{
            if(i==s.size()-1) w[i] = 0;
            else w[i] = w[i+1];
        }
    }
    ll ans = 0;
    rep(i,0,s.size()){
        if(s[i] == 'B'){
            ans += w[i];
        }
    }
    cout << ans << "\n";
}

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

namespace ABC098A
{
    class Program
    {
        static void Main(string[] args)
        {
            int A, B, max;

            var word = Console.ReadLine().Split(' ');

            A = int.Parse(word[0]);
            B = int.Parse(word[1]);

            max = A + B;

            if (max < A - B) max = A - B;
            if (max < A * B) max = A * B;

            Console.WriteLine(max);

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
    using namespace std;
    int main()
    {
      int n;
      cin>>n;
      int arr[n];
      for(int i=0;i<n;i++)
      {
        cin>>arr[i];
      }
      vector<int>dp(n);
      dp[0]=0;
	  dp[1]=abs(arr[0]-arr[1]);
      for(int i=2;i<n;i++)
      {
        int op1=abs(arr[i]-arr[i-1])+dp[i-1];
        int op2=abs(arr[i]-arr[i-2])+dp[i-2];
        
        dp[i]=min(op1,op2);
      }
      cout<< dp[n-1]<<endl;
    }

Measured memory_bytes: 1024
def main():
    N, P = (int(i) for i in input().split())
    A = [int(i) % 2 for i in input().split()]
    from collections import Counter
    c = Counter(A)
    odd = 2**(c[1]-1) if c[1] > 0 else 0
    even = 2**c[0]
    if 0 < odd:
        even *= odd
    print(odd*2**c[0] if P == 1 else even)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
#define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0]))
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int INTINF = 2147483647;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int result = 0;
  rep(i, N) {
    int l, r; cin >> l >> r; 
    result += r-l+1;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
inf = float("inf")
N, Ma, Mb = map(int, input().split())
ABC = []
for _ in range(N):
    a, b, c = map(int, input().split())
    ABC.append((a, b, c))
dp = [[inf] * 420 for _ in range(420)]
dp[0][0] = 0
for a, b, c in ABC:
    for i in range(410, -1, -1):
        for j in range(410, -1, -1):
            if dp[i][j] < inf:
                dp[i+a][j+b] = min(dp[i+a][j+b], dp[i][j] + c)
ans = inf
n = 1
while max(Ma * n, Mb * n) < 420:
    ans = min(ans, dp[Ma * n][Mb * n])
    n += 1
print(ans if ans < inf else -1)


Measured memory_bytes: 47068
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 3e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 755;
const int MAXV = 1000000000;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;

int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d", &n);
    if (360 % n == 0) {
        printf("%d\n", 360 / n);
    } else {
        printf("%d\n", 360 / __gcd(360, n));
    }
    return 0;
}

Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
using namespace std;

string shuffle(string &str, int h)//?????????h?????????????????????????????£?????????
{
	string copy_str = str;
	
	for(int i = 0; i < h; i++){
		copy_str.push_back(str[i]);
	}
	
	for(int i = 0; i < str.size(); i++){
		str[i] = copy_str[i + h];
	}
	return str;
}
int main(void)
{
	while(true){
		
		string str;
		cin >> str;
		
		if(str == "-"){
			break;
		}
		
		int shuffle_num;
		cin >> shuffle_num;//?????£??????????????°
		
		for(int i = 0; i < shuffle_num; i++){
			int h;//?????????h???
			cin >> h;
			str = shuffle(str, h);
		}
		
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n;
    cin >> n;
    const int N = 1e6 + 10;
    vector<int> arr(n), cnt(N);
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        cnt[arr[i]]++;
    }
    sort(arr.begin(), arr.end());
    arr.resize(unique(arr.begin(), arr.end()) - arr.begin());
    int ans = 0;
    for(int i = 0; i < arr.size(); ++i){
        if(cnt[arr[i]] == 1){
            ans++;
        }
        for(int j = arr[i]; j < N; j += arr[i]){
            cnt[j] = 0;
        }
    }
    cout << ans << endl;

}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t;
    t  = 1;
    while(t--)
        solve();

}


Measured memory_bytes: 7988
#include <iostream>
#include <string>
using ll = long long;
using namespace std;

int main () {
	ll N;
	string A,B,C;
	cin >> N >> A >> B >> C;
	ll ans = 0;
	for (ll i=0; i<N; ++i) {
		char a = A[i];
		char b = B[i];
		char c = C[i];
		if (a == b && b == c) {
			continue;
		}
		if (a == b) {
			ans++;
			continue;
		}
		if (a == c) {
			ans++;
			continue;
		}
		if (b == c) {
			ans++;
			continue;
		}
		ans += 2;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())

dic = {"AC": 0, "WA": 0, "TLE": 0, "RE": 0}

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

print("AC x " + str(dic["AC"]))
print("WA x " + str(dic["WA"]))
print("TLE x " + str(dic["TLE"]))
print("RE x " + str(dic["RE"]))


Measured memory_bytes: 9064
#include <iostream>

using namespace std;

long long n;
long long ans1,ans2;

inline long long solve1(long long num, long long k)
{
	if (num>=k*5) return solve1(num,k*5)+num/k;
	else return num/k;
}

inline long long solve2(long long num, long long k)
{
	if (num>=k*5) return solve2(num,k*5)+(num/k+1)/2;
	else return (num/k+1)/2;
}

int main()
{
	cin >> n;
	if (n&1) cout << 0 << endl;
	else cout << solve1(n,5)-solve2(n,5);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, K, M, R;

	public static void main(String[] args) throws Exception {
		while (true) {
			N = sc.nextInt();
			K = sc.nextInt();
			M = sc.nextInt();
			R = sc.nextInt();
			if (N == 0) break;
			int[] ans = divide(1, N);
			if (M == 1) {
				for (int i = 1; i < N; ++i) {
					add(ans, divide(1, N * i));
				}
			}
			boolean carry = true;
			for (int i = R + 1; i < ans.length - 4; ++i) {
				if (ans[i] != 9) {
					carry = false;
					break;
				}
			}
			if (carry) {
				int[] add = new int[ans.length];
				add[R + 1] = 1;
				add(ans, add);
			}
			StringBuilder sb = new StringBuilder();
			sb.append((char) (ans[0] + '0'));
			sb.append('.');
			for (int i = 1; i <= R; ++i) {
				sb.append((char) (ans[i] + '0'));
			}
			System.out.println(sb);
		}
	}

	static int[] divide(int num, int den) {
		int[] ret = new int[R + 10];
		for (int i = 0; i < ret.length; ++i) {
			ret[i] = num / den;
			num %= den;
			num *= 10;
		}
		return ret;
	}

	static void add(int[] recipient, int[] donor) {
		int carry = 0;
		for (int i = donor.length - 1; i >= 0; --i) {
			recipient[i] += carry + donor[i];
			carry = recipient[i] / 10;
			recipient[i] %= 10;
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// 最大公倍数長が最適解の候補
// n/最大公約数, m/最大公約数毎に重なる文字が出現するので、
// そこでミスマッチが生じないかチェックする

long long lcm(long long a, long long b){ return a/__gcd(a, b)*b; }

int main(){
    Init();
    ll n, m; cin >> n >> m;
    string s, t; cin >> s >> t;
    ll num = lcm(n, m);
    bool chk = true;
    ll gcdn = __gcd(n, m);
    ll step_n = n/gcdn, step_m = m/gcdn;
    for(ll i=0; i<gcdn; i++) if(s[step_n*i] != t[step_m*i]) chk = false;
    cout << (chk ? num : -1) << endl; 
}

Measured memory_bytes: 3768