akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let H: usize = sc.get();
    let W: usize = sc.get();
    let mut a: Vec<Vec<usize>> = sc.mat(H, W);
    let mut ans = Vec::new();
    for i in 0..H {
        for j in 0..W {
            if a[i][j] % 2 == 0 {
                continue;
            }
            if j != W-1 {
                a[i][j] -= 1;
                a[i][j+1] += 1;
                ans.push((i+1, j+1, i+1, j+2));
            } else if i != H-1 {
                a[i][j] -= 1;
                a[i+1][j] += 1;
                ans.push((i+1, j+1, i+2, j+1));
            }
        }
    }
    println!("{}", ans.len());
    for (y1, x1, y2, x2) in ans {
        println!("{} {} {} {}", y1, x1, y2, x2);
    }
}


Measured memory_bytes: 13304
#include <stdio.h>

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


Measured memory_bytes: 2056
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
N = int(input())

B = [[0]*3 for _ in range(3)]
for _ in range(N):
    b = int(input())
    for j in range(3):
        for i in range(3):
            if A[j][i]==b:
                B[j][i]=1

if (B[0][0]+B[0][1]+B[0][2]==3) or (B[1][0]+B[1][1]+B[1][2]==3) or (B[2][0]+B[2][1]+B[2][2]==3) or (B[0][0]+B[1][0]+B[2][0]==3) or (B[0][1]+B[1][1]+B[2][1]==3) or (B[0][2]+B[1][2]+B[2][2]==3) or (B[0][0]+B[1][1]+B[2][2]==3) or (B[2][0]+B[1][1]+B[0][2]==3):
    print('Yes')
else:
    print('No')
            

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

using namespace std;

int n;
int k;
int valor[100005];
long long  dp[100000];


long long pd(int i){
if (i==n){return 0;}
if (dp[i] !=-1){return dp[i];}

long long nao_pula=1e15;
for (int j=i+1;j-i<=k and j<=n;j++){
    nao_pula=min(nao_pula,pd(j)+abs(valor[i]-valor[j]));
}

return dp[i]=nao_pula;
}

int main (){
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

cin>>n;
cin>>k;

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

memset(dp,-1,sizeof(dp));

cout<<pd(1);



}

