akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

int main(){
  int h,w;
  cin >> h >> w;
  int a = (h%2)*(w%2); 
  int b = (h%2)*(w/2) + (w%2)*(h/2);
  int c = (w/2)*(h/2);
  map<char,int> mp;
  rep(i,h*w){
    char c;
    cin >> c;
    mp[c]++;
  }
  for(auto& it:mp){
    while(it.S>0){
      if(it.S%4 == 1 || it.S%4 == 3){
        it.S--;
        a--;
      } else if(it.S%4 == 2 || (it.S%4 == 0 && c==0)) {
        it.S -= 2;
        b--;
      } else if(it.S%4 == 0 && c>0){
        it.S -= 4;
        c--;
      }
    }
  }
  if(a==0 && b==0 && c==0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys

MOD=10**9+7

n=int(input())  
a=[int(i) for i in sys.stdin.readline().split()]

from fractions import gcd
m=a[0]
for i in a:
  m=i//gcd(m,i)*m
  
ans=0
for i in a:
  ans+=m//i

print(ans%MOD)

Measured memory_bytes: 5596
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<(n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) (s.substr(f-1,t-f+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{ll x,y,t;};
struct Edge{ll to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=201010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(ll from,ll to,ll cost){E[from].pb({to,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  if(n==2)cout<<-1<<endl;
  else if(n%2==0){
    vvi ans(110);
    for(int i=0;i<n;i++){
      for(int j=1;j<(n-1);j++){
	if(j==(n/2)-1)continue;
	ans[i].pb((j+1+i)%n+1);
	//ans[i].pb((j+1+i+n/2)%n+1);
      }
    }
    for(int i=0;i<n;i++){
      for(ll a:ans[i]){
	cout<<a<<" ";
      }
      if(i<n/2)
	cout<<(i+1)%n+1<<" "<<(i+n/2)%n+1;
      else
	cout<<(i+n/2)%n+1<<" "<<(i+1)%n+1;
      cout<<endl;
    }
  }else{
    for(int i=0;i<n;i++){
      for(int j=0;j<n-1;j++){
	cout<<(j+1+i)%n+1<<" ";
      }
      cout<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x)  (long long)(x).size()
#define sqr(x) (x)*(x)
#define sof sizeof
#define ins insert
#define lowerB lower_bound
#define upperB upper_bound
#define mkp make_pair
#define mkt make_tuple
#define act(a,v) (get<(long long)a>(v))
#define mod 1000000007
#define mod1 998244353
#define N 1000003
#define inf 1e18
#define minf -1e18
#define min3(a,b,c) min(a,min(b,c));
#define max3(a,b,c) max(a,max(b,c));
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define sumall(v) accumulate(all(v),(ll)0)
#define sum accumulate
#define FastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI M_PI
#define fi first
#define se second
#define here cout<<"RSSB"<<endl
#define showzero cout<<std::showpoint
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define br "\n"
#define sp " "
#define zero (ll)0
using namespace  std ;
typedef double db;
typedef long long ll ;
typedef vector<int>vi ;
//typedef vector<l>vl ;
typedef vector<ll>vll ;
typedef vector<vector<ll> >vvl ;
typedef pair<int,int> pii ;
typedef pair<ll,ll> pll ;
typedef vector<pll>vpll;
typedef vector<string>vstr;
typedef vector<bool>vbool ;
void READ(vll &v, ll n)
{
    ll a ;
    for(ll i=0 ; i<n ; i=i+1)
    {
        cin>>a ;
        v.pb(a) ;
    }
}
void PRINT(vll &v , ll a = 0)
{
    //ll a ;
    for(ll i=a ; i<v.size() ; i=i+1)
    {
        v[i] = max((ll)0,v[i]);
        cout<<v[i]<<" " ;
    }
    cout<<"\n" ;
}
/*vbool isprime(N,true);
vll spf(N,0);
vll prime;
void sieve()
{
    isprime[0] = isprime[1] = false;
    for(ll i = 2 ; i<N ; i++)
    {
        if(isprime[i])
        {
            for(ll j=2*i ; j<N ; j+=i)
            {
                isprime[j] = false;
                if(spf[j]==0)
                {
                    spf[j] = i;
                }
            }
            prime.pb(i);
        }
    }
}*//*
ll nck(ll n , ll k ,ll m=1e18+7)
{
    ll i , j,b=1,c=1 ;
    if(n-k<k)
    {
        k = n-k ;
    }
    while(k)
    {
        b*=n ;
        c*=k ;
        ll g = __gcd(b,c) ;
        b/=g ;
        c/=g ;
        n--;
        k-- ;
    }
    return(b) ;
}*//*
long long power(long long k , long long n , long long m=mod)
{
    long long res = 1;
    while(n)
    {
        if(n%2!=0)
        {
            res = (res*k)%m ;
        }
        k = (k*k)%m ;
        n = n/2 ;
    }
    return(res) ;
}*/
ll n,m,k,l,r;
bool ok = false;
int main()
{
    FastIO ;
    PRECISION ;
    ll a,b,c,d,i,j,t,x,y,z;//,x1,y1,z1,e,f;
    ll p,q,r,u,w ;
    char ch,chr ;
    string str,st,str1,str2,str3,str4;
    //ll a1=0,a2=0,b1=0,b2=0,c1=0 ;
    //cin>>str>>str1;
    cin>>a>>b;
    if(a<=b)
    {
        cout<<"unsafe";
    }
    else
    {
        cout<<"safe";
    }
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


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

	string S;
	int N;
	cin >> S;
	const char *s = S.c_str();
	N = strlen(s);

	int ans = 0;
	for(int i=0; i<N; i++){
		if(s[i] == '0')
			ans += 1;
		else
			ans -= 1;
	}
	cout << (N - abs(ans)) << endl ;
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define PRIME 1000000007
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	cin>>n;
	map<int,int> m;
	for(int i=0;i<n;i++)
	{
		int r;
		cin>>r;
		m[r]++;
	}
	ll ans=1;
	if(n%2==0)
	{
		int cnt=1;
		for(auto it: m)
		{
			if(it.first!=cnt || (it.first==cnt && it.second!=2))
			{
				cout<<"0"<<'\n';return 0;
			}
			else
			{
				ans*=2;
				ans=ans%PRIME;
				cnt+=2;
			}
		}

		if((n-cnt+2)!=1)
		{
			cout<<"0"<<'\n';return 0;
		}
		else
		{
			cout<<ans<<'\n';
		}
	}
	else
	{
		if(m[0]!=1)
		{
			cout<<"0"<<'\n';return 0;
		}
		int cnt=2;
		for(auto it: m)
		{
			if(it.first==0)
			{
				continue;
			}
			if(it.first!=cnt || (it.first==cnt && it.second!=2))
			{
				cout<<"0"<<'\n';return 0;
			}
			else
			{
				cnt+=2;
				ans*=2;
				ans=ans%PRIME;
			}
		}
		if((n-cnt+2)!=1)
		{
			cout<<"0"<<'\n';return 0;
		}
		cout<<ans<<'\n';
	}
}	

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

int main() {
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;

  if (a1 + a2 + a3 >= 22) puts("bust");
  else
    puts("win");
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll binary_search(
    ll lo, ll hi, function<bool(ll)> is_ok,
    bool maximize
){
    while(lo < hi){
        if(maximize){
            const ll mid = (lo + hi + 1) / 2;
            if(is_ok(mid)){
                lo = mid;
            }else{
                hi = mid - 1;
            }
        }else{
            ll mid = (lo + hi - 1) / 2;
            if(is_ok(mid)){
                hi = mid;
            }else{
                lo = mid + 1;
            }
        }
    }
    return lo;
}

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n){ cin >> a.at(i); }

    ll ans = ::binary_search(
        1, *max_element(ALL(a)),
        [&](ll x) -> bool {
            ll tmp = 0;
            for(ll ai : a){
                if(ai % x == 0){
                    tmp += ai / x - 1;
                }else{
                    tmp += ai / x;
                }
            }
            return tmp <= k;
        },
        false
    );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4716
/*
オーダー
10**6	余裕を持って間に合う	
10**7	おそらく間に合う	余裕を持って間に合う
10**8	非常にシンプルな処理でない限り厳しい	おそらく間に合う
10**9		非常にシンプルな処理でない限り厳しい
logn	:OK
n		:10^7
nlogn	:10^6
n**2	:10^4
n**3	:300
2**n	:20
n!		:10



// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll N,M;
	cin >> N>>M;
	ll K,A;
	ll count[M] = {0};
	for (ll i = 0; i < N; ++i){
		cin >> K;
		REP(j,K){
			cin >> A;
			count[A-1]++;
		}
	}
 
	// 解法
	ll ans = 0;
	REP(i,M){
		// cout << count[i] << endl;
		if (count[i]==N) ans++;
	}
	
	//出力
	cout << ans << endl;
}


Measured memory_bytes: 256
def read():
    A1, A2, A3 = list(map(int, input().strip().split()))
    return A1, A2, A3

def solve(A1, A2, A3):
    if A1 + A2 + A3 >= 22:
        return 'bust'
    else:
        return 'win' 

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 2940
// use std::cmp;
// use std::collections::HashMap;
// use std::collections::HashSet;
// use std::collections::VecDeque;
// use std::collections::BTreeSet;


// const INF: i64 = 1_000_000_000;
// const MOD: i64 = 998244353;


fn main() {
    let cin = stdin();
    let mut sc = Scanner::new(cin.lock());
    let n: usize = sc.read();
    let m: i64 = sc.read();
    let v: i64 = sc.read();
    let p: usize = sc.read();
    let mut a = Vec::<i64>::new();
    for _ in 0..n {
        a.push(sc.read());
    }
    a.sort();
    a.split_off(n-p+1);
    a.reverse();
    let a = a;
    // println!("{:?}", a);
    /*
    let mut ok = 0;
    let mut ng = n+1;
    while ng - ok > 1 {
        break;
    }
    let ans = ok;
    */
    let mut sum = 0;
    let mut ans = p-1;
    for i in 0..a.len() {
        if a[0] - a[i] <= m && sum - a[i] * (i as i64) <= (n as i64 - v) * m {
            ans += 1;
        }
        sum += a[i];
    }
    println!("{}", ans);
}

// thanks, ir5
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}


Measured memory_bytes: 6396
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

t = I()
for _ in range(t):
    n = I()
    klr = [LI() for _ in range(n)]
    ans = 0
    L = []
    R = []
    for k,l,r in klr:
        if l >= r:
            L.append([k, l-r])
        else:
            R.append([n-k, r-l])
        ans += min(l, r)
    L.sort()
    R.sort()
    hl = []
    hr = []
    cnt = 0
    for k, x in L:
        heappush(hl, x)
        cnt += 1
        if cnt > k:
            heappop(hl)
            cnt -= 1
    cnt = 0
    for k, x in R:
        heappush(hr, x)
        cnt += 1
        if cnt > k:
            heappop(hr)
            cnt -= 1
    ans += sum(hl) + sum(hr)
    print(ans)

Measured memory_bytes: 131452
use std::fs;
use std::io::{stdin, Read};
fn perm_part<T: Clone>(n: usize, v: &mut [T], all: &mut Vec<Vec<T>>) {
    if n == 1 {
        all.push(v.to_vec());
        return;
    }
    for i in 0..n {
        perm_part(n - 1, v, all);
        if n % 2 == 0 {
            v.swap(i, n - 1);
        } else {
            v.swap(0, n - 1);
        }
    }
}

pub fn perm<T: Clone>(v: &Vec<T>) -> Vec<Vec<T>> {
    let mut v = v.clone();
    let mut all = vec![];
    perm_part(v.len(), &mut v, &mut all);
    all
}

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let (n, m, nr) = parse!(it, 3);
    let r: Vec<usize> = parse!(it, nr);
    let mut d = vec![vec![std::usize::MAX / 10; n]; n];
    for _ in 0..m {
        let (a, b, c): (usize, usize, usize) = parse!(it, 3);
        d[a - 1][b - 1] = c;
        d[b - 1][a - 1] = c;
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d[i][j] = std::cmp::min(d[i][k] + d[k][j], d[i][j])
            }
        }
    }

    let mut ret = std::usize::MAX;
    for v in perm(&r) {
        let mut l = 0;
        for i in 0..(v.len() - 1) {
            l += d[v[i] - 1][v[i + 1] - 1];
        }
        ret = std::cmp::min(ret, l);
    }
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 8444
N = int(input())
A = sorted(list(map(int,input().split())))
while len(A) > 1: #条件を満たす間動く
    for j in range(1,len(A)):
        A[j] = A[j] % A[0]
    A = [k for k in A if k != 0]
    A.sort()

print(A[0])

Measured memory_bytes: 65048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
ll a[N],p[N],n;
int dp[N];//´Ó±àºÅi¿ªÊ¼ÎüÊÕ,ÄÜ·ñÎüÊÕµ½Ö»Ê£Ò»Ö» 
//ÌâÒâ:n¸öÉúÎï,n<=1e5,Ã¿¸öÉúÎïÓÐÑÕÉ«iºÍ´óÐ¡Ai,i,j¿ÉÒÔÈÚºÏµ±ÇÒ½öµ±ai*2>=aj,ÈÚºÏºóÑÕÉ«Îªi,´óÐ¡Îªai+aj.ÇóÖ»Ê£ÏÂÒ»Ö»Ê±¿ÉÄÜµÄÑÕÉ«? 
int main()
{
	while(cin>>n)
	{
		p[0]=0;
		for(int i=1;i<=n;i++)
			cin>>a[i];
		sort(a+1,a+1+n);
		for(int i=1;i<=n;i++)
			p[i]=p[i-1]+a[i];
		ll mx=a[n];
		memset(dp,0,sizeof(dp));
		dp[n]=1;
		int ans=1;
		for(int i=n-1;i>=1;i--)
		{
			if(p[i]*2>=a[i+1])
			dp[i]=dp[i+1];	
			if(dp[i])
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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(){
    string s; cin>>s;
    rep(i,s.size()){
        if(s[i]==',') s[i] = ' ';
    }
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
//const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}


int main(){
    long long x,y; cin >> x >> y;
    
    /*int log_y = log2(y/x);
    
    cout << log_y+1 << endl;*/
    
    int cnt = 0;
    while(x<=y){
        cnt++;
        x *= 2;
    }
    cout << cnt << endl;
}



Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<fstream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

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

    // input
    ll A, B, C;
    cin >> A >> B >> C;

    if(A==B && B==C){
        p_yes();
    }else{
        p_no();
    }
    
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    W = [input() for n in range(N)]

    if len(set(W)) != N:
        print('No')
        return 0
    else:
        pre = ''
        for i, word in enumerate(W):
            if i > 0:
                if pre != word[:1]:
                    print('No')
                    return 0
            pre = word[len(word)-1 :]
    print('Yes')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
def solve():
    global N, L
    N, L = map(int, input().split())
    a = list(map(int, input().split()))
    for i in range(N-1):
        if a[i]+a[i+1]>=L:
            return i+1
    return False
ans = solve()
if ans:
    print('Possible')
    for i in range(1, ans):
        print(i)
    for i in range(N-1, ans, -1):
        print(i)
    print(ans)
else:
    print("Impossible")

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


int main()
{
    int n;
    char buf[30];


    fgets(buf, sizeof(buf),stdin);

    n = atoi(buf);

    int y = n + n*n + n*n*n;

    printf("%d\n", y);
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
typedef long long ll;
//#define mod 1000000007

using namespace std;

bool cal(ll a, ll b) {
    cout<<a<<" "<<b<<endl;
	if (a << 1 > b) 
		return 1; 
	b >>= 1; 
	if (a << 1 > b) 
		return (b - a) & 1; 
	if (b & 1) 
		return (b - a) & 1; 
	return cal(a, b >> 1); 
}
  
 
main() {
    int n,m,q;
    cin>>n>>m>>q;
    string s[n];
    int ans=0;
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<pow(2,n);i++){
        for(int j=0;j<pow(2,m);j++){
            int bl=0;
            for(int k=0;k<n;k++){
                for(int l=0;l<m;l++){
                    int c3=pow(2,k);
                    int c4=pow(2,l);
                    int c1=i&c3;
                    int c2=j&c4;
                    if(c1!=c3 && c2!=c4 && s[k][l]=='#'){
                        //cout<<i<<" "<<j<<" "<<k<<" "<<l<<endl;
                        bl++;
                    }
                }
            }
            //
            if(bl==q){
                //cout<<i<<" "<<j<<" "<<bl<<endl;
                ans++;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4072
from collections import deque
N,M=map(int, input().split())
A=[[]for _ in range(N)]
V=[False]*N
X=[0]*N
x=0
for i in range(M):
  L,R,D=map(int, input().split())
  A[L-1].append((R-1,D))
  A[R-1].append((L-1,-D))
  
for i in range(N):
  if V[i]==False:
    stack=deque([(i,x)])
    V[i]=True
    while stack:
      now,dx=stack.popleft()
      for new,di in A[now]:
        if V[new]:
          if X[new]!=dx+di:
            print('No')
            exit()
        else:
          X[new]=dx+di
          V[new]=True
          stack.append((new,dx+di))

if max(X)-min(X)>10**9:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 73892
fun main() {
  val (N, D) = readLongs()
  var cnt = 0
  repeat(N.toInt()) {
    val (X, Y) = readLongs()
    if (X * X + Y * Y <= D * D) cnt++
  }
  println(cnt)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readLong() = readString().toLong()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }


Measured memory_bytes: 64220
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")



n = int(input())
i = 1
s = 1
ss = set([1])
while s<n:
    i += 1
    s += i
    ss.add(i)
    
if s>n:
    ss.remove(s-n)
write("\n".join(map(str, ss)))

Measured memory_bytes: 65940
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) {
	if ((a == 0) || (b == 0))
		return 0;
	while (a != b){
		if (a > b) a = a-b;
		else 	   b = b-a;
	}
		return a; 
}

ll lcm(ll a, ll b){
	if ((a == 0) || (b == 0))
		return 0;
	return ((a/gcd(a, b))*b);
}

int main(){
	ll x, y, z, flag, a[3], m[3];
	while (1){
		ll x = 1, y = 1, z = 1, flag = 1;
		for (int i = 0; i < 3; i++){
			scanf("%lld%lld", &a[i], &m[i]);
			if (a[i] != 0 || m[i] != 0) flag = 0;
		}
		if (flag) break;
		int countx = 0, county = 0, countz = 0;
		while (1){
			x = (a[0]*x)%m[0];
			countx++;
			if (x == 1) break;
		}
		while (1){
			y = (a[1]*y)%m[1];
			county++;
			if (y == 1) break;
		}
		while (1){
			z = (a[2]*z)%m[2];
			countz++;
			if (z == 1) break;
		}
		ll re = lcm(countx, county);
		re = lcm(re, countz);
		printf("%lld\n", re);
		
	}
	return 0;
}

Measured memory_bytes: 1188
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); ++i)
int main(void) {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  sort(d.begin(), d.end());
  cout << d[n / 2] - d[n / 2 - 1] << endl;
  return 0;
}

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

using namespace std;

int main()
{
    cout << fixed;
    cout << setprecision(11);
    int n;
    cin >> n;
    vector<double> p(n);
    vector<vector<double> > dp(n+1, vector<double>(n+1, 0.0));
    dp[0][0]=1.0;
    for(int i=0; i<n; i++){
        cin >> p[i];
        for(int j=0; j<=i; j++){
            dp[i+1][j+1]+=p[i]*dp[i][j];
            dp[i+1][j]+=(1.0-p[i])*dp[i][j];
        }
    }
    double ans=0.0;
    for(int j=(n/2)+1; j<=n; j++)
        ans+=dp[n][j];
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 70784
N,K=map( int, raw_input().split() ) 

if K%2==1:
	cnt=(2*N)/(2*K)
	print cnt**3
else:
	cnt=(N/K)**3

	if N%K>=K/2:
		cnt+=(N/K+1)**3
	else:
		cnt+=(N/K)**3
	print cnt



Measured memory_bytes: 27884
#include <iostream>
#include <vector>
#include <cmath>

int main() {
  std::string a, b;
  std::cin >> a >> b;
  std::string d{a + b};
  int s = std::stoi(d);
  if ((int)std::sqrt(s) * (int)std::sqrt(s) == s){
    std::cout << "Yes" << std::endl;
  }else
    std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
signed main(){
  int N;
  cin>>N;
  string ans="Yes";
  vector<pii> A(N);
  rep(i,0,N){
    int a,b;
    cin>>a>>b;
    A[i].first=b;
    A[i].second=a;
  }
  sort(ALL(A));
  int sum=0;
  rep(i,0,N){
    sum+=A[i].second;
    if(sum>A[i].first){
      ans="No";
      break;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int l,r,d;
  cin >> l >> r >> d;
  ll res = 0;
  for(int i = l;i <= r;i++){
    if((i%d) == 0)res++;
  }
  cout << res << endl;
  


  return 0;
}

Measured memory_bytes: 3564
s = gets.chomp

N = s.count("N")
W = s.count("W")
S = s.count("S")
E = s.count("E")

if (N + S >= 1 && N * S == 0) || (W + E >= 1 && W * E == 0)
  puts "No"
else
  puts "Yes"
end


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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

int x[4], y[4];
bool v[4][4];

int dfs(int i, int j) {
	while(v[i][j]) {
		j ++;
		if(j == 4) {
			i ++;
			j = 0;
		}
	}
	if(i == 4) return 1;
	int r = 0;
	for(int sgn : {-1, 1})
	for(int k = 0; k < 4; k ++) {
		int ni = i + sgn * x[k];
		int nj = j + sgn * y[k];
		if(ni >= 0 && ni < 4 && nj >= 0 && nj < 4 && !v[ni][nj]) {
			v[i][j] = v[ni][nj] = 1;
			r += dfs(i, j);
			v[i][j] = v[ni][nj] = 0;
		}
	}
	return r;
}

int main() {
	cout << fixed << setprecision(9);
	ios :: sync_with_stdio(0);

	for(; cin >> x[0] && x[0] <= 4; ) {
		cin >> y[0];
		for(int i = 1; i < 4; i ++)
			cin >> x[i] >> y[i];
		cout << dfs(0, 0) << '\n';
	}

	return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll h,w,c[305][305][305],d[305][305][305],s[305][305],ans,dp[305][305];
int main(void){
    cin>>h>>w;
    for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char p;
			cin>>p;
			s[i][j]=int(p);
		}
	}
	for(int i=0;i+1<w;i++){
		for(int j=0;j<h;j++){
			for(int k=0;k+j<h;k++){
				if(k)c[i][j][k]+=c[i][j][k-1];
				if(s[k][i]==s[k+j][i+1])c[i][j][k]++;
				if(k)d[i][j][k]+=d[i][j][k-1];
				if(s[k+j][i]==s[k][i+1])d[i][j][k]++;
			}
		}
	}
	for(int i=0;i+1<w;i++){
		for(int j=0;j<=h;j++)for(int k=0;k<=h;k++)dp[j][k]=INF;
		dp[0][0]=0;
		for(int j=0;j<=h;j++){
			for(int k=0;k<=h;k++){
				if(j+1<=k)dp[j+1][k]=min(dp[j+1][k],dp[j][k]+c[i][k-(j+1)][j]);
				else{
					if(k)dp[j+1][k]=min(dp[j+1][k],dp[j][k]+d[i][j+1-k][k-1]);
					else dp[j+1][k]=min(dp[j+1][k],dp[j][k]);
				}
				if(k+1<=j)dp[j][k+1]=min(dp[j][k+1],dp[j][k]+d[i][j-(k+1)][k]);
				else{
					if(j)dp[j][k+1]=min(dp[j][k+1],dp[j][k]+c[i][k+1-j][j-1]);
					else dp[j][k+1]=min(dp[j][k+1],dp[j][k]);
				}
			}
		}
		ans+=dp[h][h];
	}
	cout<<ans<<endl;
}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    string aiueo;
    cin >> aiueo;
    if (aiueo[2] == aiueo[3] && aiueo[4] == aiueo[5]) {
        OUT("Yes");
    } else {
        OUT("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  ll hight = 0;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    if (hight <= a) {
      hight = a;
    } else {
      ans += hight - a;
    }
    // cout << hight << " " << ans << endl;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
#include<cassert>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds; 
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int MAXN=2e5+1;
const int M=998244353;
 
ll fac[MAXN];
ll infac[MAXN];
 
ll modexp(ll a,ll b){
	if(b==0)
		return 1;
	if(b%2==0){
		return modexp((a*a)%M,b/2);
	}
	else{
		return (a*modexp((a*a)%M,b/2))%M;
	}
}
 
ll modinver(ll num){
 
	return modexp(num,M-2);
}
 
void intialise(){
	fac[0]=1;
 
	for(int i=1;i<MAXN;i++){
		fac[i]=(fac[i-1]*i)%M;
	}
 
	infac[MAXN-1]=modinver(fac[MAXN-1]);
 
	for(int i=MAXN-2;i>=0;i--){
		infac[i]=(infac[i+1]*(i+1))%M;
		//cout<<i<<" "<<infac[i]<<endl;
	}
}
 
ll ncr(ll n,ll r){
	if(r>n)
		return 0;
 
	ll ans=fac[n];
	ans=(ans*infac[r])%M;
	ans=(ans*infac[n-r])%M;
 
	return ans;
}

void solve(){
	
	int n,m,k;
	sfi(n) sfi(m) sfi(k)

	ll ans=0;

	for(int i=0;i<=k;i++){
		ll temp=ncr(n-1,i);

		//cout<<temp<<" "<<endl;

		temp=(temp*m)%M;


		temp=(temp*modexp(m-1,n-1-(i)))%M;

		ans=(ans+temp)%M;


	}

	pfln(ans)
}


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

Measured memory_bytes: 6936
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.next_usize();
    println!("{}", n*n*n);
}

pub struct Scanner {
    buf: std::collections::VecDeque<String>,
}

impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: std::collections::VecDeque::new(),
        }
    }

    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }

            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }

    pub fn next<T: std::str::FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!("Couldn't parse!"))
    }

    pub fn next_usize(&mut self) -> usize {
        self.next()
    }

    pub fn next_isize(&mut self) -> isize {
        self.next()
    }

    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }

    pub fn next_string(&mut self) -> String {
        self.next()
    }

    pub fn next_char(&mut self) -> char {
        self.next()
    }

    pub fn next_float(&mut self) -> f64 {
        self.next()
    }
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
    
using namespace std;
    
#define endl "\n";
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,bool> pllb;
typedef pair<pair<ll,ll>,ll> plll;
    
const ll N = 110;
const ll INF = 1e17;
const ll N2 = 1e5+10;
const int MOD = 1e9+7;
    
ll n,w;
ll weight[N],val[N];
ll memo[N][N2];
    
ll dp(int idx,int v)
{
    if(idx==n)
    {
        if(v==0)
            return 0;
        else
            return 1e14;
        
    }
    ll &ret = memo[idx][v];
    if(~ret)
        return ret;
    ret = dp(idx+1,v);
    if(val[idx]<=v)
        ret = min(ret,dp(idx+1,v-val[idx])+weight[idx]);
    return ret;
}
    
    
int main()
{
    fastio
    #ifndef ONLINE_JUDGE
        //freopen("input.txt","r",stdin);
        //freopen("out.txt","w",stdout);
    #endif
    
    
    memset(memo,-1,sizeof memo);
    cin >> n >> w;
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> weight[i] >> val[i];
        sum+=val[i];
    }
    ll ans = 0;
    for(int i = 0; i <= sum; i++)
    {
        ll temp = dp(0,i);
        if(temp<=w)
            ans = i;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 86272
from functools import reduce
from math import gcd
 
 
k = int(input())
B=list()
D=list()
 
for i in range(1,k+1):
  for j in range(1,k+1):
        a=[i,j]
        b = reduce(gcd,a)
        B.append(b)
 
for i in B:
    for k in range(1,k+1):
        c = [i,k]
        d = reduce(gcd,c)
        D.append(d)
print(sum(D))
 
 

Measured memory_bytes: 190084
import math
n,d=map(int,input().split())
x=[input().split() for i in range(n)]
ans=0
for i in range(n):
        for h in range(i):
                a=0
                for j in range(d):
                        a+=(int(x[i][j])-int(x[h][j]))**2
                a=math.sqrt(a)
  
                if float.is_integer(a)==True:
                        ans+=1
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
    while(1){
        ll n; cin >> n;
        if(!n) break;
        vvl v(n);
        rep(i,n){
            ll m; cin >> m;
            rep(j,m){
                ll p; cin >> p;
                v[i].push_back(p);
            }
            sort(all(v[i]));
        }
        ll k; cin >> k;
        vl l(k); rep(i,k) cin >> l[i];
        ll ans = -1;
        rep(i,n){
            bool flag = true;
            rep(j,k){
                if(!binary_search(all(v[i]),l[j])){
                    flag = false;
                    break;
                }
            }
            if(flag){
                if(ans == -1) ans = i+1;
                else{
                    ans = -1;
                    break;
                }
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3240
import Control.Monad
import Data.List
import qualified Data.IntSet as S
import qualified Data.Vector.Storable as V

main=do
    n<-readLn
    as<-V.fromList <$> replicateM n readLn
    print $ chk 0 0 S.empty as

chk c b s v = case n of
    n | S.member n s -> (-1)
    1 -> c+1
    n -> chk (c+1) n (S.insert n s) v
    where n = (v V.! b) - 1

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int w, d;
  while ( cin >> w >> d, w ) {
    vector<int> h1(w), h2(d);
    vector<int> c1(21, 0), c2(21, 0);  
    for ( int i = 0; i < w; i++ ) cin >> h1[i], c1[h1[i]]++;
    for ( int i = 0; i < d; i++ ) cin >> h2[i], c2[h2[i]]++;

    int ans = 0;
    for ( int i = 1; i < 21; i++ ) {
      int mi = min(c1[i], c2[i]);
      ans += mi*i;
      c1[i] -= mi;
      c2[i] -= mi;
      ans += (c1[i]+c2[i])*i;      
    }

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



Measured memory_bytes: 3156
#include <bits/stdc++.h>
// #include <atcoder/all>
// using namespace atcoder;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(x.rbegin(), x.rend())
#define REVERSE(x) reverse(ALL(x))
#define MAX(x) *max_element(ALL(x))
#define MAXI(x) max_element(ALL(x)) - x.begin()
#define SUM(x) accumulate(ALL(x), 0ll)
#define COUNT(x, y) count(ALL(x), y);
#define ANS cout << ans << "\n"
#define YES cout << "YES\n";
#define NO cout << "NO\n";
#define Yes cout << "Yes\n";
#define No cout << "No\n";
#define YN YES else NO
#define yn Yes else No
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(z, v.size()) cerr << " " << v[z]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;
using vp = vector<P>;
using vs = vector<string>;

template <typename T>
inline istream& operator>>(istream& i, vector<T>& v) {
  rep(j, v.size()) i >> v[j];
  return i;
}

template <typename T1, typename T2>
inline istream& operator>>(istream& i, pair<T1, T2>& v) {
  return i >> v.first >> v.second;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

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

signed main() {
  init();
  ll N;
  cin >> N;
  vll A(N);
  cin >> A;

  ll ma = MAX(A);
  ll mi = *min_element(ALL(A));
  // debug(ma);
  // debug(mi);

  COUT(2 * N - 1);
  if (abs(ma) >= abs(mi)) {
    ll index = MAXI(A);

    rep(i, N) {
      cout << index + 1 << " " << i + 1 << endl;
      A[i] += ma;
    }
    rep(i, N) {
      if (i == 0) continue;
      cout << i << " " << i + 1 << endl;
    }
  } else {
    ll index = min_element(ALL(A)) - A.begin();

    rep(i, N) {
      cout << index + 1 << " " << i + 1 << endl;
      A[i] += mi;
    }
    repr(i, N - 2) {
      cout << i + 2 << " " << i + 1 << endl;
    }
  }

  // debugV(A);

  return 0;
}

Measured memory_bytes: 3652
import java.io.*;

public class Main {
    public static void main(String[] a) throws NumberFormatException, IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String line;
        int num = 0;
        // データ読み込み
        while ((line = in.readLine()) != null && num <= 1000) {
            if (num != 0) {
                int b = Integer.parseInt(line.split(" ")[0]);
                int c = Integer.parseInt(line.split(" ")[1]);
                int d = Integer.parseInt(line.split(" ")[2]);
                if (b > c && b > d) {
                    checkTriangle(b, c, d);
                } else if (c > b && c > d) {
                    checkTriangle(c, b, d);
                } else {
                    checkTriangle(d, b, c);
                }
            }
            num++;
        }
    }

    private static void checkTriangle(int along, int aShort1, int aShort2) {
        if ((int)Math.pow(along, 2) == (((int)Math.pow(aShort1, 2) + (int)Math.pow(aShort2, 2)))) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}

Measured memory_bytes: 23720
while line=gets
	input=line.chomp.split(",").map{|s| s.to_f}
	xs=[input[0],input[2],input[4],input[6]]
	ys=[input[1],input[3],input[5],input[7]]

	x0=xs[3]
	y0=ys[3]

	op=nil
	ans="YES"

	4.times{|i|
		x=xs[i]
		y=ys[i]
		x1=xs[(i+1)%4]
		y1=ys[(i+1)%4]
		op_i=(x-x0)*(y1-y)-(y-y0)*(x1-x)

		if op==nil then
			op=op_i
		elsif op*op_i<0
			ans="NO"
			break
		end

		x0=x
		y0=y	
	}
	puts ans
end


Measured memory_bytes: 6896
N = int(input())
A = list(map(int,input().split()))
ans = 0
total = A[0]
l=r=0
xor = A[0]

while True:
    if xor==total:
        ans += r-l+1
        r += 1
        if r==N:
            break
        total += A[r]
        xor ^= A[r]
    else:
        total -= A[l]
        xor ^= A[l]
        l += 1
    
print(ans)

Measured memory_bytes: 100516
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 2e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    int n,m;
    cin>>n>>m;
    string arr[n];
    for(int i=0;i<n;i++)cin>>arr[i];
    bool row[n]={};
    bool col[m]={};
    for(int i=0;i<n;i++){
        bool temp=true;
        for(int j=0;j<m;j++){
            if(arr[i][j]=='#')temp=false;
        }
        row[i]=temp;
    }
    for(int j=0;j<m;j++){
        bool temp=true;
        for(int i=0;i<n;i++){
            if(arr[i][j]=='#')temp=false;
        }
        col[j]=temp;
    }
    bool nl;
    for(int i=0;i<n;i++){
        nl=false;
        for(int j=0;j<m;j++){
            if(row[i]||col[j])continue;
            else {
                cout<<arr[i][j];
                nl=true;
            }
        }
        if(nl)
        cout<<endl;
    }
}

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

#define mx 100008
typedef long long int ll;

ll n;
ll dp[100009][101];
ll w[102],v[123];
ll cal(ll i,ll j)
{
    if(i<0) return LLONG_MIN;
    if(j==n+1) return 0;
    if(i==0) return 0;
    if(dp[i][j]!=-1){
        return dp[i][j];
    }
    ll res=max(cal(i,j+1),cal(i-w[j],j+1)+v[j]);
    return dp[i][j]=res;
}
int main()
{
    //seive();
    int t=1;
    //cin>>t;
    int c=0;
    while(t--){
        ll k;
        cin>>n>>k;

        for(int i=1;i<=n;i++){
            cin>>w[i]>>v[i];
        }
        ll ans=0;
        memset(dp,-1,sizeof(dp));
        ans=cal(k,1);
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 82568
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}
int main() {
    int n, m; cin >> n >> m;
    vector<int> k; // 電球ごとに接続されているスイッチ数
    vector< bitset<10> > s; // 電球ごとに接続されているスイッチ
    vector<int> p; // 電球ごとに光る条件となる、接続数を2で割った余り

    REP(i, m) {
        int tmp_k;
        cin >> tmp_k;
        k.push_back(tmp_k);

        bitset<10> row_s;
        REP(j, tmp_k) {
            int tmp_s;
            cin >> tmp_s;
            row_s[tmp_s-1] = true;
        }
        s.push_back(row_s);
    }
    REP(i, m) {
        int tmp_p;
        cin >> tmp_p;
        p.push_back(tmp_p);
    }

    // 方針: スイッチの数はたかだか10個なので、全通り試して10!なので回りきる？
    ll res = 0;
    for (int bit=0; bit < (1 << n); bit++) {
        // 発火するbitを見る
        bitset<10> vb;
        for (int i=0; i < n; i++) {
            if (bit & (1 << i)) {
                vb[i] = 1;
            }
        }

        // 電球ごとに一致数を確認する
        int on_num = 0;
        for (int i=0; i < m; i++) {
            if ((s[i] & vb).count() % 2 == p[i]) {
                on_num++;
            }
        }

        // 全て光る組み合わせであればOK
        if (on_num == m) {
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

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

class Union_Find{
  vector<int> par; vector<int> rank; vector<int> num;
public:
  Union_Find(int n) {
    par = vector<int>(n); rank = vector<int>(n,0); num = vector<int>(n,1);
    rep(i,n) par[i] = i;
  }
  int find(int x) {
    if(par[x] == x) return x;
    else  return par[x] = find(par[x]);
  }
  int number(int x) {
    return num[find(x)];
  }
  void unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    num[x] += num[y];
  } 
  bool same(int x, int y) {
    return find(x) == find(y);
  }
};

int main(){
  ll n, m;
  cin >> n >> m;
  Union_Find uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    uf.unite(a,b);
  }
  ll one = 0, two = 0, other = 0;
  rep(i,n) {
    if(uf.same(0,i)) one++;
    else if(uf.same(1,i)) two++;
    else other++;
  }
  ll t = max(one,two) + other;
  ll s = min(one,two);
  cout << t*(t-1)/2 + s*(s-1)/2 - m << endl;
  return 0;
}


Measured memory_bytes: 4560
M, D = map(int, input().split())
cnt = 0
mlist = list(range(M + 1))
for d in range(1, D + 1):
    d_1 = d % 10
    d_10 = d // 10
    if  d_1 >= 2 and d_10 >= 2 and d_1 * d_10 in mlist:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060