akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std; 

#define PI 3.14159265358979323846264338327950L

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    long double a,b,h,m,ans=0.0;
    cin>>a>>b>>h>>m;
 
    long double total_minute = h*60+m;
    long double degree = (total_minute/2) - m*6.0;
    degree*= PI/180.0;

    ans = (a*a) + (b*b) - (2*a*b*cos(degree));
 
    printf("%.20Lf\n",sqrt(ans));
 
    return 0;
}


Measured memory_bytes: 4060
n = int(input())
a = list(map(int, input().split()))
result=0
flug = 0
if(len(a) == 1):
    print(1)
else:
    a.sort()
    dp = [True] * a[-1]
    flug = 1
    for j in range(n):
        if(dp[a[j]-1] == True):
            if(a[j] == a[j-1]):
                if(flug == 0):
                    result-=1
                    flug = 1
            else:
                result+=1
                flug = 0
            k = a[j] * 2
            while(k-1 < len(dp)):
                dp[k-1] = False
                k+=a[j]
                
    print(result)

Measured memory_bytes: 93000
#define A
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
#if A
        var XY = ReadLine().Split().Select(int.Parse).ToArray();
        var X = XY[0];
        var Y = XY[1];
        var ans = Max(0, 4 - X) + Max(0, 4 - Y) + (X == 1 && Y == 1 ? 4 : 0);
        WriteLine(ans * 100000);
#endif
#if B
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split().Select(long.Parse).ToArray();
        var a = new long[N + 1];
        for (int i = 0; i < N; i++)
        {
            a[i + 1] = 2 * A[i] + a[i];
        }
        var m = a[N] / 2;
        var ans = long.MaxValue;
        for (int i = 0; i <= N; i++)
        {
            ans = Min(ans, Abs(a[i] - m));
        }
        WriteLine(ans);
#endif
#if C
        var HWK = ReadLine().Split().Select(int.Parse).ToArray();
        var H = HWK[0];
        var W = HWK[1];
        var K = HWK[2];
        var s = new bool[H, W];
        for (int i = 0; i < H; i++)
        {
            var line = ReadLine();
            for (int j = 0; j < W; j++)
            {
                s[i, j] = line[j] == '#';
            }
        }
        var ha = new bool[H];
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                if (s[i, j]) ha[i] = true;
            }
        }
        var ans = new int[H, W];
        var k = 0;
        for (int i = 0; i < H; i++)
        {
            if (ha[i])
            {
                var b = false;
                k++;
                for (int j = 0; j < W; j++)
                {
                    if (s[i, j])
                    {
                        if (b) k++;
                        b = true;
                    }
                    ans[i, j] = k;
                }
            }
            else
            {
                for (int j = 0; j < W; j++)
                {
                    if (i != 0) ans[i, j] = ans[i - 1, j];
                }
            }
        }
        if (!ha[0])
        {
            for (int j = 0; j < W; j++)
            {
                ans[0, j] = ans[1, j];
            }
        }

        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                Write(ans[i, j]);
                if (j != W - 1) Write(" ");
            }
            WriteLine();
        }
#endif
    }
}

Measured memory_bytes: 13396
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input, "index" : 0, "max" : input.length,
  "hasNext" : function(){return (this.index < this.max);},
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  }
}
Main();
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  var C = one[2];
  if((A <= C && B >= C) || (B <= C && A >= C)){
     myout("Yes");
  }else{
     myout("No");
  }
}


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

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))
#define all(a) (a).begin(),(a).end()
#define pi 3.14159265358979323846

typedef pair<ll, ll> P;
string s[] = { "SUN","MON","TUE","WED","THU","FRI","SAT"};

