akhauriyash/Code-Regression huggingface dataset:
fun main(args: Array<String>) {
    abc075c()
}

@Suppress("unused")
private class UnionFind(vSize: Int) {
    private val parent: IntArray = IntArray(vSize) { it }
    private val size: IntArray = IntArray(vSize) { 1 }

    fun root(x: Int): Int {
        if (x == parent[x]) return x

        val xr = root(parent[x])
        parent[x] = xr
        return xr
    }

    fun unite(x: Int, y: Int) {
        val xr = root(x)
        val yr = root(y)
        if (xr == yr) return

        if (size[xr] > size[yr]) {
            size[xr] += size[yr]
            parent[yr] = xr
        } else {
            size[yr] += size[xr]
            parent[xr] = yr
        }
    }

    fun isSame(x: Int, y: Int): Boolean = root(x) == root(y)

    fun size(x: Int): Int = size[root(x)]
}

fun abc075c() {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val edges = (1..m)
        .map { readLine()!!.split(' ').map { it.toInt() - 1 }.let { Pair(it[0], it[1]) } }

    var answer = 0

    for (i in 0 until m) {
        val uf = UnionFind(n)
        for (i2 in 0 until m) {
            if (i2 == i) continue
            uf.unite(edges[i2].first, edges[i2].second)
        }

        if (uf.size(0) < n) answer++
    }

    println(answer)
}


Measured memory_bytes: 38200
#include<stdio.h>

int main()
{
	int A,B,C;
	scanf("%d %d %d", &A, &B, &C);
	
	if(A == B && B != C){
		printf ("Yes\n");
	}
	else if(A != B && A == C){
		printf ("Yes\n");
	}
	else if(B == C && A != C){
		printf ("Yes\n");
	}
	else{
		printf ("No\n");
	}
return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int func(const void *a,const void *b){
	if(*((char *)a) > *((char *)b)){
		return -1;
	}else if(*((char *)a) == (*(char *)b)){
		return 0;
	}else{
		return 1;
	}
}

int func2(const void *a,const void *b){
	if(*((char *)a) > *((char *)b)){
		return 1;
	}else if(*((char *)a) == (*(char *)b)){
		return 0;
	}else{
		return -1;
	}
}

int main(){
	int count=0;
	char S[101],T[101];
	scanf("%s",S);
	scanf("%s",T);
	int N=strlen(S);
	int M = strlen(T);
	qsort((void *)S,N,sizeof(char),func2);
	qsort((void *)T,M,sizeof(char),func);
	int check=strcmp(S,T);
	if(check<0){
		printf("Yes\n");
	}else{
		printf("No\n");
	}	
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int p = sc.nextInt();
		int q = sc.nextInt();
		int r = sc.nextInt();

		if (p < q)
			System.out.println(Math.min(q, r) + p);
		else
			System.out.println(Math.min(p, r) + q);
	}

}


Measured memory_bytes: 22868
import java.io.*
import java.util.*

fun solve(N: Int, xy: Array<MutableList<Pair<Int, Int>>>) {
    fun isConsistent(flag: List<Int>): Boolean {
        // flag=1の人たちの証言が整合するか
        for (honest in flag.withIndex().filter{ it.value == 1 }.map{ it.index }) {
            for (statement in xy[honest]) {
                if (flag[statement.first - 1] != statement.second) return false
            }
        }
        return true
    }
    // println(xy.toList())
    // bit all search
    var ans = 0
    for (i in 0 until (1 shl N)) {
        val flags = (0 until N).map { (i shr it) and 1 }
        if (flags.sum() <= ans) continue
        if (isConsistent(flags)) { ans = flags.sum() }
    }
    println(ans)
    return
}

fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val xy = Array(N) { mutableListOf<Pair<Int, Int>>() }
    for (i in 0 until N) {
        val A = sc.next().toInt()
        repeat(A){
            val x = sc.next().toInt()
            val y = sc.next().toInt()
            xy[i].add(x to y)
        }
    }
    solve(N, xy)
}


Measured memory_bytes: 51460
import java.io.IOException;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) throws IOException {
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int y = sc.nextInt();
    int z = sc.nextInt();
    int answer = (x-z) / (y+z);
    System.out.println(answer);
    }
  }


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;


int main(){
	ll n,a,b,c,d;
	cin >> n >> a >> b >> c >> d;
	n--;
	for(int i=0; i<=n; i++){
		ll from = (-d*i+c*(n-i));
		ll to = (-c*i+d*(n-i));
		if(from<=b-a && to>=b-a){
			return 0*puts("YES");
		}
	}
	puts("NO");

    return 0;
}


Measured memory_bytes: 256
from itertools import product as p
s=list(input())
*t,=p(["+",""],repeat=len(s)-1)
v=0