Measured memory_bytes: 6144
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000100;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,a[N],b[N];
bool check(int md){
	int i,l,r;
	for(i=1;i<=n;i++)b[i]=a[i]>md;
	i=n/2+1;b[0]=b[1];b[n+1]=b[n];
	for(l=i-1;b[l]!=b[l+1];l--);
	for(r=i+1;b[r]!=b[r-1];r++);
	if(b[l]==b[r])return b[l];
	return i-l<r-i?b[l]:b[r];
}
int main(){
	//freopen("1.out","w",stdout);
	int i,l,r;
	n=read()*2-1;
	for(i=1;i<=n;i++)a[i]=read();
	l=0;r=n+1;while(l<r-1)
	check(l+r>>1)?l=l+r>>1:r=l+r>>1;
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 4992
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def main():
	n, k = rli()
	A = list(rli())
	dp = [INF for _ in range(n)]
	dp[0] = 0
	for i in range(1, n):
		for j in range(max(0, i-k), i):
			dp[i] = min(dp[i], dp[j] + abs(A[j] - A[i]))
	print(dp[-1])
	stdout.close()

if __name__ == "__main__":
	main()

Measured memory_bytes: 92292
N = int(input())
dic = []
dic2 = []
for i in range(N):
    dic.append(i)
    dic.extend(input().split())
    dic2.append(dic)
    dic = []

for i in range(N):
    dic2[i][2] = int(dic2[i][2])
dic = sorted(dic2, key=lambda x:(x[1],-x[2]))

for i in range(N):
    print(dic[i][0]+1)

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

int main() {
	int n; int m; int d;
	while (~scanf("%d%d%d", &n, &m, &d)) {
		double ans = (d == 0 ? n : (n - d) * 2) / ((double)n * n);
		ans *= m - 1;
		printf("%.10f\n", ans);
	}
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
#define MOD 1000000007

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

	int N;
	cin >> N;
	map<pll, ll> m;
	ll c0 = 0;
	while(N --> 0) {
		ll a, b;
		cin >> a >> b;
		if(a == 0 && b == 0) { ++c0; continue; }
		ll g = __gcd(abs(a), abs(b));
		if(b < 0 || (b == 0 && a < 0)) g = -g;
		++ m[{a/g, b/g}];
	}
	ll res = 1;
	for(auto &p : m) {
		if(p.second < 0) continue;
		ll a = p.first.first, b = p.first.second;
		ll e = b, f = -a;
		if(f < 0 || (f == 0 && e < 0)) { e = -e; f = -f; }
		pll pef = {e, f};
		ll add = 0, add2 = 0;
		while(p.second --> 0) add = (2*add + res) % MOD;
		if(m.count(pef)) while(m[pef] --> 0) add2 = (2*add2 + res) % MOD;
		res = (res + add + add2) % MOD;
	}
	res = (res+MOD-1+c0) % MOD;
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 16080
import sys

def main():
    input = sys.stdin.readline
    n, z, w = map(int, input().split())
    A = list(map(int, input().split()))

    if n == 1:
        print(abs(w - A[0]))
    else:
        print(max(abs(w - A[-1]), abs(A[-1] - A[-2])))


    


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<iostream>

int main(){

    size_t n, y;
    std::cin >> n >> y;
    y /= 1000;

    for(size_t i = 0; i <= n; i++){
        for(size_t j = 0; j <= n; j++){
            if(i + j <= n){
                if(10 * i + 5 * j + 1 * (n - i - j) == y){
                    std::cout << i << ' ' << j << ' ' << (n - i - j) << std::endl;
                    return 0;
                }
            }
        }
    }

    std::cout << -1 << ' ' << -1 << ' ' << -1 << std::endl;

    return 0;
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int c;
    cin >> c;
    cout << n[c-1] << endl;
    return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
s = input()

a = []

before = s[0]
first = int(s[0])
count = 1
for x in s[1:]:
    if x != before:
        a.append(count)
        count = 1
    else:
        count += 1
    before = x
a.append(count)

L = 0
R = k * 2
if first == 1:
    R += 1

if R >= len(a):
    print(n)
    exit()

ans = sum(a[:R])
temp = ans

if first == 0:
    temp -= a[0]
    L += 1
    if R < len(a):
        temp += a[R]
    if R + 1 < len(a):
        temp += a[R + 1]
    R += 2
else:
    temp -= a[0] + a[1]
    L += 2
    if R < len(a):
        temp += a[R]
    if R + 1 < len(a):
        temp += a[R + 1]
    R += 2

if R >= len(a):
    ans = max(ans, temp)
    print(ans)
    exit()

ans = max(ans, temp)

while R <= len(a):
    temp -= a[L] + a[L+1]
    if R + 1 < len(a):
        temp += a[R] + a[R + 1]
    elif R < len(a):
        temp += a[R]
    ans = max(ans, temp)
    L += 2
    R += 2

print(ans)

Measured memory_bytes: 46448
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//=====main=====

func main() {
	sc.Split(bufio.ScanWords)

	n := scanInt()

	g := make([][]edge, n)

	for i := 0; i < n-1; i++ {
		a,b := scanInt()-1, scanInt()-1
		g[a] = append(g[a], edge{b, i})
		g[b] = append(g[b], edge{a, i})
	}

	ans := make([]int, n-1)

	dfs(0,0,0,g,ans)

	k := 0

	for i := 0; i < n; i++ {
		if k < len(g[i]) {
			k = len(g[i])
		}
	}

	fmt.Println(k)

	for i := 0; i < n-1; i++ {
		fmt.Fprintln(wr, ans[i])
	}
	wr.Flush()

}

type edge struct {
	node int
	num int
}

func dfs(pre, next, used int, g [][]edge, ans []int) {
	color := 1
	for _, e := range g[next] {
		if pre == e.node {
			continue
		}
		if used == color {
			color++
		}
		ans[e.num] = color
		dfs(next, e.node, color, g, ans)
		color++
	}
}


Measured memory_bytes: 33920
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace std;
using namespace __gnu_pbds; 

#define     mod             (int)1e9+7
#define     MOD             998244353
#define     ll              long long
#define     mp              make_pair
#define     F               first
#define     S               second
#define     t()             int test;cin>>test;while(test--)
#define     ii              pair<int,int>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vector<int> , greater<int> >
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            "\n"
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

bool comparator(ii a, ii b)
{
   if(a.F == b.F)
   {
      return (a.S < b.S);
   }
   else
   {
      return (a.F > b.F);
   }
}  


int32_t main()
 
{  
    #ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    #endif

    IOS;
     


     int n;
     cin>>n;

     ll ans  =0;

     for(int i=1; i<=n; i++)
     {
       ll int y = n/i;

       ans += i*(y*(y+1))/2;
     }

     cout<<ans<<endl;


}
            

    
    



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

int main(){
    int n,s,t,tmp=0;
    scanf("%d",&n);
    vector<int> a;
    for (int i=0;i<n;i++) {
        scanf("%d",&s);
        if (s%10==0) tmp+=s;
        else a.push_back(s);
    }
    sort(a.begin(),a.end());
    t=accumulate(a.begin(),a.end(),0);
    if (t%10==0 && t>0) t-=a[0];
    printf("%d\n",(tmp+t)%10==0?0:tmp+t);
    return 0;
}

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

ll x = 1e9 + 7; 
const int INF = 1001001001;

struct UnionFind {
  vector<int> d;
  UnionFind(int n): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int deg[100005];
vector<int> to[100005];


int main() {
  int n, m, k;
  cin >> n >> m >> k;
  UnionFind uf(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    deg[a]++;
    deg[b]++;
    uf.unite(a,b);
  }
  rep(i,k) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  rep(i,n) {
    int ans = uf.size(i)-1-deg[i];
    for (int u : to[i]) {
      if (uf.same(i,u)) --ans;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

const int maxn = 1e5 + 5;

int main(){
	int n,i,j;
	int a[maxn][4];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<3;j++){
			scanf("%d",&a[i][j]);
		}
	}
	int dp[maxn][4];
	memset(dp, 0, sizeof dp);
	for(i=0;i<3;i++){dp[0][i] = a[0][i];}
	for(i=1;i<n;i++){
		for(j=0;j<3;j++){
			for(int k=0;k<3;k++){
				if(k != j){
					dp[i][j] = max(dp[i][j], dp[i-1][k] + a[i][j]);	
				}
				
			}
			
		}
	}
	printf("%d\n",max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])));
	return 0;
};

Measured memory_bytes: 3328
from bisect import bisect_left, bisect
n=int(input())
la=sorted(list(map(int,input().split())))
lb=list(map(int,input().split()))
lc=sorted(list(map(int,input().split())))
ans=0
for i in lb:
    ans+=bisect_left(la,i)*(len(lc)-bisect(lc,i))
print(ans)

Measured memory_bytes: 106340
c1=list(map(int,input().split()))
c1.append(c1[0])
c4=c1
c2=list(map(int,input().split()))
c2.append(c2[0])
c3=list(map(int,input().split()))
c3.append(c3[0])

c=[]
c.append(c1)
c.append(c2)
c.append(c3)
c.append(c1)

for i in range(3):
 for j in range(3):
    if (c[i][j]-c[i][j+1])!=(c[i+1][j]-c[i+1][j+1]):
      print('No')
      exit()
      
print('Yes')

Measured memory_bytes: 3064
import numpy as np

N, A, B, C = map(int, input().split(' '))
ls = []
for _ in range(N):
    ls.append(int(input()))
n = 0
INF = 10 ** 9

def dfs(n, a, b, c):
    if n == N:
        return INF if min(a, b, c) == 0 else abs(a-A) + abs(b-B) + abs(c-C) - 30
    res0 = dfs(n+1, a, b, c)
    res1 = dfs(n+1, a+ls[n], b, c) + 10
    res2 = dfs(n+1, a, b+ls[n], c) + 10
    res3 = dfs(n+1, a, b, c+ls[n]) + 10
    return min(res0, res1, res2, res3)

print(dfs(0, 0, 0, 0))

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++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)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    int N, M; cin >> N >> M;
    priority_queue<int> pq;
    FOR(i,0,N-1){ int A; cin >> A; pq.push(A); }

    FOR(i,0,M-1){ pq.push(pq.top()/2); pq.pop(); }

    ll ans = 0;
    while (!pq.empty()) ans += pq.top(), pq.pop();
    cout << ans << '\n';
}



Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

