akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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 << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n,x,m;
    cin>>n>>x>>m;
    vector<int>ok(m+1,false);
    vector<int>a;
    int cnt=0;
    a.push_back(x);
    ok[x]=true;
    if(n<=m){
        int ans=0;
    for (int i = 0; i < n; i++)
    {
       ans+=x%m;
       x=(x*x)%m;
    }
    cout<<ans<<endl;
    }
    else{
        int num=-1;
        for (int i = 0; i < n; i++)
        {
            x=(x*x)%m;
            if(ok[x]){
                num=x;
                cnt=i+1;
                break;
            }
            ok[x]=true;
            a.push_back(x);
        }
        int id=-1;
        int ans1=0;
        for (int i = 0; i < a.size(); i++)
        {
            if(a[i]==num){
                //ans1+=a[i];
                id=i;
                break;
            }
            ans1+=a[i];
        }
        n-=id;
        int shuki=a.size()-id;
        int ans2=0;
        for (int i = id; i < a.size(); i++)
        {
            ans2+=a[i];
        }
        int ans3=0;
        for (int i = id; i < id + n%shuki; i++)
        {
            ans3+=a[i];
        }
       // show(a);
       // cerr<<ans1<<" "<<ans2<<" "<<ans3<<endl;
        cout<<ans1+ans2* (n/shuki)+ans3<<endl;

        
    }

    return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i) 
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

constexpr static int MOD = 1000000000 + 7;
constexpr static int inf = INT_MAX / 2;
constexpr static llong INF = 1LL<<31;
constexpr static int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, z, w;
    cin >> n >> z >> w;
    vector<int> A(n);
    rep(i, n) cin >> A[i];

    if (n == 1) {
        cout << abs(A[0] - w);
    } else {
        cout << max(abs(A[n - 1] - w), abs(A[n - 2] - A[n - 1]));
    }
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  // input
  int n,k; cin >> n >> k;
  vector<int> x(n);
  vector<int> m(n);
  for(int i = 0;i < n; i++) cin >> x[i]; 
  

  // compute
  int ans = 0;
  for(int i = 0;i < n; i++) m[i] = min(x[i],k-x[i]);
  for(int i = 0;i < n; i++) ans += (2 * m[i]);
 
  // output  
  cout << ans << endl;
  
}

Measured memory_bytes: 3604
// Last Change: 06/29/2019 21:15:10.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll N;
  cin >> N;
  vector<ll> d(N);
  for (auto &&e : d) {
    cin >> e;
  }
  sort(d.begin(), d.end());

  ll ans = 0;

  for (ll i = d[0]; i <= d[N - 1]; ++i) {
    auto itr = lower_bound(d.begin(), d.end(), i);
    ll dist = distance(d.begin(), itr);
    if (dist == N - dist) {
      ++ans;
    }
  }

  cout << ans << endl;

  //NS::LoopUntilZeroInpput();
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main() {
    string str;
    cin >> str;
    int n = 0;
    int w = 0;
    int s = 0;
    int e = 0;
    for(char c : str){
        if(c == 'N') n = 1;
        if(c == 'W') w = 1;
        if(c == 'S') s = 1;
        if(c == 'E') e = 1;
    }
    if((n+s)%2 == 0 && (w+e)%2 == 0) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}


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

#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;

const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

map<ll, ll> prime;

int main(){
    ll n, m, v, p;
    cin >> n >> m >> v >> p;

    vector<ll> a(n);
    rep(i, n)cin >> a[i];

    sort(ALL(a), greater<ll>());

    ll low = p;
    ll high = n;

    while(low < high){
        ll mid = (low + high + 1) / 2;

        ll point = 0;

        rep(i, n){
            if(i < p-1 || i > mid-1)point += m;
            else {
                if(a[i] > a[mid-1] + m){
                    point = -1;
                    break;
                }
                point += (a[mid-1] + m) - a[i];
            }
        }

        if(point >= m*v)low = mid;
        else high = mid-1;
    } 

    cout << low << endl;
}

