akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.stream.IntStream;
import java.io.*;

public class Main {

	void solve() {
		if (ask((long) 1e12)) {
			for (int i = 0; i <= 10; i++) {
				long ans = (long) (Math.pow(10, i) + 1);
				if (ask(ans)) {
					answer(ans - 1);
					return;
				}
			}
			throw new AssertionError();
		}

		for (int len = 10; len >= 0; len--) {
			out.print("? 1");
			for (int i = 0; i < len; i++) {
				out.print('0');
			}
			out.println();
			out.flush();

			boolean res = get();
			if (res) {
				go(len + 1);
				return;
			}
		}
	}

	private void answer(long i) {
		out.println("! " + i);
		out.flush();
		return;
	}

	private void go(int i) {
		long left = (long) Math.pow(10, i - 1), right = (long) (Math.pow(10, i) - 1);
		left--;
		right++;

		while (left < right - 1) {
			long mid = (left + right) >>> 1;
			out.println("? " + mid + "0");
			out.flush();
			if (get()) {
				right = mid;
			} else {
				left = mid;
			}
		}
		answer(right);
	}

	boolean ask(long x) {
		out.println("? " + x);
		out.flush();
		return get();
	}

	private boolean get() {
		char res = in.nextToken().charAt(0);
		return res == 'Y';
	}

	FastScanner in;
	PrintWriter out;

