akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::Ordering::{Equal, Greater, Less};
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;

// author: Seong Yong-ju <sei40kr@gmail.com>

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let n: i64;
    let ss: Vec<Vec<char>>;

    input! {
        n: i64,
        ss: [chars; n as usize],
    };

    let c0 = ss
        .iter()
        .map(move |s| s.windows(2).filter(|&part| part == ['A', 'B']).count() as i64)
        .sum::<i64>();
    let c1 = ss
        .iter()
        .filter(|&s| *s.first().unwrap() == 'B' && *s.last().unwrap() == 'A')
        .count() as i64;
    let c2 = ss
        .iter()
        .filter(|&s| *s.first().unwrap() != 'B' && *s.last().unwrap() == 'A')
        .count() as i64;
    let c3 = ss
        .iter()
        .filter(|&s| *s.first().unwrap() == 'B' && *s.last().unwrap() != 'A')
        .count() as i64;

    let M = if c2 <= c3 { c3 } else { c2 };
    let m = if c2 <= c3 { c2 } else { c3 };

    let ans = c0
        + if c1 == 0 {
            m
        } else {
            c1 + if 0 < c2 + c3 { m } else { -1 }
        };

    println!("{}", ans);
}


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

using ll = long long;
using namespace std;
constexpr ll inf = 1e15;
constexpr ll mod = 1e9+7;

class BIT {
    vector<ll> bit;

public:
    BIT(size_t n) {
        bit.resize(n+1, 0);
    }

    void add(int a, ll w) {
        a += 1;
        for (int x = a; x <= bit.size(); x += x & -x) bit[x] += w;
    }

    ll sum(int a) {
        a += 1;
        ll ret = 0;
        for (int x = a; x > 0; x -= x & -x) ret += bit[x];
        return ret;
    }
};

int compress(vector<int>& x, map<int,int>& zip, vector<int>& unzip) {
    sort(begin(x), end(x));
    x.erase(unique(begin(x), end(x)), end(x));
    for (int i = 0; i < x.size(); i++) {
        zip[x[i]] = i;
        unzip.push_back(x[i]);
    }
    return x.size();
}

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

    int N;
    cin>>N;
    vector<int> a(N);
    for (int n = 0; n < N; n++) cin>>a[n];
    vector<int> sorted_a(N);
    copy(begin(a), end(a), begin(sorted_a));
    map<int, int> zip;
    vector<int> unzip;
    compress(sorted_a, zip, unzip);
    for (int n = 0; n < N; n++) a[n] = zip[a[n]];

    ll ans = 0;
    BIT bit(N);
    for (int n = 0; n < N; n++) {
        ll j = bit.sum(a[n]);
        bit.add(a[n], 1);
        ans += n - j;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 16204
using System;
using System.Text;

public class Test
{
	static public void Main( )
	{
		StringBuilder output = new StringBuilder();
		output.Capacity = 608;
		while( true ) { 
			String[] data = Console.ReadLine().Split( ' ' );
			var H = Int32.Parse( data[0] );
			var W = Int32.Parse( data[1] );
			if( 0 == H && 0 == W ) break;
			
			var w = new String( '#', W );
			var w2 = new String( '.', W-2 );
			output.Append( w ).Append( "\n" );
			for( var i=0; i<H-2; i++ ) {
				output.Append( "#" ).Append( w2 ).Append( "#\n" );
			}
			output.Append( w ).Append( "\n\n" );
		}
		Console.Write( output );
	}
}

Measured memory_bytes: 5628
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
    int x,a,b,n; cin >> x >> a >> b >> n;
    for(int i=0;i<n;i++){
        string s; cin >> s;
        if(s=="nobiro"){
            x+=a;
        }
        else if(s=="tidime"){
            x+=b;
        }
        else{
            x=0;
        }
        x=max(x,0);
    }
    cout << x << endl;
}


Measured memory_bytes: 3208
#include<iostream>
#include<vector>
#include <unordered_map>  
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <sstream>
#include <cmath>
using namespace std;