void main_(); signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  main_(); return 0;
}

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;

int dp[2011][2011][2]; // テヲツャツ。テ」ツ?ォテ、ツスツソテ」ツ??、ツスツ催ァツスツョSi, Tj, テヲツャツ。テ」ツ?ョテヲツ鳴?・ツュツ?0: I, 1: O

void main_() {

  int N, M; cin >> N >> M;
  string S, T; cin >> S >> T;

  const string IO = "IO";

  rep(i, 2011) rep(j, 2011) rep(k, 2) dp[i][j][k] = -1;

  rep(i, N) if(S[i] == 'I') rep(j, M) dp[i][j][0] = 0;
  rep(i, M) if(T[i] == 'I') rep(j, N) dp[j][i][0] = 0;

  rep(i, N+1) rep(j, M+1) rep(k, 2) {
    if(dp[i][j][k] < 0) { continue; }

    if(i < N && S[i] == IO[k]) {
      maximize(dp[i+1][j][k^1], dp[i][j][k] + 1);
    }
    if(j < M && T[j] == IO[k]) {
      maximize(dp[i][j+1][k^1], dp[i][j][k] + 1);
    }
  }

  int ans = 0;
  rep(i, N+1) rep(j, M+1) maximize(ans, dp[i][j][1]);
  cout << ans << endl;
  
}