	void run() {
		in = new FastScanner();
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

		public String nextToken() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}

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


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

using namespace std;

#define pb push_back

typedef long long ll;

string s;
int k;
set<string> h;

int main() {
	cin>>s>>k;
	for(int i=1;i<=min((int)s.size(),5);i++){
		for(int j=0;j<s.size()-i+1;j++){
			h.insert(s.substr(j,i));
		//	cout<<j<<" "<<i<<" "<<h.size()<<endl;
		}
	}
	auto u=h.begin();
	for(int i=2;i<=k;i++){
		u++;
	}
	cout<<*u;
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdlib.h>
#include<stack>
#include<set>
#include<string.h>
#include<map>
#include<vector>
#define pb push_back
#define eb emplace_back
#define ins insert 
#define mp make_pair
#define ll long long 
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define M 10000007
using namespace std;
void solve(){
	ll n,w;
	cin>>n>>w;
	ll we[n],v[n],dp[n+1][w+1];
	for (int i = 0; i < n; ++i)
	{
		cin>>we[i]>>v[i];
	}
	for (int i = 0; i <=n; ++i)
	{
		for (int j = 0; j<=w; ++j)
		{
			if(i==0 || j==0)
				dp[i][j]=0;
			else if(we[i-1]<=j)
				dp[i][j]=max(dp[i-1][j],v[i-1]+dp[i-1][j-we[i-1]]);
			else
				dp[i][j]=dp[i-1][j];
		//	cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	cout<<dp[n][w]<<endl;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0 ;
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

// ------------------------------------------------------------------------------------------

int x, y, z, K;
int A[11111];
int B[11111];
int C[11111];

signed main() {
  cin >> x >> y >> z >> K;
  rep (i, x) { cin >> A[i]; }
  rep (i, y) { cin >> B[i]; }
  rep (i, z) { cin >> C[i]; }

  vec<int> D;
  rep (i, x) {
    rep (j, y) {
      D.push_back(A[i] + B[j]);
    }
  }
  sort(all(D));
  reverse(all(D));
  sort(C, C+z);
  reverse(C, C+z);

  vec<int> ans;
  rep (i, z) {
    rep (j, min(K, (int)D.size())) {
      ans.push_back(C[i] + D[j]);
    }
  }
  sort(all(ans));
  reverse(all(ans));

  rep (i, K) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 43108
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 28 20:51:51 2020

@author: naoki
"""

X, Y, A, B, C = map(int, input().split())
p  = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p = sorted(p,reverse = True)
q = sorted(q,reverse = True)
r = sorted(r,reverse = True)

p_selected = p[:X]
q_selected = q[:Y]

#%%
All_selected = []
All_selected.extend(p_selected)
All_selected.extend(q_selected)
All_selected = sorted(All_selected)


for i in range(min(C,len(All_selected))):
    if All_selected[i] < r[i]:
        All_selected[i] = r[i]
print(sum(All_selected))

Measured memory_bytes: 109420
import sys
input = sys.stdin.readline


# import heapq
import heapq

# graph: 隣接リスト (頂点、距離）の順に格納
# start: 始点 (0-index)
# n: 頂点数
# memo[t]: startからtまでの最短距離
# return memo

def dijkstra(graph, start, n):
    INF = float('inf')
    memo = [INF] * n
    memo[start] = 0
    q = [(0, start)]

    while q:
        dist, ver = heapq.heappop(q)
        if memo[ver] < dist:
            continue
        for next_ver, next_dist in graph[ver]:
            if memo[next_ver] > dist + next_dist:
                memo[next_ver] = dist + next_dist
                heapq.heappush(q, (dist + next_dist, next_ver))

    return memo

n = int(input())
graph = [[] for i in range(n)]
for i in range(n):
    info = list(map(int, input().split()))
    for j in range(info[1]):
        graph[info[0]].append((info[j*2 + 2], info[j*2 + 3]))

memo = dijkstra(graph, 0, n)
for i, d in enumerate(memo):
    print(i, d)



Measured memory_bytes: 6200
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
int main() {
  ll n,cnt,ans=1e13,x;
  cin >> n;
  for(ll i=1; i*i<=n; i++) {
    if(n%i==0) {
      cnt=i+n/i-2;
      ans=min(ans,cnt);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void display()
{
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    puts( abs(a-c) <= d  ? "Yes" :  abs(a-b) <=d && abs(b-c) <=d ? "Yes" :"No");
    cout<<endl;
}
int main(void)
{
    display();
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;

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

	set<int> s;

	for (int i = 0; i < K; i++)
	{
		int d;
		cin >> d;

		for (int j = 0; j < d; j++)
		{
			int a;
			cin >> a;

			s.insert(a);
		}
	}

	cout << N - s.size() << endl;

	return 0;
}

Measured memory_bytes: 3576
const main = (standardInput) => {
    const lengthList = standardInput.split(' ');
    const a = Number.parseInt(lengthList[0]);
    const b = Number.parseInt(lengthList[1]);
    
    if (a < b){
        console.log('a < b');
    }else if(a > b){
        console.log('a > b');
    }else{
        console.log('a == b');
    }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));


Measured memory_bytes: 15108
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL ans1,ans2,sum;
int n;
int a[100010];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sum=0;
	for(int i=1,s=1;i<=n;i++,s*=-1){
		sum+=a[i];
		if(sum*s<=0) ans1+=abs(sum-s),sum=s;
	}
	sum=0;
	for(int i=1,s=-1;i<=n;i++,s*=-1){
		sum+=a[i];
		if(sum*s<=0) ans2+=abs(sum-s),sum=s;
	}
	printf("%lld\n",min(ans1,ans2));
	return 0;
} 


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
 
A, B, C = map(int, input().split())
K = int(input())


for bit in range(3**K):
  (a,b,c) = (A,B,C)
  r_bit = bit
  for k in range(K):
    amari = r_bit%3
    r_bit = int(r_bit/3)
    if amari == 0:
      a *= 2
    elif amari == 1:
      b *= 2
    else:
      c *= 2
  
  if a < b < c:
    print('Yes')
    exit(0)

print('No')

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

using namespace std;

int main() {
	
	int n;
	cin >> n;
	int A[n];

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

	int m;
	cin >> m;
	int B[m];

	for (int i = 0; i < m; i++) {
		cin >> B[i];
	}

	int out;

	if (n >= m) {
		for (int j = 0; j < m; j++) {
			out = 0;
			if (A[j] < B[j]) {
				out = 1;
				break;
			}
			else if (A[j] > B[j]) {
				out = 0;
				break;
			}
		}
	
	}
	else if (n < m) {
		for (int j = 0; j < n; j++) {
			out = 1;
			if (A[j] < B[j]) {
				out = 1;
				break;
			}
			else if(A[j] > B[j]){
				out = 0;
				break;
			}
		}

	}
	cout << out << endl;

}




Measured memory_bytes: 3124
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

dish = [a,b,c,d,e]
result=0

mx=-1

for dd in dish:
    for i in range(0,10):
        if (dd+i) % 10 == 0:
            tmp=i
            break
    if tmp > mx:
        mx = tmp
        buf=dd

dish.remove(buf)

for dd in dish:
    result+=dd
    for i in range(1,10):
        if result % 10 == 0:
            break
        result+=1
        
print(result+buf)


Measured memory_bytes: 3064
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    X, Y, Z, A, B, C, N = map(int, readline().split())

    S = [0]*max(2*(X+Y+Z+1), 2*N+2)
    for k in range(N):
        S[k] = k*(k+1)//2
    for k in range(N, X+Y+Z+1):
        S[k] = k*(k+1)//2 + S[k-N]

    def calc(k, x, y, z):
        return S[k] - S[k-x] - S[k-y] - S[k-z] + S[k-(x+y)] + S[k-(y+z)] + S[k-(z+x)] - S[k-(x+y+z)]

    ans = [0]*N
    for b in range(N):
        k = (X+Y+Z - b - 1) // N * N + b
        ans[b] = (
              calc(k+1, X-A, Y-B, Z-C)
            + calc(k, A, Y-B, Z-C)
            + calc(k, X-A, B, Z-C)
            + calc(k, X-A, Y-B, C)
            + calc(k-1, A, B, Z-C)
            + calc(k-1, X-A, B, C)
            + calc(k-1, A, Y-B, C)
            + calc(k-2, A, B, C)
        )
    write(" ".join(map(str, ans)))
    write("\n")
solve()


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

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  rep(i, n) rep(j, d) cin >> x[i][j];

  int ans = 0;
  for(int i = 0; i < n; ++i){
    for(int j = i + 1; j < n; ++j){
      int dist = 0;
      for(int k = 0; k < d; ++k){
        dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
      }
      for(int k = 0; k <= dist; ++k){
        if(k * k == dist){
          ans++;
        }
      }
    }
  }

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

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

int main() {
    int a[1000000];
    cin >> a[0];

    int i = 0;
    bool find = false;
    while (!find) {
        if (a[i] % 2 == 0) a[i+1] = a[i]/2;
        else a[i+1] = 3*a[i]+1;
        rep(j, i) {
            if (a[i+1] == a[j]) {
                cout << i+2 << endl;
                find = true;
                break;
            }
        }
        i++;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class _bubbleSort {
	
	// define variables & initialize
	private static int cnt = 0;	// how many bubbleSort is used
	
	// Default Constructor
	public _bubbleSort() {
	}
	
	// sort method :: sort given array using insertion Sort
	public static void sort(int[] _A, int _n) {
		int flg = 1;
		while (flg != 0) {
			flg = 0;
			for (int i = _n - 1; i >= 1; --i) {
				if (_A[i] < _A[i - 1]) {
					_A[i] = _A[i] ^ _A[i - 1];
					_A[i - 1] = _A[i] ^ _A[i - 1];
					_A[i] = _A[i] ^ _A[i - 1];
					flg = 1;
					++cnt;
				}
			}
		}
		
	}
	
	// print method :: print array
	public static void print(int[] _A) {
		for (int i = 0; i < _A.length; ++i) {
			System.out.print(_A[i]);
			if (i != _A.length - 1)
				System.out.print(" ");
		}
		System.out.println();
	}
	
	// get method :: get cnt (how many bubbleSort was used)
	public static int get() {
		return cnt;
	}
	
}

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		////////////////////////////////////
		int n = 0;
		int[] A;
		
		n = sc.nextInt();
		A = new int[n];
		
		for (int i = 0; i < n; ++i) {
			A[i] = sc.nextInt();
		}
		
		_bubbleSort.sort(A, n);
		_bubbleSort.print(A);
		System.out.println(_bubbleSort.get());
		
		////////////////////////////////////
		sc.close();
	}
}

Measured memory_bytes: 26364
N = int(input())
K = int(input())
tile = [tuple(map(int, input().split())) for i in range(K)] 
if N % 2 != 0:
    c = int(N / 2 + 0.5)
    if c % 3 == 0:
        red, blue, yellow = 2, 1, 0
    elif c % 3 == 2:
        yellow, red, blue = 2, 1, 0
    elif c % 1 == 1:
        blue, yellow, red = 2, 1, 0
    for i in range(K):
        x, y = tile[i]
        d = max(abs(x-c), abs(y-c))
        if d % 3 == red:
            print(1)
        elif d % 3 == blue:
            print(2)
        elif d % 3 == yellow:
            print(3)
else:
    c = N / 2
    if c % 3 == 0:
        red, blue, yellow = 2, 1, 0
    elif c % 3 == 2:
        yellow, red, blue = 2, 1, 0
    elif c % 1 == 0:
        blue, yellow, red = 2, 1, 0
    c += 0.5
    for i in range(K):
        x, y = tile[i]
        d = max(int(abs(x-c)-0.5), int(abs(y-c)-0.5))
        if d % 3 == red:
            print(1)
        elif d % 3 == blue:
            print(2)
        elif d % 3 == yellow:
            print(3)
    

Measured memory_bytes: 6832
#if 2
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>


#define in std::cin
#define out std::cout



int main()
{
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	auto c = [](bool b) {return b ? 1 : 0; };
	std::string S;
	in >> S;
	if (c((S.size() % 2) == 0) == c(S.front() == S.back())) {
		out << "First";
	}
	else {
		out << "Second";
	}
	out << std::endl;
	return 0;
}
#endif


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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    ll x;
    cin >> x;

    if((x > 105 && x < 200) || (x > 210 && x <300) || (x > 315 && x < 400) || (x > 420 && x < 500)
        || (x > 525 && x < 600) || (x > 630 && x < 700) || (x > 735 && x < 800) || (x > 840 && x < 900)
        || (x > 945 && x < 1000) || (x > 1050 && x < 1100) || (x > 1155 && x < 1200) || (x > 1260 && x < 1300)
        || (x > 1365 && x < 1400) || (x > 1470 && x < 1500) || (x > 1575 && x < 1600) || (x > 1680 && x < 1700)
        || (x > 1785 && x < 1800) || (x > 1890 && x < 1900) || (x > 1995 && x < 2000) || (x < 100)){
        cout << 0;
        return 0;
    }

    cout << 1;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int H,W,K;cin>>H>>W>>K;
    char S[H][W];
    REP(i,H)REP(j,W)cin>>S[i][j];
    int ans=INF;
    for(int tmp=0;tmp<(1<<(H-1));tmp++){
        bitset<9>s(tmp);
        int N=s.count();
        int Z[H-N][W];
      	REP(i,H-N)REP(j,W)Z[i][j]=0;
        int pre=H-1-N;
        int count=0;
      	REP(i,H){
            REP(j,W){
                if(i==0)Z[0][j]=S[0][j]-'0';
                else{
                    if(s.test(i-1)){
                        Z[i-1-count][j]+=S[i][j]-'0';
                    }
                    else Z[i-count][j]+=S[i][j]-'0';
                }
            }
          	if(i!=0&&s.test(i-1))count++;
        }
        bool ok=true;
        REP(k,W){
            REP(j,H-N){
                if(Z[j][k]>K){
                    ok=false;
                    break;
                }
            }
            if(k==W-1)break;
            bool cut=false;
            REP(j,H-N){
                if(Z[j][k]+Z[j][k+1]>K){
                    cut=true;
                    break;
                }
            }
            if(cut)pre++;
            else{
                REP(j,H-N)Z[j][k+1]+=Z[j][k];
            }
        }
        if(!ok)continue;
        ans=min(ans,pre);
    }
    cout<<ans<<endl;
}

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

int main(){
  int n,m,ML=0,mR;
  cin>>n>>m;
  mR=n;
  vector<long long int> L(m),R(m);
  for(int i=0;i<m;i++){
    cin>>L[i]>>R[i];
  }
  for(int i=0;i<m;i++){
    if(L[i]>ML){
      ML=L[i];
    }
    if(R[i]<mR){
      mR=R[i];
    }
  }
  if(mR>=ML){
    cout<<mR-ML+1<<endl;
  }
  else{
    cout<<0<<endl;
  }
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  double x, res;
  cin >> x;
  res = 360 / x;
  ans = 360 / x;
  count = x;
  count = lcm(count, 360);
  if (res != ans)
  {
    cout << count / x << endl;
  }
  else
  {
    cout << ans << endl;
  }
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b, c, d;
int x, y;
char ch;

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> ch;
  if (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u')
    pr("vowel");
  else
    pr("consonant");
}

Measured memory_bytes: 3640
N = int(input())
dp = [N + 1 for i in range(N+1)]
dp[0] = 0
for i in range(1,N+1):
    j = 0
    while i - pow(6,j) >= 0:
        if dp[i-pow(6,j)] + 1 < dp[i]:
            dp[i] = dp[i-pow(6,j)] + 1
        j += 1
    j = 0
    while i - pow(9,j) >= 0:
        if dp[i-pow(9,j)] + 1 < dp[i]:
            dp[i] = dp[i-pow(9,j)] + 1
        j += 1
print(dp[N])

Measured memory_bytes: 7064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define vll vector<pair<ll,ll> >
#define r0 return 0
#define be begin()
#define en end()
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define cf cout.flush()
int main()
{
   ios;
   long long n   , m ;
   cin >> n  >> m ;
   vl v ;
   forn(i , 1 , m){
    ll x;
    cin >> x;
    v.pb(x);
 }
  sort(v.begin() , v.end());
  if(n>=m) {
        cout << 0 <<endl ;
    r0 ;
  }
  vector<pll> vv;
  vl diff ;
  for(ll i=0;i<m-1;++i){
    ll foo = abs(v[i]-v[i+1]);
    diff.pb(foo);
  }
   sort(diff.be , diff.en);
   /// Travel as minimum as possible
   ll cost = 0 ;
   for(ll i = 0 ; i < m - n ; ++i){
    cost = cost + diff[i];
   }
   cout << cost << endl ;
   cf; r0 ;
}

















Measured memory_bytes: 2548
import sys
import math

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, h, m = map(int, input().split())
    t = h * 60 + m
    diff = min((5.5 * t) % 360, 360 - ((5.5 * t) % 360))

    res = pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(math.radians(diff))
    print(pow(res, 0.5))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9512
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()
    if a[0] != 0:
        return 0
    c = collections.Counter(a)
    r = 1
    for i in range(1,n):
        r *= c[a[i]-1]
        r %= mod2

    return r


print(main())





Measured memory_bytes: 20544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

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

    ll ans = 0;
    for(int i = 0; i < 22; i++){
        if(a*(i+1)<=t){ans += b;}
    }
    cout << ans << endl;
    return 0;
}


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

int n, a[100000];

int binarySearch(int key)
{
  int mid, left = 0, right;

  right = n;

  while(left < right){
    mid = (left + right) / 2;
    if(key == a[mid]) return 1;
    else if(key > a[mid]) left = mid + 1;
    else if(key < a[mid]) right = mid;
  }
  return 0;
}

int main(void)
{
  int i, j, q, key, result = 0;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }

  scanf("%d", &q);

  for(j = 0; j < q; j++){
    scanf("%d", &key);
    if(binarySearch(key)){
      result++;
    }
  }
  printf("%d\n", result);

  return 0;
}



Measured memory_bytes: 2120
#[allow(unused_imports)]
use proconio::{input, marker::*};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

fn main() {
    input! {
        n: usize,
    }

    let mut vec = vec![0; n + 1];
    vec[0] = 0;
    vec[1] = 0;
    let mut p = 2;
    while p * p <= n {
        if vec[p] > 0 {
            p += 1;
            continue;
        }
        let mut m = p * p;
        while m <= n {
            if vec[m] == 0 {
                vec[m] = p;
            }
            m += p;
        }
        p += 1;
    }

    let mut res = 0;
    for i in 1..n + 1 {
        let mut map = BTreeMap::new();
        let mut t = i;
        while vec[t] > 0 {
            *map.entry(vec[t]).or_insert(0) += 1;
            t /= vec[t];
        }
        if t > 1 {
            *map.entry(t).or_insert(0) += 1;
        }
        let mut count = 1;
        for (_, v) in map {
            count *= v + 1;
        }
        res += i * count;
    }
    println!("{}", res);
}


Measured memory_bytes: 80184
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;


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

	deque<int> R, L;
	for(int i = 0; i < N; i++) {
		if(s[i] == '<') {
			L.push_back(i);
		}
	}

	int ans = 0;
	for(int i = 0; i < N; i++) {
		if(s[i] == '<') {
			L.pop_front();
			if(R.size() == 0) {
				ans = max(ans, i + 1);
			}
			else {
				// ???????????????
				if(R.size() >= L.size() + 1) {
					int l = R[R.size() - 1 - L.size()];
					int r = N - 1;
					ans = max(ans, r - l + 1);
				}
				else {
					int l = 0;
					int r = L[R.size() - 1];
					ans = max(ans, r - l + 1);
				}
			}
		}
		else {
			if(L.size() == 0) {
				ans = max(ans, N - i);
			}
			else {
				if(L.size() >= R.size() + 1) {
					int l = 0;
					int r = L[R.size()];
					ans = max(ans, r - l + 1);
				}
				else {
					int l = R[R.size() - L.size()];
					int r = N - 1;
					ans = max(ans, r - l + 1);
				}
			}

			R.push_back(i);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3324
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    X,Y = map(int,input().split())

    res = 'No'

    for turu in range(X+1):
        kame = X - turu
        test = turu * 2 + kame * 4
        if test == Y:
            res = 'Yes'
            break

    print(res)



main()


Measured memory_bytes: 9168
//#include <bits/stdc++.h>
//
//using namespace std;
//
//#define int long long
//#define endl '\n'
//#define maxn 100010
//const int MOD = 1000000007;
//
//void solve() {
//    int k, t;
//    cin >> k >> t;
//
//    vector<int> v(k);
//    vector<pair<int, int>> val(t);
//    for (int i = 0; i < t; ++i) {
//        cin >> v[i];
//        val[i] = {i + 1, v[i]};
//    }
//    sort(val.begin(), val.end(), [](auto &a, auto &b) {
//        return a.second > b.second;
//    });
//    vector<int> ans(k);
//    int id = 0;
//    for (auto &x: val) {
//        if (id >= k)
//            id = 1;
//        for (; x.second > 0; id += 2) {
//            if (x.second == 0)break;
//            if (id >= k)
//                id = 1;
//            ans[id] = x.first;
//            x.second--;
//        }
//    }
//    for(auto x: ans)cout << x << " ";
//    cout << endl;
//    int ct = 0;
//    for (int i = 1; i < k; i++)if (ans[i] == ans[i - 1])ct++;
//    cout << ct << endl;
//}
//
//int32_t main() {
//    ios_base::sync_with_stdio(false);
//    cin.tie(nullptr);
//
//    int t = 1;
////    cin >> t;
//
//    while (t--)
//        solve();
//    return 0;
//}

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n;
    cin >> n;

    vector<int> v(n);
    map<int, int> mp;
    int sum = 0, ans = 0;
    mp[0]++;
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        sum += v[i];
        ans += mp[sum];
        mp[sum]++;
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define LCH (cur<<1)
#define RCH (cur<<1|1)
using namespace std;

const int MaxN=1e5+5;
const int Size=(1<<18)+5;
const int Mod=998244353;

int N,M,InvM,Cnt1,Cnt2,Ans;
char A[MaxN],B[MaxN];
int Fac[MaxN],Inv[MaxN];
int R[Size],Tmp[Size],F[Size],G[Size];

vector<int> V[MaxN<<2];

int C(int n,int m){
	return 1llu*Fac[n]*Inv[m]%Mod*Inv[n-m]%Mod;
}

int Pow(int base,int n){
	int ans=1;
	if(n<0)
		n+=Mod-1;
	for(;n;n>>=1){
		if(n&1)
			ans=1llu*ans*base%Mod;
		base=1llu*base*base%Mod;
	}
	return ans;
}

void NTT(int *a,int f){
	int i,j,k,w,wn,x,y;
	for(i=0;i<M;i++)
		if(i<R[i])
			swap(a[i],a[R[i]]);
	for(i=1;i<M;i<<=1){
		wn=Pow(3,f*(Mod-1)/(i<<1));
		for(j=0;j<M;j+=i<<1)
			for(k=0,w=1;k<i;k++){
				x=a[j+k],y=1llu*w*a[j+k+i]%Mod;
				a[j+k]=(x+y)%Mod;
				a[j+k+i]=(x-y+Mod)%Mod;
				w=1llu*w*wn%Mod;
			}
	}
}

void Solve(int cur,int l,int r){
	if(l==r){
		V[cur].resize(2);
		V[cur][0]=1,V[cur][1]=Mod-l;
		return;
	}
	int i,j=0,mid=l+r>>1;
	Solve(LCH,l,mid),Solve(RCH,mid+1,r);
	for(M=1;M<=r-l+1;M<<=1,j++);
	InvM=Pow(M,Mod-2);
	for(i=0;i<M;i++)
		R[i]=(R[i>>1]>>1)+((i&1)<<j-1);
	V[LCH].resize(M),V[RCH].resize(M);
	V[cur].resize(M);
	NTT(V[LCH].data(),1),NTT(V[RCH].data(),1);
	for(i=0;i<M;i++)
		V[cur][i]=1llu*V[LCH][i]*V[RCH][i]%Mod;
	NTT(V[cur].data(),-1);
	V[cur].resize(r-l+2);
	for(i=0;i<=r-l+1;i++)
		V[cur][i]=1llu*V[cur][i]*InvM%Mod;
}

void Get_Inv(int *a,int *b,int n){
	if(n<2){
		b[0]=Pow(a[0],Mod-2);
		return;
	}
	Get_Inv(a,b,n+1>>1);
	int i,j=0;
	for(M=1;M<=n<<1;j++,M<<=1);
	InvM=Pow(M,Mod-2);
	for(i=0;i<M;i++)
		R[i]=(R[i>>1]>>1)+((i&1)<<j-1);
	for(i=0;i<n;i++)
		Tmp[i]=a[i];
	for(i=n;i<M;i++)
		Tmp[i]=0;
	NTT(Tmp,1),NTT(b,1);
	for(i=0;i<M;i++)
		b[i]=1llu*b[i]*(2-1llu*Tmp[i]*b[i]%Mod+Mod)%Mod;
	NTT(b,-1);
	for(i=0;i<n;i++)
		b[i]=1llu*b[i]*InvM%Mod;
	for(i=n;i<M;i++)
		b[i]=0;
}	

int main(){
	int i,j,k;
	scanf("%s%s",A+1,B+1);
	N=strlen(A+1);
	for(i=1;i<=N;i++)
		if(A[i]=='1')
			B[i]=='1'?Cnt1++:Cnt2++;
	Fac[0]=Inv[0]=Fac[1]=Inv[1]=1;
	for(i=2;i<=N;i++){
		Fac[i]=1llu*Fac[i-1]*i%Mod;
		Inv[i]=1llu*(Mod-Mod/i)*Inv[Mod%i]%Mod;
	}
	for(i=2;i<=N;i++)
		Inv[i]=1llu*Inv[i-1]*Inv[i]%Mod;
	if(Cnt2){
		Solve(1,1,Cnt2);
		for(i=0;i<=Cnt2;i++)
			F[i]=V[1][i];
	}
	else F[0]=1;
	Get_Inv(F,G,Cnt1+1);
	for(i=0;i<=Cnt1;i++)
		Ans=(Ans+1llu*G[i]*Inv[i+Cnt2])%Mod;
	printf("%d\n",1llu*Ans*Fac[Cnt2]%Mod*Fac[Cnt2]%Mod*Fac[Cnt1]%Mod*Fac[Cnt1+Cnt2]%Mod);
	return 0;
}

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

fn main() {
    let n: usize = read();
    let h: Vec<i64> = (0..n).map(|_| read()).collect();

    let mut ans = 0;
    for i in 1..101 {
        let mut j = 0;
        let mut now = false;
        loop {
            if h[j] >= i {
                now = true;
            } else {
                if now {
                    ans += 1;
                    now = false;
                }
            }
            j += 1;
            if j == n {
                if now {
                    ans += 1;
                }
                break;
            }
        }
    }
    println!("{}", ans);
}

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


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
using namespace std;
void dfs(int place, int pass);
vector<int>graph[8];
int flag[8];
int n, m;
int counter = 0;

int main() {


	cin >> n >> m;

	int a, b;
	int i;
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		graph[a - 1].push_back(b - 1);
		graph[b - 1].push_back(a - 1);
	}

	//0が始点

	//int pass = 0;
	//int place = 0;
	for (i = 0; i < n; i++) {
		flag[i] = 0;
	}
    flag[0] = 1;
	counter = 0;
	dfs(0, 1);
	cout << counter << endl;
	return 0;
}
void dfs(int place, int pass) {
	int i;
	for (i = 0; i < graph[place].size(); i++) {
		if (flag[graph[place][i]] == 0) {
			flag[graph[place][i]] = 1;
			//pass++;
			//place = graph[place][i];
			if (pass == n - 1) {
				counter++;
              //cout << 'a' << place << ' ' << pass << endl;
			}
			else {
				dfs(graph[place][i], pass + 1);
              //cout << 'b' << place << ' ' << pass  << endl;
			}
			flag[graph[place][i]] = 0;
		}
	}
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;

int heap[250];
int H;
int main()
{
    cin >> H;
    for (int i = 0; i < H; i++)
        cin >> heap[i];

    for (int i = 0; i < H; i++)
    {
        printf("node %d: key = %d, ", i + 1, heap[i]);
        if ((i + 1) / 2 > 0)
            printf("parent key = %d, ", heap[(i + 1) / 2 - 1]);
        if (2 * (i + 1) <= H)
            printf("left key = %d, ", heap[2 * (i + 1)-1]);
        if (2 * (i + 1) + 1 <= H)
            printf("right key = %d, ", heap[2 * (i + 1)]);
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in=new Scanner (System.in);
		int N=in.nextInt();
		int L=in.nextInt();
		String[] arr=new String[N];
		for (int i = 0; i < N; i++) {
			arr[i]=in.next();
		}
		Arrays.sort(arr);
		String a="";
		for (int i = 0; i < arr.length; i++) {
			a=a+arr[i];
		}
		System.out.println(a);
	}	
}

Measured memory_bytes: 33464
import java.io.*;
import java.util.*;


/**
 * AIZU ONLINE JUDGE
 * 3107
 *  2020/5/1
 */
public class Main {




    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        int N = sc.nextInt();
        int M = sc.nextInt();
        sc.nextLine();

        String[] s = new String[N];

        int cnt = 0;
        for(int i = 0; i < N; i++) {
            s[i] = sc.nextLine();
            log.printf("%s\n", s[i]);
        }
        for(int i = 0; i < N; i++) {
            String t = sc.nextLine();
            log.printf("%s\n", t);
            for(int j = 0; j < M; j++) {
                if (s[i].charAt(j) != t.charAt(j)) {
                    cnt++;
                }
            }
        }
        System.out.printf("%d\n", cnt);

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();

        instance.systemin.close();
    }


}




Measured memory_bytes: 94620
N = int(input())
A_list = list(map(int, input().split()))

L = []
R = []
for i, A in enumerate(A_list):
    L.append(i+A)
    R.append(i-A)


import collections
r_dict = collections.Counter(R)
ans = 0
for l in L:
    ans += r_dict.get(l, 0)
print(ans)


Measured memory_bytes: 50936
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b;
	string x,y,u;
	cin>>x>>y;
	cin>>a>>b;
	cin>>u;
	if(u==x) a--;
	else if(u==y) b--;
	cout<<a<<" "<<b;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
  int N,Y;
  bool can = false;
  int a,b,c;

  cin >> N >> Y;
  Y = Y/1000;

  for(int i=0;i<N+1;i++){
    for(int j=0;j<N-i+1;j++){
      if((i*10+j*5+(N-j-i)*1)==Y){
        can = true;
        a =i;
        b=j;
        c=N-i-j;
        break;
      }
    }
  }
  if(can) cout << a << ' ' << b << ' ' << c << endl;
  else cout << "-1 -1 -1" << endl;
}


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

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  cin >> N >> M;
  vector<ll> a(N),b(M);
  rep(i,N)  cin >> a.at(i);
  rep(i,M)  cin >> b.at(i);

  vector<ll> c = convolution(a, b);
  rep(i,N+M-1)  cout << c.at(i) << " ";
  cout << endl;

  return 0;
}

Measured memory_bytes: 27252
s=input()
l=len(s)
n=2**(l-1)
total=0
for i in range(n):
    buf=s[0]
    for j in range(l-1):
        if ((i>>j)&1):
            total+=int(buf)
            buf=s[j+1]
        else:
            buf+=s[j+1]
    total+=int(buf)
print(total)


Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
typedef struct h{int t,w;}h;
int n,i,j,x,a,f,e;
h p[999];

int cmp(const void *x,const void *y)
{
	if(((h*)x)->t==((h*)y)->t)
		return ((h*)x)->w-((h*)y)->w;
	return ((h*)x)->t-((h*)y)->t;
}
int main()
{
	for(;scanf("%d",&n),n;)
	{
		for(i=j=0;i<n;i++)
		{
			scanf("%d%d%d",&a,&f,&e);
			p[j].t=f,p[j++].w=a;
			p[j].t=e,p[j++].w=-a;
		}
		qsort(p,2*n,sizeof(h),cmp);
		for(i=x=0;i<2*n;)
			if((x+=p[i++].w)>150)
				break;
		puts(i==2*n?"OK":"NG");
	}
	return 0;
}

Measured memory_bytes: 636
import Control.Monad

main = do
  n <- readLn
  txys <- map (map read . words) <$> replicateM n getLine
  putStrLn . showF $ f (map lToTri ([0,0,0]:txys))

showF :: Bool -> String
showF True  = "Yes"
showF False = "No"

lToTri [t,x,y] = (t,x,y)

f :: [(Int,Int,Int)] -> Bool
f [] = True
f [txy] = True
f ((t1,x1,y1):(t2,x2,y2):cs) = (t2-t1) >= ((x2-x1)+(y2-y1)) && ((t2-t1)-((x2-x1)+(y2-y1))) `mod` 2 == 0 && f ((t2,x2,y2):cs)

Measured memory_bytes: 73212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//オーバーフローに注意 long long　にする
//'1'+=16;      で大文字Aに
//'大文字'+=32;  で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


 
int main() {
 
  int n;
  cin >> n;
  
  for(int i = n; i<1000;i++) {
    if(i%111==0) {
    cout << i <<endl;
    return 0;
    }
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
using namespace std;

int main() {
	vector<vector<char>>A(3, vector<char>(3));
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A.at(i).at(j);
		}
	}
	for (int i = 0; i < 3; i++) {
		cout << A.at(i).at(i);
	}
	cout << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
n, m = map(int, input().split())
h = list(map(int, input().split()))
ns = defaultdict(set)
s = set(list(range(n)))

for i in range(m):
    u,v = map(int, input().split())
    u -= 1
    v -= 1
    if h[u]<=h[v] and u in s:
        s.remove(u)
    if h[v]<=h[u] and v in s:
        s.remove(v)

print(len(s))

Measured memory_bytes: 24040
A, B, M = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = min(a) + min(b)

for i in range(M):
  x, y, c = map(int, input().split())
  val = a[x-1] + b[y-1] - c
  ans = min(ans, val)
print(ans)


Measured memory_bytes: 18488
#include<iostream>
#include<cstring>
using namespace std;
 
const int MOD = 100000;
int n, m, s;
int dp[2][2001][3001];
int main()
{
  while(cin >> n >> m >> s && n && m && s){
    memset(dp, 0, sizeof dp); 
    int ans = 0;
    dp[0][0][0] = 1;
 
    for(int i = 1; i <= n * n; i++){
      for(int j = 1; j <= m; j++)
	for(int k = j; k <= s; k++)
	  dp[i % 2][j][k] = (dp[i % 2][j - 1][k - 1] + dp[(i + 1) % 2][j - 1][k - j]) % MOD; 
      
      memset(dp[(i + 1) % 2], 0, sizeof dp[(i + 1) % 2]);
    }
 
    for(int i = 1; i <= m; i++)
      ans = (ans + dp[n * n % 2][i][s]) % MOD;
    cout << ans << endl;
  }
  return 0;
}

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


using namespace std;
const int MOD = 1e9 + 7;


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

    vector<int> a(m);
    for (int i=0; i<m; i++) {
        cin >> a[i];
    }

    int t = 0;
    vector<int> b(n+1, 0);

    for (int cur=0; cur<=n; cur++) {
        if (m != 0 and a[t] == cur) {
            t++;
            continue;
        }

        if (m == 0 or (t <= m and a[t] != cur+1)) {
            if (cur == 0 and cur+1 <= n) b[cur+1] = 1;
            if (cur+1 <= n and b[cur] != 0) {
                b[cur+1] += b[cur];
                b[cur+1] %= MOD;
            }
        }

        if (m == 0 or (t <= m and a[t] != cur+2)) {
            if (cur == 0 and cur+2 <= n) b[cur+2] = 1;
            if (cur+2 <= n and b[cur] != 0) {
                b[cur+2] += b[cur];
                b[cur+2] %= MOD;
            }
        }
    }

    b[n] %= MOD;
    cout << b[n] << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <math.h>

int main()
{
    double a,b,c,d,e,f,x,y;
	while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=EOF)
	{
		x=(c*e-b*f)/(a*e-d*b);
		y=(a*f-d*c)/(a*e-d*b);
		if (fabs(x)<0.0005)
			x=0;
		else if (fabs(y)<0.0005)
			y=0;
		printf("%.3lf %.3lf\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 652
#include <stdio.h>
#include <stdlib.h>

typedef long long int llint;
const int M = 40;

int takebit(llint x, int m)
{
  return (x>>m)&1;
}

llint g(llint x, llint (*s)[2])
{
  llint r = 0;
  for(int m=0; m<M; m++) {
    r+=s[m][takebit(x,m)];
  }

  return r;
}

// kill before m-th
llint downzeromask(llint x, int m)
{
  return x&((llint)(-1)<<m);
}

// kill from m-th
llint upzeromask(llint x, int m)
{
  return x&(((llint)(1)<<m)-1);
}

int main(void)
{
  llint N, K;
  int n, m;
  llint *A, (*S)[2];
  llint s, Y, Kb, ans, new, Z;

  /* input */
  scanf("%lld%lld",&N,&K);
  A = malloc(sizeof(llint)*N);
  for(n=0;n<N;n++) {
    scanf("%lld",&(A[n]));
  }

  S = malloc(sizeof(llint)*N*2);
  Y = 0;
  for(m=0;m<M;m++) {
    s = 0;
    for(n=0;n<N;n++) {
      s += takebit(A[n],m);
    }
    S[m][0] = s<<m;
    S[m][1] = (N-s)<<m;
    if(2*s < N) {
      Y |= (llint)(1)<<m;
    }
  }
  
  Kb = K+1;
  ans = 0;
  for(m=0;m<M;m++) {
    if(takebit(Kb,m)==1) {
      Z = downzeromask(K,m+1) + upzeromask(Y,m);
      new = g(Z,S);
      if(new > ans) {
        ans = new;
      }
    }
  }

  printf("%lld\n",ans);
  
  return 0;
}

Measured memory_bytes: 896