int main(){
    string st;
    cin >> st;
    REP(i, 7) {
        if(s[i] == st) {
            cout << 7 - i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, (input().split()))

yukichi = -1
higuchi = -1
noguchi = -1

for x in range(0, N + 1):
    for y in range(0, N + 1 - x):

        z = N - x - y

        if 10000 * x + 5000 * y + 1000 * z == Y:
            yukichi = x
            higuchi = y
            noguchi = z

print(yukichi, higuchi, noguchi)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/
typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

vs input(string& s)
{
	int t = s.find('-');
	string l = s.substr(0, t);
	string r = s.substr(t + 1);
	vs res;
	res.push_back(l); res.push_back(r);
	return res;
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		vector<vs> v(n);
		map<string, int> mp;
		REP(i, n)
		{
			string s; cin >> s;
			v[i] = input(s);
		}
		int p = 0;
		REP(i, n)REP(j, 2)
		{
			string tmp = v[i][j];
			if (mp.count(tmp)) continue;
			mp[tmp] = p;
			p++;
		}
		cout << p << endl;
		Graph g(p);
		Matrix dist(p, Array(p));
		REP(i, n)
		{
			int l = mp[v[i][0]], r = mp[v[i][1]];
			add_edge(g, l, r, 1);
			add_edge(g, r, l, 1);
			dist[r][l] = 1;
		}
		vector<pii> same;
		REP(i, p)REP(j, i)
		{
			bool f1 = false, f2 = true;
			REP(k, p)
			{
				if ((dist[i][k] || dist[k][i]) && (dist[j][k] || dist[k][j])) f1 = true;
				if ((dist[i][k] && dist[k][j]) || (dist[k][i] && dist[j][k])) f2 = false;
			}
			if (f1&&f2) same.emplace_back(i, j);
		}
		for (auto i : same)
		{
			dist[i.first][i.second] = 1;
			dist[i.second][i.first] = 1;
		}
		REP(k, p)REP(i, p)REP(j, p)
		{
			if (dist[i][k] && dist[k][j]) dist[i][j] = 1;
		}
		vi color(p);
		int col = 1;
		REP(i, p)
		{
			if (color[i]) continue;
			queue<int> que;
			que.push(i);
			int c = col, d = -col;
			color[i] = c;
			while (!que.empty())
			{
				int t = que.front();
				que.pop();
				int nx = (color[t] == c ? d : c);
				REP(j, g[t].size())
				{
					if (color[g[t][j].to]) continue;
					color[g[t][j].to] = nx;
					que.push(g[t][j].to);
				}
			}
			col++;
		}
		int q;
		cin >> q;
		REP(i, q)
		{
			string s; cin >> s;
			vs t = input(s);
			if (!mp.count(t[0]) || !mp.count(t[1]))
			{
				puts("NO");
				continue;
			}
			int l = mp[t[0]], r = mp[t[1]];
			if (color[l] == -color[r] && dist[r][l])
			{
				puts("YES");
			}
			else
			{
				puts("NO");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3404
import java.util.*;

class Main{
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    HashMap<String, Integer> counts = new HashMap<String, Integer>();
    int count = 0;
    for(int i=0;i<N;i++){
      String K = sc.next();
      int t = counts.getOrDefault(K, 0);
      counts.put(K, t + 1);
      count = Math.max(count, t + 1);
   }
    List<String> st = new ArrayList<>();
        for(Map.Entry<String, Integer> entry : counts.entrySet()) {
            if(entry.getValue() == count) {
                st.add(entry.getKey());
            }
        }
        
        Collections.sort(st);
        for(String s : st) {
            System.out.println(s);
        }

    

  }
}

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int t[5];
  for(int i = 0; i < 5; i++){
    cin >> t[i];
  }
  vector<int> a(5);
  for(int i = 0; i < 5; i++){
    a[i] = i;
  }
 
  int k = 0;
  for(int i = 0; i < 5; i++){
    if(k % 10 != 0){
      k += 10 - k % 10;
    }
    k += t[a[i]];
  }
  int m = k;
  while(next_permutation(a.begin(), a.end())){
    k = 0;
    for(int i = 0; i < 5; i++){
      if(k % 10 != 0){
        k += 10 - k % 10;
      }
      k += t[a[i]];
    }
    m = min(m, k);
  }
  cout << m << "\n";
  return 0;
}

Measured memory_bytes: 256
S="012 345 678 036 147 258 048 246 "
A=[input().split()for i in range(3)]
for b in [input()for i in range(int(input()))]:
  for l in range(9):
    S=S.replace(str([9,l][b==(A[0]+A[1]+A[2])[l]]),"")
print(["No","Yes"][S.find("  ")>-1])

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)

# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

def main():
	N, M = map(int, input().split(" "))
	#N = int(input())
	#S = input()

	KS = []
	for i in range(M):
		tmp = input().split(" ")
		tmp = [int(s) for s in tmp]
		KS.append(tmp[1:])
	
	P = input().split(" ")
	P = [int(s) for s in P]

	ans = 0
	for den in range(0, 2**N):
		flg = True
		for j, val in enumerate(KS):
			tmp = 0
			for vol in val:
				aa = vol-1
				#print("{} {} {}".format(den, vol-1, (den & 2**aa) >> 1))

				if ((den & 2**(vol-1)) >> (vol-1)) == 1:
					tmp += 1
			if (tmp % 2) != P[j]:
				flg = False
		if flg == True:
			ans += 1

	print(ans)

if __name__ == "__main__":
	main()

Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define MAX_INT 100000
#define MOD 1000000007
#define forf(i,a,b) for(int i=a;i<=b;i++)

void solve()
{
    ll n;cin>>n;
    cin>>n;
    
    ll ans=(n*(n+1))/2;
    ans-=(3*(n/3*(n/3+1)))/2;
    ans-=(5*(n/5*(n/5+1)))/2;
    ans+=(15*(n/15*(n/15+1)))/2;
    cout<<ans;
}
    
    
int main()
{
    IOS;
    
    //ll t;cin>>t;while(t--)
        solve();
 
    return 0;
}

Measured memory_bytes: 3652
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define SENTINEL 1000000001

#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))

using namespace std;

typedef pair<int, int> pii;

long long int a[100010];

int main() {
	long long int N, Q;
	scanf("%lld %lld", &N, &Q);

	for (int i = 0; i < N; i++)
	{
		scanf("%lld", &a[i]);
	}
	for (int i = 0; i < Q; i++)
	{
		long long int q;
		scanf("%lld", &q);

		long long int l = 0, t = 0, c = 0;

		for (long long int r = 0; r < N; r++)
		{
			t += a[r];
			while (t > q)
			{
				t -= a[l];
				l++;
			}
			c += (r - l + 1);
		}

		printf("%lld\n", c);
	}

	return 0;
}


Measured memory_bytes: 3944
let n, l = Scanf.scanf "%d %d\n" (fun x y -> x, y)

let rec read_ints acc = function
  | 0 -> List.rev acc
  | k -> read_ints (Scanf.scanf "%d " (fun x -> x) :: acc) (k-1)

let al = read_ints [] n

let rec solve i k = function
  | [] | _ :: [] -> Some ([], [])
  | hd0 :: ((hd1 :: tl1) as tl0) -> if k < l then None else
    if hd0 + hd1 >= l then
      match solve (i+1) k (hd0 + hd1 :: tl1) with
        | None -> None
        | Some (x, y) -> Some (x, (i :: y))
    else
      match solve (i+1) (k-hd0) tl0 with
        | None -> None
        | Some (x, y) -> Some ((i :: x), y)

let sum = List.fold_left (+) 0 al

let () =
  match solve 1 sum al with
  | None -> print_endline "Impossible"
  | Some (x, y) -> print_endline "Possible"; let p = List.iter (fun x -> print_int x; print_newline ()) in p x; p (List.rev y)

Measured memory_bytes: 13184
#ifdef debug
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define vec vector
#define ALL(x) begin(x), end(x)

typedef unsigned int ui;
typedef long long ll;
typedef long double ld;
typedef pair< int, int > pii;
typedef pair< long long, long long > pll;

const int inf = 1e9;
const ll inf64 = ll(1e18);

const int N = 1e5 + 5;

int n, m;
int p[N];
vec< int > g[N];
int used[N];

void dfs(int v, set< int > &a, set< int >& b) {
    used[v] = 1;
    a.insert(v);
    b.insert(p[v]);
    for(int to : g[v]) {
        if(!used[to]) {
            dfs(to, a, b);
        }
    }
}

int main() {

#ifdef debug
    freopen("input.txt", "r", stdin);
#endif

    scanf("%d %d", &n, &m);

    for(int i = 1;i <= n;i++) {
        scanf("%d", &p[i]);
    }

    for(int u, v, i = 0;i < m;i++) {
        scanf("%d %d", &u, &v);
        g[u].push_back(v);
        g[v].push_back(u);
    }

    int res = 0;

    for(int v = 1;v <= n;v++) {
        if(used[v]) continue;
        set< int > a, b;
        dfs(v, a, b);
        for(int x : a) {
            if(b.count(x)) {
                res++;
            }
        }
    }

    printf("%d\n", res);

    return 0;
}


Measured memory_bytes: 19968
const main = (input) => {
  const lines = input.trim().split("\n");
  const [N, M] = lines[0].split(' ').map(str => parseInt(str));
  const checkList = lines.slice(1).map(line => {
    const [s, c] = line.split(' ');
    return [parseInt(s - 1), c];
  });

  // 全探索
  // for (let i = 0; i < Math.pow(10, N); i++) {
  //   const strNum = i.toString();
  //   if (strNum.length == N && checkList.every(sc => strNum[sc[0]] === sc[1])) {
  //     console.log(strNum)
  //     process.exit(0);
  //   }
  // }
  // console.log(-1);

  // 順番に埋める
  let numList = Array(N).fill(-1);
  checkList.forEach(sc => {
    sc[1] = parseInt(sc[1]);
    if (numList[sc[0]] !== -1 && numList[sc[0]] !== sc[1]) {
      console.log(-1);
      process.exit(0);
    }
    numList[sc[0]] = sc[1]
  });


  numList = numList.map((num, i) => {
    if (i === 0) {
      if (numList[i] === -1) {
        if (N === 1) {
          return 0;
        } else {
          return 1;
        }
      } else {
        return num;
      }
    } else {
      if (numList[i] === -1) {
        return 0;
      } else {
        return num;
      }
    }
  });

  if (N >= 2 && numList[0] === 0) {
    console.log(-1);
    process.exit(0);
  }

  console.log(numList.join(""));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
int h[100002];
bool good[100002];
int main()
{
	int n,m,cnt=0;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int j=0;j<m;j++)
	{
		int a,b;
		cin>>a>>b;
		if(h[a]<=h[b])
			good[a]=1;
		if(h[a]>=h[b])
			good[b]=1;
	}
	for(int i=1;i<=n;i++)
		if(good[i]==0)
			cnt++;
	cout<<cnt;
	return 0;
	
}

Measured memory_bytes: 4080
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def main():
    n = int(stdin.readline().rstrip())
    s = str(stdin.readline().rstrip())
    #n,m = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    #numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    ans = n
    dp = [0 for j in range(n+1)]
    for i in range(n):
        if s[i] == "W":
            dp[i+1] = dp[i] + 1
        else:
            dp[i+1] = dp[i]
    for i in range(n):
        ans = min (ans, dp[i] + ( (n-i-1) - (dp[n] - dp[i+1]) ))
    print(ans)


main()


Measured memory_bytes: 21228
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  struct node *prev;
  struct node *next;
  long key;
};
typedef struct node * NP;
NP MN(long);
void IN(NP);
void DN(NP);
void FI(long);
NP dummy;

int main(){
  long int val,i,n;
  char op[12];
  NP roop;

  scanf("%ld",&n);
  dummy = MN(0);

  for(i=0;i<n;i++){
    scanf("%s",op);
    
    if(strcmp(op,"insert") == 0){
      scanf("%ld",&val);
      IN(MN(val));
    }
    else if(strcmp(op,"delete") == 0){
      scanf("%ld",&val);
      FI(val);
    }
    else if(strcmp(op,"deleteFirst") == 0){
      if(dummy->next != dummy){
      DN(dummy->next);
      }
    }
    else if(strcmp(op,"deleteLast") == 0){
      if(dummy->prev != dummy){ 
     DN(dummy->prev);
      }
    }
  }

  for(roop=dummy->next;roop!=dummy;roop =roop->next){
    printf("%ld",roop->key);
    if(roop->next != dummy)printf(" ");
  }  
  printf("\n");

  return 0;
}


void FI(long value){ // find item
  NP n;
  dummy->key = value;
  for(n = dummy->next;;n=n->next){
    if(n->key == value)break;
  }
  if(n != dummy)DN(n);
    
}


void DN(NP th){ //delete node
  th->prev->next = th->next;
  th->next->prev = th->prev;
  th->prev = th->next = th;
  free(th);
  //delete th;
}


void IN(NP newn){ //insert node
  newn->next = dummy->next;
  newn->next->prev = newn;
  dummy->next = newn;
  newn->prev = dummy;
}

NP MN(long key){ //make node
  NP no = (NP)malloc(sizeof(struct node));
  //n = new struct node();
  no->prev = no;
  no->next = no;
  no->key = key;
  return no;
} 

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

int main(){
    int N;
    cin >> N;
    int a[N];
    bool seen[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
        a[i]--;
        seen[i] = false;
    }
    int tmp=0;
    seen[0] = true;
    int ans = 0;
    for(int i=0; i<N; i++){
        tmp = a[tmp];
        if(seen[tmp]){
            ans = -1;
        }else if(tmp==1){
            ans++;
            break;
        }else{
            ans++;
            seen[tmp]=true;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 896
loop {
	n, a, b = gets.split.map &:to_i
	break if n == 0
	table = [true]
	count = 0
	(1..n).each{|i|
		table[i] |= table[i-a] if i >= a
		table[i] |= table[i-b] if i >= b
		count += 1 if !table[i]
	}
	p count
}

Measured memory_bytes: 33392
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
//long long num[100000];
int u[2000000],n;
vector<int> g[201010];
int fo(){
	for(int i : g[1]){
		for(int j : g[i]){
			if(j==n) return true;
		}
	}
	return false;
}
int main(){
	int m,flag=false,a,b;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		if(a==1||b==1||a==n||b==n){
			g[a].push_back(b);
			g[b].push_back(a);
		}
	}
	cout<<(fo()?"POSSIBLE":"IMPOSSIBLE")<<endl;
	return 0;
}

Measured memory_bytes: 13552
#include<iostream>
#include<math.h>
#include<vector>

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b)
{
    return b ? gcd(b, a % b) : a;
}

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

    ll g = gcd(a, b);
    ll gd = g;
    ll ans = 1;
    ll rootg = sqrt(g) + 1;

    for (ll i = 2; (i - 1) * (i - 1) <= g; i++)
    {

        if(gd%i!=0)
            continue;

        while(gd%i==0)
        {
                gd = gd / i;
        }
        ans++;
    }
    if(gd!=1)
    {
        ans++;
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
X,Y,Z,K = list(map(int,input().split()))
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []

for j in range(X):
    if j+1 > K:
        break
    for k in range(Y):
        if j*k+1 > K:
            break
        for l in range(Z):
            if j*k*l+1 <= K:
                ans.append(A[j]+B[k]+C[l])
            else: 
                break
                
ans.sort(reverse=True)
for i in range(K):
    print(ans[i])

Measured memory_bytes: 112348
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
#define MAXN 1000000
using namespace std;
map<string,int> mp;
struct Point
{
    int x1,y1,x2,y2;
    string name;
};
struct List
{
   string name;
   int num;
   Point p[105];

}list[105];
int a[MAXN];
int main()
{
   // freopen("in.cpp","r",stdin);

    int n,i,j,k,m;
    int W,H;
    while(scanf("%d",&n)&&n)
    {
        mp.clear();
       scanf("%d%d",&W,&H);
       for(i=0;i<n;i++)
       {   cin>>list[i].name;
           mp[list[i].name]=i;
           scanf("%d",&list[i].num);
           for(j=0;j<list[i].num;j++)
           {
               scanf("%d%d%d%d",&list[i].p[j].x1,&list[i].p[j].y1,&list[i].p[j].x2,&list[i].p[j].y2);
               list[i].p[j].x1=max(list[i].p[j].x1,0);
               list[i].p[j].y1=max(list[i].p[j].y1,0);
               list[i].p[j].x2=min(list[i].p[j].x2,W);
               list[i].p[j].y2=min(list[i].p[j].y2,H);
              cin>>list[i].p[j].name;

           }
       }

       int head=0,tail=0;
       int now=0;
       int point=0;
       int x,y;
       a[head]=0;
       scanf("%d",&m);
       char str[50];
       while(m--)
       {

           scanf("%s",str);
           if(str[0]=='c')
           {
               scanf("%d%d",&x,&y);





               now=a[point];
               for(i=0;i<list[now].num;i++)
               {
                 if(list[now].p[i].x1<=x&&x<=list[now].p[i].x2&&list[now].p[i].y1<=y&&y<=list[now].p[i].y2)
                 break;


               }



            if(i<list[now].num)
            {
                a[++point]=mp[list[now].p[i].name];
                tail=point;

            }
           }
           else if(str[0]=='s')
           {   now=a[point];
               cout<<list[now].name<<endl;
           }
           else if(str[0]=='b')
           {
              point--;
              point=max(point,head);
           }
           else if(str[0]=='f')
           {
              point++;
              point=min(point,tail);

           }
       }



    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int64_t MAX = 1000000000;

int main()
{
  int64_t S, x1 = 0, y1 = 0, x2 = MAX, y2 = 1, x3, y3;
  cin >> S;
  if (S == MAX * MAX)
  {
    y2 = 0;
    x3 = y3 = MAX;
  }
  else
  {
    int64_t p = S / MAX, r = S % MAX;
    x3 = MAX - r, y3 = p + 1;
  }
  cout << x1 << ' ' << y1 << ' ' << x2 << ' ' << y2 << ' ' << x3 << ' ' << y3 << endl;
}

Measured memory_bytes: 3624
#include <stdio.h>
int main(){
int x;
scanf("%d",&x);
int a,b,c;
a=x/100;
b=(x-a*100)/10;
c=(x-a*100-b*10);

if(x>100*a+10*a+a) printf("%d",100*(a+1)+10*(a+1)+a+1);
else
if(x<=100*a+10*a+a)
printf("%d",100*a+10*a+a);



return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int N,W;
ll w[100],v[100];
ll dp[2][100010];

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

  cin>>N>>W;
  rep(i,N)cin>>w[i]>>v[i];

  int crt=0,nxt=1;
  rep(i,2)rep(j,100010)dp[i][j]=-INF;
  dp[crt][0]=0;
  rep(i,N){
    rep(j,100010)dp[nxt][j]=-INF;
    rep(j,W+1){
      if(dp[crt][j]==-INF)continue;
      if(j+w[i]<=W)maxch(dp[nxt][j+w[i]],dp[crt][j]+v[i]);
      maxch(dp[nxt][j],dp[crt][j]);
    }
    swap(crt,nxt);
  }
  ll res=-INF;
  rep(j,W+1)maxch(res,dp[crt][j]);
  cout<<res<<endl;

  return 0;
}


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

int main(){
 int n,a,t[4][14]={};
 cin >> n;
 char Mark;
 
 for(int i=0;i<n;i++){
  cin >> Mark >> a;
  if(Mark == 'S') t[0][a]++;
  else if (Mark == 'H') t[1][a]++;
  else if (Mark == 'C') t[2][a]++;
  else if (Mark == 'D') t[3][a]++;
 }

 for(int i=0;i<4;i++){
  for(int j=1; j<=13; j++){
   if(t[i][j] == 0){
    if(i == 0) cout << "S " << j <<endl;
    else if(i == 1) cout << "H "<< j <<endl;
    else if(i == 2) cout << "C "<< j <<endl;
    else if(i == 3) cout << "D "<< j <<endl;
   }
  }
 }
}


Measured memory_bytes: 3112
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        
        System.out.println("" + z + " " + x + " " + y);
    }
}


Measured memory_bytes: 39420
a,b,c=gets.split.map &:to_i
if a <= b && b <= c then
   puts "#{a} #{b} #{c}"
elsif a <= c && c <= b then
   puts "#{a} #{c} #{b}"
elsif b <= a && a <= c then
  puts "#{b} #{a} #{c}"
elsif b <= c && c <= a then
  puts "#{b} #{c} #{a}"
elsif c <= a && a <= b then
  puts "#{c} #{a} #{b}"
elsif c <= b && b <= a then
  puts "#{c} #{b} #{a}"
end


Measured memory_bytes: 8880
#include <bits/stdc++.h>
using namespace std;
#define M 1000010
#define fi first
#define sc second
#define pb push_back
#define LL long long
#define MP make_pair
#define MOD 998244353
#define pii pair<int, int>
#define For(i, x, y) for(int i = (x); i < (y); i ++)
#define rep(i, x, y) for(int i = (x); i <= (y); i ++)
#define drep(i, x, y) for(int i = (x); i >= (y); i --)
inline int read(){char ch=getchar();int x=0,f=1;while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while('0'<=ch&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
inline LL llread(){char ch=getchar();LL x=0,f=1;while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while('0'<=ch&&ch<='9'){x=x*10+ch-'0';ch=getchar();}return x*f;}
inline int Power(int x,int y,int mod){int r=1;while(y){if(y&1)r=1ll*r*x%mod;x=1ll*x*x%mod;y>>=1;}return r;}
int a[M],sg[M];
struct Edge{
	int u,v,Next;
} G[M*2];int head[M],tot;
vector<int> res;
inline void add(int u,int v){
	G[++tot]=(Edge){u,v,head[u]};
	head[u]=tot;
}
inline void dfs(int x,int fa){
	for(int i=head[x];i!=-1;i=G[i].Next){
		if(G[i].v==fa)continue;
		dfs(G[i].v,x);
		if(!sg[G[i].v]&&a[G[i].v]<a[x]){
			sg[x]=1;
		}
	}
}
inline void getans(int x,int fa,int fa_ans){
	//calc
	int SG=0;if(fa_ans==0&&a[fa]<a[x])SG++;
	for(int i=head[x];i!=-1;i=G[i].Next){
		if(G[i].v==fa)continue;
		if(!sg[G[i].v]&&a[G[i].v]<a[x])SG++;
	}if(SG)res.pb(x);
	//Next
	for(int i=head[x];i!=-1;i=G[i].Next){
		int now=0;if(G[i].v==fa)continue;
		if(!sg[G[i].v]&&a[G[i].v]<a[x])now=1;
		getans(G[i].v,x,(SG-now)>0);
	}
}
int main() {
	int n=read();
	rep(i,1,n)a[i]=read();
	memset(head,-1,sizeof(head));
	rep(i,1,n-1){
		int x=read(),y=read();
		add(x,y);add(y,x);
	}dfs(1,0);getans(1,0,-1);
	//puts("FUCK");
	sort(res.begin(),res.end());
	For(i,0,res.size()){
		printf("%d ",res[i]);
	}
	return 0;
}


Measured memory_bytes: 8576
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s;
    int N,a,size,oddcount=0,evencount=0;
    string ans;


    cin>>N;

    for(int i=0;i<N;i++){
        cin>>a;
        if(a%2==1)oddcount++;
        if(a%2==0)evencount=1;
    }

    if(oddcount%2==0||evencount==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;        
    }



}

Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int n;
    
    scanf("%d", &n);
    
    for (int i=n; i<INT_MAX; i++) {
        if (i%2==0&&i%n==0) {
            printf("%d", i);
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 1676
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;

int main() {
	vs c(2);
  	rep(i, 2) cin >> c[i];
    if(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

int main(){
  int n,m,l,i,j,k;
  long temp=0;
  cin>>n>>m>>l;
  int a[n][m],b[m][l];
  for (i=0;i<n;i++){
    for (j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  for (i=0;i<m;i++){
    for (j=0;j<l;j++){
      cin>>b[i][j];
    }
  }
  /*入力終わり*/
  for (i=0;i<n;i++){
    for (j=0;j<l;j++){
      for (k=0;k<m;k++)temp+=a[i][k]*b[k][j];
      if (j)cout<<' ';
      cout<<temp;
      temp=0;
    }
    cout<<endl;
  }
}



Measured memory_bytes: 3096
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n],i;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    int dp[n]={0};
    dp[1]=abs(a[1]-a[0]);
    if(n>2)
    {
        dp[2]=min(abs(a[2]-a[0]),dp[1]+abs(a[2]-a[1]));
    }
    for(i=3;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1]<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

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

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

Measured memory_bytes: 256
#include<stdio.h>
 
int main()
{
  int m, f, b;
 
  scanf( "%d %d %d", &m, &f, &b );
 
  if( m >= b ) printf( "0\n" );
  else if( m + f < b ) printf( "NA\n" );
  else printf( "%d\n", b - m );
 
  return 0;
 
}

Measured memory_bytes: 1812
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>











int a,b,c;



void solve()
{
	cin>>a>>b>>c;
	if(a==b)cout<<c<<"\n";
	else if(a==c)cout<<b<<"\n";
	else cout<<a<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100000
int partition(int*, int ,int);
int A[N];
int main(){

  int i,num,mid;

  scanf("%d",&num);
  for(i=0;i<num;i++){

    scanf("%d",&A[i]);
  }


   mid = partition(A,0,num-1);
  for(i=0;i<num-1;i++){

    if(i==mid){
      printf("[%d] ",A[i]);
    }
      else  printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  return 0;
  }

int partition(int *A, int p, int r){

  int x,tmp,tmp2,j,i;

  x=A[r];
  i=p-1;

  for(j=p; j<=r-1;j++){


    if(A[j]<=x){

      i=i+1;
      tmp=A[i];
      A[i]=A[j];
      A[j]=tmp;
    }
  }
    tmp2 = A[i+1];
    A[i+1]=A[r];
    A[r]=tmp2;


  return i+1;
}

Measured memory_bytes: 988
squares = set({})
for i in range(1,130):
    squares.add(i**2)

N,D=map(int,input().split())
n = 0
X = []
for _ in range(N):
    X.append(list(map(int,input().split())))

ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        sum = 0
        for k in range(D):
            sum += (X[i][k]-X[j][k])**2
        if sum in squares:
            ans += 1

print(ans)

Measured memory_bytes: 62200
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 2000;
int N;
char c[2*MAX_N+1];
int a[2*MAX_N+1];
int dp[MAX_N+1][MAX_N+1];     // dp[i][j] : (b, w) = (i, j) <- 1-indexed
int costb[MAX_N+1][MAX_N+1];
int costw[MAX_N+1][MAX_N+1];
int bindex[MAX_N+1];
int windex[MAX_N+1];

int BIT[2*MAX_N+1], n;

int sum(int i) {
  int res = 0;
  while (i > 0) {
    res += BIT[i];
    i -= i & (-i);
  }
  return res;
}


void add(int i, int x) {
  while (i <= n) {
    BIT[i] += x;
    i += i & (-i);
  }
}


int main() {
  cin >> N;
  for (int i = 0; i < 2*N; ++i) cin >> c[i] >> a[i];
  n = 2*N;
  
  for (int i = 0; i < 2*N; ++i) {
    if (c[i] == 'W') windex[a[i]] = i;
    else bindex[a[i]] = i;
  }

  /*
  cout << "windex" << endl;
  for (int i = 1; i <= N; ++i) printf("%d%c", windex[i], i != N ? ' ' : '\n');
  cout << "bindex" << endl;
  for (int i = 1; i <= N; ++i) printf("%d%c", bindex[i], i != N ? ' ' : '\n');
  */

  memset(BIT, 0, sizeof(BIT));

  for (int i = 0; i <= N; ++i) {
    if (i != 0) add(2*N-bindex[i], 1);
    for (int j = 0; j < N; ++j) {
      if (j != 0) add(2*N-windex[j], 1);
      costw[i][j] = sum(2*N-windex[j+1]);
    }
    for (int j = 1; j < N; ++j) {
      add(2*N-windex[j], -1);
    }
  }

  memset(BIT, 0, sizeof(BIT));

  for (int i = 0; i < N; ++i) {
    if (i != 0) add(2*N-bindex[i], 1);
    for (int j = 0; j <= N; ++j) {
      if (j != 0) add(2*N-windex[j], 1);
      costb[i][j] = sum(2*N-bindex[i+1]);
    }
    for (int j = 1; j <= N; ++j) {
      add(2*N-windex[j], -1);
    }
  }

  /*
  cout << "costb" << endl;
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      printf("%d%c", costb[i][j], j != N ? ' ' : '\n');
    }
  }
  cout << "costw" << endl;
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j <= N; ++j) {
      printf("%d%c", costw[i][j], j != N ? ' ' : '\n');
    }
  }
  */

  for (int j = 1; j <= N; ++j) dp[0][j] = dp[0][j-1] + costw[0][j-1];
  for (int i = 1; i <= N; ++i) dp[i][0] = dp[i-1][0] + costb[i-1][0];

  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      dp[i][j] = min(dp[i-1][j]+costb[i-1][j], dp[i][j-1]+costw[i][j-1]);
    }
  }
  
  cout << dp[N][N] << endl;

  return 0;
}


Measured memory_bytes: 47232
#include <bits/stdc++.h>
#define ll long long
#define sz size
#define pb push_back
#pragma GCC optimize("O3")
#define er erase
#define in insert
#define fr first
#define sc second
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
#define rc(s) return cout<<s,0
const int mod=1e9+7;
const int inf=1e5;
using namespace std;

int n,a,b,sum,x,maxi=1e9;

int digit(int y){
    x=y;
    sum=0;
    while(x){
        sum+=x%10;
        x/=10;
    }
        return sum;

}

int main(){
    cin >> n;
    int i=1;
    while(i<n){
        int j=n-i;
        if(maxi>digit(i)+digit(j)){
            maxi=digit(i)+digit(j);
        }
        i++;
    }
    cout<<maxi;

}

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

#define fi first
#define se second
#define lch (o << 1)
#define rch (o << 1 | 1)

typedef double db;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> pint;

const int N = 200000 + 5;
const int K = 28 + 2;
const int INF = 0x3f3f3f3f;
const ll INF_LL = 0x3f3f3f3f3f3f3f3f;

int a[N], b[N];

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

	for(int i=1; i<=n; i++)
		scanf("%d", &a[i]);
	for(int i=1; i<=n; i++)
		scanf("%d", &b[i]);

	ll ans = 0;
	for(int j=0; j<K; j++){
		vector<int> s;
		ll d = 1LL << (j+1);
		for(int i=1; i<=n; i++){
			s.push_back(a[i] % d);
			s.push_back(a[i] % d + d);
		}
		sort(s.begin(), s.end());
		
		for(int i=1; i<=n; i++){
			auto r = lower_bound(s.begin(), s.end(), 2 * d - b[i] % d);
			auto l = lower_bound(s.begin(), s.end(), 3 * d / 2 - b[i] % d);
			if((r - l) & 1) ans ^= 1LL << j;
		}
	}
	
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 6036
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define mod 998244353
#define inv2 499122177

using namespace std;
typedef long long ll;
const int MAXN = 100005;
inline int readint()
{
	int res = 0, f = 1;
	char c = 0;
	while(!isdigit(c))
	{
		c = getchar();
		if(c=='-')
			f = -1;
	}
	while(isdigit(c))
		res = res*10+c-'0', c = getchar();
	return res*f;
}
inline ll qpow(ll a, int b)
{
	ll res = 1;
	for(; b; a = a*a%mod, b >>= 1)
	    if(b&1)
	        res = res*a%mod;
	return res;
}
struct Node
{
	int u,v;
	Node *next;
}pool[MAXN<<3],*h[4][MAXN];
int n,m[4],deg[4][MAXN],tot;
inline void addEdge(int id, int u, int v)
{
	Node *p = &pool[++tot];
    p->v = v, p->next = h[id][u], h[id][u] = p;
    deg[id][v]++;
}
int sg[4][MAXN];
ll f[4][270005];
vector<int> num[4][MAXN];
inline void calc(int id, int u)
{
	if(sg[id][u]>=0)
	    return;
	sg[id][u] = 0;
	for(Node *p = h[id][u]; p; p = p->next)
	{
        calc(id,p->v);
        num[id][u].push_back(sg[id][p->v]);
	}
	sort(num[id][u].begin(),num[id][u].end());
	for(int i = 0; i<num[id][u].size(); i++)
	    if(sg[id][u]==num[id][u][i])
	        sg[id][u]++;
}
inline void fwt(ll *a, int deg)
{
	ll u,t;
	for(int i = 1; i<deg; i <<= 1)
	    for(int j = 0; j<deg; j += i<<1)
	        for(int k = j; k<j+i; k++)
	        {
	            u = a[k], t = a[k+i];
	            a[k] = (u+t)%mod, a[k+i] = (u-t+mod)%mod;
			}
}
inline void ifwt(ll *a, int deg)
{
    ll u,t;
	for(int i = 1; i<deg; i <<= 1)
	    for(int j = 0; j<deg; j += i<<1)
		    for(int k = j; k<j+i; k++)
			{
	            u = a[k], t = a[k+i];
	            a[k] = (u+t)*inv2%mod, a[k+i] = (u-t+mod)*inv2%mod;
			}
}

int main()
{
    n = readint();
    for(int i = 1; i<=3; i++)
    {
        m[i] = readint();
        for(int j = 1; j<=m[i]; j++)
        {
            int u = readint(), v = readint();
            addEdge(i,min(u,v),max(u,v)); 
		}
	}
	memset(sg,-1,sizeof(sg));
	for(int i = 1; i<=3; i++)
	    for(int j = 1; j<=n; j++)
		    if(!deg[i][j])
			    calc(i,j);
	for(int i = 1; i<=3; i++)
        for(int j = 1; j<=n; j++)
			f[i][sg[i][j]] += qpow(qpow(10,18),j);
	for(int i = 1; i<=3; i++)
        fwt(f[i],262144);
    for(int i = 0; i<262144; i++)
        f[1][i] = f[1][i]*f[2][i]%mod*f[3][i]%mod;
    ifwt(f[1],262144);
    cout << f[1][0] << endl;
	return 0;
}


Measured memory_bytes: 36352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    if(n%2) {
        cout << 0 << endl;
        return 0;
    }

    ll p = 1, ret = 0;
    while((double)p*10 <= n) {
        p *= 5;
        ret += n/(p*2);
    }    
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 256
# ABC162b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    n = int(input())
    ans = 0
    for i in range(1, n + 1):
        if not (i % 3 == 0 or i % 5 == 0):
            ans += i
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
    int n, m;
    cin >> n >> m;
    
    int cars = m;
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        cars += x - y;
        if (cars < 0) {
            cout << 0 << endl;
            return 0;
        }
        if (cars > m) {
            m = cars;
        }
    }
    
    cout << m << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  while (true) {
    string in; cin >> in;
    if (in == "0") break;
    int s = 0;
    for (string::iterator itr = in.begin();
	 itr != in.end(); itr++) {
      char c = *itr;
      int c_i = c + (0 - '0');
      s += c_i;
    }
    cout << s << endl;
  }
  return 0;
}

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

bool isAccumulable(int, int, vector<int>);

int main(int argc, char const *argv[])
{
    int n = 0, k = 0;
    cin >> n >> k;

    vector<int> w(n, 0);

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

    int sumw = accumulate(w.begin(), w.end(), 0);

    int l = 0, h = 2 * sumw + 1, m = 0;

    while (h > l + 1)
    {
        m = (l + h) / 2;
        if (isAccumulable(k, m, w))
        {
            h = m;
        }
        else
        {
            l = m;
        }
    }

    cout << h << endl;

    return 0;
}

bool isAccumulable(int k, int m, vector<int> w)
{

    int now = 0, weight = 0;

    for (int i = 0; i < (int)w.size(); i++)
    {
        // コーナーケース: ある荷物がトラックの積載荷重を超える場合
        if (w[i] > m)
        {
            return false;
        }

        if (weight + w[i] > m)
        {
            now++;
            weight = w[i];
        }
        else
        {
            weight += w[i];
        }
    }

    return (now < k);
}



Measured memory_bytes: 3664
#include<cstdio>
#include<cstring>
using namespace std;
char s[1005];
int main()
{
	int n;
	scanf("%d",&n);
	scanf("%s",s);
	int flag=0;
	for(int i=0;i<strlen(s);i++)
	{
		if(i+1<=n)
		{
			printf("%c",s[i]);
		}
		else
		{
			flag=1;
			break;
		}
	}
	if(flag==1)
	{
		printf("...");
	}
	printf("\n");
	return 0;
} 

Measured memory_bytes: 1704
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
const int Maxn=100000;
int f[Maxn+5];
vector<int> t;
void Init() {
	t.clear();
	t.push_back(1);
	for(int j=6;j<=Maxn;j=j*6)
		t.push_back(j);
	for(int j=9;j<=Maxn;j=j*9)
		t.push_back(j);
}
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	Init();
	int N;
	scanf("%d",&N);
	memset(f,0x7f,sizeof f);
	int tsize=t.size();
	for(int i=0;i<tsize;i++)
		f[t[i]]=1;
	for(int j=0;j<tsize;j++)
		for(int i=t[j];i<=N;i++)
			f[i]=min(f[i],f[i-t[j]]+1);
	printf("%d\n",f[N]);
	return 0;
}

Measured memory_bytes: 640
#062_A
x,y=map(int,input().split())
def group(s):
    if s in [1,3,5,7,8,10,12]:
        return 0
    elif s in [4,6,9,11]:
        return 1
    else:
        return 2
print('Yes' if group(x)==group(y) else 'No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int N; cin >> N;
  cpp_int res = 1;
  for (int i = 0; i < N; ++i) {
    cpp_int a; cin >> a;
    res = boost::lcm(res, a);
  }
  cout << res << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256