akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
 
int main(){
  int n,s;
  string x;
  string y;
  cin>>n;
  cin>>x;
  s=x.size();
  if(n<s){
    y=x.assign(x,0,n);
      cout<<y<<"..."<<endl;
  }
  if(n>=s){
    cout<<x<<endl;
  }
  return 0;
}

Measured memory_bytes: 3628
a = list(int(i) for i in input().split())

Count5 = 0
Count7 = 0
for i in a:
    if i == 5:
        Count5 += 1
    elif i == 7:
        Count7 += 1

if Count5 == 2 and Count7 == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n,k;
	cin>>n>>k;
	int arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	int dp[n]={};
	for(int i=1;i<n;i++)dp[i]=INT_MAX;
	for(int i=0;i<n;i++)
	{
		for(int j=1;j<=k;j++)
		{
			if(j<=i)
			{
				dp[i]=min(dp[i-j]+abs(arr[i-j]-arr[i]),dp[i]);
			}
		}
	}
	cout<<dp[n-1];

	

}

Measured memory_bytes: 4432
W,H,N=map(int,input().split())
n=H
e=0
w=W
s=0
for i in range(N):
  X,Y,A=map(int,input().split())
  if A==1: e=max(e,X)
  elif A==2: w=min(w,X)
  elif A==3: s=max(s,Y)
  else: n=min(n,Y)
if e>=w or s>=n: print(0)
else: print((w-e)*(n-s))

Measured memory_bytes: 3064
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const long long int MOD = 1000000007;

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

	ll a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;
	if (v <= w) {
		cout << "NO" << endl;
		return 0;
	}
	if (a < b) {
		if (b - a <= t * (v - w)) {
			cout << "YES" << endl;
		}
		else cout << "NO" << endl;
	}
	else {
		if (a - b <= t * (v - w)) {
			cout << "YES" << endl;
		}
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
int main() {
    int n, i, b4a=-1, a;
    long long  ans = -1;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &a);
        if (a > b4a + 1) {
            printf("-1\n");
            return 0;
        }
        if (a == b4a + 1)
            ans++;
        else
            ans += a;
        b4a = a;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
	int n;  //1...100
	int sup = 0;
	bool col[8] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		int temp;
		cin >> temp;
		if (temp >= 3200)sup++;
		else if (temp >= 2800)col[7] = true;
		else if (temp >= 2400)col[6] = true;
		else if (temp >= 2000)col[5] = true;
		else if (temp >= 1600)col[4] = true;
		else if (temp >= 1200)col[3] = true;
		else if (temp >= 800)col[2] = true;
		else if (temp >= 400)col[1] = true;
		else col[0] = true;
	}
	int ans = 0;
	for (int i = 0; i < 8; i++) {
		if (col[i])ans++;
	}
	if (ans == 0) { ans++; sup--; }
	cout << ans<<" "<<ans+sup<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
using namespace std;
int main()
{
	int i,j,k,ans=1;
	double n;
	cin  >>  n;
	int N=sqrt(n);
	cout << N*N;
	
	
	return 0;
}
	


Measured memory_bytes: 256
/*input
6 3 4
3
1
3
2
*/
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n, k, q, a[N], check[N];
main(){
	ios_base::sync_with_stdio(false);
	cin >> n >> k >> q;
	for(int i = 1;i <= n;++i) a[i] = k;
	for(int i = 0;i < q;++i)
	{
		int x;
		cin >> x;
		check[x]++;
	}
	for(int i = 1;i <= n;++i)
	{
		if(a[i] - q + check[i] >= 1) cout << "Yes";
		else cout << "No";
		cout << "\n";
	}
}

Measured memory_bytes: 1408
# include <iostream>
using namespace std;
const int MOD=1e9+7;
int f[200010],a,b,c,d,i,sol;
int inv(int a,int b,int &x,int &y){
    if(b==0){
        x=1;
        y=0;
        return 1;
    }
    int xa,ya,d=inv(b,a%b,xa,ya);
    x=ya;
    y=xa-(a/b)*ya;
}
int combinari(int a,int b){
    int sol=f[a],c,d;
    inv(f[b],MOD,c,d);
    c%=MOD;
    if(c<0)
        c+=MOD;
    sol=(1LL*sol*c)%MOD;
    inv(f[a-b],MOD,c,d);
    c%=MOD;
    if(c<0)
        c+=MOD;
    sol=(1LL*sol*c)%MOD;
    return sol;
}
int main () {
    cin>>a>>b>>c>>d;
    f[0]=1;
    for(i=1;i<=a+b;i++)
        f[i]=(1LL*f[i-1]*i)%MOD;
    for(i=d+1;i<=b;i++){
        sol+=(1LL*combinari(a-c+i-2,i-1)*combinari(c-1+b-i,b-i))%MOD;
        if(sol>=MOD)
            sol-=MOD;
    }
    cout<<sol<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;cin>>a>>b;
  if(a==b)cout<<"Draw";
  else if(a==1)cout<<"Alice";
  else if(b==1)cout<<"Bob";
  else if(a>b)cout<<"Alice";
  else cout<<"Bob";}

Measured memory_bytes: 384
#include <stdio.h>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> PAIR;

pair<ll, PAIR> edge[222222];
PAIR x[111111], y[111111];
int parent[111111];

ll Find(ll val)
{
	if (parent[val] == val)
		return val;
	else
		return parent[val] = Find(parent[val]);
}

