akhauriyash/Code-Regression huggingface dataset:
package main
 
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)
 
var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, "\n"))
}
func Output() {
  _ = writer.Flush()
}
 
func Max(x, y int) int {
  if x < y { return y }
  return x
}
 
func main() {
  N := NextInt()
  G := make([][][]int, N)
  for i := range G {
    G[i] = make([][]int, 0)
  }
  C := make([]int, N - 1)
  for i := range C {
    AB := NextIntVec()
    a, b := AB[0] - 1, AB[1] - 1
    G[a] = append(G[a], []int{i, b})
    G[b] = append(G[b], []int{i, a})
  }
  k := 0
  Q := make([][]int, N)
  for i := range Q {
    Q[i] = []int{0, 0}
  }
  pos := 1
  for _, q := range Q {
    v, c := q[0], q[1]
    k = Max(len(G[v]), k)
    next := 1
    for _, E := range G[v] {
      if E[1] < v { continue }
      if next == c { next++ }
      C[E[0]] = next
      Q[pos] = []int{E[1], next}
      pos++
      next++
    }
  }
  Write(k)
  WriteIntVec(C)
  Output()
}

Measured memory_bytes: 26368
use proconio::{fastout, input};
use std::collections::HashMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        s: [String; n],
    }

    let mut scores = HashMap::new();
    let mut count = 0u64;
    for item in s {
        let mut item_vec = item.chars().collect::<Vec<char>>();
        item_vec.sort();
        let value = scores.entry(item_vec).or_insert(0);
        count += *value;
        *value += 1;
    }
    println!("{}", count);
}


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

