akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void) {
	int a, b;
	char op;
	int ans;
	
	while (1) {
		scanf("%d %c %d", &a, &op, &b);
		
		if (op == '?') break;
		
		switch(op) {
			case '+': ans = a + b; break;
			case '-': ans = a - b; break;
			case '*': ans = a * b; break;
			case '/': ans = a / b; break;
		}
		
		printf("%d\n", ans);
	}
	
	return 0;
}



Measured memory_bytes: 2716
#include<iostream>
using namespace std;
int main()
{

int x;
cin>>x;
bool y=0;

for(int i=1;i<10;i++ )
{
    for(int t=1;t<10;t++)
    {
        if(i*t==x){
            y=1;
            break;}
    }
}
if(y==1)
    cout<<"Yes";
else cout<<"No";

    return 0;
}


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

ll func(ll b, ll p)
{
    ll i, ans = 1;
    for(i=1;i<=p;i++){
        ans *= b;
        ans %= mod;
    }
    return ans;
}

int main()
{
    ll n,ans;
    scanf("%lld", &n);
    ans = (((func(10,n)-(2*func(9,n))+func(8,n))%mod)+mod)%mod;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3752
(n, m) = gets.chomp.split(' ').map(&:to_i)

edge = []
n.times { |i| edge[i] = [0] * n }
m.times do |i|
  (s, d) = gets.chomp.split(' ').map(&:to_i)
  edge[s - 1][d - 1] = i + 1
  edge[d - 1][s - 1] = i + 1
end

class GraphDFS
  def initialize(n, m, edge)
    @n = n
    @m = m
    @edge = edge
    
    @visited = [false] * @n
    @passed  = [false] * @m
    @counter = 0
    @ord = [0] * @n
    @low = [0] * @n
  end
  
  def dfs(src = 0)
    @visited[src] = true
    
    @ord[src] = @counter
    @counter += 1
    @low[src] = @ord[src]
    
    @n.times do |dst|
      if @edge[src][dst] > 0 then
        if !@visited[dst] then
          @passed[@edge[src][dst] - 1] = true
          dfs(dst)
          @low[src] = [@low[src], @low[dst]].min
        elsif !@passed[@edge[src][dst] - 1] then
          @low[src] = [@low[src], @ord[dst]].min
        end
      end
    end
  end
  
  def count_bridge()
    c = 0
    @n.times do |src|
      @n.times do |dst|
        if @edge[src][dst] > 0 then
          if @ord[src] < @low[dst] then
            c += 1
          end
        end
      end
    end
    return c
  end
end

graph_dfs = GraphDFS.new(n, m, edge)
graph_dfs.dfs
puts graph_dfs.count_bridge.to_s

Measured memory_bytes: 1916
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.*;
import static java.lang.Math.abs;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int N = parseInt(st.nextToken());
        int K = parseInt(st.nextToken());
        int[] C = new int[N];
        st = new StringTokenizer(br.readLine());
        for (int i = 0; i < N; i++) {
            C[i] = parseInt(st.nextToken());
        }

        int MIN_TIME = MAX_VALUE;
        int start = 0, end = start + K - 1;
        while (end < N) {
            MIN_TIME = min(MIN_TIME, min(abs(C[start]), abs(C[end])) + C[end] - C[start]);
            start++;
            end = start + K - 1;

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


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

signed main(void){
    int n; cin>>n;
    vector <string> d (n);
    rep(i,n) {string s; cin>>s; sort(s.begin(),s.end()); d[i] = s;}
    int ans = 0;
    sort(d.begin(),d.end());
    double cnt = 1;
    rep(i,n-1){
        if(d[i] == d[i+1]) cnt++;
        else {
            //cout<<cnt<<endl;
            
            ans += (cnt -1 + 1)/2 * (cnt-1);
            //cout<<(cnt -1 + 1)/2 * (cnt-1)<<'*'<<endl;
            cnt = 1;
        }
    }
    //cout<<cnt<<endl;
    
    ans += (cnt -1 + 1)/2 * (cnt-1);
    cout<<ans<<endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
  int n;
  cin >> n;
  vector<int> height(n);
  for(int i = 0; i < n; ++i) cin >> height[i];
  vector<int> dp(n, INF);
  dp[0] = 0;
  dp[1] = abs(height[1] - height[0]);
  for(int i = 2; i < n; ++i){
   dp[i] = min(dp[i - 1] + abs(height[i] - height[i - 1]), dp[i - 2] + abs(height[i]- height[i -2]));
  }
  cout << dp[n - 1]  << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <string.h>
#include <iomanip>
#include <limits>
using namespace std;

const int MAX_N=10000;
int n;

int main(){
	cin >> n;
	
	cout << "ABC" << n << endl;
	return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.print(a / b);
        System.out.print(" " + a % b);
        System.out.printf(" %f\n", ((a * 1.0) / b));
        
        sc.close();
    }
}


Measured memory_bytes: 26424
N = int(input())
H = list(map(int, input().split()))

h = [0] + H
c = 0
for i in range(1, 100 + 1):
	for j in range(1, N + 1):
		if h[j - 1] < i and i <= h[j]:
			c += 1
print(c)


Measured memory_bytes: 2940
#include <iostream>
#include <map>
#include <set>
#include <utility>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n;
set<P> S;
map<P, llint> mp;

int main(void)
{
  cin >> n;
  llint x, y, w;
  for(int i = 1; i <= n; i++){
    cin >> x >> y >> w;
    mp[P(x, y)] = w;
    S.insert(P(x, y));
    S.insert(P(x+1, y));
    S.insert(P(x, y+1));
    S.insert(P(x-1, y));
    S.insert(P(x, y-1));

  }

  llint ans = 0;
  for(auto it = S.begin(); it != S.end(); it++){
    tie(x, y) = *it;
    llint tmp = 0;
    tmp += mp[P(x, y)];
    tmp += mp[P(x+1, y)];
    tmp += mp[P(x, y+1)];
    tmp += mp[P(x+1, y+1)];
    ans = max(ans, tmp);
  }
  cout << ans << " / " << 1 << endl;

  return 0;
}



Measured memory_bytes: 109376
class Dice():
    def __init__(self, arr):
        self.top = arr[0]
        self.front = arr[1]
        self.right = arr[2]
        self.left = arr[3]
        self.back = arr[4]
        self.bottom = arr[5]
        
    def rotate(self, direction):
        if direction == "N":
            self.back, self.top, self.front, self.bottom = \
            self.top, self.front, self.bottom, self.back
        elif direction == "S":
            self.front, self.bottom, self.back, self.top = \
            self.top, self.front, self.bottom, self.back
        elif direction == "E":
            self.right, self.bottom, self.left, self.top = \
            self.top, self.right, self.bottom, self.left
        elif direction == "W":
            self.left, self.bottom, self.right, self.top = \
            self.top, self.left, self.bottom, self.right
        elif direction == "R": # clockwise
            self.front, self.right, self.back, self.left =\
            self.right, self.back, self.left, self.front
            
    def get_faces(self):
        return [self.top, self.front, self.right, self.left,
               self.back, self.bottom]
    
n = int(input())
dice_list = []
for _ in range(n):
    dice_list.append(Dice(input().split()))
    
def is_same(dice1, dice2):
    flag = False
    
    if len(dice1.get_faces() and dice2.get_faces()) == 6:
        direction_list = ["", "S", "E", "S", "E", "S"]
        for direction in direction_list:
            dice2.rotate(direction)
            
            for i in range(4):
                if dice1.get_faces() == dice2.get_faces():
                    flag = True
                    break                  
                dice2.rotate("R")
                
            if flag:
                break
                
    return flag

flag = True

for i in range(n-1):
    for j in range(i+1, n):
        if is_same(dice_list[i], dice_list[j]):
            flag = False
            
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5608
isFound = False
li = list(map(int,input().split()))
min = int(li[0] / 0.08)
max = int((li[0] + 1) / 0.08) - 1
for i in range(min, max):
    if((int(i * 0.1) == li[1]) and (int(i * 0.08) == li[0])):
        print(i)
        isFound = True
        break
if(not(isFound)):
    print(-1)

Measured memory_bytes: 38384
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	fmt.Println(lcm(a, b))
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <queue>

using namespace std;

const int INF = 10000000;
char maze[1005][1005];
int d[1005][1005];
int w, h;

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

struct Coor {
	int x, y;
	Coor(int x, int y) : x(x), y(y) {}
};

queue<Coor> Q;

int bfs(int sx, int sy, int gx, int gy)
{
	int i, j;
	int nx, ny;
	
	while (Q.size() != 0){
		Q.pop();
	}
	
	for (i = 0; i < h; i++){
		for (j = 0; j < w; j++){
			d[i][j] = INF;
		}
	}
	
	d[sy][sx] = 0;
	
	Q.push(Coor(sx, sy));
	
	while (Q.size() != 0){
		
		Coor p = Q.front();
		Q.pop();
		
		if (p.x == gx && p.y == gy){
			break;
		}
		
		for (i = 0; i < 4; i++){
			
			nx = p.x + dx[i];
			ny = p.y + dy[i];
			
			if (nx >= 0 && ny >= 0 && nx < w && ny < h && maze[ny][nx] != 'X' && d[ny][nx] == INF){
				
				Q.push(Coor(nx, ny));
				d[ny][nx] = d[p.y][p.x] + 1;
			}
		}
	}
	return (d[gy][gx]);
}
			

int main(void)
{
	int n, ans = 0;
	int sx, sy;
	int x, y;
	int i, j;
	int gx[9], gy[9];
	
	scanf("%d %d %d", &h, &w, &n);
	
	for (i = 0; i < h; i++){
		for (j = 0; j < w; j++){
			scanf(" %c", &maze[i][j]);
			
			if (maze[i][j] == 'S'){
				sx = j;
				sy = i;
			}
			else if (maze[i][j] == '1'){
				gx[0] = j;
				gy[0] = i;
			}
			else if (maze[i][j] == '2'){
				gx[1] = j;
				gy[1] = i;
			}
			else if (maze[i][j] == '3'){
				gx[2] = j;
				gy[2] = i;
			}
			else if (maze[i][j] == '4'){
				gx[3] = j;
				gy[3] = i;
			}
			else if (maze[i][j] == '5'){
				gx[4] = j;
				gy[4] = i;
			}
			else if (maze[i][j] == '6'){
				gx[5] = j;
				gy[5] = i;
			}
			else if (maze[i][j] == '7'){
				gx[6] = j;
				gy[6] = i;
			}
			else if (maze[i][j] == '8'){
				gx[7] = j;
				gy[7] = i;
			}
			else if (maze[i][j] == '9'){
				gx[8] = j;
				gy[8] = i;
			}
		}
	}
	
	ans += bfs(sx, sy, gx[0], gy[0]);
	
	for (i = 1; i < n; i++){
		ans += bfs(gx[i - 1], gy[i -  1], gx[i], gy[i]);
	}
	
	printf("%d\n", ans);
	
	return (0);
}

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

int forLetter(char a, string s){
	int lastPos=-1;
	int maxProm = 0;
	int promL=0;
	for(int i=0;i<s.length();i++){
		if(s[i] == a){
			lastPos=i;
			if(maxProm<promL)maxProm=promL;
			promL=0;
		}else{
			promL++;
		}		
	}
	
	if(lastPos<0)return INT_MAX;
	return max(maxProm,(int)( s.length()-1-lastPos));
}


int main(){
	int min = INT_MAX;
	std::string s;
	cin >> s;
	for(char i = 'a';i<='z';i++){
		int r = forLetter(i,s);
		if(r<min)min=r;
	}
	cout<<min<<endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys

sys.setrecursionlimit(10**7)

# Override `input` function because `stdin.readline()` is 10x faster than built-in `input()`
input = sys.stdin.readline


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h(typ) if m > 1 else typ(input()) for _ in range(n)]


def main():
    n, = read_h()
    nxt = [i - 1 for i in read_v(n)]

    idx = 0
    cnt = 0
    for _ in range(n):
        cnt += 1
        idx = nxt[idx]
        if idx == 1:
            print(cnt)
            return

    print(-1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 11292
N, K, Q = gets.strip.split(" ").map(&:to_i)
corrects = Array.new(N) { 0 }

Q.times do 
  corrects[gets.to_i - 1] += 1
end

corrects.each do |c|
  puts (
    if K - (Q - c) > 0
      "Yes"
    else
      "No"
    end
  )
end


Measured memory_bytes: 15172
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  [n, m] <- getInts
  xs <- replicateM n getInts
  print $ solve xs n m

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve xs n m = maximum
               $ map (abs . sum . take m . sort)
               $ map (\f -> map f xs) fs

fs = map (\[o1, o2, o3] -> (\[a, b, c] -> 0 `o1` a `o2` b `o3` c)) $ replicateM 3 [(+), (-)]


Measured memory_bytes: 3196
# abc156_b.py
# https://atcoder.jp/contests/abc156/tasks/abc156_b

# B - Digits /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 整数 Nを K進数で表したとき、何桁になるかを求めてください。

# 注記
# K進表記については、Wikipedia「位取り記数法」を参照してください。

# 制約
#     入力は全て整数である。
#     1≤N≤109
#     2≤K≤10

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N K

# 出力
# 整数 Nを K進数で表したとき、何桁になるかを出力せよ。

# 入力例 1
# 11 2

# 出力例 1
# 4

# 11を 2進数で表記すると 1011 です。

# 入力例 2
# 1010101 10

# 出力例 2
# 7

# 入力例 3
# 314159265 3

# 出力例 3
# 18


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    N, K = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if K**0 <= N < K**1:
        result = 1
    elif K**1 <= N < K**2:
        result = 2
    elif K**2 <= N < K**3:
        result = 3

    result = 1
    n = N
    while True:
        if n < K:
            return [result]
        else:
            n = n / K
            result += 1


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['11 2']
        lines_export = [4]
    if pattern == 2:
        lines_input = ['1010101 10']
        lines_export = [7]
    if pattern == 3:
        lines_input = ['1314159265 3']
        lines_export = [18]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9252
#include<stdio.h>
int n,m;
int t[200001];
  
int u[200001];
  
int main(){
  int i;
    
  scanf("%d %d",&n,&m);
    
  for(i=0;i<m;i++){
    scanf("%d",&t[i]);
  }
    
  for(i=m-1;i>=0;i--){
    int num=t[i];
    if( u[num] == 0 ){
      printf("%d\n",num);
      u[num]=1;
    }
  }
  
  for(i=1;i<=n;i++){
    if(u[i]==0){
      printf("%d\n",i);
      u[i]=1;
    }
  }
  return 0;
}

Measured memory_bytes: 1768
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
// #define ll long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define eb emplace_back
#define pii pair<int, int>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
#define smax(a,b) a=max(a,b)
// #if !defined(ONLINE_JUDGE)
// #include "debugging.h"
// #endif
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
// erase,insert same as normal set

// int const mod = 7340033;
// int const mod = 998244353;
long long const mod = 1e9+7;
int power(int a,int b,int m){
    int res = 1;
    while(b){
        if(b&1){
            // res = res*a;
            res = (res*a)%m;
        }
        a=(a*a)%m;
        // a%=m;
        b=b/2;
    }
    return res;
}

int inverse(int x , int m){
    return power(x,m-2,m);
}

int const N = 1e6+5;
int const inf = 2e9;

int p[N], cnt[N];

void precompute(){
    p[1] = 1;
    for(int i=2;i<N;i++){
        if(p[i] == 0){
            for(int j=i;j<N;j+=i){
                if(p[j] == 0) p[j] = i;
            }
        }
    }    
}

void solve(){  
    int i,j;
    int n; cin >> n;
    vector<int> a(n);
    int g = 0;
    for(auto &x:a){
        cin >> x;
    }
    g = a[0];
    for(i=1;i<n;i++) {
        g = __gcd(g , a[i]);
    }
    
    // cout<<g<<endl;
    if(g > 1){
        cout << "not coprime" << endl; return;
    }
    int is = 0;
    for(auto x:a){
        int y = x;
        while(y > 1){
            int pp = p[y];
            cnt[pp]++;
            if(cnt[pp] > 1) is = 1;
            while(y%pp == 0){
                y = y/pp;
            }
        }
    }
    cout << (is ? "setwise coprime" : "pairwise coprime") << endl;
}              

int32_t main(){
    IOS;
    int t;
    t = 1;
    precompute();
    // cin>>t;  
    for(int tt=1;tt<=t;tt++){
        // cout << "Case #"<<tt<<": ";
        solve();
    }
    return 0;
}


/*  

*/

Measured memory_bytes: 26640
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

/*
 * AtCoder Beginner Contest 081 C "Not so Diverse"
 */
public class Main {

	public static void main(String[] args) {

		InputScanner in = new InputScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int N = in.nextInt();
		int K = in.nextInt();
		int[] Ai = in.nextIntArray(N);

		int type = 0;
		int maxNum = 200000;
		int[] count = new int[maxNum];
		Arrays.fill(count, 0);
		for (int A : Ai) {
			if (count[A] == 0) {
				type++;
			}
			count[A]++;
		}

		int ans = N;
		Arrays.sort(count);
		for (int i = maxNum - K; i < maxNum; i++) {

			if (count[i] == 0) {
				ans = 0;
				break;
			} else {
				ans -= count[i];
			}

		}

		out.println(ans);

		in.close();
		out.close();
	}

	/*
	 * extends java.util.Scanner
	 */
	static class InputScanner {

		Scanner scanner;

		public InputScanner(InputStream inputStream) {
			this.scanner = new Scanner(inputStream);
		}

		public int nextInt() {
			return scanner.nextInt();
		}

		public long nextLong() {
			return scanner.nextLong();
		}

		public double nextDouble() {
			return scanner.nextDouble();
		}
		public String next() {
			return scanner.next();
		}

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

		public int[][] nextIntArray(int h, int w) {
			int[][] ret = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextInt();
				}
			}
			return ret;
		}

		public long[] nextLongArray(int n) {
			long[] ret = new long[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextLong();
			}
			return ret;
		}

		public long[][] nextlongArray(int h, int w) {
			long[][] ret = new long[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public double[] nextDoubleArray(int n) {
			double[] ret = new double[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.nextDouble();
			}
			return ret;
		}

		public double[][] nextDoubleArray(int h, int w) {
			double[][] ret = new double[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.nextLong();
				}
			}
			return ret;
		}

		public String[] nextStringArray(int n) {
			String[] ret = new String[n];
			for (int i = 0; i < n; i++) {
				ret[i] = scanner.next();
			}
			return ret;
		}

		public String[] nextStringArray(int n, String split) {
			String[] ret = scanner.next().split(split);
			return ret;
		}

		public String[][] nextStringArray(int h, int w) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					ret[i][j] = scanner.next();
				}
			}
			return ret;
		}

		public String[][] nextStringArray(int h, int w, String split) {
			String[][] ret = new String[h][w];
			for (int i = 0; i < h; i++) {
				ret[i] = scanner.next().split(split);
			}
			return ret;
		}

		public void close() {
			scanner.close();
		}

	}

}