int main() {
	string s;
	cin >> s;
	if ((s[0] == s[1] && s[2] == s[1]) || (s[3] == s[1] && s[2] == s[1])) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main()
{
    char c1[4] = {0}, c2[4] = {0};
    scanf("%s%s", c1, c2);
    int k = 0;
    for (int i = 0; i < 3; i++)
    {
        if (c1[i] == c2[2 - i])
        {
            k++;
        }
    }
    if (k == 3)
    {
        printf("YES\n");
    }
    else
    {
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
use std::io::{self, Stdin};
use std::str::{self, FromStr};
use std::error::Error;
use std::cmp::min;
fn exec() {
    let mut sc = Scanner::new();
    let n: usize = sc.ne();
    let mut cnt = vec![1000000; 30];
    for _ in 0..n {
        let s: Vec<u8> = sc.ne::<String>().into_bytes();
        let mut tmp = vec![0; 30];
        for c in s {
            let x = (c - b'a') as usize;
            tmp[x] += 1;
        }
        for i in 0..26 {
            cnt[i] = min(cnt[i], tmp[i]);
        }
    }
    for i in 0..26 {
        for _ in 0..cnt[i] {
            print!("{}", (b'a' + i as u8) as char);
        }
    }
    println!("");
}

fn main() {
    const STACK: usize = 16 * 1024 * 1024;
    let _ = std::thread::Builder::new()
        .stack_size(STACK)
        .spawn(|| { exec(); })
        .unwrap()
        .join()
        .unwrap();
}

#[allow(dead_code)]
struct Scanner {
    stdin: Stdin,
    id: usize,
    buf: Vec<u8>,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            id: 0,
            buf: Vec::new(),
        }
    }
    fn next_line(&mut self) -> Option<String> {
        let mut res = String::new();
        match self.stdin.read_line(&mut res) {
            Ok(0) => None,
            Ok(_) => Some(res),
            Err(why) => panic!("error in read_line: {}", why.description()),
        }
    }
    fn next<T: FromStr>(&mut self) -> Option<T> {
        while self.buf.len() == 0 {
            self.buf = match self.next_line() {
                Some(r) => {
                    self.id = 0;
                    r.trim().as_bytes().to_owned()
                }
                None => return None,
            };
        }
        let l = self.id;
        assert!(self.buf[l] != b' ');
        let n = self.buf.len();
        let mut r = l;
        while r < n && self.buf[r] != b' ' {
            r += 1;
        }
        let res = match str::from_utf8(&self.buf[l..r]).ok().unwrap().parse::<T>() {
            Ok(s) => Some(s),
            Err(_) => {
                panic!("parse error, {:?}",
                       String::from_utf8(self.buf[l..r].to_owned()))
            }
        };
        while r < n && self.buf[r] == b' ' {
            r += 1;
        }
        if r == n {
            self.buf.clear();
        } else {
            self.id = r;
        }
        res
    }
    fn ne<T: FromStr>(&mut self) -> T {
        self.next::<T>().unwrap()
    }
}


Measured memory_bytes: 8572
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int A,B,C,N,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){

}

void debug(){

}

void answer(){
	if(N < 1200){
		cout << "ABC\n";
	}else{
		cout << "ARC\n";
	}
}

