akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
//#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#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 drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll x,n;
        cin>>x>>n;
        map<ll,ll> m;
        rep(i,n){
            ll a;
            cin>>a;
            m[a]++;
        }
        if(m[x]==0){
            cout<<x<<endl;
            return 0;
        }
        rep(i,10000){
            if(m[x-i-1]==0){
                cout<<x-i-1<<endl;
                return 0;
            }
            if(m[x+i+1]==0){
                cout<<x+i+1<<endl;
                return 0;
            }
        }
    }

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

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

	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	vector<int> dp(n, 1e9);
	dp[0] = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> h[i];
		for(int j = max(0, i - k); j < i; j++)
			dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
	}

	cout << dp[n - 1] << "\n";
}


Measured memory_bytes: 1024
hoge = input().split()
L = int(hoge[0])
R = int(hoge[1])

if (R - L) >= 2019:
  print(0)
else:
  min_ = 2019
  for i in range(L,R):
    for j in range(i+1,R+1):
      hoge = (i * j) % 2019
      if hoge < min_:
        min_ = hoge
  print(min_)

Measured memory_bytes: 3060
#include <stdio.h>
int main(){
	int x, y, cx, cy, cr;
	scanf("%d %d %d %d %d", &x, &y, &cx, &cy, &cr);
	int minx=cx-cr;
	int maxx=cx+cr;
	int miny=cy-cr;
	int maxy=cy+cr;
	if(x>=0){
		if(0>minx){
			puts("No");
			return 0;
		}
		if(maxx>x){
			puts("No");
			return 0;
		}
	}
	if(x<0){
		if(0<maxx){
			puts("No");
			return 0;
		}
		if(minx<x){
			puts("No");
			return 0;
		}
	}
	
	
	if(y>=0){
		if(0>miny){
			puts("No");
			return 0;
		}
		if(maxy>y){
			puts("No");
			return 0;
		}
	}
	if(y<0){
		if(0<maxy){
			puts("No");
			return 0;
		}
		if(miny<y){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}



Measured memory_bytes: 1812
n = int(input())
sum_ = 0

for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        sum_ += i

print(sum_)

Measured memory_bytes: 9176
import java.util.*;
import java.util.Map.Entry;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main //implements Runnable
{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int a[]=sc.nextIntArray(n);
        int b[]=sc.nextIntArray(n);
        int c[]=sc.nextIntArray(n-1);
        long s=0;
        for (int i = 0; i < a.length; i++) {
			s+=b[a[i]-1];
			if(i>0) {
				if(a[i]-a[i-1]==1) {
//					db(i);
					s+=c[a[i-1]-1];
				}
			}
		}
        
        out.println(s);
     	out.flush();
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}


//class P {
//	int x, y;
//	P(int  x, int y) {
//	  this.x=x;
//	  this.y=y;
//	}
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//    	if(a==p.a) return b-p.b;
//        return -p.a+a;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 21204
i = gets.split.map(&:to_i)
j = gets.split.map(&:to_i)
k = gets.split.map(&:to_i)

def checker(i,j,k)
  (0..100).each do |x|
    a1 = x
    b1 = i[0] - a1
    b2 = i[1] - a1
    b3 = i[2] - a1
    a2 = j[0] - b1
    a3 = k[0] - b1
    if ( j[1] == a2 + b2 &&
         j[2] == a2 + b3 &&
         k[1] == a3 + b2 &&
         k[2] == a3 + b3
         )
      return true
    end
  end
  return false
end

puts checker(i,j,k) ? "Yes" : "No"

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

int abs(int x, int y) {
    if(x - y < 0) {
        return -1 * (x - y);
    }
    else {
        return x - y;
    }
}

int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int ab, bc, ac;

    ab = abs(a, b);
    bc = abs(b, c);
    ac = abs(a, c);
    
    if(d >= ac) {
        cout << "Yes" << endl;
    }
    else if(ab <= d && bc <= d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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

const int N = 200000;
int a[N+5], dp[N+5], ans[N+5];;
vector<int> G[N+5];

void dfs(int u, int p, int len){
    int pos = lower_bound(dp+1, dp+len+1, a[u]) - dp;
    int tmp = dp[pos]; dp[pos] = a[u];
    ans[u] = (pos > len ? len = pos : len);
    for (int v : G[u]) if (v != p){
        dfs(v, u, len);
    }
    dp[pos] = tmp;
}

int main(){
    int n; scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", a+i);
    int u, v;
    for (int i = 1; i <= n-1; ++i){
        scanf("%d %d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    dfs(1, 0, 0);
    for (int i = 1; i <= n; ++i){
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 30600
#include <vector>
#include <iostream>
#include <string>

using namespace std;
using ll=long long;

void solve(long long N, vector<string> S){
  vector<ll> cnt(5);

  for(ll n=0; n<N; n++){
    switch(S[n][0]){
      case 'M':
        cnt[0]++;
        break;
      case 'A':
        cnt[1]++;
        break;
      case 'R':
        cnt[2]++;
        break;
      case 'C':
        cnt[3]++;
        break;
      case 'H':
        cnt[4]++;
        break;
    }
  }

  ll rst = 0;
  for(int i=0; i<5; i++){
    if(cnt[i] > 0){

      for(int j=i+1; j<5; j++){
        if(cnt[j] > 0){

          for(int k=j+1; k<5; k++){
            if(cnt[k] > 0){
              rst += cnt[i]*cnt[j]*cnt[k];
            }
          }

        }
      }

    }
  }

  cout << rst << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<string> S(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		cin >> S[i];
	}
	solve(N, S);
	return 0;
}



Measured memory_bytes: 11648
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextssort(n,a){return a?cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>b-a):cin.slice(cid,cid+=n).map(a=>+a).sort((a,b)=>a-b);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}
var streams=[];function print(s){streams.push(s);}

var def = 0;
function segTree(n){
  var x = 2; n--;
  while(n)n >>= 1, x <<= 1;
  this.seg = Array(x-1).fill(def);
  this.l = x >> 1;
}
segTree.prototype={
  get:function(x){
    var v = this.seg;
    x += this.l-1;
    var r = def;
    while(x >= 0){
      if(v[x] > r)r = v[x];
      x = x-1>>1;
    }
    return r;
  },
  update:function(l,r,t){//[l,r)
    if(l >= r)return;
    var self = this;
    q(l,r,0,this.l,0);
    function q(l,r,x,y,i){
      if(l === x && r === y){
        if(self.seg[i] < t)self.seg[i] = t;
        return;
      }
      var m = x+y >> 1;
      if(m < r)if(l < m){q(l,m,x,m,i+i+1);q(m,r,m,y,i+1<<1);}
      else q(l,r,m,y,i+1<<1);
      else q(l,r,x,m,i+i+1);
    }
  },
}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));
if(streams.length)console.log(streams.join("\n"));

function main(){
  var [n,k] = nexts(2);
  var a = nexts(n);
  var seg = new segTree(300001);
  for(var i = 0; i < n; i++){
    var l = Math.max(0,a[i]-k);
    var r = Math.min(300000,a[i]+k);
    var t = seg.get(a[i]);
    seg.update(l,r+1,t+1);
  }
  var ans = 0;
  for(var i = 0; i <= 300000; i++){
    ans = Math.max(ans,seg.get(i));
  }
  return ans;
}

Measured memory_bytes: 94404
#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 a, b;
    cin >> a >> b;
    int ans = 0;
    if (a > b)
    {
        ans += a;
        a--;
        if (a > b)
        {
            ans += a;
            a--;
        }
        else
        {
            ans += b;
            b--;
        }
    }
    else
    {
        ans += b;
        b--;
        if (a > b)
        {
            ans += a;
            a--;
        }
        else
        {
            ans += b;
            b--;
        }
    }
    cout << ans << endl;
}

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

#define ll long long
#define ld long double
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

vector<pair<ll, int>> vc;

bool compare_by_first(pair<ll, int> a, pair<ll, int> b)
{
    return a.first < b.first;
}

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

    rep(i, n)
    {
        ll a;
        int b;
        cin >> a;
        cin >> b;
        pair<ll, int> mypair;
        mypair.first = a;
        mypair.second = b;
        vc.push_back(mypair);
    }
    sort(vc.begin(), vc.end(), compare_by_first);

    int counter = 0;
    ll ans = 0;

    for (auto &e : vc)
    {
        if (counter + e.second <= m)
        {
            ans += e.second * e.first;
            counter += e.second;
        }
        else
        {
            int temp = m - counter;
            ans += e.first * temp;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

class Combination {
    private:
    vector<int> x, y;
    int mod = (int)1e9 + 7;
    
    void make(int n) {
        x.resize(n+1);
        y.resize(n+1);        
        x[0] = y[0] = 1;
        for (int i = 1; i <= n; i++) {
            x[i] = (x[i-1]*i) % mod;
            y[i] = modpow(x[i],mod-2);
        }
    }
    
    int modpow(int x, int n) {
        int ret = 1;
        while (n > 0) {
            if ((n & 1)) {
                ret = ret * x % mod;
            }
            x = x * x % mod;
            n >>= 1;
        }
        return ret;
    }
    
    public:
    Combination(int n) {
        make(n);
    }
    
    Combination(int n, int mod) {
        this->mod = mod;
        make(n);
    }
    
    int nCr(int n, int r) {
        if (n < r) return 0;
        return x[n] * y[n - r] % mod * y[r] % mod;
    }
    
    int nHr(int n, int r) {
        return nCr(n + r - 1, r);
    }
    
};

void run(){
    int n,k;
    cin>>n>>k;
    Combination c(2*n);
    int ans=0;
    k=min(k,n-1);
    rep(i,k+1)ans+=c.nCr(n,i)*c.nHr(n-i,i)%mod,ans%=mod;
    cout<<ans<<endl;
}

Measured memory_bytes: 9520
def Qb():
    n = int(input())
    lina = list(map(int, input().split()))

    if 0 in lina:
        print(0)
        exit()

    ans = 1
    for a in lina:
        ans *= a
        if 10 ** 18 < ans:
            ans = -1
            break
    print(ans)

if __name__ == '__main__':
    Qb()


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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int modPow(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % p;
  if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
  ll t = modPow(a, n / 2, p);
  return (t * t) % p;
}

int main() {
	int X, Y; cin >> X >> Y;
	if((X + Y) % 3 != 0 || (double)Y > 2 * (double)X || (double)Y < (double)X / 2)  {
		cout << 0 << endl;
		return 0;
	}
	ll l = max((2 * X - Y) / 3, 0);
	ll s = max((2 * Y - X) / 3, 0);
	ll fact = 1;
	for(int i = 2; i <= l + s; i++) fact = fact * i % mod;
	ll invfactl = 1;
	for(int i = 1; i <= l; i++) invfactl = invfactl * modPow(i, mod - 2, mod) % mod;
	ll invfacts = 1;
	for(int i = 1; i <= s; i++) invfacts = invfacts * modPow(i, mod - 2, mod) % mod;
	ll ans = fact * invfacts % mod;
	ans = ans * invfactl % mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3636
Public Class Program
  Shared Sub Main()
    Dim ap As Integer() = Cin.IntArr()
    Dim a As Integer = ap(0)
    Dim p As Integer = ap(1)
    Console.WriteLine((((a * 3) + p) \ 2).ToString())
  End Sub
End Class

Public Class Cin
  Public Shared Function Str() As String
    Return Console.ReadLine().Trim()
  End Function
  Public Shared Function Int() As Integer
    Return Integer.Parse(Str())
  End Function
  Public Shared Function Lng() As Long
    Return Long.Parse(Str())
  End Function
  Public Shared Function Dbl() As Double
    Return Double.Parse(Str())
  End Function
  Public Shared Function StrArr(Optional separator As String = " ") As String()
    Return Str().Split(separator)
  End Function
  Public Shared Function IntArr(Optional separator As String = " ") As Integer()
    Return Array.ConvertAll(Of String, Integer)(StrArr(separator), AddressOf Integer.Parse)
  End Function
  Public Shared Function LngArr(Optional separator As String = " ") As Long()
    Return Array.ConvertAll(Of String, Long)(StrArr(separator), AddressOf Long.Parse)
  End Function
  Public Shared Function DblArr(Optional separator As String = " ") As Double()
    Return Array.ConvertAll(Of String, Double)(StrArr(separator), AddressOf Double.Parse)
  End Function
End Class

Measured memory_bytes: 11220
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
const int inf=1e9;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
  int n,m;
  while(cin>>n>>m,n+m){
    vvi cost(3*n,vi(3*n,inf));
    rep(i,m){
      int a,b,c;
      cin>>a>>b>>c;
      a--;b--;
      cost[a][b]=cost[b][a]=c;
      cost[2*n+a][2*n+b]=cost[2*n+b][2*n+a]=c;
      cost[a][n+b]=cost[n+a][2*n+b]=0;
      cost[b][n+a]=cost[n+b][2*n+a]=0;
    }
    vi used(3*n),d(3*n,inf);
    d[0]=0;
    while(1){
      int v=-1;
      rep(i,3*n)if(used[i]==0&&(v==-1||d[v]>d[i]))v=i;
      if(v==-1)break;
      used[v]=1;
      rep(i,3*n)d[i]=min(d[i],d[v]+cost[v][i]);
    }
    cout<<min(d[n-1],d[3*n-1])<<endl;
  }
}

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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define Matrix vector<vector<int>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {
  int n;
  cin >> n;
  // --n;

  string ans;
  while (n > 0) {
    ans += 'a' + ((n - 1) % 26);
    n = (n - 1) / 26;
  }
  reverse(all(ans));
  cout << ans << endl;
}

signed main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t = 1;

#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main(void){
	int i,j,k,M,N,H,W,X,A,K;
	cin >> N >> X;
	int L[N+1];
	int D = 0;
	int c = 1;
	for(i=0;i<N;i++){
		cin >> L[i];
	}
  L[N] = 10000;
	while(D<=X){
		D += L[c-1];
		c += 1;
	}
	c -= 1;
	cout << min(c,N+1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef vector<pr> Vpr;
typedef pair<ut,ut> prs;
const int SIZE=3*1e5;
const LL p=7+1e9;
int val[2][SIZE];
int sums[2][SIZE];
int sum(int ar,int a,int b){
	return sums[ar][b]-sums[ar][a-1];
}
void input(string s,int ar){
	REP(i,s.size()){
		val[ar][i+1]=1+(s[i]=='A');
		sums[ar][i+1]=sums[ar][i]+val[ar][i+1];
	}
}
int main(){
	cin.tie(0);
	string S,T;
	cin >> S >> T;
	input(S,0);
	input(T,1);
	int Q,a,b,c,d;
	cin >> Q;
	REP(i,Q){
		cin >> a >> b >> c >> d;
		if(sum(0,a,b)%3==sum(1,c,d)%3) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3712
function makeearlieststartday(N, K, C, S)
    ret = zeros(Int, K)
    d = 1
    k = 1
    while k <= K
        if S[d] == 'o'
            ret[k] = d
            d += C + 1
            k += 1
        elseif S[d] == 'x'
            d += 1
        end
    end
    ret
end

function makelateststartday(N, K, C, S)
    ret = zeros(Int, K)
    d = N
    k = K
    while k >= 1
        if S[d] == 'o'
            ret[k] = d
            d -= C + 1
            k -= 1
        else S[d] == 'x'
            d -= 1
        end
    end
    ret
end


function solve()
    N, K, C = [parse(Int, x) for x in split(readline())]
    S = readline()

    earlieststartday = makeearlieststartday(N, K, C, S)
    lateststartday = makelateststartday(N, K, C, S)
    for (e, l) in zip(earlieststartday, lateststartday)
        if e == l
            println(e)
        end
    end
end

solve()

Measured memory_bytes: 202648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,start,end) for(int i=start; i<=end; i++)
#define repd(i,start,end) for(int i=start; i>=end; i--)
#define pb push_back
#define mod 1e9+7
#define all(x) x.begin(),x.end()
void solve() {
	ll n,count=0;
	cin>>n;
	ll a[n];
	rep(i,n)
	{
	    cin>>a[i];
	}
	rep(i,n-1)
	{
	    if(a[i]>a[i+1])
	    {
	        count+=a[i]-a[i+1];
	        a[i+1]+=a[i]-a[i+1];
	    }
	}
	cout<<count<<endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cout.tie(0); cin.tie(0); 
	cout<<fixed;
	cout<<setprecision(10);
	 {
		solve();
	}
}


Measured memory_bytes: 5168
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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() {
  int n;
  cin >> n;
  vector<int>a(n);
  int a1 = 0, a2 = 0;
  rep(i,n) {
    cin >> a[i];
    if(a[i]>a1){
      a2 = a1;
      a1 = a[i];
    }else if(a[i]>a2){
      a2 = a[i];
    }
  }
  rep(i,n){
    if(a[i]==a1) printf("%d\n",a2);
    else printf("%d\n",a1);
  }
}


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

int main(){
    int N;
    cin >> N;
    long A[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    long long count =  0;
    long long sum = 0;
    long long s[N+1];
    s[N] = 10000000010;
    for(int i=0;i<N;i++) {
        sum = sum + A[i];
        s[i] = sum;
    }

    sort(s,s+N);
    long long c = 0;
    for(int i=0;i<N;i++){
        if(s[i]==0) c++;
        else if(s[i]==s[i+1]) c++;
        if(s[i] != s[i+1] && c >0){
            count += c * (c+1)/ 2;
            c = 0;
        }
    }

    cout << count <<"\n";
    return 0;
}


Measured memory_bytes: 3456
#include <iostream>
using namespace std;
 
int main(){
  int x,y;
  cin >> x >> y;
  int turu, kame;
  if((y-2*x)%2==0 && y-2*x>=0){
    kame = (y-2*x)/2;
  }
  else{
    cout << "No" << endl;
    return 0;
  }
  if(x-kame>=0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
 
  return 0;
 
}

Measured memory_bytes: 3564
def main():
    n, m = map(int, input().split())
    x = list(map(int, input().split()))
    x = sorted(x)
    y = []
    s = x[m - 1] - x[0]
    for i in range(1, m):
        y.append(x[i] - x[i - 1])
    y = sorted(y, reverse=True)
    m = sum(y[0: n - 1])
    print(s - m)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 13968
import sys
from copy import deepcopy

def main():
    INF = 10**18
    input = sys.stdin.readline
    N, M, L = [int(x) for x in input().split()]
    d = [set() for _ in range(N+1)]
    ds = [[INF] * (N+1) for _ in range(N+1)]
    bs = [[INF] * (N+1) for _ in range(N+1)]
    for _ in range(M):
        A, B, C = [int(x) for x in input().split()]
        A, B = sorted([A, B])
        d[A].add(B)
        if L >= C:
            ds[A][B] = C

    nes = set()
    for k in range(1, N+1):
        for i in range(1, N+1):
            for j in range(i+1, N+1):
                ds[i][j] = min(ds[i][j], ds[min(i, k)][max(i, k)] + ds[min(k, j)][max(k, j)])
                if ds[i][j] <= L:
                    bs[i][j] = 1

    for k in range(1, N+1):
        for i in range(1, N+1):
            for j in range(i+1, N+1):
                bs[i][j] = min(bs[i][j], bs[min(i, k)][max(i, k)] + bs[min(k, j)][max(k, j)])

    Q, = [int(x) for x in input().split()]
    for _ in range(Q):
        s, t = sorted(int(x) for x in input().split())
        print(bs[s][t]-1 if bs[s][t] < INF else -1)


if __name__ == '__main__':
    main()


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

#define LLINF (1LL<<60)
typedef long long ll;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    int N,T;
    cin >>N>>T;

    vector<int> c(N),t(N);
    rep(i,N) cin >> c[i]>>t[i];
    
    //-----------------------------------
    int minc=1001;
    rep(i,N){
        if(t[i]<=T) chmin(minc,c[i]);
    }
    if(1000<minc){
       cout <<"TLE"<<endl; 
    }else{
        cout << minc <<endl;
    }
    return (0);
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll l, r;
    cin >> l >> r;

    vector<ll> mod;
    for(ll i=l; i<=min(r, l+2019); i++) {
        mod.push_back(i%2019);
    }

    int len = mod.size();
    int ans = 2020;
    for(int i=0; i<len; i++)
        for(int j=i+1; j<len; j++)
            if(mod[i]*mod[j]%2019 < ans)
                ans = mod[i]*mod[j]%2019;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a,b,c,d = inm()
for i in range(101):
    c -= b
    if c<=0:
        print('Yes')
        exit()
    a -= d
    if a<=0:
        print('No')
        exit()


Measured memory_bytes: 61816
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;

//Thanks for @zaki_joho
//繰り返し二乗法:a^b O(log b)
template<typename T>
T mypow(T a, T b)
{
    if (b == 0)
        return 1;
    T tmp = mypow(a, b / 2);
    if (b % 2)
        return (((tmp * tmp) % MOD) * a) % MOD;
    else
        return (tmp * tmp) % MOD;
}

int main(){
    ll h, w, a, b;
    cin >> h >> w >> a >> b;

    //nCk mod Mの計算テーブルを構築
    vll frc(2 * 1e5 + 10), inv(2 * 1e5 + 10);
    frc[0] = 1, inv[0] = 1;
    REP(i, 2 * 1e5 + 5){
        frc[i + 1] = (frc[i] * (i + 1)) % MOD;
        inv[i + 1] = mypow(frc[i + 1], MOD - 2);
    }

    auto comb = [&] (ll n, ll k){
        return (((frc[n] * inv[k]) % MOD) * inv[n - k]) % MOD;
    };
    
    ll sum = comb(h + w - 2, h - 1);
    ll x = b, y = h - a + 1, p, q;
    while(1){
        if(y > h || x < 1) break;
        p = w - x + 1, q = h - y + 1;
        sum += MOD;
        sum -= (comb(x + y - 2, x - 1) * comb(p + q - 2, p - 1)) % MOD;
        sum %= MOD;
        x--;
        y++;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int main()
{
	int l, r;
	int d;
	scanf("%d %d %d", &l, &r, &d);
	int count=0;
	
	for (int i=l; i<=r; i++){
		if(i%d==0){
		count++;
		}
	}
	printf("%d\n", count);
	
	return 0;
}

Measured memory_bytes: 1700
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

H,W=get_i
kind=Hash.new(0)
H.times do|i|
    get_nsp.each do|a|
        kind[a]+=1
    end
end

if W.even? or H.even?
  kind.each do|k,v|
      if kind[k].odd?
          puts "No"
          exit
      end
      kind[k]/=2
  end
  cnt=kind.count{|x| x[1].odd?}
  if W.even? and H.even?
    if cnt.zero?
        puts "Yes"
    else
        puts "No"
    end
  else
      even=(W.even? ? W : H)
      if cnt<=even/2
          puts "Yes"
      else
          puts "No"
      end
  end
else
    g={}
    g[1]=0
    g[2]=0
    g[4]=0
    kind.each do|k,v|
      if v>=4
          g[4]+=v/4
          v%=4
      end
      if v>=2
          g[2]+=1
          v%=2
      end
      if v==1
          g[1]+=1
      end
    end
    if g[1]==1 and g[4]>=(H/2)*(W/2) and (g[4]-(H/2)*(W/2))*2+g[2]>=H/2+W/2
        puts "Yes"
    else
        puts "No"
    end
end

Measured memory_bytes: 14464
/*
    f[x]表示以x为根的子树中，先把x染成白之后对方下一步是否会在x子树中操作 
    g[x]表示以x为根的子树中，先手是否能获得胜利。
    
    当我们枚举致胜节点为root时，先手能赢当且仅当g[root]=1. 
	
	初始化(对于单点)：
	     g[x]=1;
	     f[x]=0;
	
	
	转移：
	    1.f[x]等于所有儿子的g的位或
		 
		 这个不难理解，因为只要有一个儿子的g为1的话，我们先把x染白，
		 对方一定会在g为1的这个子树中操作，不然就输了。
		 
		2.g[x]等于所有儿子的f的位与
		
		 这个也不难理解，因为只有所有儿子的f都为1了，我们才可以依次把每个儿子染白
		 最后依然有先手优势来染x，然后就赢了hhhh
	
	考虑上述算法仅适用于根固定的情况 ，我们可以把它扩展一下，
	第一遍dfs预处理以某个节点为根的函数值，
	第二遍dfs在每个节点O(1)计算出函数值。 
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<vector>
#define ll long long
#define maxn 100005
#define pb push_back
using namespace std;
vector<int> son[maxn];
int n,m,g[maxn];
int f[maxn];
bool win=0;

void dfs1(int x,int fa){
	int sz=son[x].size()-1,to;
	f[x]=0,g[x]=1;
	
	for(int i=0;i<=sz;i++){
		to=son[x][i];
		if(to==fa) continue;;
		dfs1(to,x);
		f[x]|=g[to],g[x]&=f[to];
	}
}

void dfs2(int x,int fa,int fa_f,int fa_g){
	int sz=son[x].size()-1,to;
	int hzf[sz+2],hzg[sz+2];
	hzf[sz+1]=1,hzg[sz+1]=0;
	
	if(g[x]&fa_f) win=1;
	
	for(int i=sz;i>=0;i--){
		hzf[i]=hzf[i+1];
		hzg[i]=hzg[i+1];
		to=son[x][i];
		if(to==fa) continue;
		
		hzf[i]&=f[to];
		hzg[i]|=g[to];
	}
	
	for(int i=0;i<=sz;i++){
		to=son[x][i];
		if(to==fa) continue;
		
		dfs2(to,x,fa_g|hzg[i+1],fa_f&hzf[i+1]);
		fa_g|=g[to];
		fa_f&=f[to];
	}
}

int main(){
	int uu,vv;
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		scanf("%d%d",&uu,&vv);
		son[uu].pb(vv);
		son[vv].pb(uu);
	}
	
	dfs1(1,0);
	dfs2(1,0,1,0);
	
	if(win) puts("First");
	else puts("Second");
	
	return 0;
}

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

using namespace std;


void solve() {
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << a[k-1];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
s = [input() for _ in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            continue
        ok = False
        for dx, dy in [(1, 0), (0, 1), (0, -1), (-1, 0)]:
            nx = j + dx
            ny = i + dy
            if 0 <= nx < w and 0 <= ny < h and s[ny][nx] == '#':
                ok = True
        if not ok:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 9140
n = gets.to_i
for i in 1..n do
    puts "Case #{i}:"
    num = gets.to_i
    10.times do
        innum = num * num
        str = innum.to_s
        length = str.split("")
        zero = 8 - length.length
        rannsuustr = ("0" * zero) + str
        rannsuuhairetu = rannsuustr.split("")
        a = rannsuuhairetu[2]
        b = rannsuuhairetu[3]
        c = rannsuuhairetu[4]
        d = rannsuuhairetu[5]
        strnum = a + b + c + d
        num = strnum.to_i
        puts num

    end
end


Measured memory_bytes: 6996
import sys
import bisect
from collections import defaultdict

ans=0
#n=int(input())
n,m=map(int,input().split())
a=[(1,int(i)) for i in input().split()]

b=[0]*m
c=[0]*m
for i in range(m):
    b[i],c[i]=map(int,input().split())
    a.append((b[i],c[i]))
#a=sorted(a,reverse=True,key=lambda x:x[1])
a=sorted(a,key=lambda x:x[1])
#print(a)
t=0
while t<n:
    k,x=a.pop()
    if t+k<n:
        ans+=x*k
    else:
        ans+=x*(n-t)
    t+=k
    
print(ans)

Measured memory_bytes: 87064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  int n1 = n / 1000;
  int n2 = (n % 1000) / 100;
  int n3 = (n % 100) / 10;
  int n4 = n % 10;
  if ((n1 == n2 && n2 == n3) || (n2 == n3 && n3 == n4)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3560
use proconio::input;
use proconio::marker::Chars;

fn main() {

    input!{
        S:Chars
    }
    let N = S.len();

    for i in 1..N{
        if S[i] == S[i-1]{
            println!("{} {}",i,i+1);
            return;
        }
    }

    for i in 2..N{
        if S[i] == S[i-2]{
            println!("{} {}",i-1,i+1);
            return;
        }
    }
    println!("-1 -1");
}

Measured memory_bytes: 2468
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pi acos(-1)
#define mod 1000000007
#define inf INT_MAX
int main()
{
    int i,j,k,n,t,ans,ct=0;
    string s,ss;
    cin>>s>>ss;
    n=s.size();
    for(i=0;i<n;i++)
    {
        if(s[i]!=ss[i])
            ct++;
    }
   cout<<ct<<endl;




}




Measured memory_bytes: 3788
import java.util.Scanner;

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

        final Scanner scanner = new Scanner(System.in);

        while(true){
           int h = scanner.nextInt();
           int w = scanner.nextInt();
        if(h == 0 && w == 0){
            break;
        }
        for(int i=1;i<=h;i++){
            if(i % 2 == 1){
                for(int j=1;j<=w;j++){
                    if(j % 2 == 1){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                    if(j == w){
                        System.out.println();
                        
                        
                    }
                }
               }else{
                      for(int j=1;j<=w;j++){

                        if(j % 2 == 0){
                        System.out.print("#");
                    }else{
                        System.out.print(".");
                    }
                    if(j == w){
                        System.out.println();
                        
                    }
                }

                    }

            }
                System.out.println();
        }
     
    }
        
   
    }


Measured memory_bytes: 34784
N = int(input())
A = [0]+list(map(int,input().split()))+[0]
money = 0
L = [0]*(N+1)
for i in range(N+1):
    L[i] = abs(A[i+1]-A[i])
    money += L[i]

for i in range(1,N+1):
    ans = money - (L[i-1]+L[i] - abs(A[i+1]-A[i-1]))
    print(ans)


Measured memory_bytes: 14176
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int n,U;
int a[300010];
P dp[300010];

void solve(){
    cin >> n;
    U=(1 << n)-1;
    rep(i,U+1) cin >> a[i];
    rep(S,U+1){
        dp[S]=P(-1,-1);
    }
    dp[0]=P(0,-1);
    Rep(S,1,U+1){
        set<P> se;
        se.insert(P(a[S],S));
        rep(i,n){
            if(S&(1 << i)){
                int p1=dp[S^(1 << i)].first;if(p1!=-1)se.insert(P(a[p1],p1));
                int p2=dp[S^(1 << i)].second;if(p2!=-1)se.insert(P(a[p2],p2));
            }
        }
        auto it=se.end();it--;
        dp[S].first=(*it).second;
        it--;
        dp[S].second=(*it).second;
        //cout << dp[S].first << " " << dp[S].second << endl;
    }
    int ans=0;
    Rep(S,1,U+1){
        ans=max(ans,a[dp[S].first]+a[dp[S].second]);
        cout << ans << endl;
    }
}

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

Measured memory_bytes: 6664
#include<cstdio>
#define R register
using namespace std;
int n,cnt,sum;
int prime[1005],a[1000005],bz[1005],vis[1000005];
int read(){
	int s=0;
	char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) s=(s<<1)+(s<<3)+(ch^48);
	return s;
}
int gcd(int xx,int yy){
	if (yy==0) return xx;
	return gcd(yy,xx%yy);
}
void work(){
	for (R int i=2;i<=1000;++i){
		if (!bz[i]){
			bz[i]=1;
			prime[++cnt]=i;
			for (int j=i*2;j<=1000;j+=i)
				bz[j]=1;
		}
	}
	return;
}
bool pd(){
	for (R int i=1;i<=n;++i){
		int s=a[i];
		for (R int j=1;j<=cnt;++j){
			if (prime[j]*prime[j]>s) break;
			if (s%prime[j]==0){
				if (vis[prime[j]]) return 0;
				vis[prime[j]]=1;
				while (s%prime[j]==0&&s) s/=prime[j];
			}
		}
		if (s>1){
			if (vis[s]) return 0;
			vis[s]=1;
		}
	}
	return 1;
}
int main(){
	n=read();
	for (R int i=1;i<=n;++i)
		a[i]=read();
	sum=a[1];
	for (R int i=2;i<=n;++i)
		sum=gcd(sum,a[i]);
	if (sum==1){
		work();
		if (pd()) printf("pairwise coprime");
		else printf("setwise coprime");
	}
	else printf("not coprime");
	return 0;
}

Measured memory_bytes: 5800
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9 + 5;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
using namespace std;

int n,m,u,v;
int memo[110000];
bool fl[110000];
vector<int> eg[110000];


int dp(int v){
    if(fl[v]){
        return memo[v];
    }
    int ans = 0;
    for(int to: eg[v]){
        ans = max(ans, dp(to) + 1);
    }
    fl[v] = true;
    memo[v] = ans;
    return ans;
}
struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    UnionFind uf(n+1);

    REP(i,m){
        int a,b;
        cin >> a >> b;
        uf.unite(a,b);
        uf.unite(b,a);
    }    

    set<int> st;
    for(int i = 1;i<=n;i++){
        st.insert(uf.Find(i));
    }

    cout << st.size()-1 <<endl;
}





Measured memory_bytes: 10008
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int n;
    cin >> n;
    vi dp(n + 1, 1e9);
    dp[1] = 0;
    vi hs(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> hs[i + 1];
    }

    for (int i = 2; i <= n; i++) {
        if (i == 2) {
            dp[i] = dp[i - 1] + abs(hs[i] - hs[i - 1]);
        } else {
            dp[i] = min(dp[i - 1] + abs(hs[i] - hs[i - 1]), dp[i - 2] + abs(hs[i] - hs[i - 2]));
        }
    }

    cout << dp.back() << endl;
}

Measured memory_bytes: 1792
s = raw_input()
l = len(s)
s = s[:l-1]
l -= 1

def thisIsIt(s):
    l = len(s)
    if l%2 == 1:
        return False
    u = s[:l/2]
    b = s[l/2:]
    if u == b:
        return True

while 0 < l:
    if thisIsIt(s):
        print l
        exit()
    s = s[:l-1]
    l -= 1


Measured memory_bytes: 2568
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
  char suit;
  int value;
};

struct Card L[MAX/2 + 2],R[MAX/2 + 2];

void merge(struct Card A[],int n,int left,int mid, int right){
  int i,j,k;
  int n1 = mid - left;
  int n2 = right - mid;
  for(i = 0 ; i < n1 ; i++){
    L[i] = A[left + i];
  }
  for(i = 0 ; i < n2 ; i++){
    R[i] = A[mid + i];
  }
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for(k = left ; k < right ; k++){
    if(L[i].value <= R[j].value)A[k] = L[i++];
    else A[k] = R[j++];
  }
}

void mergeSort(struct Card A[],int n,int left,int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A,n,left,mid);
    mergeSort(A,n,mid,right);
    merge(A,n,left,mid,right);
  }
}

int partition(struct Card A[],int n,int p,int r){
  int i,j;
  struct Card t,x;
  x = A[r];
  i = p - 1;
  for(j = p ; j < r ; j++){
    if(A[j].value <= x.value){
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;
  return i + 1;
}
void quickSort(struct Card A[],int n,int p,int r){
  int q;
  if(p < r){
    q = partition(A,n,p,r);
    quickSort(A,n,p,q - 1);
    quickSort(A,n,q + 1,r);
  }
}

int main(){
  int n,i,v,stable = 1;
  struct Card A[MAX],B[MAX];
  char S[10];
  scanf("%d",&n);
  for(i = 0 ; i < n ; i++){
    scanf("%s %d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }
  mergeSort(A,n,0,n);
  quickSort(B,n,0,n - 1);
  for(i = 0 ; i < n ; i++){
    if(A[i].suit != B[i].suit)stable = 0;
  }
  if(stable == 1)printf("Stable\n");
  else printf("Not stable\n");
  for(i = 0 ; i < n ; i++){
    printf("%c %d\n",B[i].suit,B[i].value);
  }
  return 0;
}



Measured memory_bytes: 4116
// Problem : A - The Number of Even Pairs
// Contest : AtCoder Beginner Contest 159
// URL : https://atcoder.jp/contests/abc159/tasks/abc159_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

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 FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0);
	int n, m;
	cin >> n >> m;
	cout << (n * (n - 1)) / 2 + (m * (m - 1)) / 2;
	return 0;
}
 


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ++cnt[a[i]];
    }
    if (cnt[0] == n) {
        cout << "Yes" << '\n';
        return 0;
    }
    if (n % 3 != 0) {
        cout << "No" << '\n';
        return 0;
    }
    vector<int> all;
    for (auto& p : cnt) {
        for (int i = 0; i < p.second / (n / 3); i++) {
            all.push_back(p.first);
        }
    }
    if (all.size() == 3 && (all[0] ^ all[1] ^ all[2]) == 0) {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
    return 0;
}


Measured memory_bytes: 4224
a, b = input().split()
a = int(a)
b = int(b[0] + b[2] + b[3])
c = str(a*b)
if len(c) <= 2:
    print(0)
else:
    for i in range(len(c)):
        if i == len(c)-2:
            break
        print(c[i], end='')
    print('')

Measured memory_bytes: 9036
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;


int main(){
    int N,M,C; cin >> N>>M>>C;
    int A[30][30];
    int B[30];
    rep(i, M) cin >> B[i];
    rep(i, N){
        rep(j, M) cin >> A[i][j];
    }
    int count = 0;
    rep(i, N){
        int ans = 0;
        rep(j, M){
            ans += A[i][j] * B[j] ;
            // cout ?<< A[i][j] << " " << B[j] << endl;
        }
        ans +=C;
        // cout << ans << endl;
        if(ans > 0) count++;
    }
    // cout << C << endl;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256