akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};



int N;
int d[110000];
using Graph = vector<vector<int>>;

int main () {
  cin >> N;
  Graph G(N+1);

  Rep(i, N-1) {
    int a, b;
    cin >> a >> b;

    G[a].push_back(b);
    G[b].push_back(a);
  }

  priority_queue<int> pq;

  Rep(i, N) {
    int c;
    cin >> c;
    pq.push(c);
  }

  queue<int> que;
  que.push(1);
  vector<bool> seen(N+1);
  seen.assign(N+1, false);


  while (!que.empty()) {
    int v = que.front();
    que.pop();
    seen[v] = true;
    int s = pq.top(); pq.pop();
    d[v] = s;

    for (int nv: G[v]) {
      if (seen[nv]) continue;

      que.push(nv);
    }
  }

  que.push(1);
  seen.assign(N+1, false);
  ll ans = 0;

  while (!que.empty()) {
    int v = que.front();
    que.pop();
    seen[v] = true;

    for (int nv: G[v]) {
      if (seen[nv]) continue;

      ans += d[nv];
      que.push(nv);
    }
  }

  cout << ans << "\n";

  rep(i, N-1) {
    cout << d[i] << " ";
  }
  cout << d[N] << "\n";

}

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

int main() {
    int k,a,b;
    cin >> k >> a >> b;
    for(int i = a;i <= b;i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i,n) for(int i=0;i<(int)(n);i++)
#define repd(i,n) for(int i=(int)(n);i>=0;i--)
#define repm(i,m) for(auto i=m.begin();i!=m.end();i++)

int main()
{
    int r;
    cin >> r;
    cout << r*r << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = [[a[i], i] for i in range(n)]
b.sort(reverse = True)
d = {}
dcnt = {}
for i in range(n):
    if not a[i] in d:
        d[a[i]] = i
        dcnt[a[i]] = 1
    else:
        dcnt[a[i]] = dcnt[a[i]] + 1
b = [[0, 0] for _ in range(len(d) + 1)]
k = 0
for i, j in d.items():
    b[k][0], b[k][1] = i, j
    k += 1
b.sort(reverse = True)
ans = [0] * n
j = b[0][1]
cnt = 0
for i in range(len(d)):
    cnt += dcnt[b[i][0]]
    j = min(j, b[i][1])
    ans[j] += (b[i][0] - b[i + 1][0]) * cnt
for i in ans:
    print(i)

Measured memory_bytes: 46172
import java.util.Scanner;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int V[] = new int[N];
        for (int i = 0; i < N; i++) {
            V[i] = s.nextInt();
        }
        int sum = 0;
        int diff = 0;
        for (int v: V) {
            diff = v - s.nextInt(); 
            if ((diff) > 0) {
                sum = sum + diff;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class Main {

    public static void main(String[] args) {

        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);

        String str1 = null;



        PrintWriter out = new PrintWriter(System.out);
        try {
            str1 = br.readLine();
            String str2[] = str1.split(" ", 0);

            int intB1 = Integer.parseInt(str2[0]);
            int intB2 = Integer.parseInt(str2[1]);

            int intCoin = 0;
            if (intB1 >= intB2) {
            	intCoin = intCoin + intB1;
            	intB1--;
            }else {
            	intCoin = intCoin + intB2;
            	intB2--;
            }

            if (intB1 >= intB2) {
            	intCoin = intCoin + intB1;
            	intB1--;
            }else {
            	intCoin = intCoin + intB2;
            	intB2--;
            }


            System.out.println(intCoin);


        } catch (IOException e) {

        }


    }
}

Measured memory_bytes: 21204
N = int(input())
B = ([int(x) for x in input().split()])
A = [0] * N

A[0] = A[1] = B[0]
for i in range(1, N-1):
    if max(A[i], A[i+1]) > B[i]:
        A[i] = A[i+1] = B[i]
    else:
        A[i+1] = B[i]
print(sum(A))


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner input = new Scanner(System.in);
    
    while (input.hasNext()) {
      int N = input.nextInt();
      int halfN = N / 2;
      int minSum = Integer.MAX_VALUE;
      
      for (int i = 1; i <= halfN; ++i) {
          minSum = Math.min(minSum, digitSum(i) + digitSum(N - i));
      }

      System.out.println(minSum);
    }
  }

  private static int digitSum (int n) {
    int digitSum = 0;
    
    while (n > 0){
      digitSum += n % 10;
      n /= 10;
    }
    
    return digitSum;
  }
}

Measured memory_bytes: 23764
N = int(input())
S = []
C = [0,0,0,0]

for n in range(N):
    S.append(input())

for n in range(N):
    if S[n] == "AC":
        C[0] += 1
    elif S[n] == "WA":
        C[1] += 1
    elif S[n] == "TLE":
        C[2] += 1
    else:
        C[3] += 1

print("AC x ",C[0])
print("WA x ",C[1])
print("TLE x ",C[2])
print("RE x ",C[3])

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

const int mod=1e9+7;

int dp[3005][3005];

signed main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

  int n;
  cin>>n;
  string s;
  cin>>s;
  s="#"+s;
  for(int i=0;i<n;i++)
  {
    dp[1][i]=1;
  }
  for(int i=1;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(s[i]=='<')
      {
          dp[i+1][0]+=dp[i][j];
          dp[i+1][0]%=mod;
          dp[i+1][j]-=dp[i][j]-mod;
          dp[i+1][j]%=mod;
      }
      else
      {
        int z=(n-i);
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j]%=mod;
        dp[i+1][z]-=dp[i][j]-mod;
        dp[i+1][z]%=mod;
      }
    }
    for(int j=1;j<n;j++)
    {
      dp[i+1][j]=(dp[i+1][j]+dp[i+1][j-1])%mod;
    }
  }
  cout<<dp[n][0];

}