int main(){
	cin >> N;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
h,w,d=map(int,input().split())
dic=[0]*(h*w+1)
def cost(a,b):
    return abs(a[0]-b[0])+abs(a[1]-b[1])
for i in range(h):
    a=list(map(int,input().split()))
    for j in range(w):
        dic[a[j]]=(i+1,j+1)
dis=[[0] for i in range(d)]
for i in range(d):
    k=1
    for j in range(i+d,h*w,d):
        dis[i].append(dis[i][k-1]+cost(dic[j-d+1],dic[j+1]))
        k+=1
# print(dis)
q=int(input())
ans=0
for i in range(q):
    l,r=map(int,input().split())
    k=l%d-1
    print(dis[k][(r+d-1)//d-1]-dis[k][(l+d-1)//d-1])

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

int main()
{
    // 入力
    int N;
    cin >> N;
    priority_queue<P, vector<P>, greater<P>> w;

    rep (i, N) {
        int A, B;
        cin >> A >> B;

        w.push(make_pair(B, A));
    }

    ll T = 0;
    while (!w.empty()) {
        P p = w.top();
        w.pop();

        T += p.second;
        if (T > p.first) {
            cout << "No" << endl;
            return 0;
        }
    }

    // 出力
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 2420
# coding: utf-8
# Your code here!
class Tree:
    def __init__(self, parent, left_child, right_sib):
        self.left_child = left_child
        self.right_sib = right_sib
        self.parent = parent
    

def getDepth(T, u):
    d = 0
    while T[u].parent is not None:
        u = T[u].parent
        d += 1
    return d

def getChildren(T, u):
    Children = []
    c = T[u].left_child
    while c is not None:
        Children.append(str(c))
        c = T[c].right_sib
    if len(Children) != 0:
        return "[" + ", ".join(Children) + "]"
    else:
        return "[]"

n = int(input().rstrip())

T = []
for _ in range(n):
    T.append(Tree(None, None, None))

for _ in range(n):
    inputs = list(map(int, input().rstrip().split(" ")))
    u = inputs[0]
    k = inputs[1]
    children = inputs[2:] if k > 0 else [None]
    T[u].left_child = children[0]
    if k > 0:
        for i, child in enumerate(children):
            T[child].parent = u
            T[child].right_sib = children[i+1] if i+1 < len(children) else None

def print_info(T, u):
    parent = T[u].parent
    if parent is None:
        parent = -1
    depth = getDepth(T, u)
    children = getChildren(T, u)
    type_ = "root" if parent == -1 else "leaf" if children == "[]" else "internal node"
    
    print("node {}: parent = {}, depth = {}, {}, {}".format(u, parent, depth, type_ ,children if type_ != "leaf" else "[]"))

for u in range(n):
    print_info(T, u)
    
   
    
    



Measured memory_bytes: 33872
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextInt(), a = sc.nextInt(), b = sc.nextInt();
        long ans = (b * (n-1) + a) - (a * (n-1) + b) + 1;
        if (ans <= 0) System.out.println(0);
        else System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    string S; cin >> S;
    int N = (int)S.size();
    
    vector<int> Ans(N);
    for(int i=0; i<2; i++){
        
        int cnt = 0;
        for(int j=0; j<N; j++){
            if(S[j]=='R') cnt++;
            else{
                Ans[j-1] += (cnt + 1)/2;
                Ans[j] += cnt/2;
                cnt = 0;
            }
        }
        reverse(S.begin(), S.end());
        reverse(Ans.begin(), Ans.end());
        for(int j=0; j<N; j++){
            if(S[j]=='L') S[j] = 'R';
            else S[j] = 'L';
        }
    }
    
    for(int i=0; i<N; i++){
        cout << Ans[i] << " ";
    }
    cout << endl;
    
    
    return 0;
}





Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<Integer> list = new ArrayList<Integer>();
    for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    }
    
    int maxCnt = 0;
    int cnt = 0;
	
    for(int i = 0; i < list.size() - 1; i++){
      int target = i;
      for(int j = i + 1; j < list.size(); j++){
        if(list.get(target + 1) <= list.get(target)){
          cnt++;
          target++;
        }else{
          break;
        }
      }
      if(cnt > maxCnt){
        maxCnt = cnt;
      }
      i += cnt;
      cnt = 0;
    }
    System.out.println(maxCnt);
  }
}

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

import itertools

