akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String a = sc.next();
      if(a.equals("A")){
        a = "T";
      }else if(a.equals("T")){
        a = "A";
      }else if(a.equals("G")){
        a = "C";
      }else{
        a = "G";
      }
      System.out.println(a);
    }
}

Measured memory_bytes: 20564
#include<cstdio>
#include<vector>
#include<cstring>
#include<cstdlib>
using namespace std;
int dot,line,a,b;
int ans=0;
bool vis[10];
vector <int> to[10];
bool check()
{
	for(int i=1;i<=dot;i++)
	if(!vis[i])return false;
	return true;
}
void dfs(int now)
{
	vis[now]=true;
	if(check())
	{
		ans++;
		return;
	}
	for(int i=to[now].size()-1;i>=0;i--)
	{
		if(!vis[to[now][i]])
		{
			dfs(to[now][i]);
			vis[to[now][i]]=false;
		}
	}
}
int main()
{
	memset(vis,false,sizeof(vis));
	scanf("%d%d",&dot,&line);
	for(int i=1;i<=line;i++)
	{
		scanf("%d%d",&a,&b);
		to[a].push_back(b);
		to[b].push_back(a);
	}
	dfs(1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<pi,null_type,less<pi>,rb_tree_tag,tree_order_statistics_node_update> indexed_set_pair;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)2e5+5;
const int M = (int)1e3+5;
const int Q = 102;
const int logN = 19;

const double pie = acos(-1);

void solve() {
  int x;
  cin>>x;
  x -= 400;
  cout<<(8-x/200);
}
int main() {
    //freopen("./sort/b2.in","r",stdin);
    //freopen("output.txt","w",stdout);

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

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 3608
//
//  main.cpp
//  ABC164
//
//
//  Copyright © 2020 エロやん. All rights reserved.
//

#include <iostream>
using namespace std;

int main() {
    // insert code here...
    int S,W;
    cin>>S>>W;
    if(S>W)
    cout << "safe";
    else
        cout<<"unsafe";
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        int[] times = new int[n];
        for (int i = 0; i < n; i++) {
            times[i] = Integer.parseInt(sc.next());
        }
        int cnt = 0;
        int bound = 0;
        for (int i = 0; i < n; i++) {
            bound += times[i];
            if (bound > x) break;
            else {
                cnt++;
            }
        }
        System.out.println(1 + cnt);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
long n,t,i=1,m,ans;
int main(){
	cin>>n;
	int a[n+1];
	for(;i<=n;i++)cin>>t,a[i]=t-i;
	sort(a+1,a+n+1);
	m=n%2?a[n/2+1]:(a[n/2]+a[n/2])/2;
	for(i=1;i<=n;)ans+=abs(a[i++]-m);
	cout<<ans<<endl;
	return 0;
}

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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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; }

struct mint {
    long long x;
    mint(long long x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
    	return *this;
    }
    mint& operator*=(const mint a) {
    	(x *= a.x) %= MOD;
    	return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
    	if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
    	return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};

struct combination {
    vector<mint> fact, ifact;
    combination(long long n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(long long n, long long k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main(void){
    ll n,a,b; cin >> n >> a >> b;
    mint ans(0);
    ans += mint(2).pow(n)-1;
    mint nCa(1), nCb(1);
    REP(i,a){
        nCa *= n-i;
        nCa /= a-i;
    }
    REP(i,b){
        nCb *= n-i;
        nCb /= b-i;
    }
    ans -= nCa + nCb;
    cout << ans.x << 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 rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int X;
    cin >> X;
    for(int i = 4; i <= 18; i+=2){
        if(i*100 <= X && X < (i+2)*100){
            cout << 8 - (i-4)/2 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3648
N = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
sum = 0
for a in as
    sum += a
end

ans = 1e15
sunuke = 0
for i in 0...(N[0]-1)
    sunuke += as[i]
    sum -= as[i]
    ans = [ans,  (sunuke - sum).abs].min
end
puts ans

=begin
    N, M = gets.split.map(&:to_i)
    AS = N.times{ gets.to_i }
=end


Measured memory_bytes: 19208
#include<stdio.h>
int main(void){
	int n,i,a[101];
	scanf("%d",&n);
	for(i=0;i<n;i++){scanf("%d",&a[i]);}
	int min=a[0],max=a[0];
	for(i=1;i<n;i++){
		min=a[i]<min?a[i]:min;
		max=max<a[i]?a[i]:max;
	}
	printf("%d",max-min);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main()
{
  int a,b,r,c;

  scanf("%d %d",&a,&b);

  if(a < b){
    c = a;
    a = b;
    b = c;  
  }
  
  r = a % b;
  
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }

  printf("%d\n",b);
  
  return 0;
}
  

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

const int limit = 50;

int n, m;
int a[limit], b[limit];

bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
    visited[v] = true;
    for (int v2 = 0; v2 < n ; ++v2){
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
    }
}

int main()
{
    cin >> n >> m;

    for (int i = 0; i < m ; i++) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    int ans = 0;

    for (int i = 0; i < m ; ++i) {
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = false;

        for (int j = 0; j < n; j++) visited[j] = false;

        dfs(0);

        bool bridge = false;
        for (int j = 0;j < n; j++) if (visited[j] == false) bridge = true;
        if (bridge) ans += 1;

        graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
    }

    cout << ans << endl;

    return 0;
}


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


signed main(){
    int n;
    cin>>n;
    vector<int> arr(n), circle;

    for(int &x: arr) cin>>x;

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

    int ans = 0;
    for(int i=0; i<n ;i++){
        circle.push_back(arr[i]);
        if(i) circle.push_back(arr[i]);
    }

    for(int i=0; i<n-1; i++) ans += circle[i];
    
    cout<<ans<<endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int K;
int A[111111];

int calc(int x){
    rep(i,K)x=x-x%A[i];
    return x;
}

signed main(){
    cin>>K;
    rep(i,K)cin>>A[i];

    int lb=0,ub=INF;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(calc(mid)<2)lb=mid;
        else ub=mid;
    }

    int w=lb;

    lb=0;ub=INF;
    while(ub-lb>1){
        int mid=(ub+lb)/2;
        if(calc(mid)>2)ub=mid;
        else lb=mid;
    }

    int v=ub;

    if(v-w>1){
        cout<<w+1<<" "<<v-1<<endl;
    }
    else{
        cout<<-1<<endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <list>
#include <tuple>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
template<class T> inline T sqr(T x) { return x*x; }
typedef pair<int, int> P;
typedef long long ll;
typedef unsigned long long ull;

#define For(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	For(i,0,n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define rall(a)		(a).rbegin(), (a).rend()
#define sz(a)		(sizeof(a))
#define Fill(a,v)	fill((int*)a,(int*)(a+(sz(a)/sz(*(a)))),v)

bool cheak(int x, int y, int xMax, int yMax){ return x >= 0 && y >= 0 && xMax > x && yMax > y; }
const int dx[4] = { -1, 0, 1, 0 }, dy[4] = { 0, 1, 0, -1 };
const int mod = 1000000007;
const int INF = 1e9;

int main()
{
	int m, t, p, r;

	while (cin >> m >> t >> p >> r && m){

		const int M = 51;
		tuple<int,int,int> d[M]; clr(d);
		rep(i, M)get<2>(d[i]) = i + 1;

		int w[M][M]; clr(w);

		rep(_, r){
			int tm, tt, tp, tj;
			cin >> tm >> tt >> tp >> tj;
			tt--;
			if (tj){
				w[tt][tp]++;
			}
			else{
				get<0>(d[tt])++;
				get<1>(d[tt]) -= w[tt][tp] * 20 + tm;
			}
		}
		sort(d, d + t,greater<tuple<int,int,int>>());
		rep(i, t){
			cout << get<2>(d[i]);
			For(j, i + 1, t){

				if (get<0>(d[i]) == get<0>(d[j]) &&
					get<1>(d[i]) == get<1>(d[j])){
					cout << "=" << get<2>(d[j]);
					i++;
				}

			}
			if (i != t-1)
			cout << ",";
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1180
from decimal import *

n = int(input())
T = [int(input()) for i in range(n)]

for i in range(n):
    T[i] = Decimal(T[i])

def gcd(x, y):
    while x != 0 and y != 0:
        x, y = max(x, y), min(x, y)
        x %= y
    return max(x, y)

ans = Decimal(1)
for i in range(n):
    if ans % T[i] != 0:
        ans = ans * T[i] / gcd(ans, T[i])
    #ans = int(ans + 0.1)
    #print(ans)
print(int(ans))

Measured memory_bytes: 61016
using System;

namespace ALDS1_1_B_Greatest_Common_Divisor
{
	class Program
	{
		static void Main ( string[] args )
		{
			int[] input = Array.ConvertAll (Console.ReadLine ().Split (' '), int.Parse);
			int result = GreatestCommonDivisor (input[0], input[1]);
			Console.WriteLine (result);
		}

		static int GreatestCommonDivisor ( int dividend, int divisor )
		{
			if (dividend < divisor)
			{
				var tmp = dividend;
				dividend = divisor;
				divisor = tmp;
			}

			int mod;

			while ((mod = dividend % divisor) != 0)
			{
				dividend = divisor;
				divisor = mod;
			}

			return divisor;
		}
	}
}



Measured memory_bytes: 9168
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;
#define MAX_N 1000001

bool divisible[MAX_N];
bool visited[MAX_N];
void init(){
	rep(i,MAX_N){
		divisible[i] = false;
		visited[i] = false;
	}
}

int A[MAX_N];

int main(){
	init();
	int n;
	cin>>n;
	rep(i,n){
		cin>>A[i];
	}
	sort(A,A+n);
	for(int i = 0; i < n; i++){
		if( divisible[A[i]] == false && visited[A[i]] == true){
			divisible[A[i]] = true;
		}else if( divisible[A[i]] == false && visited[A[i]] == false){
			visited[A[i]]   = true;
			for(int j = 2; A[i]*j <= MAX_N; j++){
				divisible[A[i]*j] = true;
			}
		}
	}
	int ans = 0;
	rep(i,n){
		if( divisible[A[i]] == false) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 5912
#!/usr/bin/env python
from collections import defaultdict, deque
import math
from math import factorial
import fractions
import re

BIGNUM = 10 ** 9 + 7

def main():
    A, B, C = map(int, input().split())

    remain = A - B
    result = max([0, C - remain])

    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
      cin >> vec[i];
    }
    ll ans = 0;
    for(int i=0; i<N; i++){
        if(vec[i] >= K){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 640
a,b = gets.split.map(&:to_i)
nrray = [*1..316]
mrray = nrray.map{|x| x*x }
if b<10
  if mrray.any?{|y| y == 10*a+b }
    puts "Yes"
  else
    puts "No"
  end
elsif b<100
  if mrray.any?{|y| y == 100*a+b }
    puts "Yes"
  else
    puts "No"
  end
else
  if mrray.any?{|y| y == 1000*a+b }
    puts "Yes"
  else
    puts "No"
  end
end


Measured memory_bytes: 1788
N, Y = map(int, input().split())
ans = ["-1", "-1", "-1"]

for i in range(N + 1):
    for o in range(((N - i + 1))):
        p = N - i - o
        if (10000 * i) + (5000 * o) + (1000 * p) == Y:
            ans = [str(i), str(o), str(p)]
        
print(" ".join(ans))

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

int main () {
  int N,K,R,S,P;
  string T;
  cin >> N >> K >> R >> S >> P >> T;
  int score = 0;
  
  for (int i = 0; i < N; i++) {
    if (i < K || T.at(i) != T.at(i-K)){
      if (T.at(i) == 'r'){
        score += P;
      }
      else if (T.at(i) == 's'){
        score += R;
      }
      else if (T.at(i) == 'p'){
        score += S;
      }
    }
    else {
      T.at(i) = 'a';
    }
  }
  cout << score << endl;
}
      
      
  
    
  
   

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main(){
	long double a,b,h,m,o;
	cin>>a>>b>>h>>m;
	if(m==0)
	o=abs(h*30-m*6);
	else
		o=abs(h*30+m/2-m*6);
	o=cos(o* 3.14159265358979323846264338327950288 / 180.0);
	cout<<fixed<<setprecision(20)<<sqrt(a*a+b*b-2*a*b*o)<<endl;;
  return(0);
}

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

using namespace std;

int main(void) {
	int num, k, i = 0;
	long long ans = 0, buf;
	cin >> num >> k;
	vector<int> d(num);
	for (; i < num; i++) {
		scanf("%d", &d[i]);
		if (d[i] > k) {
			ans += d[i] - k;
			d[i] = k;
		}
	}
	for (i = 1; i < num; i++) {
		buf = max(d[i - 1] + d[i] - k, 0);
		if (buf) {
			ans += buf;
			d[i] -= buf;
			if (d[i] < 0) {
				d[i - 1] += d[i];
				d[i] = 0;
			}
		}
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#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 ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;


int main(){
  int n; cin>>n;
  double res=0;
  double x[n];
  double y[n];

  REP(i,n)cin>>x[i]>>y[i];
  double sum=0;
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      double l=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
     
       sum+=sqrt(l);
     //cout<<x[i]-x[j]<<' '<<y[i]-y[j]<<' '<<l<<' '<<sum<<endl;
    }
  }//全長

  double honsuu=(n*(n-3))/2+n;
  double k=1;
  for(int i=n;i>0;i--)k*=i;

  res=((n-1)*sum);
  res/=honsuu;
  std::cout << std::fixed;
std::cout << std::setprecision(9) << res;
}

Measured memory_bytes: 256
//
// Created by ss250251 on 2/16/2020.
//

#include<bits/stdc++.h>
using namespace std;
#define INF 1e18L + 7
#define MOD 1e9+7
template <typename T>
void max_self(T&a,T b){
    a = max(a,b);
}
template <typename T>
void min_self(T&a,T b){
    a = min(a,b);
}

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>dp(m,0);
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            char c;
            cin>>c;
            if(c == '#'){
                dp[j] = 0;
                continue;
            }
            if (!i && !j){
                dp[j] = 1;
                continue;
            }
            if(!i && j){
                dp[j] = dp[j-1];
            }
            else if(i && !j){
                dp[j] = dp[j]&1;
            }
            else{
                dp[j] += dp[j-1];
                if(dp[j]>=MOD)dp[j] -= MOD;
            }
        }
    }
    cout<<dp[m-1];
}

Measured memory_bytes: 384
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

class InverseTable:
    __slots__ = ['In', 'fac', 'Ifac']

    def __init__(self, mod, maxnum):
        self.In = [0, 1]; self.fac = [1, 1]; self.Ifac = [1, 1]
        for i in range( 2, maxnum + 1 ):
            self.fac.append( ( self.fac[-1] * i ) % mod )
            self.In.append( ( -self.In[mod % i] * (mod//i) ) % mod )
            self.Ifac.append( (self.Ifac[-1] * self.In[-1]) % mod )
        
    def cmb(self, n, r):
        if ( r<0 or r>n ): return 0
        r = min(r, n-r)
        return self.fac[n] * self.Ifac[r] * self.Ifac[n-r] % mod

invt = InverseTable(mod, 10**6)

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        count=0
        while n % i==0:
            count+=1
            n = n//i
        if count!=0:
            ass.append((i,count))
    if n != 1:
        ass.append((n,1))
    return ass

n=int(input())
A=list(map(int,input().split()))
data=[0]*(10**6+10)
for ai in A:
    arr=prime_factor(ai)
    for ni,ci in arr:
        data[ni]=max(data[ni],ci)
pro=1
for i in range(1,len(data)):
    pro=pro*(i**data[i])
    pro%=mod

for ai in A:
    ans+=invt.In[ai]
print(ans*pro%mod)

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

using namespace std;

int main(void) {
	int num, mm, i = 0;
	long long a, ans = 0, cost = -1;
	cin >> num >> mm;
	vector<int> d(num);
	map<int, int> mp;
	for (; i < num; i++) {
		scanf("%d%d", &d[i], &a);
		mp[d[i]] += a;
	}
	sort(d.begin(), d.end());
	i = 0;
	while (mm > 0) {
		while (cost == d[i])
			i++;
		cost = d[i];
		a = min(mp[cost], mm);
		ans += cost * a;
		mm -= a;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 5376
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int digits(ll n){
  int cnt=0;
  while(n>0){
    n/=10;
    cnt++;
  }
  return cnt;
}

int main(int argc, char const *argv[]) {
  ll n;
  std::cin >> n;
  int min=digits(n);

  for(int i=2; i<=sqrt(n); i++ ){
    if(n%i==0){
      ll a=i,b=n/i;
      int ans=max(digits(a),digits(b));
      if(ans<min) min=ans;
    }
  }

  std::cout << min << '\n';

  return 0;
}


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

#define eb emplace_back 
vector<int> e[100001];
bool vis[100001];
vector<int> ans,Ans;
void dfs(int x){
	vis[x]=true;
	ans.eb(x);
	for(int it:e[x])
		if(!vis[it]){
			dfs(it);
			break;
		}
}
void Dfs(int x){
	vis[x]=true;
	Ans.eb(x);
	for(int it:e[x])
		if(!vis[it]){
			Dfs(it);
			break;
		}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	for(int i=0,u,v;i<m;i++){
		cin>>u>>v;
		e[u].eb(v);
		e[v].eb(u);
	}
	dfs(1);
	Dfs(1);
	cout<<ans.size()+Ans.size()-1<<endl;
	for(int i=Ans.size()-1;i>=1;i--)
		cout<<Ans[i]<<' ';
	for(int it:ans)
		cout<<it<<' ';
	cout<<endl;
}



Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()

ll A,B,C,D;
int main(){
    cin>>A>>B>>C>>D;
    while(A>0&&C>0){
        C-=B;
        if(C<=0){cout<<"Yes";break;}
        A-=D;
        if(A<=0){cout<<"No";break;}
    }
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int score=0;
  if(A>B){
    score+=A;
    A=A-1;
  }
  else{
    score+=B;
    B=B-1;
  }
  if(A>B){
    score+=A;
    A=A-1;
  }
  else{
    score+=B;
    B=B-1;
  }
  cout<<score<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
vll div(ll N)
{
    vll yakusuu;
    for (ll i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            yakusuu.push_back(i);
            if (i * i != N)
                yakusuu.push_back(N / i);
        }
    }
    return yakusuu;
}

int main()
{
    int N, K;
    cin >> N >> K;
    vll A(N);
    ll sum = 0;
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    }
    int ans = 0;
    auto fac = div(sum);
    vint res(N);
    for (int &&f : fac)
    {
        
        for (size_t i = 0; i < N; i++)
        {
            res[i] = A[i] % f;
        }
        sort(all(res));
        ll l = 0, r = N - 1, cnt = 0;
        while (l < r)
        {
            int t = min(res[l], f - res[r]);
            cnt += t;
            res[l] -= t;
            res[r] = (res[r]+t)%f;
            if (res[l] == 0)
            {
                l++;
            }
            if (res[r] == 0)
            {
                r--;
            }
        }
        if (cnt <= K)
        {
            chmax(ans, f);
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
    a[i] = min(a[i], 3200)
    b.append(a[i] // 400)
b = sorted(b)
if 8 in b:
    free = b.count(8)
    b_max = len(set(b[:-free])) + free
    print("{} {}".format(max(len(set(b)) - 1, 1), b_max))
else:
    print("{} {}".format(len(set(b)), len(set(b))))

Measured memory_bytes: 3064
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
ll GCD(ll a,ll b) {return b ? GCD(b,a%b):a;}
ll LCM(ll c,ll d){return c/GCD(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    int n;
    cin>>n;
    V<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(all(a));
    ll d=*max_element(all(a));
    map<int,int> mp;
    if(d%2==0){
        mp[d/2];
        for(int i=0;i<n;i++){
            if(a[i]<d/2){
                    cout<<"Impossible"<<"\n";
                    return 0;
                }
            else if(i&&a[i]-a[i-1]>1){
                 cout<<"Impossible"<<"\n";
                    return 0;
            }
            mp[a[i]]++;
        }
        for(auto p:mp){
            if(p.fi==d/2){
                if(p.se!=1){
                    cout<<"Impossible"<<"\n";
                    return 0;
                }
            }
            else if(p.se<2){
                cout<<"Impossible"<<"\n";
                    return 0;
            }
        }
    }else{
        mp[(d+1)/2];
        for(int i=0;i<n;i++){
            if(a[i]<(d+1)/2){
                    cout<<"Impossible"<<"\n";
                    return 0;
            }
            else if(i&&a[i]-a[i-1]>1){
                 cout<<"Impossible"<<"\n";
                    return 0;
            }
            mp[a[i]]++;
        }
        for(auto p:mp){
            if(p.fi==(d+1)/2){
                if(p.se!=2){
                      cout<<"Impossible"<<"\n";
                    return 0;
                }
            }
            if(p.se<2){
                cout<<"Impossible"<<"\n";
                    return 0;
            }
        }
    }
    cout<<"Possible"<<"\n";
}


Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define CL clear()



int main()
{
int n;
 cin >> n;
 int arr[n];
 for(int i = 0; i < n; i++) cin >> arr[i];
 int t  = 0, s = 0;
 for(int i = 0; i < n-1; i++)
 {
     if(arr[i]< arr[i+1])
     {
         s = max(s, t);
         t = 0;
     }
     else t++;
 }

 cout << max(s,t);


}




Measured memory_bytes: 640
#pragma region Macros
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;
constexpr double EPS = 1e-10;
#pragma endregion

void solve() {
    int n, k, s;
    cin >> n >> k >> s;
    int pad = 0;
    for (int i=1; i<1e9; i++) {
        if (s%i != 0) {
            pad = i;
            break;
        }
    }
    for (int i=0; i<n; i++) {
        if (i < k) {
            cout << s;
        } else {
            cout << pad;
        }
        if (i == n-1) {
            cout << "\n";
        } else {
            cout << " ";
        }
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


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

using namespace std;

long long v[100005];
long long cnt[100005];
int a[100005];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);

	for(int i=2;i<=n;i++){
		if(a[i] > a[i-1]){
			// case 1
			int diff = a[i]-a[i-1];
			v[a[i]+1] += diff;
			v[1] += diff;
			v[a[i-1]+1] -= diff;

			// case 2
			v[a[i-1]+1] += diff+1;
			cnt[a[i-1]+1]++;
			v[a[i]+1]--;
			cnt[a[i]+1]--;
		}
		else{
			// case 1
			int diff = m-(a[i-1]-a[i]);
			v[a[i]+1] += diff;
			v[a[i-1]+1] -= diff;

			// case 2
			v[a[i-1]+1] += diff+1;
			cnt[a[i-1]+1]++;
			v[1] += diff - (m-a[i-1]) + 1;
			cnt[1]++;
			v[a[i]+1]--;
			cnt[a[i]+1]--;
		}
	}

	long long sum = 0;
	long long tot = 0;

	long long ans = 1e18;
	for(int i=1;i<=m;i++){
		sum += v[i];
		tot += cnt[i];
		sum -= tot;

		ans = min(ans, sum);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int a,b; cin>>a>>b;
  if(b<10)
  a*=10;
  else if(b<100)
  a*=100;
  else
  a*=1000;
  a+=b;
  // cout<<a<<endl;
  rep(i,100001){
    int k=i*i;
    if(k==a){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}


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

typedef long long ll;
///vector<pair<string, int>>;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n, 0);
  ll count = 1;
  ll inc =0;
  ll dec = 0;
  rep(i, n) cin >> a[i];

  rep(i, n-1){
    if(a[i+1]-a[i]>0)inc++;
    else if(a[i+1]-a[i]<0) dec++;

    if(dec>0 && inc>0){
      count++;
      
      dec = 0;
      inc = 0;
    }
  }
  
  cout << count << endl;
}




Measured memory_bytes: 4016
N = int(input())
T = list(map(int, input().split()))
V = list(map(int, input().split()))

l = sum(T) * 2 + 1
t_cond = [0] + T + [0]
v_cond = [0] + V + [0]
memo = [[0] * l for _ in range(N + 2)]
left = 0
for i in range(N + 2):
    for j in range(l):
        if j < left:
            memo[i][j] = v_cond[i] + (left - j) * 0.5
        elif left <= j <= left + t_cond[i] * 2:
            memo[i][j] = v_cond[i]
        else:
            memo[i][j] = v_cond[i] + (j - left - t_cond[i] * 2) * 0.5
            
    # Shift lower bound
    left += t_cond[i] * 2

f = [min(memo[i][j] for i in range(N + 2)) for j in range(l)]
ans = 0
for i in range(l - 1):
    ans += 0.25 * (f[i] + f[i + 1])
print(ans)


Measured memory_bytes: 139920
import sys
input = sys.stdin.readline

h, w, K = map(int, input().split())
s = []
for i in range(h):
    s.append(input().rstrip())

ans = float('inf')

for i in range(2 ** (h-1)):
    # 仕切り 1, 2, ...
    sep = [0]
    for j in range(h-1):
        if i & (1 << j):
            sep.append(j+1)

    memo = [0 for _ in range(len(sep))]
    cnt = 0
    

    # print(memo)
    # print('new sep: {}'.format(sep))

    for k in range(w):
        # print(memo)
        memo2 = [0 for _ in range(len(sep))]
        sep_index = 0
        for l in range(h):
            # print(sep_index)
            if sep_index < len(sep) - 1 and sep[sep_index+1] <= l:
                sep_index += 1
                # print('yay', l, sep_index)
            if s[l][k] == '1':
                if memo[sep_index] + memo2[sep_index] == K:
                    cnt += 1
                    memo = [0 for _ in range(len(sep))]
                memo2[sep_index] += 1
                if memo2[sep_index] > K:
                    cnt += ans
        for ii in range(len(sep)):
            memo[ii] += memo2[ii]
    ans = min(ans, cnt + len(sep) - 1)

print(ans)
            

Measured memory_bytes: 50524
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()

const int N = 2e3 + 2;

int n;
vector<int> g[N];
int ans[N], vis[N];

int main()
{
  cin >> n;
  for(int i = 0 ; i + 1 < n ; i++)
    g[i].pb(i + 1), g[i + 1].pb(i);
  int x, y;
  cin >> x >> y;
  y--, x--;
  g[x].pb(y);
  g[y].pb(x);
  for(int i = 0 ; i < n ; i++) {
    for(int j = 0 ; j < n ; j++)
      vis[j] = -1;
    queue<int> q;
    q.push(i);
    vis[i] = 0;
    while(q.size()) {
      int u = q.front();
      q.pop();
      ans[vis[u]]++;
      for(int v : g[u]) {
        if(vis[v] == -1) {
          vis[v] = 1 + vis[u];
          q.push(v);
        }
      }
    }
  }
  for(int i = 1 ; i < n ; i++)
    cout << ans[i] / 2 << endl;
  return 0;
}


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

static const int INF = 1000000;
int distS[200][200], distL[200][200];
int route[10000];
int dp[10000][200];

int main()
{
  int N, M;
  while (cin >> N >> M && !(N == 0 && M == 0)) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        distS[i][j] = distL[i][j] = INF;
      }
      distS[i][i] = distL[i][i] = 0;
    }

    for (int i = 0; i < M; i++) {
      int x, y, t;
      char sl;
      cin >> x >> y >> t >> sl;
      x--;  y--;
      if (sl == 'S') {
        distS[x][y] = distS[y][x] = t;
      } else {
        distL[x][y] = distL[y][x] = t;
      }
    }

    int R;
    cin >> R;
    for (int i = 0; i < R; i++) {
      cin >> route[i];
      route[i]--;
    }

    for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
          distS[i][j] = min(distS[i][j], distS[i][k] + distS[k][j]);
          distL[i][j] = min(distL[i][j], distL[i][k] + distL[k][j]);
        }
      }
    }

    for (int j = 0; j < N; j++) {
      dp[0][j] = distS[route[0]][j];
    }
    for (int i = 1; i < R; i++) {
      for (int j = 0; j < N; j++) {
        dp[i][j] = dp[i-1][j] + distL[route[i-1]][route[i]];
        for (int k = 0; k < N; k++) {
          dp[i][j] = min(dp[i][j], dp[i-1][k] + distL[route[i-1]][k] + distS[k][j] + distL[j][route[i]]);
        }
      }
    }

    int ans = INF;
    for (int i = 0; i < N; i++) {
      ans = min(ans, dp[R-1][i]);
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1972
#include <stdio.h>
int main()
{
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);

    int sum = a + b + c;

    if((a == b + c) || (b == a + c) || (c == b + a))
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}

Measured memory_bytes: 128
from collections import defaultdict
N = int(input())
C = [int(input()) for i in range(N)]
MOD = 10 ** 9 + 7

dp = [0] * (N + 1)
dp[0] = 1

D = defaultdict(int)
for i, c in enumerate(C, start=1):
    dp[i] += dp[i - 1]
    if D[c] > 0 and D[c] != i - 1:
        dp[i] += dp[D[c]]
    dp[i] %= MOD
    D[c] = i

print(dp[-1] % MOD)


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a+b > c+d) cout << "Left" << endl;
  else if (a+b < c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>

using namespace std;

#define ll long long

int main(void){
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8


import fractions
gcd = fractions.gcd

def main():
    N = int(input())
    la = list(map(int, input().split()))
    # l(i+1) = gcd(l(i), a(i)), l(0) = 0
    ll = [0]
    # r(i) = gcd(r(i+1), a(i)), r(N+1) = 0
    lr = [0]
    for i in range(N):
        l = gcd(ll[-1], la[i])
        ll.append(l)
        r = gcd(lr[-1], la[N-1-i])
        lr.append(r)
    m = 1
    for i in range(N+1):
        m = max(m, gcd(ll[i], lr[N-1-i]))
    print(m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16068
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void){
  int a,b,n;
  scanf("%d", &n);
  scanf("%d", &a);
  scanf("%d", &b);
  int i = 0;
  char str[n];
  scanf("%s",str);
  while(n>0){
    if(str[i]=='a'){
      if(a+b>0)
	printf("Yes\n");
      else
	printf("No\n");
      if(a>0)
	a--;
      else
	b--;
	
    }
    if(str[i]=='b'){
      if(b>0)
	printf("Yes\n");
      else
	printf("No\n");
      if(b>0)
	b--;
    }
    if(str[i]=='c')
      printf("No\n");
    n--;
    i++;
  }


  return EXIT_SUCCESS;
}


Measured memory_bytes: 640
N, L = map(int, input().split())

sum_all = 0
for i in range(N):
    sum_all += L + i

if L >= 0:
    ans = sum_all - L
elif N <= abs(L):
    ans = sum_all - (L + N - 1)
else:
    ans = sum_all

print(ans)

Measured memory_bytes: 3060
while True:
    try:
        n, m = map(int, input().split())
        
        if n==0 and m==0:
            break
    except:
        break
    
    Taro = []
    for i in range(n):
        s = int(input())
        Taro.append(s)
    Hana = []
    for i in range(m):
        s = int(input())
        Hana.append(s)
    
    koukan = []
    kknsum = []
    for i in range(n):
        taro = Taro
        tarou = taro[i]
        taro.pop(i)
        tsum = sum(taro)
        taro.insert(i,tarou)
        for j in range(m):
            hana = Hana
            hanak = hana[j]
            hana.pop(j)
            hsum = sum(hana)
            hana.insert(j,hanak)
            sumTa = tsum + hanak
            sumHa = hsum + tarou
            if sumTa==sumHa:
                koukan.append([tarou, hanak])
                kknsum.append(tarou+hanak)
    
    if koukan==[]:
        print('-1')
    
    else:
        kknmin = min(kknsum)
        index = kknsum.index(kknmin)
        kk = koukan[index]
        print(kk[0], kk[1])


Measured memory_bytes: 6532
n = int(input())
#num = []
s = []
d = []
kansei = []
#kansei.append(0)
#num.append(0)
#s.append(0)
#d.append(0)

k = 0

for i in range(n):
    e = input().split()
    b = str(e[0])
    c = int(e[1])
    s.append(b)
    d.append(c)
    kansei.append(0)

for i in range(n):
     #kansei[k] = i
     k = 0
     for j in range(n):
        if s[i] > s[j]:
            k += 1
        elif s[i] == s[j]:
            if d[i] < d[j]:
                k += 1
     kansei[k] = i + 1
     

for i in range(n):
    print(kansei[i])

    

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;

int  A[1005][1005];

struct node {
	int i;
	int j;
	int step;
}find1[1000001];;
const int movex[] = { -1,0,0,1 };
const int movey[] = { 0,1,-1,0 };
int k = 1;

int main() {
	int H, W;
	cin >> H >> W;
	char c;
	
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> c;
			if (c == '#') { A[i][j] = 1; find1[k].i = i; find1[k].j = j; find1[k].step = 0; k++; }
			if (c == '.') { A[i][j] = 0; }

		}
	}
	int p = 1;
	int ans = 0;
	k --;
	while (p<=k) {
		ans = max(ans, find1[p].step);
		for (int i = 0; i < 4; i++) {
			int x = movex[i] + find1[p].i;
			int y = movey[i] + find1[p].j;
			if (x >= 1 && x <= H && y >= 1 && y <= W && A[x][y] == 0) {
				A[x][y] = 1;
				k++;
				find1[k].i = x;
				find1[k].j = y;
				find1[k].step = find1[p].step + 1;
			}
		}
		p++;
	}
	cout << ans << endl;
	return 0;
}

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

bool Linear(int x,int s[],int n){
  for(int i=0; i<n; i++){
    if(s[i]==x)
      return true;
  }

  return false;
}

int main(){
  int n;
  cin >> n;

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

  int q;
  cin >> q;

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

  int count=0;
  for(int i=0; i<q; i++){
    if(Linear(t[i],s,n)!=0){
      count++;
    }
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 3108
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e15)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int n; cin>>n;
	string s; cin>>s;
	int ans=1;
	For(i,1,n-1) if(s[i]!=s[i-1]) ans++;
	cout<<ans<<"\n";
	return 0;
}

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

int main () {
  
  int a,b,c;
  int divisor_num = 0;

  cin >> a >> b >> c;

  for (int n = a; n <= b; n++) {
    if (c % n == 0)
      divisor_num += 1;
  }

  cout << divisor_num << endl;

  return 0;
}



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

void insertSort(int a[],int n);
void datalog(int a[],int n);

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

    datalog(a,n);
    insertSort(a,n);

    return 0;
}

void insertSort(int a[],int n){
    int v,j;
    for(int i=1;i<n;i++){
        v=a[i];
        j=i-1;
        while(0<=j && v<a[j]){
            a[j+1]=a[j];//一個ずらす//元々入ってたa[j+1]
            j--;
        }
        a[j+1]=v;
        datalog(a,n);
    }
}

void datalog(int a[],int n){
    for(int i=0;i<n;i++){
        cout << (i? " ": "") <<a[i];
    }
    cout <<"\n";
}


/*
algorothm
insertion sort(A,N)
   for i->n;
    v=A[i]
    j=i-1;
    while(j>=0 && A[j]>v)
        A[j+1]=A[j]
        j--
    A[j+1]=v
*/




Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>

typedef long long ll;

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> W(N, 0);
    for (int i = 0; i < N; i++) { cin >> W[i]; }

    int diff_max = INT_MAX;
    for (int T = 0; T < N - 1; T++) {
        int S1 = 0;
        int S2 = 0;
        for (int i = 0; i <= T; i++) S1 += W[i];
        for (int i = T + 1; i < N; i++) S2 += W[i];
        diff_max = min(diff_max, abs(S1 - S2));
    }

    cout << diff_max << endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
#define all(v) v.begin(),v.end()
#define endl "\n"
#define clr(n, r) memset(n,r,sizeof(n));

void fast() {
    cin.tie(0);
    cin.sync_with_stdio(0);
}
int main(){
    fast();
    int a,b;cin>>a>>b;
    cout<<a*b;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define endl '\n'
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

int gcd3(int a, int b, int c) {
    return __gcd(a, __gcd(b, c));
}

int main() {
    int k;
    cin >> k;

    ll ans = 0;
    for(int a = 1; a <= k; a++) {
        for(int b = 1; b <= k; b++) {
            for(int c = 1; c <= k; c++) {
                ans += 1LL * gcd3(a, b, c);
            }
        }
    }
    cout << ans << endl;


}


Measured memory_bytes: 3624