akhauriyash/Code-Regression huggingface dataset:
//It doesn't matter how slow you go, Unless you don't stop.
#include<iostream>
#include<algorithm>
#include<bitset>
 
#include<cmath>
#include<cstring>
#include<climits>
 
#include<deque>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
 
#include<fstream>
#include<chrono>
using namespace std;
 
typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;
typedef map<LL,LL> mp64;
 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

LL bincoef(int n,int k)
{
    // LL dp[k+1]; 
    // memset(dp, 0, sizeof(dp)); 
  
    // dp[0] = 1; 
  
    // for (int i = 1; i <= n; i++) 
    // { 
    //     for (int j = min(i, k); j > 0; j--) 
    //         dp[j] = dp[j] + dp[j-1]; 
    // } 
    // return dp[k];
    if(n<=1)
    {
        return 0;
    }
    LL res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }   
    return res; 
}

void solve()
{
     int n;cin>>n;
     LL a[n];
     map<int,int> m;
     map<LL,LL> pre;
     LL sum = 0;
     for(int i=0;i<n;i++)
     {
         cin>>a[i];
         m[a[i]]++;
     }
    //  for(auto it:m)
    //  {
    //      cout<<it.first<<" "<<it.second<<endl;
    //  }
     for(auto it:m)
     {
         LL x = bincoef(it.second,2);
         pre[it.first] += x;
         sum += x;
     }
    //  for(auto it:pre)
    //  {
    //      cout<<it.first<<" "<<it.second<<endl;
    //  }
     for(int i=0;i<n;i++)
     {
         int elmt = a[i];
         //cout<<"Element "<<elmt<<endl;
         LL res=sum;
        //  for(auto it:pre)
        //  {
        //      if(it.first!=elmt)
        //      {
        //          res += it.second;
        //      }
        //  }
         res -= pre[elmt];
        // cout<<res<<endl;
         LL addent =  bincoef(m[elmt]-1,2);
         //cout<<addent<<endl;
         res += addent;
         cout<<res<<endl;
        // cout<<endl;
     }
}
 
