akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  //昇順
  bool operator < (Point p)const{return (p.x!=x)?x<p.x:y<p.y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
};

struct Circle{
  Point p;
  Real r;
  Circle(){}
  Circle(Point p, Real r) : p(p) , r(r){}
  
  bool contain(Point a){
    return sgn((a-p).norm(),r)<=0;
  }
  
  Circle circumCircle(Point a,Point b){
    Point q=(a+b)/2;
    return Circle(q,(a-q).norm());
  }
  
  Circle circumscribedCircle(Point p, Point q, Point r){
    Point a=(q-p)*2,b=(r-p)*2;
    Point c(p.dot(p)-q.dot(q),p.dot(p)-r.dot(r));
    Circle res;
    res.p.x=a.y*c.y-b.y*c.x;
    res.p.y=b.x*c.x-a.x*c.y;
    res.p=res.p/a.cross(b);
    return Circle(res.p, p.dist(res.p));
  }

  Circle minEnclosingCircle(vector<Point>ps){
    if(ps.size()==0)return Circle(Point(0,0),0);
    if(ps.size()==1)return Circle(ps[0],0);

    Circle circle=circumCircle(ps[0],ps[1]);
    for(int i=2;i<ps.size();i++){
      if(!circle.contain(ps[i])){
	circle=circumCircle(ps[0],ps[i]);
	for(int j=1;j<i;j++){
	  if(!circle.contain(ps[j])){
	    circle=circumCircle(ps[j],ps[i]);
	    for(int k=0;k<j;k++){
	      if(!circle.contain(ps[k])){
		circle=circumscribedCircle(ps[i],ps[j],ps[k]);
	      }
	    }
	  }
	}
      }
    }
    return circle;
  }

};

int main(void){
    cout << fixed << setprecision(10);
  int n;
  cin >> n;
  vector<Point>ps(n);

  for(int i=0;i<n;i++)cin >> ps[i].x >> ps[i].y;
  Circle c;
  printf("%.10f",c.minEnclosingCircle(ps).r);
  cout << endl;

  return 0;
}

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

int main(void){
    int N; cin >> N;
    bool three=true;
    for(int i=0; i<N; i++){
        char c; cin >> c;
        if(c=='Y') three=false;
    }

    if(three) cout << "Three" << endl;
    else cout << "Four" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#include<queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define INF 2147483647
using namespace std;
using Graph=vector<vector<int>>;

int main(){
  char alpha;
  cin>>alpha;
  int key=0;
  for(char moji='a'; moji<='z';++moji){
    if(alpha==moji){
      key=1;
    }
  }
  if(key==0){
    cout<<'A';
  }else{
    cout<<'a';
  }
}

Measured memory_bytes: 3592
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N= sc.nextInt();
//		List<String> list = new ArrayList<>();
		String[] list = new String[N];
		Map<String, Integer> map = new TreeMap<String, Integer>();
		for(int i=0; i<N;i++) {
			String s = sc.next();
			if(map.get(s)==null) {
				map.put(s, 1);
			}
		}
		int ans  = map.values().toArray().length;
		
		System.out.println(ans);
	}

}

Measured memory_bytes: 77080
while True:
    N=0
    times=[]
    try:
        N=int(input())
        times=list(map(int,input().split()))
    except:
        break

    times.sort(reverse=True)
    ans=0
    for i in range(len(times)):
        ans+=(i+1)*times[i]
    print(ans)

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

using namespace std;

const int MAXN=1e5+1;

int x,y,a,b,c,p[MAXN],q[MAXN],r[MAXN],nowr;
long long ans=0;
priority_queue<int,vector<int>,greater<int> > apple;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>x>>y>>a>>b>>c;
	for(int i=1; i<=a; ++i) cin>>p[i];
	for(int i=1; i<=b; ++i) cin>>q[i];
	for(int i=1; i<=c; ++i) cin>>r[i];
	sort(p+1,p+1+a);
	sort(q+1,q+1+b);
	sort(r+1,r+1+c);
	for(int i=a; i>=a-x+1 && i>=0; --i) apple.push(p[i]);
	for(int i=b; i>=b-y+1 && i>=0; --i) apple.push(q[i]);
	nowr=c;
	while(nowr>0) {
		if(r[nowr]>apple.top()) {
			apple.pop();
			apple.push(r[nowr--]);
		} else break;
	}
	while(!apple.empty()) {
		ans+=apple.top();
		apple.pop();
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(n);
  int db2 = 0, db4 = 0;
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if (a[i] % 4 == 0) {
      db4++;
      continue;
    }
    if (a[i] % 2 == 0) {
      db2++;
    }
  }
  int other = n - db4 - db2;
  if (other > db4) {
    if (other == db4 + 1 && db2 == 0) {
      puts("Yes");
    } else {
      puts("No");
    }
    return 0;
  }
  if (2 * db4 + db2 >= n) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}