Measured memory_bytes: 64020
N, = map(int, raw_input().split())
a = map(int, raw_input().split())
x = a[0]
y = sum(a) - a[0]
r = abs(x-y)
for ai in a[1:N-1]:
  x += ai
  y -= ai
  r = min(r, abs(x-y))
print r

Measured memory_bytes: 18416
#include <stdio.h>
#include <string.h>
 
int main(void)
{
    int n, i, j, len, s, c;
    char f[90], f2[90], t[90], t2[90], ans[90];
     
    scanf("%d", &n);
     
    for (i = 0; i < n; i++){
         
        for (j = 0; j < 90; j++){
            t[j] = '0';
            t2[j] = '0';
        }
         
        scanf("%81s", f);
        scanf("%81s", f2);
         
        if (strlen(f) > 80 || strlen(f2) > 80){
            printf("overflow\n");
            continue;
        }
         
        if (strlen(f) > strlen(f2))len = strlen(f);
         
        else len =  strlen(f2);
         
        for (j = 0; j < strlen(f); j++){
            t[j] = f[strlen(f) -1 - j];
        }
         
        for (j = 0; j < strlen(f2); j++){
            t2[j] = f2[strlen(f2) -1 - j];
        }
         
         
        for (j = 0; j < len; j++){
            t[j] += t2[j] - '0';
             
            if (t[j] > '9'){
                t[j] -= 10;
                t[j + 1]++;
            }
        }
         
        if (t[len] != '0')t[len + 1] = '\0';
         
		 
        else t[len] = '\0';
         
        for(j = 0; j < strlen(t); j++){
            ans[j] = t[strlen(t) - 1 - j];
        }
        ans[strlen(t)] = '\0';
         
        if (strlen(ans) > 80){
            printf("overflow\n");
            continue;
        }
         
        printf("%s\n", ans);
    }
    return (0);
     
}

