akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int n,t;
	cin>>n>>t;
	long int i,a[n],x=t;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	for(i=1;i<n;i++)
	{
		if(a[i]-a[i-1]<=t)
		{
			x=x+a[i]-a[i-1];
		}
		else
		{
			x=x+t;
		}
	}
	cout<<x<<endl;
	
}


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

int main(){
	ll n; cin >> n;
	vl x(n); rep(i,n)cin >> x[i];
	ll sum = 0; rep(i,n)sum += x[i];
	double ave = (double)sum / n;
	ll p = 0;
	if(ave - sum/n >= 0.5) p = sum/n + 1;
	else p = sum/n;
	ll ans = 0;
	rep(i,n){
		ans += (x[i] - p)*(x[i] - p);
	} 
	cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int INF=0x3f3f3f3f;
long long n,m,a[200010],p,q;
int main(){
	cin>>n;
	p=q=-INF;
	cin>>a[1]>>a[2];
	q=max(a[1],a[2]);
	p=min(a[1],a[2]);
	for(int i=3;i<=n;i++) {
		cin>>a[i];
		if(a[i]>=q){
			p=q;
			q=a[i];
		}
		else if(a[i]>p) p=a[i];
	}
	for(int i=1;i<=n;i++){
		if(a[i]!=q) cout<<q<<endl;
		else cout<<p<<endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>

using namespace std;

int L[100];

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

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

    int m = 0;
    for(i = 0; i < N; i++){
        m = max(m, L[i]);
    }

    bool t = true;
    int sum = 0;
    for(i = 0; i < N; i++){
        if(t && L[i] == m){
            t = false;
        }else{
            sum += L[i];
        }
    }

    if(sum > m){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int a,p;
  cin>>a>>p;
  int ans;
  p += 3*a;
  ans = p/2;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;
		//int T=sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		int leng =s.length();
		
		for(int i=0;i<leng;i++){
			if(s.equals(t)){
				System.out.println("Yes");
				
				System.exit(0);
			}
			
			String a=t.substring(leng-1,leng);
			//System.out.println("a:"+a);
			String b=t.substring(0, leng-1);
			//System.out.println("b:"+b);
			t=a+b;
			//System.out.println(t.length());
			//System.out.println(t);
		}
		System.out.println("No");
		//System.out.println(t.charAt(0));
		
	}
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main() {
  int n; cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];
  int ans = 0;
  while (true) {
    int div = 0;
    for (int i = 0; i < n; i++) {
      if (i == 0 && h[i] > 0) div++;
      if (i >= 1 && h[i] > 0 && h[i - 1] <= 0) div++;
    }
    if (div == 0) break;
    ans += div;
    for (int i = 0; i < n; i++) h[i]--;
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
  int A,B;
  cin >> A >> B;
  int number;
  for(int i = A;i<=B;i++){
    int a,b,c,d,e;
    a = i/10000;
    b = (i-(i/10000*10000))/1000;
    c = (i-(i/1000*1000))/100;
    d = (i-(i/100*100))/10;
    e = i-(i/10*10);
    if(a == e && b == d){
      number++;
    }
  }
  cout << number << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import Counter

def main():
    N = II()
    ks = {}
    for i in range(1, 1000):
        ks[i * (i - 1) // 2] = i
    if N not in ks.keys():
        print('No')
        return 0
    print('Yes')
    k = ks[N]
    print(k)
    sets = [[k - 1] for i in range(k)]
    cnt = 1
    for i in range(k):
        for j in range(i):
            sets[i].append(cnt)
            sets[j].append(cnt)
            cnt += 1
    for i in range(k):
        print(*sets[i])

    return 0

main()

Measured memory_bytes: 9828
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;


double l[20],a[20],b[20];
double d[20][20];

double dis(int x, int y){
  return (l[x]-l[y])*(l[x]-l[y]) + (a[x]-a[y])*(a[x]-a[y]) + (b[x]-b[y])*(b[x]-b[y]);
}

int main(){
  int n,m;
  double dp[1<<20];
  
  cin >> n >> m;

  for(int i=0;i<n;i++)cin >> l[i] >> a[i] >> b[i];

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)d[i][j] = dis(i,j);
  }

  double mx = 0.0;
  for(int i=0;i<(1<<n);i++){
    int cnt = 0;
    for(int j=0;j<n;j++){
      if( i & (1<<j) ){
	cnt++;
	if(cnt==1){
	  dp[i] = dp[i-(1<<j)];
	  for(int k=0;k<n;k++){
	    if( (i-(1<<j)) & (1<<k) )dp[i] += d[j][k];
	  }
	}
      }
    }
    if(cnt == m)mx = max(dp[i],mx);
  }
  printf("%.8lf\n",mx);
}

Measured memory_bytes: 8592
use std::collections::VecDeque;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let mut sv = vec![
        scan!().chars().collect::<VecDeque<_>>(),
        scan!().chars().collect::<VecDeque<_>>(),
        scan!().chars().collect::<VecDeque<_>>(),
    ];

    let p = vec!["A", "B", "C"];
    let mut i = 0;
    loop {
        if let Some(c) = sv[i].pop_front() {
            match c {
                'a' => i = 0,
                'b' => i = 1,
                'c' => i = 2,
                _ => i = 0,
            }
        } else {
            println!("{}", p[i]);
            return;
        }
    }
}


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

int main() {
	int n;
	cin >> n;
	map<string, long long> ss;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		ss[s]++;
	}
	long long ans = 0;
	for (auto itr = ss.begin(); itr != ss.end(); itr++) {
		long long aa = (*itr).second;
		ans += (long long)(aa * (aa - 1)) / 2;
	}

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

Measured memory_bytes: 11136
s = input()
s,n,e,w = s.count("S"),s.count("N"),s.count("E"),s.count("W")
if (s > 0 and n == 0) or (s == 0 and n > 0):
    print("No")
elif (e > 0 and w == 0) or (e == 0 and w > 0):
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9032
#include<cstdio>
#include<functional>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<cstdlib>
#include<cctype>
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;
int main(void)
{
	string s;
	getline(cin,s);
	rep(i,s.size()) {
		if(s[i]>='A' && s[i]<='Z') s[i]=tolower(s[i]);
		else s[i]=toupper(s[i]);
		cout<<s[i];
	}
	cout<<endl;
}

Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef pair<lli, lli> pii;
int main(){
  lli n, p, q;
  std::cin >> n >> p >> q;
  vector<lli> c(n);
  for (int i = 0; i < n; i++) {
    std::cin >> c[i];
  }
  lli ans, sum = 0;
  vector<pii> dp;
  for (int i = 0; i < n; i++) {
    sum += c[i];
    dp.emplace_back(pii(c[i] + p*i, i));
  }
  ans = sum;
  sort(dp.begin(), dp.end());
  for (int i = 0; i <= n; i++) {
    int id = dp[i].second;
    ans = max(ans, sum + p*i*(i - 1) + p*q*i);
    if(i < n)sum -= c[id] + p*id;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 15084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;

const int INF = 19191919;

struct Dice{
    int x,y;
    int l,r,f,b,d,u;

    void read(){
        cin >>x >>y >>l >>r >>f >>b >>d >>u;
    }

    void rot(char c){
        int tmp;
        if(c=='L'){
            --x;
            tmp = u;
            u = r;
            r = d;
            d = l;
            l = tmp;
        }
        else if(c=='R'){
            ++x;
            tmp = u;
            u = l;
            l = d;
            d = r;
            r = tmp;
        }
        else if(c=='F'){
            --y;
            tmp = u;
            u = b;
            b = d;
            d = f;
            f = tmp;
        }
        else if(c=='B'){
            ++y;
            tmp = u;
            u = f;
            f = d;
            d = b;
            b = tmp;
        }
    }

    pi pos(){
        return {x,y};
    }

    int val(){
        return d;
    }
};


int main(){
    int n;
    while(cin >>n,n){
        map<pi,int> cov;
        vector<map<pi,int>> D(n);
        rep(i,n){
            Dice a;
            a.read();
            string rot;
            cin >>rot;

            map<pi,int> m;
            m[a.pos()] = a.val();
            for(char c:rot){
                a.rot(c);
                m[a.pos()] = a.val();
            }

            for(const auto &p:m){
                cov[p.fi] |= (1<<i);
            }
            D[i] = m;
        }

        vector<int> dp(1<<n, -INF);
        dp[0] = 0;
        rep(mask,1<<n){
            rep(i,n)if(!(mask>>i&1)){
                int nmask = mask|(1<<i);

                int add = 0;
                for(const auto &p:D[i]){
                    if((nmask|cov[p.fi]) == nmask) add += p.se;
                }
                dp[nmask] = max(dp[nmask], dp[mask]+add);
            }
        }
        cout << dp[(1<<n)-1] << endl;
    }
    return 0;
}



Measured memory_bytes: 3220
#include<stdio.h>
#include<string.h>

int main(){
	//freopen("in/0002.txt","r",stdin);
	char buf[15];
	char *endptr;
	char numptr[7];
	int a,b;
	while(fgets(buf,15,stdin)!=NULL){
		a=strtol(buf,&endptr,10);
		b=strtol(endptr,NULL,10);
		sprintf(numptr,"%d",a+b);
		printf("%d\n",strlen(numptr));
	}
	return 0;
}

Measured memory_bytes: 540
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0032
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "";
            Square square = new Square();
            int countD = 0;
            int countP = 0;
            while(!((str = Console.ReadLine()) == null))
            {
                string[] list = str.Split(',');
                square.side1 = int.Parse(list[0]); 
                square.side2 = int.Parse(list[1]); 
                square.diagonal = int.Parse(list[2]);
                if (square.IsDiamond() == true)
                {
                    countD++;
                }
                if (square.IsParalleloglyphic() == true)
                {
                    countP++;
                }
            }
            Console.WriteLine(countP);
            Console.WriteLine(countD);
        }
    }
    class Square
    {
        public int side1 = 0;
        public int side2 = 0;
        public int diagonal = 0;
        public bool IsDiamond()
        {
            if (side1 == side2)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        public bool IsParalleloglyphic()
        {
            if (((Math.Pow(side1, 2) + Math.Pow(side2, 2)) == Math.Pow(diagonal, 2)))
            {
                return true;
            }
            else
            {
                return false;
            }
        }

    }
}



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

#define LL long long
#define LD long double
#define PR pair<int,int>
#define pb push_back
#define mp make_pair

template<typename T> T Abs(T x) { return(x<0 ? -x : x); }

int n;
int h[100005];
int dp[100005];


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

	dp[0] = 0;
	dp[1] = Abs(h[0] - h[1]);

	for (int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1] + Abs(h[i] - h[i-1]), dp[i-2] + Abs(h[i] - h[i-2]));
	}

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

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