def sol(N):
    if N == 1:
        return []

    N += 1
    ans = [[] for _ in range(N)]

    K = 0
    for i, n in enumerate(range(1, N // 2)):
        ans[i].append(n)
        K += 1
    for i, n in enumerate(range(N // 2, N - 1)):
        ans[K - 1 - i].append(n)

    return ans

if N % 2 == 1:
    ans = sol(N)
    for a in ans[:M]:
        print(*a)
else:
    L = N // 2
    ans = []

    if L % 2 == 0:
        for a in sol(L + 1):
            if len(a) == 0:
                continue
            ans.append(a)
        for a in sol(L - 1):
            if len(a) == 0:
                continue
            a[0] += L + 1
            a[1] += L + 2
            ans.append(a)
        for a in ans[:M]:
            print(*a)
    else:
        for a in sol(L):
            if len(a) == 0:
                continue
            ans.append(a)
        for a in sol(L):
            if len(a) == 0:
                continue
            a[0] += L
            a[1] += L + 1
            ans.append(a)
        for a in ans[:M]:
            print(*a)


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

int main()
{
    int N, M, C, buf, sum = 0, count = 0;
    std::cin >> N >> M >> C;
    std::vector<int> A, B;
    for (int i = 0; i < M; i++)
    {
        std::cin >> buf;
        B.push_back(buf);
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            std::cin >> buf;
            A.push_back(buf);
        }
        for (int k = 0; k < M; k++) { sum += A[k] * B[k]; }
        if ((sum + C) > 0) { count++; }
        sum = 0;
        A.erase(A.begin(), A.end());
    }

    std::cout << count << std::endl;
    return 0;
}

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

int main(){
    ll N;cin>>N;
    ll info[N];
    for(ll i=0;i<N;i++)info[i]=0;
    ll flag=0;
    for(ll i=0;i<N;i++){
        ll p;cin>>p;
        if(!i and p)flag++;
        info[p]++;
    }
    ll count=0,q=0;
    while(count<N){
        if(info[q]==0 or info[0]!=1){
            flag++;
            break;
        }
        count+=info[q];
        q++;
    }
    if(flag){
        cout<<0<<endl;
        return 0;
    }
    ll k=0;
    for(ll i=0;i<N;i++){
        if(info[i]==0){
            k=i-1;
            break;
        }
    }
    ll ans=1;
    for(ll i=1;i<k;i++){
        for(ll j=0;j<info[i+1];j++){
            ans*=info[i];
            ans%=998244353;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
int main(){
	int a,b,ans;
	scanf("%d%d0", &a,&b);
	if((1<=a)&&(a<=9)&&(1<=b)&&(b<=9)){
		ans=a*b;
	}else{
		ans=-1;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
using System;
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int W, H, x, y, r;
            W = int.Parse(str[0]);
            H = int.Parse(str[1]);
            x = int.Parse(str[2]);
            y = int.Parse(str[3]);
            r = int.Parse(str[4]);
            Console.WriteLine(x - r < 0 || x + r > W || y - r < 0 || y + r > H ? "No" : "Yes");
        }
    }



Measured memory_bytes: 17940
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        long m = Long.parseLong(scan.next());
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = Long.parseLong(scan.next());
            a[i] /= 2;
        }
        scan.close();

        long lcm = a[0];
        for (int i = 1; i < n; i++) {
            lcm *= a[i] / gcd(lcm, a[i]);
            if (lcm > m) {
                System.out.println(0);
                return;
            }
        }

        long twoCount = twoCount(a[0]);
        for (int i = 1; i < n; i++) {
            long twoCountI = twoCount(a[i]);
            if (twoCountI != twoCount) {
                System.out.println(0);
                return;
            }
        }

        System.out.println(1 + (m - lcm) / (lcm * 2));
    }

    private static long gcd(long a, long b) {
        if (a % b == 0) {
            return b;
        } else {
            return gcd(b, a % b);
        }
    }

    private static long twoCount(long a) {
        long count = 0;
        while (a % 2 == 0) {
            a /= 2;
            count++;
        }
        return count;
    }

}


Measured memory_bytes: 49160
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <functional>
#include <string>
#define SIZE 200005

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

struct UF
{
	int par[SIZE],rank[SIZE];
	
	void init(int n)
	{
		for(int i=0;i<n;i++)
		{
			par[i]=i;
			rank[i]=1;
		}
	}
	int find(int x)
	{
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y)
	{
		x=find(x);
		y=find(y);
		if(x==y) return;
		if(rank[x]<rank[y])
		{
			par[x]=y;
		}
		else
		{
			par[y]=x;
			if(rank[x]==rank[y]) rank[x]++;
		}
	}
	bool same(int x,int y)
	{
		return find(x)==find(y);
	}
};
UF S,T;
vector <P> all;

int main()
{
	int n,k,l;
	scanf("%d %d %d",&n,&k,&l);
	S.init(n+2);
	T.init(n+2);
	for(int i=0;i<k;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		S.unite(a,b);
	}
	for(int i=0;i<l;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		T.unite(a,b);
	}
	for(int i=0;i<n;i++) all.push_back(P(S.find(i),T.find(i)));
	sort(all.begin(),all.end());
	for(int i=0;i<n;i++)
	{
		P p=P(S.find(i),T.find(i));
		int ans=upper_bound(all.begin(),all.end(),p)-lower_bound(all.begin(),all.end(),p);
		if(i!=0) printf(" ");
		printf("%d",ans);
	}puts("");
	return 0;
}


Measured memory_bytes: 5492
#include<iostream>
#include <math.h>
#include <iomanip>
#include <vector>

typedef long long ll;

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

using namespace std;

ll size(ll num){
    ll digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
int main() {
    ll n;
    ll ma = pow(10, 18);
    ll s = 1;
    cin >> n;
    vector<ll> a;

    rep(i, n) {
        ll as; cin >> as;
        a.push_back(as);
        if (as == 0)
        {
            cout << "0";
            return 0;
        }
        if (as > ma) {
            cout << "-1";
            return 0;
        }
    }
    rep(i, n) {
        ll as; as = a.at(i);
        ll m = size(s) + size(as);
        if (s > ma || (m > 19 && ma != s*as)) {
            cout << "-1";
            return 0;
        }
        s *= as;
    }
    if (s > ma) {
        cout << "-1";
        return 0;
    }
    cout << s;
}


Measured memory_bytes: 4324
program main
  implicit none
  integer :: n, l, i, ma, res
  integer, allocatable :: ringos(:)
  read (*, *) n, l
  allocate (ringos(n))
  do i = 1, n
    ringos(i) = l + i - 1
  end do
  ma = minval(abs(ringos))
  do i = 1, n
    if (abs(ringos(i)) == ma) ringos(i) = 0
  end do
  write (*, "(i0)") sum(ringos)
end program main


Measured memory_bytes: 256
// --------------
// Tejas Pandey  |
// 02 - 08 - 20  |
// Atcoder BC 174|
// --------------

#include <bits/stdc++.h>
using namespace std;
     
#define mod 1000000007
#define vi vector<int>
typedef long long int ll;
     
int main (void){
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int x;
  cin >> x;
  if(x > 29) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
const int INF = 2000000000;
// const ll MOD = 1000000007;

const int MAX_N = 100001;
struct edge {
  int to, cost;
};
vector<edge> g[MAX_N];
int d[MAX_N];
bool visit[MAX_N];

int N, M;

bool dfs(int v, int cost) {
  if (visit[v]) {
    return d[v] == cost;
  }
  visit[v] = true;
  d[v] = cost;

  for (int i = 0; i < g[v].size(); i++) {
    edge e = g[v][i];
    if (!dfs(e.to, cost + e.cost)) {
      return false;
    }
  }

  return true;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 0; i < M; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    g[l].push_back(edge{r, d});
    g[r].push_back(edge{l, -d});
  }

  fill(d, d + N + 1, INF);
  for (int i = 1; i <= N; i++) {
    if (visit[i]) {
      continue;
    }

    d[i] = 0;
    if (!dfs(i, 0)) {
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 12160
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut aseq = vec![0; n];
    let mut sums = vec![0; n + 1];
    for i in 0..n {
        aseq[i] = read::<i64>();
        sums[i + 1] += aseq[i];
        sums[i + 1] += sums[i];
    }
    let mut ans = 1 << 60;
    let mut pos = [0, 2];
    let mut sum = [0, aseq[1]];
    for i in 2..n - 1 {
        sum[1] -= aseq[i - 1];
        let mut values = [0, 0, 0, 0];
        for j in 0..2 {
            let total = [sums[i], sums[n] - sums[i]][j];
            let mut v = aseq[pos[j]];
            while ((sum[j] + v) - (total - sum[j] - v)).abs() < (sum[j] - (total - sum[j])).abs() {
                sum[j] += v;
                pos[j] += 1;
                v = aseq[pos[j]];
                // println!("{} {} {}", pos[j], sum[j], total - sum[j]);
            }
            values[j * 2 + 0] = sum[j];
            values[j * 2 + 1] = total - sum[j];
            // println!("{} {} {}", pos[j], sum[j], total - sum[j]);
        }
        values.sort();
        assert!(values[0] != 0);
        ans = std::cmp::min(ans, values.last().unwrap() - values[0]);
    }
    println!("{}", ans);
}


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

int main() {
  int w, h, x, y, r;
  cin >> w >> h >> x >> y >> r;

  if(x-r >= 0 && x+r <= w && y-r >= 0 && y+r <= h) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int main (int argc, char *argv[]) {
  int input;
  cin>>input;
  if (input % 10 == 7
      || input / 10 % 10 == 7
      || input / 100 % 10 == 7) {
    cout<<"Yes"<<endl;
  } else {
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
using namespace std;

const int INF=12345678;
int n,lon[100005],p[100005],dist[100005];
vector<int> nei[100005];
queue<int> q;

void DFS(int x){
	dist[x]=1;
	for(int i=0;i<nei[x].size();i++){
		int now=nei[x][i];
		if(p[x]==now) continue;
		p[now]=x;
		lon[now]=lon[x]+1;
		DFS(now);
		dist[x]+=dist[now]; 
	}
}

int main(){
	cin>>n;
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		nei[x].push_back(y);
		nei[y].push_back(x);
	}
	p[1]=1;
	lon[1]=0;
	DFS(1);
	int par=n;
	for(int i=0;i<(lon[n]-1)/2;i++) par=p[par];
//	cout<<lon[n]<<endl;
//	cout<<par<<endl;
	if(dist[par]<n-dist[par]) puts("Fennec");
	else puts("Snuke");
	return 0;
}

Measured memory_bytes: 13184
import java.util.Scanner;
import java.lang.Math;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num1 = sc.nextInt();
		int num2 = sc.nextInt();
		int hour = sc.nextInt();
		int min = sc.nextInt();
		
		double degOfMin = min*6;
		double degOfHour = hour*30 + degOfMin/12;
		
        double deg = Math.abs(degOfHour - degOfMin);
        if (deg > 180){deg = 360 - deg;}
      	double rad = Math.toRadians(deg);
        double num3 = (num1*num1) + (num2*num2) - (2*num1*num2*Math.cos(rad));
      
		System.out.print(Math.sqrt(num3));
    }
}

Measured memory_bytes: 35940
import math
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sum_A = sum(A)
sum_B = sum(B)
cnt1 = sum_B - sum_A
cnt2 = 0
for a, b in zip(A, B):
    # if a > b:
    #     cnt2 += a - b
    if a < b:
        cnt2 += math.ceil((b - a) / 2)

if cnt1 >= cnt2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 4600
#include<iostream>
#include<vector>

using namespace std;
typedef long long ll;
typedef vector<vector<long long>> mat;

const long long MOD=1000000007;

mat mul(mat &a,mat &b){
    mat c(a.size(),vector<long long>(b[0].size()));
    for(int i=0;i<a.size();++i){
        for(int k=0;k<b.size();++k){
            for(int j=0;j<b[0].size();++j){
                c[i][j]+=a[i][k]*b[k][j];
                if(c[i][j]>=MOD)c[i][j]%=MOD;
            }
        }
    }
    return c;
}

mat pow(mat a,long long n){
    mat b(a.size(),vector<long long>(a.size()));
    for(int i=0;i<a.size();++i){
        b[i][i]=1;
    }
    while(n>0){
        if(n&1)b=mul(b,a);
        a=mul(a,a);
        n>>=1;
    }
    return b;
}

ll n,k;
mat x;

signed main(){
    cin>>n>>k;
    x.resize(n);
    for(int i=0;i<n;++i){
        x[i].resize(n);
    }
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            cin>>x[i][j];
            //cout<<i<<" "<<j<<" "<<a[i][j]<<endl;
        }
    }


    x=pow(x,k);
    ll cnt=0;
    for(int i=0;i<n;++i){
        for(int j=0;j<n;++j){
            cnt+=x[i][j];
            if(cnt>=MOD){
                cnt-=MOD;
            }
        }
    }

    cout<<cnt<<endl;

    return 0;
}

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

int prime_num(int n)
{
  ++n;
  bool* array = new bool[n];
  fill_n(array, n, true);
  array[0] = array[1] = false;

  for (int i = 2; i < n; ++i)
  {
    if (!array[i]) continue;
    for (int j = i * 2; j < n; j += i)
    {
      array[j] = false;
    }
  }

  int result = 0;
  for (int i = 0; i < n; ++i)
  {
    if (array[i]) ++result;
  }

  delete[] array;
  return result;
}

int main(void)
{
  int n;
  while (cin >> n)
  {
    cout << prime_num(n) << endl;
  }
  return 0;
}

Measured memory_bytes: 2244
K = int(input())
list = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(list[K - 1])

Measured memory_bytes: 3060
import java.util.*;

class Main{
  static boolean[][] wall = new boolean[9][];
  static int[] point = {0,0,0};

  public static boolean[] lineSet(String str){
    boolean[] line = new boolean[str.length()];
    for (int i = 0; i < str.length(); i++) {
      if (str.charAt(i) == '0') {
        line[i] = false;
      }
      else {
        line[i] = true;
      }
    }
    return line;
  }

  public static void moveR(){
    System.out.print("R");
    point[1]++;
    point[2] = 0;
  }
  
  public static void moveD(){
    System.out.print("D");
    point[0] += 2;
    point[2] = 1;
  }
  
  public static void moveL(){
    System.out.print("L");
    point[1]--;
    point[2] = 2;
  }
  
  public static void moveU(){
    System.out.print("U");
    point[0] -= 2;
    point[2] = 3;
  }
  
  public static void directionR(){
    if (point[0] > 0 && wall[point[0]-1][point[1]]) {
      moveU();
    }
    else if (point[1] < 4 && wall[point[0]][point[1]]) {
      moveR();
    }
    else if (point[0] < 8 && wall[point[0]+1][point[1]]) {
      moveD();
    }
    else {
      moveL();
    }
  }
  public static void directionD(){
    if (point[1] < 4 && wall[point[0]][point[1]]) {
      moveR();
    }
    else if (point[0] < 8 && wall[point[0]+1][point[1]]) {
      moveD();
    }
    else if (point[1] > 0 && wall[point[0]][point[1]-1]) {
      moveL();
    }
    else {
      moveU();
    }
  }
  public static void directionL(){
    if (point[0] < 8 && wall[point[0]+1][point[1]]) {
      moveD();
    }
    else if (point[1] > 0 && wall[point[0]][point[1]-1]) {
      moveL();
    }
    else if (point[0] > 0 && wall[point[0]-1][point[1]]) {
      moveU();
    }
    else {
      moveR();
    }
  }
  public static void directionU(){
    if (point[1] > 0 && wall[point[0]][point[1]-1]) {
      moveL();
    }
    else if (point[0] > 0 && wall[point[0]-1][point[1]]) {
      moveU();
    }
    else if (point[1] < 4 && wall[point[0]][point[1]]) {
      moveR();
    }
    else {
      moveD();
    }
  }

  public static void direction(){
    switch(point[2]) {
      case 0:
        directionR();
        break;
      case 1:
        directionD();
        break;
      case 2:
        directionL();
        break;
      case 3:
        directionU();
    }
  }

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    for (int i = 0; i < 9; i++) {
      String str = sc.next();
      wall[i] = lineSet(str);
    }
    while(true) {
      direction();
      if (point[0] == 0 && point[1] == 0) {
        break;
      }
    }
    System.out.println("");
  }
}

Measured memory_bytes: 11000
n,d = map(int, input().split())
x = [[int(i) for i in input().split()] for _ in range(n)]

ans = 0
for i in range(n):
    for j in range(i+1, n):
        dd = 0
        for m in range(d):
            dd += (x[i][m] - x[j][m]) ** 2
        dd = dd**0.5
        if dd % 1 ==0:
            ans += 1

print(ans)


Measured memory_bytes: 3188
#import sys
#import numpy as np
#import math
#import itertools
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
#from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,m=map(int,input().split())
d={i:0 for i in range(1,m+1)}
for i in range(n):
    a=list(map(int,input().split()))
    k=a[0]
    for j in range(k):
        d[a[j+1]]+=1
ans=0
for i in d.keys():
    if d[i]==n:
        ans+=1
print(ans)

Measured memory_bytes: 38256
A=[]
for _ in range(3):
    A+=map(int,input().split())

N=int(input())
for _ in range(N):
    b=int(input())
    if b in A:
        A[A.index(b)]=0

p=[
  (0,1,2),(3,4,5),(6,7,8),
  (0,3,6),(1,4,7),(2,5,8),
  (0,4,8),(2,4,6),
]

for i,j,k in p:
    if A[i]==A[j]==A[k]:
        print('Yes')
        break
else:
    print('No')


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;

const ll INF = (1LL<<60);

int main(){

    string s, t; cin >> s >> t;

    if(s.size()+1!=t.size()){
            cout << "No" << endl;
            return 0;
    }

    rep(i, s.size()){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <math.h>

using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)
static const ll maxLL = (ll)1 << 62;

ll x[50] = {};
ll y[50] = {};
int main() {
	ll N, K; cin >> N >> K;
	rep(i, 0, N) cin >> x[i] >> y[i];

	ll s = (ll)1 << 62;

	rep(i, 0, N) {
		rep(j, 0, N) {
			rep(k, 0, N) {
				rep(l, 0, N) {
					ll cnt = 0;
					rep(g, 0, N) {
						if (x[i] <= x[g] && x[g] <= x[j] && y[k] <= y[g] && y[g] <= y[l]) {
							cnt++;
						}
					}
					if (cnt >= K) {
						s = min(s, abs(x[i] - x[j]) * abs(y[k] - y[l]));
					}
				}
			}
		}
	}
	cout << s << endl;

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int ans = 0;
  int x1, x2;
  cin >> x1;
  ans += x1;
  if (N == 2) ans += x1;
  for(int i=0; i<N-1; i++){
    cin >> x2;
    if(x1>x2){
      ans += x2;
    }
    else{
      ans += x1;
    }
    x1 = x2;
  }
  cout << ans << endl;  
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	vector<int> w(n, 0); for (int i = 0; i <= n - 1; i++) cin >> w[i];
	// sort(w.begin(), w.end());
	vector<int> pref(n, w[0]); for (int i = 1; i <= n - 1; i++) pref[i] = pref[i - 1] + w[i];

	int ans = INT_MAX;
	for (int i = 0; i <= n - 1; i++) {
		ans = min(ans, abs(pref[i] - (pref[n - 1] - pref[i])));
	}

	cout << ans;

	return 0;
}

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

int main () {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  sort(A.begin(), A.end());
  if (A.at(N-1) < K) cout << "IMPOSSIBLE" << endl;
  else {
    for (int i = 0; i < N-1; i++) {
      int a = A.at(i+1), b = A.at(i), r = a%b;
      while(r != 0) {
        a = b;
        b = r;
        r = a%b;
      }
      A.at(i+1) = b;
    }
    if (K%A.at(N-1) == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
  }
}
      

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define F first
#define S second
#define p_b push_back
#define m_p make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef pair<int, int> pa;
typedef vector<pair<int,int> > vepa;
typedef map<int, int> mp;
const ll N=1e6+5;
ll arr[N],A[N],ARR[N]  ;
bool visited[N]={};
ll cnt[N]={};
bool f;
int main()
{
    int n;
    cin>>n;
    rep(i,n&&cin>>arr[i]);
    rep(i,n-1)
    {
        arr[i+1]=__gcd(arr[i],arr[i+1]);
    }
    cout<<arr[n-1];

go;
}


Measured memory_bytes: 4352
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ins(s);
    s[5] = s[13] = ' ';
    out(s);
}


Measured memory_bytes: 3612
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,k;
  cin>>n>>k;
  cout<<k*2-n<<endl;
}

Measured memory_bytes: 256
/***********************************************
 *                   _ooOoo_                   *
 *                  o8888888o                  *
 *                  88" . "88                  *
 *                  (| -_- |)                  *
 *                  O\  =  /O                  *
 *               ____/`---'\____               *
 *             .'  \\|     |//  `.             *
 *            /  \\|||  :  |||//  \            *
 *           /  _||||| -:- |||||-  \           *
 *           |   | \\\  -   * |    |           *
 *           | \_|  ''\---/''  |   |           *
 *           \  .-\__  `-`  ___/-. /           *
 *         ___`. .'  /--.--\  `. . __          *
 *      ."" '<  `.___\_<|>_/___.'  >'"".       *
 *     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     *
 *     \  \ `-.   \_ __\ /__ _/   .-` /  /     *
 *======`-.____`-.___\_____/___.-`____.-'======*
 *                   `=---='                   *
 *^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

             佛祖保佑       永无BUG

   本程序已经经过开光处理，绝无可能再产生bug
 **********************************************/
#include<algorithm>
#include <iostream>
#include  <cstdlib>
#include  <cstring>
#include   <string>
#include   <vector>
#include   <cstdio>
#include    <queue>
#include    <stack>
#include    <ctime>
#include    <cmath>
#include      <map>
#include      <set>
#define ll long long
#define INF 0x3f3f3f3f
#define db1(x) cout<<#x<<"="<<(x)<<endl
#define db2(x,y) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<endl
#define db3(x,y,z) cout<<#x<<"="<<(x)<<", "<<#y<<"="<<(y)<<", "<<#z<<"="<<(z)<<endl
using namespace std;

int main(void)
{
    #ifdef test
    freopen("in.txt","r",stdin);
    //freopen("in.txt","w",stdout);
    clock_t start=clock();
    #endif //test

    int N,mini=2e5+10,t=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++)
    {
        int cnt;
        scanf("%d",&cnt);
        if(cnt<mini)mini=cnt,t++;
    }
    printf("%d\n",t);

    #ifdef test
    clockid_t end=clock();
    double endtime=(double)(end-start)/CLOCKS_PER_SEC;
    printf("\n\n\n\n\n");
    cout<<"Total time:"<<endtime<<"s"<<endl;        //s为单位
    cout<<"Total time:"<<endtime*1000<<"ms"<<endl;    //ms为单位
    #endif //test
    return 0;
}


// ━━━━━━神兽出没━━━━━━
//      ┏┓       ┏┓
//     ┏┛┻━━━━━━━┛┻┓
//     ┃           ┃
//     ┃     ━     ┃
//     ????━????   ┃
//     ┃           ┃
//     ┃    ┻      ┃
//     ┃           ┃
//     ┗━┓       ┏━┛
//       ┃       ┃
//       ┃       ┃
//       ┃       ┗━━━┓
//       ┃           ┣┓
//       ┃           ┏┛
//       ┗┓┓┏━━━━━┳┓┏┛
//        ┃┫┫     ┃┫┫
//        ┗┻┛     ┗┻┛
//
// ━━━━━━感觉萌萌哒━━━━━━


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

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define SX(x) (x).begin(), (x).end()
typedef pair<int, int> P;
using ll =long long;

int main()
{
  string E, O;
  cin >> E >> O;
  for (int i=0; i<E.size(); i++)
  {
    cout << E[i];
    
    if (i<O.size())
      cout << O[i];
  }
  return 0;
}

Measured memory_bytes: 256
import numpy as np
n=int(input())
abc=[]
for _ in range(n):
      abc.append(list(map(int,input().split())))
dp=np.zeros((n+1,3),np.int64)
# dp[i][0]:i日目でaをとった時の最大。dp[0]=[0,0,0]。求めるのはmax(dp[n])
dp[1]=np.array(abc[0])
for i in range(2,n+1):
      dp[i][0]=abc[i-1][0]+max(dp[i-1][1],dp[i-1][2])
      dp[i][1]=abc[i-1][1]+max(dp[i-1][0],dp[i-1][2])
      dp[i][2]=abc[i-1][2]+max(dp[i-1][0],dp[i-1][1])

print(int(np.max(dp[-1])))


Measured memory_bytes: 41916
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int vis[N];
vector<int>e[N],p1,p2;
deque<int>dq;
int main()
{
	int n,m,a,b,res,k;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&a,&b);
		e[a].push_back(b);
		e[b].push_back(a);
	}
	int r=1;
	vis[r]=1;
	dq.push_back(r);
	do
	{
		res=0;
		k=dq.front();
		vis[k]=1;
		p1.push_back(k);
		for(int i=0;i<e[k].size();i++)
		{
			if(!vis[e[k][i]])
			{
				dq.push_front(e[k][i]);
				res=1;
				break;
			}
		}
	}while(res);
	do
	{
		res=0;
		k=dq.back();
		vis[k]=1;
		p2.push_back(k);
		for(int i=0;i<e[k].size();i++)
		{
			if(!vis[e[k][i]])
			{
				dq.push_back(e[k][i]);
				res=1;
				break;
			}
		}
	}while(res);
	printf("%d\n",p1.size()+p2.size()-1);
	for(int i=p1.size()-1;i>=0;i--)
		printf("%d ",p1[i]);
	for(int i=1;i<p2.size();i++)
		printf("%d ",p2[i]);
	printf("\n");
	return 0;
}
//

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

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(a,b,c);
  bool test2 = false;
  Vi MO(b);
  while(true){
    int test = a * (z+1);
    if(test%b==c) {
      test2 = true;
      break;
    }
    else MO[test%b]++;
    if(MO[test%b]==2) break;
    z++;
  }
  YES(test2);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