Measured memory_bytes: 34820
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>
#include <set>

using namespace std;

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

	int N, M;
	cin >> N >> M;

	vector<set<int>> service_list(N, set<int>());

	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;

		service_list[a - 1].insert(b - 1);
		service_list[b - 1].insert(a - 1);
	}

	for (int next : service_list[0])
	{
		if (service_list[next].find(N - 1) != service_list[next].end())
		{
			cout << "POSSIBLE";
			return 0;
		}
	}

	cout << "IMPOSSIBLE";

	return 0;
}


Measured memory_bytes: 28416
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

alias Edge =  Tuple!(int, "u", int, "v");

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto G = new int[][](N);
    auto deg = new int[](N);
    Edge[Edge] E;
    foreach (i; 0..M) {
        s = readln.split.map!(to!int);
        auto u = s[0] - 1;
        auto v = s[1] - 1;
        deg[u] ^= 1;
        G[u] ~= v;
        G[v] ~= u;
        E[Edge(u, v)] = Edge(u, v);
    }
    auto T = new DfsTree(G);

    if (deg.sum % 2 == 1) {
        writeln(-1);
        return;
    }

    int dfs(int n, int p) {
        foreach (m; T.graph[n]) {
            if (m == p) continue;
            deg[n] ^= dfs(m, n);
        }
        if (deg[n]) {
            auto e1 = Edge(n, p);
            auto e2 = Edge(p, n);
            if (e1 in E) {
                swap(E[e1].u, E[e1].v);
            } else {
                swap(E[e2].u, E[e2].v);
            }
        }
        return deg[n];
    }

    dfs(0, -1);
    foreach (e; E.values) {
        writeln(e.u + 1, " ", e.v + 1);
    }
}

// This assumes the input graph as undirected and connected.

class DfsTree {
    import std.algorithm : any, map, min, swap;
    import std.conv : to;
    import std.typecons : Tuple, tuple;

    int n;
    int[] ord;
    int[] low;
    int[] parent;
    int[][] graph;

    this(const int[][] graph, int root = 0) {
        n = graph.length.to!int;
        ord = new int[](n);
        low = new int[](n);
        parent = new int[](n);
        this.graph = new int[][](n);
        construct_dfs_tree(graph, root);
    }

    public bool is_bridge(int u, int v) {
        if (u != parent[v] && v != parent[u]) {
            return false;
        }
        if (v == parent[u]) {
            swap(u, v);
        }
        return ord[u] < low[v];
    }

    public bool is_articulation_point(int u) {
        if (ord[u] == 0) {
            return graph[u].length >= 2;
        } else {
            foreach (v; graph[u]) {
                if (parent[u] == v) continue;
                if (ord[u] <= low[v]) return true;
            }
            return false;
        }
    }

    private void construct_dfs_tree(const int[][] org, int root) {
        int cnt = 0;
        ord[] = -1;
        low[] = -1;

        void dfs(int n, int p) {
            ord[n] = low[n] = cnt++;
            foreach (m; org[n]) {
                if (m == p) continue;
                if (ord[m] == -1) {
                    parent[m] = n;
                    graph[n] ~= m;
                    graph[m] ~= n;
                    dfs(m, n);
                    low[n] = min(low[n], low[m]);
                } else {
                    low[n] = min(low[n], ord[m]);
                }
            }
        }

        dfs(root, -1);
    }
}


Measured memory_bytes: 31740
S = list(input())

S_be = S[0] + S[1]
S_af = S[2] + S[3]

if 0 < int(S_be) and int(S_be) <= 12:
    if 0 < int(S_af) and int(S_af) <= 12:
        print("AMBIGUOUS")
    
    else:
        print("MMYY")

else:
    if 0 < int(S_af) and int(S_af) <= 12:
        print("YYMM")
    
    else:
        print("NA")