int main()
{
    DANGER;
    ofstream out("output.txt");
 
    auto start = chrono::high_resolution_clock::now();
    
    LL t = 1;
    // cin>>t;
    rep(test,1,t)
    {
        solve();
    }
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

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

using namespace std;


int main() {
	int n, y, b, r, t, id;
	double sum, maxMoney;

	while (cin >> n, n) {
		cin >> y;
		maxMoney = 0.0;
		for (int i = 0; i < n; ++i) {
			cin >> b >> r >> t;
			if (t == 1) {
				sum = 1.0 + y*r / 100.0;
			}
			else {
				sum = pow((1.0 + r / 100.0), y);
			}
			if (sum > maxMoney) {
				maxMoney = sum;
				id = b;
			}
		}
		cout << id << endl;
	}

	return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define PSUM(c) partial_sum(ALL(c), begin(c))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    vi a(N);
    cin >> a;
    
    auto solve = [&]() {
        int diameter = (*max_element(ALL(a)));
        map<int, int> cnt;
        FORE(x, a) cnt[x]++;
        REPF(i, (diameter + 3) / 2, diameter + 1) {
            if (cnt[i] < 2) {
                return false;
            }
        }
        if ((diameter % 2 == 0 && cnt[diameter / 2] != 1)
            || (diameter % 2 && cnt[(diameter + 1) / 2] != 2)) {
            return false;
        }
        return true;
    };
    cout << (solve() ? "Possible" : "Impossible") << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
    int len,i,count=0;
    char str[100],s[]="ABC",ch;
    scanf("%d%c",&len,&ch);
    gets(str);
    for(i=0;str[i]!='\0';i++)
    {
        if(str[i]=='A')
        {
            if(str[i+1]=='B')
            {
                if(str[i+2]=='C')
                {
                    count++;
                }
            }
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;
class Main{
	public static void main(String[]args){
    	Scanner in = new Scanner(System.in);
      	int n = in.nextInt();
      	int x = in.nextInt();
      	if(x!=n)
          System.out.println("No");
      	else
          System.out.println("Yes");
    }
}

Measured memory_bytes: 23636
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int A[n+1];
	for(int i=1; i<n+1; i++)
		cin>>A[i];
	for(int i=1; i<n+1; i++){
		cout<<"node "<<i<<": key = "<<A[i]<<", ";
		if(i/2>=1)	cout<<"parent key = "<<A[i/2]<<", ";
		if(i*2<=n)	cout<<"left key = "<<A[i*2]<<", ";
		if(i*2+1<=n)	cout<<"right key = "<<A[i*2+1]<<", ";
		cout<<endl;
	}
	return 0;
}


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

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

  int Ans = 0;
  rep( i, N, 1000 ) {
    if ( i%111 == 0 ) {
      Ans = i;
      break;
    }
  }

  cout << Ans << endl;
}


Measured memory_bytes: 256
from itertools import accumulate
n,k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = []

num = 0
maxi= 0
l = list(accumulate([0] + a))
for i in range(0,n-k+1):
    if l[i+k] - l[i] > maxi:
        maxi = l[i+k] - l[i]
        num = i  

for i in range(n):
    b.append((1+a[i])/2)
    
ans = sum(b[num:k+num])
print(ans)

Measured memory_bytes: 27172
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int x;

int main() {
	cin >> x;
	if (x == 3 || x == 5 || x == 7)cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

int main() {
  int n, m, c;
  std::cin >> n >> m >> c;

  std::vector<int> b(m);
  for (auto &i : b) {
    std::cin >> i;
  }

  std::vector<std::vector<int>> a(n);
  for (auto &i : a) {
    i = std::vector<int>(m);
    for (auto &j : i) {
      std::cin >> j;
    }
  }

  int ans = 0;

  for (int i = 0; i < n; i++) {
    int64_t val = 0;
    for (int j = 0; j < m; j++) {
      val += a[i][j] * b[j];
    }
    val += c;

    if (val > 0) {
      ans++;
    }
  }

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


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <map>
#include <algorithm>
#include <vector>
#include <queue>
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
typedef long long ll;
using namespace std;

ll w[100000];
ll n, k;

ll f(ll P) {
	vector<ll> track;
	for (int i = 0;i < k;i++) track.push_back(P);
	ll wi=0,ti=0;
	while (ti < k&&wi<n) {
		if (w[wi] <= track[ti]) {
			track[ti] -= w[wi];
			wi++;
		}
		else {
			ti++;
		}
	}
	return wi;
}

int main() {
	cin >> n >> k;
	for (int i = 0;i < n;i++) cin >> w[i];
	ll P;
	ll left = 0, right = 1000000000;
	while(left<right){
		P = (left + right) / 2;
		if (f(P) == n) {
			right = P;
		}
		else if (f(P) < n) {
			left = P+1;
		}
	};
	cout << right << endl;
}

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

namespace Atc_0027
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int A = int.Parse(s.Split(' ')[0]);
            int B = int.Parse(s.Split(' ')[1]);
            int C = int.Parse(s.Split(' ')[2]);

            if ((A + B + C) <= 21)
            {
                Console.WriteLine("win");
            }
            else
            {
                Console.WriteLine("bust");
            }
        }
    }
}


Measured memory_bytes: 27448
N, Y = gets.split.map(&:to_i)
(0..N).each do |n10|
    (0..(N-n10)).each do |n5|
        n1 = N - n10 - n5
        next if n1 < 0
        if (10 * n10 + 5 * n5 + n1) * 1000 == Y
            puts "#{n10} #{n5} #{n1}"
            exit
        end
    end
end
puts "-1 -1 -1"


Measured memory_bytes: 1788
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

  public static void main(String[] args) {
    FastScanner sc = new FastScanner();

    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    String[] S = sc.next().split("");

    int a = 0;
    int b = 0;
    for (int i = 0; i < N; i++) {
      if (S[i].equals("a") && a + b < A + B) {
        System.out.println("Yes");
        a++;
        continue;
      } else if (S[i].equals("b") && b < B && a + b < A + B) {
        System.out.println("Yes");
        b++;
        continue;
      }
      System.out.println("No");

    }

  }
}

class FastScanner {
  private final InputStream in = System.in;
  private final byte[] buffer = new byte[1024];
  private int ptr = 0;
  private int buflen = 0;

  private boolean hasNextByte() {
    if (ptr < buflen) {
      return true;
    } else {
      ptr = 0;
      try {
        buflen = in.read(buffer);
      } catch (IOException e) {
        e.printStackTrace();
      }
      if (buflen <= 0) {
        return false;
      }
    }
    return true;
  }

  private int readByte() {
    if (hasNextByte()) {
      return buffer[ptr++];
    } else {
      return -1;
    }
  }

  private static boolean isPrintableChar(int c) {
    return 33 <= c && c <= 126;
  }

  private void skipUnprintable() {
    while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
      ptr++;
    }
  }

  public boolean hasNext() {
    skipUnprintable();
    return hasNextByte();
  }

  public String next() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    StringBuilder sb = new StringBuilder();
    int b = readByte();
    while (isPrintableChar(b)) {
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public int nextInt() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    int n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }

  public long nextLong() {
    if (!hasNext()) {
      throw new NoSuchElementException();
    }
    long n = 0;
    boolean minus = false;
    int b = readByte();
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    if (b < '0' || '9' < b) {
      throw new NumberFormatException();
    }
    while (true) {
      if ('0' <= b && b <= '9') {
        n *= 10;
        n += b - '0';
      } else if (b == -1 || !isPrintableChar(b)) {
        return minus ? -n : n;
      } else {
        throw new NumberFormatException();
      }
      b = readByte();
    }
  }
}