def main():
     n, m, q = map(int, input().split())
     q_list = list()
     a_list = [i for i in range(1, m+1)]

     for i in range(q):
          q_list.append(list(map(int, input().split())))

     ans = 0

     for v in itertools.combinations_with_replacement(a_list, n):
          target = list(v)
          # print('target: {}'.format(target))
          score = 0
          for i in range(len(q_list)):
               point = q_list[i]
               # print('point: {}'.format(point))
               if target[point[1]-1] - target[point[0]-1] == point[2]:
                    score += point[3]
          
          if ans < score:
               ans = score
          
     print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
    int N,M; cin>>N>>M;
    set<pint> st;
    REP(i,M){
        int a,b; cin>>a>>b;
        st.insert(pint(a,b));
    }
    for(int i=2;i<=N-1;i++){
        if(st.count(pint(1,i))+st.count(pint(i,N))==2){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
 
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(0);   
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

  int n,m;
  cin>>n>>m;
  int a[m];
  int s=0;
  for (int i = 0; i < m; i++)
  {
    cin>>a[i];
    s+=a[i];
  }
  n-=s;
  if(n<0)
    cout<<-1;
  else
    cout<<n;
 
// -------------------------------------Code ends here------------------------------------------------------------------
    clock_t clk;
  clk = clock();

    clk = clock() - clk;
  cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
  return 0;
}


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

struct UnionFind {
  vector<int> par, weight;
  UnionFind(int n) : par(n,-1), weight(n) {}
  void unite(int x, int y, int w = 0) {
    x = find(x); y = find(y);
    if (x == y) return;
    if (par[x] > par[y]) swap(x, y), w = -w;
    par[x] += par[y];
    par[y] = x;
    return;
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int find(int x) {
    if(par[x] < 0) return x;
    int r = find(par[x]);
    return par[x] = r;
  }
  int sizeOf(int x) { return -par[find(x)]; }
};

int n, dist[222][222];
char c;

void warshall_floyd() {
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j) dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
}

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) {
    cin >> c;
    dist[i][j] = (c - '0' ? 1 : 1e9);
    if(i == j) dist[i][j] = 0;
  }

  UnionFind uf(n * 2);
  for(int i = 0; i < n; ++i)
    for(int j = i+1; j < n; ++j)
      if(dist[i][j] == 1) {
        uf.unite(i, j + n);
        uf.unite(j, i + n);
      }
  if(uf.same(0, n)) {
    cout << -1 << endl;
    return 0;
  }

  warshall_floyd();
  int ans = 0;
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
       ans = max(ans, dist[i][j]);
  cout << ans + 1 << endl;
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
int main(){
  
  int a , b , c;
  
  scanf("%d %d %d" , &a , &b , &c);
  
  if (a < b && b < c) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 580
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import *
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N, M = reads()
A = reads()
psum = [0] + list(accumulate(A))
c = Counter(p % M for p in psum)
ans = sum(v * (v-1) // 2 for v in c.values())
print(ans)

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

int main() {
  int n, i;
  cin >> n >> i;
  int ans = n-i + 1;
  cout << ans << endl;
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

x,y=MI()
ind=[0,2,0,1,0,1,0,0,1,0,0,1]
if ind[x-1]==ind[y-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
import math

def prime(k):
    if k == 2:
        return True
    if k == 1 or k % 2 == 0:
        return False
    else:
        for d in range(3, math.floor(math.sqrt(k)) + 1, 2):
            if k % d == 0:
                return False
        return True

n = int(input())

while not prime(n):
    n+=1
print(n)

Measured memory_bytes: 38256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

const ll MOD = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()


int main() {
	int q;
	cin >> q;
	for (int i = 0;i < q;i++) {
		ll a, b, c, ans = 0;
		cin >> a >> b;
		c = a*b;
		ll s = sqrt(c);
		if (s*s >= c)s--;
		ans += s * 2;
		if (s*(s + 1) >= c)ans--;
		if (a != b)ans--;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
s = []
for i in range(D):
  s.append(list(map(int, input().split())))
  
sdictlist = []
sdictlistsorted = []
for i in range(D):
  onedict = {}
  for j in range(26):
    onedict[j] = s[i][j]
  sdictlist.append(onedict)
  onesorteddict = sorted(onedict.items(), key=lambda x:x[1], reverse=True)
  sdictlistsorted.append(onesorteddict)

cignorelen = 3
csorted = sorted(c)
csorted = csorted[:cignorelen]
ignorelist = []
for i in range(26):
  if(c[i] in csorted):
    ignorelist.append(i+1)
    
lenpastmax = 18 #26まで設定できる
#26 -> 145419
#25 -> 18657778
#24 -> 40796238
#23 -> 54875726
#22 -> 63195752
#21 -> 66843963
#20 -> 67734290, ign=5 -> 3733319, ign=3 -> 41602078
#18                                ign=3 -> 
pastlist = []
for i in range(D):
  j = 0
  while(sdictlistsorted[i][j][0] in pastlist or sdictlistsorted[i][j][0]+1 in ignorelist):
    j += 1
  print(sdictlistsorted[i][j][0]+1)
  pastlist.append(sdictlistsorted[i][j][0])
  if(len(pastlist)==lenpastmax):
    pastlist.pop(0)

Measured memory_bytes: 10480
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,L;
    cin  >> N >> L;
    string S[N];
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }
    sort(S, S+N);
    string s = "";
    for(int i = 0; i < N; i++){
        s += S[i];
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int h=0;
  int w=0;
  char grid[100][100];
  int i=0;
  int j=0;
  int dameflag=0;
  
  scanf("%d %d",&h,&w);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      scanf(" %c",&grid[i][j]);
    }

  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(grid[i][j] =='#'){
      	if(i+1<h && grid[i+1][j] == '#'){\
                  	continue;
      	}else if(i-1>=0 && grid[i-1][j] == '#'){
        	continue;
      	}else if(j+1<w && grid[i][j+1] == '#'){

        	continue;
        }else if(j-1>=0 && grid[i][j-1] == '#'){
        	continue;
      	}
        dameflag = 1;
      }else{
      }
    }
  }
  if(dameflag){
    printf("No");
  }else{
    printf("Yes");
  }
      
  return 0;
}
             

Measured memory_bytes: 128
#include <bits/stdc++.h>
using std::string;
using std::vector;
using std::pair;
using lint = long long;
int n;

int dp[4][4][100];
string s1, s2;
int mod = 1000000007;
int go(int u, int d, int idx) {
	if (idx == n) {
		return 1;
	}
	int &ret = dp[u][d][idx];
	if (ret != -1) return ret;
	ret = 0;
	if (s1[idx] == s1[idx + 1] && s2[idx] == s2[idx + 1]) {
		ret += go(u, d, idx + 1);
		ret %= mod;
	}
	else if(s1[idx + 1] == s2[idx + 1]){
		for (int i = 1; i <= 3; i++)
			if (i != u && i != d) ret += go(i, i, idx + 1),ret %= mod;
	}
	else {
		for (int i = 1; i <= 3; i++)
			for (int j = 1; j <= 3; j++)
				if(i != j && i != u && j != d)	
					ret += go(i, j, idx + 1),ret %= mod;
	}
	return ret %= mod;
}
int main() {
	memset(dp, -1, sizeof(dp));
	scanf("%d", &n);
	std::cin >> s1 >> s2;
	s1 = " " + s1;
	s2 = " " + s2;
	printf("%d", go(0, 0, 0));
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
 int A,B,C;
 int i, judge;
 judge = 0;

 //入力
 scanf("%d %d %d", &A, &B, &C);
 
 //判定処理1
 if(A == 5 || A == 7)
  judge += 1;
 if(B == 5 || B == 7)
   judge += 1;
 if(C == 5 || C == 7)
   judge += 1;
 if((A+B+C) == 17)
   judge += 1;

 //デバッグコメント
 //printf("A = %d\n", judge);

 //判定+出力
 if(judge == 4)
  printf("YES");
 else
  printf("NO");
 
 return(0);
}

Measured memory_bytes: 128
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  if k%2==0:
    return (n//(k//2)-(n//k))**3+(n//k)**3
  return (n//k)**3

# main()
print(main())


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

using namespace std;

int main(){
    pair<int,int> p[100005];
    int n,i=0;
    cin >> n;

    while(n!=i){    
    cin >>p[i].first >> p[i].second;

    i++;
    }
    i=0;
    sort(p , p+n);
    
    while(n!=i){    
    cout << p[i].first <<" "<< p[i].second<<endl;

    i++;
    }
    
    
return 0;
}


Measured memory_bytes: 3900
/*                                  /   \                                                                   (Hello)//JSM//*/      
/*                                 /*****\                                                                              */
/*     Jai Shree Mataji           /       \ |\| |_| $ |-| K                                                            */
#include<vector>
#include<iostream>
#include<algorithm>                
#include<string.h>                 
#include<bits/stdc++.h>            
#include<cstring>                  
#include<map>                     
#include<cmath>                  
#include<set>
using namespace std;            
#define ll long long int        
#define ld long double
#define MOD 1000000007 
#define PI 3.1415926535897932384626433832795                                               
#define YY cout<<"YES"
#define NN cout<<"NO"
#define EE cout<<"\n"
#define ee cout<<"\n"
#define ne cout<<"-1"
#define pb push_back 
#define fi first
#define se second
#define mkp make_pair    
#define mkt make_tuple
#define sall(v ) sort(v.begin(), v.end())      
#define all(v )  v.begin(), v.end()      
#define rall(v )  reverse(v.begin(), v.end())      
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#define vl vector<ll>
#define vll vector< pair<ll,ll> > 
#define mpl map<ll, ll>
#define pr pair<ll,ll>
#define tpl tuple<ll,ll,ll>
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) {return (a.second < b.second); }
ll soltn(ll x, ll n) {if(x>=0) return x%n;    else return n+x%n;}
ll pd(ll x,ll y){if(x%y==0) return x/y;else return x/y+1;}
ll coda(ll n,ll d){ll count=0;while(n!=0){if(n%10==d)count++;n/=10;}return count;}
ll pow1(ll n,ll p){if(p==0)return 1;ll x=pow1(n, p/2);x=(x*x)%MOD;if(p%2==0) return x;else return (x*n)%MOD;}
/*vl v[300009];
ll vis[300009];
ll d;
ll ma;
ll ext;
ll up=0;
mpl M;
void dfs(ll node,ll distance)
{
	if(vis[node]==1)
	return;
	if(ma<=distance)
	{
		ma=distance;
		ext=node;
	}
	if(up==1)
	{
		if(distance==ma)
		M[node]=1;
	}
	vis[node]=1;
	for(ll i=0;i<v[node].size();i++)
	{
		ll child=v[node][i];
		dfs(child,distance+1);
	}
}*/
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);	
	  ll t=1;
      
      
//	   cin>>t;
	      while(t--)
{
//jai shree mataji
ll a,b,c;
cin>>a>>b>>c;
cout<<pd(a,b)*c;
ee;
	
}
return 0;
}














Measured memory_bytes: 3640
n = [int(x) for x in input()]
s=len(n)-1
ans=0

for i in range(2 **s):
    op = str(n[0])
    for j in range(s):
        if ((i >> j) & 1):
            op += '+'
        op+=str(n[j+1])

    ans += eval(op)

print(ans)

Measured memory_bytes: 3064
N, K = map(int, input().split())
mod = 10 ** 9 + 7

a = N - K + 1
b = 1
print(a)
for i in range(2, K+1):
    a = a * (N - K + 2 - i) // i
    b = b * (K - i + 1) // (i - 1)
    print(a * b % mod)

Measured memory_bytes: 3316
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author JustLive
 */

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

typedef long long ll;
typedef unsigned long long ull;

const int mod = 1000000007;
const int inf = 1000000000;
const ll infll = (ll)inf * (ll)inf;

class TaskD {
public:
    void solve(istream& in, ostream& out) {
        int n, h;
        in >> n >> h;
        vector<int> a(n), b(n);
        int mw = 0;
        for (int i = 0; i < n; i++) {
            in >> a[i] >> b[i];
            mw = max(a[i], mw);
        }
        vector<int> p;
        for (int i = 0; i < n; i++) {
            if (b[i] > mw) {
                p.push_back(b[i]);
            }
        }
        sort(p.begin(), p.end(), greater<>());
        int ans = 0;
        for (int i : p) {
            if (h <= 0) {
                break;
            }
            ans++;
            h -= i;
        }
        if (h > 0) {
            ans += ((h - 1) / mw) + 1;
        }
        out << ans;
    }
};


int main() {
    TaskD solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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


int main(){
    string S;
    int Q;
    cin>>S>>Q;
    vector<char> front(0);
    vector<char> back(0);
    string result="";
    bool x=true;
    for(int i=0;i<Q;i++){
        int or12;
        cin>>or12;
        if(or12==1){
            x=!x;
        }
        else if(or12==2){
            int F;
            char C;
            cin>>F>>C;
            if((F==1&&x)||(!x&&F==2)){
                front.push_back(C);
            }
            else if((F==2&&x)||(F==1&&!x)){
                back.push_back(C);
            }
        }
    }
    if(x){
        for(int i=0;i<front.size();i++){
            result+=front.at(front.size()-1-i);
        }
        result+=S;
        for(int i=0;i<back.size();i++){
            result+=back.at(i);
        }
    }
    else{
        for(int i=0;i<back.size();i++){
            result+=back.at(back.size()-1-i);
        }
        for(int i=0;i<S.size();i++){
            result+=S.at(S.size()-1-i);
        }
        for(int i=0;i<front.size();i++){
            result+=front.at(i);
        }
    }
    cout<<result<<endl;
}

Measured memory_bytes: 1496
a = str(input())
b = str(input())
a = list(a)
b = list(b)
c = len(b)-len(a)
if c == 1:
    for d in range(0, len(a)):
        if a[d] != b[d]:
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")

Measured memory_bytes: 9056
N = int(input())
S = input()
dp = [[0]*(N+1) for _ in range(N+1)]
res = 0
for i in range(N-1,-1,-1):
  for j in range(N-1,i,-1):
    if S[i]==S[j]:
      dp[i][j]=max(dp[i+1][j+1]+1,dp[i][j])
    res = max(res,min(j-i,dp[i][j]))
print(res)

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

typedef long long ll;

const int INF = 500000000;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> keys;
    vector<int> costs;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        costs.push_back(a);
        int key = 0;
        for (int j = 0; j < b; ++j) {
            int c;
            cin >> c;
            key |= (1 << (c - 1));
        }
        keys.push_back(key);
    }
    int state_n = 1 << N;
    vector<vector<int>> dp(M, vector<int>(state_n, INF));
    dp[0][0] = 0;
    dp[0][keys[0]] = costs[0];
    for (int i = 1; i < M; ++i) {
        int key = keys[i];
        int cost = costs[i];
        for (int j = 0; j < state_n; ++j) {
            dp[i][j] = min(dp[i][j], dp[i-1][j]);
            dp[i][j|key] = min(dp[i][j|key], dp[i-1][j] + cost);
        }
    }
    int ans = dp[M-1][state_n-1];
    if (ans >= INF) {
        cout << "-1\n";
    } else {
        cout << ans << "\n";
    }
    return 0;
}