Measured memory_bytes: 70656
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var nm = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var xyz = new long[nm[0]][];
        for (var i = 0; i < nm[0]; i++)
            xyz[i] = Array.ConvertAll(ReadLine().Split(' '), long.Parse);
        var res = long.MinValue;
        for (var i = 0; i < 8; i++)
        {
            var h = Enumerable.Repeat(-1, 3).ToArray();
            for (var j = 0; j < 3; j++)
                if (((i >> j) & 1) == 1)
                    h[j] = 1;
            var al = xyz.OrderByDescending(ar => Enumerable.Range(0,3).Select(v=>h[v]*ar[v]).Sum()).Take(nm[1]).ToArray();
            var sum = 0L;
            for (var j = 0; j < 3; j++)
                sum += Abs(al.Sum(ar => ar[j]));
            res = Max(res,sum);
        }
        WriteLine(res);
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 15840
n, m = map(int, input().split())
H = list(map(int, input().split()))
L = [1] * n
for _ in range(m):
    a, b = map(int, input().split())
    if H[a-1] < H[b-1]:
        L[a - 1] = 0
    elif H[a-1] > H[b-1]:
        L[b - 1] = 0
    else:
        L[a - 1] = 0
        L[b-1] = 0
print(sum(L))

Measured memory_bytes: 84936
import java.util.*;
import java.io.*;

public class Main{
	final static int MOD = 1000000007;
	final static int INF = 1000000000;

	public static void main(String[] args) throws IOException{
		NScanner sc = new NScanner(System.in);
		int n = sc.nextInt();
		//0:S 1:H 2:C 3:D
		boolean[][] card = new boolean[4][13];
		for(int i = 0; i < 4; ++i)
			Arrays.fill(card[i], false);
		for(int i = 0; i < n; ++i){
			String suit = sc.next();
			int val = sc.nextInt() - 1;
			if(suit.equals("S"))
				card[0][val] = true;
			else if(suit.equals("H"))
				card[1][val] = true;
			else if(suit.equals("C"))
				card[2][val] = true;
			else if(suit.equals("D"))
				card[3][val] = true;
		}
		
		char[] st = {'S', 'H', 'C', 'D'};
		for(int i = 0; i < 4; ++i){
			for(int j = 0; j < 13; ++j){
				if(!card[i][j])
					System.out.printf("%c %d\n", st[i], j+1);
			}
		}
		
	}

}

class NScanner{

	private BufferedReader br;
	private StringTokenizer tok;

	public NScanner(InputStream is) throws IOException{
		br = new BufferedReader(new InputStreamReader(is));
		getLine();
	}

	private void getLine() throws IOException{
		while(tok == null || !hasNext()){
			tok = new StringTokenizer(br.readLine());
		}
	}

	private boolean hasNext(){
		return tok.hasMoreTokens();
	}

	public String next() throws IOException{
		if(hasNext()){
			return tok.nextToken();
		}else{
			getLine();
			return tok.nextToken();
		}
	}

	public int nextInt() throws IOException{
		if(hasNext()){
			return Integer.parseInt(tok.nextToken());
		}else{
			getLine();
			return Integer.parseInt(tok.nextToken());
		}
	}

	public long nextLong() throws IOException{
		if(hasNext()){
			return Long.parseLong(tok.nextToken());
		}else{
			getLine();
			return Long.parseLong(tok.nextToken());
		}
	}

	public double nextDouble() throws IOException{
		if(hasNext()){
			return Double.parseDouble(tok.nextToken());
		}else{
			getLine();
			return Double.parseDouble(tok.nextToken());
		}
	}
}


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

#define ll long long int
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;