Measured memory_bytes: 47008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define rALL(x) x.rbegin(), x.rend()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<vector<char>> g;
int main(){
    string s;   cin >> s;
    map<ll, ll> mp;
    mp[0] = 1;
    reverse(ALL(s));
    ll now=0, dig=1;
    rep(i, s.size()){
        now = (now+(s[i]-'0')*dig)%2019;
        dig *= 10;
        dig %= 2019;
        mp[now]++;
    }
    ll res=0;
    for(auto x: mp) res += x.second*(x.second-1)/2;
    cout << res << endl;
}


Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
int N,c;
string S;
int main(){
  cin>>N>>S;
  for(char i='0';i<='9';i++){
    auto it_i = S.find(i);
    if(it_i==string::npos)continue;
    for(char j='0'; j<='9'; j++){
      auto it_j=S.find(j,it_i+1);
      if(it_j==string::npos)continue;
      for(char k='0';k<='9';k++)if(S.find(k,it_j+1)!=string::npos)c++;
    }
  }
  cout<<c<<endl;
  return 0;
}


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

void comb(vector<vector<ll>> &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

int main() {
    ll N, P, A;
    cin >> N >> P;
    vector<vector<ll> > v(N+1,vector<ll>(N+1,0));
    vector<ll> odd, even;
    rep(i,N) {
        cin >> A;
        if (A % 2 == 0) even.push_back(A);
        else odd.push_back(A);
    }
    ll ans = 0;
    comb(v);
    ans = pow(2LL, even.size());
    ll tmp = 1;
    for (ll i = 1; i * 2 <= odd.size(); ++i) {
        tmp += v.at(odd.size()).at(i * 2);
    }
    ans *= tmp;
    if (P == 1) ans = pow(2LL, N) - ans;
    cout << ans << endl;
}



Measured memory_bytes: 4060
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().rstrip()


def culc(li):
    li.sort(key=lambda x: x[0])
    ans = 10**9
    for i in range(len(li)-1):
        if li[i][1] == '+' and li[i+1][1] == '-':
            ans = min(ans, li[i+1][0]-li[i][0])
    return ans


def main():
    N = int(input())
    axisX = defaultdict(list)
    axisY = defaultdict(list)
    XplusYplus = defaultdict(list)
    XminusYminus = defaultdict(list)
    XminusYplus = defaultdict(list)
    XplusYminus = defaultdict(list)
    ans = 10**9
    for _ in range(N):
        x, y, u = input().split()
        x, y = int(x), int(y)
        if u == 'U':
            axisY[x].append([y, '+'])
            XplusYplus[x+y].append([y-x, '+'])
            XminusYplus[x-y].append([x+y, '+'])
        elif u == 'R':
            axisX[y].append([x, '+'])
            XplusYplus[x+y].append([y-x, '-'])
            XplusYminus[x-y].append([x+y, '+'])
        elif u == 'D':
            axisY[x].append([y, '-'])
            XminusYminus[x+y].append([y-x, '-'])
            XplusYminus[x-y].append([x+y, '-'])
        elif u == 'L':
            axisX[y].append([x, '-'])
            XminusYminus[x+y].append([y-x, '+'])
            XminusYplus[x-y].append([x+y, '-'])

    for v in axisX.values():
        if len(v) > 1:
            ans = min(culc(v), ans)
    for v in axisY.values():
        if len(v) > 1:
            ans = min(culc(v), ans)
    for v in XplusYplus.values():
        if len(v) > 1:
            ans = min(culc(v), ans)
    for v in XplusYminus.values():
        if len(v) > 1:
            ans = min(culc(v), ans)
    for v in XminusYplus.values():
        if len(v) > 1:
            ans = min(culc(v), ans)
    for v in XminusYminus.values():
        if len(v) > 1:
            ans = min(culc(v), ans)
    print('SAFE' if ans > 10**8 else 5 * ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 181232
H,W,K = map(int,input().split())
S = [input().strip() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]
row = 0
cnt = 1
for i in range(H):
    B = []
    for j in range(W):
        if S[i][j]=="#":
            B.append(j)
    if len(B)==0:
        continue
    elif len(B)==1:
        for k in range(row,i+1):
            for j in range(W):
                A[k][j] = cnt
        cnt += 1
        row = i+1
    else:
        for l in range(len(B)):
            if l==0:
                for k in range(row,i+1):
                    for j in range(B[0]+1):
                        A[k][j] = cnt
                cnt += 1
            elif l<len(B)-1:
                for k in range(row,i+1):
                    for j in range(B[l-1]+1,B[l]+1):
                        A[k][j] = cnt
                cnt += 1
            else:
                for k in range(row,i+1):
                    for j in range(B[-2]+1,W):
                        A[k][j] = cnt
                cnt += 1
        row = i+1
if row != H:
    for i in range(row,H):
        for j in range(W):
            A[i][j] = A[i-1][j]
for i in range(H):
    print(*A[i])

Measured memory_bytes: 7556
package main

import "fmt"

func remaining_xs(h, w int, ss []string) []int {
	xs := make([]int, 0)
OUTER:
	for x := 0; x < w; x++ {
		for y := 0; y < h; y++ {
			if ss[y][x] != '.' {
				xs = append(xs, x)
				continue OUTER
			}
		}
	}
	return xs
}

func remaining_ys(h, w int, ss []string) []int {
	ys := make([]int, 0)
OUTER:
	for y := 0; y < h; y++ {
		for x := 0; x < w; x++ {
			if ss[y][x] != '.' {
				ys = append(ys, y)
				continue OUTER
			}
		}
	}
	return ys
}

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	ss := make([]string, h)
	for i := range ss {
		fmt.Scan(&ss[i])
	}

	xs := remaining_xs(h, w, ss)
	ys := remaining_ys(h, w, ss)

	for _, y := range ys {
		for _, x := range xs {
			fmt.Printf("%c", ss[y][x])
		}
		fmt.Print("\n")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        cin >> n;
        vector<int>  v(n);
        for (int i = 0; i < n; i++) cin >> v[i];

        ll x2 = 0;
        for (int i = 0; i < n; i++) {
            if (i & 1) x2 -= v[i];
            else x2 += v[i];
        }
        vector<int> ans(n);
        ans[0] = x2 / 2;
        for (int i = 0; i < n - 1;  i++) {
            ans[i + 1] = v[i] - ans[i];
        }
        for (int i = 0; i < n; i++) {
            cout << ans[i] * 2 << " ";
        }
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

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

int main(void){
    int a, b, c;
    int k;
    int sum = 0;
    cin >> a >> b >> c;
    cin >> k;
    int MAX = max({a, b, c});
    int MMAX;

    for(int i = 1; i <= k; i++)
        MAX *= 2;
    MMAX = MAX;
    sum += MMAX;
    
    sum = sum + a + b + c;
    sum -= max({a, b, c});

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a); i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
  string s;
  cin >> s;
  ull memo[max(1,(int)s.size()-1)] = {0},tmp,cnt = 0;
  
  
  rep(i,0,pow(2,s.size()-1)){
    tmp = i;
    rep(j,0,s.size()-1){
      memo[j] = tmp % 2;
      tmp /= 2;
    }
    tmp = (int)s[0]-48;
    rep(j,0,s.size()-1){
      if(memo[j] == 0){
        tmp *= 10;
        tmp += (int)(s[j+1]-48);
      }
      else{
        cnt += tmp;
        tmp = (int)s[j+1]-48;
      }
      
    }
    cnt += tmp;
  }
  
  cout << cnt << endl;
  
    return 0;   
}

Measured memory_bytes: 256
n=int(input())
if n%2!=0:
  print(0)
  exit(0)
n//=10

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = str(X_dumy%n)+out
        X_dumy = X_dumy//n
    return out

n=Base_10_to_n(n,5)
n=reversed(list(n))
tmp=1
ans=0

for i in n:
  ans+=int(i)*tmp
  tmp=tmp*5+1
print(ans)

Measured memory_bytes: 9068
n, k = map(int, input().split())
mod = 998244353
LR = []
for i in range(k):
    l, r = map(int, input().split())
    LR.append((l, r))

class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(self.n+1) # 1-indexed

    def init(self, init_val):
        for i, v in enumerate(init_val):
            self.add(i, v)

    def add(self, i, x):
        # i: 0-indexed
        i += 1 # to 1-indexed
        while i <= self.n:
            self.bit[i] += x
            i += (i & -i)

    def sum(self, i, j):
        # return sum of [i, j)
        # i, j: 0-indexed
        return self._sum(j) - self._sum(i)

    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        res = 0
        while i > 0:
            res += self.bit[i]
            i -= i & (-i)
        return res

class RangeAddBIT:
    def __init__(self, n):
        self.n = n
        self.bit1 = BIT(n)
        self.bit2 = BIT(n)

    def init(self, init_val):
        self.bit2.init(init_val)

    def add(self, l, r, x):
        # add x to [l, r)
        # l, r: 0-indexed
        self.bit1.add(l, x)
        self.bit1.add(r, -x)
        self.bit2.add(l, -x*l)
        self.bit2.add(r, x*r)

    def sum(self, l, r):
        # return sum of [l, r)
        # l, r: 0-indexed
        return self._sum(r) - self._sum(l)

    def _sum(self, i):
        # return sum of [0, i)
        # i: 0-indexed
        return self.bit1._sum(i)*i + self.bit2._sum(i)

bit = RangeAddBIT(n+10)
bit.add(1, 2, 1)
for i in range(1, n):
    t = bit.sum(i, i+1)
    t %= mod
    #print(t)
    for j in range(k):
        l, r = LR[j]
        bit.add(i+l, i+r+1, t)
print(bit.sum(n, n+1)%mod)


Measured memory_bytes: 111080
S = input()
T = input()

d1 = dict()
d2 = dict()
L = len(S)
for i in range(L):
    s = S[i]
    t = T[i]
    if s in d1 and d1[s] != t:
        print("No")
        exit()
    else:
        d1[s] = t
    if t in d2 and d2[t] != s:
        print("No")
        exit()
    else:
        d2[t] = s
print("Yes")


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

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

    int H,N; cin >> H >> N;
    int A[N],B[N];
    rep(i,N) cin >> A[i] >> B[i];
    int dp[H+1];
    rep(i,H+1) dp[i]=INF;
    dp[0]=0;
    rep(i,N){
        rep(j,H){
            chmin(dp[j+1],dp[max((int)0,j+1-A[i])]+B[i]);
        }
    }
    cout << dp[H] << endl;
}

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

bool binary_search(int *s, int s_size, int num) {
    int left = 0, right = s_size - 1, mid;
    if (s[left] == num || s[right] == num) return true;
    
    while (right - left != 1) {
        mid = (left + right) / 2;
        if (s[mid] > num) {
            right = mid;
        }
        else if (s[mid] == num) return true;
        else {
            left = mid;
        }
    }
    
    return false;
}

int main() {
    int n; cin >> n;
    int s[n]; for (int i = 0; i < n; ++i) cin >> s[i];
    int q; cin >> q;
    int t[q]; for (int i = 0; i < q; ++i) cin >> t[i];
    
    int cnt = 0;
    for (int t_i = 0; t_i < q; ++t_i) {
        if (binary_search(s, n, t[t_i])) ++cnt;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,tmp;
    cin>>n;
    vector<ll> v;
    ll sum = 0;
    for(int i=0;i<n;i++){
        cin>>tmp;
        v.pb(tmp);
        sum+=tmp;
    }
    bitset<4040040> dp;
    dp[0]=1;
    for(int i=0;i<n;i++){
        dp|=dp<<v[i];
    }
    ll ans = (sum+1)/2;
    for(ll i=ans;i<=sum;i++){
        if(dp[i]){
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 5164
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#ifndef rd
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

int a,b,c,d;
int ans;
unordered_map<int,int> pool;
void solve(int n, int poo) {
	if(poo>=ans||n<0)
		return;
	if(pool.find(n)!=pool.end()&&pool[n]<=poo)
		return;
	pool[n]=poo;
	if(n==0) {
		ans=poo;
		return;
	}
	if((n+0.0)*d<1e18)
		ans=min(ans,poo+n*d);
	for(int i=0; ; i++) {
		int nn=n;
		for(int j=0; ; j++) {
			int nnn=nn;
			for(int k=0; ; k++) {
				if(k) {
					for(int p=1; p<=3; p++)
						solve(nnn-p,poo+i*a+j*b+k*c+p*d);
					for(int p=1; p<=2; p++)
						solve(nnn+p,poo+i*a+j*b+k*c+p*d);
				} else if(j) {
					for(int p=1; p<=2; p++)
						solve(nnn-p,poo+i*a+j*b+k*c+p*d);
					for(int p=1; p<=1; p++)
						solve(nnn+p,poo+i*a+j*b+k*c+p*d);
				} else if(i) {
					for(int p=1; p<=1; p++)
						solve(nnn-p,poo+i*a+j*b+k*c+p*d);
					for(int p=1; p<=1; p++)
						solve(nnn+p,poo+i*a+j*b+k*c+p*d);
				}
				if(nnn%5)
					break;
				nnn/=5;
			}
			if(nn%3)
				break;
			nn/=3;
		}
		if(n&1)
			break;
		n/=2;
	}
}
void solve() {
	pool.clear();
	int n;
	cin>>n>>a>>b>>c>>d;
	ans=61*(a+d);
	for(int i=-3; i<=3; i++)
		solve(n+i,abs(i)*d);
	cout<<ans<<endl;
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(8);
	int t=1;
	cin>>t;
	fr(i,1,t) {
		solve();
	}
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 4940
#include <bits/stdc++.h>
using namespace std;
string s;
int num=0;
int main()
{
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='a') num+=5;
        if(s[i]=='b') num+=2;
        if(s[i]=='c') num+=100;
    }
    if(num==107) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    int N;
    cin>>N;
    vector<int> A;
    rep(i,N){
        int tmp;
        cin>>tmp;
        A.push_back(tmp);
    }
    sort(all(A));
    long long ans=0;
    //1番高いやつ+2番目に高いやつ+2番目に高いやつ+3番目に高いやつ+3番目に高いやつ...をN-1項足す
    rep(i,N-1){
        if(i==0){
            ans+=A[N-1];
        }else{
            if(i%2==0){
                ans+=A[N-((i/2)+1)];
            }else{
                ans+=A[N-((i+1)/2+1)];
            }
        }
    }
    

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

Measured memory_bytes: 4268
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<double> v(n);
    rep(i, n) cin >> v[i];

    sort(v.begin(), v.end());
    double tmp = (v[0] + v[1])/2;
    v[1] = tmp;
    for(int i = 2; i < n; i++){
        double c = (v[i-1] + v[i]) / 2;
        v[i] = c;
    }
    prtd(v[n-1], 6);

}


Measured memory_bytes: 256
using System;

namespace Getting_Started
{
    class Maximum_Profit
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var R = new int[n];
            for (int i = 0; i < R.Length; i++)
                R[i] = int.Parse(Console.ReadLine());

            var min = R[0];
            var max = -1e9;

            for (int i = 1; i < R.Length; i++)
            {
                if (R[i] - min > max) max = R[i] - min;
                if (R[i] < min) min = R[i];
            }

            Console.WriteLine(max);
        }
    }
}

Measured memory_bytes: 10872
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }

}

