akhauriyash/Code-Regression huggingface dataset:
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;
string S[1000000];

string ans = "No";

void solve(){
	vector<pair<LL,LL>> left2right;
	vector<pair<LL,LL>> right2left;
	for(int i=0;i<N;i++){
		LL unclosed = 0;//閉じられていない(の数
		LL min_unclosed = 0;//最下点
		for(int j=0;j<S[i].size();j++){
			if(S[i][j]=='(') unclosed++;
			else unclosed--;
			min_unclosed = min(min_unclosed,unclosed);
		}
		if(unclosed>=0) left2right.push_back(pair<LL,LL>(min_unclosed,unclosed));
		else right2left.push_back(pair<LL,LL>(min_unclosed-unclosed,-unclosed));
	}
	sort(left2right.begin(),left2right.end(),greater<pair<LL,LL>>());
	sort(right2left.begin(),right2left.end(),greater<pair<LL,LL>>());

	LL now = 0;
	for(int i=0;i<left2right.size();i++){
		LL down = left2right[i].first;
		LL up = left2right[i].second;
		//cout << down << " " << up << endl;
		if(now+down<0) return;
		now += up;
	}
	LL highest = now;
	now = 0;
	for(int i=0;i<right2left.size();i++){
		LL down = right2left[i].first;
		LL up = right2left[i].second;
		if(now+down<0) return;
		now += up;
	}
	if(highest==now) ans = "Yes";
}

int main(){
    cin >> N;
    for(int i=0;i<N;i++)cin >> S[i];

    solve();

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

Measured memory_bytes: 42052
/*
AizuOnline A0514
Quality Checking
*/
#include <stdio.h>

struct kekka {int dengen;int motor;int cable;int res;};
struct kekka kensa[1000];
int a,b,c;
int N;
int buhin[100];
main()
{ int i;

  while(EOF != scanf(" %d %d %d",&a,&b,&c) && (a||b||c))
    {
      scanf(" %d",&N);
      /*      printf("%d %d %d %d\n",a,b,c,N);*/
      for(i=0;i<N;i++)
	{
	  scanf(" %d %d %d %d",\
		&(kensa[i].dengen),\
                &(kensa[i].motor),\
                &(kensa[i].cable),\
                &(kensa[i].res));
	}

      for(i=1;i<=a+b+c;i++)
	buhin[i]=2;

      for(i=0;i<N;i++)
	if(kensa[i].res == 1)
	  {
	    buhin[kensa[i].dengen]=1;
	    buhin[kensa[i].motor ]=1;
	    buhin[kensa[i].cable ]=1;
	  }

      for(i=0;i<N;i++)
	if(kensa[i].res == 0)
	  {
	    if(buhin[kensa[i].dengen]==1&&buhin[kensa[i].motor]==1)
	      buhin[kensa[i].cable ]=0;
	    if(buhin[kensa[i].dengen]==1&&buhin[kensa[i].cable]==1)
	      buhin[kensa[i].motor]=0;
	    if(buhin[kensa[i].motor]==1&&buhin[kensa[i].cable]==1)
	      buhin[kensa[i].dengen]=0;
	  }
      
      for(i=1;i<=a+b+c;i++)
	printf("%d\n",buhin[i]);      
    }
  return(0);
}

Measured memory_bytes: 0
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
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; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();
void solve(long long A, long long B);

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

ll f(ll n){
    return n*n;
}

void Main(){
    ll N;
    cin >> N;
    vec<ll> X(N);
    ll sum = 0;
    REP(i, N){
        cin >> X[i];
        sum += X[i];
    }
    sum/=N;
    ll v1=0, v2=0, v3=0;
    REP(i, N){
        v1 += f(X[i]-sum+1);
        v2 += f(X[i]-sum-1);
        v3 += f(X[i]-sum);
    }
    cout << min({v1, v2, v3}) << el;
}



Measured memory_bytes: 384
import java.util.*;
 
public class Main {
	public static int[] ans;
	public static int max = 0;
	public static int n;
	public static int m;
	public static int[][] qs;
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		m = sc.nextInt();
		int qn = sc.nextInt();
		ans = new int[n];
		qs = new int[qn][4];
		for(int i=0; i<qn; i++){
			qs[i][0] = sc.nextInt();
			qs[i][1] = sc.nextInt();
			qs[i][2] = sc.nextInt();
			qs[i][3] = sc.nextInt();
		}
		saiki(1, 1);
		System.out.println(max);
	}
	
	public static void saiki(int now, int keta){
		for(int i=now; i<=m; i++){
			ans[keta-1] = i;
			if(keta == n) {
				int tmp = 0;
				for(int[] q: qs){
					if(ans[q[1]-1] - ans[q[0]-1] == q[2]){
						tmp += q[3];
					}
				}
				max = Math.max(max, tmp);
				continue;
			}
			saiki(i, keta+1);
		}
	}
}


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