int main(void)
{
    ll n, i, ans = 0, cnt = 0;

    scanf("%lld" ,&n);
    for (i = 1; i <= n; i++)
	{
		scanf("%lld %lld" ,&x[i].first, &y[i].first);
        x[i].second = y[i].second = i;
	}

	sort(x + 1, x + n + 1);
	sort(y + 1, y + n + 1);

	for (i = 1; i < n; i++)
	{
		edge[++cnt] = make_pair(x[i + 1].first - x[i].first, make_pair(x[i].second, x[i + 1].second));
		edge[++cnt] = make_pair(y[i + 1].first - y[i].first, make_pair(y[i].second, y[i + 1].second));
	}

	sort(edge + 1, edge + cnt + 1);

	for (i = 1; i <= n; i++)
		parent[i] = i;

	int num = 0;
    for (i = 1; num < n - 1; i++)
	{
        ll a = Find(edge[i].second.first);
        ll b = Find(edge[i].second.second);

		if (a != b)
		{
            parent[b] = a;
            ans += edge[i].first;
            ++num;
		}
	}

	printf("%lld" ,ans);
	return 0;
}


Measured memory_bytes: 8704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;
int a[100010];

void ok(){ puts("Yes"); exit(0); }
void no(){ puts("No"); exit(0); }