Measured memory_bytes: 584
n,m=map(int,input().split())
path=[[0]*n for i in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    path[a-1][b-1]=1
    path[b-1][a-1]=1#隣接グラフを作成
visited=[0]*n#どこを通ったか記憶
visited[0]=1#１は最初に通る
def dfs(position,visited,n):#深さ優先探索
    all_visited=1
    for i in range(n):
        if visited[i]==0:
            all_visited=0#行ったことがない点があれば０
            break#どこかで見つかったらループ終了
    if all_visited==1:
        return 1#全部回れたら１回カウント
    count=0#経路の個数をカウント
    for next in range(n):#次に移動する点
        if path[position][next]==0:
            continue#道がなければ次へ
        if visited[next]==1:
            continue#行ったことがあれば次へ
        visited[next]=1
        count+=dfs(next,visited,n)
        visited[next]=0#行った記録を消去して前のループに戻る
    visited[position]=0

    return count
print(dfs(0,visited,n))


Measured memory_bytes: 3064
import Data.List
import Data.Array
import Data.Maybe
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
 
getInts :: IO [Int]
getInts = (map parseInt . BS8.words) <$> BS.getLine 
    where parseInt = fst . fromJust . BS8.readInt
 
solve :: Int -> [Int] -> Int
solve k = sum . drop k . sortBy (flip compare) . change . sortBy compare
 
change :: [Int] -> [Int]
change [] = []
change (x:xs) = go x 1 xs
    where go n c [] = [c]
          go n c (x:xs)
            | n == x = go n (c+1) xs
            | otherwise = c : go x 1 xs 
 
main :: IO ()
main = do
    [n, k] <- getInts
    ls <- getInts
    print (solve k ls)

Measured memory_bytes: 31100
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] a = new int[N];
    int[] b = new int[N];
    int[] c = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = scanner.nextInt();
      b[i] = scanner.nextInt();
      c[i] = scanner.nextInt();
    }

    int dp[][] = new int[N][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i = 1; i < N; i++) {
      dp[i][0] = Math.max(dp[i - 1][1], dp[i - 1][2]) + a[i];
      dp[i][1] = Math.max(dp[i - 1][0], dp[i - 1][2]) + b[i];
      dp[i][2] = Math.max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }

    int max = dp[N - 1][0];
    max = Math.max(max, dp[N - 1][1]);
    max = Math.max(max, dp[N - 1][2]);
    System.out.println(max);
  }
}