Measured memory_bytes: 3060
#include "iostream"
#include "vector"
using namespace std;
int main(void)
{
	int n,k,m;
	while (cin>>n>>k>>m,n) {
		vector<int> s;
		for (int i = 1; i < n+1; i++) {
			s.push_back(i);
		}
		m--;
		while (s.size()>1) {
			s.erase(s.begin()+m);
			m=(m+k-1)%s.size();
		}
		cout<<s[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1324
#include <bits/stdc++.h>
#define LL long long
using namespace std ;
template <class T> void Read ( T &x, char c = getchar(), bool f = 0 ) {
	for ( x = 0 ; !isdigit(c) ; c = getchar() ) f |= c == '-' ;
	for ( ; isdigit(c) ; c = getchar() ) x = 10*x + c - '0' ;
	if (f) x = -x ;
}
template <class T> void chkmin ( T &a, T b ) { a = a<b?a:b ; }
template <class T> void chkmax ( T &a, T b ) { a = a>b?a:b ; }
const LL maxn = 2e5+5, inf = 1e13 ;
LL n, m, a[maxn], Min, Max ;
LL calc ( LL x ) {
	LL rec = 0 ;
	for ( int i = 1 ; i <= n ; i ++ )
		rec += abs(a[i]-x) ;
	return rec ;
}
int main() {
	Read(n) ;
	Min = inf, Max = -inf ;
	int i ;
	for ( i = 1 ; i <= n ; i ++ ) {
		Read(a[i]), a[i] -= i ;
		chkmin(Min, a[i]) ;
		chkmax(Max, a[i]) ;
	}
	LL l = Min, r = Max, md1, md2 ;
	LL v1, v2, vl = calc(l), vr = calc(r) ;
	while (r-l >= 10) {
		md1 = l+(r-l+1)/3 ;
		md2 = r-(r-l+1)/3 ;
		v1 = calc(md1), v2 = calc(md2) ;
		if (v1 > v2) { l = md1, vl = v1 ; }
		else { r = md2, vr = v2 ; }
	}
	for ( ; l <= r ; l ++ )
		chkmin(vl, calc(l)) ;
	cout << vl << endl ;
	return 0 ;
}

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

int main() {

  string s;
  cin >> s;
  vector<bool> app(26);
  rep(i, s.size()) app[s[i] - 'a'] = true;
  rep(i, 26) if(!app[i]) {
    printf("%c\n", char(i + 'a'));
    return 0;
  }
  
  printf("None\n");
  return 0;
    cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
}

Measured memory_bytes: 3856
n = gets.chomp.to_i
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
d = gets.chomp.to_i
ma = []
ma.push((a-1)/c+1)
ma.push((b-1)/d+1)
puts n - ma.max

Measured memory_bytes: 6092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int main()
{
	string s;
	cin>>s;
	int l = s.size();
	int l1 = (l-1)/2;
	int l2 = (l+3)/2-1;
	string s1 = s.substr(0,l1);
	string s2 = s.substr(l2,l-l2);
	
	string ss = s;
	string ss1 = s1;
	string ss2 = s2;
	reverse(ss.begin(),ss.end());
	reverse(ss1.begin(),ss1.end());
	reverse(ss2.begin(),ss2.end());
	
	//cout<<ss<<" "<<ss1<<" "<<ss2<<endl;
	
	if( s==ss && s1==ss1 && s2==ss2 )
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n;
    cin >> n; 
    if(n == 1 || n == 2 || n == 3 || n == 4 || n == 5 || n == 6 || n == 7 || n == 8 || n == 9 || n == 10 || n == 12 || n == 14 || n == 16 || n == 18 || n == 15 || n == 21 || n == 24 || n == 27 || n == 16 || n == 20 || n == 28 || n == 32 || n == 36 || n == 25 || n == 30 || n == 35 || n == 40 || n == 45 || n == 36 || n == 42 || n == 48 || n == 54 || n == 49 || n == 56 || n == 63 || n == 64 || n == 72 || n == 81)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long int;using ld = long double;using P = pair<ll,ll>;const int MOD = (int)1e9+7;const string rt = "\n";const string sp = " ";/* 最大公約数 */template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}/* UnionFind */template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};/* コンビネーション */template<typename T> ll combpm(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}/* 多次元ベクター */template<class T>vector<T> multi_vector(size_t a){return vector<T>(a);}template<class T, class... Ts>auto multi_vector(size_t a, Ts... ts){return vector<decltype(multi_vector<T>(ts...))>(a, multi_vector<T>(ts...));}/* テスト関数 */void test(ll n){cout << "test" << n << endl;}/* 小数点以下 */void fixsp(ll n){cout << fixed << setprecision(n);}void defsp(ll n){cout << defaultfloat << setprecision(n);}

/* ここからコード開始 */

int main(){
  kyopro;
  ll N;
  cin >> N;
  ll Lmax{}, Lall{};
  rep(i, 0, N){
    ll L;
    cin >> L;
    Lall += L;
    Lmax = max(Lmax, L);
  }
  cout << (Lmax < Lall - Lmax ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int H,W;
  cin >>H>>W;
  char a[H][W];
  int i, j;
  char tmp;
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      cin>>tmp;
      if(tmp=='#')  a[i][j]='#';
      else  a[i][j]='.';
    }
  }
  int row_black[H], ary_black[W];
  for(i=0;i<H;i++){
    row_black[i]=0;
  }
  for(i=0;i<W;i++){
    ary_black[i]=0;
  }
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if (a[i][j]=='#') row_black[i]=1;
    }
  }
  for(j=0;j<W;j++){
    for(i=0;i<H;i++){
      if (a[i][j]=='#') ary_black[j]=1;
    }
  }
  for(i=0;i<H;i++){
    int flag=0;
    for(j=0;j<W;j++){
      if (row_black[i]==1 && ary_black[j]==1){
        cout<<a[i][j];
        flag=1;
      }
    }
    if(flag)  cout<<'\n';
  }
}


Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    int main() {
	int h,w,p,q;
	while(1){
		cin>> h >> w;
		p=h/2;
		q=w/2;
		if(h == 0 && w == 0){
			break;
		}
		 for (int i=0; i<p; i++){
		 	for (int j=0; j<q; j++ ){
		 		cout<<"#.";
		 	}
		 	if (w%2 == 1){
		 		cout<<"#";
		 	}
		 	cout<<endl;
		 	for (int j=0; j<q; j++ ){
		 		cout<<".#";
		 	}
		 	if (w%2 == 1){
		 		cout<<".";
		 	}
		 	cout<<endl;
		 } 
		 if(h%2==1){
		 	for (int j=0; j<q; j++ ){
		 		cout<<"#.";
		 	}
		 	if (w%2 == 1){
		 		cout<<"#";
		 	}
cout<<endl;
		 }
		 
                 cout<<endl;
	}
    return 0;
    }