int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    ll n;
    cin>>n;

    ll ans = LONG_MAX;
    for(ll i=1; i<=sqrt(n); i++){
        if(n%i == 0){
            ll a = n/i, b = i;
            ll dist = (a-1) + (b-1);
            if(dist < ans){
                ans = dist;
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main()
{
  int n;
  string s;
  cin >> n >> s;
  vector<uint64_t> c(26, 1);
  for (int i = 0; i < n; i++) {
    c[s[i] - 'a']++;
  }
  uint64_t ans{1};
  for (int i = 0; i < 26; i++) {
    ans *= c[i];
    ans %= 1'000'000'007;
  }
  cout << ans - 1 << endl;
}


Measured memory_bytes: 512
fn main() {
    let (n, max_w) = read_tuple();
    let items = read_vec2::<u64>(n as u32);
    let mut dp: Vec<Vec<u64>> = Vec::new();
    for _ in 0..n+1 {
        let v = vec![0; max_w + 1];
        dp.push(v);
    }

    let mut max = 0;
    for i in 1..n+1 {
        for w in 0..max_w+1 {
            let cur_w = items[i-1][0];
            let cur_v = items[i-1][1];
            if w < cur_w as usize {
                dp[i][w] = dp[i-1][w];
            } else {
                dp[i][w] = std::cmp::max(dp[i-1][w], dp[i-1][w-(cur_w as usize)] + cur_v);   
            }
            chmax(&mut max, dp[i][w]);
        }
    }
    println!("{}", max);
}

fn chmax(a: &mut u64, b: u64) {
    if *a < b {
        *a = b;
    }
}

fn read_tuple() -> (usize, usize) {
    let v = read_vec::<usize>();
    (v[0], v[1])
}

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

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    let mut v2 = Vec::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).ok();
        let v = s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
        v2.push(v);
    }
    v2
}


Measured memory_bytes: 106748
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
const double EPS=1E-8;
////////////////////////////////////////

void calc(int n){
    int m=1;
    while(1){
        if(m*(m+1)/2>=n)break;
        m++;
    }
    int k=m*(m+1)/2-n;
    rep(i,1,m){
        if(i!=k)cout<<i<<endl;
    }
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);
    
    int n;cin>>n;
    calc(n);
    
    
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	s := Scan()
	fmt.Print(string(s[0]))
	fmt.Print(len(s) - 2)
	fmt.Println(string(s[len(s)-1]))
}


Measured memory_bytes: 1772
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        n: usize,
        mut ll: [isize; n]
    };
    if n < 3 {
        println!("0");
        return;
    }
    ll.sort();
    let mut count = 0;
    for i in 0..(n - 2) {
        let a = ll[i];
        for j in (i + 1)..(n - 1) {
            let b = ll[j];
            for k in (j + 1)..n {
                let c = ll[k];
                if (a == b) || (b == c) {
                    continue;
                }
                count += ((b - a < c) && (c < a + b)) as i32;
            }
        }
    }
    println!("{}", count);
}


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

int main() {
    int N;
    long long D;
    cin >> N >> D; 
    D *= D;
    long long Xi, Yi;
    int total= 0;
    while(N--) {
        cin >> Xi >> Yi;
        if(Xi*Xi + Yi*Yi <= D) {
            total++;
        }
    }
    cout << total;
    return 0;
}

Measured memory_bytes: 3512
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			m = scanner.nextInt();
			n = scanner.nextInt();
			if ((m | n) == 0)
				break;
			M = new HashMap<Pair, Integer>();
			h = 1;
			a = new int[n][m];
			pairs = new Pair[24];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < m; j++) {
					int t = scanner.nextInt();
					if (t == 0) {
						a[i][j] = -1;
					} else if (t == 1) {
						pairs[h] = new Pair(i, j);
						a[i][j] = h++;
					} else {
						pairs[0] = new Pair(i, j);
						a[i][j] = 0;
					}
				}
			System.out.println(slove(0, 1));
		}
	}

	private int slove(int cur, int bit) {
		Pair p = new Pair(cur, bit);
		if (M.containsKey(p))
			return M.get(p);
		int res = 0;
		for (int[] mo : move) {
			int y = pairs[cur].y;
			int x = pairs[cur].x;
			while (true) {
				y += mo[0];
				x += mo[1];
				if (!isOK(y, x))
					break;
				if (a[y][x] == 0)
					if (Integer.bitCount(bit) == h) {
						return res + 1;
					}
				if (a[y][x] >= 1) {
					if ((bit >> a[y][x] & 1) == 1)
						continue;
					res += slove(a[y][x], bit | 1 << a[y][x]);
					break;
				}
			}
		}
		M.put(p, res);
		return res;
	}

	private boolean isOK(int y, int x) {
		if (0 <= y && y < n && 0 <= x && x < m)
			return true;
		return false;
	}

	class Pair {
		int y, x;

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + x;
			result = prime * result + y;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Pair other = (Pair) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (x != other.x)
				return false;
			if (y != other.y)
				return false;
			return true;
		}

		public Pair(int y, int x) {
			super();
			this.y = y;
			this.x = x;
		}

		private Main getOuterType() {
			return Main.this;
		}

	}

	int m, n, h;
	Pair[] pairs;
	int[][] a;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };
	Map<Pair, Integer> M;
}