Measured memory_bytes: 640
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  dead_code
)]
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
//use std::num;
//use petgraph::unionfind::UnionFind;
//use permutohedron::LexicalPermutation as _;

const MOD: i64 = 1000_000_007;
//#[fastout()]
fn main() {
  input! {
      N:usize,
  }
  let mut ans = 0;
  for a in 1..N {
    let b = (N-1)/a;
    ans += b;
  }
  println!("{}", ans);
}


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


int main() {
    int A,B;
    cin>>A>>B;
    int a =A+B;
    int b=A-B;
    int c=A*B;
    int mx = max(a,max(b,c));
    cout <<mx <<endl;
}

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

const int INF = 1<<28;
int N, M;
vector<int> B, P;

int numOfSwaps(const vector<int> &a) {
  int n = a.size();
  int res = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = i+1; j < n; ++j) {
      res += (a[i] > a[j]);
    }
  }
  return res;
}

int calc(const vector<int> &a) {
  if(accumulate(a.begin(), a.end(), 0) !=
     accumulate(B.begin(), B.end(), 0)) return INF;
  vector<int> b(N, -1);
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      if(b[j] == -1 && B[j] == a[i]) {
        b[j] = i;
        break;
      }
    }
  }
  return numOfSwaps(b);
}

int main() {
  cin >> N >> M;
  B.resize(N); P.resize(M);
  for(int i = 0; i < N; ++i) cin >> B[i];
  for(int i = 0; i < M; ++i) cin >> P[i];
  vector<int> C(N), D(N);
  for(int i = 0, j = 0; j < M; ++j) {
    for(int k = 0; k < P[j]; ++k, ++i) C[i] = j & 1;
  }
  for(int i = 0; i < N; ++i) D[i] = 1 - C[i];
  cout << min(calc(C), calc(D)) << endl;
  return 0;
}

Measured memory_bytes: 1200
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

x = int(input())
a = 0
b = 0
done = False
for f in range(-300, 300):
    for l in range(-300, 300):
        if((f**5)-(l**5)==x):
            a = f
            b = l
            done = True
            break
    if(done):
        break
print(a,b)


Measured memory_bytes: 64916
using System;
using System.Collections;
using System.Collections.Generic;

namespace StudyCsharp
{
    static class Program
    {
        /// <summary>
        /// アプリケーションのメイン エントリ ポイントです。
        /// </summary>
        [STAThread]
        static void Main()
        {
            string[] s1 = Console.ReadLine().Split(' ');
            System.Collections.ArrayList s2 = new ArrayList();

            for (int i = 0; i < int.Parse(s1[0]); i++)
            {
                s2.Add(Console.ReadLine());
            }

            s2.Sort();

            string ans = string.Empty;
            foreach (var s in s2) 
            {
                ans += s;
            }
            
            Console.WriteLine(ans);
        }
    }
}


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

int main(){
 int a,b,k;
    cin >> a >> b >> k;
    vector<int> c;
    
    int count = 0;
    
    for(int i = 1; i <= min(a,b); i++) {
     if(a % i == 0 && b % i == 0) {
         c.push_back(i);
         count++;
     }
    }
    
    
     cout << c.at(count - k);
}

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

int main() {
  int n, d;
  cin>>n>>d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i,n) {
    rep(j,d) cin >> x[i][j];
  }
  int ans = 0;
  rep(i,n)rep(j,i) { // j < i
    int sq = 0;
    rep(k,d) {
      int s = x[i][k]-x[j][k];
      sq += s*s;
    }
    int s = sqrt(sq)+0.5;
    if (s*s == sq) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#初期data準備
student_max = 50
student_result = list()
student_grade = list()

for i in range(student_max):

    #インプットdataの挿入
    student_result.append(list(map(int, input().split())))

    #m、f、r がすべて -1 のとき入力終わり
    if sum(student_result[i]) == -3:
        break
    
    #成績判定
    if student_result[i][0] == -1 or student_result[i][1] == -1:
        student_grade.append("F")
    elif student_result[i][0] + student_result[i][1] >= 80:
        student_grade.append("A")
    elif student_result[i][0] + student_result[i][1] >= 65:
        student_grade.append("B")
    elif student_result[i][0] + student_result[i][1] >= 50:
        student_grade.append("C")
    elif student_result[i][0] + student_result[i][1] >= 30:
        if student_result[i][2] >= 50:
            student_grade.append("C")
        else:
            student_grade.append("D")
    else:
        student_grade.append("F")

#成績の表示
[print(i) for i in student_grade]



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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n, a, b; cin >> n >> a >> b;
    if((b-a) % 2 == 0){
        cout << (b-a)/2 << endl;
    }else{
        ll c = min(a-1, n-b) + 1;
        cout << c + (b-a-1)/2 << endl;
    }
}

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