#ifdef LOCAL
#define DEBUG(...) cerr << #__VA_ARGS__ << ": ", debug(__VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename T, size_t N> ostream& operator << (ostream &os, const array<T, N> &a) {os << "("; for (int i=0; i<(int)N; i++) {if (i) os << ", "; os << a[i];} return os << ")";}
template<typename T> ostream& operator << (ostream &os, const vector<T> &v) {os << "["; for (int i=0; i<(int)v.size(); i++) {if (i) os << ", "; os << v[i];} return os << "]";}
void debug() {cerr << "\n";} template<typename T, typename... Args> void debug(T x, Args... args) {cerr << x << "; "; debug(args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    unordered_map<string, int> mp;
    for (int i=0; i<n; i++) {
        string s;
        cin >> s;
        mp[s]++;
    }

    int mx = 0;
    set<string> st;
    for (auto p : mp) {
        if (p.second > mx) {
            mx = p.second;
            st.clear();
        }
        if (p.second == mx)
            st.insert(p.first);
    }

    for (string s : st)
        cout << s << "\n";

    return 0;
}


Measured memory_bytes: 32072
N=int(input())
s=[]
t=[]
j=0
k=0
for i in range(N):
 a,b= input().split()
 s.append(a)
 t.append(int(b))
o=input()
for i in range(N):
 if j==1:
  k+=t[i]
 if s[i]==o:
  j+=1
print(k)

Measured memory_bytes: 3060
import math
N = int(input())
L = []
for i in range(5):
  A = int(input())
  L.append(A)
'''
#bottleneck:一番細い所(i,i+1)を考える。(X = min(L))
すると、1分あたりにX人運べる計算になる。Y分あたりにN人より N/Y = X so Y = ceil(N/X)
よってceil(N/X)がその細い所を全員通らせるのにかかる時間。
+スタートしてから細い所を使わない時間 = i-1
+全員が乗り終わってからゴールまで経過する時間 = 5-i
(1人ずつ通す　→　最後の人は遅くとも、5-i分前に乗ってないと。)
'''
print(math.ceil(N/min(L)) + 4)

  

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);

int main(){
    IOS;
    ll h,w,a,b;cin>>h>>w>>a>>b;
    f(i,0,h){
        f(j,0,w){
            ll x=(i<b)^(j<a);
            cout<<x;
        }
        cout<<endl;
    }
    return 0;  
} 

Measured memory_bytes: 1280
use std::io::*;
use std::str::FromStr;

fn main(){
    let n: i32 = read();
    let mut check = false;
    for i in 0..(n/4+1) {
        if (n - i * 4) % 7 == 0 {
            check = true;
        }
    }
    println!("{}", if check {"Yes"} else {"No"});
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>

using namespace std;

int main()
{
	int n;

	cin >> n;

	vector<int> vc(n);

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

	int ans = 0;
	for(int i = 0; i < n; ++i)
	{
		int c;
		cin >> c;
		ans += vc[i] > c ? vc[i] - c : 0;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int L, R, d;
    cin >> L >> R >> d;
    cout << R/d - (L - 1)/d << endl;
    return 0;
}

Measured memory_bytes: 3568
#include<iostream>
#include<string>
#include<algorithm>
#include<queue>
#include<cmath>
#include<set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> T;
typedef unsigned long long ll;




int main(){
    int N;
    int A[100000];
    cin >> N;
    for(int n=0;n<N;n++){
        cin >> A[n];
    }
    ll ans=0;
    ll min=1;
    
    ans += A[0]-1;
    min=2;
    for(int n=1;n<N;n++){
        if(A[n]<=min){
            if(A[n]==min){
                min++;
            }
        }else{
            ll tmp1=A[n]/min;
            ll tmp2=A[n]%min;
            if(tmp2==0){
                ans+=tmp1-1;
            }else{
                ans+=tmp1;
            }
        }
    }
    
    cout << ans << endl;
    
    
    
    
    return 0;
}


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


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

    int n;
    cin >> n;

    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];

    for (int i = 0; i < n - 1; i++) {
      for (int j = 0; j < n - 1; j++) {
        if (a[j] < a[j + 1]) {
          int temp = a[j];
          a[j] = a[j + 1];
          a[j + 1] = temp;
        }
      }
    }

    int alice = 0;
    int bob = 0;

    for (int i = 0; i < n; i++) {
      if (i % 2 == 0) {
        alice += a[i];
      } else {
        bob += a[i];
      }
    }
    cout << alice - bob << endl;
    return 0;
}

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

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

	void run() {
		Scanner sc = new Scanner();
		String s = sc.next();
		int n = s.length();
		long cntW = 0;
		for (int i = 0; i < n; ++i) {
			if (s.charAt(i) == 'W')
				++cntW;
		}
		if (cntW == 0) {
			System.out.println(0);
			return;
		}
		long ans = -cntW * (cntW - 1) / 2;
		for (int i = 0; i < n; ++i) {
			if (s.charAt(i) == 'W') {
				ans += i;
			}
		}
		System.out.println(ans);
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

}

class Scanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		return (int) nextLong();
	}
}


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

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int k;
    cin>>k;
    ll cs=0;
    for(i=1;i<=k+1;i++){
    	cs=cs*10+7;
    	if(cs%k==0){
    	    cout<<i<<endl;
			return 0;	
		}
		cs=cs%k;
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 3656
#ifdef ConanYu
#include "local.hpp"
#else
#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void Main();
#define debug(...) do { } while(0)
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  Main();
}
#endif

void Main() {
  int a, b; cin >> a >> b;
  if(a >= 13) cout << b << "\n";
  else if(a >= 6) cout << b / 2 << "\n";
  else {
    cout << "0\n";
  }
}


Measured memory_bytes: 256
from collections import deque


max_n = 110000
dp = [-1] * max_n  # -1を未探索とする
dp[0] = 0  # 初期条件の設定
n = int(input())
que = deque([])
que.append(dp[0])
while que:
    v = que.popleft()
    pow = 1
    while v + pow <= n:
        if dp[v + pow] == -1:
            dp[v + pow] = dp[v] + 1
            que.append(v + pow)
        pow *= 6
    pow = 1
    while v + pow <= n:
        if dp[v + pow] == -1:
            dp[v + pow] = dp[v] + 1
            que.append(v + pow)
        pow *= 9
# print(dp)
print(dp[n])

Measured memory_bytes: 43372
from functools import reduce

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd (a, b)

def multi_lcm(numbers):
    return reduce(lcm, numbers, 1)

n = int(input())
a = [int(i) for i in input().split()]

a_lcm = multi_lcm(a)
x = a_lcm - 1

score = 0
for i in range(n):
    score += x % a[i]

print(score)


Measured memory_bytes: 3812
# coding: utf-8
s=input()
n=len(s)
flg=False
flg_=False
a=0
b=0
for i in range(n):
    if s[i]=="C":
        a=i
        flg=True
        break
for i in range(n-1,-1,-1):
    if s[i]=="F":
        b=i
        flg_=True
        break
if flg and flg_ and a<b:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61820
import math

def a():
    s = input()
    if s == 'RRR':
        print(3)
    elif 'RR' in s:
        print(2)
    elif 'R' in s:
        print(1)
    else:
        print(0)


def b():
    pass



def c():
    pass



def d():
    pass


a()
# b()
# c()
# d()

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

int main()
{
 	int k, a, b;
  cin >> k >> a >> b;
 	for( ; a <= b; a++){
      if(a % k == 0){
      	cout << "OK\n";
        return 0;
      }
    }
  cout << "NG\n";
  return 0;
}

Measured memory_bytes: 3592
n = int(input())
v = list(map(int, input().split()))
v2 = sorted(v)

while len(v2)>0:
  if len(v2) == 1:
    print(v2[0])
    quit()
  new = (v2[0]+v2[1])/2
  v2.append(new)
  v2.pop(0)
  v2.pop(0)
  v2.sort()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int N;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  for (int i = 0; 4*i <= N; i++) {
    int rem = N - 4*i;
    if (rem % 7 == 0) {
      cout << "Yes" << endl;
      return 0;
    }
  }  
  cout << "No" << endl;

  return 0;
}

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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<string> result(N);

    for (int i = 0; i < N; i++) {
        cin >> result.at(i);
    }

    int AC = 0, WA = 0, TLE = 0, RE = 0;

    for (int i = 0; i < N; i++) {
        if (result.at(i) == "AC") AC++;
        if (result.at(i) == "WA") WA++;
        if (result.at(i) == "TLE") TLE++;
        if (result.at(i) == "RE") RE++;
    }
    cout << "AC " << "x " << AC << endl;
    cout << "WA " << "x " << WA << endl;
    cout << "TLE " << "x " << TLE << endl;
    cout << "RE " << "x " << RE << endl;
    return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
typedef long long lint;
const int N=1e5+5;
int n,val[N];

namespace utils{
	template <class T> inline void apn(T &x,const T y){x=x<y?x:y;}
	template <class T> inline void apx(T &x,const T y){x=x<y?y:x;}
	inline int nxi(){
		int x=0;
		char c;
		while(((c=getchar())>'9'||c<'0')&&c!='-');
		const bool f=(c=='-')&&(c=getchar());
		while(x=x*10-48+c,(c=getchar())>='0'&&c<='9');
		return f?-x:x;
	}
}
using namespace utils;