int main()
{
    ll row,col;
    cin>>row>>col;
    char arr[row+5][col+5]={0};
    ll brr[row+5][col+5]={0};
    for(int i=0;i<row;i++)
    {
        for(int j=0;j<col;j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0;i<row;i++)
    {
        for(int j=0;j<col;j++)
        {
            ll cnt=0;
            if(arr[i][j]=='#')
            {
                brr[i][j]=50000;
            }
            else{
                for(int k=i-1;k<i+2;k++)
                {
                    for(int l=j-1;l<j+2;l++)
                    {
                        if(k<0 || k>=row || l<0 || l>=col)
                        {
                            continue;
                        }
                        else{
                            if(arr[k][l]=='#')
                            {
                                cnt++;
                            }
                        }
                    }
                }
                brr[i][j]=cnt;
            }
        }
    }
    for(int i=0;i<row;i++)
    {
        for(int j=0;j<col;j++)
        {
           if(brr[i][j]==50000)
           {
               cout<<"#";
           }
           else{
            cout<<brr[i][j];
           }
        }
        cout<<endl;
    }
}


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

int result[200] = { 0 };

	int main()
	{
		int member;
		cin >> member;
		int time1[200], time2[200], time3[200];
		
		for (int i = 0; i < member; i++){
			cin >> time1[i] >> time2[i] >> time3[i];
		}

		int sign[200] = { 0 };
		for (int i = 0; i < member; i++)
		{
			for (int a = 0; a < member; a++)
			{
				if (time1[i] == time1[a])
				{
					sign[i]++;
				}
			}
			if (sign[i] == 1)result[i] += time1[i];

		}
		



		int sign2[200] = { 0 };
		for (int i = 0; i < member; i++)
		{
			for (int a = 0; a < member; a++)
			{
				if (time2[i] == time2[a])
				{
					sign2[i]++;
				}
			}
			if (sign2[i] == 1)result[i] += time2[i];

		}


		int sign3[200] = { 0 };
		for (int i = 0; i < member; i++)
		{
			for (int a = 0; a < member; a++)
			{
				if (time3[i] == time3[a])
				{
					sign3[i]++;
				}
			}
			if (sign3[i] == 1)result[i] += time3[i];

		}




		for (int i = 0; i < member;i++)
		cout << result[i] << endl;

		cin >> result[123];





	}

Measured memory_bytes: 1164
#include<stdio.h>
int main(void){
        int b,f,r,v,n,i,j;
        int a[4][3][10]={0};
        scanf("%d",&n);
        for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
                a[b-1][f-1][r-1]=a[b-1][f-1][r-1]+v;
	}
        for(i=0;i<4;i++){
		for(j=0;j<3;j++){
		       printf(" %d %d %d %d %d %d %d %d %d %d\n",a[i][j][0],a[i][j][1],a[i][j][2],a[i][j][3],a[i][j][4],a[i][j][5],a[i][j][6],a[i][j][7],a[i][j][8],a[i][j][9]);
                }
                if(i<3){printf("####################\n");}
	}
	
	return 0;
}