int main() {
  int N,K;
  cin >> N >> K;
  
  int ans = 1;
  
  for (int i = 0; i < N; i++) {
    if (ans < K)
      ans *= 2;
    else
      ans += K;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

day = {"SUN": 0, "MON": 1, "TUE": 2, "WED": 3, "THU": 4, "FRI": 5, "SAT": 6}

print(7 - day.get(S))

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

void insert(int);
void preorder(Node);
void inorder(Node);
void treeDelete(Node);
Node treeMinimum(Node);
Node getSuccessor(Node);
Node treeSearch(Node, int);

#define NIL NULL

Node root;

Node treeMinimum(Node x){
while(x->left != NIL) x = x->left;
return x;
}

Node treeSearch(Node u, int k){
    while (u != NIL && k != u->key){
        if(k < u->key) u = u->left;
        else u = u->right;
    }
    return u;
}

void treeDelete(Node z){
    Node x;
    Node y;
    if(z->left == NIL || z->right == NIL) y = z;
    else y = getSuccessor(z);
    if(y->left != NIL) x = y->left;
    else x = y->right;
    if(x != NIL) x->parent = y->parent;
    if(y->parent == NIL) root = x;
    else if(y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;
    if(y!=z)z->key = y->key;
}

Node getSuccessor(Node x){
    Node y;
    if(x->right != NIL) return treeMinimum(x->right);
    y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
    }

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

     while (x != NIL){
         y = x;
         if (z->key < x->key)
             x = x->left;
         else 
             x = x->right;
     }
     z->parent = y;
    if (y == NIL)
        root = z;
    else if (z->key < y->key)
        y->left = z;
    else 
        y->right = z;

}

void inorder(Node u){
if (u == NIL) return;
inorder(u->left);
printf(" %d", u->key);
inorder(u->right);
}

void preorder(Node u){
    if(u == NIL) return;
    printf(" %d", u->key);
preorder(u->left);
preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
      scanf("%s", com);
      if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      }
      if(com[0] == 'i'){
          scanf("%d", &x);
      insert(x);
      }
      else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
}
 else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
}
  return 0;
}