Measured memory_bytes: 1156
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] W = new String[N];
        boolean ok = true;
        Set<String> set = new HashSet<>();
        for (int i = 0; i < W.length; i++) {
            W[i] = sc.next();
            if (set.contains(W[i])) {
                ok = false;
            }
            set.add(W[i]);
            if (i >= 1) {
                if (W[i].charAt(0) != W[i - 1].charAt(W[i - 1].length() - 1)) {
                    ok = false;
                }
            }
        }
        if (ok) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

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

int main(){
  int A, B, C, D;
  int dta, dtb;
  scanf("%d %d %d %d", &A, &B, &C, &D);

  dta = A / D;
  if(A % D != 0)dta+=1;
  dtb = C / B;
  if(C % B != 0)dtb+=1;


  //printf("ta: %d  tb: %d\n", dta, dtb);
  if(dta >= dtb){
    printf("Yes\n");
  }else{
    printf("No\n");
  }

  return 0;
}

Measured memory_bytes: 1664
import java.util.*;

class Main{
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int ihas = 0;
		int iline = Integer.parseInt(line);
		for(int i=0;i<line.length();i++) {
			int x = line.charAt(i) - 48;
			ihas += x;
		}
		if(iline%ihas==0) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
    }
}

Measured memory_bytes: 22228
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 1000000007
#define bitcnt(a) (ll) __builtin_popcount((a))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll n, k;
vector<ll> v;

ll calc(ll a, ll b) { return a / b + ((a % b) ? 1 : 0); }

int main() {
  cin >> n >> k;
  ll itr = 0;
  REP(i, n) {
    ll h;
    cin >> h;
    if (h == 1)
      itr = i;
  }
  ll left = itr, right = n - 1 - itr;
  return !printf("%lld\n", calc(n - 1, k - 1));
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi                  3.14159265359
ll INF=1e18+10;
ll MOD=1000000009;

const int N=2*1e5+10;
bool vis[N];

int main()
{
    fastio;
    int n;cin>>n;
    int a[n+1];
    for(int i=0;i<n;i++)
    cin>>a[i+1];

    for(int i=n;i>0;i--)
    {
        int last=(n/i)*i;
        int c=0;
        for(int j=last;j>0;j-=i)
            if(vis[j]==1)c++;
        if((c%2==0 && a[i]==0) || (c%2==1 && a[i]==1))
            continue;
        else
            vis[i]=1;
    }
    vector<int> v;
    for(int i=1;i<=n;i++)
        if(vis[i])
        v.push_back(i);

    int siz=v.size();
    cout<<siz<<endl;
    for(int i=0;i<siz;i++)
        cout<<v[i]<<" ";
}

Measured memory_bytes: 2552
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.first+a.second > b.first+b.second; }