Measured memory_bytes: 159900
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]


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


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


class UnionFind:
    def __init__(self, n):
        self._parent = [i for i in range(n)]
        self._rank = [0 for _ in range(n)]
        self._group_size = [1 for _ in range(n)]
        self.num_of_groups = n

    def find(self, x):
        if self._parent[x] == x:
            return x
        px = self._parent[x]
        root = self.find(px)
        self._parent[x] = root
        return root

    def union(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self._rank[px] < self._rank[py]:
            self._parent[px] = py
            self._group_size[py] += self._group_size[px]
        else:
            self._parent[py] = px
            self._group_size[px] += self._group_size[py]
        if self._rank[px] == self._rank[py]:
            self._rank[py] += 1
        self.num_of_groups -= 1

    def is_same(self, x, y):
        return self.find(x) == self.find(y)

    def group_size(self, x):
        px = self.find(x)
        return self._group_size[px]


def main():
    N, M, K = LI()
    AB = [LI1() for _ in range(M)]
    CD = [LI1() for _ in range(K)]

    uf = UnionFind(N)

    friend = [[] for _ in range(N)]
    block = [[] for _ in range(N)]

    for (a, b) in AB:
        friend[a].append(b)
        friend[b].append(a)
        uf.union(a, b)
    for (c, d) in CD:
        block[c].append(d)
        block[d].append(c)

    for i in range(N):
        gs = uf.group_size(i)
        bc = 0
        for bi in block[i]:
            bc += int(uf.is_same(i, bi))
        # print(i, gs, fc, bc)
        print(gs - len(friend[i]) - bc - 1, end=" ")


main()


Measured memory_bytes: 95428
list1 = [int(i) for i in input().split()]
lista=[]
for i in range(1,int(list1[0])+1):
  if (int(list1[0])% int(i)==0) and  (int(list1[1])% int(i)==0): 
    lista.append(i)
c=int(list1[2])
lista.reverse()
#print(lista)
print(lista[c-1])

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

int main(){
  int a, b, k;

  cin >> a >> b >> k;

  for(int i=0;i<k;i++){
    if(a+i <= b){
      cout << a+i << endl;
    }
  }
  for(int j=k-1;j>=0;j--){
    if(b-j > a+(k-1)){
      cout << b-j << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <cstdint>
#include <cstdio>
#include <vector>
#include <string>
#include <deque>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <cstring>
#include <assert.h>
#include <chrono>
#include <random>
#include <functional>
#include <bitset>
#include <iterator>
#include <unordered_map>
#include <unordered_set>
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace std;

int par(vector<int>& a, int n)
{
  int pp = 0;
  for (int i = 0; i < n; i++) {
    int N = n - 1, K = i;
    if ((N & K) == K) pp ^= (a[i] % 2);
  }
  return pp;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    char c;
    cin >> c;
    a[i] = c - '0' - 1;
  }
  if (par(a, n)) {
    cout << "1\n";
  } else {
    if (!count(a.begin(), a.end(), 1)) {
      for (int& x : a) x /= 2;
      cout << 2 * par(a, n) << '\n';
    } else {
      cout << "0\n";
    }
  }
  return 0;
}

Measured memory_bytes: 4224
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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


int main() {
	int i, j, k;
	int N, M, K;

	cin >> N;
	int A[100000];
	ll S = 0;
	rep(i, 0, N) {
		cin >> A[i];
	}

	S +=abs( A[0]);
	rep(i, 1, N) {
		S += abs(A[i] - A[i - 1]);
	}
	S += abs(A[N - 1]);

	ll s = S;
	s += - abs( A[0]) - abs(A[1] - A[0]) + abs(A[1]);
	cout << s << endl;
	rep(i, 1, N-1) {
		s = S;
		s += -abs(A[i] - A[i-1]) - abs(A[i] - A[i+1]) + abs(A[i+1]- A[i-1]);
		cout << s << endl;
	}
	s = S;
	s += -abs(A[N-1] - A[N-2]) - abs(A[N-1]) + abs(A[N-2]);
	cout << s << endl;

	return 0;

}


Measured memory_bytes: 1664
#include<cstdio>
#include<vector>
using namespace std;

const int lim = 24*60*60;

inline int t(int h, int m, int s){
  return h*60*60 + m*60 + s;
}

int main(){
  int n;
  while(scanf("%d",&n)){
    if(n==0)break;

    vector<int> x(lim+1,0);
    for(int i=0;i<n;i++){
      int h1,m1,s1, h2,m2,s2;
      scanf("%d:%d:%d %d:%d:%d",&h1,&m1,&s1,&h2,&m2,&s2);

      x[t(h1,m1,s1)]++;
      x[t(h2,m2,s2)]--;
    }

    int ans = 0, cur = 0;
    for(int i=0;i<=lim;i++){
      cur += x[i];
      ans = max(ans, cur);
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 1368
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, a[55];

  std::cin >> N;

  for (int i = 0; i < N; i ++)
    std::cin >> a[i];

  auto pair = std::minmax_element(a, a + N);

  std::vector<std::pair<int, int>> pairs;

  if (std::abs(*pair.first) > std::abs(*pair.second)) {
    for (int i = 0; i < N; i ++)
      if (a[i] != *pair.first) {
        pairs.emplace_back(pair.first - a, i);
        
        a[i] += *pair.first;
      }

    for (int i = N - 1; i >= 1; i --) {
      pairs.emplace_back(i, i - 1);

      a[i - 1] += a[i];
    }
  }
  else {
    for (int i = 0; i < N; i ++)
      if (a[i] != *pair.second) {
        pairs.emplace_back(pair.second - a, i);
        
        a[i] += *pair.second;
      }

    for (int i = 0; i < N - 1; i ++) {
      pairs.emplace_back(i, i + 1);

      a[i + 1] += a[i];
    }
  }

  std::cout << pairs.size() << std::endl;

  for (const auto& pair : pairs)
    std::cout << pair.first + 1 << ' ' << pair.second + 1 << std::endl;

  return 0;
}


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

int main(){
  int h,w;
  cin>>h>>w;
  int d[10][10];
  rep(i,0,10){
    rep(j,0,10){
      cin>>d[i][j];
    }
  }
  rep(k,0,10){
    rep(i,0,10){
      rep(j,0,10){
        d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
      }
    }
  }
  
  int ans=0;
  rep(i,0,h){
    rep(j,0,w){
      int a;
      cin>>a;
      if(a!=-1){
        ans+=d[a][1];
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 636
import java.util.*;

public class Main {
	public static void printArray(int[] a) {
		for (int i = 0; i < a.length; i++) {
			System.out.print(a[i] + ", ");
		}
		System.out.println();
	}

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static class Triple implements Comparable<Triple> {
	// 	public int A, B, C;
	// 	Triple(int A, int B, int C) {
	// 		this.A = A;
	// 		this.B = B;
	// 		this.C = C;
	// 	}

	// 	@Override
	// 	public String toString() {
	// 		return String.format("(%d, %d, %d)", A, B, C);
	// 	}

	// 	@Override
	// 	public int compareTo(Triple o) {
	// 		int a = this.A - o.A;
	// 		if (a != 0) return a;
	// 		int b = this.B - o.B;
	// 		if (b != 0) return b;
	// 		return this.C - o.C;
	// 	}
	// }

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int N = arr.length;
		int[] cnt = new int[N];
		Arrays.fill(cnt, 1);

		for (int i = 0; i < N; i++) {
			if (cnt[i] > 0 && arr[i] == 'R') {
				int j = i;
				while (arr[j] == 'R' && arr[j+1] == 'R') {
					cnt[j + 2] += cnt[j];
					cnt[j] = 0;
					j += 2;
				}
			}
		}
		for (int i = N-1; i >= 0; i--) {
			if (cnt[i] > 0 && arr[i] == 'L') {
				int j = i;
				while (arr[j] == 'L' && arr[j-1] == 'L') {
					cnt[j - 2] += cnt[j];
					cnt[j] = 0;
					j -= 2;
				}
			}
		}
		System.out.println(joinInt(cnt));
	}

	static String joinInt(int[] a) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(' ');
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}
}


Measured memory_bytes: 27172
S = input()

S = S.replace("dream",'/*/').replace('erase','/+/')
S = [i for i in S.split('/') if i != '']
for i in range(len(S)):
    if S[i] == '*' or S[i] == '+':
        continue
    if S[i] == 'r':
        if i != 0 and S[i-1] == '+':
            continue
    elif S[i] == 'er':
        if i != 0 and S[i-1] == '*':
            continue
    print('NO')
    exit()
print('YES')
            

Measured memory_bytes: 3956
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>

using namespace std;
typedef long long ll;

int main()
{
	int N;
	cin >> N;
	vector<vector<int>> G(N, vector<int>());
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	map<int, int> done;	//V, color
	queue<pair<int, int>> q;
	q.emplace(0, 1);
	q.emplace(N-1, 2);
	while (!q.empty()) {
		int V;
		int c;
		tie(V, c) = q.front();
		q.pop();
		if (done[V] != 0)
			continue;
		done[V] = c;
		for (auto i : G[V]) {
			q.emplace(i, c);
		}
	}
	int color[2] = { 0 };
	for (const auto& i : done) {
		if (i.second == 1)
			color[0]++;
		else
			color[1]++;
	}
	cout << (color[0] > color[1] ? "Fennec" : "Snuke") << endl;
	return 0;
}


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

int main() {
	
	int k;
	cin >> k;
	cout << (k / 2) * ((k + 1) / 2) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <set>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    //MAX_H = 100
    //MAX_W = 8

    //あみだくじの全通り
    //H = 2, W = 3のとき、 3^2 = 9通り
    //W = 3のとき、 1-2 or 2-3 or 繋がない の3通り
    //縦棒1から始まるというルールがある
    //9通りの行き先は、1,2,1,2,1,1,3,2,1
    // 
    //線があったとき、なかったときでdpしていけばよい?
    //dp[i][k]: 高さiで位置Kに到達する個数
    //もらうdp

    ll dp[H+1][W];
    for(int i = 0; i < H+1; ++i)
    {
        for(int j = 0; j < W; ++j)
        {
            dp[i][j] = 0;
        }
    }

    dp[0][0] = 1;

    for(int i = 1; i < H+1; ++i)
    {
        //bit 1 -> 0と1につながっている
        for(int bit = 0; bit < (1 << (W-1)); ++bit)
        {
            bool ok = true;
            //線分がつながっていたらout
            for(int x = 0; x < W - 2; ++x)
            {
                if((bit & (1 << x)) && (bit & (1 << (x + 1))))
                {
                    ok = false;
                }
            }
            if(ok)
            {
                for(int j = 0; j < W; ++j)
                {
                    if(bit & (1 << j))
                    {
                        dp[i][j] += dp[i-1][j+1];
                    }
                    else if(j != 0 && (bit & (1 << (j-1))))
                    {
                        dp[i][j] += dp[i-1][j-1];
                    }
                    else
                    {
                        dp[i][j] += dp[i-1][j];
                    }
                    dp[i][j] %= MOD;
                }
            }

        }

        //線分 0-1,1-2,2-3,3-4...
        //線分 0-1をはやしたときにもdp[2]に追加する

        //線分は、横軸に対して、max(1, W-2)本追加できること(つながっていなければok)
    }

    ll res;
    res = dp[H][K-1];

    //よって、最大 8^100 -> 64bitに収まらない

    //特性として、元々、Kに行く予定のあみだくじ
    //に対して、位置 H の線を Kにつなぐと、Kに行かなくなる

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
from collections import defaultdict
import math
import re

def main():
    #H, W = map(int, input().split())
    N = int(input().strip())
    P = list(map(int, input().split()))

    cnt = 0
    for i in range(1, N-1):
        if (P[i] < P[i+1] and P[i] > P[i-1])\
            or (P[i] < P[i-1] and P[i] > P[i+1]):
            cnt += 1
    print(cnt)



if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    
    #0から他の頂点へ
    def BellmanFord(N, M, edges):
        #N頂点，M辺，edgesのリスト
        inf=10**20
        d = [inf] * N
        d[0] = 0

        for i in range(N-1):
            for (u, v, c) in edges:
                if to[u] and to[v] and rto[u] and rto[v]:
                    if d[u] + c < d[v]:
                        d[v] = d[u] + c

        
        #何処かの最短距離がまだ更新されるか確認
        for (u, v, c) in edges:
            if to[u] and to[v] and rto[u] and rto[v]:
                if d[u] + c < d[v]:
                    return None#負の閉路
                
        return d[N-1]
    
    N,M,P=MI()
    edges=[]
    adj1=[[]for _ in range(N)]
    adj2=[[]for _ in range(N)]
    for _ in range(M):
        a,b,c=MI()
        a-=1
        b-=1
        c-=P
        edges.append([a,b,-1*c])
        adj1[a].append(b)
        adj2[b].append(a)
        
    ################
    #BFSで使う点を選択．
    import queue
    q=queue.Queue()
    
    to=[0]*N
    to[0]=1
    rto=[0]*N
    rto[-1]=1
    
    q.put(0)
    while not q.empty():
        v=q.get()
        for nv in adj1[v]:
            if to[nv]==0:
                to[nv]=1
                q.put(nv)
                
    q.put(N-1)
    while not q.empty():
        v=q.get()
        for nv in adj2[v]:
            if rto[nv]==0:
                rto[nv]=1
                q.put(nv)
        
    
    ################
    
    ans=BellmanFord(N,M,edges)
    
    if ans==None:
        print(-1)
    elif ans>=10**10:
        print(-1)
    else:
        print(max(-1*ans,0))
    
        

main()


Measured memory_bytes: 62676
a = int(input())
ar = list(map(int,input().split(" ")))
br = []
while True:
    b = len(ar)
    s = "N"
    for i in range(b-1,-1,-1):
        if ar[i] == i+1:
            s = "Y"
            br.append(ar[i])
            del ar[i]
            break
    if s == "N":
        print(-1)
        exit()
    if len(ar) == 0:
        break
for i in range(a-1,-1,-1):
    print(br[i])

Measured memory_bytes: 3064
k = int(input())
a = list(map(int, input().split()))
l, r = 0, 10 ** 15
while r - l > 1:
    m = (l + r) // 2
    t = m
    for x in a:
        m = m // x * x
    if m <= 2:
        l = t
    else:
        r = t
l2, r2 = 0, 10 ** 15
while r2 - l2 > 1:
    m = (l2 + r2) // 2
    t = m
    for x in a:
        m = m // x * x
    if m < 2:
        l2 = t
    else:
        r2 = t
if l < r2:
    print(-1)
else:
    print(r2, l)


Measured memory_bytes: 63856
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;

#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

typedef long long ll;

int main(){
    ll H, W;
    cin >> H >> W;
    if(W % 3 == 0 || H % 3 == 0){
        cout << 0 << endl;
        return 0;
    }
    ll a, b, c;
    ll MAX, MIN;
    ll ans = pow(10, 15);
    FOR(h,1,H){
        a = W * h;
        b = (W/2) * (H - h);
        c = ((W+1)/2) * (H - h);
        MAX = max(a, max(b, c));
        MIN = min(a, min(b, c));
        ans = min(ans, MAX - MIN);
        b = (H-h)/2 * W;
        c = (H-h+1)/2 * W;
        MAX = max(a, max(b, c));
        MIN = min(a, min(b, c));
        ans = min(ans, MAX - MIN);
    }

    FOR(w,1,W){
        a = H * w;
        b = (H/2) * (W - w);
        c = ((H+1)/2) * (W - w);
        MAX = max(a, max(b, c));
        MIN = min(a, min(b, c));
        ans = min(ans, MAX - MIN);
        b = (W-w)/2 * H;
        c = (W-w+1)/2 * H;
        MAX = max(a, max(b, c));
        MIN = min(a, min(b, c));
        ans = min(ans, MAX - MIN);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;
using MIte = multimap<long, long, greater<long> >::iterator;

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

	//
	int A, B;
	cin >> A >> B;

	if ((A * B) % 2 == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n,m,c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for _ in range(n):
    List = list(map(int, input().split()))
    p = c
    for i in range(m):
        p += List[i] * b[i]
    if p > 0:
        count += 1
print(count)


Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
const int N=2e3+5;
int a[N];
int min(int a,int b){
if(a<b)return a;
else return b; }
int main() {
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++) {
        for(int j=i+1;j<=n;j++) {
            int t=min(j-i,abs(i-x)+abs(j-y)+1);
            a[t]++;
        }
    }
    for(int i=1;i<n;i++) {
        cout<<a[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include <random>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int a,b;
  scanf("%d%d",&a,&b);
  if (a == b) {
    cout<<0<<endl;
    return 0;
  }
  if (abs(a) == abs(b)) {
    cout<<1<<endl;
    return 0;
  }
  if (abs(a) < abs(b)) {
    int ans = abs(b)-abs(a);
    if (a < 0) ans++;
    if (b < 0) ans++;
    cout<<ans<<endl;
    return 0;
  } else {
    int ans = abs(a)-abs(b);
    if (a > 0) ans++;
    if (b > 0) ans++;
    cout<<ans<<endl;
    return 0;
  }
  return 0;
}































Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  ll N,K;
  cin>>N>>K;
  
  vector<ll>t(N);
  vector<ll>date(N);
  date[0]=0;
  
  rep(i,N){
    cin>>t[i];
    
    if(i>0){
      date[i]=t[i]-t[i-1];
    }
    
  }
  ll sub=0;
  for(ll i=1;i<N;i++){
    if(date[i]<K){
      sub+=(K-date[i]);
    }
  }
  
  cout<<K*N-sub<<endl;
}

    

  


Measured memory_bytes: 3328
#include<stdio.h>
int main()
{
	int tc;
	scanf("%d",&tc);
	char input[105];
	scanf("%s",input);
	int mid = tc/2;
	int flag = 1;
	if(tc % 2 == 1) flag = 0;
	for(int i = 0;i<mid;i++)
	{
		if(input[i] != input[mid+i])
		{
			flag = 0;
		}		
	}
	if(flag == 0) printf("No\n");
	else{
		printf("Yes\n");
	}
}

Measured memory_bytes: 2080
//#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
// 293206GT
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <unordered_set>
#include <stack>
#include <string>
#include<algorithm>
#include <random>
#include <bitset>
#include <chrono>

typedef long long ll;

using namespace std;
#define put(a) cout << (a) << '\n'
#define sqr(x) (x) * (x)
typedef pair<ll, ll> pii;
typedef long double ld;

typedef pair<ld, ld> pld;
#define rep(x, y, a) for (int x = (y); x < (int)(a); ++x)
#define all(a) a.begin(), a.end()
#define chkmax(a, b) a = max(a, (b))
#define chkmin(a, b) a = min(a, (b))
#define prev asasdasd
#define next aasdasda
#define left asdasdasdasd
#define right asnabsdkasdl
#define rank asdasdknlasd
#define move asdasdas

typedef vector<ll> vi;
typedef vector<pii> vpii;
namespace IO {
    template<class A, class B>
    ostream &operator<<(ostream &out, pair<A, B> &a) {
        out << a.first << " " << a.second;
        return out;
    }

    template<class A, class B>
    ostream &operator<<(ostream &out, vector<pair<A, B>> &a) {
        for (pair<A, B> x: a)
            out << x.first << " " << x.second << '\n';
    }

    template<class A>
    ostream &operator<<(ostream &out, vector<A> &a) {
        for (A x: a) out << x << ' ';
        return out;
    }

    template<class A, class B>
    istream &operator>>(istream &in, pair<A, B> &a) {
        in >> a.first >> a.second;
        return in;
    }

    template<class A>
    istream &operator>>(istream &in, vector<A> &a) {
        for (A &x: a) in >> x;
        return in;
    }
}
using namespace IO;
#define int ll

void solve() {
    string s;
    cin >> s;
    if (s == "ABC") put("ARC");
    else put("ABC");
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.precision(30);
//    freopen("input.txt", "r", stdin);
    int q = 1;
//    cin >> q;
    while (q--) solve();
}



Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

// bit calculation[how many "1"] (= __builtin_popcount())
int bit_count(int n) {
	int cnt = 0;
	while (n > 0) {
		if (n % 2 == 1)cnt++;
		n /= 2;
	}
	return cnt;
}
template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;
 
	UnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}
 
	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}
 
	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}
 
	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	}
 
	bool same(int x, int y) {
		return root(x) == root(y);
	}
 
	bool merge(int x, int y, Abel w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}
 
	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

int main() {
    int n, m;
    cin>> n >> m;
    UnionFind<int> UF(n);
    rep(i, m){
        int l, r, d;
        cin >> l >> r >> d;
        l--; r--;
        if(UF.same(l, r) && UF.diff(l, r) != d){
            cout << "No" << endl;
            return 0;
        }
        else{
            UF.merge(l, r, d);
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1536
n = gets. to_i
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)
plus = 0
sum = 0
n.times do |i|
  if plus - a[i] > 0
    sum += a[i]
    plus = b[i]
  else
    sum += plus
    a[i] -= [plus,a[i]].min
    if b[i] - a[i] > 0
      sum += a[i]
      plus = b[i] - a[i]
    else
      sum += b[i]
      plus = 0
   end
  end
end
sum += [a[-1],plus].min

puts sum

Measured memory_bytes: 19596
import Foundation

let input = readLine()!

let learge = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
let small = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in 0...25 {
    if input == learge[i] {
        print("A")
    }
    if input == small[i] {
        print("a")
    }
}

Measured memory_bytes: 12904
#include<bits/stdc++.h>
using namespace std;
#define BOOST ios_base :: sync_with_stdio(false), cin.tie(NULL), cout.tie(0)
#define fo(i,a,n) for(int i=a;i<n;i++)
#define fc(i,a,n,c) for(int i=a;i<n;i+=c)
#define fi(i,n,a) for(int i=n-1;i>=a;i--)
#define in cin>>
#define out cout<<
#define ll long long
#define el <<"\n"
#define es <<" "

int main(){
  BOOST;
  long int a,b;
  in a>>b;
  if(a>9)  out b;
  else out 100*(10-a)+b;
  return 0;
}

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

using namespace std;
int n;
int matriz [100009][8];
int dp[10000009][8];

int pd (int i, int j){
if (i==n+1){return 0;}

if (dp[i][j]!=-1){return dp[i][j];}

int nano = 0;

for (int x=1;x<=3; x++){

if (x!=j){
  nano= max(nano,pd(i+1,x)+matriz[i][x]);}
 }




return dp[i][j]=nano;


}



int main(){

cin>>n;
for (int i=1;i<=n;i++){
    for(int j=1;j<=3;j++){
        cin>>matriz[i][j];
    }
}
memset(dp,-1,sizeof(dp));

cout<<pd(1,0);

return 0;
}


Measured memory_bytes: 322176
#include <stdio.h>

int fibonacci(int);

int F[44];
int n;

int main() {

  scanf("%d", &n);

  printf("%d\n", fibonacci(n));

  return 0;
}

int fibonacci(int n){
  int i;

  F[0]=1;
  F[1]=1;
  for(i=2;i<n+1;i++) F[i] = F[i-1]+F[i-2];

  return F[n];
}

Measured memory_bytes: 596