akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
    char S[100000];
    int i = 0, read;
    int tile_color[100000];
    for(i = 0; i < 100000; i ++){
        S[i] = 0;
        tile_color[i] = 123;
    }
    read = scanf("%s", S);
    for(i = 0; i < 100000; i ++){
        if(S[i] == 48){
            tile_color[i] = 0;
        }else if(S[i] == 49){
            tile_color[i] = 1;
        }
    }
    int dummy1 = 0, dummy2 = 0;
    int ref = 0;
    //0 -> 1 -> 0 -> ...
    ref = 0;
    i = 0;
    while(tile_color[i] < 2)
    {
        if(abs(tile_color[i] - ref) > 0.5)
        {
            dummy1 ++;
        }
        if(ref == 0)
        {
            ref = 1;    
        }else{
            ref = 0;
        }
        i ++;
    }
    //1 -> 0 -> 1 -> ...
    ref = 1;
    i = 0;
    while(tile_color[i] < 2)
    {
        if(abs(tile_color[i] - ref) > 0.5)
        {
            dummy2 ++;
        }
        if(ref == 0)
        {
            ref = 1;    
        }else{
            ref = 0;
        }
        i ++;
    }
    //Output
    if(dummy1 >= dummy2){
        printf("%d", dummy2);
    }else{
        printf("%d", dummy1);
    }
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
void solve1();
void solve()
{
    int t;cin>>t;
    while(t--)
    {
        solve1();
    }
}
int main()
{
    solve1();
    return 0;
}
void solve1()
{
    int n,m;
    cin>>n>>m;
    cout<<n*m<<endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

#define erep(i, x, n) for (auto i = x; i<=(ll)(n); i++)
#define rep(i, x, n) for(auto i = x; i<(ll)(n); i++)
#define all(v) ((v).begin()), ((v).end())
#define sz(v) ((int)((v).size()))
#define mod(n, m) ((n%m + m) % m)
#define reset(n, m) memset(n, m, sizeof n)
#define endl '\n'

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

	int n, k;
	cin >> n >> k;
	vi vec(n);
	int idx = -1;
	rep(i, 0, n)
	{
		cin >> vec[i];
		if (vec[i] == 1)
			idx = i;
	}

	int l = max(0, idx - k + 1), r = idx;
	while (r - l + 1 != k && r < n)
		r++;
	int mn = 1e9;
	while (l < n)
	{
		int before = l, after = n - r - 1;
//		cout << l << " " << r << endl;
//		cout << "--> " << before << " " << after << endl;
		int x = (before + k - 1 - 1) / (k - 1);
		int y = (after + k - 1 - 1) / (k - 1);
//		cout << "x, y: " << x << " " << y << endl << endl;
		mn = min(mn, x + y);
		if (vec[l] == 1)
			break;
		l++;
		r++;
		r = min(r, n - 1);
	}
	cout << mn + 1 << endl;

	return 0;
}



Measured memory_bytes: 640
H, W, D = map(int, input().split())

dic = {}
K = H*W//D
memo = [[0]* (K+1) for _ in range(D+1)]

for y in range(1, H+1):
    A = list(map(int, input().split()))
    for x, a in enumerate(A, 1):
        dic[a] = [x, y]

for extra in range(H*W+1, H*W+2*D):
    dic[extra] = [0, 0]

for i in range(1, D+1):
    for j in range(K):
        x, y = dic[i+D*j]
        nx, ny = dic[i+D*(j+1)]
        cost = abs(x-nx) + abs(y-ny)
        memo[i][j+1] = memo[i][j] + cost

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    i = L % D
    j = L//D
    delta = (R-L)//D
    if i == 0:
        i = D
        j -= 1
    ans = memo[i][j+delta] - memo[i][j]
    print(ans)


Measured memory_bytes: 61052
M=10**9+7
mod =M
import sys
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
NNN = (10**6)
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        c = 0
        while n % i == 0:
            n /= i
            c+=1
        if c!=0:
            table.append((i,c))
        i += 1
    if n > 1:
        table.append((int(n), 1))
    return table

from collections import defaultdict
N=input()
xs = list(map(int, input().split()))
ys = []
d = defaultdict(int)
for x in xs:
    ps = prime_decomposition(x)
    psd = defaultdict(int)
    for p, c in ps:
        psd[p] = c
        d[p] = max(d[p], c)
    ys.append(psd)
g=1
for p in d:
    g=mul(g,p**(d[p])%M)%M
r=0
for x in xs:
    r = (r+mul(g,inverse[x]))%M
print(r%M)