Measured memory_bytes: 16256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector


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

i64 H, N; cin>> H >> N;
VI A(N); invec(A);

if (accumulate(ALL(A), 0LL) >= H) cout << "Yes\n";
else cout << "No\n";

}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



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

int main() {
	int a, b, c, d, e, f;

	while (cin >> a >> b >> c >> d >> e >> f) {
		double x, y;
		x = (double)(b*f - c*e) / (b*d - a*e);
		y = (double)(c - a*x) / b;
		if (fabs(x) < 1e-6) x = 0;
		if (fabs(y) < 1e-6) y = 0;
		cout << fixed << setprecision(3) << x << " " << y << endl;
	}
	return 0;
}

Measured memory_bytes: 3288
#include <iostream>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define MOD 1000000007
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n, w;
	cin >> n >> w;

	Matrix wv(4);

	ll w1, ww, vv;
	cin >> w1 >> vv;
	wv[0].push_back(vv);
	REP(i, n - 1) {
		cin >> ww >> vv;
		wv[ww - w1].push_back(vv);
	}

	REP(i, 4) {
		sort(all(wv[i]), greater<ll>());
	}

	Matrix sum_wv(4, Array(1, 0));

	REP(i, 4) {
		for (auto j : wv[i]) {
			sum_wv[i].push_back(sum_wv[i][sum_wv[i].size()-1]+j);
		}
	}
	//cout << "aa" << endl;

	ll ans = 0;
	for (int i = 0; i <= n &&i<sum_wv[0].size() && (w1+0)*i<=w; i++) {
		for (int j = 0; i + j <= n && j < sum_wv[1].size() && (w1 + 0) * i + (w1+1)*j <= w; j++) {
			for (int k = 0; i+j+k <= n && k < sum_wv[2].size() && (w1 + 0) * i + (w1 + 1) * j+(w1+2)*k <= w; k++) {
				for (int l = 0; i + j + k + l <= n && l < sum_wv[3].size() && (w1 + 0) * i + (w1 + 1) * j + (w1 + 2) * k + (w1+3)*l <= w; l++) {
					chmax(ans, sum_wv[0][i] + sum_wv[1][j] + sum_wv[2][k] + sum_wv[3][l]);
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
 	int i;	
  	int ans = 0;
  	int n;
  char b[3];
  
  scanf("%s",b);
  if(b[0]=='R'){
   ans++;
  }
  if(b[1]=='R'){
    ans++;
  }else{
   if(b[2]=='R'){
    printf("1");
     return 0;
   }
   }
    
  
  if(b[2]=='R'){
    ans++;
  }

  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define repitr(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;
	rep(i,(int)s.size()){
		int k = i;
		int j;
		for(j = 0; j < (int)s.size(); j++){
			if(s[k] != t[j]) break;
			k = (k+1) % s.size();
		}
		if(j == (int)s.size()){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
// Input N dan R.
// Jika N>=10, output R
// Jika tidak, output R - 100*(10-N)

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

int N, R;

int main () {
    cin >> N >> R;
    if (N >= 10) {
        cout << R << endl;
    } else {
        cout << R + 100*(10-N) << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

class UnionFind{
  private:
    vector<int> Parent;
  public:
    UnionFind(int N){
      Parent = vector<int> (N,-1);
    }

    int find(int x){
      if(Parent[x]<0)return x;
      return Parent[x] = find(Parent[x]);
    }

    int size(int x){
      return -Parent[find(x)];
    }

    bool connect(int x, int y){
      x = find(x);
      y = find(y);
      if(x == y) return false;

      if(x<y)swap(x,y);
      Parent[x] += Parent[y];
      Parent[y] = x;
      return true;
    }

    bool same(int x, int y){
      return find(x) == find(y);
    }
};

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K,L;cin >> N >> K >> L;
  UnionFind load = UnionFind(N);
  UnionFind railway = UnionFind(N);
  while(K--){
    int p,q;cin >> p >> q;
    --p;--q;
    load.connect(p,q);
  }
  while(L--){
    int r,s;cin >> r >> s;
    --r;--s;
    railway.connect(r,s);
  }
  map<PII,int> mp;
  rep(x,N)++mp[PII(load.find(x),railway.find(x))];
  rep(x,N){
    int num = mp[PII(load.find(x),railway.find(x))];
    cout << num SPF;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 13568
#include <iostream>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  if(S.length() < 26){
    for(int i = 0; i < 26; ++i){
      bool f = true;
      for(size_t j = 0; j < S.length(); ++j){
        if(S[j] == 'a' + i){
          f = false;
          break;
        }
      }
      if(f){
        cout << S << (char)('a'+i) << endl;
        return 0;
      }
    }
  }
  for(int i = 25; i > 0; --i){
    if(S[i-1] < S[i]){
      cout << S.substr(0,i-1);
      char c = S[i];
      for(int j = 25; j >= i; --j){
        if(S[j] > S[i-1]) c = min(c,S[j]);
      }
      cout << c << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}

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

const int N = 3005;
int n;
long double p[N], dp[N][N], ans;

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

  for (int i = 1; i <= n; i++)
    scanf("%Lf", p+i);

  dp[0][0] = 1; //p-bility of take exactly j heads among first i tosses

  for (int i = 1; i <= n; i++) {
    dp[i][0] = (1-p[i]) * dp[i-1][0];
    for (int j = 1; j <= i; j++)
      dp[i][j] = p[i] * dp[i-1][j-1] + (1-p[i]) * dp[i-1][j];
  }

  for (int j = (n+1)/2; j <= n; j++)
    ans += dp[n][j];

  printf("%.10Lf\n", ans);
  return 0;
}


Measured memory_bytes: 139264
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int n,a[1001],vis[1001];
int main() {
    scanf("%d",&n);
    int len=0;
    for (int i=1;i<=n;i++) {
        scanf("%d",&a[i]);
        len=max(len,a[i]);
        vis[a[i]]++;
    }
    for (int i=0;i<=len;i++) {
        int now=max(i,len-i);
        vis[now]--;
        if (vis[now]<0) {
            printf("Impossible\n");
            return 0;
        }
    }
    for (int i=0;i<=n-1;i++)
        if (vis[i]&&i<=(len+1)/2) {
            printf("Impossible\n");
            return 0;
        }
    printf("Possible\n");
    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[] a = new int[N];
    for (int i = 0; i < N; i++) {
      a[i] = sc.nextInt();
    }
    long[] leftSum = new long[N];
    long[] rightSum = new long[N];
    leftSum[0] = a[0];
    rightSum[N-1] = a[N-1];
    for (int i = 1; i < N; i++) {
      leftSum[i] = a[i] + leftSum[i-1];
      rightSum[N-1-i] = a[N-1-i] + rightSum[N-i];
    }
    
    long min = Long.MAX_VALUE;
    for (int i = 0; i < N-1; i++) {
      min = Math.min(min, Math.abs(leftSum[i]-rightSum[i+1]));
    }
    
    System.out.println(min);
  }
}

Measured memory_bytes: 64808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] arrays = br.readLine().split(" ");
		
		int x = Integer.parseInt(arrays[0]);
		int y = Integer.parseInt(arrays[1]);
		
		if(x > y){
			System.out.println(gcd(x, y));
		}
		else {
			System.out.println(gcd(y, x));
		}

	}
	static int gcd(int x, int y) {

		if (y == 0) {
			return x;
		} else {
			return gcd(y, x % y);

		}

	}
}

Measured memory_bytes: 16900
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b; cin >> a >> b;
	if (a == b)cout << a + b;
	else if (abs(a - b) == 1)cout << a + b;
	else cout << max(a, b) + max(a, b) - 1;
	

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#coding:utf-8
N,M  = map(int,input().split())
A = list(map(int,input().split()))
b = 0
c = [0,2,5,5,4,5,6,3,7,6]
bagS = [[] for i in range(N+1)]

def check2(A,B):
    p = 0
    t = 0
    # print(A)
    # print(B)
    if len(A) > len(B):
        return A
    elif len(A) < len(B):
        return B
    for a,b in zip(A,B):
        if  a- b > 0:
            return A
        elif a-b < 0:
            return B
    return A
    # for a in A:
    #     p = p*10+a
    # for b in B:
    #     t = t*10+b
    # if t > p:
    #     return B

    # else:
    #     return A

while b != N:

    for a in A:
        if b+ c[a] <= N:
  
            bagS[b+c[a]] = check2(bagS[b+c[a]],sorted((bagS[b]+[a]),reverse=True))

    for i in range(b+1,N+1):
        if bagS[i]:
            b = i
            break
print("".join(list(map(str,bagS[N]))))



Measured memory_bytes: 252552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;


namespace ABC136
{
    class Program
    {
        static void Main(string[] args)
        {
            var din = ReadInts();
            int a = din[0];
            int b = din[1];
            int c = din[2];
            int ans = c - (a - b);
            if (ans<0)
            {
                ans = 0;
            }

            WriteLine("{0}", ans);
            Read();
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

    }
}


Measured memory_bytes: 13140
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();
        if(a<b){
            System.out.println("a < b");
        }else if(a>b){
            System.out.println("a > b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26144
#include <stdio.h>
#include <string.h>

int main(void) {
  char a[110], b[110];
  scanf("%s%s", a, b);
  if(strlen(a) > strlen(b)) printf("GREATER");
  else if(strlen(a) < strlen(b)) printf("LESS");
  else printf("%s", strcmp(a, b) ? (strcmp(a, b) > 0 ? "GREATER": "LESS") : "EQUAL");
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;a++) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int p, q;
	int a[100];
	for (int i = 0; i < 100; i++) { a[i] = 0; }
	while (cin >> p >> q) {
		if(p==0&&q==0)
		{
			bool others_even = a[0]%2==1&&a[1]%2==1;
			for (int i = 2; i < 100; i++) {
				others_even = others_even && (a[i] % 2 == 0);
			}
			if (others_even) { cout << "OK" << endl; }
			else { cout << "NG" << endl; }
			for (int i = 0; i < 100; i++) { a[i] = 0; }
			continue;
		}
		a[p - 1]++;
		a[q - 1]++;
	}
	return 0;

}


Measured memory_bytes: 3096