akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

int main(){
	startTime=clock();
	ll n,k;
	cin >> n >> k;
	if(k%2){
		ll ans= n/k;
		cout << ans*ans*ans;
	}
	else{
		ll k1=k/2;
		ll ans1=n/k1;
		ll even=ans1/2;
		ll odd=ans1-even;
		cout << even*even*even + odd*odd*odd;

	}

	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
const i64 MOD = 1e9 + 7;
int64_t powmod(int64_t a, int64_t p) {
    int64_t value = 1;
    for (int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
        if (p & 1) value = (value * mul) % MOD;
    }
    return value;
}
int main() {
    int N;
    cin >> N;
    map<int, int> m;
    for(int i = 0; i < N; i++) {
        int a;
        cin >> a;
        m[a]++;
    }
    for(int i = (N - 1) % 2; i < N; i += 2) {
        if( (i == 0 && m[i] != 1) || (i != 0 && m[i] != 2)) {
            cout << 0 << endl;
            return 0;
        }
        m.erase(i);
    }
    if(m.size()) {
        cout << 0 << endl;
    } else {
        cout << powmod(2, N / 2) << endl;
    }
    return 0;
}

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

using namespace std;

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

    int n;
    cin >> n;
    multiset<int> s;
    vector<int> v;

    for (int i = 0; i < (1 << n); i++) {
        int x;
        cin >> x;
        s.insert(x);
    }

    v.push_back(*s.rbegin());
    s.erase(--s.end());

    while (v.size() < (1 << n)) {
        vector<int> tmp;

        for (int x : v) {
            auto it = s.lower_bound(x);
            if (it == s.begin())
                return cout << "No\n", 0;

            it--;
            tmp.push_back(*it);
            s.erase(it);
        }

        for (int x : tmp)
            v.push_back(x);
    }

    cout << "Yes\n";

    return 0;
}


Measured memory_bytes: 14012
import java.io.*;

class Main
{
	public static void main(String[] args) throws IOException
	{

	BufferedReader br =
	new BufferedReader(new InputStreamReader(System.in));

	String str = br.readLine();
	int x = Integer.parseInt(str);

	//System.out.println( x^3 );	//^???Java??§????????§?????????XOR???????????????
	System.out.println( x*x*x );		// <= ??£?§£
	//System.out.println( Math.pow( x^3) ); // Math.pow ???double???????????????
	//System.out.println( (int)Math.pow( x^3) ); // <= ??£?§£

}
} 

Measured memory_bytes: 24108
#include <bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair <int, int>
#define iiii pair <int, pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i, x) for(int (i) = 0; (i) < (x); (i)++)
inline int getint() {
	int x = 0, p = 1; 
	char c = getchar();	
	while (c <= 32) c = getchar();
	if (c == 45) p = -p, c = getchar();
	while (c > 32) x = x * 10 + c - 48, c = getchar();
	return x * p;
}
using namespace std;
//ruogu_alter
const int N = 1e5 + 5;
int n, a[N], b[N], c[N], id[N];
set<pii > S;
//
bool cmp(int x, int y) {
	return b[x] < b[y];
}
int main() {
	n = getint(); 
	rep(i, n) a[i] = getint(), S.insert(mp(a[i], i)), c[i] = a[i];
	rep(i, n) b[i] = getint(), id[i] = i;
	sort(c, c + n);
	sort(id, id + n, cmp);
	int d = 0;
	rep(i, n) if(c[i] > b[id[i]]) return !printf("No\n");
	rep(ii, n) {
		int i = id[ii];
		S.erase(mp(a[i], i));
		if (a[i] <= b[i]) {++d; continue;}
		set<pii >::iterator it = S.lower_bound(mp(b[i] + 1, -INF));
		if(it == S.begin()) return !printf("No\n");
		--it;
		int x = it -> first, y = it -> second;
		S.erase(it);
		swap(a[y], a[i]);
		S.insert(mp(a[y], y));
	}
	if (d > 1) printf("Yes\n"); else printf("No\n");
	return 0;
}


Measured memory_bytes: 6528
#!/usr/bin/env python3
import sys
args = sys.argv
if len(args) == 2:
  from IPython import embed
  em = True
else:
  em = False
input = sys.stdin.readline
M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())
if D2 == 1:
  print("1")
else:
  print("0")


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

int main(){
	int n; cin >> n;
	string s; cin >> s;
	int x = 0;
	int ans = 0;
	for(int i = 0; i < s.size(); ++i){
		x += (s[i] == 'I' ? 1 : -1);
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();
        Dice dice = new Dice(str);
        str = br.readLine();
        for(int i=0;i<str.length();i++){
            char c = str.charAt(i);
            switch(c){
                case 'S':
                    dice.moveS();
                    break;
                case 'W':
                    dice.moveW();
                    break;
                case 'E':
                    dice.moveE();
                    break;
                case 'N':
                    dice.moveN();
                    break;
                default:
                    break;
            }
        }
        System.out.println(dice.getStr(0));
    }
}

class Dice{
    private String str[];//0=???,1=???,2=???,3=???,4=??????,5=???
    private String tmp;
    
    Dice(String str) {
        this.str = new String[6];
        this.str = str.split(" ");
    }
    
    public String getStr(int n){
        return this.str[n];
    }
    