Measured memory_bytes: 94316
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    ll h, n;
    cin >> h >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(h + 1, INF));
    for (int i = 0; i <= n; i++)
    {
        dp[i][0] = 0;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= h; j++)
        {
            if (j < a[i])
            {
                dp[i + 1][j] = min(dp[i][j], ((j + a[i] - 1) / a[i]) * b[i]);
            }
            else
            {
                dp[i + 1][j] = min(dp[i + 1][j - a[i]] + b[i], min(dp[i][j], (j + a[i] - 1) / a[i] * b[i]));
            }
        }
    }
    // for (auto line : dp)
    // {
    //     print(line);
    // }
    cout << dp[n][h] << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 81580
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int N;
    cin>>N;
    vector<pair<int,int>> A;

    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        A.push_back({a,i+1});
    }

    sort(A.begin(),A.end());

    for(int i = 0;i < N;i++) {
        cout<<A[i].second<<" ";
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 1780
from heapq import heappush, heappop
import re
from collections import deque
import sys
import math
input = sys.stdin.readline


def int_raw():
    return int(input())

def str_in():
    return input().strip("\n")

def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def ncr(n, r, mod=DIV):
	r = min(r, n-r)
	ret = 1
	for i in range(1, r+1):
		ret = ret * (n-i+1) % mod
		ret = ret * mod_inv(i, mod) % mod
	return ret


class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        self.mini = [i for i in range(n+1)]

    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        mini = min(self.mini[x],self.mini[y])
        self.mini[x]=mini
        self.mini[y]=mini
    
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

def main():
    n = int_raw()
    As = list(ints_raw())
    As.sort()
    ans = As[0]
    for a in As[1:]:
        ans = (ans+a)/2.0
    return ans
print(main())


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

int main() {
	int n;
	cin >> n;
	string str = "No";
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			if (i * j == n) {
				str = "Yes";
				break;
			}
			if (str == "Tes") {
				break;
			}
		}
	}
	cout << str << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"


const int N=100005;
const int MOD=1e9+7;
 

// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
 
 
 int sum[N];
int main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/

int n;
cin>>n;
string s;
set<string > st;

for(int i=0;i<n;i++)
{
	cin>>s;
	st.insert(s);
	
}
cout<<st.size();



}