Measured memory_bytes: 2700
#include<bits/stdc++.h>
using namespace std;
int main(void){
	string s;
	int n,nn;
	int i,j;
	int sum;
	int box[10];
	while(1){
		cin>>n;
		if(n==0)	break;
		for(i=0;i<n;i++)	box[i]=0;
		cin>>s;
		i=0;
		sum=0;
		j=1;
		nn=100;
		while(1){
			if(i==nn)	break;
			if(j==n+1)	j=1;
			if(s[i]=='M'){
				box[j-1]++;
			}
			if(s[i]=='S'){
				sum+=box[j-1];
				box[j-1]=0;
				sum++;
			}
			if(s[i]=='L'){
				box[j-1]+=sum;
				box[j-1]++;
				sum=0;
			}
			//cout<<"I="<<i<<" "<<"J="<<j<<" "<<"札="<<s[i]<<" "<<"場="<<sum<<endl;
			// for(int k=0;k<n;k++)	cout<<k+1<<" "<<box[k]<<" ";
			// cout<<endl<<endl;
			i++;
			j++;
		}
		sort(box,box+n);
		for(i=0;i<n;i++){
			if(i)	cout<<" ";
			cout<<box[i];
		}
		cout<<" "<<sum<<endl;
	}
	return 0;
}


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

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int m[100], a[100], b[100], n;