    void moveW(){
        tmp = this.str[0];
        this.str[0] = this.str[2];
        this.str[2] = this.str[5];
        this.str[5] = this.str[3];
        this.str[3] = tmp;
    }
    
    void moveE(){
        tmp = this.str[0];
        this.str[0] = this.str[3];
        this.str[3] = this.str[5];
        this.str[5] = this.str[2];
        this.str[2] = tmp;
    }
    
    void moveS(){
        tmp = this.str[0];
        this.str[0] = this.str[4];
        this.str[4] = this.str[5];
        this.str[5] = this.str[1];
        this.str[1] = tmp;
    }
    
    void moveN(){
        tmp = this.str[0];
        this.str[0] = this.str[1];
        this.str[1] = this.str[5];
        this.str[5] = this.str[4];
        this.str[4] = tmp;
    }
}

Measured memory_bytes: 24364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#define _USE_MATH_DEFINES
#include <cmath>

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

using namespace std;
typedef long long ll;

const int MAXN = 1000;
const int MAXV = 10100;

int main() {
   int n, W[MAXN], W_sort[MAXN], cnt[MAXN], num[MAXV];
   int min_w = 10100;
   int ans = 0;

   cin >> n;
   rep(i, n) {
      scanf("%d", &W[i]);
      min_w = min(min_w, W[i]);
      W_sort[i] = W[i];
   }
   rep(i, MAXN) {
      cnt[i] = 0;
   }
   sort(W_sort, W_sort + n);
   rep(i, n) {
      num[W_sort[i]] = i;
   }


   for (int i = 0; i < n; i++) {
      if (cnt[i] == 1) continue;
      int j = i;
      int csum = 0;
      int cmin = 10100;
      int cntl = 0;
      do {
         cntl++;
         csum += W[j];
         cmin  = min(cmin, W[j]);
         cnt[j] = 1;
         j = num[W[j]];
      } while (i != j);
      ans += min(csum + cmin * (cntl - 2), csum + min_w * (cntl + 1) + cmin);
   }

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



Measured memory_bytes: 3256
#include<iostream>
#include<vector>
#include<algorithm>
#include<bitset>
using namespace std;
int main(){
    int n,m,k,t,cnt,ans=0;
    cin>>n>>m;
    bool s[10][10]={},p[m]={};

    for(int i=0;i<m;i++){
        cin>>k;
        for(int j=0;j<k;j++){
            cin>>t;
            s[i][t-1]=true;
        }
    }
    for(int i=0;i<m;i++){
        cin>>t;
        p[i]=t%2;
    }
    for(int i=0;i<1<<n;i++){
        bitset<10>sw(i);
        bool flag=true;
        for(int j=0;j<m;j++){
            cnt=0;
            for(int k=0;k<n;k++)if(sw[k]&&s[j][k])cnt++;
            if(cnt%2!=p[j])flag=false;
        }
        if(flag)ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    string s,pat;
    cin>>s>>pat;
    int ans=1e9;
    for(i=0;i+pat.size()-1<s.size();i++)
    {
        int cost=0;
        for(j=0;j<pat.size();j++)
        {
            if(s[i+j]!=pat[j]) cost++;
        }
        ans=min(ans,cost);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>
int main()
{
   int a,y,m;
    scanf("%d",&a);
    y=(a/100);
    m=(a%100);

    if(((y>=1)&&(y<=12))&&((m>=1)&&(m<=12)))
    {
        printf("AMBIGUOUS");
    }
    else
    {
        if((y>=1)&&(y<=12))

        {
            printf("MMYY");
        }
        else if((m>=1)&&(m<=12))

        {
            printf("YYMM");
        }
        else
        {
            printf("NA");
        }
    }
}






Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
int pd(int x)
{
	int s=0;
	while (x>0)
	{
		s++;
		x/=10;
	}
	return s;
}
int main ()
{
	long long n, a, b, f;
	cin>>n;
	for(long long i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{
			a=i;
			b=n/i;
		}
	}
	
	long long k, j;
	k=pd(a);
	j=pd(b);
	f=max(k,j);
	cout<<f<<endl;
	return 0;
}

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


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

   deque<char> deq;
   string s;
   cin >> s;
   for(auto tmp :s){
    deq.push_back(tmp);
   }
   bool on = false;
   int q;
   cin >> q;
   while(q--){
    int t;
    cin >> t;
    if(t==1) on ^= true;
    else {
        int f;
        cin >> f;
        char c; 
        cin >> c;
        if(on^(f==1)) deq.push_front(c);
        else deq.push_back(c);
    }
   }
   string ans;
   for(auto tmp: deq) ans.push_back(tmp);
   if(on) reverse(ans.begin(), ans.end());
   cout << ans <<"\n"; 
}



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

typedef long long int ll;
typedef pair<int,int> pi;
priority_queue<pi, vector<pi>, greater<pi> > pq; //min heap

#define dodebug(i, n, arr)	for(int i=0;i<n;++i)	cout<<arr[i]<<" ("<<i<<")\n";

ll gcd(ll a,ll b){	if(b == 0)	return a;return gcd(b,a%b);}
ll binpow(ll n,ll x){	ll ans = 1;while(x){if(x & 1)	ans *= n;n *= n;x >>= 1;}return ans;}

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

	int n, cap;
	cin>>n>>cap;

	vector<ll> dp(cap+1, 0);

	int w;
	ll v;
	for(int i=0;i<n;++i){
		cin>>w>>v;
		for(int i=cap;i-w>=0;--i)	dp[i] = max(dp[i], dp[i-w] + v);
	}
	
	ll ans = 0;
	for(int i=0;i<=cap;++i)		ans = max(ans, dp[i]);

	cout<<ans<<'\n';

	return 0;
}

Measured memory_bytes: 3920
#include <iostream>

using namespace std;

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

  cin >> A >> B >> C;
  int sum = 0;
  for (int i = 0; i <= 100; i++) {
    sum += A;
    int remainder = sum % B;

    if (remainder == C) {
      cout << "YES" << endl;
      return 0;
      //cout << sum << "," << remainder << "[got]" <<endl;
    } else {
      //cout << sum << "," << remainder << endl;
    }
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define fi first
#define se second
using namespace std;
typedef pair<int,int> P;
int dx[]={0,1,0,-1},dy[]={-1,0,1,0},w,h,x,y,d,c1,c2,c3;
string s[51];
bool b[51][51][4];
main(){
  while(cin>>h>>w,h&&(d=1)){
    vector<P>v;
    memset(b,0,sizeof(b));
    r(i,h)cin>>s[i];
    c1=c2=c3=y=x=0;
    while(1){
      v.push_back(P(y,x));
      if(b[y][x][d])break;
      b[y][x][d]=1;
      if(y==h-1&&(x==w-1||!x)||!y&&x==w-1){
        if(x==w-1&&y==h-1)c1++;
        if(!x&&y==h-1)c2++;
        if(x==w-1&&!y)c3++;
        r(i,v.size()-1)s[v[i].fi][v[i].se]='#';
        v.clear();
      }
      int yy=y+dy[d],xx=x+dx[d];
      if(yy<0||yy>=h||xx<0||xx>=w)d=(d+1)%4;
      else if(s[yy][xx]=='#'&&yy+xx)d=(d+1)%4;
      else{
        int ya=yy+dy[(d+3)%4],xa=xx+dx[(d+3)%4];
        if(ya>=0&&ya<h&&xa>=0&&xa<w&&s[ya][xa]=='.')d=(d+3)%4;
        y=yy,x=xx;
      }
    }
    if(!(y+x)&&c1&&c2&&c3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3184
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, M, = map(int, input().split())
L = [list(input().strip()) for _ in range(N)]

m = [[10 ** 18 for _ in range(M)] for _ in range(N)]

def bfs(x, y, c):
    if L[x][y] == "#":
        return

    if m[x][y] <= c:
        return

    m[x][y] = c

    if x + 1 < N:
        bfs(x + 1, y, c + 1)

    if y + 1 < M:
        bfs(x, y + 1, c + 1)

    if x - 1 >= 0:
        bfs(x - 1, y, c + 1)

    if y - 1 >= 0:
        bfs(x, y - 1, c + 1)

bfs(0, 0, 0)

if m[-1][-1] == 10 ** 18:
    print(-1)
    exit()

def dfs(x, y, c):
    if x == 0 and y == 0:
        L[x][y] = "o"
        return True
    for (_x, _y) in [(-1, 0), (0, -1), (1, 0), (0, 1)]:
        if x + _x < N and x + _x >= 0 and y + _y < M and y + _y >= 0:
            if c - 1 == m[x + _x][y + _y]:
                if dfs(x + _x, y + _y, c - 1):
                    L[x][y] = "o"
                    return True
    return False

dfs(N - 1, M - 1, m[-1][-1])

ans = 0
for v in L:
    ans += len([0 for c in v if c == "."])

print(ans)

Measured memory_bytes: 4740
a,b,c=(int(x) for x in input().split())

if a>b:
    i=a
    a=b
    b=i
if b>c:
    i=b
    b=c
    c=i
if a>b:
    i=a
    a=b
    b=i

print(str(a)+' '+str(b)+' '+str(c))


Measured memory_bytes: 5604
#include <stdio.h>

int main()
{
	int N;
	scanf("%d",&N);

	char array[N];
	scanf("%s",array );

	int countR=0;
	int countB=0;

	int i;
	for ( i=0 ; i<N ; i++	){
		if (array[i] == 'R'){
			countR ++;
		}
		if (array[i] == 'B'){
			countB ++;
		}
	}

	if ( countR > countB ){
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


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

using namespace std;
#define ll long long


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for (auto &x:a) cin >> x;
    for (auto &x:b) cin >> x;
    for (auto &x:c) cin >> x;

    vector<ll> temp(x * y);
    int indx = 0;
    for (int i = 0; i < x; i++) for (int j = 0; j < y; j++) temp[indx++] = a[i] + b[j];

    sort(temp.rbegin(), temp.rend());

    temp.resize(min(k, (int) temp.size()));

    vector<ll> res(temp.size() * z);
    indx = 0;
    for (int i = 0; i < temp.size(); i++) for (int j = 0; j < z; j++) res[indx++] = temp[i] + c[j];

    sort(res.rbegin(), res.rend());
    for (int i = 0; i < k; i++) cout << res[i] << '\n';


    return 0;
}

Measured memory_bytes: 31616
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    string pres, t;
    cin >> pres >> t;
    string ans;
    for (int i = 0; i + t.size() <= pres.size(); i++) {
        bool ok = true;
        string s = pres;
        for (int j = 0; j < t.size(); j++) {
            if (s[i + j] == t[j]) continue;
            if (s[i + j] == '?') s[i + j] = t[j];
            if (s[i + j] != '?' && s[i + j] != t[j]) {
                ok = false;
                break;
            }
        }
        if (ok) ans = s;
    }

    if (ans.size() == 0) {
        cout << "UNRESTORABLE" << endl;
    } else {
        for (int i = 0; i < ans.size(); i++) {
            if (ans[i] == '?') ans[i] = 'a';
        }
        cout << ans << endl;
    }
    return 0;
}

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

// コンテスト中のみ
#define int long long


#define ll long long
#define rep(i,n) for(int i = 0; i < (n); i++)
int MOD = 1000000007;
const int inf = 1001001001;
const ll INF = 1LL << 60;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	int cntr = 0, cntw = 0;
	rep(i,n)
	{
		if (s[i] == 'R')cntr++;
		else cntw++;
	}
	ans = min(cntr, cntw);
	vector<int>q;
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == 'R') {
			q.push_back(i);
		}
	}
	int res = 0;
	int idx = 0;
	rep(i, n) {
		if (s[i] == 'W') {
			if (idx < q.size() && i < q[idx]) {
				res++;
				idx++;
			}
			else {
				break;
			}
		}
	}
	ans = min(ans, res);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5472
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define MOD 2019LL
typedef long long LL;
template<class T> inline void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const LL LLINF = 1000000000;

int main(void) {
	LL L, R;
	cin >> L >> R;

	LL ans = LLINF;
	for (LL i = L; i <= R-1; i++)
	{
		for (LL j = i+1; j <= R; j++)
		{
			chmin(ans, (i*j)%MOD);

			if (ans == 0) {
				goto OUTPUT;
			}
		}
	}
	OUTPUT:
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int D,p[10],c[10],G,ans=1000000000;
int main(){
    cin>>D>>G;
    G/=100;
    for(int i=0;i<D;i++){
        cin>>p[i]>>c[i];
        c[i]/=100;
    }
    for(int i=0;i<1<<D;i++){
        int sum=G,num=0,Max=-1;
        for(int j=0;j<D;j++){
            if(i>>j&1){
                num+=p[j];
                sum-=(p[j]*(j+1)+c[j]);
            }else Max=j;
        }
        for(int j=0;j<p[Max]-1&&0<sum;j++){
            sum-=(Max+1);
            num++;
        }
        if(sum>0) continue;
        ans=min(ans,num);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
//配列の添字ズレに注意
//=に注意

int main(){
  int n,x,t; cin>>n>>x>>t;
  //string s; cin>>s;
  
  
  cout<<(n%x==0?t*(n/x):t*(n/x+1))<<endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main()
{
int i=0, n,f=0;
cin>>n;
while(f==0)
{
if(((i*i)<=n)&&((i+1)*(i+1)>n))
{
cout<<i*i;
f=1;
goto x;
}
i++;
}
x:
return 0;
}

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

#define N 200000
#define M 100

int main() {
	int n;

	cin >> n;

	if (n >= 30) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<deque>
#include<string>
#include<map>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>

using namespace std;


int main(void) {
	int n, a; cin >> n;
	int sum = 0;

	for (int i = 0; i < n; i++) {
		cin >> a;
		if (a % 2 == 1) {
			sum++;
		}
	}

	if (sum % 2 == 1) { cout << "NO" << endl; }
	else { cout << "YES" << endl; }

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c;
int main()
{
    cin>>a>>b>>c;
    for(int i=1; i<=1000; ++i)
    {
        if((a*i)%b==c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int a,b,c;
	cin>>a>>b>>c;
	int ans=a+b+c;
	int m=max({a,b,c});
	ce(ans-m)
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repl(i, l, r) for (int i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a + b == 15) cout << "+" << endl;
    else if(a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
listA = list(map(int, input().split()))
listA.sort()
countL =[]

index=0
beforeN=0
count=0
while index < len(listA):
    if index ==0:
        beforeN = listA[index]
        count+=1
    else:
        if listA[index] == beforeN:
            count+=1
        else:
            countL.append(count)
            beforeN = listA[index]
            count=1
    index+=1
countL.append(count)

if len(countL)== k:
    print(0)
else:     
    countL.sort()
    index2 =0
    sum =0
    while index2 < len(countL)-k:
        sum+=countL[index2]
        index2+=1
    print(sum)

Measured memory_bytes: 25468
#include "bits/stdc++.h"
// Custom Header {{{
#define ALL(x) x.begin(), x.end()
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}}

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

    const auto f = [](i64 x) -> i64 {
        return
            6 * ((x + 1) / 2) +
            5 * (x / 2);
    };

    i64 X;
    cin >> X;

    i64 ok = i64(1e15);
    i64 ng = 0;

    while(ok - ng > 1) {
        i64 mid = (ok + ng) / 2;
        if (f(mid) >= X) ok = mid;
        else ng = mid;
    }

    cout << ok << endl;

    return 0;
}

// vim: set foldmethod=marker :


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;


int main(){
  int A,B,H,M;
  cin>>A>>B>>H>>M;
  double kakudo = abs(H*30 + M*0.5 - 6*M);
  kakudo = kakudo * M_PI / 180.0;
  double ans;
  ans = sqrt(A*A+B*B-2*A*B*cos(kakudo));
  cout <<setprecision(10) << ans << endl;
  return 0;
}



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

int main() {
  long long N,ans=202020202020;
  cin >> N;
  vector<long long> A(N);
  cin >> A[0];
  for(int i=1;i<N;i++){
    cin >> A[i];
    A[i] += A[i-1];
  }
  
  for(int i=0;i<N-1;i++){
    long long x = A[i] , y = A[N-1]-A[i];
    ans = min(ans,abs(x-y));
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int N;
	std::cin >> N;
	int count = 0;
	std::array<int, 6> digit = { 1,10,100,1000,10000,100000 };
	auto beg = digit.begin();
	auto end = digit.end();
	for (int i : boost::irange(1, N + 1))
	{
		if ((std::upper_bound(beg, end, i) - beg) % 2 == 1)
		{
			++count;
		}
	}
	std::cout << count << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 256
import itertools as itr

def solve(n, x):
    return [sum(i) for i in itr.combinations(range(1, n+1), 3)].count(x)

if __name__ == '__main__':
    while True:
        n, x = [int(i) for i in input().split()]
        if n == x == 0: break
        print(solve(n, x))

Measured memory_bytes: 8076
import sys
 
N = int(input())
A = list(map(int, input().split()))
Ans = 1

for j in range(N):
  if A[j] == 0:
    Ans = 0
    print(Ans)
    sys.exit()    

for i in range(N):
  Ans = Ans * A[i]
  if Ans > 1000000000000000000:
    Ans = -1
    print(Ans)
    sys.exit()
  
 
print(Ans)

Measured memory_bytes: 21636
#include "math.h"
#include <algorithm>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
#define ifor(i, a, b) for (int i = (a); i < (b); i++)
#define rfor(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long double ld;
typedef long long int lli;
typedef complex<double> P;
const double eps = 1e-11;
int vex[4] = {1, 0, -1, 0};
int vey[4] = {0, 1, 0, -1};
typedef vector<double> Vec;
typedef vector<int> vec;
typedef vector<Vec> MAT;
typedef vector<vec> mat;
lli MOD = 1000000007;
lli INF = 1e17;
struct edge {
    lli to, cap, rev;
    edge(lli to, lli cap, lli rev)
    {
        this->to = to;
        this->cap = cap;
        this->rev = rev;
    }
};

#define MAX_V 100005
vector<edge> G[MAX_V];
lli level[MAX_V];
lli iter[MAX_V];
void add_edge(lli from, lli to, lli cap)
{
    G[from].push_back(edge(to, cap, G[to].size()));
    G[to].push_back(edge(from, 0, G[from].size() - 1));
}
lli gcd(lli a, lli b)
{
    return b > a ? gcd(b, a) : (b == 0 ? a : gcd(b, a % b));
}
void bfs(lli s)
{
    //memset(level, -1, sizeof(level));
    rep(i, MAX_V) level[i] = -1;
    queue<lli> que;
    level[s] = 0;
    que.push(s);
    while (!que.empty()) {
        lli v = que.front();
        que.pop();
        for (lli i = 0; i < G[v].size(); i++) {
            edge& e = G[v][i];
            if (e.cap > 0 && level[e.to] < 0) {
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}
lli dfs(lli v, lli t, lli f)
{
    if (v == t)
        return f;
    for (lli& i = iter[v]; i < G[v].size(); i++) {
        edge& e = G[v][i];
        if (e.cap > 0 && level[v] < level[e.to]) {
            lli d = dfs(e.to, t, min(f, e.cap));
            if (d > 0) {
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}
lli max_flow(lli s, lli t)
{
    lli flow = 0;
    while (true) {
        bfs(s);
        if (level[t] < 0)
            return flow;
        //memset(iter, 0, sizeof(iter));
        rep(i, MAX_V) iter[i] = 0;
        lli f;
        while ((f = dfs(s, t, INF)) > 0) {
            flow += f;
        }
    }
}
void init()
{
    rep(i, 2005)
    {
        G[i].clear();
        level[i] = 0;
        iter[i] = 0;
    }
}
signed main()
{

    lli n;

    cin >> n;
    lli s = n;
    lli v = n + 1;
    vector<lli> a(n);
    lli sum = 0;
    lli inf = 1e17;
    rep(i, n)
    {
        cin >> a[i];
        if (a[i] > 0) {
            add_edge(i, v, a[i]);
            sum += a[i];
        } else {
            add_edge(s, i, -a[i]);
        }
    }
    rep(i, n)
    {
        lli f = i + 1;
        for (lli j = 2 * f; j <= n; j += f) {
            add_edge(i, j - 1, inf);
        }
    }
    cout << sum - max_flow(s, v) << 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 REP(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

int dp[101][10001];

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, W;
    cin >> n >> W;
    int v[n], w[n];
    rep(i, n) cin >> v[i] >> w[i];

    rep(i, n) {
        rep(j, 10001) {
            if (j < w[i]) dp[i+1][j] = dp[i][j];
            else if (j >= w[i]) dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
        }
    }
    cout << dp[n][W] << endl;

    return 0;
}



Measured memory_bytes: 7148
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

dp = [0] * N
dp[0] = 0
dp[1] = dp[0] + abs(H[0] - H[1])
for i in range(2, N):
    l = []
    if i <= K:
        for j in range(i):
            l.append(dp[j] + abs(H[j] - H[i]))
            dp[i] = min(l)
    else:
        for j in range(1, K + 1):
            l.append(dp[i - j] + abs(H[i - j] - H[i]))
            dp[i] = min(l)

print(dp[N - 1])

Measured memory_bytes: 84552
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

int main(){

    int n,k;cin>>n>>k;
    int sticks[n];
    fore(i,0,n){
        cin>>sticks[i];
    }
    sort(sticks,sticks+n);
    ll ans = 0;
    fore(i,0,k){
        ans += sticks[n-i-1];
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sun Feb 16 21:00:33 JST 2020
 **/

signed main() {
    vector<Int> a(3);
    REP(i, 3) cin >> a[i];
    sort(a.begin(), a.end());
    bool ans = a[0] != a.back() && (a[0] == a[1] || a[1] == a[2]);
    cout << (ans ? "Yes" : "No") << endl;
}


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

vector<long long> luca(int x){
vector<long long> a(x+1);
  a.at(0)=2;
    a.at(1)=1;
  for (int i=0;i<x+1;i++){
    if(i>1){
      a.at(i)=a.at(i-1)+a.at(i-2);
    }
  }
  return a;
}

int main() {
 int N;
  cin>>N;
  cout<<luca(N).at(N)<<endl;
}


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

using namespace std;


char convert(char k)
{
    if(k=='1')
    {
        return '9';
    }
    if(k=='9')
    {
        return '1';
    }
}

int main()
{
    string str;
    cin >> str;

    for(int i = 0; i < 3; i++)
    {
    cout << convert(str[i]);
    }
    cout << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
int n,a[maxn];
int main()
{
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if((i&1)&&(a[i]&1))
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#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 FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const LL MOD = 1000000007;
const int N = 2005;
int s[N], t[N];
LL dp[N][N];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	REP(i, n)scanf("%d", &s[i]);
	REP(i, m)scanf("%d", &t[i]);
	LL ret = 1;
	dp[0][0] = 0;
	FOR(i, 1, n+1) {
		FOR(j, 1, m+1) {
			if(s[i-1] == t[j-1])dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] + 1)%MOD;
			else dp[i][j] = (dp[i][j - 1] + dp[i - 1][j] - dp[i-1][j-1] + MOD)%MOD;
		}
	}
	cout << (dp[n][m]+1)%MOD << endl;
	return 0;

}

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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define RLOOP(i, N) for (int i =(int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

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

int main(){
  int n;
  cin>>n;
  ll sum=0;
  ll v[5];
  memset(v,0,sizeof(v));
  REP(i,n){
    string s;
    cin>>s;
    if(s[0]=='M')v[0]++;
    if(s[0]=='A')v[1]++;
    if(s[0]=='R')v[2]++;
    if(s[0]=='C')v[3]++;
    if(s[0]=='H')v[4]++;
  }
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        sum+=v[i]*v[j]*v[k];
      }
    }
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int e[110];
  for(int i=0; i<12; i++) cin >> e[i];
  sort(e,e+12);
  /*for(int i=0; i<12; i++){
    cout << e[i] << endl;
  }*/
  if(e[0]==e[3] && e[4]==e[7] && e[8]==e[11]) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}



Measured memory_bytes: 3132
#include <iostream>
using namespace std;
void func(int,int,double,int);
int p,q,a,n,cnt;
double k;
 
int main(){
  while(1){
    cin>>p>>q>>a>>n;
    if(!p&&!q&&!a&&!n) break;
    k=1.0*p/q;
    cnt=0;
    func(0,1,0,1);
    cout<<cnt<<endl;
  }
  return 0;
}
 
void func(int x,int w,double y,int I){
  if(-0.00000001<=k-y&&k-y<=0.00000001) cnt++;
  if(x==n) return ;
  for(int i=I;w*i<=a;i++){
    if(y+1.0/i>k+0.01) continue;
    func(x+1,w*i,1.0/i+y,i);
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;
const ll LINF = 1e18;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> x(m);
  vector<ll> l(m-1,0);
  
  rep(i,m) cin >> x[i];
  sort(all(x));
  rep(i,m-1) {
    l[i] = abs(x[i+1]-x[i]); 
  }
  sort(rall(l));
 if(n >= m) {
   cout << 0 << endl;
   return 0;
 }
 ll ans = 0;
 for(int i=0;i<(l.size(),n-1);i++){
   ans += l[i];
 }
 ans = x[m-1] - x[0] -ans;
 cout << ans<< endl;
  
}

Measured memory_bytes: 1408
import copy
import queue
q=queue.Queue()
dx=[-1,0,1,0]
dy=[0,1,0,-1]
n,m=map(int,input().split())
b=[list(input()) for i in range(n)]
def abc(s,sy,sx):
    q=queue.Queue()
    for i in range(n):
        if 'S' in s[i]:
            sy=s[i].index('S')
            sx=i
            break
    # for i in range(n):
    #     if 'G' in s[i]:
    #         gy=s[i].index('G')
    #         gx=i
    #         break
    d=[[-1 for i in range(m)] for j in range(n)]
    q.put([sx,sy])
    d[sx][sy]=0
    while not q.empty():
        p=q.get()
        # if p[0]==gx and p[1]==gy:
        #     break
        for i in range(4):
            nx=p[0]+dx[i]
            ny=p[1]+dy[i]
            if 0<=nx<n and 0<=ny<m and s[nx][ny]!='#' and d[nx][ny]==-1:
                q.put([nx,ny])
                d[nx][ny]=d[p[0]][p[1]]+1
    return d

s=copy.deepcopy(b)
res=0
for i in range(n):
    for j in range(m):
        if s[i][j]==".":
            a=abc(s,j,i)
            for k in range(n):
                a_max=max(a[k])
                if res<a_max:
                    res=a_max
print(res)


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

using namespace std;

int main(void)
{
    int n, k, L[51], i, sum = 0;

    cin >> n >> k;
    for(i = 0; i < n; i++){
        cin >> L[i];
    }

    sort(L, L + n, greater<int>());

    for(i = 0; i < k; i++){
        sum += L[i];
    }

    cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>

using namespace std;

int num_digits(long n) {
	int i = 1;
	while (n >= 10) { n /= 10; i++; }
	return i;
}

int main(int argc, char *argv[]) {
	long N;
	cin >> N;

	int ans = 100;
	for (long A = 1; A <= sqrt(N); A++) {
		if (N % A != 0) continue;

		long B = N / A;
		ans = min(ans, max(num_digits(A), num_digits(B)));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <map>
#define debug(x) std::cerr << #x << " = " << (x) << std::endl 

using namespace std;
typedef long long LL;
const int maxn =  1e5;

string s;

int main()
{	
	while(cin >> s)
	{
		int f = 1;
		int len = s.length();
		int sum = 0;
		for(int i = 0; i < len; i++)
		{
			if(s[i] <= 'Z' && s[i] >= 'A') sum++;
		}
		if(sum != 2) f = 0;
		if(s[0] != 'A') f = 0;
		sum = 0;
		for(int i = 2; i <= len - 2; i++)
			if(s[i] == 'C') sum++;
		if(sum != 1) f = 0;
		if(f ==  1) printf("AC\n");
		else printf("WA\n");
	}
	return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))
out = [0]*9
for i in range(N):
    if A[i]>=3200:
        out[8] += 1
    else:
        out[A[i]//400]=1
MIN = sum(out[0:8])
MAX = MIN + out[8]
if MIN>=1:
    print(MIN, MAX)
else:
    print(1,MAX)

Measured memory_bytes: 61856
#include <stdio.h>

int main(void)
{
    int N,i;
    double A[200],sum=0;

    scanf("%d",&N);
    for(i=0; i<N; i++){
        scanf("%lf",&A[i]);
    }

    for(i=0; i<N; i++){
        sum+=1/A[i];
    }

    printf("%lf",1/sum);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<queue>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
typedef long long ll;
using namespace std;
ll const MAX = 1005;
ll n;
ll a[MAX];
ll ans[MAX];

int main() {
	cin >> n;
	bool flag = 1;
	ll odd_sum = 0; ll even_sum = 0;
	ll odd_cnt = 0; ll even_cnt = 0;
	REP(i, 1, n) {
		cin >> a[i];
		if (a[i] >= 0) {
			flag = 0;
			if (i % 2 == 0) {
				even_sum += a[i];
				even_cnt++;
			}
			else {
				odd_sum += a[i];
				odd_cnt++;
			}
		}
	}
	if (flag) {
		ll max_v = a[1];
		ll max_i = 1;
		REP(i, 2, n) {
			if (max_v < a[i]) {
				max_v = a[i];
				max_i = i;
			}
		}
		cout << max_v << endl << n - 1 << endl;
		for (ll i = n; i >= max_i + 1; i--) {
			cout << i << endl;
		}
		REP(i, 1, max_i - 1) {
			cout << 1 << endl;
		}
		return 0;
	}
	ll cur, next, cnt;
	if (odd_sum > even_sum) {
		cur = next = n - (n % 2 == 0);
		cnt = odd_cnt;
	}
	else {
		cur = next = n - (n % 2 == 1);
		cnt = even_cnt;
	}
	cout << max(odd_sum, even_sum) << endl;
	while (a[cur] < 0) {
		next = cur = cur - 2;
	}
	ll ans_cnt = 0;
	for (ll i = n; i > cur; i--) {
		ans_cnt++;
		ans[ans_cnt] = i;
	}
	REP(i, 1, cnt - 1) {
		next -= 2;
		while (a[next] < 0) {
			next -= 2;
		}
		while (cur > next) {
			ll erase = (cur + next) / 2;
			ans_cnt++;
			ans[ans_cnt] = erase;
			cur -= 2;
		}
	}
	REP(i, 1, cur - 1) {
		ans_cnt++;
		ans[ans_cnt] = 1;
	}
	cout << ans_cnt << endl;
	REP(i, 1, ans_cnt) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s=new List<int>();
      static List<int> p=new List<int>();
        static List<int> m=new List<int>();
    static decimal result;
static Hashtable ht=new Hashtable();
static int N,M;
    static void Main()
    {
Read1();
      Read2();
//合計値が最大になればＯＫ。
//マイナスはそのまま，プラスは一度他のマイナスから引いてやってからベースに結果に引き渡す。      
//
      s.Sort();
for(int i=0;i<N;i++){
if(s[i]>=0){p.Add(s[i]);}else{m.Add(s[i]);}
}
if(m.Count==0){for(int i=1;i<p.Count;i++){result+=p[i];}result-=p[0];}      
else if(p.Count==0){for(int i=0;i<m.Count-1;i++){result-=m[i];}result+=m[m.Count-1];}                  
else{int pr=p[0];
     int mr=m[0];
     for(int i=1;i<p.Count;i++){mr-=p[i];}
      for(int i=1;i<m.Count;i++){pr-=m[i];}    
     result=pr-mr;
    }
                    Console.WriteLine(result.ToString());
      
if(m.Count==0){
  result=p[0];
    for(int i=1;i<p.Count-1;i++){
                      Console.WriteLine(result.ToString() + " " + p[i]);
result-=p[i];}
  Console.WriteLine(p[p.Count-1] + " " + result.ToString());
  }      
else if(p.Count==0){
  result=m[m.Count-1];
  for(int i=0;i<m.Count-1;i++){
  Console.WriteLine(result.ToString() + " " + m[i]);
    result-=m[i];
  }}                  
else{int pr=p[0];
     int mr=m[0];
     for(int i=1;i<p.Count;i++){
  Console.WriteLine(mr.ToString() + " " + p[i]);       
       mr-=p[i];}
      for(int i=1;i<m.Count;i++){
  Console.WriteLine(pr.ToString() + " " + m[i]);        
        pr-=m[i];}
   Console.WriteLine(pr + " " + mr);    
     result=pr-mr;
    }
      
      
    }

    static void Read1()
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()
    {
      
        string[] tmp=Console.ReadLine().Split(' ');
for(int i=0;i<N;i++){s.Add(int.Parse(tmp[i]));}

}
}


Measured memory_bytes: 29512
import sys
from collections import defaultdict as dd
from bisect import bisect_left as bl
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
cs = [0] * (N + 1)
d = dd(list)
res = 0
for i in range(N):
  cs[i + 1] = cs[i] + A[i]
for i in range(1, N + 1):
  d[cs[i]].append(i)
for i in range(N):
  x = bl(d[cs[i]], i + 1)
  res += max(len(d[cs[i]]) - x, 0)
  #print(res, i)
#print(d)
#print(cs)
print(res)

Measured memory_bytes: 117324
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define yawn ios_base::sync_with_stdio(false); cin.tie(NULL);
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
int freq1[300005];
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int main()
{
    yawn;
    int a,b;
    cin>>a>>b;
    cout<< (a*3+b)/2;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
  val sq = {x:Int -> x*x}
  val N = readLine()!!.toInt()
  val A = readLine()!!.split(" ").map(String::toInt)
  val avr = A.average()
  val avrI = avr.toInt() + if(avr-avr.toInt() < 0.5)0 else 1
  print(A.map{sq(it-avrI)}.sum())
}

Measured memory_bytes: 36076
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,n)  for(ll i=0;i<n;i++)
#define fb(i,n) for(ll i=n-1;i>=0;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int,int> pii;
int main()
{
	IOS;
	//int t; cin>>t;
	int t=1;
	while(t)
	{
		int n; cin>>n; int a[n]; for(int i=0;i<n;i++) cin>>a[i];
		int z=pow(10,5)+1;
		int v[z]={0};
		ll sum=0;
		for(int i=0;i<n;i++)
		{
			sum=sum+a[i];
			v[a[i]]++;
		}
		int q; cin>>q;
		while(q)
		{
			int b,c; cin>>b>>c;
			int temp=v[b];
			v[b]=0;
			v[c]=v[c]+temp;
			sum=sum+temp*(c-b);
			cout<<sum<<"\n";
			q--;
		}
		t--;
	}
	return 0;
}

Measured memory_bytes: 4416
#include <stdio.h>
#include <iostream>
using namespace std;

int main()
{
  int a;
  int b;
  double d, r, f;

  cin >> a >> b;

  d = a / b;
  r = a - b * d;
  f = 1.0 * a / b;

  printf("%lf %lf %lf\n", d, r, f);

  return 0;
}


Measured memory_bytes: 3196
#include<iostream>
#include<cstdio>
#include<iomanip>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

#define ld  long double
#define ll  long long int
#define ull unsigned long long int
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,s,n) for(int i=s;i<n;i++)

const int    INF = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1);

//切り上げ整数除算
int divRoundUp(const int& a, const int& b) { return (a + b - 1) / b; }
//四捨五入
int roundOff(const double& a) { return (int)(a + 0.5); }

using namespace std;

void Main() {
	int N; cin >> N;
	string str; cin >> str;
	
	str.erase(unique(ALL(str)), str.end());

	cout << str.size() << "\n";
}

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

	Main();

	return 0;
}

Measured memory_bytes: 512