Measured memory_bytes: 19228
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
	int x, a;
	cin >> x >> a;
	if (x < a) cout << 0 << endl;
	else cout << 10 << endl;
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define brep1(i,n) for(int i=n;i>=1;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long

unsigned const int MOD = 1e9+7;

int main(void){
    int h,w;
    cin >> h >> w;
    string map[h];
    int wlen[h][w];
    int hlen[h][w];
    
    rep(i,h){
        cin >> map[i];
        rep(j,w){
            wlen[i][j]= 0;
            hlen[i][j]= 0;
        }
    }
    rep(i,h){
        int count = 0;
        rep(j,w){
            if(map[i][j] == '#'){
                rep1(k,count+1){
                    wlen[i][j-k] = count; 
                }
                count = 0;
            }
            else if(map[i][j] == '.' && j == w-1){
                count++;
                rep(k,count)wlen[i][j-k] = count; 
            }
            else count++;
        }
    }
    rep(i,w){
        int count = 0;
        rep(j,h){
            if(map[j][i] == '#'){
                rep1(k,count+1){
                    hlen[j-k][i] = count; 
                }
                count = 0;
            }
            else if(map[j][i] == '.' && j == h-1){
                count++;
                rep(k,count)hlen[j-k][i] = count; 
            }
            else count++;
        }
    }
    int ans = 1;
    rep(i,h){
        rep(j,w){
            //cout << wlen[i][j] << endl;
            if(wlen[i][j]+hlen[i][j]-1 > ans)ans =wlen[i][j]+hlen[i][j] -1;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 35588
//ACACACACACACACACACACACACACACAC
#include<stdio.h>{
	int main(){
		int n,y,i,j,k;
		scanf("%d %d",&n,&y);
		
		for(i=0;i<=n&&i*10<=y/1000;i++){
			for(j=0;i+j<=n&&i*10+j*5<=y/1000;j++){
				for(k=0;i+j+k<=n&&i*10+j*5+k<=y/1000;k++){
					if(i+j+k==n&&i*10+j*5+k==y/1000){
						printf("%d %d %d",i,j,k);
						return(0);
					}
				}
			}
		}
				
		printf("-1 -1 -1");
		
		return(0);
	}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define show(x) cout<<#x" = "<<x<<endl;
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<unsigned,unsigned> uupair;
typedef pair<int,int> iipair;
typedef vector<int> vec;
typedef vector<ll> llvec;
typedef vector<unsigned> uvec;
typedef vector<ull> ullvec;
typedef vector<uvec> grid;
typedef vector<vec> igrid;
typedef vector<string> svec;
typedef vector<svec> sgrid;
typedef vector<bool> bvec;
typedef vector<bvec> bgrid;
typedef vector<char> cvec;
typedef vector<uupair> uupvec;
typedef vector<iipair> iipvec;
typedef unordered_map<unsigned,unsigned> uuhmap;
typedef unordered_map<ll,ll> llllhmap;
typedef map<unsigned,unsigned> uumap;
typedef map<int ,unsigned> iumap;
typedef map<int,int> iimap;
typedef unordered_map<int ,unsigned> iuhmap;
typedef unordered_map<int,int> iihmap;
typedef unordered_map<unsigned,uvec> uuvechmap;
typedef unordered_map<ull,ull> ullullhmap;
typedef map<char,cvec> ccvecmap;
typedef unordered_set<unsigned> uhset;
typedef set<unsigned> uset;

int main()
{
    cin.tie(0);
    vector< vector<ld>> dp;
    vector<ld> heads,tails;
    unsigned n;
    cin>>n;
    dp.resize(n+1,vector<ld>(n+1,0));
    heads.resize(n+1);
    tails.resize(n+1);

    for(unsigned i=1;i<=n;++i)
    {
        cin>>heads[i];
        tails[i]=1-heads[i];
    }
    dp[0][0]=1;
    for(unsigned i=0;i<=n;++i)
    {
        for(unsigned j=1;j<=n;++j)
        {
            if(i>0)
            {
                dp[i][j]=dp[i-1][j-1]*heads[j] + dp[i][j-1]*tails[j];
            }
            else if(i == 0)
                dp[i][j]=dp[i][j-1]*tails[j];
        }
    }

    ld res=0;
    for(unsigned i=n/2+1;i<=n;++i)
    {
        res+=dp[i][n];
    }
    cout<<fixed<<setprecision(11);
    cout<<res;
}

Measured memory_bytes: 141056
n=int(input())
s=input().split()
s.append(0)

q=int(input())
t=input().split()

cnt=0
for i in range(q):
    key=t[i]
    s[n]=key
    j=0
    while(s[j]!=key):
        j+=1

    if j==n:
        continue
    else:
        cnt+=1

print(cnt)


Measured memory_bytes: 6056
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>     
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, k, a[N], b[N], ans, it1, it2, pref1[N], pref2[N];

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n >> m >> k;
   for (int i = 1; i <= n; i ++) cin >> a[i], pref1[i] = pref1[i - 1] + a[i];
   for (int i = 1; i <= m; i ++) cin >> b[i], pref2[i] = pref2[i - 1] + b[i];
   int it = m;
   for (int i = 0; i <= n; i ++) {
      if (pref1[i] > k) break;
      while (it > 0 && pref1[i] + pref2[it] > k) it --;
      ans = max (ans, i + it);
   }
   cout << ans;
}               
 
signed main () {                                       
   #ifdef QWERTY
      freopen("input", "r", stdin);
   #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 9912
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <deque>
#include <assert.h>
#include <random>
#include <bitset>
#include <string>
#include <cstring>
#include <memory.h>

using ll = long long;

const int inf = 1e9;
const ll infll = 1e18;

using namespace std;

ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}

struct Solution {
	Solution() {
		int n;
		cin >> n;
		//vector<int>a(n);
		int cur = 1;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			if (x == cur) {
				cur++;
			}
		}
		if (cur == 1) {
			cout << -1;
			return;
		}
		cout << n - (cur - 1);
	}
};

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	for (; t; t--) {
		Solution s;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))

import bisect
l.sort()
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        idx = bisect.bisect_left(l,l[i]+l[j])
        #print('idx',idx)
        if j < idx:
            cnt += idx - j - 1


print(cnt)

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[a]; if (a != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int cmin = INF;
	REP(i, 26) {
		int tmp = 0;
		vi v;
		REP(j, s.size()) {
			if (s[j] == i + 'a')v.push_back(j);
		}
		if (v.size() == 0)continue;
		tmp = max(tmp, v[0]);
		tmp = max(tmp, s.size()-1-v[v.size() - 1]);
		REP(j, v.size() - 1) {
			tmp = max(tmp, v[j + 1] - v[j]-1);
		}
		cmin = min(tmp, cmin);
	}
	cout << cmin << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n, w;
  cin >> n >> w;
  vector<int> weight(n);
  vector<int> value(n);
  rep(i, n) {
    cin >> value[i] >> weight[i];
  }
  vector<int> dp(w+10);
  rep(j, w+1) {
    rep(i, n) {
      if(j >= weight[i]) {
        dp[j] = max(dp[j-weight[i]]+value[i], dp[j]);
      }
    }
  }
  cout << dp[w] << endl;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main() {
    int n, m; cin >> n >> m;
    vector<P> sv;
    rep(i, m) {
        int s;
        int c;
        cin >> s >> c;
        sv.emplace_back(s, c);
    }
    int ans=-1;
    for(int i=pow(10, n-1) - (n==1); i<=pow(10, n)-1; i++) {
        string str = to_string(i);
        bool isOk = true;
        for(auto au : sv) {
            if(str[au.first-1] != '0'+au.second) {
                isOk = false;
            }
        }
        if(isOk) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double DB;

#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define R(i,n) for(int i=0;i<(n);++i)
#define fill(a,b) memset(a,b,sizeof(a))

const int maxn = 410;
const int mod = 1e9 + 7;

int n,c;
int a[maxn],b[maxn];
LL P[maxn][maxn],A[maxn][maxn];
LL d[2][maxn];

/*
LL pow_m(int a,int n)
{
	LL res = 1;
	while(n)
	{
		if(n&1) res = res*a %mod;
		a = a*a %mod;
		n >>= 1;
	}
	return res;
}
*/

void init()
{
	F(i,1,400)
	{
		P[i][0] = 1;
		F(j,1,400)
			P[i][j] = P[i][j-1]*i %mod; 
	}
}

int main()
{
	//freopen("test.txt","r",stdin);
	init();

	scanf("%d %d",&n,&c);	
	F(i,1,n) scanf("%d",a+i);
	F(i,1,n) scanf("%d",b+i);

	F(i,1,n)
	{
		F(k,0,c)
		{
			A[i][k] = 0;
			F(j,a[i],b[i])
			{
				A[i][k] = (A[i][k] + P[j][k])%mod;
			}
		}
//		printf("%d\n",A[i][1]);
	}


	int p = 1;
	d[p][0] = 1;
	F(i,1,n)
	{
		p ^= 1;
		fill(d[p],0);
		F(j,0,c)
		{
			F(k,0,c)
			{
				if(k+j > c) break;
				d[p][k+j] = (d[p][k+j] + d[p^1][j]*A[i][k] %mod) %mod;
			}
		}
	}
	printf("%lld\n",d[p][c]);
//	printf("%d\n",pow_m(a[1],c)*C[n+c-1][c]%mod);
	return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
typedef pair<int,int> pii;
typedef vector<int64_t> vl;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define ALL(a) begin(a),end(a)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

    
void solve()
{
	int n;cin>>n;
    int a[n];REP(i,n)cin>>a[i];
    vector<vector<int>>dp(n+1,vector<int>(3,0));
    rep(i,1,n+1){
        REP(j,3)dp[i][j]=dp[i-1][j];
        REP(j,3)if(dp[i][j]==a[i-1]){dp[i][j]++;break;}
    }
    //REP(i,n+1){REP(j,3)cout<<dp[i][j];cout<<endl;}
    ll ans=1;
    REP(i,n){
        int tmp=0;
        REP(j,3)if(dp[i][j]==a[i])tmp++;
        ans*=tmp;
        ans%=mod;
    }
    cout<<ans<<endl;

}

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


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

int main()
{
	int A, B, H, M;
	cin >> A >> B >> H >> M;

	double th = (double)H / 12 + (double)M / 60 / 12 - (double)M / 60;
	th *= M_PI * 2;
	double ans = sqrt( A * A + B * B - 2 * A * B * cos( th ) );

	cout << fixed << setprecision(12) << ans << endl;
}


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

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;

    rep(i, N) cin >> A[i];
    rep(i, N) {
        sum[i + 1] = sum[i] + A[i];
    }
    map<int, int> mp;
    rep(i, N) {
        mp[sum[i + 1]]++;
    }
    int ans = 0;
    rep(i, N) {
        if (sum[i + 1] == 0) ans++;
        ans += mp[sum[i + 1]] - 1;
        mp[sum[i + 1]]--;
    }
    cout << ans << endl;




    return 0;
}


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

int n;
double ans, x;

int main() {
    cin >> n;
    string u;
    rep(i, n) {
        cin >> x >> u;
        if (u[0] == 'J') ans += x;
        else ans += x * 380000;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int A, B, C;
  cin >> A >> B >> C;

  int ret = 0;
  while(true){
    if(B >= A){
      ret++;
      B -= A;
      C--;
    }else{
      break;
    }
    if(C==0) break;
  }

  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch RegularTriangle | diff RegularTriangle.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address RegularTriangle.cpp && ./a.out

/*
 
 5/9/2019
 
 19:40-
 
 */

int A,B,C;

void solve() {
//  VI X={A,B,C};
//  sort(ALL(X));
//  cout<<(X[0]+X[1]>X[2]?"YES":"NO")<<endl;
  cout<<(A==B&&B==C?"Yes":"No")<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>A>>B>>C;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    void solve() {
        Scanner in = new Scanner(System.in);
        int A = in.nextInt() * 100, B = in.nextInt() * 100, C = in.nextInt(), 
            D = in.nextInt(), E = in.nextInt(), F = in.nextInt();
        
        int w = A, s = 0;
        for(int i = 0; i <= F / A; i++){
            for(int j = 0; j <= F / B; j++){
                for(int x = 0; x <= F / C; x++){
                    for(int y = 0; y <= F / D; y++){
                        int a = A * i + B * j;
                        int b = C * x + D * y;
                        if(100 * b <= a * E && b * w > a * s && a + b <= F){
                            w = a;
                            s = b;
                        }
                    }
                }
            }
        }
        System.out.println(w + s + " " + s);
    }

    public static void main(String[] args) {
        new Main().solve();
    }
}

Measured memory_bytes: 21972
import java.util.Scanner;
import java.util.Arrays;

class Island implements Comparable {
    int m, n;
    public Island(int m, int n) {
        this.m = m;
        this.n = n;
    }

    public int compareTo(Object arg) {
        Island otherIsland = (Island)arg;
        return this.n - otherIsland.n;
    }
}

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n;
        while (true) {
            n = sc.nextInt();
            if (n == 0) break;

            Island[] islands = new Island[n];
            for (int i = 0; i < n; i++) {
                islands[i] = new Island(sc.nextInt(), sc.nextInt());
            }
            Arrays.sort(islands);

            int total = 0;
            boolean yes = true;
            for (int i = 0; i < n; i++) {
                total += islands[i].m;
                if (total > islands[i].n) {
                    yes = false; break;
                }
            }

            System.out.println(yes ? "Yes" : "No");
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 22512
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cassert>
#include <utility>
#include <numeric>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#define rep(i,n) for (int i=0; i<(n); ++i)

using namespace std;
using ll = long long;

int main (){
    ll H,N;
    cin >> H >> N;
    vector <ll> A(N);
    ll sum=0;
    for (int i=0;i<N;i++){
        cin >> A[i];
        sum += A[i];
    }

    if (sum >= H ){
        cout << "Yes";
    }
    else {
        cout << "No";

    }
    
}

Measured memory_bytes: 1024
import math
def main():
    H, W = map(int, input().split())
    if H == 1 or W == 1:
        print(1)
    else:
        a = math.ceil(W/2) * math.ceil(H/2)
        b = math.floor(W/2) * math.floor(H/2)
        print(a+b)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n = int(input())
k = int(input())

d_sum = [[0,0,0] for i in range(101)]
pre = [0,0,0]
for i in range(1,101):
    pre[0] += 9
    pre[1] += 81*(i-1)
    pre[2] += (9**3)*(i-1)*(i-2)//2
    d_sum[i][0] = pre[0]
    d_sum[i][1] = pre[1]
    d_sum[i][2] = pre[2]

s = str(n)

ans = d_sum[len(s)-1][k-1]

nonzero = 0
for ind, i in enumerate(s):
    if int(i)==0:
        continue
    digit = len(s)-ind-1
    if ind==0:
        nonzero += 1
        if nonzero==k:
            ans += int(i)
            break
        ans += (int(i)-1)*d_sum[digit][k-nonzero-1]
    else:
        ans += d_sum[digit][k-nonzero-1]
        nonzero += 1
        if nonzero==k:
            ans += int(i)
            break
        ans += (int(i)-1)*d_sum[digit][k-nonzero-1]

print(ans)

Measured memory_bytes: 3064
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      String s = sc.next();
      if(s.length() <= k)
        System.out.println(s);
      else
        System.out.println(s.substring(0, k) + "...");
  }
}

Measured memory_bytes: 27088
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[m];
  mem(a);
  rep(i,n) {
    int k;
    R k;
    rep(j,k) {
      int x;
      R x;
      a[x-1]++;
    }
  }
  int ans=0;
  rep(i,m) {
    if(a[i]==n) ans++;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long L,R;
    cin >> L >> R;
    vector<int> Num;
    long long testKaisu=2019<R-L+1 ? 2019 : R-L+1;
    for(long long i=L; i<L+testKaisu; i++){
        Num.push_back(i%2019);
    }
    int ans=2018;
    for(long long i=0; i<testKaisu-1; i++){
        for(long long j=i+1; j<testKaisu; j++){
            if(ans > (Num.at(i)*Num.at(j))%2019){
                ans = (Num.at(i)*Num.at(j))%2019;
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
/**
*    created: 30.06.2020 14:31:52
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcountll(bit)
using namespace std;
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;}
const int mod = 1000000007;
const long double pi = acos(-1.0);
const int inf = 1LL << 60;

signed main() {

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0;
    int ans = 0;
    rep(i,n) {
        if (s[i] == 'I') x++;
        else x--;
        chmax(ans,x);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
package main

import "fmt"

func main() {
	for {
		var x, y int
		fmt.Scan(&x, &y)
		if x == 0 && y == 0 {
			break
		} else {
			if x < y {
				fmt.Println(x, y)
			} else {
				fmt.Println(y, x)
			}
		}
	}
}



Measured memory_bytes: 1260
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(void) {
    int n,d;
    cin >> n>> d;

    vector<vector<int>> x;
    x.resize(n);
    for(int i = 0; i < n; ++i) {
        x[i].resize(d);
    }

    // int **x = new int*[d];
    // for(int i = 0; i < d; i++) {
    //     x[i] = new int[n];
    // }

    for(int i = 0; i < n; ++i) {
        for(int di = 0; di < d; ++di) {
            cin >> x[i][di];
        }
    }

    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i+1; j < n; ++j) {

            int temp = 0;
            for(int di = 0; di < d; ++di) {
                temp += pow((x[i][di] - x[j][di]),2);
            }
            double check = sqrt(temp);
            if(ceil(check) == floor(check)) {
                cnt++;
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

struct StronglyConnectedComponents {
  int V;
  std::vector<std::vector<int>> G, rG;
  std::vector<int> vs, cmp;
  std::vector<bool> used;

  StronglyConnectedComponents(const int V)
      : V(V), G(V), rG(V), cmp(V), used(V) {}

  void add_edge(const int from, const int to) {
    G[from].push_back(to);
    rG[to].push_back(from);
  }

  void dfs(const int v) {
    used[v] = true;
    for (int c : G[v])
      if (not used[c]) dfs(c);
    vs.push_back(v);
  }

  void rdfs(const int v, const int k) {
    used[v] = true;
    cmp[v] = k;
    for (int c : rG[v])
      if (not used[c]) rdfs(c, k);
  }

  int run() {
    std::fill(used.begin(), used.end(), false);
    vs.clear();
    for (int v = 0; v < V; v++)
      if (!used[v]) dfs(v);
    std::fill(used.begin(), used.end(), false);
    int k = 0;
    for (int i = vs.size() - 1; i >= 0; i--)
      if (!used[vs[i]]) rdfs(vs[i], k++);
    return k;
  }

  std::vector<int> create_order() {
    std::vector<int> order(V);
    for (std::size_t i = 0; i < cmp.size(); i++) {
      order[cmp[i]] = i;
    }
    return order;
  }
};

void yosupo() {
  int N, M;
  std::cin >> N >> M;
  StronglyConnectedComponents scc(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    std::cin >> a >> b;
    scc.add_edge(a, b);
  }
  scc.run();
  std::map<int, std::vector<int>> ans;
  for (int i = N - 1; i >= 0; i--) {
    ans[scc.cmp[i]].emplace_back(i);
  }
  std::cout << ans.size() << std::endl;
  for (auto&& p : ans) {
    std::cout << p.second.size();
    for (int& i : p.second) std::cout << ' ' << i;
    std::cout << std::endl;
  }
}

void aoj() {
  int N, M;
  std::cin >> N >> M;
  StronglyConnectedComponents scc(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    std::cin >> a >> b;
    scc.add_edge(a, b);
  }
  scc.run();
  int Q;
  std::cin >> Q;
  for (int i = 0; i < Q; i++) {
    int u, v;
    std::cin >> u >> v;
    std::cout << (scc.cmp[u] == scc.cmp[v]) << std::endl;
  }
}

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

  // yosupo();
  aoj();
  return 0;
}


Measured memory_bytes: 4504
#include <bits/stdc++.h> 
 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

int main(){
    LL N,Y;
    cin>>N>>Y;
    LL tmp=0;
    REP(i,N+1){
        LL N2=N-i;
        REP(j,N2+1){
            tmp=i*10000LL+j*5000LL;
            if((Y>=tmp)&&(Y-tmp)%1000==0&&Y-tmp==(N-i-j)*1000){
                //cout<<i*10000<<" "<<j*5000<<" "<<(N-i-j)*1000<<endl;
                cout<<i<<" "<<j<<" "<<N-i-j<<endl;return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int c=0;
  for (int i=0;i<3;i++){
    if (s.at(i)=='o')c++;
  }
  cout << 700+100*c <<endl;
    
      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    ll sum[n + 1] = {};
    rep(i, 0, n) {
        int a;
        cin >> a;
        sum[i + 1] = sum[i] + a;
    }
    map<ll, ll> mp;
    ll ans = 0;
    rep(i, 0, n + 1) {
        ans += mp[sum[i]];
        mp[sum[i]]++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int n;
vector<int> a;

int main()
{
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int l = 0, r = 0;
    for(int i = 0; i < n; i += 2) l += a[i];
    for(int i = 1; i < n; i += 2) r += a[i];

    cout << abs(l - r) << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()

ans = 0
n = 0
acgt = ('A', 'C', 'G', 'T')
for si in s:
    if si in acgt:
        n += 1
    else:
        if n > ans:
            ans = n
        n = 0
if n > ans:
    ans = n
print(ans)


Measured memory_bytes: 2940
import sys
Q, H, S, D = map(int,input().split())
N = int(input())

cost_per_two_liters = [8*Q,4*H,2*S,D]
res = int(N/2) * min(cost_per_two_liters)
if N % 2 == 0:
    print(res)
else:
    res += min([4*Q,2*H,S])
    print(res)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
// #include <iomanip>
// std::cout << std::fixed << std::setprecision(5);

int main()
{
    std::string s;
    std::cin >> s;
    if(s[0]=='S')       std::cout << "Cloudy";
    else if(s[0]=='C')  std::cout << "Rainy";
    else if(s[0]=='R')  std::cout << "Sunny";
    std::cout << std::endl;
    return 0;
}

Measured memory_bytes: 256
N,X = map(int,input().split())
src = list(map(int,input().split()))
dp = src[:]
ans = float('inf')
for n in range(N):
    for m in range(N):
       if dp[m] > src[m-n]:
           dp[m] = src[m-n]
    ans = min(ans, sum(dp)+n*X)
print(ans)

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

//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define FS first
#define SE second

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal var
//------------------------------------------


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  int A,B,C;
  str ans = "No";
  cin >> A >> B >>C;
  if(A<C&&B>C) ans = "Yes";
  if(A>C&&B<C) ans = "Yes";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
using ll = long long;
using namespace std;
ll n,k,s=0,a[550],b[550],ans=0;
ll f(ll p){
    ll s2=0,s3=0;
    rep(i,0,n){b[i]=a[i]%p;s2+=b[i];} //s2...16行目で探索する約数pでa[i]を割ったものの和
    sort(b,b+n);
    rep(i,0,n-s2/p)s3+=b[i];  //s3は操作する回数：s2/pは作る約数の数、つまりそれ以前の数まで(n-s2/p)についてb[i]を操作する
    if(s3<=k) return p;             //k回越えなければ返す
    else return 0;
}
int main(){
    cin>>n>>k;
    rep(i,0,n) {cin>>a[i];s+=a[i];}     //s...a[i]の和を取り、sのすべての約数について試す
    for(ll p=1;(p*p)<=s;p++) if(s%p==0){//中央の約数は√s1よりp*p<=s前後から約数を探索
        ans=max(ans,f(p));              //約数pについてk回以下で処理できるかf関数で確認
        if(s%p==0)ans=max(ans,f(s/p)); //上は√pまで、ここでは√pからｓまで後ろから探索(s%pが約数となる条件)
    }
    cout<<ans;
}


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

using namespace std;
long long dp[100010][3];
int a[100010],b[100010],c[100010];
int main(){

  int n;
  cin>>n;

  memset(dp,0,sizeof(dp));
  for(int i=1;i<=n;i++){
    cin>>a[i];
    cin>>b[i];
    cin>>c[i];
  }

  for(int i=1;i<=n;i++){
    dp[i][0]=max(dp[i-1][1],dp[i-1][2]) + a[i];
    dp[i][1]=max(dp[i-1][0],dp[i-1][2]) + b[i];
    dp[i][2]=max(dp[i-1][0],dp[i-1][1]) + c[i];
  }

  long long  ans = max(dp[n][0],dp[n][1]);
  ans =max(ans,dp[n][2]);
  cout<<ans;


   return 0;
}

Measured memory_bytes: 3712
#include<iostream>
using namespace std;
using ll = long long;
const int AMAX = 100000;
ll cnt[AMAX + 1];

int main(void) {
int N;
ll K;
cin >> N >> K;

 for (int i = 0; i < N; ++i) {
int A, B;
cin >> A >> B;
cnt[A] += B;
}

 for (int ans = 1; ans <= AMAX; ++ans){
if (K <= cnt[ans]) {
 cout << ans << endl;
 break;
}
 K -= cnt[ans];
}

 return 0;
}


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

int main(){
    int n; cin>>n;
    vector<int> a(n);
    int cnt=0,m=1e9;
    long long ans=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]<0) cnt++;
        m=min(m,abs(a[i]));
        ans+=abs(a[i]);
    }
    if(cnt%2) ans-=2*m;
    
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fv               first
#define sv               second
#define ll               long long
#define pb               push_back
#define mp               make_pair
#define pll              pair<ll,ll>
#define pii              pair<int,int>
#define READ(x)          freopen(x,"r",stdin)
#define WRITE(x)         freopen(x,"w",stdout)
#define isWorking()      cout<<"Wroking"<<endl
#define all(x)           (x).begin(),(x).end()
#define allr(x)          (x).rbegin(),(x).rend()
#define fill(x,y)        memset(x, y, sizeof(x))
#define PRINT(ok)        cout<<(ok? "YES":"NO")<<endl
#define DoublePrint(x,a) cout<<fixed<<setprecision(x)<<a<<endl
#define Fast_Input       ios_base :: sync_with_stdio(0),cin.tie(0);

const ll mod= 1e9+7,INF=1e8,mx= 1e6+5,mn=100;
int testCase=1,cas=0;

int main() {

    Fast_Input

    while(testCase--){
        int n; cin>>n;

        priority_queue <ll> q;

        ll x;

        for(int i=0; i<n; i++){
            cin >> x;
            if(x%2==0){
                q.push(x);
            }
        }
        ll cnt = 0 , ans =0;

        while(!q.empty()){

            ll y = q.top();
            q.pop();

            y/=2;
            ans ++;
            cnt +=3;

            if(y%2==0) q.push(y);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  int cntb=0,cntw=0;
  vector<int> b(n+2,0),w(n+2,0);
  for(int i=0;i<n;i++){
    if(s[i]=='#') cntb++;
    if(s[n-1-i]=='.') cntw++;
    b[i+1]=cntb;
    w[n-i]=cntw;
  }
  int ans=b[0]+w[1];
  for(int i=1;i<n+2;i++){
    ans=min(ans,b[i-1]+w[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, sz[N], par[N];
vector<int> adjList[N];
map<int, int> w[N];

void dfs(int v, int p) {
	par[v] = p;
	sz[v] = 1;
	for (int u : adjList[v]) {
		if (u == p) continue;
		dfs(u, v);
		sz[v] += sz[u];
	}
}

vector<int> centroids;
void cent(int v, int p) {
	bool isCent = true;
	for (int u : adjList[v]) {
		if (u == p) continue;
		cent(u, v);
		isCent = isCent && sz[u] <= n / 2;
	}
	isCent = isCent && n - sz[v] <= n / 2;
	if (isCent) {
		centroids.emplace_back(v);
	}
}

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

	cin >> n;

	int a, b, c;
	for (int i = 1; i < n; i++) {
		cin >> a >> b >> c;
		adjList[a].emplace_back(b);
		adjList[b].emplace_back(a);
		w[a][b] = c;
		w[b][a] = c;
	}

	dfs(1, -1);
	cent(1, -1);
	dfs(centroids[0], -1);

	long long ans = 0;
	for (int v = 1; v <= n; v++) {
		if (par[v] == -1) continue;
		ans += (long long) sz[v] * w[v][par[v]];
	}
	ans *= 2LL;

	if (centroids.size() > 1) {
		ans -= (long long) w[centroids[0]][centroids[1]];
	}
	else {
		int mn = INT_MAX;
		for (auto we : w[centroids[0]]) {
			mn = min(mn, we.second);
		}
		ans -= (long long) mn;
	}

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 30584
/*16D8101024H Muramatsu Masaki 村松 将希 mentuyu C++*/

#include<iostream>
#include<math.h>

int isprime(int x){
  int i;
  if(x == 2){
    return 0;
  }

  if(x < 2 || x%2 == 0){
    return 1;
  }

  i = 3;
  while(i <= sqrt(x)){
    if(x % i == 0){
      return 1;
    }
    i = i + 2;
  }
  return 0;
}

int main(){
  int i,n,a[10000],flag = 0;
  std::cin>>n;
  for(i=0;i<n;i++){
    std::cin>>a[i];
  }

  for(i=0;i<n;i++){
    if(isprime(a[i]) == 0){
      flag++;
    }
  }
  std::cout<<flag<<"\n";
  return 0;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a;
  string s = "9999";
  for(int i = 0;i < 4;i++){
    cin >> a;
    s.at(i) = '0' + a;
  }
  sort(s.begin(),s.end());
  if(s == "1479"){
    cout << "YES";
  }else{
    cout << "NO";
  }
}

Measured memory_bytes: 256