Measured memory_bytes: 25172
#include <iostream>
using namespace std;
int main() {
	int N, X;
	cin >> N >> X;
	int sum = 0, ans = 1;
	for (int i = 0; i < N; ++i) {
		int L;
		cin >> L;
		sum += L;
		if (sum <= X) ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


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

    ll N, K; cin >> N >> K;
    vector<ll> a(N+1, 0), cum(N+1, 0);
    repr(i, 1, N+1) cin >> a[i];
    repr(i, 1, N+1) cum[i] = cum[i-1] + a[i];
    repr(i, 1, N+1) cum[i] -= i, cum[i] %= K;

    // rep(i, N+1) cout << cum[i] << ' ';
    // cout << endl;

    map<int, ll> mp;
    ll ans = 0;
    rep(r, N+1){
        ans += mp[cum[r]];
        mp[cum[r]]++;
        if(r-K+1>=0) mp[cum[r-K+1]]--;
    }
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 15872
#include<iostream>

using namespace std ;

int main()
{
	int h ,w ;
	char str[ 2 ][ 3 ] = { { "#." } ,{ ".#" } , } ;
	while( cin >> h >> w ,h | w )
	{
		for( int i = 0 ; i < h ; i++ )
		{
			for( int j = 0 ; j < w ; j++ )
				cout << str[ i % 2 ][ j % 2 ] ;
			cout << endl ;
		}
		cout << endl ;
	}
	return 0 ;
}

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

int K, A, B;

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

  if(A % K != 0 && B % K != 0 && (A / K) * K + K > B) cout << "NG" << endl;
  else cout << "OK" << endl;
  return 0;
}

Measured memory_bytes: 3632
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    n, m = map(int, input().split())
    uf = UnionFind(n)
    la = [None] * m
    for i in range(n):
        a = list(map(int, input().split()))
        for v in a[1:]:
            if la[v - 1] is None:
                la[v - 1] = i
            else:
                uf.union(i, la[v - 1])
    if uf.group_count() == 1:
        print("YES")
    else:
        print("NO")

if __name__ == "__main__":
    main()


Measured memory_bytes: 15544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    ll ans = 0;
    while(true)
    {
        bool update = false;
        for(int i = 0; i < n; i++)
        {
            if(a[i] >= n)
            {
                update = true;
                ll x = a[i] / n;
                a[i] %= n;
                ans += x;
                for(int j = 0; j < n; j++)
                {
                    if(j == i) continue;
                    a[j] += x;
                }
            }
        }
        if(!update)
        {
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int n[20]={};
  int s[20][100]={};
  int answer[20]={};
  int MAX=-1,min=1001,jM=0,jm=0;
  int i=0,j=0;

  for(;;i++){
    cin >> n[i];//?????°??\???
    if(n[i]>=3&&n[i]<=100){
      for(MAX=-1,min=1001,j=0;j<n[i];j++){//?????°?¶??????????
	cin >> s[i][j];
	if(MAX<s[i][j]){//?????§????±???????
	  MAX=s[i][j];
	  jM=j;
	}
	if(min>s[i][j]){//????°??±???????
	  min=s[i][j];
	  jm=j;
	}
	answer[i]+=s[i][j];
      }
      
      answer[i]=(answer[i]-s[i][jM]-s[i][jm])/(n[i]-2);
    }else{
      break;
    }
  }
  for(i=0;n[i]>=3&&n[i]<=100;i++){//??????
    cout << answer[i] << endl;
  }
}

Measured memory_bytes: 3028
#pragma GCC optimize("O2")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
}
int main()
{
    vok();
    ll n,k;
    IN n>>k;
    vll a(n);
    bitset<50> b[n];
    loop(i,0,n)
    {
        IN a[i];
        bitset<50> temp(a[i]);
        b[i]=temp;
    }
    bitset<50> ans(0);
    rloop(i,49,0)
    {
        int countt=0;
        loop(j,0,n)
        {
            if(b[j][i])
            {
                countt++;
            }
          	cout<<"";
        }
        ans[i]=1;
        if((countt*2)<n && ans.to_ullong()<=k)
        {
            //Do Nothing
        }
        else
        {
            ans[i]=0;
        }
    }
    ll fans=0LL;
    ll X=ans.to_ullong();
    loop(i,0,n)
    {
      	cout<<"";
        fans+=(X^a[i]);
    }
    OUT fans<<endl
    return 0;
}


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

int main() {
	map<int, int>check;
	for (int i = 0, tmp; i < 3; i++) {
		cin >> tmp; check[tmp]++;
	}

	bool ok = true;
	for (auto&& x : check) {
		if (x.first == 5 && x.second != 2)ok = false;
		if (x.first == 7 && x.second != 1)ok = false;
	}
	cout << (ok ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
using namespace std;
int main(){
	int a[200050]={0},b[100050],c,i,j,n,m;
	scanf("%d%d",&n,&m);
	for(i=0;i<2*m;i++){
		scanf("%d",&a[i]);
		if(a[i]<=n){
			b[a[i]]++;
		}
	}
	int times=0,t1,t2,t3,flag=1;
	for(i=0;i<=m;i++){
		if(b[i]%2!=0){
			flag=0;	
			break;
		}
	}	
	if(flag==1){
		printf("YES\n");
	}
	else{
		printf("NO\n");	
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;

int main(){
  int a;scanf("%d",&a);
  int L=a/100;
  int R=a%100;
  if(1<=L&&L<=12){
    if(1<=R&&R<=12)printf("AMBIGUOUS\n");
    else printf("MMYY\n");
  }else{
    if(1<=R&&R<=12)printf("YYMM\n");
    else printf("NA\n");
  }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::*;

fn read<T: FromStr>(s: &mut StdinLock) -> T {
    let s = s.by_ref().bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().unwrap_or_else(|_| panic!("Faild to parse {}", s))
}

fn main() {
    let s = stdin();
    let mut s = s.lock();

    let a: i32 = read(&mut s);
    let b: i32 = read(&mut s);

    println!("{}", (a + b + 1) / 2);
}

Measured memory_bytes: 4352
A, B, K =map(int, input().split())
ans = []


for i in range(K):
    if A <= A+i <= B:
        ans.append(A+i)


for i in range(K):
    if A <= B-(K-1)+i <= B and B-(K-1)+i not in ans:
        ans.append(B-(K-1)+i)
for a in ans:
    print(a)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
const int maxn = 400200;
int cnt = 0;
bool query(string v){
    assert(v[0] != '0');
    cout << "? " << v << endl; fflush(stdout);
    cnt++;
    assert(cnt <= 64);
    char ans;
    cin >> ans;
    return ans == 'Y';
}
int main(){
    vector<int> have;
    if(query("1000000000")){
        string value = "2";
        for(int e = 0; e < 10; e++){
            if(query(value)){
                value[0] = '1';
                cout << "! " << value << endl;
                return 0;
            }
            value.push_back('0');
        }
    }
    int len = -1;
    for(int mid = 9; mid >= 0 && len == -1; mid--){
        string value = "1";
        for(int f = 0; f < mid; f++)
            value.push_back('0');
        if(query(value))
            len = mid;
    }
    len++;
    string building;
    for(int e = 0; e < len-1; e++)
        building.push_back('0' + (e == 0));
    for(int e = 0; e < len-1; e++){
        int lo = (e == 0), hi = 9, ans = -1;
        while(lo <= hi){
            int mid = (lo + hi) >> 1;
            building[e] = '0' + mid;
            if(query(building)) ans = mid, lo = mid + 1;
            else hi = mid - 1;
        }
        assert(ans != -1);
        building[e] = '0' + ans;
    }
    string copy = building;
    for(int e = 9; e >= 0; e--){
        copy.push_back('0' + e);
        copy.push_back('9');
        if(e == 0 || !query(copy)){
            copy.pop_back();
            copy.back()++;
            cout << "! " << copy << endl;
            fflush(stdout);
            return 0;
        }
        copy.pop_back();
        copy.pop_back();
    }
    assert(0);
    return 0;
}


Measured memory_bytes: 596
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include<set>
#include<tuple>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;


int A, B, C, N;
	
bool hoge(int x, int y, int z){
	if(x < 0 || A <= x) return true;
	if(y < 0 || B <= y) return true;
	if(z < 0 || C <= z) return true;
	
	return false;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
	int dx[6] = {1,-1,0,0,0,0};
	int dy[6] = {0,0,1,-1,0,0};
	int dz[6] = {0,0,0,0,1,-1};
	
	int ans = 0;
	set<tuple<int,int,int>> s;
	
	cin>>A>>B>>C>>N;
	
	ans = (A*B + B*C + C*A) * 2;
	
	for(int i = 0; i < N; i++){
		int x, y, z;
		
		cin>>x>>y>>z;
		
		for(int j = 0; j < 6; j++){
			int nx = x + dx[j];
			int ny = y + dy[j];
			int nz = z + dz[j];
			
		
			if(s.count(make_tuple(nx,ny,nz)) || hoge(nx,ny,nz)) {
				ans--;
			} else {
				ans++;
			}
		}
		
		s.insert(make_tuple(x, y, z));
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 3252
def main():
    N, K = map(int, input().split())
    p = map(int, input().split())

    def expectation(x):
        return (1 + x) / 2

    e = map(expectation, p)

    def accumulation(a):
        s = 0
        yield s
        for x in a:
            s += x
            yield s

    *acc, = accumulation(e)

    ans = 0
    for i in range(K, N + 1):
        ans = max(ans, acc[i] - acc[i - K])

    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

using namespace std;

int main(void)
{
    int N; cin >> N;

    for(int i = N; i < 10000000000; ++i)
    {
        if(i % 2 == 0 and i % N == 0)
        {
            cout << i << endl;
            return 0;
        }
        else if((i * 2) % 2 == 0 and (i * 2) % N == 0)
        {
            cout << i * 2 << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <limits>

using int64 = long long;

template<class T>
class edge {
public:
    int to;
    T weight;

    edge(int to, T weight) : to{to}, weight{weight} {}
};

template<class T>
using Graph = std::vector<std::vector<edge<T>>>;

template<class T>
class Dijkstra {
private:
    Graph<T> g;
    const T INF = std::numeric_limits<T>::max() / 2;

    struct State {
        int v;
        T weight;

        State(int v, T weight) : v{v}, weight{weight} {}

        bool operator < (const State& s) const
        {
            return weight > s.weight;
        }
    };

public:
    Dijkstra(const Graph<T>& g) : g{g} {}

    std::vector<T> shortest_path(int s)
    {
        std::priority_queue<State> pq;
        pq.emplace(s, 0);

        std::vector<T> weight(g.size(), INF);
        weight[s] = 0;

        const auto& update = [&](const edge<T>& e, const State& s) -> bool
        {
            if (weight[s.v] + e.weight >= weight[e.to])
                return false;

            weight[e.to] = weight[s.v] + e.weight;
            return true;
        };

        while (!pq.empty()) {
            State curr = pq.top(); pq.pop();
            if (weight[curr.v] < curr.weight)
                continue;

            for (const edge<T>& e : g[curr.v])
                if (update(e, curr))
                    pq.emplace(e.to, weight[e.to]);
        }

        return weight;
    }
};

int main()
{
    int N;
    std::cin >> N;

    Graph<int64> g(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b, c;
        std::cin >> a >> b >> c;
        a--; b--;
        g[a].emplace_back(b, c);
        g[b].emplace_back(a, c);
    }

    int Q, K;
    std::cin >> Q >> K;
    K--;

    Dijkstra<int64> d(g);
    auto sp = d.shortest_path(K);

    for (int i = 0; i < Q; i++) {
        int x, y;
        std::cin >> x >> y;
        x--; y--;
        std::cout << sp[x] + sp[y] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 21144
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
   string s;
   cin >> s;
   if(s.size() % 2 == 0){
         for(int i = 0;i < s.size();i+= 2){
               if(s.substr(i,2) != "hi"){
                     cout << "No" << endl;
                     return 0;
               }
         }
         cout << "Yes" << endl;
   }else{
         cout << "No" << endl;
   }
}


Measured memory_bytes: 3584
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
	int a,b,c;
	cin>>a>>b>>c;
	if(a+b+c>=22){
		cout<<"bust";
		return 0;
	}
	cout<<"win";
	exit(0);
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include <algorithm>
int main() {

	std::string ina;

	std::cin >> ina;

	for (int i = 0; i < 3; i++) {
	
		if (ina[i] == '9')
		{
			ina[i] = '1';
		}
		else if (ina[i] == '1')
		{
			ina[i] = '9';
		}

	}
	std::cout << ina << std::endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int 
using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++)
  cin>>a[i];
  sort(a,a+n,greater<ll>());
  ll sum=a[0];
  for(ll i=1,j=1;i<n-1;i++)
  {
    sum+=a[j];
    if(i%2==0) j++;
  }
      cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
using namespace std;
const int mod=1000000007;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int n,k,r,s,p;
    cin >> n >> k;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    char prev[k];
    ll ans = 0;
    rep(i,0,k-1)prev[i] ='a';
    rep(i,0,n-1){
        if(i<k){
            // prev[i%k] = t[i]; 
        }else{
            if(prev[i%k] == t[i]){
                prev[i%k] = 'a';
                continue;
            }
        }
        if(t[i] == 'r'){
            ans += p;
        }
        if(t[i] == 's'){
            ans += r;
        }
        if(t[i] == 'p'){
            ans += s;
        }             
        prev[i%k] = t[i];
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

// #define DEBUG

const ll mod = 1e9 + 7;
ll mypow(ll x, ll y, ll m = mod)
{
    ll ans = 1;
    ll q = x;
    while (y > 0)
    {
        if (y % 2 == 1)
        {
            ans *= q;
            ans %= m;
        }
        q = q * q;
        q %= m;
        y = y / 2;
    }
    return ans % m;
}

/*
def comb(a,b,m):
    if b == 0 or b == a:
        ret = 1
    else:
        ret = 1
        for i in range(a-b+1,a+1):
            ret = (ret * i) % m
        for i in range(1,b+1):
            ret = (ret * pow(i,m-2,m) ) % m
    return ret
*/

ll permulation(ll x, ll y, ll m = mod)
{
    ll ans = 0;
    if (x >= y)
    {
        
        ans = 1;
        for (ll i = x - y + 1; i <= x; i++)
        {
            ans = (ans * i) % m;
        }
    }
    return ans;
}

ll combination(ll x, ll y, ll m = mod)
{
    ll ans = 0;
    if (y == 0 || y == x)
        ans = 1;
    else
    {
        ans = 1;
        for (ll i = x - y + 1; i <= x; i++)
        {
            ans %= ans * i;
        }
        for (ll i = 1; i <= y; i++)
        {
            ans %= ans * mypow(i, m - 2, m);
        }
    }
    return ans;
}

int main()
{

#ifdef DEBUG
    cout << "DEBUG MODE" << endl;
    ifstream in("input.txt"); //for debug
    cin.rdbuf(in.rdbuf());    //for debug
#endif

    ll n, k;
    cin >> n >> k;
    cout << permulation(k, n) << endl;
    return 0;
}

// getline(cin,s);
// a = strtok(s, ",");  ","で分解
// for (int i = 0; i < n; i++)


Measured memory_bytes: 3104
n = int(input())
AC = 0
TLE = 0
WA = 0
RE = 0
for i in range(n):
    s = input()
    if s == 'AC':
        AC += 1
    if s == 'WA':
        WA += 1
    if s == 'TLE':
        TLE += 1
    if s == 'RE':
        RE += 1
print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))


Measured memory_bytes: 9148
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

N, K = MAP()

ans = (N//K)**3
if K%2:
	print(ans)
else:
	ans += (N//K + (K//2 <= N%K))**3
	print(ans)

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<vector<int>> g(n);
  for(int i=0;i<n-1;++i) {
    int a, b; cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  ll su = 0;
  vector<int> c(n);
  for(int i=0;i<n;++i) {
    cin >> c[i];
    su += c[i];
  }
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  su -= c[0];
  queue<int> que;
  vector<bool> sel(n);
  que.push(0);
  sel[0] = true;
  int num = 0;
  vector<int> ans(n);
  while(!que.empty()) {
    int now = que.front(); que.pop();
    ans[now] = c[num];
    num++;
    for(int i=0;i<(int)(g[now].size());++i) {
      int next = g[now][i];
      if(!sel[next]) {
        sel[next] = true;
        que.push(next);
      }
    }
  }
  cout << su << endl;
  printv(ans);
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> B(N-1);
    for(int i = 0; i < N-1; i++){
        cin >> B[i];
    }
    
    long long ans = 0;
    ans += B[0];
    for(int i = 0; i < N-1; i++){
        if(i != N-2){
            ans += min(B[i], B[i+1]);
        }else{
            ans += B[i];
        }
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 384
// NK
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define ll long long
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define eb emplace_back
#define pob pop_back
#define psf push_front
#define pof pop_front
#define mkp make_pair
#define mkt make_tuple
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(false), cin.tie(nullptr);
	int n; cin>>n;
	ll dp[n];
	ll a[n];
	for (int i=0; i<n; i++)
		cin>>a[i];

	dp[0]=false;
	dp[1]=abs(a[0] - a[1]);

	for (int i=2; i<n; i++){
		dp[i] = min( abs(a[i] - a[i-1])+dp[i-1], abs(a[i] - a[i-2])+dp[i-2] );
	}
	cout<<dp[n-1]<<endl;
	
	return 0;
}


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

int main() {
  int r;
  ll p;

  cin >> r;
  cout << fixed << setprecision(10);
  cout << 2*r*3.14159265358979 << endl;
  return 0;
}

Measured memory_bytes: 3804
let n = Scanf.scanf " %d" (+) 0
let cs, ss, fs = Array.(make (n - 1) 0, make (n - 1) 0, make (n - 1) 0)
let _ = for i = 0 to n - 2 do Scanf.scanf " %d %d %d" @@ fun a b c -> cs.(i) <- a; ss.(i) <- b; fs.(i) <- c done
let _ = for j = 0 to n - 1 do let t = ref 0 in for i = j to n - 2 do t := ss.(i) + max 0 ((!t - ss.(i) + fs.(i) - 1) / fs.(i)) * fs.(i) + cs.(i) done; Printf.printf "%d\n" !t done

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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n;
string s, t;

int main() {
	megaRandom();
	cin >> n >> s >> t;
	for(int i = 0; i < sz(s); i ++) {
		bool oks = 1;
		for(int it = i, jt = 0; it < sz(s) && jt < sz(t); it ++, jt ++) {
			if(s[it] != t[jt]) {
				oks = 0; 	
				break;
			}
		}
		if(oks) {
			cout << i + n;
			return 0;
		}
	}        	
	cout << sz(s) + sz(t);
	return 0;  
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        char[] a = scanner.nextLine().toCharArray();
        char[] b = scanner.nextLine().toCharArray();
        char[] newA = new char[a.length + 1];
        char[] newB = new char[b.length + 1];
        for (int i = 1; i < newA.length; i++) {
            newA[i] = a[i-1];
        }
        for (int i = 1; i < newB.length; i++) {
            newB[i] = b[i-1];
        }
        Node[][] dp= new Node[newA.length][newB.length];
        for (int i = 0; i < newA.length; i++) {
            dp[i][0] = new Node(0, -1, -1);
        }
        for (int i = 0; i < newB.length; i++) {
            dp[0][i] = new Node(0, -1, -1);
        }
        for (int i = 1; i < newA.length; i++) {
            for (int j = 1; j < newB.length; j++) {
                if(newA[i] == newB[j]) {
                    dp[i][j] = new Node(dp[i-1][j-1].len + 1, i-1, j-1);
                } else {
                    if(dp[i-1][j].len >= dp[i][j-1].len) {
                        dp[i][j] = new Node(dp[i-1][j].len, i-1,j);
                    } else {
                        dp[i][j] = new Node(dp[i][j-1].len, i,j-1);
                    }
                }
            }
        }
        StringBuilder sb = new StringBuilder();
        int i =newA.length-1,j=newB.length-1;
        while(i>=0&&j>=0) {
           if(newA[i]==newB[j] && newA[i]!='\0') {
               sb.append(newA[i]);
           }
           int tmpI = dp[i][j].x;
           int tmpJ = dp[i][j].y;
           i = tmpI;
           j = tmpJ;
        }
        System.out.println(sb.reverse());
    }

    static class Node {
        public int len;
        public int x;
        public int y;
        public Node(int len, int x, int y) {
            this.len = len;
            this.x = x;
            this.y = y;
        }
    }

}

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

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

// 自動でmodを取ってくれる整数型
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(int n){ // 2のn乗
    if(n==0) return 1;
    mint x=f(n/2);
    x*=x;
    if(n%2==1) x*=2;
    return x;
}

// a^n mod を計算する
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//////////////////////////
int main(){
    string s;
    int n;
    cin>>n>>s;
    vector<mint> dp(n);
    rep(i,n) dp[i]=1;
    rep(i,n-1){
        vector<mint> dpt(n);
        vector<mint> sum(n-i+1);
        sum[0]=0;
        rep(j,n-i) sum[j+1]=sum[j]+dp[j];
        rep(j,n-i){
            if(s[i]=='<'){
 //               for(int k=j+1;k<=n-1-i;k++) dpt[j]+=dp[k];
                dpt[j]=sum[n-i]-sum[j+1];
            }
            else{
//                for(int k=0;k<=j;k++) dpt[j]+=dp[k];
                dpt[j]=sum[j+1];
            }
        }
        dp=dpt;
    }
    mint ans=0;
    rep(i,n) ans+=dp[i];
    cout<<dp[0]<<endl;
    return 0;
}


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

using namespace std;

vector<pair<int, int>> pt;
vector<int> id;
int n;

double getDist(pair<int, int> a, pair<int, int> b){
    return sqrt((a.first - b.first) * (a.first - b.first)
                + (a.second - b.second) * (a.second - b.second));
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        int x, y;
        cin >> x >> y;
        pt.emplace_back(x, y);
    }
    double ans = 0;
    for(int i = 0; i < (int) pt.size(); i++){
        for(int j = 0; j < (int) pt.size(); j++){
            if(i != j) ans += getDist(pt[i], pt[j]) / (double) n;
        }
    }
    cout << fixed << setprecision(10) << ans << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int N;cin>>N;
    vector<int>v(N);
    vector<int>c(N);
    vector<int>sub(N);
    int ans=0;
    rep(i,N)cin>>v.at(i);
    rep(i,N)cin>>c.at(i);
    rep(i,N){
        sub.at(i)=v.at(i)-c.at(i);
        if(sub.at(i)>=0)ans+=sub.at(i);
    }
    cout<<ans<<endl;

}

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

int main() {
    int a, b, c, d, x;
    cin >> a >> b >> c >> x;
    int res = 0;
    for (int e = 0; e <= a; ++e) {
        for (int f = 0; f <= b; ++f) {
            for (int g = 0; g <= c; ++g) {
                
                int tortal = 500 * e + 100 * f + 50 * g;
                if (x == tortal) res++;
            }
        }
    }
    cout << res << endl;
}

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
}


Measured memory_bytes: 3624
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
a.sort()
b = 1
for i in a:
  b |= b<<i
  
b &= 2**(s+1)-2**((s+1)//2)
t = b&(-b)
print(t.bit_length()-1)

Measured memory_bytes: 11580
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline
    h, w = [int(x) for x in input().rstrip().split(" ")]
    for i in range(h):
        c = input().rstrip()
        print(c)
        print(c)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 62184
# include <bits/stdc++.h>
using namespace std;
struct Bottle{
	int a;
	double l;
} a[4];
bool cmp(Bottle x,Bottle y){ return x.a*y.l < y.a*x.l; }
int main(){
	for (int i=0;i<4;++i)scanf("%d",&a[i].a);
	a[0].l=0.25;a[1].l=0.5;a[2].l=1;a[3].l=2;
	sort(a+0,a+4,cmp);
	double N; cin >> N;
	long long cost = 0;
	for (int i=0;i<4;++i){
		cost += (long long)floor(N / a[i].l) * a[i].a;
		N -= floor(N / a[i].l) * a[i].l;
	}
	cout << cost << endl;
	return 0;
}

Measured memory_bytes: 764