akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,n) for(ll i=a;i<(ll)(n);i++)

struct point {
   int x;
   int y;
};

int main(){
   point A,B,C;
   while(cin>>A.x>>A.y>>B.x>>B.y>>C.x>>C.y, A.x||A.y||B.x||B.y||C.x||C.y){
      //辺の長さ
      double aL = sqrt(pow(C.x-B.x, 2)+pow(C.y-B.y, 2));
      double bL = sqrt(pow(C.x-A.x, 2)+pow(C.y-A.y, 2));
      double cL = sqrt(pow(B.x-A.x, 2)+pow(B.y-A.y, 2));

      //角度
      double rad[3];
      rad[0] = acos((bL*bL+cL*cL-aL*aL)/(2*bL*cL));
      rad[1] = acos((cL*cL+aL*aL-bL*bL)/(2*cL*aL));
      rad[2] = acos((aL*aL+bL*bL-cL*cL)/(2*aL*bL));

      //面積
      double s = (aL+bL+cL)/2;
      double S = sqrt(s*(s-aL)*(s-bL)*(s-cL));
      //内接円半径
      double r = S/s;
      
      //マルファッティ円の半径
      double rM[3];
      for(int i=0; i<3; i++){
         rM[i] = ((1+tan(rad[(1+i)%3]/4))*(1+tan(rad[(2+i)%3]/4)))/(2*(1+tan(rad[i]/4)))*r;
         cout << fixed << setprecision(10) << rM[i];
         if(i < 2) cout << " ";
      }
      cout<<endl;
   }
}



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

int main(){
  int D;
    
  while(cin >> D){
    int N, M;
    
    vector<int> A, B;    
    string s;
    int t;
    
    cin >> N;
    for(int i = 0 ; i < N ; i++){
      cin >> s >> t;
      if(s == "D") A.push_back(t);
    }
    
    cin >> M;    
    for(int i = 0 ; i < M ; i++){
      cin >> s >> t;
      if(s == "DD") B.push_back(t);
    }

    bool dp[20][210];
    memset(dp, false, sizeof(dp));
    dp[0][0] = true;
    
    for(int i = 0 ; i < (int)A.size() ; i++)
      for(int j = 13 ; j >= 0 ; j--)
	for(int k = 100 ; k >= 0 ; k--)
	  if(dp[j][k]) dp[j+1][k+A[i]] = true;
	    
    for(int i = 0 ; i < (int)B.size() ; i++)
      for(int j = 13 ; j >= 0 ; j--)
	for(int k = 100 ; k >= 0 ; k--)
	  if(dp[j][k]) dp[j+2][k+B[i]] = true;

    
    int ans = 0;    
    for(int i = 0 ; i <= D ; i++)
      for(int j = 0 ; j <= 100 ; j++)
	if(dp[i][j]) ans = max(ans, j);
    
    cout << ans << endl;
    
  }
  return 0;
}

Measured memory_bytes: 1236
import sys
sys.setrecursionlimit(10**7)
n,m=map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
  u,v=map(int,input().split())
  u,v=u-1,v-1
  g[u].append(v)
mi=set(range(n))
flg=False
def func(path):
  chk=set(path)
  if len(path)!=2:
    for i,v in enumerate(path):
      nvs=[nv for nv in g[v] if nv in chk]
      if len(nvs)==1:continue
      for nv in nvs:
        if nv==path[(i+1)%len(path)]:continue
        ary=[nv]
        for j,vj in enumerate(path):
          if vj==nv:break
        if i>j:
          ary=path[j:i+1]
        else:
          ary=path[:i+1]+path[j:]
        #print(path,ary,i,j)
        func(ary)
  print(len(path))
  for v in path:
    print(v+1)
  exit()

def dfs(v,seen):
  mi.discard(v)
  for nv in g[v]:
    if seen[nv]!=-1:# 巡回閉路
      seen[nv]=v
      path=[v]
      chk={v}
      while seen[v] not in chk:
        v=seen[v]
        path.append(v)
        chk.add(v)
      path.reverse()
      func(path)
    else:
      seen[nv]=v
      dfs(nv,seen)
      seen[nv]=-1
while mi:
  v=mi.pop()
  seen=[-1]*n
  dfs(v,seen)
print(-1)
exit()


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

static const int MAX = 51;
ll dp[MAX][MAX][MAX*MAX];
int x[MAX];

