akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    string S;
    cin >> S;
    int n = S.size();
    vector<int> h(n+1), max_l(n+1), max_r(n+1);
    h[0] = 0;
    for ( int i = 1; i <= n ; i++ ) {
        char s = S[i-1];
        h[i] = h[i-1];
        if ( s == '\\' ) h[i]--;
        if ( s == '/' ) h[i]++;
    }
    max_l[0] = h[0];
    for ( int i = 1; i <= n; i++ ) {
        max_l[i] = max(max_l[i-1] , h[i]);
    }
    max_r[n] = h[n];
    for ( int i = n-1; i >= 0; i-- ) {
        max_r[i] = max(max_r[i+1], h[i]);        
    }
    vector<int> L;
    int x2 = 0, d1, d2;
    for ( int i = 0; i < n; i++ ) {
        d1 = min(max_r[i], max_l[i]) - h[i];
        d2 = min(max_r[i+1], max_l[i+1]) - h[i+1];
        if (d1 < 0) d1 = 0;
        if (d2 < 0) d2 = 0;
        if ( (d1 == 0 || d2 == 0) && x2 > 0 ) {
            x2 += d1 + d2;
            L.push_back(x2/2);
            x2 = 0;
        } else {
            x2 += d1 + d2;
        }
    }
    if ( x2 > 0 ) {
        L.push_back(x2/2);
        x2 = 0;
    }

    int A = 0;
    for ( int i = 0; i < L.size(); i++ ) {
        A += L[i];
    }
    
    cout << A << '\n';
    cout << L.size();
    for ( int i = 0; i < L.size(); i++ ) {
        cout << " " << L[i];
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3388
import java.awt.*;
import java.util.*;

public class Main{
	static final int dx[]= {0,-1,0,1};
	static final int dy[]= {-1,0,1,0};

	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int h=s.nextInt();
		int w=s.nextInt();

		boolean f[][]=new boolean[h][w];

		ArrayDeque<Point> q=new ArrayDeque<>();

		for(int i=0;i<h;++i) {
			char[]t=s.next().toCharArray();
			for(int j=0;j<w;++j) {
				if(t[j]=='#') {
					f[i][j]=true;
					q.add(new Point(j,i));
				}
			}
		}

		int i=-1;
		for(;!q.isEmpty();++i) {
			//for(boolean[]g:f)System.err.println(Arrays.toString(g));
			System.err.println();
			for(int size=q.size();size>0;--size) {
				Point poll=q.poll();
				for(int d=0;d<4;++d) {
					int y=poll.y+dy[d];
					int x=poll.x+dx[d];
					if(0<=y&&y<h&&0<=x&&x<w&&!f[y][x]) {
						f[y][x]=true;
						q.add(new Point(x,y));
					}
				}
			}
		}
		System.out.println(i);
	}
}

Measured memory_bytes: 70920
#include<stdio.h>
#include<string.h>
char s[11];
int main()
{
    gets(s);
    if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
    	printf("Yes\n");
    else
    	printf("No\n");
    return 0;
}

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

#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())


int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a, b, k;
	cin >> a >> b >> k;
	if (k >= a) {
		k -= a;
		a = 0;
	}
	else a -= k, k = 0;
	if (k >= b) {
		b = 0;
	}
	else b -= k;
	cout << a << ' ' << b;
	return 0;
}



Measured memory_bytes: 256
// In the name of god
#include <bits/stdc++.h>
#pragma GCC optimize("02")
#define F first
#define S second 
#define pb push_back
#define all(x) x.begin(),x.end()
#define fileoi freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
using namespace std;
using ll = long long;
const ll maxn=2e5+5,inf=1e18+18,mod=1e9+7;
ll n,a[maxn],ps[maxn],sum,ans;
int main(){
	ios::sync_with_stdio(false) , cin.tie(0) , cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ps[i]=a[i];
		if(i>0)ps[i]=(ps[i]+ps[i-1])%mod;
	}
	for(int i=0;i<n-1;i++){
		ll x=(ps[n-1]-ps[i]+mod)%mod;
		ans=(ans+((x*a[i])%mod))%mod;
	}
	cout<<ans%mod<<endl;
}


Measured memory_bytes: 6728
#include <bits/stdc++.h>
          
#define pb push_back
#define ll long long
#define f first
#define s second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);;                                                      
} 
int dx[5] = {-1, 0, 0, 1};
int dy[5] = {0, -1, 1, 0};
  
const int N = 1e6 + 100;
const ll mod = 1e9 + 7;
const ll big = 1e9;
  
vector<int> g[N];
int was[N];
int dfs(int v)
{
	was[v] = 1;
	int ans = 1;
	for (int i = 0; i < g[v].size(); i++)
	{
		int to = g[v][i];
		if (was[to])
		{
			continue;
		}
		ans += dfs(to);
	}
	return ans;
}
int main() 
{
    data();     
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
    	int u, v;
    	cin >> u >> v;
    	g[u].pb(v);
    	g[v].pb(u);
    }
    vector<int> sz;
    for (int i = 1; i <= n; i++)
    {
    	if (!was[i])
    	{
    		sz.pb(dfs(i));
    	}
    }
    sort(sz.begin(), sz.end());
    int j = 0;
    int kol = 0;
    int ans = 0;
    while (j < sz.size())
    {
    	if (sz[j] - kol > 0)
    	{
    		ans += sz[j] - kol;
    		kol += sz[j] - kol;
    	}
    	j++;
    }
    cout << ans;
}
//a[3] * (a[1] + a[2]

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

using namespace std;

