akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AGC001_A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = getint();
            var x = getsplit();
            var a = Array.ConvertAll(x, int.Parse);
            Array.Sort(a);
            long sum = 0;
            for (int i = 0; i < 2*n; i++)
            {
                if (i%2==0)
                {
                    sum += a[i];
                }
               
            }
            Console.WriteLine(sum);
        }
        public static string[] getsplit()
        {
            string[] x = Console.ReadLine().Split(' ');
            return x;
        }
        public static int getint()
        {
            int x = int.Parse(Console.ReadLine());
            return x;
        }
    }
}


Measured memory_bytes: 2648
[N,D] = list(map(int,input().split()))
listX =[]
for i in range(N):
    listX.append(list(map(int,input().split())))
output = 0

def dist(x,y):
    d2 = 0
    for i in range(D):
        d2 += (x[i]-y[i])**2
    d = d2**0.5
    return d

for i in range(N):
    for j in range(i,N):
        if i==j:
            continue
        else:
            d = dist(listX[i],listX[j])
            if d == int(d):
                output += 1

print(output)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){

int A,B,i,sum=1,count=0;

cin >> A >> B;

for(i=0;i==0;i){

  if(sum<B){
    sum=sum-1+A;
    count++;
  }
  else{
    break;
  }
}
cout << count << endl;
}


Measured memory_bytes: 3608
use std::str::FromStr;
use std::io::stdin;