int main(){
    int n, a;
    cin >> n >> a;
    for(int i = 0; i < n; i++){
        cin >> x[i];
    }
    dp[0][0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int j = 0; j <= i; j++){
            for(int k = 0; k <= n*50; k++){
                dp[i][j][k] += dp[i-1][j][k];
                if(j > 0 && k >= x[i-1])
                    dp[i][j][k] += dp[i-1][j-1][k-x[i-1]];
            }
        }
    }
    ll ans = 0;
    for(int j = 1; j <= n; j++){
        ans += dp[n][j][a*j];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 30692
# Generated by AtcoderGreedy on 2018-05-10
# ABC085 D
# Your code here
$N, $H = gets.chomp.split(' ').map(&:to_i)

$b = []
$max_a = -100

$total = []
$N.times do
  a, b = gets.chomp.split(' ').map(&:to_i)
  $max_a = a < $max_a ? $max_a : a
  $b << b
end

$b = $b.sort

count = 0

while $H > 0
  if $b.empty? || $b.last < $max_a
    # puts [$H, $max_a, count].inspect
    count += ($H / $max_a.to_f).ceil
    break
  else
    count += 1
    $H -= $b.pop
  end
end

puts count


Measured memory_bytes: 4216
#include<stdio.h>
#include<string.h>
int main()
{
    char s[30];
    scanf("%s", s);
    int l = strlen(s);
    int i;
    int x = 0;
    if (l == 26)
    {
        for (i = l - 2; i >= 0; i--)
        {
            if (s[i] < s[i + 1])
            {
                x = i + 1;
                break;
            }
        }
        if (x == 0)
        {
            printf("-1\n");
            return 0;
        }
        else
        {
            x--;
            char min = 'z' + 1;
            for (i = x + 1; i < 26; i++)
            {
                if (s[x] - s[i] < 0)
                {
                    if (s[i] < min)
                        min = s[i];
                }
            }
            s[x] = min;
            s[x + 1] = '\0';
            printf("%s\n", s);
            return 0;
        }
    }
    else
    {
        int j;
        for (j = 0; j < 26; j++)
        {
            x = 0;
            for (i = 0; i < l; i++)
            {
                if (s[i] == 'a' + j)
                {
                    x++;
                    break;
                }
            }
            if (x == 0)
            {
                printf("%s%c\n", s, 'a' + j);
                return 0;
            }
        }
    }
}

Measured memory_bytes: 128
/*
#include <cstdio>
#include <cstring>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
*/
#include <bits/stdc++.h>
#define pb push_back
#define FOR(x,st,n) for(int x = (st); x < (n); ++ x)

using namespace std;


typedef long long unsigned ll;
typedef pair<int,int> P;
typedef vector<P> vp;
typedef vector<int> vi;
typedef vector<vi> vvi;


const ll N=(2e5)+6000;

int n,bar,cnt=0;
int cot[N/10];
bool isprime[N];



int main(){


    
    cin>>n;
    memset(isprime,1,sizeof(isprime));
    for(ll i=2;i<N;i++){
        if(isprime[i]){
            cot[cnt++] = i;
            
            if(i>=n){
                
                cout<<i<<endl;
                break;
            }
            for(ll j=i*i;j<N;j+=i){
                isprime[j]= false;
            }
        }
    }



    return 0;
}

Measured memory_bytes: 512
import math
import string


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


l = [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]
k = int(input())
print(l[k-1])


Measured memory_bytes: 3832
from collections import Counter
h, w, *s = open(0).read().split()
h = int(h)
w = int(w)
s = Counter(list(''.join(s)))

one = two = four = 0

for k in s:
    if s[k] % 4 == 0:
        four += 1
    elif s[k] % 2 == 0:
        two += 1
    else:
        one += 1
limit_one = 0
limit_two = 0


def ans():
    if two <= limit_two and one <= limit_one:
        print("Yes")
    else:
        print("No")


if h & 1 and w & 1:
    limit_two = h // 2 + w // 2
    limit_one = 1
    ans()
elif h & 1:
    limit_two = w // 2
    ans()
elif w & 1:
    limit_two = h // 2
    ans()
else:
    limit_two = 0
    ans()


Measured memory_bytes: 9520
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 1e9;

int main() {
    int y, m, d;
   
    scanf(" %d/%d/%d", &y, &m, &d);
    if (m > 4)cout << "TBD";
    else cout << "Heisei";

    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())   
s=input()
ans=0
for i in range(n):
    if(s[i]=="L" and i>=1):
        if(s[i-1]=="L"):ans+=1
    elif(s[i]=="R" and i<=n-2):
        if(s[i+1]=="R"):ans+=1
ans+=2*k
ans=min(n-1,ans)
print(ans)


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

#define MN 60000

int main()
{
	bool pr[MN] = {0};
	for(int i=2; i<MN; i++) pr[i]=1;
	
	for(int i=2; i*i<MN; i++)
	{
		if(pr[i])
		for(int j=i*2; j<MN; j+=i)
		{
			pr[j]=0;
		}
	}

	int n;
	while(cin >> n)
	{
		for(int i=n-1; i>1; i--)
		{
			if(pr[i]) { cout << i << " "; break; }
		}
		for(int i=n+1; i<MN; i++)
		{
			if(pr[i]) { cout << i << endl; break; }
		}
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int count = 0;
		int length = 0;
		Scanner sc = new Scanner(System.in);
			String s = sc.next();
			length = s.length();
			String t = sc.next();		
			
			if(t.length() != length) {
				System.out.println("2 String have diffrent length.");
				return;
			}	
			
			for(int i=0;i<length;i++) {
				if(!s.substring(i, i+1).equals(t.substring(i,i+1))){
					count++;
				}
			}
			System.out.println(count);
			count=0;
		
	}
	
}

Measured memory_bytes: 55344
#include<cstdio>
#include<algorithm>

using namespace std;

bool p[500000];
int s[100000];

void set()
{
	fill(p,p+500000,true);
	p[0]=false;
	p[1]=false;
	for(int i=2;i<500000;i++)
	{
		for(int j=2;j*i<500000;j++)
		{
			p[i*j]=false;
		}
	}
	int count=0;
	for(int i=0;i<500000;i++)
	{
		if(p[i])
		{
			s[count]=i;
			count++;
		}
	}
}

int main()
{
	set();
	while(true)
	{
		int n;
		int ans=0;
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++)
		{
			ans+=s[i];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define repz(i, z, n) for(decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for(decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(all(v)))
#define MIN(v) (*min_element(all(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<

using namespace std;
void debug_out(){ cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

typedef long long ll;
typedef unsigned long long ul;
// 1s間で可能なループ回数2E+8回
// intの最大値2147483647~2E+9
// long longの最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<> push_back
// 連想配列map<key,value> insert,
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// 大文字65-90(-32)
// 小文字97-122(+32)
// 1E+9 +7
const ll mod = 1000000000+7;
bool ispalindrome(string s){
  rep(i, SIZE(s)/2){
    if(s[i]!=s[SIZE(s)-1-i]) return false;
  }
  return true;
}
int main(){
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s; cin >> s;
  int n = SIZE(s);
  string first_part=s.substr(0, (n-1)/2);
  string second_part=s.substr((n+3)/2-1, n+1-(n+3)/2);
  // debug_out(first_part);
  // debug_out(second_part);
  if(ispalindrome(s) and ispalindrome(first_part) and ispalindrome(second_part)) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    table = [list(map(int, input().split())) for _ in range(n)]
    ct = cy = cx = 0
    for t, x, y in table:
        dist = abs(y - cy) + abs(x - cx)
        time = t - ct
        if dist > time or (time - dist) % 2 != 0:
            print('No')
            return
        ct = t
        cy = y
        cx = x
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 27380
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        boolean[] bool1 = new boolean[n+1];
        boolean[] bool2 = new boolean[n+1];
        for(int i = 0;i < m;i++){
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(a == 1){
                bool1[b] = true;
            }
            if(b == n){
                bool2[a] = true;
            }
        }
        if(solve(bool1,bool2,n)){
            System.out.println("POSSIBLE");
            return;
        }
        System.out.println("IMPOSSIBLE");

    }
    public static boolean solve(boolean[] bool1,boolean[] bool2,int n){
        for(int i = 1;i <= n;i++){
            if(bool1[i] && bool2[i]){
                return true;
            }
        }
        return false;
    }
}


Measured memory_bytes: 94336
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define pb push_back
typedef long double ld;
typedef vector<ll> vll;
typedef vector<pair<ll,ll>> vpl;
const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const ll mod = 1e9+7;

int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
        // cin >> tt;
    while((tt)--){
        ll n,m,k; cin >> n >> m >> k;
        vll a(n+1),b(m+1);
        repA(i,1,n) {
            cin >> a[i];
            a[i]+=a[i-1];
        }
        repA(i,1,m){
            cin >> b[i];
            b[i] += b[i-1];
        }

        ll ans =0;
        ll i=0;
        ll j = m;
        while(i<=n){
            if(a[i]>k) break;

            while((a[i]+b[j])>k)j--;
            ans = max(ans,i+j);
            i++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 6384
#include<iostream>
#include<algorithm>

using namespace std;

int gcd(int x, int y){
    int r;
    while(y != 0){
        r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int u[n];
    int d[n];
    u[0] = a[0];
    d[n-1] = a[n-1];
    for(int i = 1; i < n; i++){
        u[i] = gcd(u[i-1], a[i]);
    }
    for(int i = n - 2; i >= 0; i--){
        d[i] = gcd(d[i+1], a[i]);
    }
    // for(int i = 0; i < n; i++){
    //     cout << u[i] << " ";
    // }
    // cout << "\n";
    // for(int i = 0; i < n; i++){
    //     cout << d[i] << " ";
    // }
    // cout << "\n";
    int ans;
    ans = max(d[1], u[n-2]);
    for(int i = 1; i < n - 1; i++){
        ans = max(ans, gcd(u[i-1], d[i+1]));
    }
    
    cout << ans << '\n';
}


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

typedef pair<int,int> P;
typedef long long ll;

int n;
int a[123456],b[123456];
ll c[10],H,W;
map<P,int> cnt;

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

for(int i=0; i<n; i++) scanf("%d %d",&a[i],&b[i]);

for(int i=0; i<n; i++){
   if(a[i]+2<=H&&b[i]+2<=W){
   		cnt[P(a[i]+1,b[i]+1)]++;
   }
   if(a[i]+2<=H&&(b[i]-1>=1&&b[i]+1<=W)){
   		cnt[P(a[i]+1,b[i])]++;
   }
   if(a[i]+2<=H&&b[i]-2>=1){
   		cnt[P(a[i]+1,b[i]-1)]++;
   }
   if((a[i]+1<=H&&a[i]-1>=1)&&b[i]+2<=W){
   		cnt[P(a[i],b[i]+1)]++;
   }
   if((a[i]+1<=H&&a[i]-1>=1)&&(b[i]-1>=1&&b[i]+1<=W)){
   		cnt[P(a[i],b[i])]++;
   }
   if((a[i]+1<=H&&a[i]-1>=1)&&b[i]-2>=1){
   		cnt[P(a[i],b[i]-1)]++;
   }
   if(a[i]-2>=1&&b[i]+2<=W){
   		cnt[P(a[i]-1,b[i]+1)]++;
   }
   if(a[i]-2>=1&&(b[i]-1>=1&&b[i]+1<=W)){
   		cnt[P(a[i]-1,b[i])]++;
   }
   if(a[i]-2>=1&&b[i]-2>=1){
   		cnt[P(a[i]-1,b[i]-1)]++;
   }
}

map<P,int>::iterator it = cnt.begin();
while( it != cnt.end() ){
	P m=(*it).first; int n=(*it).second;
	//cout<<m.first<<" "<<m.second<<" "<<(*it).second<<endl;
	c[n]++;
	++it;
}

ll sub=0;

for(int i=1; i<10; i++){
	sub+=c[i];
}

c[0]=(H-2)*(W-2)-sub;

for(int i=0; i<10; i++) cout<<c[i]<<endl;

return 0;
 
}

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

int main() {
	char s[103], p[102];
	int l, i, b = 0, j, k;
	fgets(s, 121, stdin);
	l = strlen(s) - 1;
	fgets(p, l, stdin);
	k = strlen(p) - 1;
	if (k == 1) {
		if (strchr(s, p[0]) != NULL) b++;
	}else{
		for(i = 0; i < l - 1; ++i) {
				if (strstr(s, p) != NULL) ++b;
			s[102] = s[0];
			for (j = 0; j < l - 1; ++j) {
				s[j] = s[j + 1];
			}
		s[l - 1] = s[102];
		}
	}
	if (b != 0) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 2000
solve xss
    | all null xss = []
    | otherwise = (sum $ map head xss) : (solve $ map tail xss)


main = do
    _ <- getLine
    str <- getContents
    let xs = zipWith ($) (repeat $ (map read) . words) (lines str) :: [[Int]]
    let xs' = map (\x -> x ++ [sum x]) xs
    putStr $ unlines $ map (unwords . (map show)) (xs' ++ [solve xs'])

Measured memory_bytes: 5488
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

Int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

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

  cin>>n; Int a[n]; rep(i,n)cin>>a[i]; sort(a,a+n);
  Int ans=0,l=a[0],r=a[0],mi=1,ma=n-1;
  rer(i,1,n){
    if(r>l){
      if(a[ma]-l>r-a[mi]){
        ans+=a[ma]-l; l=a[ma]; ma--;
      }else{
        ans+=r-a[mi]; r=a[mi]; mi++;
      }
    }else{
      if(a[ma]-r>l-a[mi]){
        ans+=a[ma]-r; r=a[ma]; ma--;
      }else{
        ans+=l-a[mi]; l=a[mi]; mi++;
      }
    }
  }
  END
}


Measured memory_bytes: 4440
#include <stdio.h>
int main(void)
{

	int m, f, r;
	char seiseki;
	while (1)
	{
		scanf("%d %d %d", &m, &f, &r);

		if (m == -1 && f == -1 && r == -1)
			break;

		if ((0 <= m + f && m + f < 30) || m == -1 || f == -1)
		{
			seiseki = 'F';
		}
		else if (80 <= m + f && m + f <= 100)
		{
			seiseki = 'A';
		}
		else if (65 <= m + f && m + f < 80)
		{
			seiseki = 'B';
		}
		else if ((50 <= m + f && m + f < 65) || (50 <= r && r <= 100))
		{
			seiseki = 'C';
		}
		else if (30 <= m + f && m + f < 50)
		{
			seiseki = 'D';
		}
		printf("%c\n", seiseki);
	}
	return 0;
}


Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

using ll=long long;

int main() {
	ll X, K, D, f, left;
	cin >> X >> K >> D;
	X = abs(X);
	if (K <= X / D) {
		cout << abs(X - K * D) << endl;
	}
	else {
		f = floor(X / D);
		left = K - f;
		X -= D * f;
		cout << (left % 2 == 0 ? X : abs(X - D)) << endl;
	}
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using V = vector<ll>;
#define _GLIBCXX_DEBUG
#define rep(i, a, b) for(int i = a; i < b; i++)
#define ALL(v) v.begin(), v.end()

int main(){
    int n; cin>>n;
    double ans=0.0,a;
    rep(i,0,n){
        int a; cin>>a;
        ans+=1.0/a;
    }
    ans=1.0/ans;
    cout<<setprecision(16)<<ans<<endl;
}


Measured memory_bytes: 256
q = int(input())
F = [1]*(10**5)
for i in range(2,5*10**4):##2は素数
    F[i*2]=0

F[1]=0
for i in range(3,350,2):
    for n in range(3,10**5,2):
        if n>i and n%i==0:
            F[n]=0
#print(F[:10])
acc = 0
L =[0]
for i in range(1,10**5):
    if F[i] and F[(i+1)//2]:
        acc+=1
    L.append(acc)
L.append(0)
#print(L[:11])
for i in range(q):
    li,ri = map(int, input().split( ))
    print(L[ri]-L[li-1])
    

Measured memory_bytes: 51804
#include <stdio.h>
#include<stdlib.h>
 
int main() {
  
  int Q[32] = {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};
  
  int K;
  
  scanf("%d\n",&K);
  
  printf("%d\n",Q[K-1]);
  
  return 0;
  
}

Measured memory_bytes: 128
import sys
import math
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def make_grid(h, w, num): return [[int(num)] * w for _ in range(h)]


def main():
    H, W = NMI()
    grid = [SI() for _ in range(H)]
    DH = [-1, 1, 0, 0]
    DW = [0, 0, -1, 1]

    def bfs(sh, sw):
        queue = deque()
        seen = make_grid(H, W, -1)
        queue.append([sh, sw])
        seen[sh][sw] = 0
        while queue:
            now_h, now_w = queue.popleft()
            for dh, dw in zip(DH, DW):
                next_h = now_h + dh
                next_w = now_w + dw
                if not(0 <= next_h < H and 0 <= next_w < W):
                    continue
                if seen[next_h][next_w] != -1 or grid[next_h][next_w] == "#":
                    continue
                queue.append([next_h, next_w])
                seen[next_h][next_w] = seen[now_h][now_w] + 1

        return max([max(l) for l in seen])

    ans = 0
    for h in range(H):
        for w in range(W):
            if grid[h][w] == ".":
                ans = max(ans, bfs(h, w))
    print(ans)




if __name__ == "__main__":
    main()

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

using ll = long long;
const int mod = 1e9+7;

int add (int a, int b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

int mul (ll a, ll b) {
	a *= b;
	if (a >= mod) a %= mod;
	return a;
}

int sub (int a, int b) {
	a -= b;
	if (a < 0) a += mod;
	return a;
}

int binpow (int a, int b) {
	int res = 1;
	while (b) {
		if ((b&1)) res = mul(res, a);
		b >>= 1;
		a = mul(a, a);
	}
	return res;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, k, ans = 0;
	cin >> n >> k;
	vector <int> dp(k+1);
	for (int i=k; i>=1; i--) {
		int cnt = k/i;
		dp[i] = binpow(cnt, n);
		for (int j=2; j*i<=k; j++) {
			dp[i] = sub(dp[i], dp[i*j]);
		}
	}
	for (int i=1; i<=k; i++) {
		ans = add(ans, mul(i, dp[i]));
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3712
n,l=map(int,input().split())
s=n*l+n*(n+1)/2-n
d2=100000000000000000
x=0
for i in range(n):
    s1=s-i-l
    d=abs(s-s1)
    if d<d2:
        d2=d
        x=i
print(int(s-l-x))

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

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

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

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

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

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

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

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

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

int main(void){
    string s,t; cin >> s >> t;
    vector<vector<ll>> c(26); REP(i,s.size()) c[s[i]-'a'].push_back(i);
    ll now = -1, top = 0;
    REP(i,t.size()){
        if(c[t[i]-'a'].empty()){
            cout << -1 << endl;
            return 0;
        }
        ll itr = lower_bound(ALL(c[t[i]-'a']), now+1) - c[t[i]-'a'].begin();
        if(itr == c[t[i]-'a'].size()) itr = c[t[i]-'a'][0];
        else itr = c[t[i]-'a'][itr];
        if(itr <= now) top++;
        now = itr;
    }
    ll ans = (ll)s.size()*top + now+1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int q;
	cin >> q;
	bool turn = 1;
	deque<char> deq;
	rep(i, s.size()) deq.push_back(s[i]);
	while (q--) {
		int t;
		cin >> t;
		if (t == 1) {
			turn ^= 1;
		}
		else {
			int f; char c;
			cin >> f >> c;
			if (f == 1) {
				if (turn) deq.push_front(c);
				else deq.push_back(c);
			}
			else {
				if (turn) deq.push_back(c);
				else deq.push_front(c);
			}
		}
	}
	if (!turn) reverse(all(deq));
	for (char c : deq) cout << c;
	cout << endl;
 	return 0;
}


Measured memory_bytes: 976
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w) = (v[0], v[1]);
    let mut spans = vec![];
    for i in 0..h {
        let v = read_vec::<usize>();
        let (a, b) = (v[0] - 1, v[1] - 1);
        spans.push((a, b));
    }

    let mut to = BTreeMap::new();
    let mut costs = MultiSet::new();
    for x in 0..w {
        to.insert(x, 0);
        costs.insert(0);
    }

    for (i, (l, r)) in spans.into_iter().enumerate() {
        let mut ins = to.range((Included(l), Included(r)));
        let mut dels = vec![];

        while let Some(x) = ins.next() {
            dels.push((*x.0, *x.1));
            costs.remove(x.1);
        }

        if !dels.is_empty() {
            for x in &dels {
                to.remove(&x.0);
            }
            if r != w - 1 {
                let (last_x, last_cost) = dels[dels.len() - 1];
                let next_cost = r + 1 - last_x + last_cost;
                if !to.contains_key(&(r + 1)) || next_cost < to[&(r + 1)] {
                    to.insert(r + 1, next_cost);
                    costs.insert(next_cost);
                }
            }
        }

        if let Some(x) = costs.map.iter().next() {
            println!("{}", *x.0 + 1 + i);
        } else {
            println!("-1");
        }
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

struct MultiSet<T> {
    size: usize,
    map: std::collections::BTreeMap<T, u32>,
}

impl<T> MultiSet<T>
where
    T: Ord,
{
    fn new() -> Self {
        MultiSet {
            size: 0,
            map: std::collections::BTreeMap::new(),
        }
    }
    fn len(&self) -> usize {
        self.map.len()
    }
    fn insert(&mut self, val: T) {
        self.size += 1;
        *self.map.entry(val).or_insert(0) += 1;
    }
    fn remove(&mut self, val: &T) {
        assert!(self.map.contains_key(val));
        let cnt = self.map.get_mut(val).unwrap();
        *cnt -= 1;
        if *cnt == 0 {
            self.map.remove(val);
        }
    }
}


Measured memory_bytes: 12476
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;
const ll INF = 1061109567;
const double EPS = 1e-10;

int main(){
    int N;
    ll x=-INF;
    ll buf;
    cin>>N;
    int F[N][10];
    int P[N][11];
    int count[N];
    for(int i=0;i<N;i++){
        for(int j=0;j<10;j++){
                cin>>F[i][j];
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<11;j++){
            cin>>P[i][j];
        }
    }
    for(int i=1;i<1024;i++){
        for(int m=0;m<N;m++){
        count[m]=0;
        }
        for(int j=0;j<10;j++){
            if(1&(i>>j)){
                for(int k=0;k<N;k++){
                    if(F[k][j]==1){
                        count[k]++;
                    }
                }
            }
        }
        for(int k=0;k<N;k++){
            if(k==0){
                buf=P[k][count[k]];
            }else{
                buf+=P[k][count[k]];
            }
        }
        if(buf>x){
            x=buf;
        }
    }
    cout<<x<<endl;
    return 0;
}

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

using namespace std;

#define REP(i, a, b) for (int i = a; i < (int)b; i++)
#define rep(i, n) REP(i, 0, n)
#define all(c) (c).begin(), (c).end()

typedef pair<int, int> pii;

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

template <class T> constexpr bool in_range(T y, T x, T H, T W) {
  return 0 <= y && y < H && 0 <= x && x < W;
}

struct consumption {
  int on, off, stay;
  consumption() {}
  consumption(int on, int off, int stay) : on(on), off(off), stay(stay) {}
};

/*------------------------------------------*/
int H, W, M;
vector<string> G;
map<pii, consumption> costs;
vector<pii> vs;
map<pii, int> cnt;
/*------------------------------------------*/

int bfs(pii s, pii t) {

  map<pii, int> dist;
  dist[s] = 0;

  queue<pii> q;
  q.push(s);

  while (!q.empty()) {
    int y, x;
    tie(y, x) = q.front();
    q.pop();
    if (y == t.first && x == t.second)
      return dist[{y, x}];
    rep(k, 4) {
      int ny = y + dy[k], nx = x + dx[k];
      if (!in_range(ny, nx, H, W))
        continue;
      if (G[ny][nx] == '#')
        continue;
      if (dist.find({ny, nx}) == dist.end()) {
        dist[{ny, nx}] = dist[{y, x}] + 1;
        q.push({ny, nx});
      }
    }
  }
  assert(0);
}

vector<pii> make_path() {
  vector<pii> path = {vs[0]};
  queue<pii> q;
  q.push(vs[0]);
  set<pii> vis;
  vis.insert(vs[0]);
  pii prev[55][55];
  int idx = 0;

  while (!q.empty()) {
    int y, x;
    tie(y, x) = q.front();
    q.pop();
    if (idx + 1 >= vs.size())
      continue;
    if (y == vs[idx + 1].first && x == vs[idx + 1].second) {
      vector<pii> pt;
      pii curr = vs[idx + 1];
      for (; curr != vs[idx]; curr = prev[curr.first][curr.second])
        pt.push_back(curr);
      reverse(all(pt));
      for (auto &e : pt)
        path.push_back(e);
      idx++;
      if (idx == vs.size())
        break;
      vis.clear();
      vis.insert({y, x});
      while (!q.empty())
        q.pop();
    }
    rep(k, 4) {
      int ny = y + dy[k], nx = x + dx[k];
      if (!in_range(ny, nx, H, W))
        continue;
      if (G[ny][nx] == '#')
        continue;
      if (vis.count({ny, nx}))
        continue;
      vis.insert({ny, nx});
      prev[ny][nx] = {y, x};
      q.push({ny, nx});
    }
  }
  return path;
}

void input() {
  cin >> H >> W >> M;
  G.resize(H);
  rep(i, H) cin >> G[i];

  int C[3][H][W];
  rep(k, 3) rep(i, H) rep(j, W) cin >> C[k][i][j];
  rep(i, H) rep(j, W) costs[{i, j}] = {C[1][i][j], C[2][i][j], C[0][i][j]};
  rep(i, M) {
    int r, c;
    cin >> r >> c;
    vs.emplace_back(r, c);
  }
}

int main() {

  input();

  auto path = make_path();
  for (auto e : path)
    cnt[e]++;

  int ans = 0;
  map<pii, int> dist;
  int currdist = 0;
  pii prev = vs[0];

  for (auto &&e : path) {
    currdist += bfs(prev, e);
    if (dist.find(e) == dist.end())
      ans += costs[e].on;
    else
      ans +=
          min(costs[e].off + costs[e].on, costs[e].stay * (currdist - dist[e]));
    if (cnt[e] == 1)
      ans += costs[e].off;
    cnt[e]--;
    dist[e] = currdist;
    prev = e;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 19708
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N;
  std::cin >> N;
  std::vector< std::pair<ll, ll> > vp(N);
  for (ll i = 0; i < N; i++) {
    std::cin >> vp[i].first;
  }
  for (ll i = 0; i < N; i++) {
    std::cin >> vp[i].second;
  }
  ll ans = 0LL;
  for (ll i = 0; i < N; i++) {
    ans += (vp[i].first > vp[i].second) ? vp[i].first - vp[i].second : 0;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, '*'..string.sub(k, i, i)) end local r = io.read local u = table.unpack or unpack return function() return r(u(a)) end end})
read.N = function(N) local t={} for i=1,N do t[i]=read.n() end return t end
string.totable = function(s) local t={} local u=string.sub for i=1,#s do t[i] = u(s, i, i) end return t end
string.split = function(s) local t={} for w in string.gmatch(s, "[^%s]+") do table.insert(t, w) end return (table.unpack or unpack)(t) end
local function array(dimension, default_val) assert(type(default_val) ~= 'table') local n=dimension local m={}if default_val~=nil then m[1]={__index=function()return default_val end}end for i=2,n do m[i]={__index=function(p, k)local c=setmetatable({},m[i-1])rawset(p,k,c)return c end}end return setmetatable({},m[n])end
----
local N, Q = read.nn()
local edges = {}
for i=1,N do
    edges[i] = {}
end
local insert = table.insert
for i=1,N-1 do
    local a, b = read.nn()
    insert(edges[a], b)
    insert(edges[b], a)
end
local q = {}
for i=1,N do
    q[i] = 0
end
for i=1,Q do
    local p, x = read.nn()
    q[p] = q[p] + x
end

local C = {}
for i=1,N do
    C[i] = 0
end
local function dfs_cps(node, prev, accum, cont)
    accum = accum + q[node]
    C[node] = accum
    local adjs = edges[node]
    local function make_cont(j)
        return function()
            local next = adjs[j]
            if next then
                if next ~= prev then
                    return dfs_cps(next, node, accum, make_cont(j+1))
                else
                    return make_cont(j+1)()
                end
            else
                return cont()
            end
        end
    end
    return make_cont(1)()
end
dfs_cps(1, -1, 0, function()
    print(table.concat(C, ' '))
end)

Measured memory_bytes: 128852
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  





void solve(){
	int n;
	cin >> n ;
	string s ;
	cin >> s ;
	int cnt = count(all(s),'R')*count(all(s),'G') * count(all(s),'B') ;
	fr(j,1,n-1){
		fr(i,0,j-1){
			int k = 2*j-i;
			if(2*j-i < n){
				if((s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i])) cnt--;
			}
		}
	}
	cout << cnt << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << ":" << #x << " = " << (x) << endl;
#else
#define dbg
#endif

#pragma endregion Macros

int main()
{
    string S,T;
    cin >> S >> T;

    ll ans = 100100100100LL;

    rep(i, S.size() - T.size()+1){
        ll c = 0;
        for (int j = 0; j < T.size(); j++) {
            if (S[i + j] != T[j]) c++;
        }

        chmin(ans, c);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#include <iostream>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;

#define pf(n) cout << n << endl
#define ps() cout <<" ";
#define sf(n) cin >> n
#define in(i,n) for (int i = 0; i < n; i++)
#define mn -
#define pls +
#define mod %
#define E =
#define EE ==
#define le <=
#define ge >=
int mx=9999999;
/**  '' "\n" - ^ **/

inline void yes(int counter){
	if(counter EE 0)
    cout<<"yes\n";
    else if(counter EE 1)
    cout<<"Yes\n";
    else cout<<"YES\n";
    return;
}
inline void no(int counter){
	if(counter EE 0)
    cout<<"no\n";
    else if(counter EE 1)
    cout<<"No\n";
    else cout<<"NO\n";
    return;
}

inline int inc(int i,int j)
{
	return i + j;
}
inline int dec(int i,int j)
{
	return i - j;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string a;
    cin>>a;
    int sum E 0;
    in(i,a.length())
    {
    	sum E inc(sum,a[i] mn 48);
	}
	if(sum mod 9 EE 0)
	{
		yes(1);
	}
	else
	{
		no(1);
	}
}


Measured memory_bytes: 3772
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
int main(){
    ll N;
    cin >> N;
    vl A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    ll a = 0, ans = 0, b = 0;
    for(int i = 0; i < N; i++){
        if(A[i] < A[i + 1]){
            b = i - a;
            ans = max(ans, b);
            a = i + 1;
        }
        if(i == N - 1){
            b = N - 1 - a;
            ans = max(ans, b);
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

H,W = LI()
N = I()
a = LI()

ANS = []
for i in range(N):
    ANS += [i+1]*(a[i])

for i in range(H):
    if i % 2 == 0:
        print(*ANS[W*i:W*(i+1)])
    else:
        print(*reversed(ANS[W*i:W*(i+1)]))

Measured memory_bytes: 74460
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n;
vvi G;
vi used;
int dfs(int a){
	used[a]=true;
	int out=0;
	rep(i,G[a].size())if(!used[G[a][i]])out^=dfs(G[a][i]);
	return out+1;
}
int main(){
	int n;
	cin>>n;
	G=vvi(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	used=vi(n);
	int t=dfs(0);
	if(t==1)cout<<"Bob"<<endl;
	else cout<<"Alice"<<endl;
}









Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
int a[100005];
int main()
{
    int n;
    cin >> n;
    for(int i = 1; i <= n; i++)
    cin >> a[i];
    sort(a+1, a+1+n);
    int zhong = a[n]/2;
    int mins = INF;
    int ans;
    if(n%2 == 0)zhong = a[n]/2;
    else zhong = a[n]/2+1;
    for(int i = 1; i <= n; i++)
    {
        if(abs(zhong-a[i]) < mins)
        {
            mins = abs(zhong-a[i]);
            ans = a[i];
        }
    }
    cout << a[n] << ' ' << ans << endl;
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
  string s;
  cin >> s;
  sort(all(s));
  bool a = true;
  for (char i = 'a'; i <= 'z'; i++){
    if(!binary_search(all(s),i)){
      print(i);
      a = false;
      break;
    }
    else{
      continue;
    }
  }
  if(a){
    print("None");
  }
}

Measured memory_bytes: 512
#include<stdio.h>

int main()
{
  int i, j, H, W;

  while(1){
    scanf("%d%d", &H, &W);
    if(H == 0 && W == 0) break;

    for(i = 0; i < H; i++){
      for(j = 0; j < W; j++){
        if(i == 0 || i == H-1 || j == 0 || j == W-1) printf("#");
        else printf(".");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from fractions import Fraction

K, A, B = map(int, input().split())
if B <= A+3:
    print(K+1)
else:
    k = (K-A+1)//2
    print(k*B-(k-1)*A+(K-A+1)%2)


Measured memory_bytes: 63980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin >> S >> T;
  
  int Ns;
  Ns = S.size();
  T.erase(Ns);
  if(S==T){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628