akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a[3];
  for(int i=0;i<3;i++) cin>>a[i];
  sort(a,a+3);
  if(a[0]==5&&a[1]==5&&a[2]==7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 764
import java.io.*;
import java.util.*;
import java.util.Collections;
  
class Main{
    public static void main(String[] a) throws Exception{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        Integer[] mountains=new Integer[10];
        for(int i=0;i<10;i++){
            mountains[i]=Integer.valueOf(br.readLine());
        }
        Arrays.sort(mountains, Collections.reverseOrder());
        for(int i=0;i<3;i++){
            System.out.println(mountains[i]);
        }       
    }
}

Measured memory_bytes: 24480
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
#define MAX 1000000000

int main() {
  int n,k;
  cin >> n >> k;
  vector<ull> h(n);
  for(int i = 0; i < n; i++)
    cin >> h[i];
  sort(h.begin(), h.end());
  ull hmax,hmin,hsa, sa = MAX;
  for(int i = 0; i < n-k+1; i++) {
    hmin = h[i];
    hmax = h[i+k-1];
    hsa = hmax-hmin;
    if(sa > hsa)
      sa = hsa;
  }
  cout << sa << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int S = 39;

int main() {
  int N;
  while(cin >>N) printf("3C%02d\n", (N % S == 0 ? S : N % S));
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define ponto pair<int,int>

int n,x,m,tot=0,c=0;
vector<int>a;

int32_t main()
{
	cin >> n >> m;
	for(int i=0; i<n; i++)
	{
		cin >> x;
		a.push_back(x);
		tot += x;
	}
	
	
	double p = tot/(4.0*m);
	//cout << tot << ' ' << p << '\n';
	for(int i=0; i<n; i++)
		if(a[i] >= p)
			c++;
			
	puts(c >= m ? "Yes" : "No");
}

Measured memory_bytes: 256
import           Control.Monad
import           Control.Applicative
import           Data.Ord
import           Data.List
import qualified Data.Vector                   as V
import           Data.Array.IO

main :: IO ()
main = do
  [a, b, c] <- map read . words <$> getLine

  print
    $  ((reverse . sort)
         [ i | i <- [1 .. max a b], a `mod` i == 0 && b `mod` i == 0 ]
       )
    !! (c - 1)

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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    LL N;
    cin >> N;
    vector<LL> v(N);
    REP(i, N) {
        cin >> v[i];
    }
    sort(ALL(v), greater<LL>());
    LL W = 0;
    LL H = 0;
    for(int i = 0;H*W == 0 && i < N - 1;) {
        if(W == 0) {
            if(v[i] == v[i + 1]) {
                W = v[i];
                i += 2;
            }else{
                i++;
            }
        }else if(H == 0) {
            if(v[i] == v[i + 1]) {
                H = v[i];
                i += 2;
            }else{
                i++;
            }
        }
    }
    LL res = W*H;
    cout << res << endl;
    return 0;
}



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

int main()
{
    int n;
    string s;

    while( cin >> n )
    {
        if( n == 0 )
            break;

        bool a[3] = { 0, 0, 1 };
        
        int cnt = 0;
        for( int i = 0; i < n; i++ )
        {
            cin >> s;
            if( s == "lu" )
                a[0] = 1;
            else if( s == "ru" )
                a[1] = 1;
            else if( s == "ld" )
                a[0] = 0;
            else
                a[1] = 0;

            if( a[0] == a[1] && a[0] == a[2] )
            {
                cnt++;
                a[2] = !a[2];
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
def Get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def Get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def Get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def Get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
s=Get_nsp()

ans=[]
s.each do|c|
  case c
    when "0" then
      ans.push("0")
    when "1" then
      ans.push("1")
    when "B" then
      ans.pop() unless ans.size.zero?
  end
end
puts ans.join("")

Measured memory_bytes: 2044
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
long long n, m, v, p, a[100001];
bool cmp(long long x, long long y)
{
    return x > y;
}
int main(int argc, char const *argv[])
{
    scanf("%lld%lld%lld%lld", &n, &m, &v, &p);
    for (int i = 1; i <= n; i++)
    {
        scanf("%lld", &a[i]);
    }
    sort(a + 1, a + n + 1, cmp);
    long long ans = p, sum = 0;
    for (int i = p + 1; i <= n; i++)
    {
        if (a[i] + m < a[p])
        {
            break;
        }
        if (v - n + i <= p)
        {
            ans++;
        }
        else
        {
            if (((v - p - n + i) * m - sum - 1) / (i - p) + 1 + a[p] <= a[i] + m)
            {
                ans++;
            }
        }
        sum += a[p] - a[i];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4604
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[]a = new int[3];
		for(int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		sc.close();
		Arrays.sort(a);
		int ans = a[0] * a[1];
		ans /= 2;
		System.out.println(ans);
	}
}

Measured memory_bytes: 21972
#include<queue>
#include<iostream>
#include<string.h>
using namespace std;

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

struct Dice{
	int t,b,n,s,e,w;
	int y,x;
	
	int c;
	Dice(int top,int bottom,int north,int south,int east,int west,int sx,int sy,int cost){
		t=top,b=bottom,n=north,s=south,e=east,w=west;
		x=sx,y=sy,c=cost;
	}
	bool operator<(const Dice &r)const
	{
		return c>r.c;
	}
	void roll(int d)
	{
		int tmp;
		y+=dy[d],x+=dx[d];
		
		if(d==0)
		{
			tmp=t; t=s; s=b; b=n; n=tmp;
		}else if(d==1)
		{
			tmp=t; t=e; e=b; b=w; w=tmp;
		}else if(d==2)
		{
			tmp=t; t=n; n=b; b=s; s=tmp;
		}else
		{
			tmp=t; t=w; w=b; b=e; e=tmp;
		}
	}
};

int w,h;
bool in(int x,int y){
	if(x<0 || y<0 || x>=w || y>=h) return false;
	return true;
}

int main(){
	int p[10][10],memo[10][10][100];
	while(cin>>h>>w && h!=0){
		priority_queue<Dice> que;
		for(int y=0;y<h;y++)
			for(int x=0;x<w;x++){
				cin>>p[y][x];
			}
		memset(memo,-1,sizeof(memo));

		int gx,gy,sx,sy;
		cin>>sy>>sx>>gy>>gx;
		que.push(Dice(1,6,5,2,3,4,sx,sy,0));
		while(!que.empty()){
			Dice now=que.top();
			que.pop();
//			cout<<now.x<<" "<<now.y<<" "<<now.b<<" "<<now.c<<endl;
			if(now.x==gx && now.y==gy) {cout<<now.c<<endl; break;}
			if(memo[now.y][now.x][now.e*7+now.b]>=0 && memo[now.y][now.x][now.e*7+now.b]<=now.c) continue;
			memo[now.y][now.x][now.e*7+now.b]=now.c;


			for(int r=0;r<4;r++){
				Dice copy=now;
				copy.roll(r);
				if(in(copy.x,copy.y)){
					copy.c+=copy.b*p[copy.y][copy.x];
					que.push(copy);
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1056
#ライブラリインポート
from collections import defaultdict
INF = float("inf")
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#更新クエリ
def update(data, k, x, N0):
	k += N0 - 1
	data[k] = x
	while k > 0:
		k = (k - 1) // 2
		data[k] = data[2 * k + 1] | data[2 * k + 2]

#求値クエリ 最初:query(a, b, 0, 0, N0)
def query(data, a, b, k, l, r):
	if r <= a or b <= l:
		return 0
	if a <= l and r <= b:
		return data[k]
	else:
		vl = query(data, a, b, k * 2 + 1, l, (l + r) // 2)
		vr = query(data, a, b, k * 2 + 2, (l + r) // 2, r)
		return vl | vr

#処理内容
def main():
	N = int(input())

	#セグ木初期化
	N0 = 2 ** (N - 1).bit_length()
	S = list(input())
	data = [0] * (2 * N0 - 1)
	for i in range(N):
		data[N0 - 1 + i] = 2 ** (ord(S[i]) - 97)
		ind = N0 - 1 + i
		while ind > 0:
			ind = (ind - 1) // 2
			data[ind] = data[ind * 2 + 1] | data[ind * 2 + 2]

	Q = int(input())
	for _ in range(Q):
		que = list(input().split())
		if que[0] == "1":
			i = int(que[1]) - 1
			c = 2 ** (ord(que[2]) - 97)
			update(data, i, c, N0)
		else:
			a = int(que[1])
			b = int(que[2])
			a -= 1
			jjj = query(data, a, b, 0, 0, N0)
			ans = 0
			while jjj != 0:
				if jjj % 2 == 1:
					ans += 1
				jjj = int(jjj // 2)

			print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 103720
# -*- coding: utf-8 -*-

import collections
import math


class Vector2(collections.namedtuple("Vector2", ["x",  "y"])):

    def __add__(self, other):
        return Vector2(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Vector2(self.x - other.x, self.y - other.y)

    def __mul__(self, scalar):  # cross product
        return Vector2(self.x * scalar, self.y * scalar)

    def __neg__(self):
        return Vector2(-self.x, -self.y)

    def __pos__(self):
        return Vector2(+self.x, +self.y)

    def __abs__(self):  # norm
        return math.sqrt(float(self.x * self.x + self.y * self.y))

    def dot(self, other):  # dot product
        return self.x * other.x + self.y * other.y

    def cross(self, other):  # cross product
        return self.x * other.y - self.y * other.x


if __name__ == '__main__':

    a, b, c, d = map(int, input().split())
    p1 = Vector2(a, b)
    p2 = Vector2(c, d)
    base = p2 - p1
    q = int(input())

    for _ in range(q):
        e, f = map(int, input().split())
        hypo = Vector2(e - a, f - b)
        r = hypo.dot(base) / abs(base)**2
        x = p1 + base * r
        print(x.x, x.y)



Measured memory_bytes: 6156
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
    int n, k;
    cin >> n >> k;
    vi p(n);
    rep(i, n) cin >> p[i];

    rep(i, n) p[i]++;
    
    vi r(n + 1);
    r[0] = 0;
    rep(i, n) r[i + 1] = r[i] + p[i];

    int mx = 0;
    for(int i = k; i < n + 1; i++) {
        int tmp = r[i] - r[i - k];
        mx = max(mx, tmp);
    }

    //cout << mx << endl;

    double ans = mx / 2.0;
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	ll n,k; cin>>n>>k;
	ll sum=0LL;
	VL a(n); rep(i,n) cin>>a[i], sum+=a[i];
	VL d;
	for(ll i=1; i*i<=sum; i++){
		if(sum%i==0) d.PB(i);
		if(i*i!=sum) d.PB(sum/i);
	}
	sort(ALL(d));
	ll ans=1LL;
	for(auto i:d){
		VL r(n); rep(j,n) r[j]=a[j]%i; sort(ALL(r));
		VL L(n+1,0LL),R(n+1,0LL);
		reps(j,n){
			L[j]=L[j-1]+r[j-1]; R[n-j]=R[n-j+1]+(i-r[n-j]);
		}
		rep(j,n+1){
			if(L[j]==R[j]&&L[j]<=k) chmax(ans,i);
		}
	}


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


Measured memory_bytes: 764
var s:ansistring;
    t,p:longint;
begin
  readln(s);
  t:=pos('C',s);
  if t=0 then
  begin
    writeln('No');
    halt;
  end;
  for p:=length(s) downto 1 do
    if s[p]='F' then
      break;
  if s[p]<>'F' then
  begin
    writeln('No');
    halt;
  end;
  if p<t then
  begin
    writeln('No');
    halt;
  end;
  writeln('Yes');
end.

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#define ll unsigned long long
#include<map>

using namespace std;

int main(){
	int n;
	scanf(" %d",&n);
	map<ll,ll> tra;
	ll primes[]= {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101};
	for(int i = 0; i < n;++i){
		ll id = 1;
		for(int j = 0; j < 10;++j){
			char c;
			scanf(" %c",&c);
			id *= primes[c - 'a'];
		}
		//cout << id<<endl;
		if(tra.count(id)){
			++tra[id];
		}
		else
			tra[id] = 1;
	}
	ll ans = 0;
	for(const auto &pa: tra)
		ans += (((pa.second)*(pa.second-1))>>1);
	cout << ans << endl;
}

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

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

    int h, w;

    cin >> h >> w;
    string s[h];
    for (int i = 0; i < h; ++i) {
        cin >> s[i];
    }

    pair<int, int> dirs[4] = {
            make_pair(0,  1),
            make_pair(1,  0),
            make_pair(0,  -1),
            make_pair(-1,  0)
    };
    // pair<int, int> p;
    int x, y;
    // bool success = false;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (s[i][j] == '#') {
                bool clear = false;
                for (const auto &dir : dirs) {
                    y = i + dir.first;
                    x = j + dir.second;
                    if (0 <= y && y < h && 0 <= x && x < w && s[y][x] == '#') {
                        clear = true;
                        break;
                    }
                }
                if (!clear) {
                    // cout << i << ',' << j << endl;
                    goto fail;
                }
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
fail:
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main{
  static long mod=1000000007;
  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    //System.out.println("hi");
    long n=in.nextInt();
    long mul=1;
    if (n==0)
      w.println(1);
    else{
      for(int i=1;i<=n;i++){
        mul=(mul%mod)*(i%mod);
        mul=mul%mod;
      }
      w.println(mul);
    }
    w.close();
    }

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
      throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
        return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public int[] nextIntArray(int n) {
      int a[] = new int[n];
      for (int i = 0; i < n; i++) {
        a[i] = nextInt();
      }
      return a;
    }

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
      c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
      return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 21332
#include <stdio.h>

int abs(int a) {
    if(a>=0) {
        return a;
    } else {
        return -a;
    }
}

int calc_temp(int T, int H, int A) {
    return abs(1000*T - 6*H - 1000*A);
}


int main() {
    int N, T, A;
    scanf("%d", &N);

    scanf("%d %d", &T, &A);

    int i, H[N], min, min_index;
    for(i=0; i<N; i++) {
        scanf("%d", &H[i]);
        if(i==0) {
            min = calc_temp(T, H[i], A);
        } else if(i>0) {
            if(calc_temp(T, H[i], A)<min) {
                min = calc_temp(T, H[i], A);
                min_index = i;
            }
        }
    }

    printf("%d\n", min_index+1);


    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n;
llong d[55];
llong sum;

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

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += d[i] * d[j];
        }
    }

    cout << sum << endl;

    return 0;
}


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

typedef long long ll;

const int maxn = 300010;
const ll INF = 300000000000001LL;

ll a[maxn];
priority_queue<ll, vector<ll>, greater<ll> > que1;
priority_queue<ll> que2;
ll maxsum[maxn], minsum[maxn];

int main()
{
	int n;
	scanf("%d",&n);
	for (int i=1;i<=n * 3;i++) scanf("%lld",&a[i]);
	
	ll sum = 0;
	for (int i=1;i<=n;i++) que1.push(a[i]), sum += a[i];
	maxsum[n] = sum;
	for (int i=n+1;i<=2*n;i++)
	{
		que1.push(a[i]); sum += a[i];
		sum -= que1.top(); que1.pop();
		maxsum[i] = sum;
	}
	
	sum = 0;
	for (int i=3*n;i>2*n;i--) que2.push(a[i]), sum += a[i];
	minsum[2*n+1] = sum;
	for (int i=2*n;i>=n;i--)
	{
		que2.push(a[i]); sum += a[i];
		sum -= que2.top(); que2.pop();
		minsum[i] = sum;
	}
	
	ll ans = -INF;
	for (int k=n;k<=2*n;k++)
	{
		ans = max(ans, maxsum[k] - minsum[k+1]);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 7668
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll k;
    cin>>k;
    ll n=k%10;
    if(n==2||n==4||n==5||n==7||n==9)cout<<"hon"<<endl;
    else if(n==3)cout<<"bon"<<endl;
    else cout<<"pon"<<endl;


}


Measured memory_bytes: 3624
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd

mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
arr=[]
for i in range(3):
    mm=limii()
    arr.append(mm)

n=ii()

b=lin(n)

for i in range(3):
    for j in range(3):
        if arr[i][j] in b:
            arr[i][j]=0
chk=False

for i in range(3):
    if arr[0][i]==0 and arr[1][i]==0 and arr[2][i]==0:
        chk=True
    elif arr[i][0]==0 and arr[i][1]==0 and arr[i][2]==0:
        chk=True
if arr[0][0] ==0 and arr[1][1]==0 and arr[2][2]==0:
    chk=True
if arr[2][0] ==0 and arr[1][1]==0 and arr[0][2]==0:
    chk=True

if chk==True:
    print("Yes")
else:
    print("No") 


Measured memory_bytes: 65516
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=998244353;
struct nd{int x,d,y;}a[200005];
int dp[200005],b[200005],c[200005];
bool cmp(nd a,nd b)
{
    return a.x<b.x;
}
int main()
{

    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&a[i].x,&a[i].d);
        a[i].y=a[i].x+a[i].d;
    }
    a[n+1].x=0x3f3f3f3f;
    sort(a+1,a+1+n,cmp);
    int pos=n;
    c[n]=n+1;
    for(int i=n-1;i>=1;i--)
    {
        if(a[i].y<=a[pos].x)
        {
            c[i]=pos;
            pos=i;
        }
        else
        {
            while(a[i].y>a[pos].x)
            {
                pos=c[pos];
            }
            c[i]=pos;
            pos=i;
        }
    }
    dp[n+1]=1;
    for(int i=n;i>=1;i--)
    {
        dp[i]=(dp[i+1]+dp[c[i]])%mod;
    }
//    for(int i=1;i<=n;i++)
//    {
//        if(i>1)printf(" ");
//        printf("%d",dp[i]);
//    }
//    printf("\n");
    printf("%d\n",dp[1]);
}


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

int main(){
  int N;
  cin >> N;
  int A[N];
  rep(i, N){
    cin >> A[i];
  }
  double ans=0;
  rep(i, N){
    ans += (1.0/A[i]);
  }
  cout << fixed << setprecision(10);
  cout << 1.0 / ans << endl;
}


Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int totalc = 1000000000;//
  for (int i = -100; i <= 100; i++) {
    int totalc_ati = 0;
    for (int j = 0; j < n; j++) {
      int sa = a.at(j) - i;//(x-y)
      totalc_ati += sa * sa;
    }
    totalc = min(totalc_ati, totalc);
  }
  cout << totalc;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	char num[110];
	long long int k;
	cin >> num;
	cin >> k;
	int count = 0;
	char answer;
	for (int i = 0;i < 100;i++) {
		if (num[i] == '1') {
			count++;
		}
		else {
			answer = num[i];
			break;
		}
	}
	if (count >= k) {
		cout << 1 << endl;
	}
	else {
		cout << answer << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n,m;
struct A{
    int u,v,d;
};
queue<A> Q;
int cnt;
vector<int> a[21];

void dfs(int v){
    if(v==20)cnt++;
    for(auto &u:a[v])dfs(u);
}
int main(){
    cin>>m;
    int i;
    m--;

    for(i=1 ; (1<<i)-1<m ; i++){
        Q.push({i,i+1,(1<<(i-1))});
        Q.push({i,i+1,0});
       // cout<<i<<" "<<i+1<<" "<<(1<<(i-1))<<"\n";
       //  cout<<i<<" "<<i+1<<" "<<0<<"\n";
    }
    for(i=1 ; i<20 ; i++){
        if(((1<<(i-1))&m)){
            Q.push({i,20,((m>>i)<<i)});
          ///  cout<<i<<" "<<20<<" "<<((m>>i)<<i)<<"\n";
        }
    }
    Q.push({1,20,m});
    cout<<20<<" "<<Q.size()<<"\n";
    while(!Q.empty()){
        A t=Q.front();
        cout<<t.u<<" "<<t.v<<" "<<t.d<<"\n";
        Q.pop();
        a[t.u].push_back(t.v);
    }
   /// dfs(1);
  ///  cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        string[] board = new string[N];
        for (int i = 0; i < N; i++)
        {
            board[i] = cin.next();
        }

        int ans = 0;

        for (int t = 0; t < N; t++)
        {
            string[] b2 = new string[N];
            for (int i = 0; i < N; i++)
            {
                b2[i] = board[(i + t) % N];
            }
            bool flag = true;
            for (int i = 0; i < N; i++)
            {
                for (int j = i + 1; j < N; j++)
                {
                    if(b2[i][j] != b2[j][i])
                    {
                        flag = false;
                        break;
                    }
                }
                if (!flag) break;
            }
            if (flag) ans += N;
        }

        Console.WriteLine(ans);
    }

}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}



Measured memory_bytes: 13140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskAtCoder solver = new TaskAtCoder();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskAtCoder
    {
        public void solve(int testNumber, Scanner in, PrintWriter out)
        {
            String s = in.next();
            int dp[][] = new int[s.length() + 1][2];
            init_dp(dp, s.length() + 1);
            int[] a = new int[s.length()];
            for (int i = 0; i < s.length(); i++)
            {
                a[i] = Character.getNumericValue(s.charAt(i));
            }
            dp[0][0] = Math.min(a[0], 1 + 10 - a[0]);
            dp[0][1] = Math.min(a[0] + 1, 1 + 10 - a[0] - 1);
            for (int i = 1; i < s.length(); i++)
            {
                dp[i][0] = Math.min(dp[i - 1][0] + a[i], dp[i - 1][1] + 10 - a[i]);
                dp[i][1] = Math.min(dp[i - 1][0] + a[i] + 1, dp[i - 1][1] + 10 - a[i] - 1);
            }

            System.out.println(dp[s.length() - 1][0]);
        }

        static void init_dp(int dp[][], int N)
        {
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    dp[i][j] = -1;
                }
            }
        }

    }
}



Measured memory_bytes: 74100
import collections

n = int(input())

a = list(map(int, input().split()))
total = sum(a)
aa = collections.Counter(a)
q = int(input())

for i in range(q):
    b, c = map(int, input().split())
    if b in aa and c in aa:
        total += c * aa[b] - b * aa[b]
        print(total)
        aa[c] += aa[b]
        aa.pop(b)
    elif b in aa:
        total += c * aa[b] - b * aa[b]
        print(total)
        aa[c] = aa[b]
        aa.pop(b)
    else:
        print(total)

Measured memory_bytes: 21288
#include <iostream>
#include <vector>

using namespace std;

int M = (int)(1e9+7);
vector<vector<long long int>> dp(1005, vector<long long int>(1005, -1));

//dp[x][y] = number of possible ways to reach point (x,y)
long long int solve(int h, int w)
{
    if(dp[h][w] != -1)
        return(dp[h][w]);
    if(h == 1 && w == 1)
        return(dp[h][w] = 1);
    if(h == 1)
        return(dp[h][w] = solve(h, w-1));
    if(w == 1)
        return(dp[h][w] = solve(h-1, w));
    return(dp[h][w] = (solve(h-1, w) + solve(h, w-1)) % M);
}

int main()
{
    int h, w;
    char ele;
    long long int ans;
    cin >> h >> w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin >> ele;
            if(ele == '#')
                dp[i][j] = 0;
        }
    }
    ans = solve(h, w);
    cout << ans << endl;
    return(0);
}

Measured memory_bytes: 8320
#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());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (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;

// return 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;
}
// return nCk 前処理 O(N) + query あたり O(1)
static bool init = false;
ll cb_res = 1;
const ll M = 2e6 + 10;
vll frc(M + 1, 1), inv(M + 1, 1);
long long comb(int n, int k){
    if(!init){
        init = true;
        REP(i, M){
            frc[i + 1] = (frc[i] * (i + 1)) % MOD;
            inv[i + 1] = mypow(frc[i + 1], MOD - 2);
        }
    }
    if (k < 0 || n < k) return 0;
    cb_res = (((frc[n] * inv[k]) % MOD) * inv[n - k]) % MOD;
    return cb_res;
}

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

    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    // (0, 0) -> (r, c) : (r + c)Cr
    // sum_{c = 0, ..., c2}rCc = (r + 1)Cc2
    ll res = 0;
    for (ll r = r1; r <= r2; r++) {
        res += MOD + comb(r + 1 + c2, c2) - comb(r + 1 + c1 - 1, c1 - 1);
        res %= MOD;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 31488
#include <iostream>
#include <vector>

using namespace std;

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

    vector<long> spots(n + 2, 0);
    unsigned long long sum = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> spots[i];
        sum += abs(spots[i] - spots[i - 1]);
    }
    sum += abs(spots[n]);
    
    for (int i = 1; i <= n; ++i) {
        cout << sum - abs(spots[i] - spots[i - 1]) - abs(spots[i + 1] - spots[i]) + abs(spots[i + 1] - spots[i - 1]) << endl;
    }

    return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

int main(void) {
	int a, b, c, k, i;
	int fa, wa;
	wa = 0;
	if(scanf("%d%d%d%d", &a, &b, &c, &k)==1);
	if(a <= k){
		wa = a;
		fa = k - (a + b);
		if(fa > 0){
			for(i=0;i<fa;i++){
				wa--;
			}
		}
	}
	else{
		wa = k;
	}
	printf("%d", wa);
	return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 x, y;
    cin >> x >> y;

    i64 ans = abs(abs(x) - abs(y));
    if (x + ans == y) {
        cout << ans << endl;
    } else if (x * y > 0) {
        cout << ans + 2 << endl;
    } else {
        cout << ans + 1 << endl;
    }
}

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


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

const int N = 1e5+5;
int n;
struct Invl
{
    int l, r, id;
};
bool used[N];

int move(int& i, int l, int r) {
    if (l <= i && i <= r) return 0;    
    int ret = 0;
    if (i > r) {
        ret = i-r;
        i = r;
    }
    else if (i < l) {
        ret = l-i;
        i = l;
    }
    else assert(false);
    return ret;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    vector<Invl> u, v;
    for (int i = 0; i < n; i++) {
        int l, r; cin >> l >> r;
        u.push_back({l,r,i});
        v.push_back({l,r,i});
    }
    sort(u.begin(),u.end(),[](auto a, auto b) {
            return a.l > b.l;
            });
    sort(v.begin(),v.end(),[](auto a, auto b) {
            return a.r < b.r;
            });
    /*
    for (auto p: v) {
        cout << p.l << ' ' << p.r << '\n';
    }
    */
    int i = 0, j = 0;
    int curr = 0;
    ll ans = 0;
    while (i < n && j < n) {
        while (i < n && used[v[i].id]) i++;
        if (i < n) {
            ans += move(curr,v[i].l,v[i].r);
            used[v[i].id] = true;
            //cout << "taking " << v[i].l << ' ' << v[i].r << '\n';
        }

        while (j < n && used[u[j].id]) j++;
        if (j < n) {
            ans += move(curr,u[j].l,u[j].r);
            used[u[j].id] = true;
            //cout << "taking " << u[j].l << ' ' << u[j].r << '\n';
        }
        //cout << ans << '\n';
    }
    ans += abs(curr);
    //try other way
    i = j = curr = 0;
    ll ans2 = 0;
    memset(used,0,sizeof used);
    while (i < n && j < n) {
        while (j < n && used[u[j].id]) j++;
        if (j < n) {
            ans2 += move(curr,u[j].l,u[j].r);
            used[u[j].id] = true;
            //cout << "taking " << u[j].l << ' ' << u[j].r << '\n';
        }

        while (i < n && used[v[i].id]) i++;
        if (i < n) {
            ans2 += move(curr,v[i].l,v[i].r);
            used[v[i].id] = true;
            //cout << "taking " << v[i].l << ' ' << v[i].r << '\n';
        }
        //cout << ans << '\n';
    }
    ans2 += abs(curr);

    cout << max(ans,ans2) << '\n';
}



Measured memory_bytes: 2988
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, alice=0, bob=0;
    cin >> n;
    int data[n];
    for(int i=0; i < n; i++)  cin >> data[i];
    sort(data, data+n, greater<int>());

    for(int i=0; i<n; i++){
        if((i+1) % 2) alice += data[i];
        else bob += data[i];
    }

    cout << alice - bob << endl;
}


Measured memory_bytes: 256
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import cmath as cma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(n=0):
    if n: return [0 for _ in range(n)]
    else: return list(imap())
def farr(): return list(fmap())
def sarr(n=0):
    if n: return ["" for _ in range(n)]
    else: return sinput().split()
def barr(n): return [False for _ in range(n)]
sys.setrecursionlimit(10**7)
MOD = 10**9 + 7; EPS = sys.float_info.epsilon
PI = np.pi; EXP = np.e; INF = np.inf


n = iinput()
p = iarr()
a = [i for i in range(1,n+1)]

ans = 'NO'
for i in range(n):
    for j in range(n):
        pp = cp.deepcopy(p)
        pp[i],pp[j] = pp[j],pp[i]
        if pp == a: ans = 'YES'; break
    
print(ans)


Measured memory_bytes: 19352
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SZ = 3009, MOD = 1e9 + 7;

ll dp[SZ][SZ][2];
ll n, q;
vector<ll> vec;

ll bpow(ll vl, ll p, ll MOD) {
	if (p == 0) return 1ll;
	if (p % 2 == 1) {
		return (bpow(vl, p - 1, MOD) * vl) % MOD;
	}
	else {
		ll b = bpow(vl, p / 2, MOD);
		return (b * b) % MOD;
	}
}
int main() {
	fastInp;

	cin >> n >> q;
	vec.resize(n);
	for (auto &cur : vec) cin >> cur;

	for (int i = 0; i < vec.size(); i++) {
		for (int j = i + 1; j < vec.size(); j++) {
			if (vec[i] < vec[j]) {
				dp[i][j][1]++;
			}
			else if (vec[i] > vec[j]) {
				dp[i][j][0]++;
			}
		}
	}

	ll curPw = 1, inv = bpow(2, MOD - 2, MOD), c = 0;

	while (q--) {
		ll l, r;
		cin >> l >> r;
		l--; r--;
		if (l > r) swap(l, r);
		vector<tuple<ll, ll, ll, ll>> add;


		for (int i = 0; i < n; i++) {
			if (i < l) {
				add.push_back({ i, r, 1, (dp[i][l][1] * curPw) % MOD });
				add.push_back({ i, r, 0, (dp[i][l][0] * curPw) % MOD });

				add.push_back({ i, l, 1, (dp[i][r][1] * curPw) % MOD });
				add.push_back({ i, l, 0, (dp[i][r][0] * curPw) % MOD });
			}
			else if (i > r) {
				add.push_back({ r, i, 1, (dp[l][i][1] * curPw) % MOD });
				add.push_back({ r, i, 0, (dp[l][i][0] * curPw) % MOD });

				add.push_back({ l, i, 1, (dp[r][i][1] * curPw) % MOD });
				add.push_back({ l, i, 0, (dp[r][i][0] * curPw) % MOD });
			}
			else if (i > l && i < r) {
				add.push_back({ i, r, 0, (dp[l][i][1] * curPw) % MOD });
				add.push_back({ i, r, 1, (dp[l][i][0] * curPw) % MOD });

				add.push_back({ l, i, 0, (dp[i][r][1] * curPw) % MOD });
				add.push_back({ l, i, 1, (dp[i][r][0] * curPw) % MOD });
			}
		}
		ll s = ((dp[l][r][1] * curPw) % MOD + (dp[l][r][0] * curPw) % MOD) % MOD;
		c++;
		dp[l][r][1] = (s * bpow(bpow(2, c, MOD), MOD - 2, MOD)) % MOD;
		dp[l][r][0] = (s * bpow(bpow(2, c, MOD), MOD - 2, MOD)) % MOD;
		if (dp[l][r][1] >= MOD) dp[l][r][1] -= MOD;
		if (dp[l][r][0] >= MOD) dp[l][r][0] -= MOD;

		for (auto cur : add) {
			ll l = get<0>(cur), r = get<1>(cur), fl = get<2>(cur), vl = get<3>(cur);
			if (l > r) {
				swap(l, r);
				fl = !fl;
			}
			dp[l][r][fl] = (dp[l][r][fl] * curPw) % MOD;
			dp[l][r][fl] += vl;

			dp[l][r][fl] = ((dp[l][r][fl] * bpow(bpow(2, c, MOD), MOD - 2, MOD)) % MOD);
		}

		curPw *= 2;
		curPw %= MOD;
	}

	ll ans = 0, pw = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += (dp[i][j][0] * curPw) % MOD;
			if (ans >= MOD) ans -= MOD;
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 85992
#include <stdio.h>

int main(void)
{
	int a, b, sum;
	int i;
	
	while (scanf("%d %d", &a, &b) != EOF){
		sum = a + b;
		
		i = 0;
		while (sum!= 0){
			sum /= 10;
			i++;
		}
		
		printf("%d\n", i);
	}
	
	return (0);
}

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

int x[300000];

int main(){
    int n;
    scanf("%d", &n);
    int m = 3 * n;
    f(i, 0, m)scanf("%d", x + i);
    sort(x, x + m);
    ll an = 0;
    for (int i = m - 2; i >= n; i -= 2)an += x[i];
    printf("%lld\n", an);
}


Measured memory_bytes: 1408
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = MAP()
if A%2==0 or B%2==0 or C%2==0:
	print(0)
	exit()

l = sorted([A, B, C])
rV = l[0]*l[1]*(l[2]//2)
bV = l[0]*l[1]*(-(-l[2]//2))
print(bV-rV)


Measured memory_bytes: 5200
#include <cstdio>
#include <iostream>
#include <queue>
#include <utility>
using namespace std;

int h, w, n;

int p[10][2];

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

bool a[1000][1000];
int m[1000][1000];

char str[1001];

int t(int sx, int sy, int ex, int ey) {
	for (int i=0;i<h;i++) {
		for(int j=0;j<w;j++) {
			m[j][i] = -1;
		}
	}
	m[sx][sy] = 0;
	
	queue< pair<int, int> > que;
	que.push( make_pair(sx, sy) );
	
	while(!que.empty()) {
		 pair<int, int> np = que.front();
		que.pop();
		for(int i=0;i<4;i++) {
			int px = np.first+dx[i], py = np.second+dy[i];
			if( (px<0||px>=w) || (py<0||py>=h) )continue;
			else if( !a[px][py] )continue;
			else if(px==ex&&py==ey)return m[np.first][np.second]+1;
			else if( m[px][py]>=0 && m[px][py]<=(m[np.first][np.second]+1) )continue;
			m[px][py] = m[np.first][np.second]+1;
			que.push( make_pair(px, py) );
		}
	}
	
	cout << "error!" << endl;
	return -1;
}

int main() {
	
	cin >> h >> w >> n;
	
	for(int i=0;i<h;i++) {
		cin >> str;
		for(int j=0;j<w;j++) {
			a[j][i] = (str[j]!='X');
			if(str[j]=='S') {
				p[0][0] = j;
				p[0][1] = i;
			}else if(str[j]>='1' && str[j]<='9') {
				p[str[j] - '0'][0] = j;
				p[str[j] - '0'][1] = i;
			}
		}
	}
	
	int s = 0;
	for(int i=0;i<n;i++) {
		s += t(p[i][0], p[i][1], p[i+1][0],  p[i+1][1]);
	}
	
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 6104
#include <iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int result=0;
  for(int i=3;i<=N;i+=2){
    int count=0;
    for(int j=1;j<=i;j++){
      count+=i%j==0?1:0;
    }
    if(count==8) result++;
  }
  cout<<result<<"\n";
  return 0;
}

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

int main() {
    int N, Y;
    scanf("%d%d", &N, &Y);

    int A = Y / 1000;
    for (int i=0; i <= A; i++) {
        for (int j=0; j <= N-i; j++) {
            if (1000*i + 5000*j + 10000*(N-i-j) == Y && N-i-j >= 0) {
                printf("%d %d %d", N-i-j, j, i);
                return 0;
            }
        }
    }
    printf("-1 -1 -1");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll l,r;
    cin>>l>>r;
    ll ans=2020;
    if(r-l>=2020){
        cout<<0<<endl;
    }
    else{
        for(ll i=l;i<r;i++){
            for(ll j=i+1;j<=r;j++){
                ans=min(ans,(i*j)%2019);
            }
        }
        cout<<ans<<endl;
    }





    return 0;
}


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

using namespace std;

int main(void){

  int a[3];
  while( cin >> a[0] >> a[1] >> a[2] , ( a[0] || a[1] || a[2] ) ){
    
    int n;
    cin >> n;
    sort( a , a + 3 );
    int R = a[0]*a[0] + a[1]*a[1];

    while(n--){
      int r;
      cin >> r;
      if( 2 * r > sqrt(R) ) cout << "OK" << endl;
      else cout << "NA" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef long int li;
typedef vector<int> vi;
#define pb push_back
vi a;
int x,y,z;
int main() {

cin>>x>>y>>z;
a.pb(x);a.pb(y);a.pb(z);

sort(a.begin(),a.end());
int h = a[2];
stringstream ss;
ss << h;
string str = ss.str();
int t = a[1];
stringstream s;
s << t;
string str1 = s.str();
stringstream geek(str+str1);
    int z = 0;
    geek >> z;
cout<<z+a[0]<<endl;

    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<pair<int, int>> red(n), blue(n);
  rep(i, n) cin >> red.at(i).first >> red.at(i).second; //red(x,y)
  rep(i, n) cin >> blue.at(i).second >> blue.at(i).first; //blue(y,x)
  sort(red.rbegin(), red.rend());
  sort(blue.begin(), blue.end());

  int ans = 0;

  rep(i,n) {
    rep(j,n) {
      if(blue.at(i).second > red.at(j).first && blue.at(i).first > red.at(j).second) {
        ans++;
        red.at(j).first = 2 * n;
        break;
      }
    }
  }

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

Measured memory_bytes: 256