fn main() {
    let n = read::<usize>();
    let vec = read_vec::<u64>();
    let mut hightest = 0 as u64;
    let mut count = 0 as u64;
    for i in 0..n {
        let current = vec[i];
        if current >= hightest {
            count += 1;
            hightest = current;
        }
    }
    println!("{}", count);
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

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

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
int main(){
  int N;cin>>N;
  vector<ll> A(N);
  for(int i = 0;i < N;i++)cin>>A[i];
  for(int i = 0;i < N;i++){// 0���܂܂�邩����
    if(A[i] == 0LL){
      cout << 0 << endl;
      return 0;
    }
  }
 
  ll ans = 1LL, MAX = 1000000000000000000LL;
  for(int i = 0;i < N;i++){
    if(MAX / ans < A[i]){// 10^18�𒴂��Ȃ�������
      ans = -1LL;
      break;
    }
    ans *= A[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 4048
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007

int main(){
    int N; cin >> N;
    vector<int> T(N);
    int sum = 0;
    for(int &t:T){
        cin >> t;
        sum += t;
    }
    int M; cin >> M;
    for(int i=0; i<M; i++){
        int p, x; cin >> p >> x;
        cout << sum - T[--p] + x << endl;
    }
    return 0;
}


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

const int INF = 1001001001;

int W, H, F, M, O;
int fld[15][15];

struct data {
	int y, x, s, o, f;
	data(int y, int x, int s, int o, int f)
		:y(y), x(x), s(s), o(o), f(f) {}

	bool operator<(const data &d)const {
		return f>d.f;
	}
};

int dist[15][15][1 << 10][50];

void solve() {
	fill_n(***dist, 15 * 15 * (1 << 10) * 50, INF);
	priority_queue<data>que;
	for (int i = 0; i<W; i++) {
		dist[0][i][1 << i][O] = 0;
		que.push(data(0, i, 1 << i, O, 0));
	}

	while (que.size()) {
		data d = que.top(); que.pop();
		if (dist[d.y][d.x][d.s][d.o]<d.f)continue;
		if (d.o == 0)continue;
		for (int i = -1; i <= 1; i += 2) {
			int ny = d.y, nx = d.x + i;
			if (nx<0 || nx >= W)continue;
			int ns, no, nf;
			if (d.s >> nx & 1) {
				ns = d.s; no = d.o - 1; nf = d.f;
			}
			else {
				ns = d.s | (1 << nx);
				no = min(M, d.o - 1 + (fld[ny][nx] >= 0 ? fld[ny][nx] : 0));
				nf = d.f + (fld[ny][nx] >= 0 ? 0 : -fld[ny][nx]);
			}
			if (no<0)continue;
			if (dist[ny][nx][ns][no] <= nf)continue;
			dist[ny][nx][ns][no] = nf;
			que.push(data(ny, nx, ns, no, nf));
		}

		int ny = d.y + 1, nx = d.x;
		if (ny>H)continue;
		int ns, no, nf;
		ns = 1 << nx;
		no = min(M, d.o - 1 + (fld[ny][nx] >= 0 ? fld[ny][nx] : 0));
		nf = d.f + (fld[ny][nx] >= 0 ? 0 : -fld[ny][nx]);
		if (no<0)continue;
		if (dist[ny][nx][ns][no] <= nf)continue;
		dist[ny][nx][ns][no] = nf;
		que.push(data(ny, nx, ns, no, nf));
	}

	int mi = INF;
	for (int j = 0; j<W; j++) {
		for (int o = 0; o <= M; o++) {
			mi = min(mi, dist[H][j][1 << j][o]);
		}
	}

	if (mi>F)cout << "NA" << endl;
	else cout << mi << endl;
}

int main() {
	while (cin >> W >> H, W || H) {
		cin >> F >> M >> O; M--; O--;
		for (int i = 1; i <= H; i++) {
			for (int j = 0; j<W; j++) {
				cin >> fld[i][j];
			}
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 48228
A, B, C = map(int, input().split())
K = int(input())

_sum = []
_max = max(A, B, C)
remaining = [r for r in [A, B, C] if r != _max]
if len(remaining) == 0:
    remaining = [_max, _max]
if len(remaining) == 1:
    remaining.append(_max)

for i in range(K):
    _max = _max * 2

print(_max + sum(remaining))


Measured memory_bytes: 61804
#include <stdio.h>

int main(void){
   int n,k,i,b[1001],t=0,p=0;
   scanf("%d%d",&n,&k);

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


   for(i=0;i<1001;i++)
      b[i]=0;
   for(i=0;i<n;i++)
      b[price[i]]+=1;

   for(i=0;i<k;i+=0){
      if(b[p]>=1){
         t+=p; i++;
         if(b[p]==1) p++;
         else b[p]--;
      }
      else p++;
   }


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

Measured memory_bytes: 1728
#include <iostream>
#include <string>
using namespace std;
int main(void){
  int A,B;
  cin >> A >> B;
  
  string s;
  cin >> s;
  
  if(s[A] != '-')
    cout << "No"<< endl;
  else{
    int ans = 0;
    for(int i=0;i<A;i++){
      if(s[i] == '-')
        ans++;
    }
    for(int i=A + 1;i<= A + B;i++){
      if(s[i] == '-')
        ans++;
    }
    
    if(ans == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int x,y;
        
        for(int i=1;i<=3000; i++){
         cin>>x>>y;   
        if(x==0&&y==0){break;}
       else if(y<x){
          swap(x,y);  
       }cout<<x<<" "<<y<<endl;
}
}


Measured memory_bytes: 3104
#include <cstdio>
#include <cstring>

char str[4];
int main() {
	scanf("%s", str);
	for(int i = 0; str[i]; i++) {
		if(str[i] == '1') str[i] = '9';
		else if(str[i] == '9') str[i] = '1';
	}

	printf("%s\n", str);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ll q = N/i;
    ans += (q+1)*q/2*i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define mod7 1000000007

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int x, y;
	bool pos = false;
	cin>>x>>y;
	if (y-2*x>=0 and (y-2*x)%2==0) {
		if (4*x-y>=0 and (4*x-y)%2==0) pos = true;
	}
	cout<<(pos? "Yes" : "No")<<'\n';
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;


string sim(string s) {
    string stk;
    for (char c: s) {
	if (stk.empty()) {
	    stk += c; continue;
	}
	if (stk.back() == '(' && c == ')') {
	    stk.pop_back(); continue;
	}
	stk += c;
    }
    return stk;
}

vector<string> mid;

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

    int n;
    cin>>n;

    while (n--) {
	string s; cin>>s;
	s = sim(s);
	if (s == "") continue;
	mid.push_back(s);
    }
    vector<string> left, right;
    for (auto s: mid) {
	int rnk = 0;
	for (char c: s) {
	    if (c=='(') rnk++; else rnk--;
	}
	if (rnk>=0) left.push_back(s); else right.push_back(s);
    }

    // net positive, but can still dip in the middle like ))(((
    sort(left.begin(), left.end(), [&](string a, string b) {
	    int n = a.length();
	    int m = b.length();
	    int i=0;
	    while (i<n && a[i]==')') i++;
	    
	    int j=0;
	    while (j<m && b[j]==')') j++;

	    return i<j;
	});

    sort(right.begin(), right.end(), [&](string a, string b) {
	    int n = a.length();
	    int m = b.length();
	    
	    int o1 = 0;
	    while (o1<(int)a.size() && a[o1]==')') o1++;
	    
	    int o2 = 0;
	    while (o2<(int)b.size() && b[o2]==')') o2++;

	    return n-o1 > m-o2;
	});
    

    string s;

    for (auto p: left) {
	for (char c: p) s += c;
    }
    for (auto p: right) {
	for (char c: p) s += c;
    }

    
    s = sim(s);
    if (s.empty()) cout<<"Yes\n"; else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 88092
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N,T = [int(x) for x in input().split()]
cost = []
for _ in range(N):
    c,t = [int(x) for x in input().split()]
    if t <= T:
        cost.append(c)

if cost:
    print(min(cost))
else:
    print("TLE")

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<fstream>
#include<stdio.h>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define PI  3.141592
//----------------------------------------
int main(void)
{

	int n;
	cin >> n;
	vector<int> a(n);

	rep(i, n)
	{
		cin >> a[i];

		if (a[i] % 2 != 0) continue;

		if (a[i] % 5 == 0 || a[i] % 3 == 0) continue;

		cout << "DENIED" << endl;
		return 0;

	}

	cout << "APPROVED" << endl;
}

Measured memory_bytes: 384
package main

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	_, a, b, c, d := nextInt(), nextInt()-1, nextInt()-1, nextInt()-1, nextInt()-1
	s := next()

	// 連続する岩がないか
	for i := a + 1; i < max(c, d); i++ {
		if s[i] == '#' && s[i+1] == '#' {
			YesOrNo(false)
			return
		}
	}

	if c < d {
		YesOrNo(true)
		return
	}

	// 3連続の空白があるか
	ok := false
	for i := b; i <= d; i++ {
		if s[i-1] == '.' && s[i] == '.' && s[i+1] == '.' {
			ok = true
			break
		}
	}
	YesOrNo(ok)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func YesOrNo(ok bool) {
	if ok {
		puts("Yes")
	} else {
		puts("No")
	}
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

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

    vector<vector<long long>> dp(n + 1, vector<long long>(n * a + 1));
    dp[0][0] = 1;
    for (int i = 0; i < n; ++i)
        for (int j = n; j > 0; --j)
            for (int k = x[i]; k < n * a + 1; ++k)
                dp[j][k] += dp[j - 1][k - x[i]];

    long long ans = 0;
    for (int i = 1; i <= n; ++i) ans += dp[i][i * a];

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1280
n, m = gets.chomp.split.map(&:to_i)
arr = gets.chomp.split.map(&:to_i)
miti = Array.new(n,0)
m.times do 
	a, b = gets.chomp.split.map{|ngo| ngo.to_i - 1}
	miti[a] = [miti[a], arr[b]].max
	miti[b] = [miti[b], arr[a]].max
end
cnt = 0
n.times do |i|
	cnt += 1 if arr[i] > miti[i]
end
puts cnt



Measured memory_bytes: 23428
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long long a,b,yakuans,baians;
	while(cin>>a>>b){
		long long c;
		c=a*b;
		if(b>a)swap(a,b);
		while(1){
			long long r;
			r=a%b;
			if(a%b==0)break;
			a=b;
			b=r;
		}
		baians=c/b;
		cout<<b<<" "<<baians<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
read k
read a b

s="$((b-a+1))"
ans=0

for i in `seq $((s))`
do
tmp="$((a+i-1))"
tmp="$((tmp%k))"
if [ $tmp = 0 ]; then
  ans=1
fi
done

if [ $ans = 1 ]; then
	echo "OK"
else
	echo "NG"
fi

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define mod 1000000007
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    FAST;
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll x=min(a,k);
    k-=x;
    ll y=min(k,b);
    k-=y;
    ll z=min(k,c);
    cout<<x-z;
}

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

int main(void) {
	int N, K;
	scanf("%d %d", &N, &K);
	int l[50];
	for (int i = 0; i < N; i++) {
		scanf("%d", &l[i]);
	}
	sort(l, l + N, greater<int>());
	int ans = 0;
	for (int i = 0; i < K; i++) {
		ans += l[i];
	}

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


Measured memory_bytes: 3776
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
const double pi=acos(-1.0);

int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int main(void){
    long long int a,v,b,w,t,x,y;
    cin>>a>>v>>b>>w>>t;
    if(a<b){x=a;y=b;}
    else{x=b;y=a;}
    for(int i=0;i<t;++i){
        x+=v;
        y+=w;
        if(x>=y){cout<<"YES"<<endl;return 0;}
        
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 3632
while True:
    (H, W) = [int(i) for i in input().split()]
 
    if H == W == 0:
        break
 
    for i in range(H):
        for r in range(W):
            if (i + r) % 2 == 0:
                print('#', end='')
            else:
                print('.', end='')
            #print('#', end='') if (i + r) % 2 == 0 else print('.', end='')
        print()
    print()

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i]
#define si(x)       cin>>x
#define sii(x,y)    cin>>x>>y
#define siii(x,y,z) cin>>x>>y>>z
#define ahell   998244353
#define hell 1000000007
#define N 1000001
#define fl 1.0000000000
//#define mod 998244353
#define cntbit(a) __builtin_popcountl(a)
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
//vector<int>adj[100005];
//int indeg[100005],lpath[100005];
main()
{
  ios
int n,m,i;
int j;
int u,v,q;
int test=1;
//si(test);

while(test--)
{
  int h,w;
  cin>>h>>w;
  char c[h][w];
  for(i=0;i<h;i++)
  {

    for(j=0;j<w;j++)
        cin>>c[i][j];

  }

  int dp[h][w];

  for(i=0;i<h;i++)
    for(j=0;j<w;j++)
        dp[i][j]=0;

  dp[0][0]=1;

  for(i=1;i<w;i++)
    {
        if(c[0][i]=='.')
            dp[0][i]=dp[0][i-1];
    }


  for(i=1;i<h;i++)
  {
    for(j=0;j<w;j++)
    {
        if(c[i][j]=='#')continue;

        if(j==0)
        {
            dp[i][j]=dp[i-1][j];
        }
        else
        {
            dp[i][j]=dp[i-1][j]+dp[i][j-1];
            dp[i][j]%=hell;
        }
    }
  }

  cout<<dp[h-1][w-1];
}

}


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

int main() {
  int N;
  bool hnn = 0;
  vector<vector<bool>> tei(3,vector<bool>(3));
  vector<vector<int>> bingo(3,vector<int>(3));
  for(int i = 0; i<3; i++){
    for(int j = 0; j<3; j++){
      cin >> bingo.at(i).at(j);
    }
  }
   cin >> N;
   vector<int> bibi(N);
  for(int i = 0 ; i<N; i++){
    cin >> bibi.at(i);
    for(int j =0; j<3; j++){
      for(int k =0;k<3; k++){
        if(bibi.at(i)==bingo.at(j).at(k)){
          tei.at(j).at(k)=1;
        }
      }
    }
  }
  for(int i = 0;i<3; i++){
    if(tei.at(i).at(0)){
      if(tei.at(i).at(1)){
        if(tei.at(i).at(2)){
          hnn = 1;
        }
       }
      }if(tei.at(0).at(i)){
      if(tei.at(1).at(i)){
        if(tei.at(2).at(i)){
          hnn = 1;
        }
       }
      }
    }if(tei.at(1).at(1)){
      if(tei.at(0).at(0) && tei.at(2).at(2)){
        hnn = 1;
      }else if(tei.at(2).at(0) && tei.at(0).at(2)){
        hnn = 1;
      }
    }if(hnn){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n = int(input())

max_diff = -float('inf')
min_diff = float('inf')
max_sum  = -float('inf')
min_sum  = float('inf')
for _ in range(n):
    x, y =map(int, input().split())
    max_diff = max(max_diff, x-y)
    min_diff = min(min_diff, x-y)
    max_sum = max(max_sum, x+y)
    min_sum  = min(min_sum, x+y)
print(max(max_diff - min_diff, max_sum - min_sum))

Measured memory_bytes: 69708
#include <iostream>
#include <bits/stdc++.h>
#include <set>

using namespace std;
using Int = long long;
Int prime = 1000000007;
Int memo[100001];

signed main(){
    Int n, m;
    cin >> n >> m;
    set<Int> a;
    for (Int i = 0; i < m; i++){
        Int tmp;
        cin >> tmp;
        a.insert(tmp);
    }

    memo[n] = 1;
    for (Int i = n - 1; i >= 0; i--){
        memo[i] = 0;
        set<Int>::iterator ite;
        ite = a.find(i);
        if (ite != a.end()) continue;

        if (i + 1 <= n) memo[i] += memo[i + 1];
        if (i + 2 <= n) memo[i] += memo[i + 2];
        memo[i] %= prime;
    }
    cout << memo[0] << endl;
    return 0;
}

Measured memory_bytes: 5760
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
    A=list(map(int,input().split()))
    p=C
    for j in range(M):p+=A[j]*B[j]
    if p>0:count+=1
print(count)

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

int main(){
  int n;
  cin>>n;
  ll ans=0;
  vector<int> sum(n);
  rep(i,n){
    int a,b;
    cin>>a>>b;
    sum[i]=a+b;
    ans-=b;
  }
  sort(sum.begin(),sum.end(),greater<int>());
  rep(i,n){
    ans+=sum[i];
    i++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

const int MAX_V=1e4+10;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; ll V; cin >> N >> V;
    vector<ll> a(N),b(N),c(N),d(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    rep(i,N) cin >> c[i];
    rep(i,N) cin >> d[i];
    map<ll,ll> m1,m2;
    rep(i,N) rep(j,N) ++m1[a[i]+b[j]];
    rep(i,N) rep(j,N) ++m2[c[i]+d[j]];
    ll ans=0;
    for (auto x:m1) ans+=x.second*m2[V-x.first];
    cout << ans << endl;
}


Measured memory_bytes: 190652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int N=55;
const int M=1e4+5;

int he[N],ver[M],nex[M],A[M],B[M],tot;
void addedge(int u,int v,int a,int b){
    ver[tot]=v;nex[tot]=he[u];A[tot]=a;B[tot]=b;he[u]=tot++;
}
ll d[N][M];
int tag[N][M];

int C[N],D[N];

struct node{
    int u,k;
    ll w;
    bool operator>(const node&a)const{return w>a.w;}
};
priority_queue<node,vector<node>,greater<node> >q;

void init();
void work();
int ca=1;
int main(){
//    freopen("in.txt","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
//    init();
//    int T;cin>>T;
//    while(T--)
    work();
    return 0;
}
void work(){
    int n,m;cin>>n>>m;
    int S;cin>>S;
    int u,v,a,b;
    tot=1;
    for(int i=0;i<m;i++){
        cin>>u>>v>>a>>b;
        addedge(u,v,a,b);
        addedge(v,u,a,b);
    }
    for(int i=1;i<=n;i++) cin>>C[i]>>D[i];

    const int lim=6e3;
    memset(d,0x3f,sizeof(d));
    d[1][min(S,lim)]=0;
    q.push(node{1,min(S,lim),0});
    while(!q.empty()){
        int u=q.top().u,k=q.top().k;
        q.pop();
//        cout<<u<<' '<<k<<endl;
        if(tag[u][k]) continue;
        tag[u][k]=1;
        int j=min(lim,k+C[u]);
        if(d[u][j]>d[u][k]+D[u]){
            d[u][j]=d[u][k]+D[u];
            q.push(node{u,j,d[u][j]});
        }
        for(int i=he[u];i;i=nex[i])if(A[i]<=k){
            int v=ver[i];
            int j=k-A[i];
            if(d[v][j]>d[u][k]+B[i]){
                d[v][j]=d[u][k]+B[i];
                q.push(node{v,j,d[v][j]});
            }
        }
    }
    for(int i=2;i<=n;i++){
        ll ans=1e18;
        for(int j=0;j<=lim;j++) ans=min(ans,d[i][j]);
        cout<<ans<<'\n';
    }
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;


int main() {
  ll a, b;
  cin>>a>>b;
  int r = -1;
  for(int x=0; x<100000; x++){
    int v1,v2;
    v1 = (x*8)/100;
    v2 = (x*10)/100;

    if(v1==a && v2==b){
      r = x;
      break;
    }
  }

  cout<<r<<endl;
  
  

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	int n; cin >> n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;i++){
		cin >> a[i] >> b[i] ; 
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	cout << a[n-1]+(b[0]-0) << endl;
}

Measured memory_bytes: 1024
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, a: "List[int]"):
    s = sum(a)
    c = 0
    m = float("inf")
    for i in range(len(a) - 1):
        c += a[i]
        m = min(m, abs(2 * c - s))
    print(m)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25064
N = int(input())
a = [int(x) for x in input().split()]

b = [0]*9
ans = 0
count = 0
for i in a:
    if i//400 < 8:
        b[i//400] = 1
    else:
        b[8] += 1
print(max(1, sum(b[:8])), sum(b))


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

int main()
{

    string s;
    cin>>s;
    int c=0;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='R')
            c+=1;
        else
        {
             if(c>ans)
                ans=c;
            c=0;
        }
    }
   if(c>ans)
                ans=c;
    cout<<ans<<endl;
   
}

Measured memory_bytes: 3616
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int W, H, x, y, r;
    
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if (!((y-r < 0) || (H < y+r) || (x-r < 0) || (W < x+r))) {
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}

Measured memory_bytes: 584
mod = 7+10**9
def ncr(n,c,mod):
  x = 1
  y = 1
  for i in range(n-c+1,n+1):
    x = x*i%mod
  for j in range(1,c+1):
    y = y*j%mod
  return (x * pow(y, mod-2, mod)) % mod

n, a, b = map(int, input().split())
al = pow(2, n, mod) -1
acr = ncr(n, a, mod)
bcr = ncr(n, b, mod)
print( (al-(acr+bcr))%mod )

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

int main(){
  vector<int> A(3);
  int K;
  cin >> A.at(0) >> A.at(1) >> A.at(2) >> K;
  sort(A.begin(),A.end());
  for (int i = 0; i < K; i++) {
    A.back()*=2;
  }
  cout << accumulate(A.begin(),A.end(),0) << endl;
}


Measured memory_bytes: 256
// doot diddly donger cuckerino Hahahahahah


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vi = vector<int>;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
template <typename T, typename U>
std::ostream& operator<<(std::ostream& stream, const pair<T, U>& p) {
  return stream << p.first << " " << p.second;
}
template <typename T>
std::ostream& operator<<(std::ostream& out, const vector<T>& vec) {
  for (const T& x: vec) out << x << ' ';
  return out;
}
template <typename T>
std::istream& operator>>(std::istream& in, vector<T>& vec) {
  for(auto& x: vec) in >> x;
  return in;
}
// @formatter:on


class DTriangles {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n - 2; ++i) {
      int k = i + 2;
      for (int j = i + 1; j < n; ++j) {
        while (k < n && a[i] + a[j] > a[k]) ++k;
        if (k > j) {
          ans += k - j - 1;
        }
      }
    }
    cout << ans << '\n';
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	DTriangles solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
const long double PI = (acos(-1));
const long long MOD = 1000000007;
#define rep(i,n) REP(i,0,n)
#define REP(i,x,n) for(int i=x;i<n;++i)

///////////////////////////////////////////////////
// -------------------- I/O -------------------- //
///////////////////////////////////////////////////
// https://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords
template<typename T> void outputVec(const std::vector<T>& vec, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	for (auto it = vec.begin(); it != vec.end() - 1; ++it) { std::cout << *it << " "; }
	std::cout << *(vec.end() - 1) << "\n";
}
template<typename T> void outputVal(const T& res, const int precision = 0) {
	if (precision > 0) std::cout << std::fixed << std::setprecision(precision);
	std::cout << res << "\n";
}
template<typename T> T inputVal() { T a; std::cin >> a; return a; }
template<typename T> std::vector<T> inputVec(int N) {
	std::vector<T> vec(N);
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
	return vec;
}
template<typename T> void inputVec(std::vector<T>& vec) {
	for (auto it = vec.begin(); it != vec.end(); ++it) { std::cin >> *it; }
}

///////////////////////////////////////////////////
// ------------------- utils ------------------- //
///////////////////////////////////////////////////
// change min/max
template<class T> inline bool chMin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chMax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

///////////////////////////////////////////////////
// ------------------- main -------------------- //
///////////////////////////////////////////////////
void Main() {
	const int N = inputVal<int>();
	map<string, priority_queue<pair<int,int> > > mp;

	rep(i, N) {
		string s; cin >> s;
		int rate; cin >> rate;
		if (mp.find(s) == mp.end()) {
			priority_queue<pair<int,int> > que;
			que.push(make_pair(rate, i));
			mp[s] = que;
		}
		else {
			mp[s].push(make_pair(rate, i));
		}
	}

	for (auto city : mp) {
		while (!city.second.empty()) {
			cout << city.second.top().second + 1 << endl;
			city.second.pop();
		}
	}
}

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

	double tmp;
	cin >> tmp;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var Instance = new Question();
			Instance.Exec();
		}
	}

	public class Question
	{
		public void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int a = array[0];
			int b = array[1];
			int c = array[2];
			int d = array[3];
			bool isConneceted = false;
			if (Math.Abs(a - c) <= d
				|| (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d)) {
				isConneceted = true;
			}

			string str = isConneceted ? "Yes" : "No";
			Console.WriteLine($"{str}");
			Console.ReadKey();
		}
	}
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> S(n);
    copy_n(istream_iterator<string>(cin), n, S.begin());
    map<string, int> count;
    int ma = 0;
    for (const auto &s: S){
        count[s]++;
        ma = max(ma, count[s]);
    }
    vector<string> ans;
    for (const auto &c: count){
        if (c.second == ma)
            ans.push_back(c.first);
    }
    sort(ans.begin(), ans.end());
    for (const auto &a: ans)
        cout << a << endl;
}

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

int main() {
    int n,h;cin>>n>>h;
    int a[n],b[n];rep(i,n)cin>>a[i]>>b[i];
    
    sort(a,a+n,greater<int>());
    sort(b,b+n,greater<int>());
    
    int ans = 0;
    int i=0;
    while(b[i]>a[0]){
        h-=b[i];
        ++ans;
        ++i;
        if(h<=0 ||i==n)break;
    }
    if(h>0){
    ans+=h/a[0];
    if(h%a[0] != 0)++ans;
    }

    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4332
#include<iostream>
#include<math.h>
using namespace std;

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



Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
// ------------------------
void solve() {
    string S, T; cin >> S >> T;
    int count = 0;
    if(S[0] == T[0]) ++count;
    if(S[1] == T[1]) ++count;
    if(S[2] == T[2]) ++count;

     cout << count << "\n";
}

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

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <iostream>
using namespace std;

int main() {
	int	N;
	cin >> N;
	long A[N + 1], B[N], kill = 0;
	for(int i = 0;i < N + 1;i++) cin >> A[i];
	for(int i = 0;i < N;i++) cin >> B[i];
	for(int i = 0;i < N;i++){
      if(B[i] - A[i] > 0){
        kill += A[i];
        B[i] -= A[i];
        if(B[i] - A[i + 1] > 0){ 
          kill += A[i + 1];
          A[i + 1] = 0;
        }
        else{ 
          kill += B[i];
          A[i + 1] -= B[i];
        }
      }
      else kill += B[i];
    }
	cout << kill;
}


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

int main(){
  set <char> S;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    char h;
    cin>>h;
    S.insert(h);
  }
  if(S.size()==3){
    cout<<"Three"<<endl;
  }else if(S.size()==4){
    cout<<"Four"<<endl;
  }
}


Measured memory_bytes: 256
#Fukushimaken: 
from heapq import heappop, heappush
OUT, IN = 0, 1
def P(i):
    return 31 if i % 5 == 1 else 3

def M(i):
    return 17 * (i % 2) + 3 * (i % 3) + 19

def check(c, n):
    for i in xrange(16):
        if (c >> i) & n == 0:
            return i
    return None

ans = [-1] * 100 + [0]
eq = map(lambda i: (i * 5, i, IN, None, P(i)), xrange(100))
c = 1 << 17
while len(eq) != 0:    
    m, n, et, i, p = heappop(eq)
    if et == IN:        
        i = check(c, p)
        if ans[n-1] != -1 and i is not None:
            c = c | (p << i)
            ans[n] = m - n * 5
            heappush(eq, (m + M(n), n, OUT, i, p))
        else:
            heappush(eq, (m + 1, n, IN, None, p)) #
    else:        
        c = c ^ (p << i)

while True:
    try:
        n = input()
        print ans[n]
    except:
        break

Measured memory_bytes: 4520
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		double k = sc.nextDouble(), t = k;
		for (int i=1; i<n; i++) {
			t*=k-1; // Good catch NICE problem
			if (t>Integer.MAX_VALUE) break;
		}
		System.out.println(new Double(t).intValue());
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 37480
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static long MOD = 1000000007;
	static char[] exp;

	public static void main(String[] args) {
		exp = sc.next().toCharArray();
		int v = sc.nextInt();
		int r1 = calc1();
		int r2 = calc2();
		if (v == r1) {
			System.out.println(v == r2 ? 'U' : 'M');
		} else {
			System.out.println(v == r2 ? 'L' : 'I');
		}
	}

	static int calc1() {
		ArrayList<Integer> stack = new ArrayList<Integer>();
		stack.add(exp[0] - '0');
		for (int i = 1; i < exp.length; i += 2) {
			if (exp[i] == '+') {
				stack.add(exp[i + 1] - '0');
			} else {
				stack.set(stack.size() - 1, stack.get(stack.size() - 1) * (exp[i + 1] - '0'));
			}
		}
		int ret = 0;
		for (int v : stack) {
			ret += v;
		}
		return ret;
	}

	static int calc2() {
		int v = exp[0] - '0';
		for (int i = 1; i < exp.length; i += 2) {
			if (exp[i] == '+') {
				v += exp[i + 1] - '0';
			} else {
				v *= exp[i + 1] - '0';
			}
		}
		return v;
	}

}

Measured memory_bytes: 17336
from collections import Counter,defaultdict,deque
from heapq import heappop, heappush
import sys,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

d,g = inpl()
p = [0] * d
c = [0] * d
for i in range(d):
    p[i], c[i] = inpl()
res = float('inf')

for flag in itertools.product((0,1),repeat=d):
    sco = 0
    cnt = 0
    for i,j in enumerate(flag):
        if j:
            sco += (i+1)*100*p[i] + c[i]
            cnt += p[i]
    # print(flag,sco,cnt)
    if sco >= g:
        res = min(res, cnt)
    else:
        rem = g - sco #残り
        for i,j in enumerate(flag):
            if not j:
                tmp = -(-rem//((i+1)*100))
                # print(flag,tmp)
                if tmp < p[i]:
                    res = min(res, cnt+tmp)
print(res)


Measured memory_bytes: 41324
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define endl "\n"
#define pi 3.14159265358979323846264338327950288
#define MOD 1000000007
#define INF -100000000000000
#define ordered_set tree<pair< ll int ,ll  int>, null_type,less<pair<ll int, ll int>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
#define MAXN 2000007
#define lld long double
using namespace __gnu_pbds;
ll int spf[MAXN]={0};
void sieve() 
{ 
    spf[1] = 1; 
    for (ll int i=2; i<MAXN; i++) 
  
        // marking smallest prime factor for every 
        // number to be itself. 
        spf[i] = i; 
  
    // separately marking spf for every even 
    // number as 2 
    for (ll int i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll int i=3; i*i<MAXN; i++) 
    { 
        // checking if i is prime 
        if (spf[i] == i) 
        { 
            // marking SPF for all numbers divisible by i 
            for (ll int j=i*i; j<MAXN; j+=i) 
  
                // marking spf[j] if it is not  
                // previously marked 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 
  set<ll int> s;
// A O(log n) function returning primefactorization 
// by dividing by smallest prime factor at every step 
bool getFactorization(ll int x) 
{ 
    vector<ll int> ret; 
    while (x != 1) 
    { 
        
        if(s.find(spf[x])!=s.end())
        	return false;
        else 
        	ret.push_back(spf[x]); 
        x = x / spf[x]; 

    }
    for(ll int i=0;i<ret.size();i++)
    s.insert(ret[i]); 
    return true;
} 
int main()
{
    fast;
    ll int n;
    cin>>n;
    ll int a[n];
    sieve();ll int i;
    for(i=0;i<n;i++)
    	cin>>a[i];
    ll int g=a[0];ll int f=0;
    for(i=1;i<n;i++)
    	g=__gcd(a[i],g);
    for(i=0;i<n;i++)
    {
    	bool z=getFactorization(a[i]);
    	if(z==false)
    	{
    		f=1;break;
    	}
    	
    }
    if(f==0)
    {
    	cout<<"pairwise coprime\n";
    }
    else if(g==1)
{
	cout<<"setwise coprime\n";
}
else
cout<<"not coprime\n";
}



Measured memory_bytes: 27020
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	string s;
	int num = 0;
	cin >> s;
	for (int i = 0; s[i] != '\0'; i++) {
		if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') {
			int cnt = 1;
			for (int j = i+1; j < s.size(); j++) {
				if (s[j] == 'A' || s[j] == 'C' || s[j] == 'G' || s[j] == 'T') {
					cnt++;
				}
				else {
					break;
				}
			}
			num = max(num, cnt);
		}
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
S = input()[::-1]

kari = ['dream', 'dreamer', 'erase', 'eraser']
 
words = [i[::-1] for i in kari]
 
l = len(S)
cnt = ''

for i in range(l):
    cnt += S[i]
    if cnt in words:
        cnt = ''

if cnt!='':
    print('NO')
else:
    print('YES')

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

int main(){
  int h,w,i,j;
  cin>>h>>w;
  string s[h];
  for(i=0;i<h;i++){
    cin>>s[i];
  }
  for(i=0;i<w+2;i++){
    cout<<"#";
  }
  cout<<endl;
  for(i=0;i<h;i++){
    cout<<"#"+s[i]+"#"<<endl;
  }
  for(i=0;i<w+2;i++){
    cout<<"#";
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>
#include <cmath>
#include <utility>
#include <map>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<int> vecint;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)




int main() {
	ll i, N, M, j,k;
	string S, T, U;
	cin >> S >> T >> U;
	cout << "A" << T[0] << "C\n"; 
	return 0;
}



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

using namespace std;
const int maxn = 1e5;
const double eps = 1e-5;
typedef long long int LL;
LL mod = 1000000007;

char ss[maxn];
int main()
{
    int n;
    scanf("%s",ss+1);
    ss[6] = ss[14] = ' ';
    puts(ss+1);
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    for (int i = 0; i < N; i++) cin >> S[i];
    
    vector<pair<int, int>> ps1, ps2;
    
    int all = 0;
    for (int i = 0; i < N; i++) {
        int K = S[i].size();
        int bottom = 0;
        int sub = 0;
        int now = 0;
        for (int j = 0; j < K; j++) {
            if (S[i][j] == '(') {
                now++;
                sub++;
            }else {
                now--;
                sub--;
            }
            bottom = min(bottom, now);
        }
        all += sub;
        if (sub > 0) ps1.push_back({sub, bottom});
        else ps2.push_back({sub, bottom});
    }
    
    sort(ps1.begin(), ps1.end(), [](auto x, auto y){if (x.second != y.second) return x.second > y.second; else return x.first > y.first;});
    sort(ps2.begin(), ps2.end(), [](auto x, auto y){return x.first + y.second > y.first + x.second;});
    
    if (all != 0) {
        cout << "No\n";
        return 0;
    }
    
    int pos = 0;
    for (int i = 0; i < (int)ps1.size(); i++) {
        if (pos + ps1[i].second < 0) {
            cout << "No\n";
            return 0;
        }
        pos += ps1[i].first;
    }
    for (int i = 0; i < (int)ps2.size(); i++) {
        if (pos + ps2[i].second < 0) {
            cout << "No\n";
            return 0;
        }
        pos += ps2[i].first;
    }
    cout << "Yes\n";
    return 0;
}

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

long long int t[1005]={0}, a[1005]={0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i)cin >> t[i] >> a[i];
    long long int takahashi = t[0], aoki = a[0];
    for(int i=1;i<n;++i){
        long long int tmp = max((takahashi + (t[i] - 1)) / t[i], (aoki + (a[i] - 1)) / a[i]);
        takahashi = t[i] * tmp;
        aoki = a[i] * tmp;
    }
    cout << takahashi + aoki << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=210,M=1e7+10;
int n,m,x[N],y[N],dp[N][N],prime[M],cnt;bool isp[M];
void init(){
	isp[0]=isp[1]=1;
	for (int i=2;i<M;i++){
		if (!isp[i]) prime[++cnt]=i;
		for (int j=1;j<=cnt&&i*prime[j]<M;j++){
			isp[i*prime[j]]=1;
			if (i%prime[j]==0) break;
		}
	}
	isp[2]=1;
}
//一般图最大带权匹配......
bool go[N][N];
int vis[N],match[N],C;
bool find(int x){
    for (int i=1;i<=m;i++)
    if (go[x][i]&&vis[i]!=C){
        vis[i]=C;
        if (!match[i]||find(match[i])){
            match[x]=i;
            match[i]=x;
            return 1;
        }
    }
    return 0;
}
int main()
{
	init();
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&x[i]);
	int last=y[++m]=x[1];
	for (int i=1;i<=n;i++)
    if (x[i]!=last) y[++m]=last,y[++m]=x[i],last=x[i]+1;else last++;
    y[++m]=last;
    for (int i=1;i<=m;i++)
    for (int j=1;j<=m;j++)
    if (!isp[abs(y[i]-y[j])]) go[i][j]=go[j][i]=1;
    int ans=0,odd=0,even=0;
    for (int i=1;i<=m;i++)
    if ((y[i]&1)&&!match[i]) C++,ans+=find(i);
    for (int i=1;i<=m;i++)
    if (!match[i]) y[i]&1?odd++:even++;
    ans+=odd/2*2;
    ans+=even/2*2;
    if (odd&1) ans+=3;
    printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 14592
def lcs(s1, s2):
    if len(s1) < len(s2):
      s1, s2 = s2, s1
    dp = []
    for s2_k in s2:
        #print(dp)
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):#要素とそのindexを取得
            #s2_kをs1のbgn_idx番目以降から探す
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            #print(s2_k, i, cur_idx, chr_idx, dp)
            if not chr_idx:#0だったらTrue#findは見つからないとき - 1を返す
                break
            dp[i] = min(cur_idx, chr_idx)
            #print(dp)
            bgn_idx = cur_idx
            
        else:#breakされなければ読み込まれる。
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if chr_idx:#0だったらfalse
                dp.append(chr_idx)
            #print(dp)    
             
    return len(dp)


n = int(input())
for _ in range(n):
    x = input()
    y = input()
    print(lcs(x, y))


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

#define DIV 1000000007

long long N, M;
long long dp[305][305][305];
vector<pair<long long, long long> >rule[305];

bool valid(int pos, int red, int yel, int bul){
	for(int i = 0; i < rule[pos].size(); i++){
		long long left = rule[pos][i].first;
		long long w = rule[pos][i].second;
		long long num = 0;
		if(left <= red){
			num++;
		}
		if(left <= yel){
			num++;
		}
		if(left <= bul){
			num++;
		}
		if(num != w){
			return false;
		}
	}
	return true;
}

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

	for(long long i = 1; i <= M; i++){
		long long l, r, x;
		cin >> l >> r >> x;
		rule[r].push_back(make_pair(l, x));
	}

	//dp[0][0][0] = 1;
	if(valid(1, 1, 0, 0)){
		dp[1][0][0] = 1;
	}
	if(valid(1, 0, 1, 0)){
		dp[0][1][0] = 1;
	}
	if(valid(1, 0, 0, 1)){
		dp[0][0][1] = 1;
	}
	for(long long idx = 2; idx <= N; idx++){
		//進む先の情報からそれがvalidか判断できる

		//used red at (idx - 1)
		for(long long yel = 0; yel < idx; yel++){
			for(long long bul = 0; bul < idx; bul++){
				bool ok = true;
				if(valid(idx, idx, yel, bul)){
					//choose red
					dp[idx][yel][bul] += dp[idx - 1][yel][bul];
					dp[idx][yel][bul] %= DIV;
				}

				if(valid(idx, idx-1, idx, bul)){
					//choose yel
					dp[idx - 1][idx][bul] += dp[idx - 1][yel][bul];
					dp[idx - 1][idx][bul] %= DIV;
				}

				if(valid(idx, idx-1, yel, idx)){
					//choose bul
					dp[idx - 1][yel][idx] += dp[idx - 1][yel][bul];
					dp[idx - 1][yel][idx] %= DIV;
				}
			}
		}

		//used yel at (idx - 1)
		for(long long red = 0; red < idx; red++){
			for(long long bul = 0; bul < idx; bul++){
				if(valid(idx, idx, idx-1, bul)){
					//choose red
					dp[idx][idx - 1][bul] += dp[red][idx - 1][bul];
					dp[idx][idx - 1][bul] %= DIV;
				}
				if(valid(idx, red, idx, bul)){
					//choose yel
					dp[red][idx][bul] += dp[red][idx - 1][bul];
					dp[red][idx][bul] %= DIV;
				}
				if(valid(idx, red, idx-1, idx)){
					//choose bul
					dp[red][idx - 1][idx] += dp[red][idx - 1][bul];
					dp[red][idx - 1][idx] %= DIV;
				}
			}
		}

		//used bul at (idx - 1)
		for(long long red = 0; red < idx; red++){
			for(long long yel = 0; yel < idx; yel++){
				if(valid(idx, idx, yel, idx - 1)){
					//choose red
					dp[idx][yel][idx - 1] += dp[red][yel][idx - 1];
					dp[idx][yel][idx - 1] %= DIV;
				}
				if(valid(idx, red, idx, idx-1)){
					//choose yel
					dp[red][idx][idx - 1] += dp[red][yel][idx - 1];
					dp[red][idx][idx - 1] %= DIV;
				}
				if(valid(idx, red, yel, idx)){
					//choose bul
					dp[red][yel][idx] += dp[red][yel][idx - 1];
					dp[red][yel][idx] %= DIV;
				}
			}
		}
	}

	long long ans = 0;
	for(long long red = 0; red <= N; red++){
		for(long long yel = 0; yel <= N; yel++){
			for(long long bul = 0; bul <= N; bul++){
				//cout << "dp[" << red << "][" << yel << "][" << bul << "] = " << dp[red][yel][bul] << endl;
				if(red == N || yel == N || bul == N){
					ans += dp[red][yel][bul];
					ans %= DIV;
				}
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 219392