use std::cmp::{max, min};

fn main() {
    let n: usize = read();
    let k: i64 = read();
    let q: usize = read();
    let a: Vec<i64> = read_n(q);

    let mut point = vec![0; n];

    for i in a {
        let idx = (i - 1) as usize;
        point[idx] += 1;
    }

    for i in point {
        if k - (q as i64 - i) > 0 {
            println!("{}", "Yes");
        } else {
            println!("{}", "No");
        }
    }
}


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

//macro-----------------------------------------------------------------------------------------
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i=a;i>b;i--)
#define int long long

//constant--------------------------------------------------------------------------------------
const int inf = 100100100100000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//general_method--------------------------------------------------------------------------------
vector<int> cs(vector<int> arr){vector<int> ret = arr;rep(i,1,arr.size()){ret[i] += ret[i-1];}return ret;}
int ceil(int a, int b){if(a%b == 0) return a/b;else return a/b + 1;}
int digitlen(int i){int t = i;int count = 0;while(t){count += 1;t /= 10;}return count;}
int gcd(int m, int n){if((0== m)||(0 == n))return 0;while(m != n){if(m > n)m = m - n;else n = n - m;}return m;}
int lcm(int n, int m){return n*m/gcd(n,m);}

//io_method-------------------------------------------------------------------------------------
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
void print(int n){cout << n << endl;}
void print(vector<int> arr){cout << arr[0];rep(i,1,arr.size()) cout << " " << arr[i];cout << endl;}
void print(string s){cout << s << endl;}
void print(pair<int, int> p){cout << p.first << " " << p.second;}
void print(vector<vector<int>> arr){rep(i,0,arr.size()){print(arr[i]);}}