class range {
private:
  struct Iterator {
    int val;
    int operator*() {return val;}
    bool operator!=(Iterator& itr) {return val < itr.val;}
    void operator++() {++val;}
  };
  Iterator i, n;
public:
  range(int n) : i({0}), n({n}) {}
  range(int i, int n) : i({i}), n({n}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

template<class T> inline T at(const vector<T> &v, int i) {return v[(i % (int)v.size() + v.size()) % v.size()];}

template<class T> inline bool is_max(T &a, const T &b) {return a < b ? a = b, true : false;}
template<class T> inline bool is_min(T &a, const T &b) {return a > b ? a = b, true : false;}

int main() {
  int n, l;
  cin >> n >> l;
  int a[n];
  for (int i : range(n)) cin >> a[i];
  pair<int, int> v[n];
  for (int i : range(n)) v[i] = make_pair(a[i], i);
  sort(v, v + n);
  vector<int> t(n + 2, 0);
  for (int i : range(n)) {
    int x = v[i].second;
    t[x + 1] = max(t[x], t[x + 2]) + l - a[x];
  }
  cout << *max_element(t.begin(), t.end()) << endl;
}

Measured memory_bytes: 2584
#include <iostream>
std::string map[12];
void dfs(int x,int y){
	if(x-1>=0&&map[y][x-1]=='1')map[y][x-1]='0',dfs(x-1,y);
	if(x+1<=11&&map[y][x+1]=='1')map[y][x+1]='0',dfs(x+1,y);
	if(y-1>=0&&map[y-1][x]=='1')map[y-1][x]='0',dfs(x,y-1);
	if(y+1<=11&&map[y+1][x]=='1')map[y+1][x]='0',dfs(x,y+1);
	return ;
}
int main(){
	while(1){
		for(int i=0;i<12;i++){
			std::cin>>map[i];
		}
		if(std::cin.eof())return 0;
		int r = 0;
		for(int y=0;y<12;y++){
			for(int x=0;x<12;x++){
				if(map[y][x]=='1'){
					r++,map[y][x]='0',dfs(x,y);
				}
			}
		}
		std::cout<<r<<std::endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
void custom_swap(int b, int e, int t);

typedef long long ll;
ll a[1005];

int main()
{
	using namespace std;
	int n, q, b, e, t;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	cin >> q;
	while (q--)
	{
		cin >> b >> e >> t;
		custom_swap(b, e, t);
	}
	for (int i = 0; i < n - 1; i++)
	{
		cout << a[i] << ' ';
	}
	cout << a[n - 1] << endl;
	return 0;
}

void custom_swap(int b, int e, int t)
{
	for (int k = 0; k < e - b; k++)
	{
		ll temp = a[b + k];
		a[b + k] = a[t + k];
		a[t + k] = temp;
	}
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  if (A >= 13){
    cout << B << endl;
  }
  else if(A >= 6){
    cout << B/2 << endl;
  }
  else{
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#ifdef on_linux
	#include <sys/resource.h>
#endif

#ifdef dobby_is_a_free_elf
	#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
	#define trace(...) 0;
#endif

using namespace std;
using namespace __gnu_pbds;


#define all(x)                  (x).begin(), (x).end()
#define between(i,x,y)          ((i) >= (x) && (i) <= (y))
#define DECIMAL(n)              cout << fixed << setprecision(n)
#define fi                      first
#define lbd                     lower_bound
#define mem0(x)                 memset(x, 0, sizeof (x))
#define mem1(x)                 memset(x, -1, sizeof (x))
#define mp                      make_pair
#define pb                      push_back
#define pf                      push_front
#define ppb                     pop_back
#define ppf                     pop_front
#define sc                      second
#define sqr(a)                  ((a) * (a))
#define sz(x)                   (int)((x).size())
#define ubd                     upper_bound

#define int                     long long

template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
	const char *comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

inline void elf_magic(int testcase)
{
	int n, x, m;
	cin >> n >> x >> m;

	bool vis[m + 10] = {};

	int ctr = 0;
	vector<int> v;

	int brat = -1;
	while (ctr < n) {
		if (vis[x]) { brat = x; break; }
		vis[x] = 1;
		v.pb(x);
		ctr++;
		x = (x * x) % m;
	}

	int ans = 0;
	int bb = 0;
	int i;
	for (i = 0; i < ctr; ++i) {
		if (v[i] == brat) { bb = i; break; }
		ans += v[i];
	}

	trace(ans);

	int temp = 0;
	for (i; i < ctr; ++i) {
		temp += v[i];
	}

	trace(temp, (n - bb) / (ctr - bb));

	ans += temp * ((n - bb) / (ctr - bb));

	for (int i = 0; i < ((n - bb) % (ctr - bb)); ++i) {
		ans += v[i + bb];
	}

	cout << ans;
	return;
}

int32_t main()
{
	#ifdef on_linux
	rlimit cpu_time {.rlim_cur = 2, .rlim_max = RLIM_INFINITY};
	setrlimit(RLIMIT_CPU, &cpu_time);
	#endif

	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	int TESTS = 1;
	//cin >> TESTS;
	for (int i = 1; i <= TESTS; ++i) {
		// cout << "Case #" << i << ": ";
		elf_magic(i);
		if (i != TESTS)	{ cout << '\n'; }
	}
	return 0;
}

Measured memory_bytes: 3952
import math

if __name__ == '__main__':
    a, b, h, m = tuple(map(int, input().split()))
    t = h + m/60
    w = (2 - 1/6) * t
    w %= 2

    c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(w*math.pi))
    print(c)

Measured memory_bytes: 9572
#include<bits/stdc++.h> 
using namespace std;
long long n,ans;
int s;
int main(){
    cin>>n;
    for(int i=sqrt(n);i>0;--i)
        if(n%i==0){
            ans=n/i;
            break;
        }
    while(ans>0){
        s++;
        ans/=10;
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int i, a, b;
  for (i; ; ){
    scanf("%d %d", &a, &b);
    if (a+b==0) break;
    else {
      if (a>b) printf("%d %d\n", b, a);
      else printf("%d %d\n", a, b);
    }
  }
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include <cstdio>
#include<cstring>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) {if (x % y == 0) return y;else return LGCD(y, x % y);}
ll LLCM(ll x, ll y) {return x * y / LGCD(x, y);}

int GCD(int x, int y) {if (x % y == 0) return y;else return GCD(y, x % y);}
int LCM(int x, int y) {return x * y / GCD(x, y);}
ll dp[10000][10000];
ll combination(ll n, ll r) {
         if (n == r){dp[n][n] = 1;}
	else if (r == 0) {return dp[n][0] = 1;}
	else if (r == 1) {return dp[n][1]=n;}
	else {dp[n][r]=dp[n - 1][r - 1] % 1000000007 + dp[n - 1][r] % 1000000007;
	return dp[n][r]=combination(n - 1, r - 1) % 1000000007 + combination(n - 1, r) % 1000000007;}
}

int main() {
	vector<int>Book(9);
	int ans;
	int A;
	while (1) {
		cin >>A;
		if (A == 0)break;
		else { 
			for (int i = 0;i < 9;i++) { cin >> Book.at(i);
			A = A - Book.at(i);
			}cout << A << endl;
		}
		
	}
	
	return 0;
}



Measured memory_bytes: 2976
A, B, C, X, Y = list(map(int, input().split()))

ans =0

if A + B > 2 * C:
    ans += 2 * C * min(X,Y) 
    if X > Y:
        ans += (X-Y) * min(2*C, A)
    else:
        ans += (Y-X) *min(2*C, B)
else:
    ans = A * X + B* Y
print(ans)

Measured memory_bytes: 9156
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
long long MOD = 1e9+7;
pair<int,int> dx[4] = {{1,0},{-1,0},{0,1},{0,-1}};
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long fastpow(long long x,long long k)
{
    if(!k)
        return 1;
    if(k & 1)
        return ((x * fastpow(x,k-1) % MOD) % MOD) % MOD;
    long long ans = fastpow(x,k/2);
    ans %= MOD;
    ans *= ans;
    ans %= MOD;
    return ans;
}
long long sumF(long long x)
{
    int s = 0;
    while(x)
        s += x%10,x /= 10;
    return s;
}
long long CompCost[200005];
int parent[200005];
int findParent(int x)
{
    if(parent[x] == x)
        return x;
    return parent[x] = findParent(parent[x]);
}
int freqarr[4];
long long totalOp;
int n;
long double dp[305][305][305];
bool visited[305][305][305];
double solve(int f1,int f2,int f3)
{
    if(f1 == 0 && f2 == 0 && f3 == 0)
        return 0;
    if(visited[f1][f2][f3])
        return dp[f1][f2][f3];
    long double sum = f1+f2+f3;
    long double C = 1.0*n / sum;
    if(f1)
        C += (1.0*f1/sum) * solve(f1-1,f2,f3);
    if(f2)
        C += (1.0*f2/sum) * solve(f1 + 1,f2 - 1,f3);
    if(f3)
        C += (1.0*f3/sum) * solve(f1,f2+1,f3-1);
    visited[f1][f2][f3] = true;
    return dp[f1][f2][f3] = C;
}
int main()
{
    IO;
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        int x;
        cin >> x;
        freqarr[x]++;
    }
    totalOp = freqarr[1] + freqarr[2]*2 + freqarr[3]*3;
    cout << fixed << setprecision(15) << solve(freqarr[1],freqarr[2],freqarr[3]);
    return 0;
}


Measured memory_bytes: 467328
N = int(input())
A = list(map(int, input().split()))

man=1
cnt=0
man_list=[0]*N
A.sort()
A += [0]

for a in A:
  if a != man:
    man_list[man-1] = cnt
    man = a
    cnt=0
  cnt+=1

for l in man_list:
  print(l)

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

using namespace std;

int main(){
	map<string,int> m;
	m.insert(make_pair("AC", 0));
	m.insert(make_pair("WA", 0));
	m.insert(make_pair("TLE", 0));
	m.insert(make_pair("RE", 0));
	int n;
	cin >> n;
	for(int i = 0; i < n; ++i){
		string s;
		cin >> s;
		++m[s];
	}
	cout << "AC x " << m["AC"] << "\nWA x " << m["WA"] << "\nTLE x " << m["TLE"] << "\nRE x " << m["RE"];

	return 0;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int n, k, x, y; cin >> n >> k >> x >> y;
  int ans;
  if(n > k)
    ans = k * x + (n-k) * y;
  else
    ans = n * x;
  cout << ans << endl;

  return 0;
}




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

// chmin, chmax関数
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

// Yes-Noを出力する問題で楽をする
void Ans(bool f){
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

//---------------------------

int main(){
    int a,b,c; cin >> a >> b >> c;
    set<int> s;
    s.insert(a); s.insert(b); s.insert(c);
    cout << s.size() << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
    
def main():
    n,m=map(int,input().split())
    A=[int(input())for _ in range(m)]
    flag=[True]*(n+2)
    for a in A:
        flag[a]=False
    mod=10**9+7
    dp=[0]*(n+1)
    dp[0]=1
    for i in range(n):
        if flag[i+1]:
            dp[i+1]+=dp[i]%mod
        if flag[i+2] and i<n-1:
            dp[i+2]+=dp[i]%mod
    print(dp[n]%mod)

if __name__=='__main__':
    main()

Measured memory_bytes: 45276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1<<29;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int n; cin >> n;
    ll s1 = 0, s2 = 0, c1 = 0, c2 = 0, a;
    REP(i, 1, n + 1){
        cin >> a;
        s1 += a;
        s2 += a;
        if(i % 2 == 0){
            if(s1 >= 0) c1 += 1 + s1, s1 = -1;
            if(s2 <= 0) c2 += 1 - s2, s2 = 1;
        }
        else {
            if(s1 <= 0) c1 += 1 - s1, s1 = 1;
            if(s2 >= 0) c2 += 1 + s2, s2 = -1;
        }
    }
    cout << min(c1, c2) << endl;
    return 0;
}

Measured memory_bytes: 256
import math
def comb(x,y):
    return math.factorial(x)//(math.factorial(x-y)*math.factorial(y))
n,m = map(int,input().split())

ans1=0
ans2=0
if n > 1:
    ans1=comb(n,2)
if m > 1:
    ans2=comb(m,2)
print(ans1+ans2)

Measured memory_bytes: 3060
N,K=map(int,input().split())
A=list(map(int,input().split()))

flag=0
def woap(current_city,li,K):
    global flag
    next_city=li[current_city]-1
    if trace[next_city]!=-1 and trace[next_city]!=K:
        flag=1
        return current_city
    else:
        trace[next_city]=K
        return next_city

def woap2(current_city,li):
    next_city=li[current_city]-1
    return next_city

trace=[-1]*N
trace[0]=0
rest=K
current_city=0
for i in range(1,K+1):
    current_city=woap(current_city,A,i)
    if flag==1:
        break
    else:
        rest-=1


loop_length=K-rest-trace[A[current_city]-1]+1
amari=rest%loop_length
for i in range(amari):
    current_city=woap2(current_city,A)

print(current_city+1)

Measured memory_bytes: 32344
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	long long a,b,c,d,s1,s2;
	while(cin>>a)
	{
		cin>>b>>c>>d;
		s1=a*b;
		s2=c*d;
		if(s1>=s2)
		cout<<s1;
		else
		cout<<s2;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a = 1000, b, c,d,e=0;

    scanf("%d", &b);

    c = b % a;
    d = a-c;
    if (b % a != 0) {
        printf("%d", d);
    }

    else {
        printf("%d",e );
    }

    return 0;
}

Measured memory_bytes: 2124
// Created by kashi on 21-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}
int32_t main() {
   string str;
   cin>>str;
   int count=0;
   int ans=0;
   for(int i=0;i<str.size();i++){
       if(str[i]=='R'){
           count++;
           ans=max(ans,count);
       }
       else
           count=0;
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 3624
/*  ***  In The Name of God ... ***  */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const ll N = 1e5 + 10;

int n ;
map < int , int > cnt;
vector < int > vec;

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	for(int i = 0 ; i < n ; i++)
	{
		int x;
		cin >> x;
		cnt[x]++;
		if(cnt[x] >= 2)
			vec.push_back(x) , cnt[x] = 0;
	}
	sort(vec.begin() , vec.end());
	reverse(vec.begin() , vec.end());
	if(vec.size() < 2)
		return cout << 0 , 0;
	cout << (ll)((ll)vec[0] * (ll)vec[1]) << '\n';
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vector<set<int>> g(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].insert(b);
    g[b].insert(a);
  }
  ll ans = 0;
  vi v;
  rep2(i, 1, n) v.push_back(i);
  do {
    bool ok = true;
    if(!g[v[0]].count(0)) ok = false;
    rep(i, n - 2) if(!g[v[i + 1]].count(v[i])) ok = false;
    if(ok) ans++;
  } while(next_permutation(all(v)));
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque

S = list(input())
T = input()
S = deque(S)
St = S
i = 0
flag = False
while i < len(S):
    if "".join(St) == T:
        flag = True
        break
    else:
        lst = St.pop()
        St.appendleft(lst)

    i += 1
print("Yes") if flag else print("No")


Measured memory_bytes: 3316
using System;

class Program
{
    static void Main(string[] args)
    {
        int n, m, l, i, j, k;
        long subTotal = 0;
        long total = 0;

        //整数受け取り
        string[] str1 = Console.ReadLine().Split(' ');
        n = int.Parse(str1[0]);
        m = int.Parse(str1[1]);
        l = int.Parse(str1[2]);

        //2次元配列数値受け取り(n * m)
        int[,] array1 = new int[n, m];

        for (i = 0; i < n; i++)
        {
            string[] str2 = Console.ReadLine().Split(' ');

            for (j = 0; j < m; j++)
            {
                array1[i, j] = int.Parse(str2[j]);        
            }
        }

        //2次元配列数値受け取り(m * l)
        int[,] array2 = new int[m, l];
            
        for (i = 0; i < m; i++)
        {
            string[] str3 = Console.ReadLine().Split(' ');

            for (j = 0; j < l; j++)
            {   
                array2[i, j] = int.Parse(str3[j]);
            }
        }

        //計算&出力
        for (i = 0; i < n; i++)
        {
            for (j = 0; j < l; j++)
            {
                for (k = 0; k < m; k++)
                {
                    subTotal = array1[i, k] * array2[k, j];
                    total += subTotal;
                    subTotal = 0;
                }
                Console.Write(total);
                total = 0;

                if (j < l - 1)
                {
                    Console.Write(" ");
                }
            }
            Console.WriteLine("");
        }
    }
}


Measured memory_bytes: 9408
<?php

    // ???????????°????????\???
    $num = preg_split('/ /', trim(fgets(STDIN)));

    // ????????¢?????????????¨???§?¨??????????
    $width = $num[0];
    // ????????¢?????????????????§?¨??????????
    $height = $num[1];
    // ???????????????x??§?¨??????????
    $x  = $num[2];
    // ???????????????y??§?¨??????????
    $y = $num[3];
    // ?????????????????????
    $r = $num[4];

    echo($width >= ($x + $r) && $height >= ($y + $r) && $x >= $r && $y >= $r ? "Yes" : "No");

?>

Measured memory_bytes: 15616
S = input()

flag = False

for i in range(len(S)):
    if i % 2 == 1:
        if S[i] == 'R':
            flag = True
            break
    else:
        if S[i] == 'L':
            flag = True
            break
            
if flag == True:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 2940
N = int(input())
P = list(map(int, input().split()))

ans = [0]*N
min_cal = [0]*N
min_cal[0] = P[0]

for i in range(N-1):
  min_cal[i+1] = min(min_cal[i],P[i+1])

for i in range(N):
  if min_cal[i] >= P[i]:
    ans[i] = 1

print(sum(ans))

Measured memory_bytes: 32372
MOD = 10 ** 9 + 7
N = 10 ** 6
fact = [1]*(N+1)
rfact = [1]*(N+1)
r = 1
for i in range(1, N+1):
  fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD-2, MOD)
for i in range(N, 0, -1):
  rfact[i-1] = r = r * i % MOD

# nPk (mod MOD) を求める
def perm(n, k):
  return fact[n] * rfact[n-k] % MOD

# nCk (mod MOD) を求める
def comb(n, k):
  return (fact[n] * rfact[k] * rfact[n-k]) % MOD

x,y = map(int, input().split())
ans = 0
if not (x + y) % 3:
  cnt = (x+y) // 3
  a = abs(x-y)
  if cnt >= a:
    r = (cnt - a) // 2
    ans = comb(cnt,r)
print(ans)

Measured memory_bytes: 55820
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
/*BISMILLAH UR RAHMAN*/ 
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<fixed<<setprecision(10);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) int(x.size())
#define INF INT_MAX;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
double startTime;
double getCurrentTime()
{return ((double)clock() - startTime) / CLOCKS_PER_SEC;}
typedef long long int ll;
typedef pair<int,int> ii;
int mod=1e9+7;
char arr[1010][1010];
int cnt[1010][1010];
int dp(int m,int n)
{
  if(m<=0||n<=0)return 0;
  if(arr[m-1][n-1]=='#')return 0;
  if(cnt[m][n]!=-1)return cnt[m][n];
  if((m==1&&n==2)||(n==1&&m==2)) return cnt[m][n]=1;
  int ans;
  if(m-1>0&&n-1>0)
  ans=(dp(m-1,n)%mod+dp(m,n-1)%mod)%mod;
  else
  {
    if(m-1>0)
      ans=dp(m-1,n)%mod;
    else
      ans=dp(m,n-1)%mod;
  }

  return cnt[m][n]=ans;
}
int main()
{  
  //fast
  int h,w;
  cin>>h>>w;
  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j)
      cin>>arr[i][j]; 
    memset(cnt,-1,sizeof(cnt));
    //startTime = (double)clock();
    cout<<dp(h,w)%mod<<endl;
    //cout<<getCurrentTime()<<endl;

}


Measured memory_bytes: 5376
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int r;
	cin >> r;
	cout << r * r << endl;

	return 0;
}


Measured memory_bytes: 3220
n = int(raw_input())
st = raw_input()
ilist = st.split()
ilist = [int(a) for a in ilist]
for i in range(0, n):
    ilist[i]-=1
k = 0
for i in range(0, n):
    if (i == ilist[ilist[i]]): k+=1
print k/2

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  ll S;
  if(N%(A+B)<=A){
    cout << N/(A+B)*A+N%(A+B);
    return 0;
  }
  else if(N%(A+B)>A){
    cout << N/(A+B)*A+A;
    return 0;
  }
}

Measured memory_bytes: 3608
def intlist(x):
    y = []
    for i in range(len(x)):
        y.append(int(x[i]))
    return y
 
N, M, X = map(int, input().split())
price = -1
 
L = []
a = []
c = []
suit =[]

for i in range(M+1):
    a.append(0)
    
for i in range(N):
    text = input().split()
    L.append(intlist(text))
    
for i in range(2**N):
    c = a.copy()
    
    for j in range(N):
        if (i >> j) & 1:
            for k in range(M+1):
                c[k] = c[k] + L[j][k]
    suit.append(c.copy())
                
suit2 = []

for i in range(len(suit)):
    if min(suit[i][1:len(suit)]) >= X:
        suit2.append(suit[i])
        


if suit2 != []:
    if len(suit2) >= 2:
    
        cheaper = suit2[0][0]
        for i in range(len(suit2)):
            if cheaper > suit2[i][0]:
                cheaper = suit2[i][0]
        price = cheaper
    elif len(suit2) == 1:
        price = suit2[0][0]
        
print(price)

Measured memory_bytes: 11296
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
  int H, A;
  int ans=0;
  cin >> H >> A;
  while(H>0){
    H=H-A;
    ans++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {

    val list = readLine()!!.split(" ").map { it.toInt() }

//    var elements = mutableListOf<Int>()
    var elements = listOf<Int>()
    // 与えられた数値回数ループしたいなら3回したいなら0 until 3 -> 0, 1, 2
    // Collectionの結合はどうだっけ？
    // 読み取り専用リストでもplusで変更できるのか？->できてない。ではmutableListならできるのか？->できない
    // 読み取り専用リストでも、入れ直したらできる。mutableListとして変更してListを返して入れ直すのだろうか？
    for (i in 0 until list[1])
        elements = elements + readLine()!!.split(" ").map { it.toInt() }

    for (i in 1..list[0])
        println(elements.count { it == i })
}

Measured memory_bytes: 37984
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int n,a,b,p,c,ans=0; 
    cin >> n >> a >> b >> p; 
    for (int i=1;i<n;i++){
        cin >> c;
        ans += min(b,(c-p)*a);
        p = c;
    }
    cout << ans << endl;
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

using namespace std;

vector<vector<int>> graph;
vector<vector<int>> rgraph;
vector<bool> visited;
vector<int> vs;
vector<int> cmp;

void add_edge(int from, int to) {
    graph[from].push_back(to);
    rgraph[to].push_back(from);
}

void dfs(int v) {
    visited[v] = true;
    for (auto to:graph[v]) {
        if (!visited[to])dfs(to);
    }
    vs.push_back(v);
}

void rdfs(int v, int k) {
    visited[v] = true;
    cmp[v] = k;
    for (auto to:rgraph[v]) {
        if (!visited[to])rdfs(to, k);
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    graph = vector<vector<int>>(n);
    rgraph = vector<vector<int>>(n);

    for (int i = 0; i < m; i++) {
        int s, t;
        cin >> s >> t;
        add_edge(s, t);
    }

    visited = vector<bool>(n);
    vs = vector<int>(0);
    for (int i = 0; i < n; i++) {
        if (!visited[i])dfs(i);
    }

    visited = vector<bool>(n);
    reverse(vs.begin(), vs.end());
    cmp = vector<int>(n);
    int k = 0;
    for (auto nowv:vs) {
        if (!visited[nowv])rdfs(nowv, k++);
    }
    vector<int> indeg(k), outdeg(k);
    /*
    for(int i = 0; i < n; ++i) {
        cout << cmp[i] << ' ';
    }
    cout << endl;
     */
    for(int i = 0; i < n; ++i) {
        for(int j : graph[i]) {
            if(cmp[i] != cmp[j]) {
                ++indeg[cmp[i]];
                ++outdeg[cmp[j]];
            }
        }
    }
    int ci = 0, co = 0;
    for(int i = 0; i < k; ++i) {
        if(indeg[i] == 0) ++ci;
        if(outdeg[i] == 0) ++co;
    }
    if(k == 1) ci = 0, co = 0;
    cout << max(ci, co) << endl;
    return 0;
}


Measured memory_bytes: 5536
#include <cstdio>

template<typename T> void inline fastin(T &num) {
  T c;
  num = 0;
  c = getchar_unlocked();
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
}

int main() {
  int a, b, c; fastin(a); fastin(b); fastin(c);
  if (a + b >= c) {
    printf("%s\n", "Yes");
  } else {
    printf("%s\n", "No");
  }
  return 0;
}


Measured memory_bytes: 128
N = int(input())
a = [i for i in map(int, input().split())]

i = 0
pointer = 1
cnt = 0
while i < N:
    if a[i] == pointer:
        pointer += 1
        cnt += 1
    i += 1

if cnt != 0:
    print(N - cnt)
else:
    print(-1)

Measured memory_bytes: 77644
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vii vector<vi>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

const ll INF = 1LL << 60;

int main(){
  int n,m; cin >> n >> m;
  vi X(m); for(auto &x: X) cin >> x;

  if (n >= m){std::cout << 0 << '\n'; return 0;}

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

  vi L(m-1);
  rep(i, m-1) L[i] = X[i+1]-X[i];
  sort(L.begin(),L.end());
  reverse(L.begin(),L.end());

  int sum = 0;
  rep(i, n-1) sum += L[i];

  std::cout << X[m-1] - X[0] - sum << '\n';

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
void input() {
  cin >> N;
  A.resize(N);
  rep(i, 0, N - 1) { cin >> A[i]; }
}
void solve() {
  B.resize(N);

  B[0] = A[0];
  rep(i, 1, N - 1) { B[i] = B[i - 1] + A[i]; }

  int ans = INF;
  rep(i, 0, N - 2) { ans = min(ans, abs(B[i] - (B[N - 1] - B[i]))); }
  if (N == 2) {
    ans = INF;
    ans = abs(A[0] - A[1]);
  } else if (N == 3) {
    ans = INF;
    ans = min(ans, abs((A[0] + A[1]) - A[2]));
    ans = min(ans, abs(A[0] - (A[1] + A[2])));
  }
  cout << ans << endl;

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;
#define ll long long
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update>  ordered_set;
using namespace std;
 
#define fr(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (long long i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (long long i = (n) - 1; i >= 0; i--)
#define foreach(it,ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define fillinf(ar, n) fr(i,0,(n)) ar[i] = INF
#define debug(x) cout<<#x<<": "<<x<<endl
#define arr1d(a,n) cout << #a << " : "; fr(_,1,n) cout << a[_] << ' '; cout << endl;
#define arr1d0(a,n) cout << #a << " : "; rep(_,n) cout << a[_] << ' '; cout << endl;
#define arr2d(a,n,m) cout << #a << " :" << endl; fr(_,1,n) {fr(__,1,m) cout << a[_][__] << ' '; cout << endl;}
#define arr2d0(a,n,m) cout << #a << " :" << endl; rep(_,n) {rep(__,m) cout << a[_][__] << ' '; cout << endl;}


#define ull unsigned long long
#define ld long double
#define ui unsigned int
#define all(ar) ar.begin(), ar.end()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define y0 yyyyyy0
auto clk=clock();
#define y1 yyyyyy1
#define setb __builtin_popcount
#define BIT(n) (1<<(n))
#define SQR(x) ((x) * (x))
#define CUBE(x) ((x) * (x) * (x))
#define LSOne(S) (S) & (-S)
inline bool EQ(double a, double b) {return fabs(a - b) < 1e-9;}
 
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;


 
inline int two(int n) {return 1 << n;}
inline int isOnBit(int n, int b) {return (n >> b) & 1;}
inline void onBit(int & n, int b) {n |= two(b);}
inline void offBit(int & n, int b) {n &= ~two(b);}
inline int lastBit(int n) {return n & (-n);}
inline int cntBit(int n) {int res = 0; while(n && ++res) n -= n &(-n); return res;}
 
#define INP "test.inp"
#define OUT "test.out"
 
#define PI 3.1415926535897932385
#define INF 10000000000000000ll
#define EPS 1e-7
#define MAXN 100000
#define MOD 998244353
#define dec decr
#define endl '\n'
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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



    int n,k;
    cin>>n>>k;
    vi v(n);
    rep(i,n)cin>>v[i];
    vi dp(n,INT_MAX/2);
    dp[0]=0;
    for(int i=1;i<n;i++){
        for(int j=(i-k>=0)?i-k:0;j<i;j++){
        dp[i]=min(dp[i],dp[j]+abs(v[j]-v[i]));
}
    }
    cout<<dp[n-1];
   
    return 0;
}   

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
using namespace std;
#define endl '\n'

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long int k, a, b;
    cin >> k;
    cin >> a >> b;
    if(a%k==0||b%k==0){
        cout << "OK";
    }
    else if( k*(a/k+1)<b || k*(b/k)>a ){
        cout << "OK";
    }else{
        cout << "NG";
    }

    return 0;
}

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

vector<long long> fact, inv_fact;

long long POW(long long a, long long b) {
    long long result = 1;
    while (b) {
        if (b & 1) {
            result *= a;
        }

        a *= a;
        b /= 1;
    }

    return result;
}

long long combination(long long n, long long m) {
    return fact[n] / fact[n - m] / fact[m];
}

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

    fact.resize(N + 1, 1);
    inv_fact.resize(N + 1);
    for (int i = 1; i <= N; i++) {
        fact[i] = i * fact[i - 1];
    }

    vector<vector<long long>> combination(N + 1, vector<long long>(N + 1, 0));
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || j == i) {
                combination[i][j] = 1;
            } else {
                combination[i][j] = combination[i - 1][j - 1] + combination[i - 1][j];
            }
        }
    }

    sort(v.begin(), v.end(), greater<long long>());

    printf("%.10f\n", accumulate(v.begin(), v.begin() + A, 0.0) / A);

    if (v[0] != v[A - 1]) {
        //v[A - 1]の数を数える
        int inner_num = 0, outer_num = 0;
        for (int i = 0; i < N; i++) {
            if (v[i] == v[A - 1]) {
                if (i < A) {
                    inner_num++;
                } else {
                    outer_num++;
                }
            }
        }

        cout << combination[inner_num + outer_num][inner_num] << endl;
    } else {
        //v[A - 1]がどこまで続いているかによって変わる
        long long num = 0;
        for (int i = 0; i < N; i++) {
            if (v[i] == v[A - 1]) {
                num++;
            }
        }

        long long ans = 0;
        for (int i = A; i <= B; i++) {
            ans += combination[num][i];
        }

        cout << ans << endl;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
 
class Hello
{
    static int[] ones =new int []{
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
    };
    
    
    static void aiueo(int tou,int kai,int num,int ninzu)
    {
        ones[(tou-1)*30+(kai-1)*10+num-1]+=ninzu;
    }
    
    static void Main()
    {
        
        int kensu=int.Parse(Console.ReadLine());
        string [] str;
        int tou;
        int kai;
        int num;
        int ninzu;
        for(int i=0;i<kensu;i++)
        {
            str=Console.ReadLine().Split(' ');
            tou=int.Parse(str[0]);
            kai=int.Parse(str[1]);
            num=int.Parse(str[2]);
            ninzu=int.Parse(str[3]);
            aiueo(tou,kai,num,ninzu);
        }
        for(int i=0;i<120;i++)
        {
            if((i+1)%30==0&&(i+1)!=120)
            {
                Console.WriteLine(" {0}",ones[i]);
                Console.WriteLine("####################");
            }
            else if((i+1)%10==0)Console.WriteLine(" {0}",ones[i]);
            else Console.Write(" {0}",ones[i]);
            
        }
    }
}


Measured memory_bytes: 18004
# 入力を空白で分割して、それぞれa,bに代入する。
a, b, c= input().split()

# 文字列を整数に変換する
a = int(a)
b = int(b)
c = int(c)

if a < b < c:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5596
import itertools
n=int(input())
S=input()
L=list(itertools.product(range(10),repeat=3))
N=[''.join(str(c) for c in l) for l in L]
x=0
for n in N:
  if n[0] in S:
    a=S.index(n[0])+1
    if n[1] in S[a:]:
      b=S[a:].index(n[1])+a+1
      if n[2] in S[b:]:
        x+=1
print(x)

Measured memory_bytes: 3188
import sys
input = sys.stdin.readline
N = int(input())
a =[0]+ list(map(int, input().split()))
for i in range(N,0,-1):
    a[i] =sum(a[i::i]) %2

print(sum(a))
del a[0]
for i,v in enumerate(a):
    if v==1:
        print(i+1,end=" ")

Measured memory_bytes: 68472
#include<stdio.h>
#define For(i,a,b) for(register int i=(a);i<=(b);i++)
using namespace std;
const int maxn=3e5+50;
const long long mod=998244353;
int n,r,g,b,rg,rb,gb,tot;
long long ans=1;
char s[maxn];
signed main(){
	scanf("%d%s",&n,s+1);tot=n;
	For(i,1,n*3){
		if(s[i]=='R'){
			if(gb){
				ans=1LL*ans*(gb--)%mod;
				continue;
			}
			if(g){
				ans=1LL*ans*(g--)%mod,++rg;
				continue ;
			}
			if(b){
				ans=1LL*ans*(b--)%mod,++rb;
				continue ;
			}
			ans=ans*1LL*(tot--)%mod,++r;
		}else if(s[i]=='G'){
			if(rb){
				ans=1LL*ans*(rb--)%mod;
				continue;
			}
			if(r){
				ans=1LL*ans*(r--)%mod,++rg;
				continue ;
			}
			if(b){
				ans=1LL*ans*(b--)%mod,++gb;
				continue ;
			}
			ans=ans*1LL*(tot--)%mod,++g;			
		}else if(s[i]=='B'){
			if(rg){
				ans=1LL*ans*(rg--)%mod;
				continue;
			}
			if(r){
				ans=1LL*ans*(r--)%mod,++rb;
				continue ;
			}
			if(g){
				ans=1LL*ans*(g--)%mod,++gb;
				continue ;
			}
			ans=ans*1LL*(tot--)%mod,++b;			
		}
	}
	printf("%lld\n",(ans%mod+mod)%mod);
}

Measured memory_bytes: 512
/*
 * Since g++10 is released, some characters is not valid inside #if 0 :(
 * So, why not using clang++? :D

 * Date:
  echo -n '  ' && date +%Y.%m.%d # Just Run this (Type !!sh in Vim).

 * Solution:
  To be updated after "Accept".

 * Digression:

 * CopyRight:
          ▁▃▄▄▄▃▃▃▃▄▶
        ▗▇▀▔    ▔▔▔▔
       ▄▛   ▃▅━━■▄▂
      ▟▊   ▐▘     ▀▙
     ▟▜▌   ▐▖   ▋  ▐▍
    ▟▘ ▜   ▝▀▇▆●▘  ▐▌
  ▗▟▘   ▜▃       ▁▅▛
  ▔▀▼▅▄▃▃██▅▄▄▄▅■▀▔
        ▔▔▔▔▔▔
 */

#include <cstdio>
#include <vector>
#include <algorithm>
#define debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long ll;

struct {
	inline operator int () { int x; return scanf("%d", &x), x; }
	/* inline operator ll () { ll x; return scanf("%lld", &x), x; } */
	template<class T> inline void operator () (T &x) { x = *this; }
	template<class T, class ...A> inline void operator () (T &x, A &...a)
	{ x = *this; this -> operator () (a...); }
} read;

const int maxn = 270000, maxw = 100005;
int val[maxn], wei[maxn], dep[maxn];
ll f[515][maxw];
ll sv[515], sw[515];
int tv[20], tw[20];

int main () {
	int n = read;
	for (int i = 1; i <= n; i ++)
		read(val[i], wei[i]);

	for (int i = 1; i <= n; i ++)
		dep[i] = dep[i >> 1] + 1;

	int K = dep[n] >> 1, Lim = 100000;
	for (int i = 1; i <= n and dep[i] <= K; i ++) {
		std::copy(f[i >> 1], f[i >> 1] + wei[i], f[i]);
		for (int w = wei[i]; w <= Lim; w ++)
			f[i][w] = std::max(f[i >> 1][w], f[i >> 1][w - wei[i]] + val[i]);
	}

	int q = read;
	while (q --) {
		int u = read, lim = read;
		if (dep[u] <= K) {
			printf("%lld\n", f[u][lim]);
			continue;
		}
		int p = dep[u] - K, x = u >> p;
		for (int i = 0; i < p; i ++)
			sv[1 << i] = val[u >> i], sw[1 << i] = wei[u >> i];
			/* tv[i] = val[u >> i], tw[i] = wei[u >> i]; */
		ll ans = f[x][lim];
		for (int S = 0; S < (1 << p); S ++) {
			sv[S] = sv[S & (S - 1)] + sv[S & -S];
			sw[S] = sw[S & (S - 1)] + sw[S & -S];
			if (sw[S] <= lim)
				ans = std::max(ans, f[x][lim - sw[S]] + sv[S]);
		}
		printf("%lld\n", ans);
	}
}


Measured memory_bytes: 404116
li = [list(map(int, input().split())) for _ in range(3)]
if li[0][0]- li[0][1] == li[1][0]- li[1][1] and li[1][0]- li[1][1] == li[2][0]- li[2][1]:
  if li[0][1]- li[0][2] == li[1][1]- li[1][2] and li[1][1]- li[1][2] == li[2][1]- li[2][2]:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define REP(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;



int main(){
    std::ios_base::sync_with_stdio(false);

    int n, t; cin >> n >> t;
    std::vector<ll> a(n); REP(i,n) cin >> a[i];
    std::vector<ll> m(n); m[0] = a[0];
    std::vector<ll> d(n);

    REP(i,n) if(i!=0) m[i] = min(a[i], m[i-1]);
    REP(i,n) d[i] = a[i]-m[i];

    int ans = 0; ll mi = -1;

    REP(i,n) mi = max(mi, d[i]);
    REP(i,n) if(d[i] == mi) ans++;

    cout << ans << endl;

    return 0;
}


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

int main() {
  double w,h,x,y;
  double s = 0;
  cin >> w >> h >> x >> y;
  s = w*h;
  cout << fixed << setprecision(10) << s/2.0 << endl;
  if(w == x*2 && h == y*2) {
    cout << '1' << endl;
  }else {
    cout << '0' << endl;
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);
  int fact = 1;
  for (int i = 0; i < N; i++) { //階乗の計算
      fact *= (i+1);
      C.at(i) = fact;
  }

  int a=0, b=0, count_a=0, count_b=0;
  /*exa. 42531 4xxxxの時、12345~35421より大きいので、(5-1)!*(4-0-1)番目より大きい
               42xxxの時、41235~41532より大きいので、(4-1)!*(3-0-1)を足す
               425xxの時、42135~42351より大きいので、(3-1)!*(5-2-1)を足す
               式の階乗の部分は位に依存、
               後ろの部分は(その位の数)-(左の位にあるその位の数より大きい個数)-1*/

  for (int i = 0; i < N-1; i++) {
    int D=0, E=0; 
    for (int j = 0; j < i; j++) {
       if(A.at(j)<A.at(i)) D++;
       if(B.at(j)<B.at(i)) E++;
    } 
    a += C.at(N-i-2)*(A.at(i)-D-1);
    b += C.at(N-i-2)*(B.at(i)-E-1);
  }

  if(a>=b) cout << a-b << endl;
  else cout << b-a << endl;
}

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

int main()
{
char s;
   cin >> s;

   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

   return 0;
}


Measured memory_bytes: 3636