using Edge = pair<int, ll>;
using Graph = vector<vector<Edge> >;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}


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

	ll  d, n, r ,l ,k, ans = 0, ret = M;
	bool flag = false, flag2 = false;
	string s, t;
	/*ll a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) Yes(1);
	else Yes(0);*/
	cin >> n;
	cin >> s;
	rep(i, n) {
		if (s[i] == 'R')ans++;
	}
	Yes(ans > (n - ans));
	return 0;

}


Measured memory_bytes: 256
// TOPSIC001_0

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;


int main(){
    int N,X ; cin >> N >> X;
    vector<int> L(N+1); REP(i, N) cin >> L.at(i);

    int ans = 0;
    long sum = 0;
    for(int i = 0 ; i <= N ; i++){

        if(sum <= X)         ans++;
        sum += L.at(i);

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

LL a[7];

int main() {
	REP(i, 7)scanf("%lld", &a[i]);
	LL ret = a[1];
	LL ret1 = a[1] + (a[0] / 2) * 2 + (a[3] / 2) * 2 + (a[4] / 2) * 2;
	LL ret2 = a[1] + ((a[0] - 1) / 2) * 2 + ((a[3] - 1) / 2) * 2 + ((a[4] - 1) / 2) * 2 + 3;
	if (a[0] == 0 || a[3] == 0 || a[4] == 0)ret2 = 0;
	cout << max(ret1, ret2) << endl;
	return 0;
}

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

#define MX1 2005
#define MX2 4000005
bitset<MX2>b_set;
int a[MX1],n;

void process()
{
    b_set.reset();
    b_set.set(0);
    for(int i=0; i<n; i++)
    {
        b_set = b_set|(b_set<<a[i]);
    }
}

int main()
{
    int i,x,s=0;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
        s += a[i];
    }
    x = (s+1)>>1;
    process();
    for(i=x; i<=s; i++)
    {
        if(b_set.test(i))
        {
            printf("%d\n",i);
            exit(0);
        }
    }
    return  0;
}
/// median >= (sum+1)/2

Measured memory_bytes: 2176
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    c = [input() for _ in range(2)]

    if (c[0][0] == c[1][2]) and (c[1][0] == c[0][2]) and (c[0][1] == c[1][1]):
        print('YES')
    else:
        print('NO')


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-

def qq(limit=9):
    qq_str = ''
    for i in range(1, limit+1):
        for j in range(1, limit+1):
            qq_str += str(i) + 'x' + str(j) + '=' + str(i*j)
            if i != limit or j != limit:
                qq_str += '\n'
    return qq_str

def main():
    print(qq())

if __name__ == '__main__':
    main()

Measured memory_bytes: 7428
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
const int INF = 1001001001;
const ll MOD = 998244353;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

// ll lpow(ll a, ll b){
//   if(b==0) return 1;
//   else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
//   else return lpow(a,b-1) * a;
// }


signed main(){
	int n; cin>>n;
	cout << n*n << endl;


  return 0;
}


Measured memory_bytes: 256
a[6],x;main(i,j){for(;~j;++i)i<6?x|=1<<(scanf("%d",&j),a[i]=--j):i>10?x=i=0:printf("%d\n",x-(x&-x)&&x-7?j=a[i-5],x&2?x&1?j+1:j:j?1:2:3);exit(0);}

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

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

    long long x, y;
    cin >> x >> y;

    int cnt = 1;
    while(x * 2 <= y){
        x *= 2;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    ll x3, y3;

    if(s % (ll)1e9 == 0){
        y3 = s / (ll)1e9;
        x3 = 0;
    } else {
        y3 = s / (ll)1e9 + 1;
        x3 = (ll)1e9 - (s % (ll)1e9);
    }

    cout << 0 << " " << 0 << " " << (ll)1e9 << " " << 1 << " " << x3 << " " << y3 << endl; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
const int inf = (1LL << 60);
int dist[305][305];

signed main() {
  int N; cin >> N;
  int sum = 0;
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < N; ++j) {
      cin >> dist[i][j];
      sum += dist[i][j];
    }
  }
  sum /= 2;

  int ret = 0;
  bool ok = true, pos = false;
  for(int i = 0; i < N; ++i) {
    for(int j = i + 1; j < N; ++j) {
      pos = false;
      for(int k = 0; k < N; ++k) {
        if(k == i || k == j) continue;
        int wa = dist[i][k] + dist[k][j];
        if(wa < dist[i][j]) ok = false;
        else if (wa == dist[i][j]) {
          pos = true;
        }
      }
      if(pos) {
        sum -= dist[i][j];
      }
    }
  }
  if(ok) cout << sum << endl;
  else cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 1024