signed main() {
  SS(int,n);
  map<pair<int, int>, int> mp;
  int ans = 0;
  rep(i,n){
    string s = to_string(i+1);
    int f = s.front() - '0', r = s.back() - '0';
    mp[{f,r}]++;
  }
  rep(i, 10)rep(j, 10)ans += mp[{i,j}] * mp[{j,i}];
  p(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  int n; cin >> n;
  cout << n << ":";
  for(int i = 2; i<=sqrt(n)+1; i++){
    if(n % i == 0){
      while(n % i == 0){
        n /= i; cout << " " << i;
      }
    }
  }
  if(n != 1) cout << " " << n;
  cout << endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int64_t modpow(int64_t a, int64_t b, int64_t MOD) {
	int64_t ret = 1;
	while (b > 0) {
		if (b & 1) { (ret *= a) %= MOD; }
		(a *= a) %= MOD;
		b >>= 1;
	}
	return ret % MOD;
}

int main() {
	Int N, P;
	cin >> N >> P;
	string s;
	cin >> s;

	if (P == 2 || P == 5) {
		vector<Int> curr(P, 0);
		curr[(int)(s[0] - '0') % P] = 1;
		Int ans = curr[0];
		for (int i = 1; i < N; ++i) {
			vector<Int> nxt(P, 0);
			int x = s[i] - '0';
			nxt[x % P] += 1;
			for (int j = 0; j < P; ++j) {
				nxt[(j * 10 + x) % P] += curr[j];
			}
			ans += nxt[0];
			curr = nxt;
		}
		cout << ans << endl;

		return 0;
	}

	Int x = 0, y = 1;
	map<Int, Int> mp;
	mp[0] = 1;
	for (int i = 0; i < N; ++i) {
		(x = x * 10 + (s[i] - '0')) %= P;
		Int z = x * modpow(y, P - 2, P) % P;
		mp[z] += 1;
		y = y * 10 % P;
	}
 
	Int ans = 0;
	for (auto it = mp.begin(); it != mp.end(); ++it) {
		ans += it->second * (it->second - 1) / 2;
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
long long st=1,ed=1.2e9;
long long arr[100005];
main()
{
	int t,r;
    long long a,b,mn=1e18;
    scanf("%d%lld%lld",&t,&a,&b);
    for(int i = 0;i < t;i++)
    {
        scanf("%lld",&arr[i]);
    }
    while(st<=ed)
    {
        long long md=(st+ed)/2;
        long long co=0,ck=0;
        long long s=0;
        for(int i = 0;i < t;i++)
        {
            co+=(max(arr[i]-b*md,s)+(a-1-b))/(a-b);
            if(co>md)
            {
                ck=1;
                break;
            }
        }
        //printf("\n\n");
        if(co>md || ck==1)
        {
            st=md+1;
        }
        else
        {
            mn=min(mn,md);
            ed=md-1;
        }
    }
    printf("%lld",mn);
}


Measured memory_bytes: 1024
n = gets.chomp
a = gets.chomp
b = gets.chomp
c = gets.chomp

n = n.to_i
r = 0
n.times do |i|
  ca, cb, cc = a[i], b[i], c[i]
  r += 1 if ca != cb
  r += 1 if cb != cc
  r -= 1 if (ca != cb) && (cb != cc) && (ca == cc)
end

puts r.to_s

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
 
using lnt = long long;
using Real = long double;
 
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)
 
#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)
 
constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;
 
template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}
 
using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	char a; cin >> a;
	if('a' <= a and a <= 'z') cout << 'a' << ln;
	else cout << 'A' << ln;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
using namespace std;
typedef long long ll;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define FOREACH(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))

int main() {
    
    ll a,b,x;
    cin>>a>>b>>x;
    
    cout<<(b/x)-((a==0?-x:a-1)/x)<<endl;
    
    return 0;
}




Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;

const int N = 100003;
int n, a[N];
ll sum[N];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
		sum[i] = sum[i - 1] + a[i];
	}
	
	ll sumnow = 0, cnt = 0, ans, sumi;
	int op = 0;
	for (int i = 1; i <= n; ++i) {
		op ^= 1;
		sumi = sum[i] + sumnow;
		if (op) {
			if (sumi > 0) continue;
			cnt += (1 - sumi);
			sumnow += (1 - sumi);
		} else {
			if (sumi < 0) continue;
			cnt += (sumi + 1);
			sumnow -= (sumi + 1);
		}
	}
	ans = cnt;
	
	op = 1; cnt = sumnow = 0;
	for (int i = 1; i <= n; ++i) {
		op ^= 1;
		sumi = sum[i] + sumnow;
		if (op) {
			if (sumi > 0) continue;
			cnt += (1 - sumi);
			sumnow += (1 - sumi);
		} else {
			if (sumi < 0) continue;
			cnt += (sumi + 1);
			sumnow -= (sumi + 1);
		}
	}
	printf("%lld\n", min(ans, cnt));
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>