bool judge(int x){
  int w = 0;
  rep(i, n) if(a[i] <= x && b[i] > x) w += m[i];
  return w <= 150;
}

int main(){
  while(scanf("%d", &n) && n){
    rep(i, n) scanf("%d%d%d", m + i, a + i, b + i);
    bool res = true;
    rep(i, n) res &= judge(a[i]);
    rep(i, n) res &= judge(b[i]);
    puts(res ? "OK" : "NG");
  }
  return 0;
}

Measured memory_bytes: 1016
import sys
import math

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    A, B = readline().split()
    A = int(A)
    B1, B2 = B.split('.')
    B1 = int(B1)
    B2 = int(B2)

    ans = A * B1 + int(A * B2 // 100)
    print(ans)

    return


if __name__ == '__main__':
    main()


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int ans=0;

  string s;
  cin >> s;
  REP(i, 4)
  {
    if (s[i]=='+')
    {
      ans++;
    }
    else
    {
      ans--;
    }
  }

  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 2e5+10;
const int NG = -1;

int N;
ll A[MAX], B[MAX];

ll solve() {
    priority_queue<ii> q;
    ll ans = 0;
    REP (i, N) {
        if (B[i] == A[i]) continue;
        if (B[i] < A[i]) return NG;
        q.push(ii(B[i], i));
    }

    while (!q.empty()) {
        ll i = q.top().second;
        q.pop();
        ll r = B[(i+1)%N] + B[(N+i-1)%N];
        ll k = (B[i] - A[i]) / r;
        if (k <= 0) return NG;
        ans += k;
        B[i] -= r * k;
        if (A[i] == B[i]) continue;
        q.push(ii(B[i], i));
    }

    return ans;
}

int main() {
    cin >> N;
    REP (i, N) cin >> A[i];
    REP (i, N) cin >> B[i];
    cout << solve() << endl;
}

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

namespace CSharpSample01
{


    class Program
    {

        

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int[] data = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int D = data[0];
            int X = data[1];

            int cnt = 0;
            for(int i = 1; i <= N; i++)
            {
                int a = int.Parse(Console.ReadLine());

                for(int j = 0; ; j++)
                {
                    if (j * a + 1 <= D) cnt++;
                    else break;
                }

            }

            Console.WriteLine(X + cnt);
            


        }
    }
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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 (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    //lol result{0};
    string s1; cin >> s1;
    string s2; cin >> s2;
    //int k; cin >> k;
    /*
    vector<int> a(n);
    REP(i, n)
    {
        cin >> a[i];
    }
    */

    REP(i, s1.length())
    {
        if(s1[i] != s2[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<algorithm>
#define int long long
using namespace std;
signed main() {
	int q, a, b, ima = 0; string s, c;
	cin >> s >> q;
	for (int h = 0; h < q; h++) {
		cin >> a;
		if (a == 1) { ima++; ima %= 2; }
		else {
			cin >> b >> c;
			if (b == 1) {
				if (ima == 0) { s.insert(0, c); }
				if (ima == 1) { s += c; }
			}
			if (b == 2) {
				if (ima == 0) { s += c; }
				if (ima == 1) { s.insert(0, c); }
			}
		}
	}
	if (ima == 1) {
		reverse(s.begin(), s.end());
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 900
#include<stdio.h>
#include<string.h>

int main(void){
        char s[64], t[64];
        scanf("%s %s", s, t);
        int n = strlen(s), m = strlen(t);

        int f = -1;
        for(int i=0; i<n-m+1; i++){
                for(int j=0; j<m; j++){
                        if(s[i+j]!=t[j] && s[i+j]!='?') break;
                        if(j==m-1) f = i;
                }
        }
  
        if(f<0){
                puts("UNRESTORABLE");
                return 0;
        }else{
                for(int i=0; i<m; i++) s[f+i] = t[i];
                for(int i=0; i<n; i++){
                        if(s[i]=='?') s[i] = 'a';
                }
                printf("%s\n", s);
        }
        return 0;
}

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

int main() {
  string S;
  cin >> S;

  int ans = 0;
  int count = 0;
  for (int i = 0; i < S.size(); i++) {
    char c = S.at(i);
    if (c == 'A' || c == 'T' || c == 'C' || c == 'G') {
      count++;
    } else {
      ans = max(count, ans);
      count = 0;
    }
  }
  ans = max(count, ans);

  cout << ans << endl;

  return 0;
}


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

int main() {
    int K, S;
    cin >> K >> S;
    int res = 0;

    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - x - y;
            if (z >= 0 && z <= K) res++;
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3624
import sys
input = sys.stdin.readline
import itertools

N, M = [int(item) for item in input().split()]

k = []
s = []
for i in range(M):
    items = [int(item) for item in input().split()]
    k.append(items[0])
    s.append(items[1:])

p = [int(item) for item in input().split()]

count = 0

for pat in itertools.product([0, 1], repeat=N):
    for l in range(M):
        ons = sum([pat[item - 1] for item in s[l]])
        if ons % 2 != p[l] % 2:
            break
    else:
        count += 1

print(count)


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int H, W, D;
    cin >> H >> W >> D;
    LL cum[SIZE] = {};
    vector<P> v(H * W + 1);
    for(int i = 1; i <= H; ++i) {
        for(int j = 1; j <= W; ++j) {
            int n;
            cin >> n;
            v[n] = MP(i, j);
        }
    }

    for(int i = 1; i + D <= H * W; ++i) {
        cum[i + D] += cum[i] + abs(v[i].F - v[i + D].F) + abs(v[i].S - v[i + D].S);
    }

    int Q;
    cin >> Q;
    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << cum[r] - cum[l] << endl;
    }
    return 0;
}



Measured memory_bytes: 5560
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong();
		long B = sc.nextLong();
		long ans = 0;

		int i = 1;
		while (i <= B) {
			if ((long) A * i % B == 0) {
				ans = (long) A * i;

				break;
			} else {
				i++;
			}

		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 23892
#include<stdio.h>

int main(void){
    int n,m,l,i,j,k;
    int a[100][100],b[100][100];
    long long c[100][100]={0};
    
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
           scanf("%d",&a[i][j]);
        }
    }
    
     for(i=0;i<m;i++){
        for(j=0;j<l;j++){
           scanf("%d",&b[i][j]);
        }
    }
    
    for(i=0;i<n;i++){
        for(j=0;j<l;j++){
            for(k=0;k<m;k++){
                c[i][j]+=a[i][k]*b[k][j];
            }
            if(j==l-1){
                printf("%ld",c[i][j]);
            }else{
                printf("%ld ",c[i][j]);
            }            
        }
        printf("\n");
    }
    
    return 0;
    
}



Measured memory_bytes: 2100
def main():
    n,m=map(int,input().split())
    h=list(map(int,input().split()))
    res=[1]*n
    for i in range(m):
        a,b=map(int,input().split())
        if h[a-1]<h[b-1]:
            res[a-1]=0
        elif h[a-1]>h[b-1]:
            res[b-1]=0
        else:
            res[a-1]=0
            res[b-1]=0
    print(sum(res))
if __name__=="__main__":
    main()

Measured memory_bytes: 19948
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int X,A,B;cin>>X>>A>>B;
    if(A>=B)cout<<"delicious"<<endl;
    else{
    if(A<B&&B-A<=X)cout<<"safe"<<endl;
    else cout<<"dangerous"<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;

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

    int[] A = new int[N+1];
    int[] B = new int[N];
    for (int i = 1; i <= N; i++) {
      A[i] = sc.nextInt();
      B[i-1] = A[i] - i;
    }
    Arrays.sort(B);
    if (N % 2 == 0) {
      System.out.println(Math.min(calc(A, B[N/2]), calc(A, B[N/2-1])));
    } else {             
      System.out.println(calc(A, B[N/2]));
    }
  }
  
  private static long calc(int[] A, int b) {
    long ret = 0;
    for (int i = 1; i < A.length; i++) {
      ret += Math.abs(A[i] - (b + i));
    }
    return ret;
  }
}

Measured memory_bytes: 78916
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;

int main(){
	cin>>n;
	int a=0;
	int b=0;
	int c=0;
	REP(i,n){
		string s;
		cin>>s;
		if(s=="A"){
			a++;
			b++;
		}
		if(s=="Un")c++;
		if(s=="Un"&&a>0)a--;
	}
	if(a==0&&b==c)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}
		
	


Measured memory_bytes: 3168
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <bitset>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

int main() {
    string s;
    cin >> s;
    vector<char> v;
    v.push_back(s[0]);
    int cnt = 0;
    for (int i = 1; i < s.length(); ++i) {
        while (v.size() > 1 && v[v.size() - 2] != s[i]) {
            v.pop_back();
            ++cnt;
        }
        v.push_back(s[i]);
    }
    if (cnt % 2 == 0) {
        cout << "Second\n";
    } else {
        cout << "First\n";
    }
}

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

class segmenttree{
    private:
    int n;
    long long identity = 0;//単位元
    std::vector<long long> dat;
    public:
    
    void init(int N){
        n=1;
        while(n<N)n*=2;
        dat.clear();
        for(int i=0;i<2*n-1;++i){
            dat.push_back(identity);
        }
    }
    
    long long calc();
    
    void update(int k,long long a){
        k+=n-1;
        dat[k]=a;
        while(k>0){
            k=(k-1)/2;
            dat[k]=calc(dat[2*k+1],dat[2*k+2]);
        }
    }
    
    long long query(long long a,long long b){
        a+=n;
        b+=n;
        long long R=0;
        while(a < b){
            if(a % 2 == 1){
                R = calc(R, dat[a - 1]);
                a += 1;
            }
            a /= 2;
            if(b % 2 == 1){
                b -= 1;
                R = calc(R, dat[b - 1]);
            }
            b /= 2;
        }
        return R;
    }
    
    long long calc(long long a,long long b){
        return (a+b)%3;
    }
    
};


int main(){
    
    string S,T;
    int Q;
    int A[114514],B[114514],C[114514],D[114514];
    int G[114514],H[114514];
    
    cin >> S >> T;
    cin >> Q;
    REP(i,Q){
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--;B[i]--;C[i]--;D[i]--;
    }
    
    //Aを1、Bを2、O(=AB)を0と扱う
    
    segmenttree Sseg,Tseg;
    
    //Sをセグる
    Sseg.init(S.size());
    REP(i,S.size()){
        Sseg.update(i,(S[i]=='A'?1:2));
    }
    REP(i,Q){
        G[i]=Sseg.query(A[i],B[i]+1);
    }
    //Tをセグる
    Tseg.init(T.size());
    REP(i,T.size()){
        Tseg.update(i,(T[i]=='A'?1:2));
    }
    REP(i,Q){
        H[i]=Tseg.query(C[i],D[i]+1);
    }
    
    //REP(i,Q){cout << G[i] <<" "<< H[i] << endl;}
    
    REP(i,Q){
        if(G[i]==H[i]){
            cout << "YES" << '\n';
        }else{
            cout << "NO" << '\n';
        }
    }
    
    return 0;
}

Measured memory_bytes: 8116
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = n * m - ((n + m) * 2) + 4;
  if (n == 1 && m == 1) ans = 1;
  else if (n == 1 || m == 1) ans = n * m - 2;
  else if (n == 2 || m == 2) ans = 0;
  if (ans < 0) ans = 0;
  P(ans);
  return 0;
}



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

#define FOR(i,a,b)  for(ll i=a;(i)<(b);++(i))
#define RFOR(i,a,b) for(ll i=a;(i)>=(b);--(i))
#define REP(i,n)    FOR(i,0,n)
#define RREP(i,n)   RFOR(i,n,0)
#define ALL(v)      v.begin(), v.end()
#define UNIQ(v)     sort(ALL(v)); v.erase(unique(ALL(v)), v.end())
#define BIT(n)      (1LL<<(n))
#define DEBUG(a)    cout << #a << " = " << a << endl

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int A, B, C, K;

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

    int rest[] = {A, B, C};
    int num[] = {1, 0, -1};
    int index = 0;
    int sum = 0;

    FOR(i, 0, 3) {
        if (K > rest[i]) {
            sum += num[i] * rest[i];
            K -= rest[i];
        } else {
            sum += num[i] * K;
            break;
        }
    }

    cout << sum << endl;
}


Measured memory_bytes: 3636
def LI(): return list(map(int, input().split()))
def I(): return map(int, input().split())
mod = 10**9 + 7

def main():
  x , y = I()
  for i in range(x+1):
    if 2 * i + 4 * (x-i) == y:
      print('Yes')
      exit()
    
  print('No')
  
if __name__ == '__main__':
  main()

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

ll GCD(ll a, ll b)
{
	if (b == 0) return a;
	else return GCD(b, a%b);
}

int main(int argc, char **argv)
{
	ll N, X; cin >> N >> X;
	vector<ll> x(N); for (ll i = 0; i < N; ++i) cin >> x[i];
	ll res{0};
	for (ll i = 0; i < N; ++i)
		res = GCD(abs(x[i]-X), res);

	std::cout << res << std::endl;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
	}

	void solve() {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		sc.close();

		int cnt = 0;
		int maxL = 0;
		for(int i = 0; i < c.length; i++) {
			if (c[i]=='A'||c[i]=='C'||c[i]=='G'||c[i]=='T'){
				cnt++;
				maxL = Math.max(cnt, maxL);
			}else {
				cnt = 0;
			}
		}
		System.out.println(maxL);
	}

}


Measured memory_bytes: 23764
#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 TRACE
#ifdef TRACE
#define tr(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define tr(...)
#endif

#define ll long long
#define ld long double 
#define endl "\n"
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (ll)(a.size())
#define all(a) a.begin(), a.end() 
#define fr(i,n) for(i=1;i<=n;++i)
#define rp(i,n) for(i=0;i<n;++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());      // Remove _64 for 32 bit random nos.

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use pair if duplicates are there 
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the pointer to kth element.(0-based)
typedef pair<ll, ll> ii;
typedef vector<ll> vl;
typedef vector<ii> vii;
const ll N = 200010;
ll mod=1e9+7;

ll ffmod(ll x, ll y, ll mod)
{
    ll rt=1;
    while(y)
    {
        if(y&1ll) rt=(rt*x)%mod;
        x=(x*x)%mod, y/=2ll;
    }
    return rt;
}

int main()
{
    FIO;
    string s;
    ll i;
    cin>>s;
    for(i=0;i<SZ(s);i+=2)
        if(i+1>=SZ(s) || s[i]!='h' || s[i+1]!='i')
            break;
    if(i==SZ(s))
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int N;
    cin >> N;
     
     vector<long long int> vec(N);
     for(int n=0; n<N; n++) {
        cin >> vec[n];
     }
     
     long long int ans=200*200*100+1;
     for(long long int i=-100; i<=100; i++) {
        long long int tmp=0;
        for(int n=0; n<N; n++) {
            tmp += pow(vec[n]-i, 2);
        }
        ans = min(ans, tmp);
     }

     cout << ans << endl;
     

    return 0;
    
}

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

///////////////////////////////////////////
const long long int INF = 1000000000000000000LL;
using ll = long long int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
template<class T>T sqar(T x){ return x*x; }
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
///////////////////////////////////////////

int main(){
    ll n;
    cin>>n;
    if(n%2 == 0){
        cout<<n<<endl;
    }else{
        cout<<2*n<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(int(1e7))
from collections import deque
def inpl(): return list(map(int, input().split()))

input()
A = set(inpl())
B = set(inpl())
ands = sorted(A&B)
ors = sorted(A|B)

print(len(ands), len(ors))
if len(ands):
    print(*ands,sep="\n")
if len(ors):
    print(*ors, sep="\n")


Measured memory_bytes: 38256
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		String t = sc.next();

		char[] ss = new char[s.length()];

		char[] tt = new char[t.length()];

		for(int i=0;i<s.length();i++) {

			ss[i]= s.charAt(i);
		}

		for(int i=0;i<t.length();i++) {

			tt[i]= t.charAt(i);
		}

		Arrays.sort(ss);

		Arrays.sort(tt);

		boolean ans = false;

		boolean flag = false;

		int len = Math.min(s.length(), t.length());

		for(int i=0;i<len;i++) {

			if(ss[i]<tt[tt.length-1-i]) {

				ans = true;

				break;
			}

			if(ss[i]!=tt[tt.length-1-i]) flag = true;

			if(i==len-1 && ss.length>tt.length) ans = false;
		}

		if(!flag && ss.length<tt.length) ans = true;

		if(s.equals(t)) ans = false;

		if(ans)System.out.println("Yes");

		else System.out.println("No");
	}

}


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

int main(){
    int n,s,k;
    while(cin>>n>>k>>s && n){
        int ans=0;
        for(int mask=0;mask<(1<<n);mask++){
            int c=0;
            for(int i=0;i<n;i++)c+=(mask>>i&1);
            if(c!=k) continue;
            int ts=0;
            for(int i=0;i<n;i++)ts+=(mask>>i&1)*(i+1);
            if(ts==s)ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
const int INF = 114514810;
using namespace std;
typedef long long LL;

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> B(n);
  rep(i,n) cin>>B[i];
  vector<int> p(m);
  rep(i,m) cin>>p[i];
  vector<int> tg(n);

  int k=0;
  vector<int> b = B;
  rep(i, p.size())rep(j, p[i]) tg[k++]=i%2;
  int ans = INF;
  int tmp = 0;
  rep(i, n){
    if(tmp == INF) break;
    if(b[i] == tg[i]) continue;
    rep(j, n){
      if(i+j >= n){
        tmp = INF;
        break;
      }
      if(b[i+j] == tg[i]){
        swap(b[i], b[i+j]);
        tmp += j;
        break;
      }
    }
  }
  ans = min(ans, tmp);
  k=0;
  rep(i, p.size())rep(j, p[i]) tg[k++]=(i+1)%2;
  tmp = 0;
  b = B;
  rep(i, n){
    if(tmp == INF) break;
    if(b[i] == tg[i]) continue;
    rep(j, n){
      if(i+j >= n){
        tmp = INF;
        break;
      }
      if(b[i+j] == tg[i]){
        swap(b[i], b[i+j]);
        tmp += j;
        break;
      }
    }
  }
  ans = min(ans, tmp);
  cout << ans << endl;
}




Measured memory_bytes: 3164
#include <stdio.h>

int main(void){
  int a,b,c,d,e,k,score;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
  if(b - a <= k){
    score = score + 1;
  }
  if(c - a <= k){
    score = score + 1;
  }
  if(d - a <= k){
    score = score + 1;
  }
  if(e - a <= k){
    score = score + 1;
  }
  if(c - b <= k){
    score = score + 1;
  }
  if(d - b <= k){
    score = score + 1;
  }
  if(e - b <= k){
    score = score + 1;
  }
  if(d - c <= k){
    score = score + 1;
  }
  if(e - c <= k){
    score = score + 1;
  }
  if(d - e <= k){
    score = score + 1;
  }
  if(score == 10){
    printf("Yay!");
  } else {
    printf(":(");
  }
}

Measured memory_bytes: 128
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <bitset>
# include <sstream>
# include <set>
# include <cmath>
# include <algorithm>
#pragma comment(linker,"/STACK:102400000,102400000")
using namespace std;
#define LL          long long
#define lowbit(x)   ((x)&(-x))
#define PI          acos(-1.0)
#define INF         0x3f3f3f3f
#define eps         1e-8
#define MOD         1000000007

inline int scan() {
    int 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;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
#define MX 100005
/**************************/
int n;
LL a[MX];
LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);}
bool check(LL x)
{
    for (int i=0;i<n;i++)
        if (x%a[i]!=0) return 0;
    return 1;
}
int main()
{
    n = scan();

    for (int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    LL yue =a[0];
    LL ans =a[0];
    for (int i=1;i<n;i++)
    {
        yue = gcd(ans,a[i]);
        ans = ans/yue*a[i];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256