for i in t:
  b=""
  for j in range(2*len(s)-1):
    if j%2:
      b+=i[j//2]
    else:
      b+=s[j//2]
  v+=eval(b)

print(v)

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

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

	int height[n];
	int pd[n];

	for (int i = 0; i < n; i++) {
		cin >> height[i];		
	}

	for (int i = 0; i < n; i++) {
		pd[i] = 1e9 + 10;
	}
	pd[0] = 0;

	for (int i = 1; i < n; i++) {
		for (int j = i - 2; j < i; j++) {
			if (j >= 0)
				pd[i] = min(pd[i], pd[j] + abs(height[j] - height[i]));
		}
	}

	cout << pd[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using intpair=pair<int,int>;
using llpair=pair<ll,ll>;
using llvec=vector<ll>;
using llmat=vector<vector<ll>>;
#define PI 3.141592653589793
#define llmattp(name,a,b,num) name(a,vector<ll>(b,num))
#define INTINF 1<<30
#define LLINF 1LL<<60
#define ABS(x) ( (x)>0 ? (x) : -(x) )
#define gsort(vbeg,vend) sort(vbeg,vend,greater<>())

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

ll gcd(ll a, ll b) { //最大公約数
	if(a==0||b==0) return 0;
	if(a<b) swap(a,b);
	ll tmp = a%b;
	while(tmp!=0) {
		a = b;
		b = tmp;
		tmp = a%b;
	}
	return b;
}

ll factorial(ll x) { //階乗
	ll f=1;
	for(ll i=2; i<x; i++) {
		f*=i;
	}
	return f;
}

ll nPr(ll n, ll r) {
	ll result=1;
	for(ll i=r+1; i<=n; i++) result*=i;
	return result;
}

ll nCr(ll n, ll r) {
	if (n == r) { return 1; }
	if (r > n) { return 0; }

	if (r > n / 2) { r = n - r; }

	if (n == 0) { return 0; }
	if (r == 0) { return 1; }
	if (r == 1) { return n; }

	double result = 1;
	for (double i = 1; i <= r; i++) {
		result *= (n - i + 1) / i;
	}

	return (ll)result;
}

ll GreaterBinarySearch(ll *array, ll key, ll max, ll min) { //にぶたんgreater
	if(array[max]<array[min]) {
		return NULL;
	} else {
		ll mid = max + (min-max)/2;
		if(array[mid]<key) {
			return GreaterBinarySearch(array,key,max,mid-1);
		} if(array[mid]>key) {
			return GreaterBinarySearch(array,key,mid+1,min);
		} else {
			return mid;
		}
	}
}

int DigitNum(ll n) { //桁数
	int digit=0;
	ll wari=1LL;
	while(n/wari) {
		digit++;
		wari*=10;
	}
	return digit;
}

bool IsPrime(ll num) { //素数判定
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

	double sqrtNum = sqrt(num);
	for (ll i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// 素数ではない
			return false;
		}
	}

	// 素数である
	return true;
}

vector<ll> Divisor(ll x) { // 約数列挙
	vector<ll> result;
	ll i=1LL;
	for( ; i*i<x; i++) {
		if(x%i) continue;
		result.push_back(i);
		result.push_back(x/i);
	}
	if(i*i==x&&x%i==0)
		result.push_back(i);
	
	sort(result.begin(),result.end());
	return result;
}

vector<llpair> PrimeFact(ll x) { // 素因数分解 {素因数,指数}
	vector<llpair> result;
	ll ex=0LL;
	if(x%2==0) {
		while(x%2==0) {
			x/=2;
			ex++;
		}
		result.push_back({2,ex});
	}

	for(ll i=3LL; i*i<=x; i+=2) {
		if(x%i) continue;

		ex=0LL;
		while(x%i==0) {
			x/=i;
			ex++;
		}
		result.push_back({i,ex});
	}

	if(x!=1) result.push_back({x,1});

	return result;
}

bool Palind(string s) { //回文判定
	return s == string(s.rbegin(), s.rend());
}


int main() {
	ll N; cin>>N;
	ll result=0LL;
	if(N%2) {
		cout<<0<<endl;
		return 0;
	}

	for(ll wari=10LL; N>=wari; wari*=5) {
		result+=N/wari;
	}

	cout<<result<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

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

  rep(i,10){
    rep(j,10){
      if(i*j == n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3652
using System;
using System.Linq;

namespace MinPro2019D
{
    public class Program
    {
        static void Main()
        {
            var L = int.Parse(Console.ReadLine());
            var dp = new long[5];

            for (var i = 0; i < L; i++)
            {
                var A = int.Parse(Console.ReadLine());

                for (var t = 1; t < 5; t++)
                {
                    dp[t] = Math.Min(dp[t - 1], dp[t]);
                }

                for (var t = 0; t < 5; t++)
                {
                    if (Math.Abs(t - 2) == 0) dp[t] += (A % 2) ^ 1;
                    if (Math.Abs(t - 2) == 1) dp[t] += (A % 2) + (A == 0 ? 2 : 0);
                    if (Math.Abs(t - 2) == 2) dp[t] += A;
                }
            }

            Console.WriteLine(dp.Min());
        }
    }
}

Measured memory_bytes: 17360
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
using namespace std;
using Graph = vector<vector<int>>;

#define INF (1 << 21);
typedef long long ll;


int main(){
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  ll A[1000], B[1000], C[1000];
  vector<ll>x;
  vector<ll>y;
  for(int i = 0;i < X;++i)
    cin >> A[i];
  for(int i = 0;i < Y;++i)
    cin >> B[i];
  for(int i = 0;i < Z;++i)
    cin >> C[i];
  sort(A, A + X, greater<>());sort(B, B + Y, greater<>());sort(C, C + Z, greater<>());
  for(int i = 0;i < X;++i){
    for(int j = 0;j < Y;++j){
      x.push_back(A[i] + B[j]);
    }
  }
  sort(x.begin(), x.end(), greater<>());

  for(int i = 0;i < K && i < X*Y;++i){
    for(int j = 0;j < Z;++j){
      y.push_back(x[i] + C[j]);
    }
  }
  sort(y.begin(), y.end(), greater<>());
  for(int i = 0;i < K;++i)
    cout << y[i] << endl;
}


Measured memory_bytes: 43108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

double d, e;

int main()
{
    while (cin >> d >> e)
    {
        if (d == 0 && e == 0)
            return 0;
        double dis = inf, ans = inf;
        for (double i = 0; i <= d; i++)
        {
            dis = sqrt(i * i + (d - i) * (d - i));
            ans = min(ans, abs(dis - e));
        }
        printf("%lf\n", ans);
    }
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

int main(){
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  vector<int> c;
  while(!a.empty()){
    int asz=a.size();
    rep(rei,asz){
      int i=asz-1-rei;
      if(i==0&&a[i]!=i+1){
        cout<<-1<<endl;
        exit(0);
      }
      if(a[i]==i+1){
        c.push_back(a[i]);
        a.erase(a.begin()+i);
        break;
      }
    }
  }
  rep(i,c.size())cout<<c[(int)c.size()-1-i]<<endl;
}

        





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

int isSymmetric(char *s,int n){
  int i,j;
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(s[i*n+j]!=s[j*n+i]) return 0;
    }
  }
  return 1;
}

void run(void){
  int n;
  scanf("%d",&n);
  char *s=(char *)calloc(n*n+1,sizeof(char));
  int i,j,k;
  for(i=0;i<n;i++) scanf("%s",s+i*n);
  int ans=0;
  for(i=0;i<n;i++){
    if(isSymmetric(s,n)){
      ans+=n;
    }
    for(j=0;j<n;j++){
      char c=s[j*n];
      for(k=1;k<n;k++) s[j*n+k-1]=s[j*n+k];
      s[j*n+n-1]=c;
    }
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

from bisect import bisect_right

N,W = LI()
w,v = LIR(N,2)

w_list = []
for i in range(N+1):
    for j in range(i*w[0],i*(w[0]+3)+1):
        w_list.append(j)
w_list = sorted(list(set(w_list)))
M = len(w_list)

d = {}
temp = 0
for wl in w_list:
    d[temp] = wl
    temp += 1

dp = [[0]*M for _ in range(N)]
for i in range(N):
    for j in range(M):
        dp[i][j] = dp[i-1][j]
        x = d[j]-w[i]
        if x >= 0:
            p = bisect_right(w_list,x)
            dp[i][j] = max(dp[i][j], dp[i-1][p-1]+v[i])

p = bisect_right(w_list,W)
print(dp[N-1][p-1])

Measured memory_bytes: 60120
import java.awt.Point;
import java.io.FileInputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	static String ango;
	static ArrayList<String> kouho;
	static int kouhonum;
	
	static char[] buf;
	static char[] tmp = {'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'};
	
	private static void check(char[] text)
	{
		for(int j = 0;j < ango.length();j++) buf[j] = text[j];
		
		for(int i = 1;i < 26;i++)
		{
			for(int j = 0;j < ango.length();j++)
			{
				if(buf[j] == tmp[i])
				{
					buf[j] = tmp[i-1];
					break;
				}
			}
		}
		
		String making = String.valueOf(buf);
		if(ango.equals(making))
		{
			if(kouhonum >= 10)
			{
				kouho.set(5, kouho.get(6));
				kouho.set(6, kouho.get(7));
				kouho.set(7, kouho.get(8));
				kouho.set(8, kouho.get(9));
				kouho.set(9, String.valueOf(text));
			}
			else
			{
				kouho.add(String.valueOf(text));
			}
			kouhonum++;
		}
	}
	
	private static void dfs(char[] text, int num)
	{
		if(num == ango.length())
		{
			check(text);
		}
		else
		{
			char c = ango.charAt(num);
			
			text[num] = c;
			dfs(text, num+1);
			
			if(c != 'z')
			{
				text[num] = (char)((int)c + 1);
				dfs(text, num+1);
			}
		}
	}
	
	private static void start()
	{
		kouho = new ArrayList<String>();
		char[] text = new char[ango.length()];
		buf = new char[ango.length()];
		kouhonum = 0;
		dfs(text, 0);
		
		System.out.println(kouhonum);
		for(String s : kouho)
		{
			System.out.println(s);
		}
	}
	
	public static void main(String[] args)
	{
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			ango = sca.next();
			
			if(ango.equals("#")) break;
			
			start();
		}
	}
}

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

#define ll              long long
#define pb              push_back
#define ff              first
#define ss              second
#define mp              make_pair

#define scan(a)         scanf("%d", &a)
#define scanl(a)        scanf("%lld", &a)
#define scand(a)        scanf("%lf", &a)
#define scan2(a, b)     scanf("%d %d", &a, &b)
#define scanl2(a, b)    scanf("%lld %lld", &a, &b)
#define scand2(a, b)    scanf("%lf %lf", &a, &b)

#define yes             cout << "yes\n"
#define no              cout << "no\n"
#define Case(i)         cout << "Case " << int(i) << ": "

#define lop(n)          for(int i = 0; i < n; i++)
#define lopj(n)         for(int j = 0; j < n; j++)
#define lopr(a, n)      for(int k = a; k < n; k++)
#define lrev(n, a)      for(int i = n; i >= a; i--)

#define all(x)          x.begin(), x.end()
#define mem(a, b)       memset(a, b, sizeof(a))

#define vin             vector <int>
#define vll             vector <ll>
#define vst             vector <string>
#define pll             pair <ll, ll>
#define pss             pair <string, string>
#define vpll            vector <pll>

#define fread           freopen("input.txt", "r", stdin)
#define fwrite          freopen("output.txt", "w", stdout)
#define fastio          ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define mod             1000000007
#define PI              acos(-1.0)
#define inf             999999999999


using namespace std;


int main()
{
    fastio;

    ll tt, x, y, c = 0;
    double n, d;

    cin >> tt >> n;

    while(tt--)
    {
        cin >> x >> y;

        d = sqrt((x * x) + (y * y));

        if(d <= n)
            c++;


    }

    cout << c << '\n';



    return 0;
}



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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ss = Console.ReadLine().Split();
            var A = int.Parse(ss[0]);
            var B = int.Parse(ss[1]);
            var C = int.Parse(ss[2]);

            if (A == B)
                Console.WriteLine(C);
            else if (A == C)
                Console.WriteLine(B);
            else
                Console.WriteLine(A);
        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <vector>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
const long long INF = 1LL<<60;
const int MAX = 5100;

int N;
vector<long long> A;
vector<vector<int> > G;

int num[MAX]; // v の部分木に何個の頂点が含まれるか
long long dp[MAX][MAX][2]; // vの部分木、vを含めず何個か、(全部正かどうか)
long long sdp[MAX][2]; // 頂点 v の子ノード ch たちに足してナップサック

void rec(int v, int p) {
    num[v] = 1;
    for (auto ch : G[v]) {
        if (ch == p) continue;
        rec(ch, v);
        num[v] += num[ch];
    }
    
    for (int j = 0; j <= num[v]; ++j) sdp[j][0] = sdp[j][1] = INF;
    
    sdp[0][0] = A[v];
    if (A[v] > 0) sdp[0][1] = A[v];
    
    int curnum = 0; // 現在までに見た部分木のノード数の和
    for (auto ch : G[v]) {
        if (ch == p) continue;
        for (int j = curnum; j >= 0; --j) {
            long long tmp0 = sdp[j][0], tmp1 = sdp[j][1];
            sdp[j][0] = sdp[j][1] = INF;
            for (int k = 0; k <= num[ch]; ++k) {
                chmin(sdp[j+k][0], tmp0 + dp[ch][k][0]);
                if (dp[ch][k][0] < 0 || dp[ch][k][1] < INF/2) chmin(sdp[j+k+1][0], tmp0);
                if (A[v] > 0) {
                    chmin(sdp[j+k][1], tmp1 + dp[ch][k][1]);
                    if (dp[ch][k][0] < 0 || dp[ch][k][1] < INF/2) chmin(sdp[j+k+1][1], tmp1);
                }
            }
        }
        curnum += num[ch];
    }
    for (int j = 0; j <= num[v]; ++j) {
        dp[v][j][0] = sdp[j][0];
        dp[v][j][1] = sdp[j][1];
        
        //cout << v << ", " << j << ": " << make_pair(dp[v][j][0], dp[v][j][1]) << endl;
    }
}

int main() {
    while (cin >> N) {
        A.resize(N);
        for (int i = 0; i < N; ++i) cin >> A[i];
        G.assign(N, vector<int>());
        for (int i = 0; i < N-1; ++i) {
            int u, v; cin >> u >> v; --u, --v;
            G[u].push_back(v);
            G[v].push_back(u);
        }
        for (int i = 0; i < MAX; ++i) for (int j = 0; j < MAX; ++j)
            dp[i][j][0] = dp[i][j][1] = INF;
        rec(0, -1);
        int res = N;
        for (int i = 0; i <= N; ++i) {
            if (dp[0][i][0] < 0) chmin(res, i);
            if (dp[0][i][1] < INF/2) chmin(res, i);
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 407552
#include<bits/stdc++.h>
using namespace std;
int main () {
  int H, W, K;
  cin >> H >> W >> K;
  char choco[11][1001];
  for (int i = 1; i <= H; i ++) {
    for (int j = 1; j <= W; j ++) {
      cin >> choco[i][j];
    }
  }
  int numb[11][1001];
  for (int i = 0; i <= W; i ++) numb[0][i] = 0;
  for (int i = 0; i <= H; i ++) numb[i][0] = 0;
  for (int i = 1; i <= H; i ++) {
    for (int j = 1; j <= W; j ++) {
      numb[i][j] = numb[i][j - 1];
      if (choco[i][j] == '1') {
        numb[i][j] ++;
      }
    }
  }
/*  for(int i = 0; i <= H; i ++) {
    for (int j = 0; j <= W; j ++) {
      cout << setw(4) << numb[i][j];
    }
    cout << endl;
  }
  cout << endl;*/
  int sum[11][1001];
  for (int i = 0; i <= H; i ++) {
    for (int j = 0; j <= W; j ++) {
      sum[i][j] = 0;
    }
  }
  for (int i = 1; i <= W; i ++) {
    for (int j = 1; j <= H; j ++) {
      sum[j][i] = sum[j - 1][i] + numb[j][i];
    }
  }
 /* for(int i = 0; i <= H; i ++) {
    for (int j = 0; j <= W; j ++) {
      cout << setw(4) << sum[i][j];
    }
    cout<< endl;
  }*/
  int cut[11];
  int si;
  int ans = 1e9 + 3;
  for (int i = 0; i < 1 << (H - 1); i ++) {
    cut[0] = 0;
    int i_ = i;
    si = 1;
    for (int j = 1; j <= H - 1; j ++) {
      if (i_ % 2) {
        cut[si] = j;
        si ++;
      }
      i_ /= 2;
    }
    int kj = si - 1;
    int fl = 0;
    cut[si] = H;
    int search = 1;
    for (int j = 0; j < W * 4; j ++) {
      bool ok = true;
      if (search > W) break;
      for (int k = 1; k <= si; k ++) {
        if (sum[cut[k]][search] + sum[cut[k - 1]][fl] 
            - sum[cut[k - 1]][search] - sum[cut[k]][fl] > K) {
          ok = false;
        }
      }
      if (!ok) {
        kj ++;
        fl = search - 1;
        search --;
        //if (i == 0) cout << fl << endl;
      }
      search ++;
    }
    if (ans > kj) {
      ans = kj;
      //cout << i << endl;
    }
  }
  cout << ans << endl;
}



Measured memory_bytes: 3640
n, m, x, y = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

X.sort(reverse=True)
Y.sort()

ok = False
for z in range(x + 1, y + 1):
    if X[0] < z and Y[0] >= z:
        ok = True
        break

if ok:
    print('No War')
else:
    print('War')


Measured memory_bytes: 3060
S = input()

s_list = []
for char in S:
    s_list.append(char)
    
import collections

c = collections.Counter(s_list)

if abs(c['a'] - c['b']) < 2 and abs(c['b'] - c['c'] < 2) and abs( c['c'] - c['a']) < 2:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 4212
import itertools

MAX_DIS = 10**10
N,M,R = map(int,input().split(" "))
r_list = list(map(int,input().split(" ")))
roads = [[MAX_DIS]*N for i in range(N)]
for i in range(N):
    roads[i][i] = 0
for i in range(M):
    A,B,C = map(int,input().split(" "))
    roads[A-1][B-1] = C
    roads[B-1][A-1] = C
for k in range(N):
    for i in range(N):
        for j in range(N):
            roads[i][j] = min(roads[i][j],roads[i][k]+roads[k][j])
min_dis = MAX_DIS
for directions in itertools.permutations(r_list):
    distance  = 0
    for dir in range(1,len(directions)):
        distance += roads[directions[dir-1]-1][directions[dir]-1]
    if distance < min_dis:
        min_dis =distance
print(min_dis)


Measured memory_bytes: 47472
program main
  implicit none
  
  integer :: n,m,x,a(100),i,j,b(100)=0,ss=0,bb=0
  
  read(*,*)n,m,x
  read(*,*)(a(i),i=1, m)
  do i = 1, n
    do j = 1, m
      if (i == a(j)) then
        b(i) = 1
      end if
    end do
  end do
  
  do i = 1, x-1
    ss = ss + b(i)
  end do
  do i = x+1,100
    bb = bb + b(i)
  end do
  
  write(*,*)min(ss,bb)
end program main


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
   
   int N;
   
   scanf("%d",&N);
  
   int H[N];
   int Check[N];
   
   int i;
   
   for (i = 0; i < N; i++) {
      scanf("%d",&H[i]);
      Check[i] = 0;
   }
   
   int flag = 1;
   
   while (flag == 1) {

      flag = 0;
      for (i = 0; i < N - 1; i++) {
         if (H[i] > H[i+1] && Check[i] == 0) {
            H[i] = H[i] - 1;
            Check[i] = 1;
            flag = 1;
         }
      }
      
   }
   
   int check = 0;
   for (i = 0; i < N - 1; i++) {
      if (H[i] > H[i+1]) {
         check = 1;
         break;
      }
   }
   
   if (check == 0) {
      printf("Yes\n");
   }
   else {
      printf("No\n");
   }

   return 0;
}


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

using namespace std;
 
#define PB(x)	push_back(x)
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP(x)	make_pair(x)
 
#define debug(_x)		cerr << #_x << '=' << _x << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << _x << ' ' << #_y << '=' << _y << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << _x << ' '; cerr << endl;

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

const int N = 2005;
int dp[N][N];

int32_t main() {
	FAST_IO;
		
	int n;
	cin >> n;
	string s[n];
	for (string& x: s) cin >> x;
	
	map<string, int> m;
	for (int i = 0; i < n; i++) {
		m[s[i]]++;
	}
	
	cout << m.size() << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


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

using namespace std;

const int N = 200000 + 77 , L = 17;
long long dp[1 << L] , sum[1 << L];
int n , a[L][L];
int main(){
   ios::sync_with_stdio(0);cin.tie(0);
   cin >> n;
   for(int i = 0;i < n;++ i)
      for(int j = 0;j < n;++ j)
         cin >> a[i][j];
   for(int msk = 1;msk < (1 << n);++ msk){
      int lb = __builtin_ctz(msk & - msk);
      sum[msk] = sum[msk ^ (1 << lb)];
      for(int i = 0;i < n;++ i)
         if((1 << i) & msk)
            sum[msk] += a[lb][i];
   }
   for(int msk = 0;msk < (1 << n);++ msk){
      for(int sub = msk;;sub = (sub - 1) & msk){
         long long val = dp[msk ^ sub] + sum[sub];
         dp[msk] = max(dp[msk] , val);
         if(sub == 0)
            break ;
      }
   }
   cout << dp[(1 << n) - 1];
   return 0;
}


Measured memory_bytes: 1280
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] K = new int[N];
        int[][] A = new int[N][M];
        int x = 1;
        int ans = 0;

        for(int i=0; i<N; i++){
            K[i] = sc.nextInt();
            for(int j=0; j<K[i]; j++){
                A[i][j] = sc.nextInt();
            }
        }
        if(N>1){
            for(int i=0; i<M; i++){
                loop:for(int j=1; j<N; j++){
                    for(int k=0; k<K[j]; k++){
                        if(A[0][i]==A[j][k]){
                            x += 1;
                            break;
                        }
                        else if(A[0][i]!=A[j][M-1] && k==M-1){
                            x = 0;
                            break loop;
                        }
                    }
                }
                if(x==N){
                    ans += 1;
                }
                x = 1;
            }
        }
        if(N==1){
            ans = K[0];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll a[211][211];
int h, w;
ll dp[402][202][202];

void amax(ll &x, ll y)
{
	x=max(x,y);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>h>>w;
	for(int i = 1; i <= h; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			cin>>a[i][j];
		}
	}
	for(int i = 2; i <= h + w; i++)
	{
		for(int j = 1; j <= h; j++)
		{
			for(int k = 1; k <= h; k++)
			{
				if(j>=i||k>=i) continue;
				if(i-j>w||i-k>w) continue;
				dp[i][j][k] = max(max(max(dp[i-1][j-1][k-1], dp[i-1][j][k-1]), dp[i-1][j-1][k]), dp[i-1][j][k]);
				dp[i][j][k] += a[j][i-j] + a[k][i-k];
				if(j==k) dp[i][j][k]-=a[j][i-j];
			}
		}
	}
	cout << dp[h+w][h][h] << '\n';
}


Measured memory_bytes: 125568
#include<iostream>
    #include<cstdlib>
    #include<math.h>
    #include<set>
    #include<string>
    #include<stdlib.h>
    using namespace std ;

    int gcd(int a, int b){
      if(a%b==0)return b;
      else return gcd(b,a%b);
    }
    int main(){
      int X,A;
      cin>>X>>A;
      if(X<A)cout<<0<<endl;
      else cout<<10<<endl;
      return 0;
    }

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

const int N = 220000;

int n;
long long a[N], sum[N];
int L[N], R[N];

inline long long calc(int st, int en, int p, int q) {
	long long s = sum[en] - sum[st - 1];
	long long s1 = sum[q] - sum[p - 1];
	long long s2 = s - s1;
	return abs(s1 - s2);
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i];
	for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
	L[2] = 1;
	for (int i = 3; i <= n; i++) {
		L[i] = L[i - 1];
		while (L[i] + 1 < i && calc(1, i, 1, L[i]) > calc(1, i, 1, L[i]+1)) L[i]++;
	}
	R[n - 1] = n;
	for (int i = n - 2; i >= 1; i--) {
		R[i] = R[i + 1];
		while (R[i] - 1 > i && calc(i, n, R[i], n) > calc(i, n, R[i] - 1, n)) R[i]--;
	}
	long long ans = LLONG_MAX;
	for (int i = 2; i <= n - 1; i++) {
		vector<long long> v;
		v.push_back(sum[L[i]]);
		v.push_back(sum[i] - sum[L[i]]);
		v.push_back(sum[R[i + 1] - 1] - sum[i]);
		v.push_back(sum[n] - sum[R[i + 1] - 1]);
		sort(v.begin(), v.end());
		ans = min(ans, v[3] - v[0]);
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 2e5 + 5 ;
int n , k ;
double p[maxn] , sum[maxn] ;
double cal(double x)
{
	return (x + 1) / 2 ;
}
int main()
{
	double ans = 0.0 ;
	scanf("%d%d" , &n , &k) ;
	for(int i = 1 ; i <= n ; i ++)  scanf("%lf" , &p[i]) ;
	for(int i = 1 ; i <= n ; i ++)  p[i] = cal(p[i]) ;
	for(int i = 1 ; i <= n ; i ++)  sum[i] = sum[i - 1] + p[i] ;
	for(int i = k ; i <= n ; i ++)
	  ans = max(ans , sum[i] - sum[i - k]) ;
	printf("%.12f\n" , ans) ;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
int bek(int b,int p)
{
	int x=b;
	for (int i=2;i<=p;i++){
		x*=b;
	}
	return x;
}
int main(int argc, char* argv[])
{
	int X;
	cin>>X;
	if (X==1){
		cout<<1<<endl;
		return 0;
	}
	int b=2,p=1;
	int MaxV=0;
	for (b=2;b<=X;b++){
		for (p=2;p<=X;p++){
			int v=bek(b,p);
			if (v>X){
				break;
			}
			if (MaxV<v){
				MaxV=v;
			}
		}
	}
	cout<<MaxV<<endl;
	return 0;
}

Measured memory_bytes: 256
'use strict';
function Main(inputs) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  const input = inputs.split("\n");
  const [a, b] = input[0].split(' ');
  const num_a = BigInt(a);
  const num_b_100 = BigInt(b.replace('.', ''));
  const c = num_a * num_b_100 / 100n;
  console.log(c.toString());
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29580
module Main where

import Control.Applicative
import Control.Monad
-- import Data.List
import qualified Data.ByteString.Char8 as B
import Data.Array.IArray
import Data.Array.MArray
import Data.Array.ST

readi b | Just (n, _) <- B.readInt b = n

main :: IO ()
main = do
    [n, m] <- fmap read . words <$> getLine :: IO [Int]
    as <- fmap ((\[a, b] -> (readi a, readi b)) . B.words) . B.lines <$> B.getContents

    let a1 = runSTUArray $ do
            a <- newArray (1, n) False
            forM_ as $ \(i, j) -> do
                when (i == 1) $ writeArray a j True
            return a

    let a2 = runSTUArray $ do
            a <- newArray (1, n) False
            forM_ as $ \(i, j) -> do
                when (j == n) $ writeArray a i True
            return a

    let f i = and [a1 ! i, a2 ! i]

    if any f [2 .. n - 1]
        then putStrLn "POSSIBLE"
        else putStrLn "IMPOSSIBLE"

Measured memory_bytes: 60796
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
using namespace std;

typedef long long ll;
const int N = 1e5 + 5;
int val[N];

int main()
{
    int n;
    scanf("%d", &n);
    
    int ans = 0;
    int amin = 1e4 + 4, ai, bmax = -1e4 - 4, bi;
    for (int i = 1; i <= n; i ++)
    {
        scanf("%d", &val[i]);
        if (val[i] < amin) amin = val[i], ai = i;
        if (val[i] > bmax) bmax = val[i], bi = i;
        ans += abs(val[i]);
    }
    if (ai == bi) ai ++;
    if (amin >= 0) ans -= 2 * amin;
    if (bmax <= 0) ans += 2 * bmax;

    printf("%d\n", ans);
    for (int i = 1; i <= n; i ++)
    {
        if (i == ai || i == bi) continue;
        if (val[i] > 0)
        {
            printf("%d %d\n", amin, val[i]);
            amin -= val[i];
        }
        else
        {
            printf("%d %d\n", bmax, val[i]);
            bmax -= val[i];
        }
        // cout << i << endl;
    }
    printf("%d %d\n", bmax, amin);
}

Measured memory_bytes: 2304
def gcd(a, b):
	while b != 0:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

N, M = map(int, input().split())
S = input()
T = input()

L = lcm(N, M)
n = L//N
m = L//M

sub_S = S[::m]
sub_T = T[::n]

if sub_S == sub_T:
    print(L)
else:
    print(-1)

Measured memory_bytes: 3316
#include"bits/stdc++.h"

void Main() {
    int n;
    std::cin >> n;

    if (n % 2 == 0) {
        std::cout << 0.5 << std::endl;
    } else {
        std::cout << ((n + 1) / 2.0) / n << std::endl;
    }
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
template <typename T>
T pow(T a, ll n, T e = 1) {
    T ret = e;
    while (n) {
        if (n & 1) ret *= a;
        a *= a;
        n >>= 1;
    }
    return ret;
}
 
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
 
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    bool operator==(ModInt rhs) const { return x == rhs.x; }
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
 
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
 
using mint = ModInt<1000000007>;
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n, m; cin >> n >> m;
    vector<vector<ll>> vec(100010);
    rep(i, n){
        ll a, b; cin >> a >> b;
        vec[a].push_back(b);
    }
    ll ans = 0;
    priority_queue<ll> q;
    _rep(i, 1, m + 1){
        for(auto v : vec[i]) q.push(v);
        if(!q.empty()){
            ans += q.top();
            q.pop();
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8736
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c=0,d=0;
  cin>>a>>b;
  cout<<a*(a-1)/2+b*(b-1)/2;
}

Measured memory_bytes: 256
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){int n;cin>>n;double r,R,a=M_PI/180; double s[2];while(n){s[0]=s[1]=0;rep(j,2){R=0;rep(i,n-1)cin>>r,s[j]+=sin(r*a),R+=r;s[j]+=sin((360-R)*a);cin>>n;}cout<<(s[0]!=s[1]?s[0]>s[1]?1:2:0)<<endl;}return 0;}

Measured memory_bytes: 0
"use strict";

function main(input){
  const args = input.trim().split('\n').map(_=>_.split(' ').map(_=>parseInt(_,10)));
  const n = args[0][0];
  const w_max = args[0][1];
  const items = args.slice(1);
  
  const dp = Array(100001).fill(1000000001); // 価値をiにするための最小容量
  dp[0] = 0;
  for(let i=0; i<n; i++){
    const weight = items[i][0];
    const value = items[i][1];
    for(let v=100000; v>=value; v--){
      dp[v] = Math.min(dp[v], dp[v-value] + weight);
    }
  }
  
  for(let i=100000; i>=0; i--){
    if(dp[i] <= w_max){
      console.log(i);
      return;
    }
  }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 8524
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1e18) + 1;

ll power(ll x, ll y)
{
    ll ans = 1;
    while (y)
    {
        if (y & 1)
            ans = (ans * x) % MOD;
        x = (x * x) % MOD;
        y >>= 1;
    }
    return ans;
}

ll comb(ll n, ll k)
{
    ll ans = 1;
    ll i;

    rep(i, 0, k)
    {
        ans *= n - i;
        ans %= MOD;
        ans *= power(i + 1, MOD - 2);
        ans %= MOD;
    }

    return ans;
}

int main(void)
{
    ll n, a, b;
    ll ans = 0;

    cin >> n >> a >> b;

    ans = power(2, n);

    ans = (ans - comb(n, a) + -comb(n, b) - 1 + MOD * 2) % MOD;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N,i,j;
	scanf("%d",&N);
	char W[N][11];
	for(i=0;i<N;i++) scanf("%s",W[i]);
	
	for(i=0;i<N-1;i++){
	for(j=i+1;j<N;j++){
		if(strcmp(W[i],W[j])==0){
			printf("No");
			return 0;
		}
	}
	}
	
	for(i=0;i<N-1;i++){
		if(W[i][strlen(W[i])-1]!=W[i+1][0]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 128
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <deque>
#include <queue>
using namespace std;

typedef long long ll;

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n';
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string h;
    int y,m,d;
    cin >> h >> y >> m >> d;
    while(h != "#"){
        if((y>31) or(y==31 and m>=5)){
            cout << "? " << y-30 << " " << m << " " << d << endl;
        }else{
            cout << h << " " << y << " " << m << " " << d << endl;
        }
        cin >> h >> y >> m >> d;
    }
    return 0;
}


Measured memory_bytes: 3260
#include <stdio.h>

int main(void) {
	char P[16];
	int natto;
	int i, j;
	int answer = -1;
	if (scanf("%15s", P) != 1) return 1;
	for (natto = 0; natto < 12; natto++) {
		if (P[natto] == '\0') return 2;
		if (P[natto] == '?') break;
	}
	if (natto >= 12) return 2;
	for (i = 0; i <= 9; i++) {
		int asumikana = 0;
		int kitamuraeri;
		P[natto] = i + '0';
		for (j = 1; j <= 11; j++) {
			asumikana += (P[11 - j] - '0') * (j <= 6 ? (j + 1) : (j - 5));
		}
		asumikana %= 11;
		kitamuraeri = asumikana <= 1 ? 0 : 11 - asumikana;
		if (P[11] - '0' == kitamuraeri) {
			if (answer == -1) answer = i; else answer = -2;
		}
	}
	if (answer < 0) {
		puts("MULTIPLE");
	} else {
		printf("%d\n", answer);
	}
	return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;


int main(){
    int H, W; 
    cin >> H >> W;
    vector<vector<int>> c(10, vector<int>(10));
    rep(i,10)rep(j,10) cin >> c[i][j];
    vector<vector<int>> A(H, vector<int>(W));
    rep(i,H)rep(j,W) cin >> A[i][j];
    for(int k = 0; k < 10; ++k){
        for(int i = 0; i < 10; ++i){
            for(int j = 0; j < 10; ++j){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    int ans = 0;
    rep(i,H)rep(j,W){
        if(A[i][j] == -1) continue;
        ans += c[A[i][j]][1];
    }
    cout << ans << endl;
}

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

long long N, K;
vector<long long> sumV(100001);

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

  int N;
  cin >> N;
  vector<int> W(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> W.at(i);
    sum += W.at(i);
  }
  int sum2 = 0;
  int min = 9999999;
  for(int i = 0; i < N; i++){
    sum2 += W.at(i);
    if(abs(sum - sum2 - sum2) < min){
      min = abs(sum - sum2 - sum2);
    }
  }
  cout << min <<endl;
}


Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

aa = sorted([a[i]-i-1 for i in range(n)])

if n % 2 == 1:
    idx = n // 2
    res = 0
    for ai in aa[:idx]:
        res += aa[idx] - ai
    for ai in aa[idx:]:
        res += ai - aa[idx]

else:
    idx_1 = n // 2 -1
    idx_2 = n // 2
    res_1 = 0
    for ai in aa[:idx_1]:
        res_1 += aa[idx_1] - ai
    for ai in aa[idx_1:]:
        res_1 += ai - aa[idx_1]
    res_2 = 0
    for ai in aa[:idx_2]:
        res_2 += aa[idx_2] - ai
    for ai in aa[idx_2:]:
        res_2 += ai - aa[idx_2]
    res = min(res_1, res_2)

print(res)

Measured memory_bytes: 25708
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

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

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...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    vector<int> order(5);
    for(int i = 0; i < 5; i++){
        cin >> order[i];
    }
    sort(ALL(order), [&](int x, int y){
        int d1 = 10 * ((x + 9) / 10) - x;
        int d2 = 10 * ((y + 9) / 10) - y;
        return d1 < d2;
    });
    int t = 0;
    for(int i = 0; i < 5; i++){
        t += order[i];
        if(i == 4) break;
        while(t % 10 != 0) t++;
    }
    cout << t;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>

using namespace std;

bool C(int b){
	for(int i=1;i*i<=b;i++){
		if((b-i)%(2*i+1)==0)return true;
	}
	return false;
}

int n;
int a[100001];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	int cnt=0;
	for(int i=0;i<n;i++){
		if(!C(a[i]))cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

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

ll mod=998244353;

int main(){
    ll n,k;
    cin>>n>>k;
    vector<pair<ll,ll>> t,ans(n+250000,{0,0});
    for(ll _=0;_<k;++_){
        pair<ll,ll> p;
        cin>>p.first>>p.second;
        t.push_back(p);
    }
    
    ll f=0;
    for (ll i = 1; i <= n; i++) {
        f+=ans[i].first;
        if(i==1||f>0){
            for (auto p : t) {
                ans[i+p.first].first=ans[i+p.first].first+(i==1?1:f)%mod;
                ans[i+p.second].second=ans[i+p.second].second+(i==1?1:f)%mod;
            }
        }
        f-=ans[i].second;
    }
    ll aaaa=0; 
    for(ll i = 1; i < n; i++){
        aaaa=((aaaa+ans[i].first)%mod-(ans[i].second))%mod;
    }
    aaaa=(aaaa+ans[n].first)%mod;
    cout<<aaaa;
    
}

Measured memory_bytes: 10384
import java.util.Scanner;
class Main
{
static Scanner scan = new Scanner(System.in);
    public static void main(String[] args) {
        int takahashi = 0;
        String str = scan.next();

        for(int i =0 ;i<str.length();i++)
        {
            String s = String.valueOf(str.charAt(i));
            switch(s){
                case "+":
                takahashi++;
                break;
                case "-":
                takahashi--;
                break;
                default :
                break;
            }
        }
        System.out.println(takahashi);
    }

}

Measured memory_bytes: 21972