//main------------------------------------------------------------------------------------------


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

    int n = input();
    cout << n << ":";
    int t = n;
    rep(i,2,sqrt(t)+1){
        while(n % i == 0){
            cout << " " << i;
            n /= i;
        }
    }
    if(n > 1) cout << " " << n;
    print("");
    


}


Measured memory_bytes: 3224
using System;
using System.Dynamic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] inputNum = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            if (inputNum[0] == inputNum[1]) {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 28304
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
	fast


		
	int n;
	cin>>n;

	ll sum = 0;

	vi a(n),b(n),c(n-1);
	forn(i,0,n)
	{
		cin>>a[i];
	}	
	forn(i,0,n)
	{
		cin>>b[i];
	}	
	forn(i,0,n-1)
	{
		cin>>c[i];
	}	

	forn(i,0,n)
	{
		sum += b[a[i]-1];
		if(i+1 < n && (a[i+1]-a[i]) == 1)
		{
			sum += c[a[i]-1];
		}
	}

	cout<<sum;






	return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 112345;
int A[MAX_N], B[MAX_N];
int main2() {
  int N = nextInt();
  vector< pair<int,int> > v;
  REP(i, N){
    A[i] = nextInt();
    B[i] = nextInt();
    v.push_back({A[i] + B[i], i});
  }
  sort(ALL(v));
  reverse(ALL(v));
  // pv(ALL(v));
  ll ans = 0;
  REP(i, N) {
    if (i % 2 == 0)
      ans += A[v[i].second];
    else
      ans -= B[v[i].second];
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 1912
<?php
$n=trim(fgets(STDIN));
$ans = [];
for($i=0; $i<$n; $i++){
	$array = explode(" ", trim(fgets(STDIN)));
	if($i===0){
		$ans[] = $array;
	}else{
		$a = max($ans[$i-1][1], $ans[$i-1][2]) + $array[0];
		$b = max($ans[$i-1][0], $ans[$i-1][2]) + $array[1];
		$c = max($ans[$i-1][0], $ans[$i-1][1]) + $array[2];
		$ans[] = [$a, $b, $c];
	}
}
echo max($ans[$n-1]) . "\n";

Measured memory_bytes: 45556
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<iostream>
#include<cstring>
#include<vector>
#include<string> 
#include<queue>
#include<algorithm>
using namespace std;
int main()
{
	char s[4];
	while(scanf("%s",s)!=EOF)
	{
		int sum=700;
		for(int i=0;i<3;i++)
		{
			if(s[i]=='o')sum+=100;
			else;
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 256
N = gets.to_i
array=gets.chomp.split(" ").map(&:to_i).sort

ret = 0 
(0..(N-3)).each do |i|
    x = array[i]
    ((i+1)..(N-2)).each do |j|
        y = array[j]
        sub = array[(j+1)..-1]
        ind = sub.bsearch_index {|z| z >= x+y }
        if ind == nil
            ret += sub.length
        else
            ret += ind
        end
    end
end
puts ret

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

int main()
{
    long n,min=100000000000,max=0;
    scanf("%ld",&n);

    long x[n];
    for(int i=0;i<n;i++)
    {
        scanf("%ld",&x[i]);
        if(max<x[i])
        {
            max=x[i];
        }
    }
    for(int i=1;i<=max;i++)
    {
        long tmp=0;
        for(int j=0;j<n;j++)
        {
            tmp+=(x[j]-i)*(x[j]-i);
        }
        if(min>tmp)
        {
            min=tmp;
        }
    }
    printf("%ld",min);

    return 0;
}

Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import product
def main():
    h, w, k = map(int,input().split())
    C = [input() for _ in range(h)]
    comb_list = list(product([False, True], repeat = h + w))
    ans = 0
    for comb in comb_list:
        cunt = 0
        for i in range(h):
            if not comb[i]:
                continue
            for j in range(w):
                if not comb[h+j]:
                    continue
                if C[i][j] == '#':
                    cunt += 1
        if cunt == k:
            ans += 1
    print(ans)



if __name__=='__main__':
    main()

Measured memory_bytes: 9528
N = int(input())
from math import gcd
prime = [0] * 2 + [1] * (10 ** 6 - 1)
A = list(map(int, input().split()))
A.sort()
g = 0
for a in A:
  g = gcd(g, a)
for i in range(2, 10 ** 2 + 1):
  if prime[i]:
    for j in range(2 * i, 10 ** 3 + 1, i):
      prime[j] = 0
P = [i for i in range(2, 10 ** 3 + 1) if prime[i]]
from bisect import bisect
A = A[bisect(A, 1):]
N = len(A)
x = [0] * (10 ** 6 + 1)
if N <= 80000:
  for a in A:
    for p in P:
      if a % p == 0:
        x[p] += 1
        while a % p == 0:
          a //= p
      if a == 1:
        break
    if a > 1:
      x[a] += 1
  if max(x) < 2:
    print('pairwise coprime')
    exit()
if g == 1:
  print('setwise coprime')
  
else:
  print('not coprime')

Measured memory_bytes: 199732
#include <bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<ll> vint;
int main() {
  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  string ans="No";
  if (abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)) ans="Yes";
  cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<vector<int>> plan(N, vector<int>(3));
	for (int i = 0; i < N; i++) cin >> plan[i][0] >> plan[i][1] >> plan[i][2];

	vector<vector<int>> dp(N, vector<int>(3));
	dp[0] = plan[0];
	for (int i = 1; i < N; i++) {

		for (int j = 0; j < 3; j++) {

			dp[i][j] = max({ dp[i][j], dp[i - 1][(j + 1) % 3] + plan[i][j], dp[i - 1][(j + 2) % 3] + plan[i][j] });
		}
	}

	cout << max({ dp[N - 1][0], dp[N - 1][1], dp[N - 1][2] });

	return 0;
}

Measured memory_bytes: 11264
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <functional>
using namespace std;
const int INT_INF = 500000000;
const long long LONG_LONG_INF = (long long)pow(10, 18);
const int MOD = pow(10, 9) + 7;
/* contest template */
int N, A;
int n;

int main()
{
    cin >> N >> A;
    n = N % 500;
    if (n <= A)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 405

int N,MA,MB;
int dp[2][405][405];

int main(){

	scanf("%d %d %d",&N,&MA,&MB);

	int CURRENT = 0,NEXT = 1;

	for(int i = 0; i < 2; i++){
		for(int k = 0; k < SIZE; k++){
			for(int p = 0; p < SIZE; p++){

				dp[i][k][p] = BIG_NUM;
			}
		}
	}

	//dp[current,next][aのsum][bのsum] = 最小コスト
	dp[CURRENT][0][0] = 0;

	int a,b,c;

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

		scanf("%d %d %d",&a,&b,&c);

		//商品iを買わない場合
		for(int k = 0; k < SIZE; k++){
			for(int p = 0; p < SIZE; p++){

				dp[NEXT][k][p] = min(dp[NEXT][k][p],dp[CURRENT][k][p]);
			}
		}

		//商品iを買う場合
		for(int k = 0; k+a < SIZE; k++){
			for(int p = 0; p+b < SIZE; p++){
				if(dp[CURRENT][k][p] == BIG_NUM)continue;

				dp[NEXT][k+a][p+b] = min(dp[NEXT][k+a][p+b],dp[CURRENT][k][p]+c);
			}
		}
		swap(CURRENT,NEXT);
	}

	int ans = BIG_NUM;

	int A = MA,B = MB;

	while(A < SIZE && B < SIZE){

		ans = min(ans,dp[CURRENT][A][B]);

		A += MA;
		B += MB;
	}

	if(ans == BIG_NUM){

		printf("-1\n");

	}else{

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

	return 0;
}


Measured memory_bytes: 1536
#include <cstdio>
struct cood {int x, y;};
cood star[200], star2[1000];
int main() {
    int m,n;
    while (scanf("%d",&m)) {
        if (!m) break;
        for (int i=0; i<m; i++) {
            int x, y; scanf("%d%d",&x,&y);
            star[i]=(cood){x,y};
        }
        scanf("%d",&n);
        for (int i=0; i<n; i++) {
            int x, y; scanf("%d%d",&x,&y);
            star2[i]=(cood){x,y};
        }
        for (int i=0; i<n; i++) {
            int j;
            int dx=star2[i].x-star[0].x;
            int dy=star2[i].y-star[0].y;
            for (j=1; j<m; j++) {
                int x=star[j].x+dx;
                int y=star[j].y+dy;
                int k;
                for (k=0; k<n; k++) {
                    if (star2[k].x==x&&star2[k].y==y) break;
                }
                if (k==n) break;
            }
            if (j==m) {
                printf("%d %d\n",dx,dy);
                break;
            }
        }
    }
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define w(x) scanf("%d",&x);while(x--)
#define ws(x) scanf("%d",&x);getchar();while(x--)
#define rep(i,b) for(i=0;i<=b;i++)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi 2*acos(0.0)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;

const int N=1e6+2;
long long  mod=1e9+9;
int t,j,cs=0,n,a,b,i;
string s;

int main()
{
    cin>>s;
    n=s.size();
    string x,y,c;
    c=s.substr(0,n-2);
    n-=2;
    x=c.substr(0,n/2);
    y=c.substr(n/2,n/2);
    while(x!=y){
        c=c.substr(0,n-2);
        n-=2;
        x=c.substr(0,n/2);
        y=c.substr(n/2,n/2);
    }
    cout<<n<<endl;
}



Measured memory_bytes: 3612
/**Author:Sagor*/

#include<bits/stdc++.h>
#include<numeric>

using namespace std;
#define pri(n)          printf("%d\n",n)
#define prll(n)         printf("%lld\n",n)
#define prd(n)          printf("%lf\n",n)
#define scll(n)         scanf("%lld",&n)
#define sci(n)          scanf("%d",&n)
#define scd(n)          scanf("%lf",&n)
#define pi              acos(-1)//inbuilt M_PI
#define ll              long long
#define pb              push_back
#define vsort(v)        sort(v.begin(),v.end())
#define asort(n)        sort(ar,ar+n)
#define yes             cout<<"Yes\n"
#define no              cout<<"No\n"
#define for1(i,n)       for(i=1;i<=n;i++)
#define for0(i,n)       for(i=0;i<n;i++)
#define mod             1000000007
#define watch(x)        cout << (#x) << " is " << (x) <<"\n";

/** for print with quote \"hello world\"
    1LL is used to convert into long long*/


int main()
{
    /*freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);*/
    /**ios_base::sync_with_stdio(false);
    cin.tie(NULL);/**Dont't use scanf of printf*/
    ll n,sum=0,i,a;
    cin>>n;
    for0(i,n){
        cin>>a;
        sum+=(a-1);
    }
    cout<<sum<<endl;


    return 0;
}

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

int main(){
	int n;
	cin >> n;
	int m, M;
	long int S = 0;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		if(a < m || i == 0) m = a;
		if(a > M || i == 0) M = a;
		S += a;
	}
	cout << m << ' ' << M << ' ' << S << endl;
	return 0;
}

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

int main(){
    ll N;
    cin >> N;
    vector<ll> a(3*N);
    rep(i, 0, 3*N) cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    for(ll i = N; i < 3*N; i += 2){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  int sum = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    sum ^= A[i];
  }
  
  for(int i = 0; i < N - 1; i++){
    cout << (A[i] ^ sum) << ' ';
  }
  cout << (A[N - 1] ^ sum) << endl;
  
  return 0;
}

Measured memory_bytes: 4048