Measured memory_bytes: 1024
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll mod = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
bool check(string str){
    int n = str.length();
    for(int i = 0; i < n; i++)
        if(str[i] != str[n-1-i])
            return false;
    return true;
}
void solve(){
    string str;
    cin>>str;
    int n = str.length();
    if(check(str) && check(str.substr(0, n/2)) && check(str.substr((n+1)/2)))
        cout<<"Yes";
    else
        cout<<"No";
    
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3604
package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	N := uint8(getInt())
	S := getString()

	var result string
	for i := range S {
		newByte := S[i] + N
		if newByte > 'Z' {
			newByte = 'A' + (newByte - 'Z' - 1)
		}
		result += string(newByte)
	}

	fmt.Println(result)
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  int n, k;
  cin >> n >> k;
  vi h(n);
  rep(i,n) cin >> h[i];
  vi dp(n, inf);
  dp[0] = 0;
  rep(i,n-1) {
    for(int j = 1; i+j < n && j <= k; j++) {
      dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;
using P = std::pair<int, int>;

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

int main(int argc, char *argv[])
{
    // input values
    int N;
    std::cin >> N;

    // dp table
    int dp[550000];

    // init dp table
    for (int i = 0; i < 550000; i++) {
        dp[i] = INF;
    }

    // init condition
    dp[0] = 0;

    // loop
    for (int i = 0; i <= N; i++) {
        chmin(dp[i+1], dp[i]+1);
        for (int pow6 = 6; pow6 <= N; pow6*=6) {
            chmin(dp[i+pow6], dp[i]+1);
        }
        for (int pow9 = 9; pow9 <= N; pow9*=9) {
            chmin(dp[i+pow9], dp[i]+1);
        }
    }

    std::cout << dp[N] << std::endl;
    return 0;
}

Measured memory_bytes: 2432
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1 << 20);
static const int WHITE = 0;
static const int BLACK = 2;
static const int GRAY = 1;
int n;
vector<pair<int,int> > adj[MAX];

void dijkstra() {
    priority_queue<pair<int,int> > PQ;
    int d[MAX], color[MAX];
    for (int i = 0; i < n; i++) {
        d[i] = INFTY;
        color[i] = WHITE;
    }
    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = GRAY;
    while (!PQ.empty()) {
        pair<int,int>f=PQ.top();PQ.pop();
        int u = f.second;
        color[u] = BLACK;
        if(d[u]<f.first*(-1))continue;
        
        for (int j = 0; j < adj[u].size(); j++) {
            int v=adj[u][j].first;
            if (color[v] == BLACK)continue;
            if(d[v]>d[u]+adj[u][j].second){
                d[v]=d[u]+adj[u][j].second;
                PQ.push(make_pair(d[v]*(-1),v));
                color[v]=GRAY;
            }
        }
    }
    for (int i = 0; i < n; i++) {
        cout << i << " " << (d[i] == INFTY ? -1 : d[i]) << endl;
    }
}


int main(void) {
    cin >> n;
    int k, c, u, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }
    dijkstra();
    return 0;
}



Measured memory_bytes: 8092
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static AtCoderTemplate.MyLibrary;
using System.Numerics;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main (string[] args)
        {
            string[] str = Console.ReadLine ().Split (' ');
            int N = int.Parse (str[0]);

            str = Console.ReadLine ().Split (' ');
            BigInteger[] A = new BigInteger[N];
            BigInteger ans = 1;

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

                A[i] = BigInteger.Parse (str[i]);
                if (A[i] == 0)
                {
                    Console.WriteLine (0);
                    return;
                }
            }

            BigInteger b = (BigInteger) Math.Pow (10, 9) * (BigInteger) Math.Pow (10, 9);

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

                ans *= A[i];
                if (ans > b)
                {
                    Console.WriteLine (-1);
                    return;
                }
            }
            Console.WriteLine (ans);

        }
    }

    class MyLibrary
    {

        // 自作の関数
        public static int MyFunction (int n)
        {
            return 0;
        }
    }
}

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