Measured memory_bytes: 95180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
long long a[100010][3];
long long dp[100010][3];

int main()
{
    int N; cin >> N;
    rep(i, N)
    {
        rep(j, 3) cin >> a[i][j];
    }
    //long long dp[100010][3];

    rep(i, N)
    {
        rep(j, 3)
        {
            rep(k, 3)
            {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    long long ans = 0;
    rep(j, 3) chmax(ans, dp[N][j]);
    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	const ll mod = 1e9 + 7;

	ll N;
	std::cin >> N;

	ll ans = 1;
	vll c(N+1, 0);
	c[0] = 3;
	rep(i, 0, N) {
		ll A;
		std::cin >> A;
		ans *= c[A];
		ans %= mod;
		c[A]--;
		c[A + 1]++;
	}

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


Measured memory_bytes: 4040
#include<cmath>
#include<cstdio>
#define N 3003
using namespace std;
int a[N],i,j,m,n;double b,c,d,e,s,t,x,y;const double p=acos(-1);
int main()
{
	for(scanf("%d%d",&n,&m),i=1;i<=n;i++)scanf("%d",a+i);
	for(i=1;i<=n;i++)for(j=i+1,s=t=0;j<=n;j++)b=cos(p*(a[i]+a[j])/m+p),c=sin(p*(a[i]+a[j])/m+p),d=cos(2*p*a[i]/m)-b,e=sin(2*p*a[i]/m)-c,x+=(j-i-1)*b+d*s-e*t,y+=(j-i-1)*c+d*t+e*s,s+=cos(p*(a[j]-a[i])/m),t+=sin(p*(a[j]-a[i])/m);
	return 0*printf("%.15lf %.15lf\n",6*x/(n*(n-1ll)*(n-2)),6*y/(n*(n-1ll)*(n-2)));
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,g;
    cin>>a>>b>>c>>d>>e;
    if(b%d==0)  f=b/d;
    if(b%d!=0)  f=b/d+1;
    if(c%e==0)  g=c/e;
    if(c%e!=0)  g=c/e+1;
    if(f<=g)    cout<<a-g;
    if(f>g) cout<<a-f;
    cout<<endl;
}



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

int main() {
  int H,W;
  cin >> H >> W;
  char array[60][60] = {{0}};
  for(int i=0;i<H;i++) {
    cin >> array[i];
    //cout << array[i] << endl;
  }
  for(int i=0;i<H;i++) {
    for(int j=0;j<W;j++) {
      if(array[i][j] == '.') {
	int sum=0;
	for(int l=-1;l<=1;l++) {
	  for(int m=-1;m<=1;m++) {
	    //if(l==m || i+l<0 || j+m<0) continue;
	    /*else*/ if(array[i+l][j+m] == '#') sum++;
	  }
	}
	//cout << sum << endl;
	array[i][j] = sum + '0';
      }
    }
    cout << array[i] << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
    int x,a,b;
    while(cin>>x>>a>>b){
       if(b<=a)
         cout<<"delicious"<<endl;
       else if(b>a&&b<=x+a)
         cout<<"safe"<<endl;
       else if(b>x+a)
         cout<<"dangerous"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	string s;
	cin >> s;
	s += '?';
	n = s.size();
	int last[256] = {0};
	int maxd[256] = {0};
	int ans = 0;	
	for(int i=0; i<n; ++i)
	{
		for(int j=0; j<256; ++j)
			maxd[j] = max(maxd[j], i+1 - last[j]);
		last[s[i]] = i+1;
	}

	
	ans = 999999;
	for(int j='a'; j<='z'; ++j)
		ans = min(ans, maxd[j]-1);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
int main() {
  int n, i, x, y, z, ans;
  cin >> n;
  for(i=1;i<=n;i++){
    ans=0;
    for(x=1;x<=floor(sqrt(i));x++)
      for(y=1;y<=floor(sqrt(i-x*x));y++){
	if(x*x-y*y-x*y>i)
	  break;
	for(z=1;z<=floor(sqrt(abs(i-x*x-y*y-x*y)));z++){
	  if(x*x + y*y + z*z + x*y + y*z + z*x > i)
	    break;
	  if(x*x + y*y + z*z + x*y + y*z + z*x == i)
	    ans++;
	}
      }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cassert>
#include <complex>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <sstream>
#include <ctime>
#include <cctype>
#include <set>
#include <map>
#include <queue>
#include <bitset>
#include <deque>
#include <stack>
#include <memory.h>
using namespace std;
typedef long long ll;
#define mp make_pair
int n;
int a[100005];
int main(){
	cin>>n;
	if(n%2==1){
		cout<<0;
		return 0;
	}
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	cout<<max(0,a[n/2]-a[n/2-1]);
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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 (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N;
    cin >> N;

    vi a(N+1,0);
    REP(i,N) {
        assert(i+1 >=1 and i+1 <= N);
        cin >> a[i+1];
    }

    int itr = N;
    vi b(N+1,0);

    for (int i = N; i>=1; i--) {
        int acm = 0;
        for (int j=i+i; j < N+1; j += i) {
            assert(j >=1 and j <= N);
            acm += b[j];
        }

        assert(i >=1 and i <= N);
        if (a[i] != acm%2) b[i] = 1;
    }
    
    cout << accumulate(ALL(b),0) << endl;

    //for (int i : b) cout << i << endl;

    REP(i,N){
        assert(i+1 >= 1 );
        assert(i+1 <= N);
        if (b[i+1] == 1) {
            cout << i+1;
            if (i+1 != N) cout << " ";
        } 
    } 

    return 0;
}


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

int main() {
	int A, c=0, i;
	cin >> A;
	for (i = A - 1; i > 0; i--) {
		if (A % i == 0)
			c++;
	}
	if (c == 1 && A != 2)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    
    int nMinusK = n - k;
    
    if (n <= k) {
      System.out.println(n * x);
    } else {
      System.out.println(k * x + nMinusK * y);
    }
  }
}

Measured memory_bytes: 21716
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    bool flag = true, zero = false;
    ll a[n], ans = 1, maxi = 1e18;
    for(int i = 0; i < n; i++) {
    	cin>>a[i];
    	if(ans != 0 && a[i] > maxi / ans) {
    		flag = false;
    	}
    	if(a[i] == 0) {
    		zero = true;
    	}
    	ans = ans * a[i];
    }
    if(flag && !zero) {
    	cout<<ans<<"\n";
    } else if(zero) {
    	cout<<"0\n";
    } else {
    	cout<<"-1\n";
    }
}

Measured memory_bytes: 4444
s=int(input())
a=[s]

cnt=0
for i in range(10**6):
  if s%2==0:
    s=s/2
    cnt+=1
    if s in a:
      break
    a.append(s)
    
  else:
    s=3*s+1
    cnt+=1 
    if s in a:
      break    
    a.append(s)

print(cnt+1)

Measured memory_bytes: 9180
A, B, K = map(int, input().split())
if K <= (B - A) // 2:
    for i in range(A, A + K):
        print(i)
    for i in range(B - K + 1, B + 1):
        print(i)
else:
    for i in range(A, B + 1):
        print(i)

Measured memory_bytes: 3064
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll a[100017];
ll b[100017];
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll res = 1;  
    x = x % p;   
    if (x == 0) return 0;  
    while (y > 0){  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
void solve(){
	ll n,m,i,x,y;
	cin>>n>>m;
	for(i=0;i<n;i++){
		a[i]=1;
		b[i]=0;
	}
	b[0]=1;
	for(i=0;i<m;i++){
		cin>>x>>y;
//		cout<<x<<" "<<y<<endl;
		if(b[x-1]==1)
			b[y-1]=1;
		a[x-1]--;
		a[y-1]++;
		if(a[x-1]==0)
			b[x-1]=0;
	}
//	for(i=0;i<n;i++)
//		cout<<a[i]<<" "<<b[i]<<"\n";
	cout<<sum(b,n,0);
	return;
}
int main(){
//	ios::sync_with_stdio(false);
//  cin.tie(NULL);
//	#ifndef ONLINE_JUDGE
//		freopen("input.txt","r",stdin);
//		freopen("output.txt","w",stdout);
//	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

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

int main() {
    string S;
    vector<int> C(26, 0);
    while (getline(cin, S)) {
        for (int i=0; i<S.size(); i++)
            if ((S.at(i)-'a'>=0)&&(S.at(i)-'a'<=25))
                C.at(S.at(i)-'a')++;
            else if ((S.at(i)-'A'>=0)&&(S.at(i)-'A'<=25))
                C.at(S.at(i)-'A')++;
    }
    for (int i=0; i<26; i++)
        cout <<(char)('a'+i) <<" : " <<C.at(i) <<endl;
    return 0;
}


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

int main(){
  int m, l, ans;
  string s, t, u;
  vector<string> V;
  vector< vector<string> > H(2);
  cin >> m;
  for (int i = 0; i < m; ++i){
    cin >> s;
    V.push_back(s);
    l = s.length();
    ans = 1;
    for (int j = 1; j < l; ++j) {
      t = "";
      u = "";
      for (int k = 0; k < j; ++k){
	t += s[k];
	u += s[j-1-k];
      }
      H[0].push_back(t);
      H[0].push_back(u);
      t = "";
      u = "";
      for (int k = 0; k+j < l; ++k) {
	t += s[j+k];
	u += s[l-1-k];
      }
      H[1].push_back(t);
      H[1].push_back(u);
      for (int a = 0; a < 2; ++a) {
	for (int b = 0; b < 2; ++b) {
	  for (int c = 0; c < 2; ++c) {
	    V.push_back(H[a][b]+H[(a+1)%2][c]);
	  }
	}
      }
      H[0].erase(H[0].begin(), H[0].end());
      H[1].erase(H[1].begin(), H[1].end());
    }
    ans = 1;
    sort(V.begin(), V.end());
    for (int j = 1; j < V.size(); ++j) {
      if (V[j] != V[j-1]) ++ans;
    }
    cout << ans << endl;
    V.erase(V.begin(), V.end());
  }
  return 0;
}

Measured memory_bytes: 3232
using System;
using System.Linq;

namespace ConsoleApp5
{
    class Program
    {
        static void Main()
        {
            var a = Console.ReadLine();
            int result = a.Sum(c => c - '0');

            if (result % 9 == 0 || result == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 26804
def solve(N, As):
    m = 1
    for a in As:
        m *= a
    k = 0
    for a in As:
        k += m / a
    return m / k

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


Measured memory_bytes: 2940
N=int(input())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
Z=list(map(int,input().split()))

X.pop(0)
Y.pop(0)
Z.pop(0)

result=[i for i in Z if i not in X or i in Y]
print(len(result))


Measured memory_bytes: 5604
#include<stdio.h>

int bubblesort(int a[],int n){
  int flag=1;
  int esc;
  int j;
  int count=0;
  while(flag){
    flag = 0;
    for(j=n-1;j>=1;j--){
      if(a[j]<a[j-1]){
	esc = a[j];
	a[j] = a[j-1];
	a[j-1] = esc;
	flag = 1;
	count++;
      }
    }
  }
  return count;
}


int main(void){
  int n,i;
  int a[100]={};
  int count;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  count = bubblesort(a,n);
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}

Measured memory_bytes: 1808
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k,t[100000];
  cin>>n>>k;
  priority_queue<int> q;
  for(int i=0;i<n;i++){
    cin>>t[i];
    if(i)q.push(t[i]-t[i-1]-1);
  }
  int ans=t[n-1]-t[0]+1;
  while(--k)ans-=q.top(),q.pop();
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3888
#include <iostream>
#include <vector>
using namespace std;
 
vector<int> *adj;
bool vis[200007] = {};
int n;
 
bool dfs(int v, int depth){
  if(depth == 2) return (v == n-1);
  if(vis[v]) return false;
  vis[v] = 1;
  bool r = false;
  for(auto& u : adj[v]){
    r |= dfs(u, depth+1);
  }
  return r;
}
 
int main(){
  int e, a, b;
  cin >> n >> e;
  adj = new vector<int>[n];
  while(e--){
    cin >> a >> b;
    a--; b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }
  cout << (dfs(0, 0) ? "POSSIBLE" : "IMPOSSIBLE") << '\n';
}

Measured memory_bytes: 12144
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long int lli;

int main() {
    int N, K;
    vector<int> x;
    cin >> N;
    cin >> K;
    for (int i = 0; i < N; i++) {
        int temp;
        cin >> temp;
        x.push_back(temp);
    }
    int sum = 0;
    for (int i = 0; i < N; i++) {
        int sub = K - x[i];
        if (sub > x[i]) {
            sum += 2 * x[i];
        } else {
            sum += 2 * sub;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3608
//テストケースの5のWAが解決できなかったので、解説AC
//参考 https://qiita.com/hkrutknouch/items/910c371e2828787e4292

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s,t; cin >> s >> t;
    vector<string> ans;
    int l = s.size()-t.size()+1;
    for(int i = 0; i < max(0, l); i ++) {
        string tmp = s;
        for(int j = 0; j < t.length(); j ++) {
            if(i+j>s.size()-1) break;
            if(tmp[i+j]=='?' || tmp[i+j]==t[j]) tmp[i+j] = t[j];
            else break;
            if(j==t.length()-1) {
                for(int k = 0; k < tmp.length(); k ++) {
                    if(tmp[k]=='?') tmp[k] = 'a';
                }
                ans.push_back(tmp);
            }
        }
    }
    sort(ans.begin(), ans.end());
    cout << (ans.size() > 0 ? ans[0] : "UNRESTORABLE") << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> llVEC;
typedef vector<P> PVEC;
typedef priority_queue<P,PVEC,greater<P> > PPQ;
typedef priority_queue<ll, llVEC, greater<ll> > llPQ;

#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n-1; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue;
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

template<typename T>
ll sz(vector<T> &vec){ return (ll)vec.size(); }
ll sz(string &s){ return (ll)s.size(); }
ll gcd(ll a,ll b){ return ((!b) ?a :gcd(b, a%b)); }
ll lcm(ll a,ll b){ return a / gcd(a,b) * b; }

int main(){
    string s;
    cin >> s;
    if(s[0] != s[sz(s)-1]){
        cout << ((sz(s)%2)?"First":"Second") << endl;
    }
    else{
        cout << ((sz(s)%2)?"Second":"First") << endl;
    }
    return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k,a,b,flag=0;
  cin>>k>>a>>b;
  for(int i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      cout<<"OK";
      flag=1;
      break;
    }
  }
  if(flag==0)
    cout<<"NG";
}


Measured memory_bytes: 3596
// #include <bits/stdc++.h>  // This will work only for g++ compiler.
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

// #define tree_set tree<int, null_type,greater<int>, rb_tree_tag,tree_order_statistics_node_update>
// #define for0(i, n) for (int i = 0; i < (int)(n); ++i) // 0 based indexing
// #define for1(i, n) for (int i = 1; i <= (int)(n); ++i) // 1 based indexing
// #define forc(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i) // closed interver from l to r r inclusive
// #define forr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i) // reverse 0 based.
// #define forr1(i, n) for (int i = (int)(n); i >= 1; --i) // reverse 1 based
// #define FASTIO ios::sync_with_stdio(false); cin.tie(0); //for faster IO

// //short hand for usual tokens
// #define pb push_back
// #define fi first
// #define se second


// // to be used with algorithms that processes a container Eg: find(all(c),42)
// #define all(x) (x).begin(), (x).end() //Forward traversal
// #define rall(x) (x).rbegin(), (x).rend() //reverse traversal


// // traversal function to avoid long template definition. Now with C++11 auto alleviates the pain.
// #define tr(c,i) for(__typeof__((c)).begin() i = (c).begin(); i != (c).end(); i++)


// // find if a given value is present in a container. Container version. Runs in log(n) for set and map
// #define present(c,x) ((c).find(x) != (c).end())


// //find version works for all containers. This is present in std namespace
// #define cpresent(c,x) (find(all(c),x) != (c).end())


// // Avoiding wrap around of size()-1 where size is a unsigned int.
// #define size(a) int((a).size())


// using namespace std;
// using namespace __gnu_pbds;

// // Shorthand for commonly used types
// typedef vector<int> vi;
// typedef vector<vi> vvi;
// typedef pair<int, int> ii;
// typedef vector<ii> vii;
// typedef long long ll;
// typedef vector<ll> vll;
// typedef vector<vll> vvll;
// typedef double ld;


// const ll INF = 1e18+7;


// void solve(){
//     int n,h;
//     cin>>n>>h;
//     vi arr(n);
//     for0(i,n)cin>>arr[i];
//     int curr=0;
//     bool box=false;
//     while(1){
//         int temp;
//         cin>>temp;
//         if(!temp)break;
//         switch(temp){
//             case 1:
//                 if(curr)curr--;
//                 break;
//             case 2:
//                 if(curr!=size(arr)-1)curr++;
//                 break;
//             case 3:
//                 if(!box&&arr[curr]){arr[curr]--;box=true;}
//                 break;
//             case 4:
//                 if(box&&arr[curr]!=h){arr[curr]++;box=false;}
//                 break;
//         }
//     } 
//     for0(_,size(arr))cout<<arr[_]<<" ";
//     cout<<"\n";
// }


// int main() {
//     FASTIO
//     cout.precision(10);
//     cout << fixed;
//     solve();
//     return 0;
// }

// //2 1 3 1 4 0 1
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll n1=max(a*c,a*d);
    ll n2=max(b*c,b*d);
    cout<<max(n1,n2)<<"\n";
    return 0;
}

Measured memory_bytes: 3636
#include<cstdio>

double a,b,c,d,e,f;
double x,y;

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

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define INF 0x3F3F3F3F3F3F3F3Fll
#define maxn 
using namespace std;

int len[60], N;
long long c[60], dp[2][60][30];
char S[2][60][30];

bool isPalindrome(char *s, char *t) {
    for(; s < t; ++s, --t) if(*s != *t) return false;
    return true;
}

long long dfs(const int &n, const int &l, const bool &f) {
    long long &ret = dp[f][n][l];
    if(ret != -1) return ret;
    const int &r = len[n] - 1;
    if(isPalindrome(S[f][n] + l, S[f][n] + r)) return ret = 0;
    ret = INF;
    for(int i = 1; i <= N; ++i) {
        if(r - l + 1 <= len[i]) {
            bool valid = true;
            for(int j = 0; j <= r - l; ++j) {
                if(S[f][n][j + l] != S[!f][i][j]) {
                    valid = false;
                    break;
                }
            }
            if(valid) ret = min(ret, c[i] + dfs(i, r - l + 1, !f));
        } else {
            bool valid = true;
            for(int j = 0; j < len[i]; ++j) {
                if(S[f][n][j + l] != S[!f][i][j]) {
                    valid = false;
                    break;
                }
            }
            if(valid) ret = min(ret, c[i] + dfs(n, l + len[i], f));
        }
    }
    return ret;
}

int main() {
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) {
        scanf("%s%lld", S[0][i], c + i);
        len[i] = strlen(S[0][i]);
        strcpy(S[1][i], S[0][i]);
        reverse(S[1][i], S[1][i] + len[i]);
    }
    long long Ans = INF;
    memset(dp, 0xFF, sizeof dp);
    for(int i = 1; i <= N; ++i) Ans = min(Ans, c[i] + dfs(i, 0, false));
    printf("%lld\n", Ans == INF ? -1 : Ans);
    return 0;
}



Measured memory_bytes: 3804