akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}void hSwap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}

void ShowData(int x[], int left, int right)
{
	int i;
	for (i = left; i <= right; i++)printf("%d  ", x[i]);
	printf("\n");
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		hSwap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

int main(){
	int n;
	scanf("%d", &n);
	PRINTD(n / 2 * ((n + 1) / 2));
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;
int main()
{
    int n; cin >> n;
    vector< int > v(n);
    for( auto &i : v ) cin >> i;
    sort( v.begin(), v.end() );
    int ans = 0;
    for( int i = 0; i < n; ++ i )
    {
        for( int j = i + 1; j < n; ++ j )
        {
            int L = v[i] + v[j];
            int l = j, r = n - 1;
            while( l < r )
            {
                int mid = ( l + r + 1 ) >> 1;
                if( v[mid] < L )
                    l = mid;
                else r = mid - 1;
            }
            ans += l - j;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: August 27 2019
 * 
 */

#include <bits/stdc++.h>

#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(i,x) for(auto i=0 ; i<(x); ++i)
#define ef else if
#define wh while
#define el else
#define ivv(x) int x; cin>>x
#define lv(x) bint x; cin>>x
#define sv(x) string x; cin>>x
#define cv(x) char x; cin>>x
#define fv(x) float x; cin>>x
#define dv(x) double x; cin>>x
#define endl '\n'
using namespace std;

auto SOLUTION_FUNCTION( void ) ->void {
    // your solution goes here 
    ivv(n);ivv(d);
    int i(0);
    int counter(0);
    while(i<n){
        i++;
        i+=d+d;
        counter++;
    }
    cout<<counter<<'\n';
    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("input","r",stdin);
    freopen("output","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}

Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re, \
array, bisect, sys, random, time, copy, functools, os, queue, pdb
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N, K = LI()
A = LI()

from fractions import Fraction
"""
2 1なら
2 1 2 1
点灯数は、左の数のほうが多いもの
2 1
2 1
2 1
の3種類
2回つなげてみたら決まる
2 1 2 1なら
K = 2で3
K=3 で 2 1 2 1 2 1で6
K=4 で2 1 2 1 2 1 2 1で10通り 4+3+2+1=
K=6なら 2 1 2 1 2 1 2 1 2 1 2 1で6+5+4+3+2+1 =

偶奇でわける
modで割る

1 2なら
1 2 1 2で1しかない1
1 2 1 2 1 2なら3で2 + 1
1 2 1 2 1 2 1 2 なら6で3+2+1
"""
if len(set(A)) == 1:
    print(0)
    exit()

"""
各数字ごとに数える
"""
K %= mod
in_count = 0
for i in range(N):
    for j in range(i, N):
        if A[i] > A[j]:
            #  print('i, j', i,j, A[i], A[j])
            in_count += 1
#  print(in_count)
in_count %= mod
in_ans = in_count * K
in_ans %= mod

out_count = 0
for i in range(N):
    for j in range(N):
        if A[i] > A[j]:
            out_count += 1
#  print(out_count)

out_count %= mod
#  out_ans = (out_count * K * (K-1))//2
#  out_ans = out_count * (((K * (K-1))%mod)/2) % mod
out_ans = int(Fraction(out_count) * Fraction(K) * Fraction(K-1) / Fraction(2))
out_ans %= mod
#  print(in_ans, out_ans)
print(int((in_ans + out_ans)%mod))


Measured memory_bytes: 7756
s = str(input())

#first 0
#second 1

state = 0

def remove(s):
    if len(s) == 2:
        return s
    else:
        for i in range(1,len(s)-1):
            if s[i-1] != s[i+1]:
                s_new = s[:i]+s[i+1:]
                break
        else:
            s_new = s
        return s_new

while True:
    #print(s,remove(s))
    state = (state+1)%2
    if s == remove(s):
        break
    else:
        s = remove(s)

if state ==0:
    print("First")
else:
    print("Second")




Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		ArrayList<Integer> h = new ArrayList<Integer>();
		ArrayList<Integer> w = new ArrayList<Integer>();
		ArrayList<String> strArray = new ArrayList<String>();
		String data;
		int count = 0;
		while(true) {
			strArray.add(br.readLine());
			data = strArray.get(strArray.size() - 1);
			if(data.equals("0 0")) {
				break;
			}
			count++;
		}
		
		for(int i = 0; i < strArray.size(); i++) {
			String s = strArray.get(i);
			String [] ary = s.split(" ", 0);
			h.add(Integer.parseInt(ary[0]));
			w.add(Integer.parseInt(ary[1]));
		}
		
		for(int k = 0; k < count; k++) {
			for(int i = 0; i < h.get(k); i++) {
				for(int j = 0; j < w.get(k); j++) {
					if(i >= 1 && i < h.get(k) - 1 && j >= 1 && j < w.get(k) - 1){
						System.out.print('.');
					}else {
						System.out.print('#');
					}
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 36692
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n); for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
typedef pair<int, int> P;
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i <=n;i++){
    num*=yakusu[i];
  }
  return num;
}


//cout<<""<<endl;
int main(){
  int H,W;cin>>H>>W;
  vvi c(10,vector<int> (10));
  rep(i,10){
    rep(j,10){
      cin>>c[i][j];
    }
  }
  vvi A(H,vector<int>(W));
  rep(i,H){
   rep(j,W){
     cin>>A[i][j];
   }
  }
  vvi G(10,vector<int>(10,1000000));
  rep(i,10){
    G[i][i]=0;
  }
  rep(i,10){
    rep(j,10){
      G[i][j]=min(G[i][j],c[i][j]); 
    }
  }
  rep(k,10){
    rep(i,10){
      rep(j,10){
        G[i][j]=min(G[i][j],G[i][k]+G[k][j]);
      }
    }
  }
  int ans=0;
  rep(i,H){
    rep(j,W){
      if(A[i][j] !=-1){
        ans += G[A[i][j]][1];
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
n, k = map(int, input().split())
MOD = 10 ** 9 + 7

inv = [0] * 2000
inv[1] = 1
for i in range(2, 2000):
    inv[i] = (MOD - (MOD // i) * inv[MOD % i] % MOD) % MOD

fact = [0] * 2000
finv = [0] * 2000
fact[0] = 1
finv[0] = 1
for i in range(1, 2000):
    fact[i] = (i * fact[i - 1]) % MOD
    finv[i] = (inv[i] * finv[i - 1]) % MOD


def modcomb(n, r):
    if n < r or r < 0:
        return 0
    return fact[n] * finv[r] % MOD * finv[n - r] % MOD


for i in range(k):
    x = modcomb(n - k + 1, i + 1)
    y = modcomb(k - 1, i)
    print(x * y % MOD)

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

#define ll long long int
using namespace std;
int main()
{
    int n,t,a,p;
    double x,b,c,m=1e9;
    cin>>n>>t>>a;
    for(int i=0;i<n;i++)
    {
        cin>>c;
        c = c*.006;
        b = t-c;
       // cout<<"b = "<<b<<endl;
        x = abs(a-b);
       //cout<<"abs = "<<x<<endl;
        if(x<m)
        {
            m = x;
            p= i+1;
        }
    }
    cout<<p<<endl;

    return 0;
}


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

int main(){
    int N;
    const int INF = 1e9;
    while(cin >> N, N){
        vector<vector<int>> Graph(10,vector<int>(10,INF));

        for(int i=0;i<N;i++){
            int a,b,c;
            cin >> a >> b >> c;
            Graph[a][b] = c;
            Graph[b][a] = c;
        }

        for(int mid = 0; mid < 10; mid++){
            for(int from = 0; from < 10; from++){
                for(int to = 0; to < 10; to++){
                    if(Graph[from][mid] == INF || Graph[mid][to] == INF) continue;
                    Graph[from][to] = min(Graph[from][to], Graph[from][mid] + Graph[mid][to]);
                }
            }
        }

        int V = -1;
        int minCost = INF;

        for(int i=0;i<10;i++){
            int cost = 0;
            for(int j = 0;j<10;j++){
                if(i == j) continue;
                if(Graph[i][j] == INF) continue;
                cost += Graph[i][j];
            }
            if(minCost > cost && cost != 0){
                minCost = cost;
                V = i;
            }
        }
        cout << V << " " << minCost << endl;
    }
}


Measured memory_bytes: 3052
import java.io.*;
import java.util.*;
import java.math.*;

 
 public class Main	{
   static class Pair implements Comparable<Pair>{
   int a;
   int b;
   public Pair(int x,int y){a=x;b=y;}
   public Pair(){}
   public int compareTo(Pair p1){
      return a+b-p1.a-p1.b;
   }
 }
static class TrieNode{
  TrieNode[]child;
  int w;
  boolean term;
  TrieNode(){
    child = new TrieNode[26];  
  }
}
  public static int gcd(int a,int b)
  {
    if(a<b)

      return gcd(b,a);
    if(b==0)
      return a;
    return gcd(b,a%b);
    
  }
  //static long ans = 0;
  static long mod = 998244353;//(long)(1e9+7);
   
    public static void main(String[] args) throws Exception {
       new Thread(null, null, "Anshum Gupta", 99999999) {
            public void run() {
                try {
                    solve();
                } catch(Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        }.start();
    }

static long pow(long x,long y){
    if(y == 0)return 1;
    if(y==1)return x;
    long a = pow(x,y/2);
    a = (a*a)%mod;
    if(y%2==0){
        return a;
    }
    return (a*x)%mod;
}

static long mxx;
static int mxN = (int)(1e5+5);
 public static void solve() throws Exception {
   // solve the problem here
   MyScanner s = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out), true);
        int t = 1;//s.nextInt();
        mxx = (long)(1e18+5);
 
        while(t-->0){
        	int n = s.nextInt();
        	int m = s.nextInt();
        	int[]a=new int[m];
        	int sum = 0;
        	for(int i=0;i<m;i++) {
        		a[i] = s.nextInt();
        		sum += a[i];
        	}
        	n -= sum;
        	sum = n;
        	out.println(sum>=0?sum:-1);
        	
        }
           
        out.flush();
}
 
     
 
 
 
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
 
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
 
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt() { return Integer.parseInt(next()); }
        long nextLong() { return Long.parseLong(next()); }
        double nextDouble() { return Double.parseDouble(next()); }
         
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}


Measured memory_bytes: 34412
#include<bits/stdc++.h>
using namespace std;
#define f(n) for(int i=0; i<n; i++)
#define endl '\n'
#define ll long long

int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    string s;
    cin >> s;

    cout << ( s[2] == s[3] && s[4] == s[5] ? "Yes" : "No");

    return 0;
}




Measured memory_bytes: 3596
import collections
n,m = map(int,input().split())
a = list(map(int,input().split()))
col = collections.Counter(a)

for i in range(m):
  b,c = map(int,input().split())
  col[c] += b
col = sorted(col.items(), key=lambda x:x[0],reverse=True)

ans=0
for k,v in col:
  if n <= v:
    ans += k*n
    break
  else:
    ans += k*v
    n -= v
print(ans)


Measured memory_bytes: 46976
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define lli long long int
#define all(x) x.begin(),x.end()
#define siz(x) x.size()
#define prs(x,y) x.find(y)!=x.end()
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
inline int level(int n){int ans=0;while(n%2==0){n/=2;ans++;}return ans;}
int main()
{

	double r;
	cin>>r;
	cout<<2.0*M_PI*r;
}



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

using namespace std;
#define all(a)a.begin(),a.end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod = int(1e9)+7;
using V = vector<int>;
using P = pair<int,int>;

int main()
{
    ll  a,b,n;cin >>a>>b>>n;
    //rep(i,50){
    //cout <<a*i/b-a*(i/b)<< endl;
    //}
    ll k=min(b-1,n);
    cout <<a*k/b-a*(k/b)<< endl;
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var res = new int[num];
        for(var i = 0; i < num; i++)
        {
            var str1 = ReadLine();
            var str2 = ReadLine();
            var memo = new int[str1.Length, str2.Length];
            for (var j = 0; j < str1.Length; j++)
                for (var h = 0;h<str2.Length; h++)
                    memo[j, h] = -1;
            dp(str1, str2, str1.Length - 1, str2.Length - 1, memo);
            res[i] = memo[str1.Length - 1, str2.Length - 1];
        }
        WriteLine(string.Join("\n", res));
    }
    private static int dp(string str1,string str2,int m1,int m2,int[,] memo)
    {
        if (m1 < 0 || m2 < 0) return 0;
        if (memo[m1, m2] != -1) return memo[m1, m2];
        if (str1[m1] == str2[m2]) return memo[m1, m2] = dp(str1, str2, m1 - 1, m2 - 1, memo) + 1;
        else return memo[m1, m2] = Max(dp(str1, str2, m1 - 1, m2, memo), dp(str1, str2, m1, m2 - 1, memo));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  
static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}



Measured memory_bytes: 39040
using System;
class B_Uneven{
	static void Main(string[] args){
		double N = double.Parse(Console.ReadLine());
		int Score = 0;
		if(Math.Floor(N / 10) > 0){
			Score += 9;
			if(Math.Floor(N / 1000) > 0){
				Score += 900;
				if(N >= 10000)Score += ((int)Math.Floor(N) - 9999);
				if(N >= 100000)Score --;
			}else if(N >= 100)Score += ((int)Math.Floor(N) - 99);
		} else Score += (int)Math.Floor(N);
		Console.WriteLine(Score);
	}
}


Measured memory_bytes: 13140
n,k = list(map(int, input().split()))
a = list(map(int, input().split()))
a.insert(0,0)
start = 1
now = start
c = 0
flag = [-1]*(n+1)
while c < k and flag[now] == -1:
    #print(now)
    flag[now] = c
    c+= 1
    now = a[now]
#print(c, now)
if c == k:
    print(now)
else:
    k-=c
    cc = c-flag[now]
    nokori = k % cc
    for i in range(nokori):
        now = a[now]
    print(now)


Measured memory_bytes: 32224
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
const int M = 1e5 + 10;
const int INF = 0x3f3f3f3f;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define endl '\n'
#define ls (i << 1)
#define rs (i << 1 | 1)
#define loop(i, a, b) for (int i = a; i < b; ++i)

inline int read() {
    char ch = getchar();
    int w = 1, c = 0;
    for (; !isdigit(ch); ch = getchar())
        if (ch == '-') w = -1;
    for (; isdigit(ch); ch = getchar()) c = (c << 3) + (c << 1) + (ch ^ 48);
    return w * c;
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(b * d, b * c), max(a * d, a * c)) << endl;
    return 0;
}

Measured memory_bytes: 3192
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, M; cin >> N >> M;
    int AC = 0, PN = 0;
    vector<pair<int, string>> P(M);
    vector<int> V(N, 0);
    vector<bool> AC_flag(N, false);
    vector<bool> flag(N, false);
    for (int i = 0; i < M; ++i) {
        int a;
        string s;
        cin >> a >> s;
        cin.clear();
        cin.ignore(1024, '\n');
        if (s == "AC") AC_flag[a - 1] = true;
        P[i].first = a;
        P[i].second = s;
    }
    for (int i = 0; i < M; ++i) {
        if (flag[P[i].first - 1] == false && AC_flag[P[i].first - 1] == true) {
            if (P[i].second == "WA") PN++;
            else if (P[i].second == "AC") {
                AC++;
                flag[P[i].first - 1] = true;
            }
        }
    }
    cout << AC << " " << PN << endl;
}

Measured memory_bytes: 6912
package main
import (
  "fmt"
  "sort"
)

func main() {
	var n, d, ind int
  	a := make([]int, 0)
  	fmt.Scan(&n)
  for i := 0; i < n; i++ {
    fmt.Scan(&d)
   		a = append(a, d)
  	}
  b := make([]int, 0)
  for _, v := range a {
    b = append(b, v)
  }
  sort.Sort(sort.IntSlice(b))
  size := len(b)
  max := b[size-1]
  big := b[size-2]
  for i, v := range a {
    if ind == 0 {
      switch {
    	case v == max :
      		ind = i
      }
    }
  }
  switch {
    case max == big:
    for i := 0; i < n; i++{
      fmt.Println(max)
    }
    case max != big:
    for i := 0; i < n; i++{
        if i == ind {
          fmt.Println(big)
        }else{
          fmt.Println(max)
        }
      }
    }
}

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

int main()
{
	int N, u, v;
	scanf("%d%d%d", &N, &u, &v);
	u--; v--;
	using vi = std::vector<int>;
	using vvi = std::vector<vi>;
	vvi edges(N);
	for (int i{}; i < N - 1; i++)
	{
		int A, B;
		scanf("%d%d", &A, &B);
		A--; B--;
		edges[A].push_back(B);
		edges[B].push_back(A);
	}
	vi taka(N, 1 << 30), aoki(N, 1 << 30);
	taka[u] = aoki[v] = 0;
	std::queue<int> bfs;
	bfs.push(u);
	while (!bfs.empty())
	{
		auto now{bfs.front()};
		bfs.pop();
		for (auto& e: edges[now])
		{
			if (taka[e] != (1 << 30)) continue;
			taka[e] = taka[now] + 1;
			bfs.push(e);
		}
	}
	bfs.push(v);
	while (!bfs.empty())
	{
		auto now{bfs.front()};
		bfs.pop();
		for (auto& e: edges[now])
		{
			if (aoki[e] != (1 << 30)) continue;
			aoki[e] = aoki[now] + 1;
			bfs.push(e);
		}
	}
	int dist{aoki[u]};
	int ans{1 - dist % 2};
	if (dist % 2 == 1)
	{
		for (int i{}; i < N; i++)
		{
			if (i != u && (aoki[i] <= taka[i] || aoki[i] + taka[i] == dist)) continue;
			if (aoki[i] - taka[i] == dist)
				ans = std::max(ans, dist / 2 * 2 + taka[i]);
			else
			{
				int corner{(dist - (aoki[i] - taka[i])) / 2};
				ans = std::max(ans, dist / 2 * 2 + taka[i] - corner * 2);
			}
		}
	}
	else
	{
		for (int i{}; i < N; i++)
		{
			if (i != u && (aoki[i] <= taka[i] || aoki[i] + taka[i] == dist)) continue;
			if (aoki[i] - taka[i] == dist)
				ans = std::max(ans, (dist / 2 - 1) * 2 + taka[i] + 1);
			else
			{
				int corner{(dist - (aoki[i] - taka[i])) / 2};
				ans = std::max(ans, (dist / 2 - 1) * 2 + taka[i] + 1 - corner * 2);
			}
		}
	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 6656
from collections import Counter


a = input()

wlist = []

for i in a:
    wlist.append(i)

S=Counter(wlist)
if len(S.keys()) == 2:
    if S.most_common()[0][1] == 2:
        print("Yes")
    else:
        print("No")
        exit()
else:
    print("No")
    exit()



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

using ll=long long;
const ll MOD=1e9+7;
int main(){
    int n,m;
    cin>>n>>m;
    string buf;
    cin>>buf;
    vector<int> s(n);
    for(int i=0;i<n;i++) s[i]=buf[i]-'0';
    vector<pair<int,int>> lr(m);
    for(int i=0;i<m;i++){
        cin>>lr[i].first>>lr[i].second;
        lr[i].first--;
    }
    sort(lr.begin(),lr.end(),[](pair<int,int> lhs,pair<int,int> rhs){
        return lhs.first==rhs.first ? lhs.second>rhs.second : lhs.first<rhs.first;
    });
    vector<int> l;
    vector<int> r;
    int mr=0;
    for(int i=0;i<m;i++){
        if(mr<lr[i].second){
            while(mr<lr[i].first){
                l.push_back(mr);
                r.push_back(mr+1);
                mr++;
            }
            l.push_back(lr[i].first);
            r.push_back(lr[i].second);
            mr=r.back();
        }
    }
    for(int i=r.back();i<n;i++){
        l.push_back(i);
        r.push_back(i+1);
    }
    m=l.size();

    vector<int> sum(n);
    partial_sum(s.begin(),s.end(),sum.begin()+1);
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));
    dp[0][0]=1;
    int rig=0;
    int idx=0;
    for(int i=0;i<n;i++){
        int p=0;
        if(idx<m && l[idx]==i){
            p=sum[r[idx]]-sum[rig];
            rig=r[idx];
            idx++;
        }
        // cerr<<"$"<<i<<" "<<p<<" "<<rig<<endl;
        for(int j=0;j<=n;j++){
            // cerr<<"#"<<i<<" "<<j<<" "<<dp[i][j]<<endl;
            if(j+p-1>=0) (dp[i+1][j+p-1]+=dp[i][j])%=MOD;
            if(rig-i>j+p) (dp[i+1][j+p]+=dp[i][j])%=MOD;
        }
    }
    cout<<dp[n][0]<<endl;
    return 0;
}

Measured memory_bytes: 70784
#include <bitset>
#include <deque>
#include <cassert>
#include <cstring>
#include <vector>
#include <iostream>
using namespace std;

long long check(vector<int> &a) {
    long long ans = 0;
    const int n = a.size();
    for (int x = 1; x < n; x++) {
        long long dp[x][n-x];
        memset(dp, 0, sizeof dp);
        dp[0][0] = int(a[0] == a[x]);
        for (int i = 1; i < x; i++)
            dp[i][0] = dp[i-1][0] + int(a[i] == a[x]);
        for (int j = 1; j + x < n; j++) {
            for (int i = 0; i < x; i++) {
                dp[i][j] = dp[i][j-1];
                if (i > 0) {
                    dp[i][j] += dp[i-1][j] - dp[i-1][j-1];
                    if (a[i] == a[j+x]) dp[i][j] += dp[i-1][j-1];
                }
            }
        }
        ans += dp[x-1][n-x-1];
    }
    return ans;
}

int solve(long long n, deque<int> &s, deque<int> &t, int a) {
    if (n > 1) {
        if (n % 2 == 1) {
            a = solve(n / 2, s, t, a);
            s.push_back(a);
            t.push_back(a);
            return a + 1;
        } else {
            a = solve(n - 1, s, t, a);
            s.push_front(a);
            t.push_back(a);
            return a + 1;
        }
    } else {
        s.push_back(a);
        t.push_back(a);
        return a + 1;
    }
}

int main() {
    long long n; cin >> n;
    deque<int> s, t;
    solve(n, s, t, 1);
    vector<int> ans;
    ans.insert(ans.end(), s.begin(), s.end());
    ans.insert(ans.end(), t.begin(), t.end());
    // assert (n == check(ans));
    cout << ans.size() << endl;
    for (int x : ans) cout << x << " ";
    cout << endl;
}


Measured memory_bytes: 3124
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    d, t, s = MI()
    if d/s <= t:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
N, M = map(int, input().split())
As = list(map(int, input().split()))
BCs = [tuple(map(int, input().split())) for _ in range(M)]

As.sort()
BCs.sort(key=lambda x: x[1], reverse=True)

iA = 0
for B, C in BCs:
    for j in range(B):
        if As[iA] < C:
            As[iA] = C
            iA += 1
            if iA >= N:
                break
        else:
            break
    else:
        continue
    break

print(sum(As))


Measured memory_bytes: 22116
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

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


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;

#define int long long

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

    int x = min(b-1,n);
    int zz = (a*x)/b - a * (x/b);
    cout <<zz << endl;


}






Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
    ll n, a, b;
    cin >> n  >> a >> b;
    if((b-a-1)%2 == 1) cout << (b-a) / 2 << endl;
    else cout << min(a-1, n-b) + 1 + (b-a-1) / 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/














int N, S, T;
int A[303], B[303];
//---------------------------------------------------------------------------------------------------
map<pair<int, int>, int> memo;
int ask(int u, int v) {
	if (u == v) return 0;
	if (u > v) swap(u, v);

	if (memo.count({ u, v })) return memo[{u, v}];

	printf("? %d %d\n", u, v);
	fflush(stdout);

	int res; cin >> res;

	return memo[{u, v}] = res;
}
void answer(vector<int> v) {
	printf("!");
	fore(x, v) printf(" %d", x);
	printf("\n");
	fflush(stdout);
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> S >> T;

	rep(i, 1, N + 1) A[i] = ask(S, i);
	rep(i, 1, N + 1) B[i] = ask(T, i);

	vector<pair<int, int>> v;
	rep(i, 1, N + 1) if (A[T] == A[i] + B[i]) v.push_back({ A[i], i });
	sort(all(v));

	vector<int> ans;
	fore(p, v) {
		if (ans.size() == 0) ans.push_back(p.second);
		else {
			int pre = ans.back();
			if (A[T] == A[pre] + ask(pre, p.second) + B[p.second]) {
				ans.push_back(p.second);
			}
		}
	}
	answer(ans);
}





Measured memory_bytes: 4652
import sys

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


def main():
    x1, y1, x2, y2 = map(int, readline().split())
    p = x2 - x1
    q = y2 - y1

    x3 = x2 - q
    y3 = y2 + p
    x4 = x1 - q
    y4 = y1 + p

    print(x3, y3, x4, y4)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61936
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
using psi = pair<string, int>;
// functions

#endif


int main_C() {
    cin.tie(0);
    ios::sync_with_stdio(false);
        
    ll N, K; cin >> N >> K;
    vi A(N), B(N); REP(i, N) cin >> A[i] >> B[i];

    map<int, ll> mp;
    REP(i,N) {
        mp[A[i]] += B[i];
    }

    ll k = 0;
    int ans = 0;
    for(auto p : mp) {
        k += p.second;
        if (k >= K) {
            ans = p.first;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>

#define N (8000)
#define CtoI(c) (N + c)

void calc(int* array, int count) {
    int index;
    for (index = 0; index < 2 * N + 1; index++) {
        if (array[index] % 2 == 1) {
            array[index - count] += 2;
            array[index + count] += 2;
        }
    }
    for (index = 0; index < 2 * N + 1; index++) {
        if (array[index] > 1) {
            array[index] = 1;
        } else {
            array[index] = 0;
        }
    }
}
int main()
{
    char s[N + 1];
    scanf("%s", s);
    int x, y;
    scanf("%d %d", &x, &y);

    int x_set[2*N+1];
    int y_set[2*N+1];
    int tmp;
    for (tmp = 0; tmp < 2*N+1; tmp++) {
        x_set[tmp] = y_set[tmp] = 0;
    }
    x_set[CtoI(0)] = 1;
    y_set[CtoI(0)] = 1;

    int current, t_count, f_count;
    for (current = t_count = f_count = 0; 1 == 1; current++) {
        if (s[current] == 'F') {
            f_count++;
            continue;
        }
        if (f_count > 0) {
            if (t_count == 0) {
                x_set[CtoI(0)] = 0;
                x_set[CtoI(f_count)] = 1;
            } else {
                if (t_count % 2 == 0) {
                    calc(x_set, f_count);
                } else {
                    calc(y_set, f_count);
                }
            }
            f_count = 0;
        }
        if (s[current] == 'T') {
            t_count++;
        }
        if (s[current] == '\0') {
            break;
        }
    }
    if (x_set[CtoI(x)] == 1 && y_set[CtoI(y)] == 1) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

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

#define M 200010

#define mem(a, b) memset(a, b, sizeof(a))
#define F(literate_val, max, step) for (literate_val = 0; literate_val < max; literate_val += step)

typedef long long LL;
typedef unsigned long long ULL;

//std::unordered_map<LL, LL> _NAME_MAP;
LL Array[M];
struct robot
{
    //LL pos;
    //LL range;
    LL left;
    LL right;
    bool operator<(const robot &b) const
    {
        return right < b.right || (right == b.right && left < b.left);
    }
} R[M];
inline LL qr()
{
    register char c = getchar();
    if (c == EOF)
        return -1;
    register LL n = 0;
    while (c > '9' || c < '0')
    {
        c = getchar();
    }

    while (c <= '9' && c >= '0')
    {
        n = (n << 3) + (n << 1) + c - 48;
        c = getchar();
    }

    return n;
}
inline char qrc()
{
    register char c = getchar();
    while (c < 'A' && c > 'Z')
        c = getchar();
    return c;
}

int main()
{

    LL n, m;
    n = qr();

    for (auto i = 0; i < n; i++)
    {
        LL pos = qr();
        LL ran = qr();
        R[i].left = pos - ran;
        R[i].right = pos + ran;
    }
    std::sort(R, R + n);
    LL ans = 1;
    LL cur = R[0].right;
    for (auto i = 1; i < n; i++)
    {
        if (R[i].left >= cur)
        {
            cur = R[i].right;
            ans++;
        }
    }
    std::cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
struct p {
    ll x, y, c;
    p(ll x = 0, ll y = 0, ll c = 0) : x(x), y(y), c(c) {}
};

struct UnionFind {
private:
    vector<ll> par;
    vector<ll> count;
    vector<ll> rank;
public:
    UnionFind(int N) {
        count.assign(N, 1);
        rank.assign(N, 0);
        par.assign(N, 0);
        rep(i, N) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x)
            return x;
        else {
            par[x] = root(par[x]);
            return par[x];
        }
    }

    void unite(int x, int y) {
        x = root(x), y = root(y);
        if (x == y) return;
        if (rank[x] < rank[y])
            swap(x, y);
        else if (rank[x] == rank[y])
            rank[y]++;
        par[y] = x;
        count[x] += count[y];
        return;
    }

    int size(int x) {
        return count[root(x)];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }
};
using UF = struct UnionFind;

int main() {
    init();
    ll N;
    cin>>N;
    vc<p> A(N);
    vl cx(N), cy(N);
    rep(i, N) cin >> A[i].x >> A[i].y, cx[i] = A[i].x, cy[i] = A[i].y;

    sort(all(cx)), sort(all(cy));
    cx.erase(unique(all(cx)), cx.end()), cy.erase(unique(all(cy)), cy.end());
    rep(i, N) A[i].x = lower_bound(all(cx), A[i].x) - cx.begin(), A[i].y = lower_bound(all(cy), A[i].y) - cy.begin();

    ll xsize = cx.size(), M = 0;
    rep(i, N) A[i].y += xsize, chmax(M, A[i].y + 1);

    UF uf(M);
    rep(i, N) uf.unite(A[i].x, A[i].y);

    vc<p> C(M, p(0, 0, 0));

    rep(i, M) {
        ll par = uf.root(i);
        i < xsize ? C[par].x++ : C[par].y++;
    }


    rep(i, N) {
        ll par = uf.root(A[i].x);
        C[par].c++;
    }

    ll ans = 0;
    rep(i, M) {
        ans += C[i].x * C[i].y - C[i].c;
    }

    cout << ans << endl;
}

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

using namespace std;

void solve() {
  int k, x;
  cin >> k >> x;
  cout << (500 * k >= x ? "Yes" : "No") << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(), (a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(), (a).end())
map<int,int64_t> p;
//(O(n))
void fl(int64_t n){
    if(n==1){
        return ;
    }
    int tmp = n;
    while(tmp%2==0 ){
        tmp /= 2;
        p[2]++;
    }
    for(int i=3;i<=tmp;i++){
        while(tmp % i ==0){
            tmp /= i;
            p[i]++;
        }
    }
}
int main(){
    int64_t n;
    cin>>n;
    //(O(n));
    for(int i=1;i<=n;i++){
        fl(i);
    }
    int64_t ans = 1;
    for(auto c:p){
        int g = c.first;
        int64_t sh = c.second;
        if(g!=1){
            ans = ans*(sh+1)%big; 
        }
        //cout<<g<<"^"<<sh<<endl;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
sys.setrecursionlimit(10**6)

n,m = na()
k = m//n
ans = 0
for i in range(1,k+1)[::-1]:
    if m%i == 0:
        ans = i
        break

print(ans)


Measured memory_bytes: 40044
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main(){
    fast;
    long double l;
    cin>>l;
    
    long double ans = (l/3)*(l/3)*(l/3);
    
    cout<<fixed<<setprecision(6)<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int n, k;
  cin >> n >> k;
  vector<ll> h(n);
  for (auto &x: h) cin >> x;

  h.push_back(0);

  vector<vector<ll> > dp(n+2, vector<ll>(k+1, (ll) 9e18));
  for (int j = k; j >= 0; j--) dp[0][j] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = k; j >= 0; j--) {
      if (i == 0) dp[i+1][j] = h[i];
      else dp[i+1][j] = min(dp[i+1][j], dp[i][j] + max(0LL, h[i] - h[i-1]));

      for (int l = 1; l <= j; l++) {
        if (i+l+1 > n+1) break;

        if (i == 0) dp[i+l+1][j-l] = h[i+l];
        else dp[i+l+1][j-l] = min(dp[i+l+1][j-l], dp[i][j] + max(0LL, h[i+l] - h[i-1]));

        if (i+l+1 == n+1) {
          dp[n][j-l] = min(dp[n][j-l], dp[n+1][j-l]);
        }
      }
    }
  }

  ll ans = (ll) 9e18;
  for (int j = k; j >= 0; j--) ans = min(ans, dp[n][j]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3880
#include<iostream>
#include<cstring>

using namespace std;

const int MAX = 101;
char data[MAX][MAX];
int n;
int dx[4] = {0,1,0,-1};
int dy[4] = {-1,0,1,0};
 
void print(){
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++)
      cout << data[i][j];
    cout << endl;
  }
}

bool movable(int d, int x, int y){
  return data[y+dy[d]][x+dx[d]] == ' ';
}

void solve(){

  int x = 2,y = n-1;
  int d = 0;

  for(int i = 0; i < n; i++)
    data[0][i] = data[n-1][i] = data[i][0] = data[i][n-1] = '#';

  data[n-1][1] = ' ';

  if(n == 4) return;

  while(1){
    int num = 0;

    while(1){
      x += dx[d];
      y += dy[d];
      if(movable(d,x,y)){
	num++;
	data[y][x] = '#';
      }else{
	x -= dx[d];
	y -= dy[d];
	break;
      }
    }
    if(num < 2) break;
    d++;
    d%=4;
  }
}

void init(){
  memset(data,' ',sizeof(data));
}

int main(){

  bool line = false;
  int x;
  cin >> x;
  
  while(x--){
    if(line) cout << endl;
    line = true;
    init();
    cin >> n;
    solve();
    print();
  }
  return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

int r, p, s;

int opnum(char x) {
    if (x == 's') {
        return (r);
    }
    if (x == 'r') {
        return (p);
    }
    if (x == 'p') {
        return (s);
    }
    return 0;
}
char op(char x) {
    if (x == 's') {
        return ('r');
    }
    if (x == 'r') {
        return ('p');
    }
    if (x == 'p') {
        return ('s');
    }
    return 0;
}

int main() {
    long a, b, n, k, ans = 0;
    cin >> n >> k >> r >> s >> p;
    string t, save(n, '.');
    cin >> t;
    for (int i = 0; i < t.size(); i++) {
        if (i < k) {
            ans += opnum(t[i]);
            save[i] = op(t[i]);
        } else if (save[i - k] == op(t[i])) {
            if (i + k < t.size()) {
                save[i] = op(op(t[i + k]));
            }
        } else {
            ans += opnum(t[i]);
            save[i] = op(t[i]);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
int main(void){
    int n,min,max;
    int64_t sum;
    sum=0;
    int a[10010];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a,a+n);
    min=a[0];
    max=a[n-1];
    for(int i=0;i<n;i++){
        sum=sum+a[i];
    }
    cout << min << " " << max << " " << sum << endl;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;  
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define Rep(i, a, b) for(ll i = a; i <= b; i++)
#define repr(i, a, b) for(ll i = b-1; i >= a; i--)
// #define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
// #define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
// const ll INF = 1LL << 60;
const ll INF = 100000000000;
#define pp pair<ll, pair<ll, ll>> 
// #define fi first
// #define se second
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
 
/*--------------------------------------------------------------------------------
 
--------------------------------------------------------------------------------*/


int main() {
    ll n; cin >> n;
    Vl a(n);
    rep(i, 0, n) cin >> a[i];
    ll now = 0;
    ll ans = 0;
    repr(i, 0, n){
        // -1
        if(i > 0 && a[i-1]+1 < a[i]){
            co(-1);
            return 0;
        }
        if(a[i] > i){
            co(-1);
            return 0;
        }
        //
        if(now < a[i]){
            ans += a[i];
            now = a[i];
        }
        // cout << i << " : " << now << endl;
        if(now) now--;
    }
    co(ans);

    return 0;
}

Measured memory_bytes: 4852