int main()
{
	read(n);
	for(int i=1; i<=n; ++i) read(a[i]);
	sort(a+1, a+n+1);
	if(a[1] == n-1 && a[n] == n-1) ok();
	if(a[n]-a[1] > 1) no();
	int k = a[n];
	int l = n;
	for(int i=1; i<=n; ++i) if(a[i]==a[n]){
		l=i-1;
		break;
	}
	if(l<=k && 2*(k-l) <= n-l){
		if(k-l == 0 && n-l) no();
		ok();
	}
	no();
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long
#define v(T) vector<T>
#define vb vector<bool>
#define pi pair<int,int>
#define ppi pair<pair,int,int>, int>
#define vpi vector<pair<int,int>>
#define w(t) int t; cin>>t; while(t--)
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
void init() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
int32_t main() {
	FIO;
	init();
	int n; cin >> n;
	int c = 0;
	for (int i = 1; i <= n; i++) {
		int x; cin >> x; if (i & 1 && x & 1)c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define pld pair <ld, ld>
#define all(a) a.begin(), a.end()
#define vvl vector <vector <ll> >
#define cld complex <double>

typedef long long ll;

typedef long double ld;

using namespace std;

const ll maxn = 1e6 + 100;
const ll mod = 1e9 + 7;

ll n, m, k, t;

ll A[maxn];

ll D[maxn];

ll last[maxn];

vector <ll> I[maxn];

int main() {
    pyshnapyshnakaa
    ll q, w, e, a, b, c;
    cin >> n;
    for (q = 0; q < n; q++) {
        cin >> A[q];
        if (!I[A[q]].empty()) {
            last[q] = I[A[q]].back();
        }
        else {
            last[q] = -1;
        }
        I[A[q]].pb(q);
    }
    D[0] = 1;
    for (q = 1; q < n; q++) {
        D[q] = D[q - 1];
        ll i = last[q];
        if (i == -1 || i == q - 1) {
            continue;
        }
        D[q] += D[i];
        D[q] %= mod;
    }
    cout << D[n - 1];
    return 0;
}


Measured memory_bytes: 37752
#include<stdio.h>
int main(void){
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a*b>c*d){
    printf("%d",a*b);
  }else if(a*b<=c*d){
    printf("%d",c*d);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>

long long num[10000], cnum;

long long tknp(long long x)
{
    long long l = 0, r = 2000;
    while (l <= r)
    {
        long long c = (l + r) / 2;
        if (num[c] < x)
        {
            l = c + 1;
        }
        else if (num[c] > x)
        {
            r = c - 1;
        }
        else
        {
            return c;
        }
    }
    return -1;
}

int main()
{
    long long x, a, b;
    std::cin >> x;
    for (long long i = 999; i >= 0; i--)
    {
        num[999 - i] = -(i + 1) * (i + 1) * (i + 1) * (i + 1) * (i + 1);
    }
    num[1000] = 0;
    for (long long i = 1; i <= 1000; i++)
    {
        num[i + 1000] = i * i * i * i * i;
    }
    for (long long i = 0; i <= 1000; i++)
    {
        a = num[i + 1000] - x;
        //std::cout << a << " ";
        b = tknp(a);
        if (b >= 0)
        {
            std::cout << i << " " << b - 1000;
            break;
        }
    }
}

Measured memory_bytes: 3640
int main()
{
    int r, D, x, i, xi=0;
    scanf("%d%d%d", &r, &D, &x);
    xi=x;
    for (i=0; i<10; i++) {
        xi = r*x-D;
        printf("%d\n", xi);
        x=xi;
    }
    return 0;
}


Measured memory_bytes: 128
/*
g++ -std=c++14 -O2 -Wall a.cpp -o a && a
*/

//  io
#include <iostream>
//#include <fstream> //http://www.cplusplus.com/reference/fstream/fstream/
//#include <cstdio>
#include <iomanip> //http://www.cplusplus.com/reference/iomanip/
#include <limits>
//  util
#include <string>
#include <cstring>
#include <algorithm>
//#include <utility>
//#include <functional> //http://www.cplusplus.com/reference/functional/
//#include <cstdlib>
#include <cmath>
//#include <complex>
//#include <random>
//#include <bitset>
//  containers https://en.cppreference.com/w/cpp/container
#include <vector>
//#include <queue>
#include <set>
//#include <map>
//#include <unordered_set>
//#include <unordered_map>
//  time
//#include <ctime>
//#include <chrono>
//                  https://en.cppreference.com/w/cpp/header/chrono
//                  http://www.cplusplus.com/reference/chrono/

using namespace std;
typedef vector<int> arri;
typedef vector<float> arrf;
typedef pair<int, int> pairi;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 0x7fffffffffffffff;
const ll infneg = -0x7fffffffffffffff;

//file input routed to stdinout
/*
std::ifstream inFile("input.txt");
std::ofstream outFile("output.txt");
std::cin.rdbuf(inFile.rdbuf());
std::cout.rdbuf(outFile.rdbuf());
*/

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

    int n;
    cin >> n;

    arri dish(n);
    arri satis(n + 1);
    arri nextDish(n + 1);

    for (int i = 0; i < n; i++)
    {
        cin >> dish[i];
    }
    for (int i = 1; i <= n; i++)
    {
        cin >> satis[i];
    }
    for (int i = 1; i < n; i++)
    {
        cin >> nextDish[i];
    }

    ll satisfaction = 0;

    int prev = -2;
    for (int i = 0; i < n; i++)
    {
        satisfaction += satis[dish[i]];
        if (prev + 1 == dish[i])
        {
            satisfaction += nextDish[prev];
        }
        prev = dish[i];
    }

    cout << satisfaction;
}

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

typedef long long ll;

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

  ll n, a, b; cin >> n >> a >> b;
  if(a > b) {
    cout << 0 << '\n';
    return 0;
  }
  if(n == 1) {
    if(a != b) cout << 0 << '\n';
    else cout << 1 << '\n';
    return 0;
  }

  cout << (n-1)*(b-a)+a-b+1 << '\n';
  return 0;
}


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

int main(void)
{
  long a,b,c,x,y,ans=0,adm;
  scanf("%ld %ld %ld %ld %ld",&a,&b,&c,&x,&y);
  if(2*c <= a && 2*c <= b )
    {
      if(x > y)
	{
	  ans = x*c*2;
	}
      else
	{
	  ans = y*c*2;
	}
     
    }
  else if(2*c > a && 2*c <= b)
    {
      if(x > y)
	{
	  ans = (y*c*2)+(x-y)*a;
	}
      else
	{
	  ans = y*c*2;
	}
    }
  else if(2*c <= a && 2*c > b)
    {
      if(x > y)
	{
	  ans = x*c*2;
	}
      else
	{
	  ans = (x*c*2) + (y-x)*b;
	}
    }
  else if(2*c > a && 2*c > b && 2*c < a+b)
    {
      if(x > y)
	{
	  ans = (y*c*2) + (x-y)*a;
	}
      else
	{
	  ans = (x*c*2) + (y-x)*b;
	}
    }
  else
    {
      ans = x*a + y*b;
    }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

import math

k = ni()
ans = 0

for i in range(1,k+1):
    for j in range(1,k+1):
        a = math.gcd(i,j)
        for p in range(1,k+1):
            ans += math.gcd(a,p)

print(ans)


Measured memory_bytes: 9116
import Foundation

let input = Int(readLine()!)!
var array:[Int] = []
var total = 0

for i in 1...input {
    array.append(i)
    if array[i-1] % 5 == 0 || array[i-1] % 3 == 0{
        array[i-1] = 0
    }
    total += array[i-1]
}
print(total)

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

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer x;
  x=nil->next;
  while (x!=nil && x->key!=key){
    x=x->next;
  }
  return x;
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  t->prev->next=t->next;
  t->next->prev=t->prev;
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  NodePointer t=nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}

void delete(int key){
  NodePointer t;
  if((t=(listSearch(key)))!=NULL){
    if ( t == nil ) return;
    deleteNode(t);
  }
}

void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}

Measured memory_bytes: 34976
n=int(input())
a=[0]*(n+1)
for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      if x*x+y*y+z*z+x*y+x*z+y*z<=n:
        a[x*x+y*y+z*z+x*y+x*z+y*z]+=1
for i in range(1,n+1):
  print(a[i])

Measured memory_bytes: 74180
#include <stdio.h>

/* ?????????????´??????????????????? */
void trace(int A[], int N) {
  int i;
  for ( i = 0; i < N; i++ ) {
    if ( i > 0) printf(" ");  /* ??£??\??????????´?????????????????????????????????? */
    printf("%d", A[i]);
  }
  printf("\n");
}

/* ?????\????????? (0??????????????????) */
void insertionSort(int A[], int N) {
  int j, i, v;
  for ( i = 1; i < N; i++) {
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    trace(A, N);
  }
}

int main(void) {
  int N, i, j;
  int A[100];
  
  scanf("%d", &N);
  for ( i = 0; i < N; i++ ) scanf("%d", &A[i]);
  
  trace(A, N);
  insertionSort(A, N);

  return 0;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	return cout<<(n+1)/2<<"\n" , 0 ;
}		

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    int array1[n] = {},array2[n] = {};
    for(int i = 0;i < m;i++)
    {
        int a,b;
        cin >> a >> b;
        if(a == 1)
        {
            array1[b - 1] = 1;
        }
        else if(b == n)
        {
            array2[a - 1] = 1;
        }
        
    }
    for(int i = 0;i < n;i++)
    {
        if(array1[i] > 0 && array1[i] == array2[i])
        {
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";

    return 0;
}

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

std::vector<long> P;

bool permutations(long len)
{
    long change_idx=-1;
    long change_idx_2 = -1;
    for(long i=0; i<len-1; i++){
        if(P[i]<P[i+1]){
            change_idx=i;
        }
    }
    if(change_idx==-1){
        return false;
    }

    for(long j=len-1; j>=0; j--){
        if(P[change_idx]<P[j]){
            change_idx_2 = j;
            break;
        }
    }

    long temp=P[change_idx];
    P[change_idx] = P[change_idx_2];
    P[change_idx_2] = temp;

    for(long k=0; k<(len-(change_idx+1))/2; k++){
        long temp=P[change_idx+1+k];
        P[change_idx+1+k] = P[len-1-k];
        P[len-1-k] = temp;
    }
    return true;
}

int main()
{
    long N;
    std::cin >> N;
    long nums=1;
    for(long i=1; i<=N; i++){
        P.push_back(i);
        nums=nums*i;
    }
    
    std::vector<long> X,Y;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        X.push_back(temp);
    }
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        Y.push_back(temp);
    }

    long a,b;
    for(long i=0; i<nums; i++){
        for(long j=0; j<N; j++){
            if(P[j]!=X[j]){
                break;
            }
            if(j==N-1){
                a=i;
            }
        }
        for(long j=0; j<N; j++){
            if(P[j]!=Y[j]){
                break;
            }
            if(j==N-1){
                b=i;
            }
        }
        permutations(N);
    }
    std::cout << abs(a-b) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstring>
using namespace std;
#define U(v) \
cerr << #v << ": " << (v) << endl

int main() {
    string s;
    cin >> s;
    long long sm = 0;
    for (int i = 0; i < 1 << (s.size() - 1); ++i) {
        vector<int> a{ 0 };
        for (int j = 0; i >> j; ++j) {
            if ((i >> j) & 1)
                a.emplace_back(j + 1);
        }
        a.emplace_back(s.size());
        for (int j = 1; j < a.size(); ++j) {
            int p = a[j - 1];
            int q = a[j];
            long long tm = s[p] - '0';
            for (int k = p + 1; k < q; ++k) {
                tm *= 10;
                tm += s[k] - '0';
            }
            sm += tm;
        }
    }
    cout << sm << endl;
    return 0;
}


Measured memory_bytes: 256
# 途中
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
A3 = list(map(int, input().split()))

A = A1 + A2 + A3
N = int(input())

index = []
for i in range(N):
    inp = int(input())
    if inp in A:
        index.append(A.index(inp))

if \
   (0 in index and 3 in index and 6 in index) or \
   (1 in index and 4 in index and 7 in index) or \
   (2 in index and 5 in index and 8 in index) or \
   (0 in index and 4 in index and 8 in index) or \
   (2 in index and 4 in index and 6 in index) or \
   (0 in index and 1 in index and 2 in index) or \
   (3 in index and 4 in index and 5 in index) or \
   (6 in index and 7 in index and 8 in index):
    print("Yes")
else:
    print("No")


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

using namespace std;


string s,t;

int main(void){
  cin >> s >> t;

  int x = stoi(s+t);
  for ( int i=1; i<= 1000 ; i++){
    if (i*i == x){
      cout << "Yes";
      return 0;
    }
  }
  cout << "No";


  return 0;
}

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

int main(void) {
    int n, l;
    cin >> n >> l;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    for (string s : a) {
        cout << s;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
const int maxn = 5005;
long long f[maxn];
int main() {
	int N, P, A;
	scanf("%d%d", &N, &P);
	f[0] = 1;
	for(int i = 1; i <= N; ++i) {
		scanf("%d", &A);
		for(int j = 5000; j >= A; --j)
			f[j] += f[j - A];
	}
	long long ans = 0;
	for(int i = 0; i <= 5000; ++i) {
		if((i & 1) == P) ans += f[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int x, hap=0;
  	cin >> x;
  	while(x>=500){
    	x = x-500;
      	hap += 1000;
    }
  	
      while(x>=5){
    	x = x-5;
      	hap += 5;
    }

  	cout << hap << endl;
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var (
		s, t, u string
		i,j int
	)
	fmt.Scanf("%s %s\n", &s, &t)
	fmt.Scanf("%d %d\n", &i, &j)
	fmt.Scanf("%s\n", &u)
	if u == s {
		i = i - 1
	} else {
		j = j - 1
	}
	fmt.Printf("%d %d\n", i, j)
	
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    H, W = MI()
    room = [["" for j in range(W)] for i in range(H)]
    roomT = [["" for i in range(H)] for j in range(W)]
    num_yoko = [[0 for j in range(W)] for i in range(H)]
    num_tate = [[0 for j in range(W)] for i in range(H)]
    num_sum = [[0 for j in range(W)] for i in range(H)]
    for i in range(H):
        row = input()

        splited = list(map(len, row.split('#')))
        tmp = 0
        for j in range(W):
            roomT[j][i] = row[j]
            room[i][j] = row[j]
            if row[j] == "#":
                num_yoko[i][j] = 0
                tmp += 1
            else:
                num_yoko[i][j] = splited[tmp]

    ans = 0

    for j in range(W):
        target = roomT[j]
        splited = list(map(len, "".join(target).split('#')))
        tmp = 0
        for i in range(H):
            if target[i] == "#":
                num_tate[i][j] == 0
                tmp += 1
            else:
                num_tate[i][j] = splited[tmp]

            num_sum[i][j] = num_tate[i][j] + num_yoko[i][j] - 1
            ans = max(ans, num_sum[i][j])
    print(ans)


main()


Measured memory_bytes: 493736
import sys
import math
input = sys.stdin.readline

a, b, x = map(int, input().split())

m = a ** 2 * b
if x <= m / 2:
    c = (x * 2) / (a * b)
    ans = math.degrees(math.atan(b / c))
else:
    c = 2 * (m - x) / (a ** 2)
    ans = math.degrees(math.atan(c / a))

print(ans)

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

int main(){
    int n;
    cin >> n;
    int R,t[n];
    cin >> R;
    int min=R;
    for(int i=0;i<n-1;++i){
        cin >> R;
        t[i]=R-min;
        if(min>R){
            min=R;
        }
    }
    int ans=t[0];
    for(int i=1;i<n-1;++i){
        if(ans<t[i]){
            ans=t[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3880
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;

int group(int n){
    if(n==2)
        return 2;
    else if(n==4 || n==6 || n==9 || n==11)
        return 1;
    else
        return 0;

}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int A,B;
    cin >> A >> B;
    cout << (A*B*(A+B)%3==0? "Possible":"Impossible")<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const ll inf = 1e18;
const ll mod = 1e9+7;

template <class T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus; // llにしないとダメ
    exp >>= 1;
  }
  return result;
}

int main() {
    ll m, n;
    cin >> m >> n;
    cout << modpow(m,n,mod) << endl;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
string ans="";
long long int n;
cin>>n;
n=n-1;
while(n>-1){
    ans=ans+char('a'+(n%26));
    n=n/26-1;
}
reverse(ans.begin(),ans.end());
cout<<ans;
return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <sstream>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <set>

struct TestData
{
  int testNum;
  std::string input;
  std::string expectedOutput;
};

struct TestResult
{
  std::string testOutput;
  bool testPassed;
};

void testSolution();
TestResult runTestCase(const TestData& testData);
std::string formatResult(const TestData& testData, const TestResult& testResult);
void solution(std::istream& is, std::ostream& os);

static const bool IS_TESTING = false;

// define test data
static const std::vector<TestData> testDatas = {
  {1, "2\n3 4\n", "3.5\n"},
  {2, "3\n500 300 200\n", "375\n"},
  {3, "5\n138 138 138 138 138\n", "138\n"},
};

int main()
{
  if (IS_TESTING)
    testSolution();
  else
    solution(std::cin, std::cout);

  return 0;
}

void testSolution()
{
  for (const auto& testData : testDatas) {
    auto testResult = runTestCase(testData);

    std::cout << formatResult(testData, testResult);
  }
}

TestResult runTestCase(const TestData& testData)
{
    std::istringstream iss {testData.input};
    std::ostringstream oss {};

    solution(iss, oss);

    auto testOutput = oss.str();
    auto testPassed = testData.expectedOutput.compare(testOutput) == 0;
    
    return {testOutput, testPassed};
}

std::string formatResult(const TestData& testData, const TestResult& testResult)
{
  std::ostringstream oss {};

  oss << "Test " << std::setw(2) << testData.testNum << ": "
    << (testResult.testPassed ? "Passed!" : "Failed!") << std::endl;
  
  oss << "\tExpected: " << testData.expectedOutput << "\tActual  : " << testResult.testOutput << std::endl;

  return oss.str();
}


// solution to the problem
void solution(std::istream& is, std::ostream& os)
{
  auto avg = [](double n1, double n2) { return (n1 + n2) / 2; };

  // read input
  int numInputs; is >> numInputs;
  auto inputs = std::vector<double>(numInputs);
  for (auto i = 0; i < numInputs; ++i) {
    is >> inputs[i];
  }

  std::sort(inputs.begin(), inputs.end());
  double currentValue = avg(inputs[0], inputs[1]);
  for (auto i = 2; i < numInputs; ++i) {
    currentValue = avg(currentValue, inputs[i]);
  }

  os << currentValue << std::endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2, degrees
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)

INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


a, b, x = LI()
x /= a
if x > a * b / 2:
    t = (a * b - x) * 2 / a
    print(90 - math.degrees(math.atan2(a, t)))
else:
    t = x * 2 / b
    print(math.degrees(math.atan2(b, t)))


Measured memory_bytes: 39536
#include <bits/stdc++.h>
using namespace std;
long long K;
string s;
int main(){
	cin>>K;
	cin>>s;
	if(s.length()>K){
		string tmp=s.substr(0,K);
		cout<<tmp<<"..."<<'\n';
	}else{
		cout<<s<<'\n';
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int main()
{
    int x1, y1, x2, y2;
    cin>>x1>>y1>>x2>>y2;
    int x3, y3, x4, y4;
    x3 = x2 + y1 - y2;
    y3 = y2 + x2 - x1;
    x4 = x1 + y1 - y2;
    y4 = y1 + x2 - x1;
    cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<' '<<endl;

    return 0;
}


Measured memory_bytes: 256
# from line_profiler import LineProfiler
from collections import deque
from sys import stdin

def main():
    while(True):
        W, H = map(int, stdin.readline().split())
        if not W: break
        tx,ty = map(int, stdin.readline().split())
        kx,ky = map(int, stdin.readline().split())
        ma = [[False]*(W+2) for _ in range(H+2)]
        for i in range(1,H+1):
            for j,a in enumerate(stdin.readline().split()):
                ma[i][j+1] = bool(1-int(a))
        que = deque([[tx,ty,kx,ky,0]])
        pas = set()
        ans = "NA"
        while(que):
            tx,ty,kx,ky,c = que.popleft()
            if tx == kx and ty == ky:
                ans = c
                break
            if c+1 > 100: continue
            for dx,dy in [[-1,0],[0,-1],[1,0],[0,1]]:
                tdx, tdy = ( dx, dy) if ma[ty+dy][tx+dx] else (0,0)
                kdx, kdy = (-dx,-dy) if ma[ky-dy][kx-dx] else (0,0)
                ttx,tty,kkx,kky = tx+tdx,ty+tdy,kx+kdx,ky+kdy
                if (ttx,tty,kkx,kky) in pas: continue
                que.append([ttx,tty,kkx,kky,c+1])
                pas.add((ttx,tty,kkx,kky))
        print(ans)

if __name__ == "__main__":
    # prf = LineProfiler()
    # prf.add_function(main)
    # prf.runcall(main)
    # prf.print_stats()
    main()


Measured memory_bytes: 35200
A,B=map(int,input().split())

def ans090(A:int, B:int):
    count=0
    for i in range(A,B+1):
        if str(i)[0]==str(i)[-1] and str(i)[1]==str(i)[-2]:
            count+=1
    return count

print(ans090(A,B))

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

using namespace std;

int main() {
    string p,s;
    cin >> p >> s ;

    p += p;
    string::size_type pos = p.find(s);
    if (pos != -1)
        cout << "Yes" <<endl;
    else
        cout << "No" << endl;
     return 0;
}

Measured memory_bytes: 1192
N=int(input())
def make_divisors(n):
    divisors = [n]
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
 
    divisors.sort()
    return divisors

if N == 2:
    print(1)
else:   
    cnt = len(make_divisors(N - 1))
    for i in make_divisors(N):
        tmp = N
        while tmp % i == 0:
            tmp //= i
        if tmp % i == 1:
            cnt += 1
    print(cnt)

Measured memory_bytes: 3188
# diverta2019-2C - Successive Subtraction
def main():
    n = int(input())
    lst = sorted(map(int, input().rstrip().split()))
    s = lst[0]  # start
    l = lst[-1]  # last
    log = []
    for i in lst[1:-1]:
        if i > 0:
            log += [(s, i)]
            s -= i
        else:
            log += [(l, i)]
            l -= i
    log += [(l, s)]
    print(l - s)
    for i, j in log:
        print(i, j)


if __name__ == "__main__":
    main()

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

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

  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  cout << a.at(K-1) << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long ll;

int main() {
  int k;
  cin >> k;
  
  ll res = 1;
  
  for (int i = 1; i <= k; ++i) {
    res = (res * i) % 1000000007;
  }
  
  cout << res << endl;
  return 0;
}

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

using namespace std;

int main(){
	int A, B, ans = 0; cin >> A >> B;
	for(int i = A; i <= B; ++i){
		int a=i/10000,b=(i-a*10000)/1000,c=(i-a*10000-b*1000)/100,d=(i-a*10000-b*1000-c*100)/10,e=(i-a*10000-b*1000-c*100-d*10);
		if(a == e && b == d) ans++;
	}
	cout << ans << endl;
}

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

template <typename T> 
struct WeightedUnionFind{
  Int n;
  T d;
  vector<Int> r,p;
  vector<T> ws;
  WeightedUnionFind(){}
  WeightedUnionFind(Int sz,T d_):
    n(sz),d(d_),r(n,1),p(n),ws(n,d){iota(p.begin(),p.end(),0);}
  Int find(Int x){
    if(x==p[x]){
      return x;
    }else{
      Int t=find(p[x]);
      ws[x]+=ws[p[x]];
      return p[x]=t;
    }
  }
  T weight(Int x){
    find(x);
    return ws[x];
  }
  bool same(Int x,Int y){
    return find(x)==find(y);
  }
  void unite(Int x,Int y,T w){
    w+=weight(x);
    w-=weight(y);
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y),w=-w;
    r[x]+=r[y];
    p[y]=x;
    ws[y]=w;
  }
  T diff(Int x,Int y){
    return weight(y)-weight(x);
  }
};


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

//INSERT ABOVE HERE
signed main(){
  Int h,w,n;
  cin>>h>>w>>n;
  vector<Int> y(n),x(n),a(n);
  for(Int i=0;i<n;i++) cin>>y[i]>>x[i]>>a[i],y[i]--,x[i]--;

  vector<vector<Int> > vh(h),vw(w);
  for(Int i=0;i<n;i++){
    vh[y[i]].emplace_back(i);
    vw[x[i]].emplace_back(i);
  }

  auto NO=[&](){
    cout<<"No"<<endl;
    exit(0);
  };
  
  WeightedUnionFind<Int> ufW(w,0);
  for(Int i=0;i<h;i++){
    if(vh[i].empty()) continue;
    Int k=vh[i][0];
    for(Int j:vh[i]){
      Int d=(a[k]-a[j]);
      if(ufW.same(x[k],x[j])){
	if(ufW.diff(x[k],x[j])!=d) NO();
      }else{
	ufW.unite(x[k],x[j],d);
      }
    }
  }
  //cout<<"OK"<<endl;
  WeightedUnionFind<Int> ufH(h,0);
  for(Int i=0;i<w;i++){
    if(vw[i].empty()) continue;
    Int k=vw[i][0];
    for(Int j:vw[i]){
      Int d=(a[k]-a[j]);
      if(ufH.same(y[k],y[j])){
	if(ufH.diff(y[k],y[j])!=d) NO();
      }else{
	ufH.unite(y[k],y[j],d);
      }
    }
  }
  
  const Int INF = 1e18;
  vector<Int> mih(h,INF),mah(h,-INF);
  for(Int i=0;i<n;i++){
    Int r=ufH.find(y[i]);
    Int v=ufH.diff(r,y[i]);
    chmin(mih[r],v);
    chmax(mah[r],v);
  }
  vector<Int> miw(w,INF),maw(w,-INF);
  for(Int i=0;i<n;i++){
    Int r=ufW.find(x[i]);
    Int v=ufW.diff(r,x[i]);
    chmin(miw[r],v);
    chmax(maw[r],v);
  }

  for(Int i=0;i<n;i++){
    Int r=ufH.find(y[i]);
    Int d=ufH.diff(r,y[i]);
    Int v=a[i]+d-mah[r];
    //cout<<i<<":"<<a[i]<<" "<<d<<" "<<mah[r]<<":"<<v<<endl;
    if(v<0) NO();
  }
  
  for(Int i=0;i<n;i++){
    Int r=ufW.find(x[i]);
    Int d=ufW.diff(r,x[i]);
    Int v=a[i]+d-maw[r];
    //cout<<i<<"+"<<a[i]<<" "<<d<<" "<<maw[r]<<":"<<v<<endl;
    if(v<0) NO();
  }
  
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 21376
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = ReadLong();
            var ans = (x / 11) * 2;
            var a = x % 11;
            if (a == 0)
            {
                
            }
            else if (a <= 6)
            {
                ans += 1;
            }
            else
            {
                ans += 2;
            }

            WriteLine(ans);
        }
       

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

#define INF 1<<29

typedef long long ll;
using namespace std;

//わからん。

int main(void) {
	int n, p;
	cin >> n >> p;
	vector<int>A(n);
	int odd = 0, even = 0;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
		if (A[i] % 2 == 0) {
			even++;
		}
		else {
			odd++;
		}
	}
	ll ans = 0;
	if (odd == 0) {
		if (p == 0) {
			ans = pow(2, odd + even);
		}
		else {
			ans = 0;
		}
	}
	else {
		ans = pow(2, odd + even - 1);
	}
	cout << ans;
	return 0;
	
}

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

using i64 = int64_t;

i64 gcd(i64 m, i64 n) {
    return (n == 0 ? m : gcd(n, m % n));
}

int main(){
    string s;
    while(cin >> s, s != "#"){
        reverse(s.begin(), s.end());
        i64 numerator, denominator = 1, idx = 0, n = 0;
        if(s[idx] == 'h'){
            numerator = 0;
            idx += 5;
        }else{
            numerator = 90;
            idx += 4;
        }
        while(idx < s.size()){
            denominator *= 2;
            numerator *= 2;
            if(s[idx] == 'h'){
                numerator -= 90;
                idx += 5;
            }else{
                numerator += 90;
                idx += 4;
            }
        }
        //cout << numerator << "/" << denominator << endl;
        i64 d = gcd(numerator, denominator);
        numerator /= d;
        denominator /= d;
        cout << numerator;
        if(denominator != 1)cout << "/" << denominator;
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3044
N,K= [int(i) for i in input().split()]
R,S,P= [int(i) for i in input().split()]
n=input()
C=N//K + 1
#T = np.zeros((K,C),dtype = int)
#print(T)
score=0

for i in range(K):
        mem=""
        for j in range(i,N,K):
                if n[j] =='r':
                        if j < K:
                                score+=P
                                mem ='r'
                        elif n[j-K]=='r' and mem=='r': mem =""
                        else:
                                score+=P
                                mem ='r'
                elif n[j] =='s':
                        if j < K:
                                score+=R
                                mem ='s'
                        elif n[j-K]=='s' and mem=='s': mem =""
                        else:
                                score+=R
                                mem ='s'
                elif n[j] =='p':
                        if j < K:
                                score+=S
                                mem ='p'
                        elif n[j-K]=='p' and mem=='p': mem =""
                        else:
                                score+=S
                                mem ='p'
                        
print(score)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using ll = long long;
using namespace std;
const ll mod = 1000000007;

int main() {
    char a,b;
    cin >> a >> b;

    if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
        cout << 'H' << endl;
    } else {
        cout << 'D' << endl;
    }
 
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        N=int(input())
        while True:
            for h in range(1,3501):
                for n in range(h,3501):
                    if 4*h*n-N*n-N*h==0:
                        continue
                    else:
                        temp=(N*h*n)/(4*h*n-N*n-N*h)
                        if temp>0 and temp.is_integer():
                            return [h,n,int(temp)]
    for i in main():
        print(i,end=' ')


resolve()

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

int main(){
    int n,k,r,s,p;
    cin >> n>> k >> r >> s >> p;
    string t;
    cin >> t;
    vector<char> hand;
    int point=0;
    for(int i=0; i<k; i++){
        if(t.at(i) == 'r'){
            hand.push_back('p');
            point += p;
        }
        else if(t.at(i) == 's'){
            hand.push_back('r');
            point += r;
        }
        else{
            hand.push_back('s');
            point += s;
        }
        //cout << point << endl;
    }
    for(int i=k; i<n; i++){
        if(t.at(i) == 'r'){
            if(hand.at(i-k) == 'p'){
                hand.push_back('n');
            }
            else{
                hand.push_back('p');
                point += p;
            }
        }
        else if(t.at(i) == 's'){
            if(hand.at(i-k) == 'r') hand.push_back('n');
            else{
                hand.push_back('r');
                point += r;
            }
        }
        else{
            if(hand.at(i-k) == 's') hand.push_back('k');
            else{
                hand.push_back('s');
                point += s;
            }
        }
        //cout << point << endl;
    } 
    cout << point << endl;
}


Measured memory_bytes: 3748
N, M = map(int, input().split())

shops = []
min_money = 0

for i in range(0, N):
    A, B = map(int, input().split())

    shops.append({'price': A, 'stock': B})

shops.sort(key=lambda x: x['price'])

for shop in shops:

    # 在庫がある
    if M < shop['stock']:
        min_money += shop['price'] * M
        break
    else:
        min_money += shop['price'] * shop['stock']
        M -= shop['stock']

print(min_money)


Measured memory_bytes: 41528
#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    string c1,c2; cin >> c1 >> c2;
    reverse(ALL(c1));
    if(c1==c2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

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

int main()
{
	int64_t n, t;
	cin >> n >> t;
	vector<int64_t> as(n), bs(n);
	for (int64_t i = 0; i < n; i++)
	{
		cin >> as[i] >> bs[i];
	}

	vector<pair<int64_t, int64_t>> cs(n);
	for (int64_t i = 0; i < n; i++)
	{
		cs[i] = {as[i], bs[i]};
	}
	sort(cs.begin(), cs.end());

	for (int64_t i = 0; i < n; i++)
	{
		as[i] = cs[i].first;
		bs[i] = cs[i].second;
	}

	vector<vector<int64_t>> dp(n + 1, vector<int64_t>(t + 1, 0));
	for (int64_t i = 0; i < n; i++)
	{
		for (int64_t j = 0; j <= t; j++)
		{
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if (j + as[i] < t)
			{
				dp[i + 1][j + as[i]] = max(dp[i + 1][j + as[i]], dp[i][j] + bs[i]);
			}
			else if (j < t)
			{
				dp[i + 1][t] = max(dp[i + 1][t], dp[i][j] + bs[i]);
			}
		}
	}

	int64_t ans = 0;
	for (int64_t j = 0; j <= t; j++)
	{
		ans = max(ans, dp[n][j]);
	}

	cout << ans << endl;

	return 0;
}

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

int main(int argc, char *argv[])
{
    int a, b, x;
	cin >> a >> b >> x;

	if ((x <= a + b) && (x >= a)) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            int n = int.Parse(Console.ReadLine());
            double ans = 0;
            for (int i=0; i<n; i++)
            {
                string[] s = Console.ReadLine().Split(' ');
                if (s[1] == "JPY") ans += double.Parse(s[0]);
                else ans += double.Parse(s[0]) * 380000;
            }
            Console.WriteLine(ans);
        }
    }
    //mcs Main.cs
    //mono Main.exe

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

char f(int i){
  if(i == 1)return 'a';
  if(i == 2)return 'b';
  if(i == 3)return 'c';
  if(i == 4)return 'd';
  if(i == 5)return 'e';
  if(i == 6)return 'f';
  if(i == 7)return 'g';
  if(i == 8)return 'h';
  if(i == 9)return 'i';
  if(i == 10)return 'j';
  if(i == 11)return 'k';
  if(i == 12)return 'l';
  if(i == 13)return 'm';
  if(i == 14)return 'n';
  if(i == 15)return 'o';
  if(i == 16)return 'p';
  if(i == 17)return 'q';
  if(i == 18)return 'r';
  if(i == 19)return 's';
  if(i == 20)return 't';
  if(i == 21)return 'u';
  if(i == 22)return 'v';
  if(i == 23)return 'w';
  if(i == 24)return 'x';
  if(i == 25)return 'y';
  if(i == 0)return 'z';
}

int main(){
  long long n;cin >> n;
  string ans = "";
  
  while(n >= 1){
    ans = f((n%26)) + ans;
    if(n%26 == 0){
      n -= 1;
      n /= 26;
    } else {
      n /= 26;
    }
      
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
from collections import Counter
n,k,l = map(int, input().split())
def f(m):
    a = list(range(n))
    def g(i):
        if a[i] == i:
            return i
        a[i] = g(a[i])
        return a[i]
    for _ in range(m):
        p,q = map(int, input().split())
        i = g(p-1)
        j = g(q-1)
        a[j] = i
    return g
g = f(k)
h = f(l)
c = Counter((g(i),h(i)) for i in range(n))
print(' '.join((str(c.get((g(i),h(i)), 1)) for i in range(n))))

Measured memory_bytes: 60516