akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>; // グラフ型

int main()
{
    string s; cin >> s;
    string t; cin >> t;
    int ans = 0;

    rep(i,s.size()){
        if(s[i]!=t[i]) ans++;
    }
    cout << ans << endl;
}

/*
g++ b.cpp
./a.out

oj d https://atcoder.jp/contests/abc172/tasks/abc172_b
oj t
*/


Measured memory_bytes: 3916
import numpy as np
N,D = map(int,input().split())

X = []
for i in range(N):
    X.append(list(map(int,input().split())))
X = np.array(X)

t=0
for i in range(N):
    for j in range(i+1,N):
        d = (X[i]-X[j])**2
        d = np.sum(d)
        if d**0.5==int(d**0.5):
            t += 1

print(t)

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

int main() {
  int N; cin >> N;
  int Degit_Sums = 0;
  int n = N;
  while (n>0) {
    Degit_Sums += n%10;
    n/=10;
  }
  if (N%Degit_Sums == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  ll cnt=0;
  for(int i=1;i<N;i+=3){
    cnt+=(N+(i&1))/2;
  }
  if((N-1)%3==0){cnt+=(N+(N-1&1))/2;}
  for(int i=2;i<N;i+=3){cnt++;}
  cout<<cnt<<endl;
  for(int i=1;i<N;i+=3){
    for(int j=(i&1?0:1);j<N;j+=2){cout<<i<<" "<<j<<endl;}
  }
  if((N-1)%3==0){
    for(int j=(N-1&1?0:1);j<N;j+=2){cout<<N-1<<" "<<j<<endl;}
  }
  for(int i=2;i<N;i+=3){cout<<i<<" "<<(i&1?0:1)<<endl;}


  return 0;
}


Measured memory_bytes: 1536
// C# program to build the smallest number 
// by removing n digits from a given number 
using System;
using System.Collections.Generic;
using System.Linq;
class GFG
{
    static List<int> ans1 = new List<int>();
    static List<int> ans2 = new List<int>();
    public static void Main(String[] args)
    {
        var input1 = Console.ReadLine().Split(' ');
        var n = int.Parse(input1[0]);
        var k = int.Parse(input1[1]);

        for (int i = 0; i < k; i++)
        {
            var d = int.Parse(Console.ReadLine());

            var arr = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Cheat(n, k, d, arr);
        }

        var ans = ans2.Except(ans1);

        Console.Write(ans.Count());


    }

    public static void Cheat(int n, int k, int d, int[] arr)
    {

        for (int i = 1; i <= n; i++)
        {
            if (arr.Contains(i))
            {
                ans1.Add(i);
            }
            else
            {
                ans2.Add(i);
            }
        }

    }
}




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

typedef long long ll;
const int INF = 1e9;
const ll INFF = 1e18;
const int MAXN = 510;
const int MOD = 1e9 + 7;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	// vector<int> urutan;
	// vector<int> ans;
	// for (int n = 1 ; n <= 8 ; n++)
	// {
	// 	urutan.clear();
	// 	ans.clear();
	// 	for (int i = 1 ; i <= n ; i++)
	// 		urutan.push_back(i);
	// 	// continue;
	// 	int mx = 0;
	// 	do{
	// 		int cnt = 0;
	// 		for (int i = 0 ; i < n ; i++)
	// 			cnt += (i + 1) % urutan[i];
	// 		// cout << cnt << endl;
	// 		if (cnt > mx)
	// 		{
	// 			// cout << cnt << endl;
	// 			mx = cnt;
	// 			ans = urutan;
	// 		}
	// 		// if (cnt == 28)
	// 		// {
	// 		// 	for (int i = 0 ; i < urutan.size() ; i++)
	// 		// 		cout << ans[i] << " ";
	// 		// 	cout << endl;	
	// 		// }
	// 	} while (next_permutation(urutan.begin(),urutan.end()));
	// 	cout << mx << endl;
	// 	// for (int i = 0 ; i < urutan.size() ; i++)
	// 	// 	cout << ans[i] << " ";
	// 	// cout << endl;
	// }
	ll n;
	cin >> n;
	ll ans = (n * (n - 1)) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[])
{
    char str[21];
    scanf("%s",str);
    int i;
    int len = strlen(str) - 1;
    for(i = len;i >= 0;i--){
        printf("%c",str[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#include <stdlib.h>

typedef struct _node {
	signed int key;
	struct _node *left;
	struct _node *right;
} node;

node *allocNode(int key) {
	node *p = (node *)malloc(sizeof(node));
	p->key = key;
	p->left = NULL;
	p->right = NULL;
	return p;
}

void terminate(node *p) {
	if (p == NULL) return;
	terminate(p->left);
	terminate(p->right);
	free(p);
}
void insert(node **T, node *z) {
	node *y = NULL;
	node *x = *T;
	while (x != NULL) {
		y = x;
		if (z->key < x->key) x = x->left;
		else x = x->right;
	}
	if (y == NULL) *T = z;
	else if (z->key < y->key) y->left = z;
	else y->right = z;
}

void preParse(node *p) {
	if (p == NULL) return;
	printf(" %d",p->key);
	preParse(p->left);
	preParse(p->right);
}
void inParse(node *p) {
	if (p == NULL) return;
	inParse(p->left);
	printf(" %d",p->key);
	inParse(p->right);
}

int main() {
	int n, i, key;
	char order[7];
	node *p, *root = NULL;
	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%s %d", order, &key);
		switch (order[0])
		{
		case 'i':
			p = allocNode(key);
			insert(&root, p);
			break;
		case 'p':
			inParse(root);
			printf("\n");
			preParse(root);
			printf("\n");
			break;
		}
	}
	terminate(root);
	return 0;
}



Measured memory_bytes: 17352
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <bitset>
#include <utility>
#include <queue>
#include <deque>

using namespace std;

bool test(const string& s){
    int n;
    n = s.size();
    for(int i=0;i<n;++i){
        if(s[i]!=s[n-i-1]) return false;
    }
    for(int i=0;i<(n-1)/2;++i){
        if(s[i]!=s[(n-1)/2-i-1]) return false;
    }
    for(int i=(n+3)/2-1;i<n;++i){
        if(s[i]!=s[n+(n+3)/2-i-2]) return false;
    }
    return true;
}

int main(){

    string S;
    cin >> S;

    if(test(S)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int> v(N);
    int i;
    for(i=0; i<N; i++) cin >> v.at(i);

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

    double ans = (v.at(0) + v.at(1)) / 2.0;

    for(i=2; i<N; i++){
        ans = (ans + v.at(i)) / 2.0;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
MOD = 10 ** 9 + 7
cnt = [0] * (k + 1)

for gcd in range(1, k + 1):
    cnt[gcd] = pow(k // gcd, n, MOD)

for gcd in range(k, 0, -1):
    for i in range(2, k // gcd + 1):
        cnt[gcd] -= cnt[gcd * i]

ans = sum([num * c for num, c in enumerate(cnt)]) % MOD
print(ans)

Measured memory_bytes: 15580
#include <bits/stdc++.h>
#include <math.h>
#include <iostream>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
 
int main(void){
    int N;
    cin >> N;
    int student[N], A;
    REP(i,N){
        cin >> A;
        student[A-1] = i+1;
    }
    REP(i,N){
        printf("%d ",student[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int sum1[105],sum2[105],arr1[105],arr2[105];
int main()
{
    int n,cnt,mx=0;
    cin>>n;
    for(int i= 1; i <= n; i++) {
        cin>>arr1[i];
        sum1[i] = sum1[i-1] + arr1[i];
    }
    for(int i = 1; i <= n; i++){
        cin>>arr2[i];
        sum2[i] = sum2[i-1] + arr2[i];
    }
    for(int i = 1; i <= n; i++) {
        cnt = sum1[i] + sum2[n] - sum2[i-1];
        mx = max(mx,cnt);
    }
    cout<<mx<<endl;
}


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

typedef struct{
  char name[10];
  int qms;
}P;

void Calc(int,int);
void enqueue(P);
P dequeue(void);

P pro[100000];
int head=0,tail=0;

int main()
{
  int n,q,i;

  scanf("%d%d",&n,&q);

  for(i=0;i<n;i++){
    scanf("%s%d",pro[tail].name,&pro[tail].qms);
    tail = (tail+1)%100000;
  }

  Calc(q,n);

  return 0;
}

void Calc(int q,int n)
{
  P a;
  int Q=0;
  
  while(1){
    a = dequeue();
    if(a.qms > q){
      a.qms = a.qms-q;
      enqueue(a);
      Q += q;
    }
    else if(a.qms <= q){
      Q += a.qms;
      printf("%s %d\n",a.name,Q);
      n--;
      if(n==0) break;
    }
  }
}

void enqueue(P b)
{
  pro[tail] = b;
  tail = (tail+1)%100000;
}

P dequeue(void)
{
  P d;

  d = pro[head];
  head = (head+1)%100000;

  return d;
}


  
  
    
    
    
    
    
  



Measured memory_bytes: 3268
import java.util.*;
import java.lang.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String S = String.valueOf(N);
		char a = S.charAt(0);
		char b = S.charAt(1);
		char c = S.charAt(2);
		if( a=='7' || b=='7' || c=='7' ){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35808
N=int(input())
M=10**9+7
ans=1
m=1
for i in range(N):ans=(ans*10)%M
for i in range(N):m=(m*9)%M
ans-=(m*2)%M
m=1
for i in range(N):m=(m*8)%M
print((ans+m)%M)

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

int main(){

    ll A,B,N;
    cin >> A >> B >> N;
    if(N<B) cout << (A*N-A*N%B)/B << endl;
    else cout << (A*(B-1)-A*(B-1)%B)/B << endl;
}


Measured memory_bytes: 3636
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
  
if __name__=="__main__":
  n=int(input())
  if n==1:
    print(0)
  else:
    soinnsuu=factorization(n)
    ans = 0
    for sosuu in soinnsuu:
      x = 1
      while True:
        if sosuu[1]>=x:
          ans+=1
          sosuu[1]-=x
          x+=1
        else:
          break
    print(ans)

Measured memory_bytes: 9500
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define c(P)        cout<<P<<"\n"
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp(x,y)     make_pair(x,y) 
#define exit(x)     cout<<x<<"\n",return
#define mem(a,val)  memset(a,val,sizeof(a))
#define fr(i,a,n)   for(ll i=a;i<n;i++)
#define frr(i,a,n)  for(ll i=n-1;i>=a;i--)
const ll N=500005;
const ll mod = 1e9 + 7;

using namespace std;

void lcs(string s, string t,ll n,ll m)
{
  ll table[n+1][m+1];

  for (int i = 0; i <= n; ++i)
  {
   fr(j,0,m+1)
   {
    if(i==0 or j==0)
      table[i][j] = 0;
    else if(s[i-1]==t[j-1])
    {
      table[i][j] = table[i-1][j-1] +1;

    }
    else
    {
      table[i][j] = max(table[i-1][j],table[i][j-1]);
    }
   }
  }
  ll index = table[n][m];
char lcs[index+1]; 
lcs[index] = '\0';
  
   // Start from the right-most-bottom-most corner and 
   // one by one store characters in lcs[] 
   ll i = n, j = m; 
   while (i > 0 && j > 0) 
   { 
      // If current character in X[] and Y are same, then 
      // current character is part of LCS 
      if (s[i-1] == t[j-1]) 
      { 
          lcs[index-1] = s[i-1]; // Put current character in result 
          i--; j--; index--;     // reduce values of i, j and index 
      } 
  
      // If not same, then find the larger of two and 
      // go in the direction of larger value 
      else if (table[i-1][j] > table[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   // Print the lcs 
   cout << lcs; 
}
void solve()
{
  ll T=1;
  //cin>>T;
  while(T--)
  {
  string s,t;
  ll n,m,k,c=0,q,ans=0;
  cin>>s>>t;
  n = s.length();
  m = t.length();
lcs(s,t,n,m);

 }
}

signed main(){
 
        ios_base::sync_with_stdio(false);   
        cin.tie(NULL);
       solve();
    return 0;
    }


Measured memory_bytes: 70656
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな　オーバーフローする
//開区間と閉区間どうにかしろ
//アルファベットが何番目かは x=s[i]-'a'
const ll MOD = 1000000007;
int h,w;
string s[444];

int main(){
    cin >> h >> w;
    rep(i,h) cin >> s[i];
    bool visit[h][w];
    memset(visit,0,sizeof(visit));
    ll ans=0;
    rep(i,h){
        rep(j,w){
            if(!visit[i][j]){
                
    ll bl=0,wh=0;
    queue<P> q;
    q.push({i,j});
    visit[i][j]=1;
    if(s[i][j]=='#') bl++;
    else wh++;
    int dy[4]={1,0,-1,0};
    int dx[4]={0,1,0,-1};
    while(!q.empty()){
        P d=q.front(); q.pop();
        rep(k,4){
            int ny=d.fi+dy[k]; int nx=d.se+dx[k];
            if(0<=ny && ny<h && 0<=nx && nx<w && s[d.fi][d.se]!=s[ny][nx] && (!visit[ny][nx])){
                q.push({ny,nx});
                visit[ny][nx]=1;
                if(s[ny][nx]=='#') bl++;
                else wh++;
        
            }
        }
    }
    ans+=bl*wh;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 640
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      String s = sc.next();
      int count = 0;
      for(char c = 'a';c <= 'z';c++){
      	for(int i = 0;i < s.length();i++){
        	if(s.charAt(i)==c)count++;
        }
        if(count%2==1){
        	System.out.println("No");
            return;
        }
        count = 0;
      }
      System.out.println("Yes");
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
//#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}

const int N = 100100;
int good[N],bad[N];

int32_t main(){
 fastio;
 int n,m;
 cin>>n>>m;
 int res=0,res2=0;
 for(int i=0;i<m;i++){
  int p;
  cin>>p;
  string s;
  cin>>s;

  if(s=="AC"){
    if(good[p]==0){
    res+=bad[p];
      res2++;
    bad[p]=0;
    }
      good[p]=1;
  }else if(!good[p])bad[p]++;

 }
 cout << res2 <<" "<<res<< endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 1792
import itertools
n,m = map(int,input().split())
e = [list(map(int,input().split())) for _ in range(m)]

seq = tuple([x for x in range(2,n+1)])
route = list(itertools.permutations(seq))

ans = 0
for t in route:
    now = 1
    flag = True
    t = list(t)
    for i in t:
        (p,q) = (now,i) if now < i else (i,now)
        if [p,q] not in e:
            flag = False
            break
        now = i
    if flag:
        ans += 1

print(ans)

Measured memory_bytes: 3572
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

VI g[100010];
signed main(void)
{
  int n;
  cin >> n;
  REP(i, n-1) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    g[u].PB(v);
    g[v].PB(u);
  }

  VI dist(n);
  function<void(int,int)> dfs1 = [&](int v, int p) {
    for(int &i: g[v]) if(i != p) {
      dfs1(i, v);
      chmax(dist[v], dist[i] + 1);
    }
  };

  dfs1(0, -1);
  // cout << dist << endl;

  // ans[i] = (頂点iから最も遠い頂点)
  VI ans(n);
  function<void(int,int,int)> dfs2 = [&](int v, int pval, int p) {
    // vの子の情報を集める
    vector<PII> d_child;
    // d_child[0], d_child[1]が存在しないのを防ぐ
    d_child.PB({0, -1});
    for(int &i: g[v]) {
      if(i == p) d_child.PB({pval+1, i});
      else d_child.PB({dist[i]+1, i});
    }
    sort(ALL(d_child), greater<>());
    ans[v] = d_child[0].first;
    for(int &i: g[v]) if(i != p) {
      // pvalはd_childの最大が基本
      // 最大が頂点iの部分木ならそれがpvalにはならないので次に大きいのをpvalにする
      dfs2(i, d_child[d_child[0].second == i].first, v);
    }
  };

  dfs2(0, 0, -1);
  // cout << ans << endl;

  // 全ての辺を2回通るのが基本で最大の深さのところだけ行って戻らないので片道分でいい
  REP(i, n) cout << 2*(n-1) - ans[i] << endl;

  return 0;
}



Measured memory_bytes: 31552
from operator import itemgetter

N = int(input())
SP = tuple(input().split() for _ in range(N))

# input -> (str, int)
SP_list = []
for i in SP:
    i[1] = int(i[1])
    SP_list.append(i)

# add number to head of these lists
for i in range(len(SP)):
    SP_list[i].insert(0, i+1)

SP_list = sorted(SP_list, key=itemgetter(2))
SP_list = sorted(SP_list, key=itemgetter(1), reverse=True)

for i in reversed(SP_list):
    print(i[0])

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int X;
  int A=0;
  int B=0;
  cin >>X;
  while(1)
  {
   A=A-X;
   B++;
   if(A<0)A=A+360;
   if(A==0)break;
  }
  cout << B;
}

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

int main() {
    int N; int64_t X;
    cin >> N >> X;
    vector<int64_t> BP(N + 1), P(N + 1);
    BP[0] = 1, P[0] = 1;
    for(int i = 0; i < N; ++i) {
        BP[i + 1] = BP[i] * 2 + 3;
        P[i + 1] = P[i] * 2 + 1;
    }
    auto f = [&](auto &&f, int l, int64_t x) -> int64_t {
        if(l == 0) return 1;
        if(x == 1) return 0;
        else if(x <= BP[l-1] + 1) return f(f, l-1, x-1);
        else if(x == BP[l-1] + 2) return P[l-1] + 1;
        else if(x <= BP[l-1] * 2 + 2) return P[l-1] + f(f, l-1, x-(BP[l-1]+2)) + 1;
        else return P[l];
    };
    cout << f(f, N, X) << '\n';
    return 0;
}


Measured memory_bytes: 256
use proconio::input;

const C:usize = 26;
fn main() {
    input!{
        d:usize,
        c:[i32;C],
        s:[[i32;C];d],
        t:[usize;d]
    };
    let t:Vec<usize> = t.into_iter().map(|x|x-1).collect();

    let mut last:Vec<i32> = vec![-1;C];
    let mut ans = 0;
    for (day,&ti) in t.iter().enumerate() {
        ans += s[day][ti];
        last[ti] = day as i32;
        for j in 0..26 {
            ans -= (c[j] as i32) * ((day as i32) -last[j]);
        }
        println!("{}",ans);
    }

}



Measured memory_bytes: 2216
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    int N, M;
    cin>>N>>M;
    vector<pair<int, int> > arr(M);
    int a, b;
    for(int i=0;i<M;++i){
        cin>>a>>b;
        arr[i] = mp(b, a);
    }
    sort(arr.begin(), arr.end());
    int ans = 1;
    int down = arr[0].fi;
    for(int i=1;i<M;++i){
        if(down <= arr[i].se){
            ans++;
            down = arr[i].fi; 
        }
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define int ll
#define Endl endl

signed main(void){
    int N,K;
    cin >> N >> K;
    
    double Ans=0;
    
    for(int i=1;i<=N;i++){
        int t=i;
        double ad=1.0;
        while(t<K){
            t*=2;
            ad/=2.0;
        }
        Ans+=ad;
    }
    printf("%.14f",Ans/(double)N);
    
    return 0;
}


Measured memory_bytes: 256
import numpy as np

X = int(input())

A = -1000
is_finish = False
while 1:
    B = -1000
    while 1:
        if X+B**5 == A**5:
            print("%d %d"%(A,B))
            is_finish=True
            break
        if X+B**5 > A**5:
            break
        B+=1
    A+=1
    if is_finish:
        break


Measured memory_bytes: 27044
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	sc.nextInt()
	S := sc.nextRuneSlice()
	slime := S[0]
	count := 1
	for i := 1; i < len(S); i++ {
		if slime != S[i] {
			count++
		}
		slime = S[i]
	}
	fmt.Println(count)
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	vector<int> dp(n+1, 0);
	dp[1] = abs(v[0] - v[1]);
	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1] + abs(v[i] - v[i-1]), dp[i-2] + abs(v[i] - v[i-2]));
	}
	cout << dp[n-1] << endl;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << '\n'; exit(0);}

int main()
{
  using ld = long double;
  cout << fixed << setprecision(15);
  cerr << fixed << setprecision(15);

  const ld PI = acosl(-1);

  ll N, L;
  cin >> N >> L;
  vector<ll> T(N);
  for (ll i = 0; i < N; i++)
  {
    cin >> T.at(i);
  }

  ld X = 0, Y = 0;
  for (ll i = 0; i < N; i++)
  {
    for (ll j = i + 1; j < N; j++)
    {
      ld t0 = (T.at(i) + T.at(j)) / 2.0, t1 = (T.at(i) + T.at(j) + L) / 2.0;
      ld x0 = cosl(2 * PI * t0 / L), x1 = cosl(2 * PI * t1 / L);
      ld y0 = sinl(2 * PI * t0 / L), y1 = sinl(2 * PI * t1 / L);

      ld tmpx = x1 * (j - i - 1) + x0 * (N - 2 - (j - i - 1));
      ld tmpy = y1 * (j - i - 1) + y0 * (N - 2 - (j - i - 1));
      X += tmpx, Y += tmpy;
      //cerr << i << " " << j << " " << tmpx << " " << tmpy << endl;
    }
  }
  X /= N * (N - 1) * (N - 2) / 6.0, Y /= N * (N - 1) * (N - 2) / 6.0;

  cout << X << " " << Y << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll N;
    cin>>N;
    rep2(n,1,3501){
        rep2(h,1,3501){
            ll s=n*h*N;
            ll t=4*n*h-h*N-n*N;
            if(t==0) continue;
            if(s%t==0){
                ll w=s/t;
                if(w<1) continue;
                cout<<n<<" "<<h<<" "<<w<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()

R=[]
G=[]
B=[]
for i in range(N):
    if S[i]=="R":
        R.append(i)
    elif S[i]=="G":
        G.append(i)
    else:
        B.append(i)

cnt=len(R)*len(G)*len(B)
for i in R:
    for j in G:
        koho=set()
        if (j+i)%2==0:
            koho.add((j+i)//2)
        if 0<=2*i-j<N:
            koho.add(2*i-j)
        if 0<=2*j-i<N:
            koho.add(2*j-i)
        for k in koho:
            if k in B:
                cnt-=1
            
                
print(cnt)

Measured memory_bytes: 69168
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include "bits/stdc++.h"
using namespace std;
#define int long long

int p[1000001];

void go(){
    for( int i = 2; i*i <= 1000000; i++ ){
        if( p[i] == 0 ){
            for( int j = i; j <= 1000000; j += i ){
                if( p[j] == 0 ){
                    p[j] = i;
                }
            }
        }
    }
    for( int i = 1; i <= 1000000; i++ ){
        if( p[i] == 0 )p[i] = i;
    }
}

int32_t main(){
    go();
    int n;
    cin >> n;
    int ar[n];
    for( int i = 0; i < n; i++ ){
        cin >> ar[i];
    }
    map<int,int> cnt;
    for( int i = 0; i < n; i++ ){
        int num = ar[i];
        while( num > 1 ){
            int d = p[num];
            cnt[d]++;
            while( num % d == 0 ){
                num /= d;
            }
        }
    }
    int flag = 1;
    for( auto it : cnt ){
        if( it.second > 1 ){
            flag = 0;
        }
    }
    if( flag ){
        cout << "pairwise coprime";
    }
    else{
        int gcd = ar[0];
        for( int i = 1; i < n; i++ ){
            gcd = __gcd(gcd, ar[i]);
        }
        if( gcd == 1 ){
            cout << "setwise coprime";
        }
        else{
            cout << "not coprime";
        }
    }
}


Measured memory_bytes: 24072
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
int f[2005][2005];
const ll mod = 1e9 + 7;
#define R register
int main()
{
	//long long n;
	R int i,j,k,n,ans = 0;
	scanf("%d",&n);
	f[0][0] = 1;
	for(i=0;i<=n/3;++i){//最多这么多轮 
		for(j=i * 3;j<=n;++j){
			for(k=3;k<=n-j;++k) f[i+1][j+k]+=f[i][j],f[i+1][j+k]>mod?f[i+1][j+k]-=mod:f[i+1][j+k]^=0;
		}
	}
	for(i=1;i<=n/3;++i) ans += f[i][n],ans %= mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 6304
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
def A():
    n = I()
    print(n*800-200*(n//15))

#B
def B():
    k = I()
    ans = 0
    for i in range(1,k):
        for j in range(i+1,k+1):
            if (i%2)^(j%2):
                ans += 1
    print(ans)

#C
def C():
    x,t = LI()
    print(max(0,x-t))

#D
def D():
    n = I()
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)

#E
def E():
    x,y,s,t = LI()
    return

#F
def F():
    n = I()
    x = LI()
    a = sorted(x)
    for i in range(n):
        j = bisect.bisect_left(a,x[i])
        if j >= n//2:
            print(a[n//2-1])
        else:
            print(a[n//2])

#G
def G():
    n,m = LI()
    if m <= 2*n:print(m//2)
    else:
        ans = n
        m -= 2*n
        ans += m//4
        print(ans)

#H
def H():
    return

def J():
    return

def K():
    return

#Solve
if __name__ == "__main__":
    G()


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

signed main() {
	int n; cin >> n;
	if (n < 1000) {
		cout << "ABC" << endl;
	}
	else cout << "ABD" << endl;
}


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

int main(){
  int n,r,c;

  while(cin >> n >> r){
    stack<int> a,b,d;
    for(int i=0;i<n;i++)d.push(i);
    while(r--){
      for(int i=0;i<(n+1)/2;i++){
	a.push(d.top());d.pop();
      }
      while(d.size()){
	b.push(d.top());d.pop();
      }

      cin >> c;
      while(a.size() || b.size()){
	for(int i=0;i<c;i++){
	  if(a.empty())break;
	  d.push(a.top());a.pop();
	}
	for(int i=0;i<c;i++){
	  if(b.empty())break;
	  d.push(b.top());b.pop();
	}
      }
    }
      cout << d.top() << endl;
  }
}

Measured memory_bytes: 0
#include <stdio.h>
int main(void)
{
	int a, b, d, r;
        double f;
	
	scanf("%d", &a);
	scanf("%d", &b);

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

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

	return 0;
}

Measured memory_bytes: 636
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define LLPair pair<ll, ll>
typedef long long ll;

using namespace std;

struct Point { int x, y; };
struct Edge { int to, cost; };
struct gNode { int from, to, cost; };
struct tNode { int value; int parent; vector<int> child; };

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

int gcd(int a, int b){ return a % b == 0 ? b : gcd(b, a%b); }
int lcm(int a, int b){ return a * b/ gcd(a, b); }
int extgcd(int a, int b, int& x, int& y){
	int d = a;
	if(b != 0){
		d = extgcd(b, a%b, y, x);
		y -= (a/b) * x;
	} else{
		x = 1; y = 0;
	}
	return d;
}
ll mod_pow(ll x, ll n){
	if(n == 0) return 1;
	ll res = mod_pow(x*x % MOD, n/2);
	if(n & 1) res = res * x % MOD;
	return res;
}

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


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(int argc, const char * argv[]) {
    char a_st[10000];
    char b_st[10000];
    int a[100];
    int b[100];
    int s[100];
    int x, loop;
    int a_num, b_num, num, n, i;

    scanf("%d", &loop);
    for (i = 0; i < loop; i++) {
        scanf("%s%s", a_st, b_st);

        if (strlen(a_st) > 80 || strlen(b_st) > 80) {
            puts("overflow");
            continue;
        }
        
        for (n = 0; n < 100; n++) {
            a[n] = 0;
            b[n] = 0;
            s[n] = 0;
        }
        
        a_num = (int)strlen(a_st) - 1;
        for (n = 0; n <= a_num; n++){
            a[a_num - n] = a_st[n] - '0';
        }
        
        b_num = (int)strlen(b_st) - 1;
        for (n = 0; n <= b_num; n++) {
            b[b_num - n] = b_st[n] - '0';
        }
        
        if (a_num >= b_num) num = a_num;
        else num = b_num;
        
        for (n = 0; n <= num; n++) {
            if ((x = a[n] + b[n] + s[n]) > 9) {
                s[n+1] = 1;
                x = x - 10;
            }
            s[n] = x;
        }
        
        if (s[80] > 0) {
            puts("overflow");
            continue;
        }
        
        if (s[num+1] > 0) printf("%d", s[num+1]);
        for (n = num; n >= 0; n--) {
            printf("%d", s[n]);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 624
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef vector < pair < ll, ll > > vpll;
#define kill freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define pb push_back
#define fo(i,n) for(ll i=0;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
#define fi first
#define se second
#define MOD 998244353
#define Boost() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define MOD1 1000000007
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
#define oo 100000000000000000
const ll dx[]={-1,0,1, 0,-1,1, 1,-1};
const ll dy[]={ 0,1,0,-1, 1,1,-1,-1};
void solve(){
    ll n;
    double d;
    cin>>n>>d;
    ll ans = 0;
    fo(i,n){
        ll x,y;
        cin>>x>>y;
        double val = (x*x)+(y*y);
        val = sqrt(val);
        if(val<=d)ans++;
    }
    cout<<ans;
    
}
int main(){
    Boost();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3796
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

Int a[100005];

int main(){
    Int N; cin >> N;
    Int L; cin >> L;

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

    for (int i = 0; i < N-1; i++){
        if (a[i] + a[i+1] >= L){
            cout << "Possible" << endl;
            for (int j = 0; j < i; j++){
                cout << j+1 << endl;
            }
            for (int j = N-2; j > i; j--){
                cout << j+1 << endl;
            }
            cout << i+1 << endl;
            return 0;
        }
    }
    cout << "Impossible" << endl;
    return 0;
}


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

#define println(msg) cout << msg << endl

int main() {
  // 入力
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  
  // 計算
  int minPrice = INT_MAX;
  int m = max(X, Y);
  for (int c = 0; c <= (2 * m); c++) {
    int a = max(X - c / 2, 0);
    int b = max(Y - c / 2, 0);
    int price = a * A + b * B + c * C;
    minPrice = min(minPrice, price);   
  }
  
  // 出力
  println(minPrice);
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int main() {
	cin >> s;
	n = s.size();
	vector<int> cnt(n + 1);
	vector<int> ans(n);
	for (int i = 0; i < n; i++) cnt[i] = (s[i] == 'L');
	
	int cntL = 0 , cntR = 1;
	for (int i = 1; i <= n; i++){
	    if (!cnt[i] && cnt[i - 1]){
	        ans[i - cntL] = (cntL + 1)/2 + cntR/2;
	        ans[i - cntL - 1] = (cntR + 1)/2 + cntL/2;
	        cntR = 0, cntL = 0;
	    }
	    cntR += !cnt[i]; cntL += cnt[i];
	}
	for (int i = 0; i < n; i++) cout << ans[i] << ' ';
	return 0;
}

Measured memory_bytes: 1408
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int>> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i;
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i].first;
    b[i].second = i;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  for (int i = 0; i < n; i++) {
    if (a[i].first > b[i].first) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = 1; i < n; i++) {
    if (a[i] <= b[i - 1]) {
      cout << "Yes\n";
      return 0;
    }
  }
  vector<int> to(n);
  for (int i = 0; i < n; i++) {
    to[a[i].second] = b[i].second;
  }
  int cur = 0;
  int cnt = 0;
  do {
    cur = to[cur];
    cnt++;
  } while (cur != 0);
  //cerr << cnt << endl;
  cout << (cnt == n ? "No\n" : "Yes\n");
  return 0;
}

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

int main() {
  vector<int> e(4);
  int i;
  for (i = 0; i < e.size(); i++) {
    cin >> e[i];
  }
  sort(e.begin(), e.end());
  cout << (e[0] == e[1] && e[2] == e[3] ? "yes" : "no") << endl;
  return 0;
}



Measured memory_bytes: 3144
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using P = pair<int, int>;

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

constexpr int MOD = 1e9 + 7;
constexpr ll INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    // dp[i][j] := [i, j] の最小値
    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));

    for(int len=1; len<n; len++){
        for(int s=0; s+len<n; s++){

            ll dpmin = INF;
            ll sum = 0;
            for(int i=s; i<s+len; i++){
                chmin(dpmin, dp[s+1][i+1] + dp[i+2][s+len+1]);
                sum += a[i];
            }

            sum += a[s+len];

            dp[s+1][s+len+1] = dpmin + sum; 
        }
    }

    cout << dp[1][n] << endl;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
 
int main()
{
    int n,i,j,a[2][101],p=0,m=0,max,sum;
    scanf("%d",&n);
    for(i=0;i<2;i++)
    for(j=0;j<n;j++)
    {
        scanf("%d",&a[i][j]);
    }
    max=0;
    for(j=0;j<n;j++)
    {
        max=max+a[1][j];
    }
    max=max+a[0][0];
    while(p<n)
    {
        sum=0;
        for(j=0;j<=m;j++)
        {
            sum=sum+a[0][j];
        }
    for(j=m;j<n;j++)
    {
        sum=sum+a[1][j];
    }
    if(max<sum)
    {
        max=sum;
    }
        m++;
        p++;
 
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <iomanip>
#include <fstream>
//#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const ll INF = (1 << 30);
const ll inf = (1LL << 50LL);
const int  maxn = 1e6 + 5;

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(false);
    double a, b;
    cin >> a >> b;
    double ret = a / b;
    printf("%.6f\n", ret);
    return 0;
}


Measured memory_bytes: 256
from collections import Counter

votes = Counter([input() for _ in range(int(input()))])

v = votes.most_common()
num = v[0][1]


ans_list = []
for i in  v:
	if(i[1] == num):
		 ans_list.append(i[0])
	else:
		break

for i in sorted(ans_list):
	print(i)


	


Measured memory_bytes: 47608
while true
  judges = gets.to_i
  break if judges == 0
  a = Array.new(judges)
  for i in 0..(judges-1)
    a[i] = gets.to_i
  end
  sum = 0
  for i in 0..(judges-1)
    sum = sum + a[i]
  end
  sum = sum - a.max - a.min
  puts sum/(judges-2)
end

Measured memory_bytes: 8508
#include <iostream>
#include <iomanip>

using namespace std;

int main() {

	int a, b;
	cin >> a >> b;

	double A, B;

	A = double(a);
	B = double(b);
    cout << fixed;
    cout << setprecision(5);
	cout << a / b << " " << a % b << " " << A/B << endl;
}



Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repin(a,n) vector<ll> a(n);rep(i,n){cin>>a[i];}
#define in(a) ll a;cin>>a;
#define out(a) cout<<a<<endl;

int main()
{
    in(a);
    string s;
    cin >> s;
    if(a>=3200){
        out(s);
    }else{
        out("red");
    }
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStreamReader}
import java.util.Arrays.binarySearch

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val n = in.readLine.toInt
  val a, b, c = in.readLine.split(" ").map(_.toLong).sorted
  
  val ans = {
      var posA = 0
      var posC = 0
      def findA(tar:Long):Int = {
        while(posA < n && a(posA) < tar) posA += 1
        posA
      }
      def findC(tar:Long):Int = {
        while(posC < n && c(posC) <= tar) posC += 1
        posC
      }

      b./:(0L)((acc,e) => {
        val ac = findA(e)
        val cc = n - findC(e)

        acc +  ac.toLong * cc.toLong
      })
    }

  println(ans)
}

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

using namespace std;
typedef long long ll;

#define INF (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int x[20][20], y[20][20], A[20];

int countbit(int n)
{
    int cnt = 0;
    for(int i = n; i > 0; i >>= 1) {
        cnt += (i & 1);
    }
    return cnt;
}


int main(void)
{
    int N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
        REP(j, A[i]) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
//    cout << countbit(5);

    int omax = 0;

    for(int st = 0; st < (1 << N); st ++ ) {
        bool ok = true;
//        cout << "st:" << st << endl;
        REP(i, N) { // 何人目
            if((st & (1<<i)) == 0) continue;
            REP(j, A[i]) { // 何番目の証言
                if(y[i][j] == 1 && (st & (1 << x[i][j])) == 0) ok = false;
                if(y[i][j] == 0 && (st & (1 << x[i][j])) != 0) ok = false;
//                cout << i << ":" << j << " " << y[i][j] << " " << x[i][j] << " " << endl;
            }
        }
//        cout << "  " << ok << " " << countbit(st) << endl;
        if(ok) omax = max(omax, countbit(st));
    }
    cout << omax << endl;


}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
     
     
typedef long long ll;
typedef vector <int> vi;
typedef pair <int,int> pi;
typedef tuple <int,int,int> ti;

#define forn(i,a,n) for(int i = a; i < n ; i++)
#define mem(str,a) memset(str, a, sizeof(str));
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(nullptr)
const int MOD = 1e9+7, N = 1e7 + 10, E = 1e-9;
/*
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
//vector <int> show;
//for (auto x : show)
//   cout << x << " ";
getline(cin,s);


*/

int main() {
    int h,w;
    cin >> h >> w;
    char img[h][w];
    forn(i,0,h)
        forn(j,0,w)
            cin >> img[i][j];
    forn(i,0,h) {
        forn(j,0,w) {
            cout << img[i][j];
        }
        cout << endl;
        forn(j,0,w) {
            cout << img[i][j];
        }
        cout << endl;
    }
    return 0;   
}

Measured memory_bytes: 3644