int main() {
  int H, W; cin >> H >> W;
  vector<string> S(H); for (int i = 0; i < H; i++) cin >> S[i];
  
  int num = H+W-1;
  int ret = 0;
  for (string s : S) {
    for (char a : s) {
      if (a == '#') ret++;
    }
  }
  
  if (ret == num) cout << "Possible" << endl;
  else cout << "Impossible" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  double d, t, s;
cin>> d >>t >> s;
  if(d/s <= t ) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

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

int n;
int A[20][20][2];
int ai[20];
int res = 0;

int popcount(int x) { //stlで見つからなかったのでコピペ。見つけたい
 x = (x & 0x55555555) + (x >> 1 & 0x55555555);  
 x = (x & 0x33333333) + (x >> 2 & 0x33333333);  
 x = (x & 0x0F0F0F0F) + (x >> 4 & 0x0F0F0F0F);  
 x = (x & 0x00FF00FF) + (x >> 8 & 0x00FF00FF);  
 x = (x & 0x0000FFFF) + (x >> 16 & 0x0000FFFF);  
  
 return x;  
}

bool isContradict(int flag, int a){ //a番目の人の証言はすべて成立するか？
  //フラグが立っている人の証言を正しいと仮定し、実際の証言と矛盾がないか確かめる
  //矛盾がある場合trueを返す
  int n = ai[a]; //証言の数
  //cout << "size: "<< n << " ";
  rep(i, n){
    int num = A[a][i][0]; //何人目について矛盾を判定するか
    //cout <<num << ": "<<  (1 << num) <<" "<< A[a][i][1]<<endl;
    if(((flag >> num) & 1) != A[a][i][1]){
      return true; //矛盾する
    }
  }
  return false;
}

int main(){
  cin >> n;
  rep(i, n){
    cin >> ai[i];
    int a = ai[i];
    rep(j, a){
      cin >> A[i][j][0] >> A[i][j][1];
      A[i][j][0]--; //0-indexedにする
      //cout << A[i][j][0] <<" "<<  A[i][j][1]<<endl;
    }
    //cout <<endl;
  }

  for(int S = 0; S < (1 << n); S++){ //n - 1じゃなくて n
    bool flg = true; //条件Sで全ての証言について成立する（矛盾しない）か
    //cout << S <<endl;
    for(int i = 0; i < n; i++){
      if(!((S >> i) & 1)){ //論理とビット演算子ごちゃまぜっていいの？
        continue;
      }
      if(isContradict(S, i)){ //条件Sのi人目の証言が成立するか
        flg = false;
        continue;
      }
    }
    //cout << endl;
    if(flg) {
      res = max(res, popcount(S));
      //cout << popcount(S) <<" "<<endl;
    }
  }
  cout << res << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
long gcd(long a,long b){
  if(a<b){
    long w=a;
    a=b;
    b=w;
  }
  if(a%b!=0)return gcd(b,a%b);
  else return b;
}
int main(void){
  long a,b;
  scanf("%ld%ld",&a,&b);
  long ab=gcd(a,b);
 // printf("%ld\n",ab);
  long w=ab;
  long c=0;
  for(long q=2;q*q<=ab;q++){
		if(w%q==0){//printf("%dを因子に持つ\n",q);
          c++;
                   while(w%q==0){w/=q;           
                  }
  }
}
  if(w>1)c++;
printf("%ld",c+1);
return 0;
}

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

typedef long long	 		ll;
typedef unsigned long long	llu;
typedef long double			ld;
typedef vector< int > 		vi;
typedef vector< ll > 		vll;
typedef vector <llu>		vllu;
typedef vector< vi >		vvi;
typedef pair<int, int> 		pii;
//typedef tuple<int,int,int>  tiii;

#define pb push_back
#define sq(a) a*a
#define fl(i,a,b) for(int i=a;i<b;i++)
#define flp(i, n) 	for(int i=0; i<n; i++)
#define endl '\n'
#define iyas_salah ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(n)	v.begin(),v.end()

bool isp(int n)
{
    for(int i=2;i<=n/2;i++)
    {
        if (n%i==0)
            return false;
    }
    return true;
}
 
int gcd(int x,int y){
  if(y==0)
    return x;
  return gcd(y,x%y);	
}
ll power(ll b,ll p)
{	
	if (p == 0)
		return 1;
	if(p % 2 == 0){
		ll ans=power(b, p/2);
		return (ans*ans);
	}
	return (b*power(b ,p-1));
}
 
 
int maxSum(vector<int>&arr, int n, int k) 
{   	
    int res = 0; 
    for (int i=0; i<k; i++) 
       res += arr[i]; 
    int curr_sum = res; 
    for (int i=k; i<n; i++) 
    { 
       curr_sum += arr[i] - arr[i-k]; 
       res = min(res, curr_sum); 
    } 
    return res; 
} 

bool is_open(char ch){
	return ch == '{' || ch == '(' || ch == '<' || ch == '[';
}
int main()
{  
	string s;
	cin>> s;
	if(s[2]==s[3] and s[5]==s[4])cout<< "Yes"<<endl;
	else	cout << "No"<<endl;



	#ifndef ONLINE_JUDGE
		system("pause");
	#endif
	return 0;	
}
	












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

int main() {
	int N, K;
	cin >> N >> K;
	int i=N/K;
	long s=pow(i,3);
	if(K%2==0){
	    int j=(N+K/2)/K;
	    s += pow(j,3);
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
INF = 10**12
param = []
for i in range(n):
    a, b, c = map(int, input().split())
    param.append([a, b, c])

dp = [[-INF] * 3 for i in range(n + 1)]
dp[0][0] = 0
dp[0][1] = 0
dp[0][2] = 0

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue

            dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + param[i][k])
print(max(dp[-1][0], dp[-1][1], dp[-1][2]))


Measured memory_bytes: 74968
n = int(input())
L = list(map(int,input().split()))
L.sort()
T = []
plus = []
minus = []
for i in range(n):
  if L[i] >= 0:
    plus.append(L[i])
  else:
    minus.append(L[i])
if len(L) == 2:
  if len(plus) == len(minus):
    print(plus[0]-minus[0])
    print(plus[0],minus[0])
  elif len(plus) == 2:
    print(plus[1]-plus[0])
    print(plus[1],plus[0])
  else:
    print(minus[1]-minus[0])
    print(minus[1],minus[0])
else:
  if len(plus) != 0 and len(minus) != 0:
    if min(len(plus),len(minus)) >= 2:
      T.append([minus[0],plus[0]])
      cur = minus[0]-plus[0]
      for i in range(1,len(plus)-1):
        T.append([cur,plus[i]])
        cur = cur-plus[i]
      T.append([plus[len(plus)-1],cur])
      cur = plus[len(plus)-1]-cur
      for i in range(1,len(minus)):
        T.append([cur,minus[i]])
        cur = cur-minus[i]
      print(cur)
      for i in range(len(T)):
        print(T[i][0],T[i][1])
    else:
      if len(minus) == 1:
        cur = minus[0]
        T.append([cur,plus[0]])
        cur = cur-plus[0]
        for i in range(1,len(plus)-1):
          T.append([cur,plus[i]])
          cur = cur-plus[i]
        T.append([plus[len(plus)-1],cur])
        cur = plus[len(plus)-1]-cur
        print(cur)
        for i in range(len(T)):
          print(T[i][0],T[i][1])
      else:
        cur = plus[0]
        T.append([cur,minus[0]])
        cur = cur-minus[0]
        for i in range(1,len(minus)):
          T.append([cur,minus[i]])
          cur = cur-minus[i]
        print(cur)
        for i in range(len(T)):
          print(T[i][0],T[i][1])
  elif len(plus) == 0:
    cur = minus[len(minus)-1]
    for i in range(n-1):
      T.append([cur,minus[n-i-2]])
      cur = cur-minus[n-i-2]
    print(cur)
    for i in range(len(T)):
      print(T[i][0],T[i][1])
  else:
    cur = plus[0]
    for i in range(1,n-1):
      T.append([cur,plus[i]])
      cur = cur-plus[i]
    T.append([plus[n-1],cur])
    cur = plus[n-1]-cur
    print(cur)
    for i in range(len(T)):
      print(T[i][0],T[i][1])

Measured memory_bytes: 23292
#include <iostream>
//#include<cmath>
//#include<algorithm>
//#include<vector>
using namespace std;

int main() {
	string S;
	cin >> S;
	switch (S[0]) {
	case 'S':
		cout << "Cloudy";
		break;
	case 'R':
		cout << "Sunny";
		break;
	case 'C':
		cout << "Rainy";
		break;
	}
}


Measured memory_bytes: 256
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public void main() {
        Scanner sc = new Scanner(new InputStreamReader(System.in));

        String os[] = sc.nextLine().split("");
        String es[] = sc.nextLine().split("");

        for (int i = 0; i < es.length; i++) {
            print(os[i]);
            print(es[i]);
        }

        if (os.length != es.length) {
            print(os[os.length - 1]);
        }

        println("");
    }

    public void print(Object o) {
        System.out.print(o);
    }

    public void println(Object o) {
        System.out.println(o);
    }

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


Measured memory_bytes: 21716
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+18;
ll n,m,l;
string s,t;
ll d[100000],dp[500][500];

int main(){
  cin >> n >> m;
  if(n % m == 0)puts("-1");
  else{
    print(n * 100000007);
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define sz(a) (int)(a).size()
 
using namespace std;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int INF = 1e5+2;
const long long hell = 998244353ll;

void solve(){
	int a,b;
	char c;
	cin >> a >> c >> b;
	if(c=='-') cout << a-b << endl;
	else cout << a+b << endl;	
}
int main(){
    	
	ios_base::sync_with_stdio(0);cin.tie(0);
    	
	int q=1;
#ifdef LOCAL
  	cin>>q;
#endif
  	while(q--){
  		solve();
  	}
#ifdef LOCAL
   	cout << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms.\n";
#endif	
	return 0;
}

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

int main() {
    int n,ans=0;cin>>n;
    if(n%10==7)ans=1;
    n/=10;
    if(n%10==7)ans=1;
    n/=10;
    if(n%10==7)ans=1;
    
    if(ans==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

	return 0;
}

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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll play = 0;
  if ((A-B) % 2 == 0) {
    play = max(A-B, B-A) / 2;
  }
  else {
    if (min(A,B) - 1 < N - max(A,B)) {
      ll p1 = min(A,B);
      ll p2 = max(A-B, B-A) / 2;
      play = p1 + p2;
    }
    else {
      ll p3 = N + 1 - max(A,B);
      ll p4 = max(A-B, B-A) / 2;
      play = p3 + p4;
    }
  }
  
  cout << play << endl;
}

Measured memory_bytes: 256
using System;

namespace InsertionSort
{
	class MainClass
	{
		public static void trace(ref int[] arr) {
			for (int i = 0; i < arr.Length; ++i) {
				if (i > 0)
					Console.Write (" ");
				Console.Write (arr [i]);
			}
			Console.WriteLine ();
		}

		public static void Main (string[] args)
		{
			int n = int.Parse (Console.ReadLine ());
			string[] nums = (Console.ReadLine ()).Split (' ');
			int[] arr = new int[n];
			for (int i = 0; i < n; ++i)
				arr [i] = int.Parse (nums [i]);

			trace (ref arr);

			insertionSort (ref arr);

		}

		//
		// insertion sort
		//
		public static void insertionSort(ref int[] arr) {

			for (int i = 1; i < arr.Length; ++i) {

				int a_i = arr [i];
				int j = i - 1;
				while (j >= 0 && arr[j] > a_i) {
					arr [j + 1] = arr [j];
					--j;
				}
				arr [j + 1] = a_i;

				trace (ref arr);
			}

		}

	}
}

Measured memory_bytes: 9116
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(x: int, y: int):
    table = [0]*13
    table[2] = 2
    table[4] = 1
    table[6] = 1
    table[9] = 1
    table[11] = 1
    if table[x] == table[y]:
        yes()
    else:
        no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    x = int(next(tokens))  # type: int
    y = int(next(tokens))  # type: int
    solve(x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
	int a,b,c,d,e;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
	if(a>=c+e && b>=d+e && c-e>=0 && d-e>=0){
		puts("Yes");
	}else{
		
		puts("No");
	}
	return 0;
}



Measured memory_bytes: 2136
A, B = map(int, input().split())

grid = [["." for _ in range(100)] for _ in range(100)]

# 上半分（50*100）を黒で、下半分(50*100)を白で埋める
for r in range(50):
    for c in range(100):
        grid[r][c] = "#"

# 上の(49*100)において、A-1マスを白に塗り替える
cnt_w = 1
for r in range(0, 49, 2):
    for c in range(100):
        if cnt_w < A:
            if c % 2 == 0:
                grid[r][c] = "."
                cnt_w += 1
        else:
            break

# 下の(49*100)において、B-1マスを黒に塗り替える
cnt_b = 1
for r in range(51, 100, 2):
    for c in range(100):
        if cnt_b < B:
            if c % 2 == 0:
                grid[r][c] = "#"
                cnt_b += 1
        else:
            break

print(100, 100)
for r in range(100):
    print("".join(grid[r]))


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

int main(){
    int N;std::cin>>N;
    std::vector<int> x(N),y(N);
    for(int i=0;i<N;++i) std::cin>>x[i]>>y[i];
    std::vector<int> ord(N);
    std::iota(begin(ord),end(ord),0);
    double ans=0;
    do{
        double tmp=0;
        for(int i=0;i+1<N;++i) tmp+=sqrt(pow(x[ord[i]]-x[ord[i+1]],2)+pow(y[ord[i]]-y[ord[i+1]],2));
        ans+=tmp;
    }while(next_permutation(begin(ord),end(ord)));
    for(int i=1;i<N;++i) ans/=i+1;
    printf("%.16f\n",ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define REPe(i, n) for(int i = 0; i <= (int)(n); ++i)
#define REPi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define REPei(i, a, b) for(int i = int(a); i <= int(b); ++i)

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

    string s;
    int flag = 0;
    cin >> s;

    REPi(i, 1, s.length()) {
        if((s.length()-i)%2 == 0) {
            int center = (s.length() - i)/2;
            int tmpFlag2 = 0;
            REP(i, center) {
                if(s[i] == s[center + i])tmpFlag2++;
            }
            if(tmpFlag2 == center) {
                flag = s.length() - i;
                break;
            }
        }
    }
    cout << flag << '\n';

}



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

#define MAX 500000
#define SENTINEL 2000000000

vector<int> L(MAX/2+2),R(MAX/2+2);
int cnt;

void merge(vector<int> *A,int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i = 0; i < n1; i++) L.at(i) = (*A).at(left + i);
    for(int i = 0; i < n2; i++) R.at(i) = (*A).at(mid + i);
    L.at(n1) = R.at(n2) = SENTINEL;
    int i = 0, j = 0;
    for(int k = left; k < right; k++){
        cnt++;
        if(L.at(i) <= R.at(j)){
            (*A).at(k) = L.at(i);
            i++;
            
        }else{
            (*A).at(k) = R.at(j);
            j++;
            
        }
    }
}

void mergeSort(vector<int> *A, int n, int left, int right){
    if(left + 1 < right){
        int mid = (left + right)/2;
        mergeSort(A,n,left,mid);
        mergeSort(A,n,mid,right);
        merge(A,n,left,mid,right);
    }
}

int main(){
    vector<int> A(MAX);
    int n;
    cnt = 0;
    
    cin >> n;
    for(int i = 0;i<n;i++) cin >> A.at(i);

    mergeSort(&A,n,0,n);
    for(int i = 0;i<n;i++){
        if(i) cout << " ";
        cout << A.at(i);
    }

    cout << endl;

    cout << cnt << endl;

    return 0;
}




Measured memory_bytes: 6628
#include <iostream>
using namespace std;
int main(){
int a,b,c,d;
int x;
cin>>a>>b>>c>>d;
if(a<=c){
if(b<c)x=0;
else if(b<=d)x=b-c;
else x=d-c;
}
else if(a>c){
if(d<a)x=0;
else if(b>=d)x=d-a;
else x=b-a;
}
cout<<x<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<iomanip>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{"; for(auto nth : list){ cout << nth << " ";}cout << "}" << endl;

using namespace std;

int main(){

	while(true){
		int a,b;
		cin >> a >> b;
				
		if(a==0&&b==0) break;

		int card[a];
		
			for(int i=a;0<i;i--){
				card[a-i]=i;
			}
			for(int i=0;i<b;i++){
				int c,d;
				cin >> c >> d;
				rotate(card,card+c-1,card+c+d-1);
			}
			cout << card[0] << endl;

	}
}

Measured memory_bytes: 1180
n, w_max = map(int, input().split())
W, V = [], []
Diff_zero = []
Diff_one = []
Diff_two = []
Diff_three = []
for i in range(n):
    w, v = map(int, input().split())
    W.append(w)
    V.append(v)
    diff = w - W[0]
    if diff == 0:
        Diff_zero.append(v)
    elif diff == 1:
        Diff_one.append(v)
    elif diff == 2:
        Diff_two.append(v)
    elif diff == 3:
        Diff_three.append(v)

Diff_zero = sorted(Diff_zero, reverse=True)
Diff_one = sorted(Diff_one, reverse=True)
Diff_two = sorted(Diff_two, reverse=True)
Diff_three = sorted(Diff_three, reverse=True)

Diff_zero_ruiseki = [0]
Diff_one_ruiseki = [0]
Diff_two_ruiseki = [0]
Diff_three_ruiseki = [0]

for i in range(len(Diff_zero)):
    Diff_zero_ruiseki.append(Diff_zero[i] + Diff_zero_ruiseki[-1])
for i in range(len(Diff_one)):
    Diff_one_ruiseki.append(Diff_one[i] + Diff_one_ruiseki[-1])
for i in range(len(Diff_two)):
    Diff_two_ruiseki.append(Diff_two[i] + Diff_two_ruiseki[-1])
for i in range(len(Diff_three)):
    Diff_three_ruiseki.append(Diff_three[i] + Diff_three_ruiseki[-1])

value_max = 0
w_zero = W[0]

for i in range(n+1):
    if i > len(Diff_zero):
        continue
    for j in range(n+1):
        if j > len(Diff_one):
            continue
        for k in range(n+1):
            if k > len(Diff_two):
                continue
            for l in range(n+1):
                if l > len(Diff_three):
                    continue
                if w_zero*i + (w_zero+1)*j + (w_zero+2)*k + (w_zero+3)*l > w_max:
                    continue
                if i + j + k + l > n:
                    continue

                value = Diff_zero_ruiseki[i] + Diff_one_ruiseki[j] + Diff_two_ruiseki[k] + Diff_three_ruiseki[l]
                value_max = max(value, value_max)

print(value_max)


             


Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define x real()
#define y imag()
using namespace std;
typedef complex<double> point;
vector <point> pl;
 
double dot(point a,point b){return a.x*b.x+a.y*b.y;}
double cross(point a,point b){return a.x*b.y-a.y*b.x;}
int ccw(point a,point b,point c){
  point d = b-a,e = c-a;
  if(cross(d,e)>0) return 1;//"COUNTER_CLOCKWISE"
  if(cross(d,e)<0) return -1;//"CLOCKWISE"
  if(dot(d,e)<0) return 2;//"ONLINE_BACK"
  if(abs(d) < abs(e)) return -2;//"ONLINE_FRONT"
  return 0;//"ON_SEGMENT"
}
 
point crosspoint(point a,point b,point c,point d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
 
bool intersection(point a,point b,point c,point d){
  return (ccw(a,b,c)*ccw(a,b,d)<=0&&ccw(c,d,a)*ccw(c,d,b)<=0);
}
 
vector<point> ConvexCut(vector<point> &polygon,point a,point b){
  vector <point> res;
  for(int i=0;i<polygon.size();i++){
    point A=polygon[i],B=polygon[(i+1)%polygon.size()];
    if(ccw(a,b,A)!=-1)res.push_back(A);
    if(ccw(a,b,A)*ccw(a,b,B)==-1)res.push_back(crosspoint(a,b,A,B));
  }
  return res;
}
 
double get_area(vector <point> &polygon){
  if(polygon.size()<3)return 0;
  double res=0;
  for(int i=0;i<polygon.size();i++)
    res+=cross(polygon[i],polygon[(i+1)%polygon.size()])/2;
  return res;
}
 
 
int main(){
  int n;
  cin>>n;
  for(int i=0,a,b;i<n;i++) cin>>a>>b,pl.push_back(point(a,b));
 
  int m;
  cin>>m;
  for(int i=0,c,d;i<m;i++){
    cin>>c>>d;
    point a,b;
    a=point(c,d);
    cin>>c>>d;
    b=point(c,d);
    vector<point> res=ConvexCut(pl,a,b);
    printf("%.8f\n",get_area(res));
  }
 
 
  return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

const int INF = 1e6 + 7;

int solve(vector<pair<int, int>> a, int d) {
    //
    if (a.empty()) {
        return abs(d);
    }
    int n = (int)a.size();
    int ans = INF;
    sort(a.begin(), a.end());
    vector<int> sm(n + 1);
    sm[n] = 0;
    for (int i = n - 1; i >= 0; i--) {
        sm[i] = max(sm[i + 1], a[i].second);
    }
    for (int len = 0; len <= n; len++) {
        int l = 0;
        if (len > 0) {
            l = a[len - 1].first;
        }
        int r = sm[len];
        if (d < 0) l = max(l, abs(d));
        if (d > 0) r = max(r, abs(d));
        ans = min(ans, l + r);
    }
    return ans;
}

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

    string ta, tb;
    cin >> ta >> tb;
    int n = (int)ta.size();
    vector<int> a(n);
    vector<int> b(n);
    int sa = 0, sb = 0;
    for (int i = 0; i < n; i++) {
        a[i] = (ta[i] == '1');
        b[i] = (tb[i] == '1');
        sa += a[i];
        sb += b[i];
    }
    if (sb == 0) {
        if (sa) cout << -1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    vector<int> l(n, -1);
    vector<int> r(n, -1);
    for (int i = 0; i < n; i++) {
        int ci = i;
        for (int len = 0; len <= n; len++) {
            if (b[ci]) {
                r[i] = len;
                break;
            }
            ci = (ci + 1) % n;
        }
        ci = i;
        for (int len = 0; len <= n; len++) {
            if (b[ci]) {
                l[i] = len;
                break;
            }
            ci = (ci - 1 + n) % n;
        }
    }
    int ans = INF;
    for (int d = -n; d <= n; d++) {
        int sw = 0;
        vector<pair<int, int>> keks;
        for (int i = 0; i < n; i++) {
            int v = (b[(i + d + n) % n]);
            if (a[i] != v) {
                sw++;
                keks.push_back({l[i], r[i]});
            }
        }
        int add = 2 * solve(keks, d) - abs(d);
        ans = min(ans, add + sw);
    }
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}   


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

using namespace std;
using ll = long long;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    int N;
    cin >> N;
    int sum = 0;

    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        sum += r - l + 1;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
typedef long long ll;

using namespace std;

int main(){
  int N;
  cin >> N;
  int A[N];
  ll sum_A = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] -= i + 1;
    sum_A += A[i];
  }

  sort(A, A + N);
  ll ans = 0;
  if (N % 2 == 1) {
    int num_center = A[(N - 1) / 2];
    for (int i = 0; i < N; i++) ans += abs(A[i] - num_center);
  }
  else {
    int num_center = A[N / 2 - 1];
    for (int i = 0; i < N; i++) ans += abs(A[i] - num_center);
    ll ans2 = 0;
    num_center = A[N / 2];
    for (int i = 0; i < N; i++) ans2 += abs(A[i] - num_center);
    ans = min(ans, ans2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
//g++  5.4.0

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
   
      for(int i=1;i<=9;i++){
        int b=n/i;
        int rem=n%i;  
          if(rem==0 and  b<=9 and b>=1){
              cout<<"Yes";
          return 0;
          }
      }
    cout<<"No";   
}

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

using mint = modint998244353;
const int MOD = 998244353;
const int INF = 1 << 30;

// モノイド
struct S {
    mint value, power10;
};
S op(S a, S b) { return S{a.value * b.power10 + b.value, a.power10 * b.power10}; }
S e() { return S{0, 1}; }

// 作用素
using F = int;
F id() { return INF; }
S mapping(F f, S x) {
    // 値を f に変えるという作用を f とする
    if (f == id()) return x;
    return S{(x.power10 - 1) * inv_mod(9, MOD) * f, x.power10};
}
F composition(F f, F g) {
    // f o g
    if (f == id()) return g;
    return f;
}

int main() {
    int N, Q;  cin >> N >> Q;
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(N);
    for (int i = 0; i < N; ++i) {
        seg.set(i, S{1, 10});
    }
    // DUMP(seg.all_prod().value.val());
    for (int _ = 0; _ < Q; ++_) {
        int l, r, d;  cin >> l >> r >> d;
        seg.apply(l - 1, r, d);
        cout << seg.all_prod().value.val() << endl;
    }
}


Measured memory_bytes: 9816
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, ans = 0;
	cin >> n;
	int s[n];
	for (int i = 0; i < n; i++) {
		cin >> s[i];
		ans += s[i];
	}
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		if (ans % 10 == 0) {
			if (s[i] % 10 != 0) {
				ans -= s[i];
			}
		} else {
			cout << ans << endl;
			return 0;
		}
	}
	cout << 0 << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
ll n, m;

ll xorr(ll a)
{
    if (a % 4 == 1) 
		return 1;
    else if (a % 4 == 2) 
		return a + 1;
    else if (a % 4 == 3 || a == 0) 
		return 0;
    else 
		return a;
}

int main()
{
    cin >> n >> m;
    if (n == 0) 
		cout << xorr(m) << endl;
    else 
		cout<< (xorr(n - 1) ^ xorr(m)) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
H = []
W = []

for l in sys.stdin:
    Ha, Wa = map(int, l.split())
    if Ha == 0 and Wa == 0:
        break
    H.append(Ha)
    W.append(Wa)

for i, numH in enumerate(H):
    for num in range(numH):
        if (num == 0) or (num == numH - 1):
            print("#" * W[i])
        else:
            sharp = "#"
            dot = "." * (W[i] - 2)
            print("{0}{1}{0}".format(sharp, dot))
    print()


Measured memory_bytes: 5624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    long long x; cin >> x;
    long long s = 100;
    int n = 0;
    while (s < x)
    {
        s += s / 100;
        n++;
    }

    cout << n << endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int gcd(int a, int b){
    if(a<b) return gcd(b,a);
    if(a%b==0) return b;
    return gcd(b,a%b);
}

int main(){
    int x,y;
    cin >> x >> y;
    cout << gcd(x,y) << endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
ll a[N];
int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++) {
		scanf("%lld",&a[i]);
		a[i]>>=1;
	}
	bool f=true;
	ll t=1;
	for(int i=0;i<n;i++) {
		ll g=__gcd(a[i],t);
		t=t/g*a[i];
		if(t>m) f=false;
	}
	for(int i=0;i<n;i++) {
		if(t/a[i]%2==0) f=false;
	}
	if(!f) printf("0\n");
	else {
		int ans=m/t/2;
		if((m/t)&1) ans++;
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define reg register

using namespace std;

typedef long long ll;
const int maxn = 100005;

inline ll read() {
    reg ll s = 0, t = 0; reg char ch = getchar();
    while (!isdigit(ch)) t |= ch == '-', ch = getchar();
    while (isdigit(ch)) s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}

struct man { int id, num; } p[maxn];

inline bool cmp(man x, man y) { return x.num < y.num; }

int main() {
    reg int n = read();
    for (reg int i = 1; i <= n; i++) p[i].num = read(), p[i].id = i;
    sort(p + 1, p + n + 1, cmp);
    for (reg int i = 1; i <= n; i++) cout << p[i].id << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
int h,w;
string s;

int main(){
	cin >> h >> w;
	REP(i,1,h+1) for(char j='A';j<'A'+w;j++){{cin >> s; if(s=="snuke"){cout << j << i << endl; return 0;}}}
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}


int main(){
    ll n,ans=INF;
    cin >> n;
    ll x[n];
    for (ll i=0;i<n;i++)cin >> x[i];
    for (ll i=0;i<101;i++){
        ll c=0;
        for (ll j=0;j<n;j++){
            c+=(i-x[j])*(i-x[j]);
        }
        ans=min(ans,c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import collections

s=input()
a=collections.Counter(s)
f=True

if a['N']>0:
	if a['S']==0:
		f=False
		
if a['S']>0:
	if a['N']==0:
		f=False
		
if a['W']>0:
	if a['E']==0:
		f=False
		
if a['E']>0:
	if a['W']==0:
		f=False
		
if f:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3316
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑


int main() {
	int n;
	cin >> n;
	cout << pow(n, 3) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  V<> di{1, 0, -1, 0}, dj{0, 1, 0, -1};
  while (true) {
    int n, m; cin >> n >> m;
    if (!n) break;
    V<string> s(n + 2, string(m + 2, '#'));
    for (int i = 1; i <= n; ++i) {
      cin >> s[i];
      s[i] = '#' + s[i] + '#';
    }
    VV<> vis(n + 2, V<>(m + 2));
    auto fn = [&](int si, int sj, int ti, int tj, int d0) -> bool {
      int i = si, j = sj, d = d0;
      VV<bool> b(n + 2, V<bool>(m + 2));
      for (int _ = 0; _ < 4 * n * m; ++_) {
        int ni = i + di[d], nj = j + dj[d];
        if (s[ni][nj] == '#') d = d + 1 & 3;
        else {
          d = d - 1 & 3;
          i = ni, j = nj;
          if (i == ti and j == tj) {
            for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) {
              vis[i][j] += b[i][j];
            }
            return true;
          }
          b[i][j] = true;
        }
      }
      return false;
    };
    [&]{
      if (!fn(1, 1, n, 1, 0) or !fn(n, 1, n, m, 1) or !fn(n, m, 1, m, 2) or !fn(1, m, 1, 1, 3)) {
        cout << "NO" << '\n';
        return;
      }
      for (int i = 1; i <= n; ++i) for (int j = 1; j <= m; ++j) if (vis[i][j] > 1) {
        cout << "NO" << '\n';
        return;
      }
      cout << "YES" << '\n';
    }();
  }
}


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

using namespace std;

int main()
{

   int n;
   cin >> n;

   int x[n+2];

   int sum = 0;

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

      sum += x[i];
   }

   int avg = sum / n;

   int ans = 0, store = INT_MAX;

   for(int j = 1; j < avg + 5; j++)
   {
        ans = 0;
        for(int i = 0; i < n; i++)
        {
            int p = abs(x[i]-j);
            ans += p * p;
        }
       // cout << ans << endl;

      store = min(store, ans);
   }

   //cout << ans << " " << ans1 << endl;

   cout << store << endl;

    return 0;
}


Measured memory_bytes: 256