int main(){
#ifdef LOCAL
	freopen("range.in","r",stdin);
	freopen("range.out","w",stdout);
#endif
	n=nxi();
	for(int i=1; i<=n; ++i){
		val[i]=nxi();
	}
	int ans=0;
	for(int i=1,l=1; i<=n; ++i){
		if(i!=val[i]){
			if(l<i) ans+=(i-l+1)>>1;
			l=i+1;
		}
		else if(i==n){
			ans+=(i-l+2)>>1;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#define int long long
using namespace std;

int mabs(int x) {
    return x >= 0 ? x : -x;
}

signed main() {
    int n, k;
    cin >> n >> k;
    n %= k;
    int ans = n;
    for(int i = 1; i <= 50000000; ++i) {
        n = mabs(n - k);
        ans = min(ans, n);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;
const int JJJ = 1009;

char matrix[JJJ][JJJ];
int dp[JJJ][JJJ],f,c;




int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

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

    cin >> f >> c;
    for(int i = 1;i <= f;i++){
        for(int j = 1;j <= c;j++){
            cin >> matrix[i][j];
        }
    }
    dp[1][1] = 1;
    for(int i = 1;i <= f;i++){
        for(int j = 1;j <= c;j++){
            if(i == 1 && j == 1) continue;
            if(matrix[i][j] != '#'){
                if(matrix[i-1][j] != '#'){
                    dp[i][j] = (dp[i][j]+dp[i-1][j])%MOD;
                }
                if(matrix[i][j-1] != '#'){
                    dp[i][j] = (dp[i][j]+dp[i][j-1])%MOD;
                }
            }
        }
    }

    cout<<dp[f][c];








    return 0;
}
/*
3 4
...#
.#..
....

5 2
..
#.
..
.#
..

5 5
..#..
.....
#...#
.....
..#..


20 20
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................

*/

Measured memory_bytes: 5248
//----------------------------おまじない
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")
//----------------------------
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#define eb(i,j) emplace_back((i),(j))
#include <bits/stdc++.h>
using namespace std;
//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;
typedef long long ll;
const int mod = 1000000009;

ll n,d,m,posi;
double res;

int main(){
    cin >> n >> m >> d;
    m--;
    posi = (n-d);
    if (d) posi *= 2;
    cerr << posi << endl;
    res = posi;
    res = res/n/n*m;
    printf("%.11f\n",res);
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
##################################
# University of Wisconsin-Madison
# Author: Yaqi Zhang
##################################

import math
import sys

def degtorad(deg):
    return deg / 180.0 * math.pi

def main():
    a, b, h, m = map(int, input().split())
    alpha = m / 60 * 360
    beta = h / 12 * 360 + m / 60 * 30
    deg = abs(alpha - beta)
    c = math.sqrt(a * a + b * b - 2 * a * b * math.cos(degtorad(deg)))
    print("{:0.9f}".format(c))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9504
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
int n,t,x[SZ];
ll f[SZ],s[SZ];
int main()
{
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;++i)
		scanf("%d",x+i),s[i]=s[i-1]+x[i];
	ll ans=8e18;
	for(int i=1;i<=n;++i)
	{
		ll u=i*(ll)t;
		for(int j=n,c=1;j>=1&&u<=ans;++c)
		{
			int k=max(j-i+1,1);
			u+=(s[j]-s[k-1])*((c==1)?5:(2*c+1));
			j=k-1;
		}
		ans=min(ans,u);
	}
	cout<<ans+(ll)n*t<<"\n";
}


Measured memory_bytes: 3840
#include <iostream>

using namespace std;

int main()
{
    int i,j,H,W;
    cin>>H>>W;
    char arr[H][W];
    for(i=0;i<H;i++){
        for(j=0;j<W;j++)
            cin>>arr[i][j];
    }
   for(i=0;i<H;i++){
        for(j=0;j<W;j++)
            cout<<arr[i][j];
        cout<<endl;
        for(j=0;j<W;j++)
            cout<<arr[i][j];
        cout<<endl;}

    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int sum=0;
	vector <int> w(n);
	for (int i=0; i<n; i++){
		cin >> w[i];
		sum+=w[i];
	} 
	int t=1;
	int ans=1e9;
	while(t!=n-1){
		int s=0;
		for (int i=0; i<=t; i++) s+=w[i];
		if (abs(2*s-sum)<ans) ans = abs(2*s-sum);
		t++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cassert>
#include<string>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<set>
using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)
#define repeat(i,j,k) for(int__ i=(j);i<(int__)(k);i++)
#define all(v) v.begin(),v.end()

const int alpha_size = 'z' - 'a' + 1;

void visit(int now, vector<bool> &visited, const vector<set<int>> &E){
    visited[now] = true;
    for(int nxt : E[now]){
        if(not visited[nxt]){
            visit(nxt, visited, E);
        }
    }
}

bool solve(){
    int N; cin >> N;
    if(N == 0) return false;
    vector<int> d(alpha_size);
    vector<set<int>> E(alpha_size);
    rep(i, N){
        string s; cin >> s;
        int f = s.front() - 'a';
        int b = s.back() - 'a';
        ++d[f];
        --d[b];
        E[f].insert(b);
    }
    vector<bool> visited(alpha_size);
    rep(i, E.size()){
        if(E[i].size() > 0){
            visit(i, visited, E);
            break;
        }
    }
    bool flg = true;
    rep(i, alpha_size){
        if(d[i] != 0 or  (E[i].size() > 0 and not visited[i])) flg = false;
    }
    cout << (flg ? "OK" : "NG") << endl;
    
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    while(solve());
    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{	
	string s;
	cin >> s;
	string ans;

	if(s == "Sunny") ans = "Cloudy";
	if(s == "Cloudy") ans = "Rainy";
	if(s == "Rainy") ans = "Sunny";
	cout << ans << endl;
}


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

using namespace std;

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

    int h, w, n;
    cin >> h >> w >> n;
    h = max(h, w);
    cout << n / h + (n % h != 0) << '\n';

    return 0;
}

//      *   *  *****  *   *  *   *
//     *   *  *      **  *  *   *
//    *****  *****  * * *  *   *
//   *   *      *  *  **  *   *
//  *   *  *****  *   *   ***

//      ***** ***** *   * *     ***** *   * ***** *****
//        *  *   * *   * *       *   **  *   *   *   *
//       *  *   * ***** *       *   * * *   *   *****
//   *  *  *   *   *   *       *   *  **   *   *
//  ****  *****   *   ***** ***** *   *   *   *


Measured memory_bytes: 256
m = list(map(int, input().split()))
A = m[0]
B = m[1]
C = m[2]

ans = 0
m.sort()

while (m[0] != m[1] and m[0] != m[1] - 1):
    m[0] += 2
    ans += 1

if m[0] == m[1]:
    ans += m[2] - m[1]
else:
    m[0]+=1
    m[2]+=1
    ans+=1
    ans += m[2] - m[1]

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	if (A * N >= B) cout << B << endl;
	else cout << A * N << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <vector>

#define ll long long int

int main(int argc, char** argv) {
  ll n;
  std::cin >> n;
  std::vector<ll> a(n+1);
  std::vector<ll> b(n);
  for (ll i = 0; i < n+1; ++i) {
    std::cin >> a[i];
    // std::cout << "a[" << i << "]: " << a[i] << std::endl;
  }
  for (ll i = 0; i < n; ++i) {
    std::cin >> b[i];
    // std::cout << "b[" << i << "]: " << b[i] << std::endl;
  }

  ll sum = 0;
  for (ll i = 0; i < n; ++i) {
    ll f = std::min(a[i], b[i]);
    a[i] -= f;
    b[i] -= f;
    sum += f;

    ll f2 = std::min(a[i + 1], b[i]);
    a[i + 1] -= f2;
    b[i] -= f2;
    sum += f2;
  }

  std::cout << sum << std::endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
// #define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<(*i)<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;


int main() {

    int h,w,k;
    cin>>h>>w>>k;
    vs v(h);
    rep(i,h)cin>>v[i];
    int ans=0;
    rep(i,1<<h){
        rep(j,1<<w){
            vs W=v;
            si y;
            si x;
            rep(a,h)if((1<<a)&i)y.insert(a);
            rep(a,w)if((1<<a)&j)x.insert(a);
            rep(a,h){
                rep(b,w){
                    if(y.count(a)||x.count(b)){
                        W[a][b]='.';
                    }
                }
            }
            int co=0;
            rep(a,h){
                rep(b,w){
                    if(W[a][b]=='#'){
                        co+=1;
                    }
                }
            }
            if(co==k)ans++;
        }
    }
    fin(ans);
}



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

bool bucket[100000] = {};

int main(){
  int n;
  cin >> n;
  
  int r = 0; 
  int ans = 0;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    if(bucket[a]){
      r ++;
    }
    else{
      bucket[a] = true;
      ans ++;
    }
  }
  
  if(r % 2 == 1) ans = ans - 1;
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        boolean[][] cards = new boolean[4][13];
        int n = scan.nextInt();

        if (n == 52) return;
        while (n != 0) {
            char image = scan.next().charAt(0);
            int num = scan.nextInt() - 1;

            switch (image) {
                case 'S':
                    cards[0][num] = true;
                    break;
                case 'H':
                    cards[1][num] = true;
                    break;
                case 'C':
                    cards[2][num] = true;
                    break;
                case 'D':
                    cards[3][num] = true;
                    break;
            }
            n--;
        }
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 13; j++) {
                if (cards[i][j] == false) {
                    switch (i) {
                        case 0:
                            System.out.println("S " + (j + 1));
                            break;
                        case 1:
                            System.out.println("H " + (j + 1));
                            break;
                        case 2:
                            System.out.println("C " + (j + 1));
                            break;
                        case 3:
                            System.out.println("D " + (j + 1));
                            break;
                    }
                }
            }
        }
    }

}

Measured memory_bytes: 26064
#include<stdio.h>
int main(void){
	int n,t,j,maxv,minv;
	int R[200000];
	scanf("%d\n",&n);
	for(t=0;t<=n-1;t++){
		scanf("%d\n",&R[t]);
	}
	minv=R[0];
	maxv=R[1]-R[0];
	for(j=1;j<=n-1;j++){
		if(maxv<R[j]-minv){
			maxv=R[j]-minv;
			
		}
		if(minv>R[j]){
			minv=R[j];
		}
		
	}
	printf("%d\n",maxv);
	return 0;
}


Measured memory_bytes: 2568
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//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 SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1000000007;

LL mod_pow_fast(LL a,LL n){
    LL p = a;
    LL ret = 1;
    while(n){
        if(n & 1) ret = (ret * p) % MOD;
        n = n >> 1;
        p = (p * p) % MOD;
    }
    return ret;
}
LL mod_inv(LL x){
    return mod_pow_fast(x, MOD - 2);
}
LL mod_fact(LL n){
    LL ret = 1;
    for(LL i = 2; i <= n; i++){
        ret = (ret * i) % MOD;
    }
    return ret;
}
LL mod_comb(LL n, LL r){
    // nCr = n! * inv(r!) * inv((n-r)!)
    return (((mod_fact(n) * mod_inv(mod_fact(r))) % MOD) *
                            mod_inv(mod_fact(n-r))) % MOD;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,k;
    cin>>n>>k;
    // 3! / 2!1! 3c2
    // 2 * 3c1
    // 2
    // 3c0
    REP(i,k){
        // 青をしきる組み合わせ数 comb(青-1, 操作数(i+1) - 1)
        // 振り分け箇所 2,3,4,...
        // 振り分ける赤の数 n-k-(振り分け箇所-2)
        LL x = 2 + i; //振り分け箇所
        LL red = n - k - (x - 2);
        LL pat = mod_comb(k + i - (i+1), k - (i+1));
        if(red < 0){
            PUTS(0);
        }
        else{
            PUTS((pat * mod_comb(x + red - 1, red)) % MOD); //x+red! / x! red!
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli int
#define ulli unsigned long long int
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define loopl(i,a,b) for(lli i=a;i<b;i++) 
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define mod2 1000000006
#define inf 1000000000000000000
#define lld long double
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<lli>
#define vii vector<int>
#define is indexed_set
#define eps 0.000001
#define endl '\n'
#define mo 998244353
#define pi 3.141592653589793
#define FF first
#define SS second
using namespace std ;
 
const lli dx4[] = {-1, 0, 1, 0};
const lli dy4[] = {0, 1, 0, -1};
const lli dx8[] = {-1, 0, 1, 0, -1, -1, 1, 1};
const lli dy8[] = {0, 1, 0, -1, -1, 1, -1, 1};
 
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

#define N 2005

void solve()
{
    lli a;
    cin>>a;

    cout<<a + a*a + a*a*a<<endl;
}

int main()
{
/////////////////////////////////////
    fastio;
////////////////////////////////////  

    lli t;
    t=1;
    while(t--)
    {
        solve();
    }
}

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

int main() {

  int N, T;
  cin >> N >> T;

  int answer = 0;

  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      if (answer == 0){
        answer = c;
      } else {
        answer = min(answer, c);
      }
    }
  }

  if (answer == 0) {
    cout << "TLE" << endl;
  } else {
    cout << answer << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define F first
#define S second
//#define int long long

///My functions
void sread ( string &s ){ cin >> s ; s = '_' + s ; }
void sprint ( string &s ){ cout << s.substr( 1 , s.size() ) ; } 

//Constants
const int mxn = 3*1e5+5, inf = 1e9+7, mod = 1e9+7;
const long long infLL = 1e18+5;
const double EPS = 1e-9 , PI = acos(-1);

//Structs

//Variables
int n ; 
vector<int>v,g[mxn];
bitset<mxn>flag;
bool sol ;
string s;
unsigned long long ans , a , ar[mxn] ; 

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    cin >> n ; ans = 1 ; 

    for( int i = 1 ; i <= n ; i++ ) {
        cin >> ar[i] ; 
        if( ar[i] == 0 ){
            cout << 0 ; 
            return 0 ; 
        }
    }
    for( int i = 1 ; i <= n ; i++ ){ 

        a = ar[i] ; 
        
        if( (unsigned long long)( ans * a ) > 1'000'000'000'000'000'000 or ( ans * a ) < ans ){
        
             cout << -1 ; 
             return 0 ; 

        }

        ans *= a ; 

    }

    cout << ans ; 






    return 0;
}
























Measured memory_bytes: 11420
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,k,x,y,c=0;
  cin>>n>>k>>x>>y;
  for(int i=0;i<n;i++){
    if(i<k)
      c+=x;
    else
      c+=y;
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int turn =0;
  int flag=0;
  while(a>0 && c>0){
    if(turn ==0){
      c=c-b;
      if(c<=0){
      	cout<<"Yes"<<endl;
      	flag=1;
      	break;
      }
      turn=1;
    }
    if(turn == 1){
      a=a-d;
      turn=0;
    }
  }
  if(flag==0){
  	cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
const long long maxn=200004;
const long long mod=998244353,inf=1000000007;
string ans;
long long n;
int main(){
	cin>>n;
	for(long long i=1;n>=i;i*=26) n-=i,ans.push_back('a');
	for(long long i=ans.size()-1;i>=0&&n;--i)
	{
		ans[i]=char(n%26+'a');
		n/=26;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3592
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<bits//stdc++.h>
#include<functional>
using namespace std;
struct P{
	long long cost,pos;
};
struct B{
	long long cost,to;
};
bool operator<(P a,P b){
	return a.cost<b.cost;
}
bool operator>(P a,P b){
	return a.cost>b.cost;
}
vector<B>e[10];
int main() {
	int n;
	while(cin>>n&&n!=0){
		for(int i=0;i<10;i++) e[i].clear();
		long long a,b,c,ma=0;
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			e[a].push_back(B{c,b});
			e[b].push_back(B{c,a});
			ma=max(a,max(b,ma));
		}
		P sum;
		sum.cost=1000000;
		for(int i=0;i<=ma;i++){
			priority_queue<P, vector<P>, greater<P>>p;
			long long b[10];
			for(int j=0;j<10;j++) b[j]=1000000;
			b[i]=0;
			p.push(P{0,i});
			while(!p.empty()){
				P t=p.top();p.pop();
				for(int j=0;j<(int)e[t.pos].size();j++){
					if(b[t.pos]+e[t.pos][j].cost<b[e[t.pos][j].to]){
						b[e[t.pos][j].to]=b[t.pos]+e[t.pos][j].cost;
						p.push(P{b[e[t.pos][j].to],e[t.pos][j].to});
					}
				}
			}
			long long sum2=0;
			for(int j=0;j<=ma;j++){
				sum2+=b[j];
			}
			if(sum.cost>sum2){
				sum.cost=sum2;
				sum.pos=i;
			}
		}
		cout<<sum.pos<<" "<<sum.cost<<endl;
	}
}

Measured memory_bytes: 3148
n=int(input())
nlst=[input() for i in range(n)]
m=int(input())
mlst=[input() for i in range(m)]
ans=0
for i in nlst:
    plus=nlst.count(i)
    minus=mlst.count(i)
    ans=max(ans,plus-minus)
    
print(ans)

Measured memory_bytes: 9184
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
 
typedef pair<int, int> P1;
bool pairCompare1(const P1& firstElof, const P1& secondElof)
{
    return firstElof.first < secondElof.first;
}

typedef pair<int, string> P2;
bool pairCompare2(const P2& firstElof, const P2& secondElof)
{
    return firstElof.first < secondElof.first;
}

int main() {

    int N, M;
    cin >> N >> M;

    vector<vector<pair<int, int>>> N_table(N+1);

    int P, Y;
    for (int i = 0; i < M; i++ ) {
        cin >> P >> Y;
        pair<int, int> p = make_pair(Y, i);
        N_table[P-1].push_back(p);
    }

    vector<pair<int, string>> ID_table;

    for (int i = 0; i < N; i++ ) {
        sort(N_table[i].begin(), N_table[i].end(), pairCompare1);
        for (int j = 0; j < N_table[i].size(); j++) {
            //string pref = to_string(i+1), id = to_string(j+1);
            //string str = string(6 - pref.size(), '0') + pref + string(6 - id.size(), '0') + id;
            char id[20];
            sprintf(id, "%06d%06d", (i+1),(j+1));
            string str = id;
            pair<int, string> p = make_pair(N_table[i][j].second, str);
            ID_table.push_back(p);
        }
    }

    sort(ID_table.begin(), ID_table.end(), pairCompare2);
    for (int i = 0; i < ID_table.size(); i++)  cout << ID_table[i].second << endl;


    return 0;
}

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

int main ()
{
  int a[10];
  int n;

  while (cin >> n){
    for (int i = 0; i <= 9; i++){
      a[i] = 0;
    }

    for (int i = 9; i >= 0; i--){
      if (n >= pow(2, i)){
        n -= pow(2, i);
        a[i]++;
      }
    }
    for (int i = 0; i <= 9; i++){
      if (a[i] == 1){
        cout << (int)pow(2, i);
        for (int j = i + 1; j <= 9; j++){
          if (a[j] == 1){
            cout << " " << (int)pow(2, j);
          }
        }
        cout << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 1200
using System;
class Program {
  static void Main(string[] args) {
    string[] input = Console.ReadLine().Split(' ');
    int n = int.Parse(input[0]);
    int r = int.Parse(input[1]);
    if (n >= 10) {
      Console.WriteLine(r);
    } else {
      Console.WriteLine(r + 100*(10-n));
    }
  }
}

Measured memory_bytes: 13140
import sys

input=sys.stdin.buffer.readline


#sys.setrecursionlimit(10**9)
#from functools import lru_cache

def RD(): return sys.stdin.read()


def II(): return int(input())


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


def MF(): return map(float,input().split())


def LI(): return list(map(int,input().split()))


def LF(): return list(map(float,input().split()))


def TI(): return tuple(map(int,input().split()))


# rstrip().decode('utf-8')
def main():
	n,k,c=MI()
	s=input().rstrip().decode()
	
	kk=k
	i=0
	L=[]
	while kk:
		if s[i]=="o":
			L.append(i+1)
			i+=c+1
			kk-=1
		else:
			i+=1
		
	kk=k
	i=n-1
	R=[]
	while kk:
		if s[i]=="o":
			R.append(i+1)
			i-=c+1
			kk-=1
		else:
			i-=1
	R.sort()
	
	for i,j in zip(L,R):
		if i==j:
			print(i)
	
	
	
	
	
	
	
	

if __name__=="__main__":
	main()


Measured memory_bytes: 25304
/*Hey, What's up?*/

#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
vector<long long>v;
int main()
{
    fastio;
    long long a=0,b=0,c,d,e,f=0,l,g,m,n,k,i,j,t,p,q;
    cin>>n>>a>>b;
    d=abs(a-b);
    if(d%2==0){
        cout<<(d/2)<<'\n';
        return 0;
    }
    p=b-1;
    q=n-a;
    f=min(p,q);
    p=a;
    q=b-a;
    p+=(q-1)/2;
    f=min(f,p);
    p=n-b+1;
    q=a+p;
    p+=(n-q)/2;
    f=min(f,p);
    cout<<f<<'\n';

    return 0;
}


Measured memory_bytes: 384
namespace ABC127.B
{
    using static System.Console;
    using System.Linq;
    using System.Collections.Generic;
    public class Program
    {
        public static void Main(string[] args)
        {
            var l = ReadInputsAsInt().ToList();


            foreach (var item in Solve(l[0],l[1],l[2]))
            {
                WriteLine(item);
            }
        }

        public static IEnumerable<int> Solve(int r, int d, int x0)
        {
            for (int i = 1; i <= 10; i++)
            {
                x0 = r * x0 - d;
                yield return x0;
            }
        }
        static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));

    }
}

Measured memory_bytes: 11348
#include <iostream>
#include <vector>
#include <utility>
#include <set>
#include <array>
#include <numeric>

using namespace std;

using Pos = pair<int64_t, int64_t>;

int64_t H, W, N;
set<Pos> Blacks;
array<int64_t, 10> Spots;


inline int64_t count(int64_t a, int64_t b)
{
  int64_t ret = 0;
  for (int64_t i=a; i<a+3; ++i)
    for (int64_t j=b; j<b+3; ++j)
      ret += Blacks.count(make_pair(i, j));

  return ret;
}

int main()
{
  cin >> H >> W >> N;

  for (int64_t i=0; i<N; ++i) {
    int64_t a, b;
    cin >> a >> b;
    Blacks.insert(make_pair(a, b));
  }

  for (const auto& p : Blacks) {

    int64_t min_a = p.first - 2 < 1 ? 1 : p.first - 2;
    int64_t max_a = H < p.first + 2 ? H - 2 : p.first;
    int64_t min_b = p.second - 2 < 1 ? 1 : p.second - 2;
    int64_t max_b = W < p.second + 2 ? W - 2 : p.second;

    for (int64_t a=min_a; a<=max_a; ++a)
      for (int64_t b=min_b; b<=max_b; ++b)
        ++Spots[count(a, b)];
  }

  for (int64_t i=1; i<10; ++i)
    Spots[i] /= i;

  Spots[0] = (H-2) * (W-2) - accumulate(Spots.cbegin()+1, Spots.cend(), static_cast<int64_t>(0));

  for (int64_t i=0; i<10; ++i)
    cout << Spots[i] << endl;

  return 0;
}


Measured memory_bytes: 6528
N = int(input())
a, b, c = [0] * N, [0] * N, [0] * N
for i in range(N):
	a[i], b[i], c[i] = map(int, input().split())
dp = [[0] * 3 for _ in range(N)]

dp[0] = [a[0], b[0], c[0]]
for i in range(N - 1):
	dp[i + 1][0] = max(dp[i + 1][0], dp[i][1] + a[i + 1], dp[i][2] + a[i + 1])
	dp[i + 1][1] = max(dp[i + 1][1], dp[i][0] + b[i + 1], dp[i][2] + b[i + 1])
	dp[i + 1][2] = max(dp[i + 1][2], dp[i][0] + c[i + 1], dp[i][1] + c[i + 1])
print(max(dp[N - 1]))

Measured memory_bytes: 62168