using namespace std;
int M[100][100]; 
int n; 
static const int WHITE=0; 
static const int GRAY=1; 
static const int BLACK=2; 
static const int INFTY=(1<<21);  
int prim()
{
    int color[100]; 
    int d[100]; 
    int parent[100];
    for(int i=0;i<n;i++)
       {
          d[i]=INFTY; 
          color[i]=WHITE;
       }
    d[0]=0; 
    parent[0]=-1;
    while(1)
    {
        int r=-1;int minv=INFTY;
        for(int i=0;i<n;i++)
        {
            if(color[i]!=BLACK&&d[i]<minv)
            {
                r=i;minv=d[i];
            }
        }
        if(r==-1) break; 
        color[r]=BLACK; 
        for(int i=0;i<n;i++)
        {
            if(color[i]!=BLACK&&M[r][i]!=INFTY) 
            {
                if(d[i]>M[r][i]) 
                {
                    d[i]=M[r][i];
                    parent[i]=r; 
                    color[i]=GRAY;
                }
            }
        }
    }
    int sum=0;
    for(int i=0;i<n;i++)
    {
        if(parent[i]!=-1)
            sum+=M[i][parent[i]];
    }
    return sum;
}
int main()
{
    while(cin>>n)
    {
        for(int i=0;i<n;i++)
            for(int j=0;j<n;j++)
              {
                   cin>>M[i][j];
                   if(M[i][j]==-1) M[i][j]=INFTY;
              }
        cout<<prim()<<endl;
    }
    return 0;
}

Measured memory_bytes: 3104
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <cstdlib>
#define PI acos(-1.0)
#define ll long long int
#define db double
#define ull unsigned long long int
#define Fill(x,y) memset(x,y,sizeof(x))
#define bug printf("!!!!!!\n");
#define fi first
#define se second
using namespace std;
const db eps = 1e-6;
const int inf = 0x3f3f3f3f; //用这个可以直接mem
const ll INF = 1e18;
const int mod = 1e9+7;
const int maxn = 1e5+5;
int cas=1;
int a[10];
char op[10];
void solve()
{
    string s;
    cin >> s;
    for(int i=0;i<s.size();i++){
        a[i+1] = s[i] - '0';
    }
    int ans ,cnt ;
    for(int i=0;i<(1<<3);i++) {
        ans = a[1]; cnt = 2;
        for(int j=0;j<3;j++){
            if(i&(1<<j)) {
                ans += a[cnt];
                op[cnt] = '+';
            }
            else{
                ans -= a[cnt];
                op[cnt] = '-';
            }
            cnt++;
        }
        if(ans == 7) break;
    }
    printf("%d",a[1]);
    for(int i=2;i<=4;i++){
        printf("%c%d",op[i],a[i]);
    }
    printf("=7\n");
}
int main()
{
    // freopen("in.txt","r",stdin);
    //  freopen("out.txt","w",stdout);
    int t = 1 ;
    //scanf("%d",&t);
    while(t--){
       // printf("Case %d: ", cas++);
        solve();
        //printf("\n");
    }
}









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

int gcd(int x, int y);
bool pairCompare(const P & firstElof, const P & secondElof);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }


int main() {
    ll n, m;
    cin >> n >> m;
    vector<P> a(n);
    ll ans = 0;
    rep(i, n) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a.begin(), a.end());
    rep(i, n) {
        if (m <= a[i].second) {
            ans += a[i].first * m;
            break;
        }
        else {
            ans += a[i].first * a[i].second;
            m -= a[i].second;
        }
    }
    cout << ans << endl;
    return 0;
}
/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

//pair�̐擪�̗v�f������������sort
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.first <= secondElof.first;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

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

    vector<ll> p(N);
    rep(i, N) cin >> p[i];

    // ll ans = INF;

    sort(p.begin(), p.end());
    ll ans = 0;
    rep(i, K) { ans += p[i]; }

    cout << ans << endl;

    // // bit全探索
    // bool exist = false;
    // for (ll bit = 0; bit < (1 << N); bit++) {
    //     ll sum = 0;

    //     for (ll i = 0; i < N; i++) {
    //         if (bit & (1 << i)) sum += p[i];
    //     }

    //     ans = min(sum, ans);
    // }

    // cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
from sys import stdin
import sys
import math

# A, B, C = [int(x) for x in stdin.readline().rstrip().split()]
# A, B = [int(x) for x in stdin.readline().rstrip().split()]
# U = input().split()
N = list(input())
if N[-1]=='2' or N[-1]=='4' or N[-1]=='5' or N[-1]=='7' or N[-1]=='9':
    print('hon')
elif N[-1]=='3':
    print('bon')
else:
    print('pon')


Measured memory_bytes: 9104