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

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


Measured memory_bytes: 2732
import sys
sys.setrecursionlimit(100000)

N = int(input())
T = [int(input()) for i in range(N)]

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return int((a * b) // gcd(a, b))

ans = T[0]
for i in range(1, N):
    ans = lcm(ans, T[i])

print(ans)

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

using namespace std;

int main(){
  string S;
  cin >> S;
  
  if(S=="Sunny") cout << "Cloudy" << endl;
  if(S=="Cloudy") cout << "Rainy" << endl;
  if(S=="Rainy") cout << "Sunny" << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
import java.util.*;
 
class Main{
 
    void solve(){
        Scanner sc = new Scanner(System.in);
 
        while(true){
            char t = sc.next().charAt(0);
            if(t=='#') break;
 
            char[][] rank = new char[4][13];
            char[][] suit = new char[4][13]; 
            boolean[][] used = new boolean[4][13];
            for(int i=0; i<4; i++){
                for(int j=0; j<13; j++){
                    String s = sc.next();
                    rank[i][j] = s.charAt(0);
                    suit[i][j] = s.charAt(1);
                }
            }
 
            int[] point = new int[2];
            int turn = 0;
 
            char now = suit[0][0];
            for(int i=0; i<13; i++){
                char max = 'a', maxC = 'a';
                for(int j=0; j<13; j++){
                    if(!used[turn][j]){
                        now = suit[turn][j];
                        maxC = now;
                        used[turn][j] = true;
                        max = rank[turn][j];
                        break;
                    }
                }
 
                int maxidx = turn;
 
                for(int j=0; j<4; j++){
                    if(j==turn) continue;
                    int fidx = -1;
                    boolean boo = false;
                    for(int k=0; k<13; k++){
                        if(!used[j][k]){
                            if(fidx==-1) fidx = k;
                             
                            if(suit[j][k]==now){
                                boo = true;
                                used[j][k] = true;

                                if(maxC==now && max(rank[j][k], max)){
                                    max = rank[j][k];
                                    maxidx = j;
                                }
                                break;
                            }
                        }
                    }

                    if(!boo){
                        used[j][fidx] = true;
                        if(suit[j][fidx]==t){
                            if(maxC!=t || (maxC==t && max(rank[j][fidx], max))){
                                max = rank[j][fidx];
                                maxidx = j;
                                maxC = t;
                            }
                        }
                    }
                }
                point[maxidx%2]++;
                turn = maxidx;
            }
 
            int ew = point[1] - 6;
            int ns = point[0] - 6;
            if(ew>ns) System.out.println("EW "+ew);
            else System.out.println("NS "+ns);
        }
    }
 
    boolean max(char c1, char c2){
        char[] list = {'2','3','4','5','6','7','8','9','T','J','Q','K','A'};
        int idx1 = 0, idx2 = 0;
        for(int i=0; i<list.length; i++){
            if(c1==list[i]) idx1 = i;
            if(c2==list[i]) idx2 = i;
        }
 
        if(idx1>idx2) return true;
        return false;
    }
 
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 24788
package main

import (
    "fmt"
)

const mod = 1000000007

func main() {
    var n int
    fmt.Scan(&n)

    m := make(map[string][]int)
    for _, b1 := range []byte{'A', 'C', 'G', 'T'} {
        for _, b2 := range []byte{'A', 'C', 'G', 'T'} {
            for _, b3 := range []byte{'A', 'C', 'G', 'T'} {
                s := string([]byte{b1, b2, b3})
                m[s] = make([]int, 100)
                switch s {
                case "AGC", "ACG", "GAC":
                    m[s][0] = 0
                default:
                    m[s][0] = 1
                }
            }
        }
    }

    for i := 4; i <= n; i++ {
        j := i - 3
        for k := range m {
            switch k {
            case "AAC", "CAC", "TAC", "GAC":
                m["ACA"][j] += m[k][j-1]
                m["ACC"][j] += m[k][j-1]
                m["ACT"][j] += m[k][j-1]
            case "AAG", "CAG", "TAG", "GAG":
                m["AGA"][j] += m[k][j-1]
                m["AGT"][j] += m[k][j-1]
                m["AGG"][j] += m[k][j-1]
            case "ATG":
                m["TGA"][j] += m[k][j-1]
                m["TGT"][j] += m[k][j-1]
                m["TGG"][j] += m[k][j-1]
            case "AGA", "CGA", "TGA", "GGA":
                m["GAA"][j] += m[k][j-1]
                m["GAT"][j] += m[k][j-1]
                m["GAG"][j] += m[k][j-1]
            case "AGT":
                m["GTA"][j] += m[k][j-1]
                m["GTT"][j] += m[k][j-1]
                m["GTG"][j] += m[k][j-1]
            case "AGG":
                m["GGA"][j] += m[k][j-1]
                m["GGT"][j] += m[k][j-1]
                m["GGG"][j] += m[k][j-1]
            default:
                end := k[1:3]
                m[end+"A"][j] += m[k][j-1]
                m[end+"C"][j] += m[k][j-1]
                m[end+"T"][j] += m[k][j-1]
                m[end+"G"][j] += m[k][j-1]
            }
        }
        for k := range m {
            m[k][j] = (m[k][j] + mod) % mod
        }
    }
    var sum int
    for _, v := range m {
        sum += v[n-3]
    }
    sum = sum % mod
    fmt.Println(sum)
}


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

using namespace std;

typedef long long ll;

const int N = 400400;
const int Mod = 1e9 + 7;

int Inv[N];
int Fact[N];
int iFact[N];

void add_self(int& x, int y)
{
    if((x += y) >= Mod) x -= Mod;
}

void sub_self(int& x, int y)
{
    if((x -= y) < 0)    x += Mod;
}

int mul(int x, int y)
{
    return (ll) x * y % Mod;
}

int fp(int x, int y)
{
    int Res = 1;

    for( ; y > 0; y >>= 1, x = mul(x, x))
        if(y & 1)
            Res = mul(Res, x);

    return Res;
}

int C(int n, int r)
{
    if(n < 0 || r < 0 || n < r) return 0;
    return mul(Fact[n], mul(iFact[r], iFact[n - r]));
}

int Ways(int n, int m)
{
    if(n < 0 || m < 0)  return 0;
    return C(n + m - 1, m);
}

int main()
{
    Inv[1] = 1;
    for(int i = 2; i < N; i++)  Inv[i] = (Mod - mul(Mod / i, Inv[Mod % i])) % Mod;

    Fact[0] = iFact[0] = 1;
    for(int i = 1; i < N; i++)  Fact[i] = mul(i, Fact[i - 1]);
    for(int i = 1; i < N; i++)  iFact[i] = mul(Inv[i], iFact[i - 1]);

    int n, k;   cin >> n >> k;

    int Ans = 0;

    for(int i = 0; i <= min(n - 1, k); i++)
    {
        add_self(Ans, mul(C(n, i), Ways(n - i, i)));
    }

    cout << Ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
int main(){

    vector<pair<int,int>> v1;
    vector<pair<int,int>> v2;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v1.push_back(make_pair(a,b));
    }
    sort(v1.begin(),v1.end());
    
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v2.push_back(make_pair(a,b));
    }
    sort(v2.begin(),v2.end());
    int long long  ans=0;
    for(int i=0;i<v2.size();i++){
        int b=v2[i].second;
        int a=v2[i].first;
        
        int j=0;
        int jj=0;
        int mx=10000;
        while(j!=v1.size()){
            if(v1[j].second<b&&v1[j].first<a){
                int sa=b-v1[j].second;
                if(sa<mx){
                    mx=sa;
                    jj=j;
                }
            }
            j++;
        }
        if(mx!=10000){
            ans++;
           
            v1[jj].first=1000;
            v1[jj].second=1000;
        }
    }
    cout<<ans<<endl;
    



return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>

using namespace std;


int main()
{

	vector<pair<int,string> > res;

	while(1){
		int n;
		map<int,int> time;
		map<string,vector<int> > man;
		map<string,int> rank;
		cin >> n;

		if(n==0) goto end;

		for(int i=0;i<n;i++)
		{
			string name;
			cin >> name;
			int m;
			cin >> m;
			if(m==0) rank[name]=0;
			for(int j=0;j<m;j++)
			{
				int t;
				cin >> t; 
				time[t]++;
				man[name].push_back(t);
			}
		}

		for(map<string,vector<int> >::iterator it = man.begin();it != man.end();it++)
		{
			for(int i=0;i<it->second.size();i++)
			{
				rank[it->first]+=n-time[it->second[i]]+1;
			}
		}

		int respts = numeric_limits<int>::max();;
		string resname;

		for(map<string,int>::iterator it = rank.begin();it != rank.end();it++)
		{
			if(it->second < respts)
			{
				respts = it->second;
				resname = it->first;
			}
		}

		res.push_back(pair<int,string>(respts,resname));
	}

	end:;
	for(int i=0;i<res.size();i++)
	{
		cout << res[i].first << " " << res[i].second << endl;
	}

	return 0;

}

Measured memory_bytes: 1256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
using namespace std;

template< typename T >
vector< T > convert_base(T x, T b) {
  vector< T > ret;
  T t = 1, k = abs(b);
  while(x) {
    ret.emplace_back((x * t) % k);
    if(ret.back() < 0) ret.back() += k;
    x -= ret.back() * t;
    x /= k;
    t *= b / k;
  }
  if(ret.empty()) ret.emplace_back(0);
  reverse(begin(ret), end(ret));
  return ret;
}

void solve(){
    string s;
    cin>>s;
    int cnt=0;
    rep(i,s.size()){
        if(s[i]=='1')++cnt;
    }
    cout<<cnt<<"\n";
}
 
 
signed main(){
	ios::sync_with_stdio(false);
        cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

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

    int a, b;
    cin >> a >> b;
    cout << a*b-a-b+1 << endl;
    return 0;
}

Measured memory_bytes: 256
def arrow(cur, arr)
  return case arr[cur[0]][cur[1]]
  when ">"
    vec_sum(cur, [0, 1])
  when "<"
    vec_sum(cur, [0, -1])
  when "^"
    vec_sum(cur, [-1, 0])
  when "v"
    vec_sum(cur, [1, 0])
  end
end

def vec_sum(v1, v2)
  return [v1[0] + v2[0], v1[1] + v2[1]]
end

loop do
  arr, path, cur = [], [], [0, 0]
  h, w = gets.split.map(&:to_i)
  
  break if h == 0 && w == 0
  
  h.times do |i|    
    arr[i] = gets.chomp.split("")
  end

  loop do
    if arr[cur[0]][cur[1]] == "."
      puts cur.reverse.join(" ")
      break
    elsif path.include?(cur)
      puts "LOOP"
      break
    end
  
    path << cur
    cur = arrow(cur, arr)
  end
end

Measured memory_bytes: 6676
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        aa: [i64; n],
    }

    let mut flags = 0u8;
    let mut joker = 0;
    for a in aa {
        let num = if a < 400 {
            0
        } else if a < 800 {
            1
        } else if a < 1200 {
            2
        } else if a < 1600 {
            3
        } else if a < 2000 {
            4
        } else if a < 2400 {
            5
        } else if a < 2800 {
            6
        } else {
            7
        };

        if a >= 3200 {
            joker += 1;
        } else {
            flags = flags | 1 << num;
        }
    }

    let not_joker = flags.count_ones();
    let min_a = if not_joker == 0 && joker > 0 {
        1
    } else {
        not_joker
    };
    let max_a = not_joker + joker;

    println!("{} {}", min_a, max_a);
}


Measured memory_bytes: 4352
n,k=map(int,input().split())
dl=[]
ul=[]
for i in range(k):
    dl.append(int(input()))
    f=list(map(int,input().split()))
    ul.extend(f)
res=0
for i in range(1,n+1):
    if not i in set(ul):
        res+=1
print(res)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t,c;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    ll ans=0;
    for(i=0;i<n-1;i++) 
    {
        if(arr[i]>arr[i+1])
        {
            ans+=arr[i]-arr[i+1];
            arr[i+1]=arr[i];
        }
    }
    cout<<ans;
}

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

struct Point{
  int x;
  int y;
}typedef point;

bool contain(point* p1, point* p2, point* p3, point* p);

int main(void){
  int n;
  cin>>n;
  int xp1,yp1,xp2,yp2,xp3,yp3,xk,yk,xs,ys;
  point p1,p2,p3,pk,ps;
  bool s,k;
  for(int i=0;i<n;i++){
    cin>>xp1>>yp1>>xp2>>yp2>>xp3>>yp3>>xk>>yk>>xs>>ys;
    p1.x=xp1;
    p1.y=yp1;
    p2.x=xp2;
    p2.y=yp2;
    p3.x=xp3;
    p3.y=yp3;
    pk.x=xk;
    pk.y=yk;
    ps.x=xs;
    ps.y=ys;
    s=contain(&p1,&p2,&p3,&ps);
    k=contain(&p1,&p2,&p3,&pk);
    if(s==k){
      cout<<"NG"<<endl;
    }
    else{
      cout<<"OK"<<endl;
    }
  }
  return 0;
}

bool contain(point* p1, point* p2, point* p3, point* p){
  int z1=0;
  int z2=0;
  z1+=(p1->x-p->x)*(p2->y-p->y)-(p2->x-p->x)*(p1->y-p->y);
  z2+=abs((p1->x-p->x)*(p2->y-p->y)-(p2->x-p->x)*(p1->y-p->y));
  z1+=(p2->x-p->x)*(p3->y-p->y)-(p3->x-p->x)*(p2->y-p->y);
  z2+=abs((p2->x-p->x)*(p3->y-p->y)-(p3->x-p->x)*(p2->y-p->y));
  z1+=(p3->x-p->x)*(p1->y-p->y)-(p1->x-p->x)*(p3->y-p->y);
  z2+=abs((p3->x-p->x)*(p1->y-p->y)-(p1->x-p->x)*(p3->y-p->y));
  if(abs(z1)==z2){
    return true;
  }
  else{
    return false;
  }
}



Measured memory_bytes: 3088
package main

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

func main() {
	n := readInt64()
	k := int(readInt64())
	a := readInt64Slice(n)

	for i := 0; i < k; i++ {

		b := make([]int64, n+1)
		for j := int64(0); j < n; j++ {
			l := max(0, j-a[j])
			r := min(n, j+a[j]+1)
			b[l]++
			b[r]--
		}

		for j := int64(0); j < n; j++ {
			if j == 0 {
				continue
			}
			b[j] += b[j-1]
		}

		if reflect.DeepEqual(a, b[0:n]) {
			break
		}

		a = b[0:n]

	}

	s := fmt.Sprint(a)
	fmt.Println(string([]rune(s)[1 : len(s)-1]))
}

var (
	scanner *bufio.Scanner
)

func init() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

func readInt64() int64 {
	var t string

	if scanner.Scan() {
		t = scanner.Text()
	}

	n, err := strconv.ParseInt(t, 10, 64)
	if err != nil {
		log.Fatal(err)
	}

	return n

}

func readInt64Slice(n int64) []int64 {
	s := make([]int64, n)
	var t string

	for i := 0; i < int(n); i++ {
		if scanner.Scan() {
			t = scanner.Text()
		}

		num, err := strconv.ParseInt(t, 10, 64)
		if err != nil {
			log.Fatal(err)
		}
		s[i] = num
	}

	return s
}

func max(x, y int64) int64 {
	if x > y {
		return x
	}
	return y
}

func min(x, y int64) int64 {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 18752
#include <iostream>
using namespace std;
int main()
{
  int N;
  cin >> N;
  long L[N + 1];
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; i++)
  {
    L[i] = L[i - 1] + L[i - 2];
  }
  cout << L[N] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string str[100] = { "KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA","AKIHABR",
"AKIHBAR","AKIHBRA","KIHABAR","KIHABRA","KIHBARA",
"AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA","AKIHABARA" }, s;
int main()
{
    cin >> s;
    for (int i = 0; i < 16; i++)
    {
        if (s == str[i])
        {
            cout << "YES";
            return 0;
        }
    }
    cout << "NO";
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

const MOD = 1000000007

func main() {
	var N, M, a int
	fmt.Scan(&N)
	fmt.Scan(&M)

	var as []int
	for i := 0; i < M; i++ {
		fmt.Scan(&a)
		as = append(as, a)
	}

	res := 1
	for i := 0; i < M; i++ {
		n := 0
		if i == 0 {
			n = as[i] - 1
		} else {
			n =  as[i] - as[i - 1] - 2
		}

		if n < 0 {
			fmt.Println(0)
			return
		}

		res *= fib(n) % MOD
		res = res % MOD
	}

	if M > 0 {
		res *= fib(N- as[M-1] -1) % MOD
		res = res % MOD
	} else {
		res *= fib(N) % MOD
		res = res % MOD
	}

	fmt.Println(res)
}

func fib(N int) int {
	if N < 2 {
		return 1
	}

	n1, n2, f := 1, 1, 1

	for i := 0; i < N - 1; i++ {
		f = (n1 + n2) % MOD
		n1 = n2 % MOD
		n2 = f % MOD
	}

	return f
}

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define fi first
#define se second
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }

ll mod = 1000000007;

int dp[210][210];

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<char> a(n);
	rep(i, n) cin >> a[i];
	dp[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			if (a[i - 1] == '-') {
				dp[i][j] = dp[i - 1][j];
			}
			else if (a[i - 1] == 'U') {
				if (j != 0) dp[i][j] += dp[i - 1][j - 1];
				dp[i][j] += dp[i - 1][j] * j;
				dp[i][j] %= mod;
			}
			else {
				dp[i][j] += dp[i - 1][j] * j;
				dp[i][j] += dp[i - 1][j + 1] * (j + 1)*(j + 1);
				dp[i][j] %= mod;
			}
		}
	}
	cout << dp[n][0] << endl;
}



Measured memory_bytes: 3464
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt
    val ps = in.readLine().split("\\s+").map(_.toInt)

    var min = Integer.MAX_VALUE
    var count = 0

    ps.foreach { p =>
      if ( min > p ) {
        count += 1
        min = p
      }
    }

    System.out.println(
      count
    )
  }
}


Measured memory_bytes: 53068
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    string str;
    cin >> str;
    int num = str.size();
    vector<char> a(num);
    for(int i=0;i<str.size();i++){
           a[i]=str[i]+n;
           if(a[i]>'Z'){
               a[i] = (a[i]-'Z'-1)+'A';
           }
    }
    for(int i=0;i<str.size();i++)    cout << a[i];
}   

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}

func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	n := iScan()
	a := iSScan(n)
	fmt.Println(max(a) - min(a))
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;


int main (){
  int n; cin >> n;
  vector<int> v(n, 0);

  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());

  int cnt = 0;

  for(int i = 0; i < n-2; i++){
    for(int j = i+1; j < n-1; j++){
      for(int k = j+1; k < n; k++){
        if(v[i] + v[j] > v[k]){cnt++;}
      }
    }
  }
 cout << cnt << endl;
}

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

public class Main {
	static Scanner in;
	static PrintWriter out;
	static String INPUT = "";

	static int count(int r1, int c1, int r2, int c2)
	{
		out.printf("? %d %d %d %d\n", r1, c1, r2, c2);
		out.flush();
		return ni();
	}
	
	static void end(boolean[][] map, int mod)
	{
		long h = 0;
		long t = 1;
		for(int i = 0;i < map.length;i++){
			for(int j = 0;j < map[0].length;j++){
				h += (map[i][j] ? 1 : 0) * t;
				h %= mod;
				t = t * 2 % mod;
			}
		}
		out.println("! " + h);
		out.flush();
	}
	
	static void solve()
	{
		int h = ni(), w = ni(), n = ni(), K = ni();
		boolean[][] map = new boolean[h][w];
		dfs(0, h, 0, w, n, map);
		end(map, K);
	}
	
	static void fill(int r1, int r2, int c1, int c2, boolean[][] map)
	{
		for(int k = r1;k < r2;k++){
			for(int l = c1;l < c2;l++){
				map[k][l] = true;
			}
		}
	}
	
	static void dfs(int r1, int r2, int c1, int c2, int n, boolean[][] map)
	{
		if(n == (r2-r1)*(c2-c1)){
			fill(r1, r2, c1, c2, map);
			return;
		}
		if(r2-r1 > c2-c1){
			int hr = (r1+r2)/2;
			int co = count(r1, c1, hr-1, c2-1);
			if(co > 0){
				dfs(r1, hr, c1, c2, co, map);
			}
			if(n-co > 0){
				dfs(hr, r2, c1, c2, n-co, map);
			}
		}else{
			int hc = (c1+c2)/2;
			int co = count(r1, c1, r2-1, hc-1);
			if(co > 0){
				dfs(r1, r2, c1, hc, co, map);
			}
			if(n-co > 0){
				dfs(r1, r2, hc, c2, n-co, map);
			}
		}
	}
	
	public static void main(String[] args) throws Exception
	{
		in = INPUT.isEmpty() ? new Scanner(System.in) : new Scanner(INPUT);
		out = new PrintWriter(System.out);
		
		solve();
		out.flush();
	}
	
	static int ni() { return Integer.parseInt(in.next()); }
	static long nl() { return Long.parseLong(in.next()); }
	static double nd() { return Double.parseDouble(in.next()); }
	static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}


Measured memory_bytes: 20856
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


struct Ans { int a, b, c, d; };

int main() {
	int H, W; cin >> H >> W;
	vector<vector<int>> a(H + 2, vector<int>(W + 2));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> a[i][j];
		}
	}
	vector<Ans> ans;
	for (int i = 0; i < H; i++) {
		if (i & 1) {
			for (int j = W - 1; j > 0; j--) {
				if (a[i][j] & 1) {
					a[i][j]--;
					a[i][j - 1]++;
					ans.push_back({ i, j, i, j - 1 });
				}
			}
			if ((a[i][0] & 1) && i < H - 1) {
				a[i][0]--;
				a[i + 1][0]++;
				ans.push_back({ i, 0, i + 1, 0 });
			}
		}
		else {
			for (int j = 0; j < W - 1; j++) {
				if (a[i][j] & 1) {
					a[i][j]--;
					a[i][j + 1]++;
					ans.push_back({ i, j, i, j + 1 });
				}
			}
			if ((a[i][W - 1] & 1) && i < H - 1) {
				a[i][W - 1]--;
				a[i + 1][W - 1]++;
				ans.push_back({ i, W - 1, i + 1, W - 1 });
			}
		}
	}
	cout << ans.size() << endl;
	for (auto &a : ans) {
		cout << a.a + 1 << " " << a.b + 1 << " " << a.c + 1 << " " << a.d + 1 << endl;
	}
	return 0;
}


Measured memory_bytes: 5232
from collections import defaultdict
def dfs(here, track, went, connect):
    for c in connect[here]:
        if track[c]:
            return True
        elif c not in went:
            went |= {c}
            track[c] = 1
            if dfs(c, track, went, connect):
                return True
    track[here] = 0
    return False

vertices, edges = (int(n) for n in input().split(" "))
connect = defaultdict(list)
for _ in range(edges):
    v1, v2 = (int(n) for n in input().split(" "))
    connect[v1].append(v2)
went = set()
track = [0 for n in range(vertices)]
for v in range(vertices):
    if v not in went and dfs(v, track, went, connect):
        print(1)
        break
else:
    print(0)

Measured memory_bytes: 8112
#include<stdio.h>
#include<string.h>
#define N 36
int main(){

  int i,j,n,min,flag=0;
  int swap,N1[N],N2[N];
  char tmp,data1[N][2],data2[N][2];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    N1[i]=i;
    scanf("%s",&data1[i]);
  }
  for(i=0;i<n;i++){
    N2[i]=i;
    strcpy(data2[i],data1[i]);
  }
  
  /*Bubble sort*/
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(data1[j][1]-'0'<data1[j-1][1]-'0'){
	tmp=data1[j][1];
	data1[j][1]=data1[j-1][1];
	data1[j-1][1]=tmp;
	tmp=data1[j][0];
	data1[j][0]=data1[j-1][0];
	data1[j-1][0]=tmp;
	swap=N1[j];
	N1[j]=N1[j-1];
	N1[j-1]=swap;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%c%c\n",data1[i][0],data1[i][1]);
    }
    else{
      printf("%c%c ",data1[i][0],data1[i][1]);
    }
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(data1[i][1]==data1[j][1] && N1[i]>N1[j]){
	flag=1;
	break;
      }
    }
    if(flag==1) break;
  }
  if(flag==1) printf("Not stable\n");
  else printf("Stable\n");
  flag=0;
  
  /*Selection sort*/
  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++){
      if(data2[j][1]-'0'<data2[min][1]-'0'){
	min=j;
      }
    }
    tmp=data2[i][1];
    data2[i][1]=data2[min][1];
    data2[min][1]=tmp;
    tmp=data2[i][0];
    data2[i][0]=data2[min][0];
    data2[min][0]=tmp;
    swap=N2[i];
    N2[i]=N2[min];
    N2[min]=swap;
  }
  for(i=0;i<n;i++){
    if(i==n-1){
      printf("%c%c\n",data2[i][0],data2[i][1]);
    }
    else{
      printf("%c%c ",data2[i][0],data2[i][1]);
    }
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      if(data2[i][1]==data2[j][1] && N2[i]>N2[j]){
	flag=1;
	break;
      }
    }
    if(flag==1) break;
  }
  if(flag==1) printf("Not stable\n");
  else printf("Stable\n");

  return 0;
}



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

using namespace std;

#define endl '\n'
#define ll long long

const ll mod = 1e9 + 7;
const ll maxn = 2e5 + 5;
const double pi = 3.1415926535897932384626433832795028841971693993751058209749445923078;
//iostream::sync_with_stdio(false);

int main()
{
	ll n, k;
	cin >> n >> k;
	if (n == k)
	{
		cout << 0 << endl;
	}
	else if (n < k)
	{
		if (n <= k / 2)
		{
			cout << n << endl;
		}
		else
		{
			cout << k - n << endl;
		}
	}
	else
	{
		n = n % k;
		if (n <= k / 2)
		{
			cout << n << endl;
		}
		else
		{
			cout << k - n << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define qwq(x) cout<<"# "<<#x<<" = "<<x<<endl;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define f(x,y) g[(x)][(y)+52]
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
 
template<class T> inline void read(T &x){
	int f=0;x=0;char ch=getchar();
	for(;!isdigit(ch);ch=getchar())f|=(ch=='-');
	for(;isdigit(ch);ch=getchar())x=x*10+ch-'0';
	if(f)x=-x;
}

const int N=1005;
int f[N][N],n,d1,d2,cnt;

void doit(int d){
	int k=1;
	while(d%4==0)d>>=2,k<<=1;
	REP(i,n*2)REP(j,n*2)
		f[i][j]+=(d&1)&&(i/k+j/k)%2==0||!(d&1)&&i/k%2==0;
}

int main(){
	read(n),read(d1),read(d2);
	doit(d1),doit(d2);
	REP(i,n*2)REP(j,n*2)
		if(f[i][j]==2&&cnt<n*n)
			printf("%d %d\n",i,j),++cnt;
	return 0;
}

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

int main() {
  int a,b,c,d,e,k ;
  cin >>a>>b>>c>>d>>e>>k ;
  if ( e-a <= k) {
    cout << "Yay!" << endl;
  }
  else{
  cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
import numpy as np
from itertools import combinations_with_replacement

N = int(input())
S = input()

rgb = 'RGB'

nr = S.count(rgb[0])
ng = S.count(rgb[1])
nb = N - nr - ng
nlst = np.array([nr, ng, nb])

nmax = np.argmax(nlst)
nmin = np.argmin(nlst)
if nmax == nmin:nmin = 2

minlst, midlst = [], []
maxlst = [0]*N

for i, s in enumerate(S):
    if s==rgb[nmax]:maxlst[i] = 1
    elif s==rgb[nmin]:minlst.append(i)
    else: midlst.append(i)
minlst.sort()
midlst.sort()
      
ans = 0

for midl in midlst:
    for minl in minlst:
        mm = abs(midl - minl)
        mmin = min(minl, midl) - mm
        mmax = max(minl, midl) + mm
        if mmin >= 0:
            if maxlst[mmin]: ans += 1
        if mmax <= N-1:
            if maxlst[mmax]: ans += 1
        if mm % 2 == 0 and maxlst[(minl + midl) // 2]: ans += 1
print(nr * ng * nb - ans)
        

Measured memory_bytes: 27336
import java.util.*;

class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		
		int input_num = sc.nextInt();
		HashMap<String, Integer> map = new HashMap<String, Integer>();
		
		//単語の入力とカウント
		for(int i=0;i<input_num;i++){
			String str = sc.next();
			if(map.get(str) == null){
				map.put(str, 1);
			}else{
				map.put(str, map.get(str) + 1);
			}
		}
		
		int max = 0;
		for (int val : map.values()) {
			if(val > max) max = val;
		}
		
		List<String> list = new ArrayList<String>();
		
		for (String key : map.keySet()) {
			if(map.get(key) == max) list.add(key);
		}
		
		Collections.sort(list);
		for(int i=0;i<list.size();i++){
			System.out.println(list.get(i));
		}
		
		
	}
}
		
		


Measured memory_bytes: 83396
//Bismillahir Rahmanir Raheem
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    vector<long long int> ar(150002);
    int n,sign = 0;
    cin>>n;
    long long a,s=0;
    long long int min = 1000000007;
    for(int i=0;i<n;i++){
        cin>>a;
        s+=abs(a);
        if(abs(a)<min){
            min = abs(a);
        }
        if(a<0) sign++;
    }
    if(sign%2==1) s-=(2*min);
    //cout<<sign<<" "<<min<<endl;

    cout<<s<<endl;
    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
using namespace std;
 
int main()
{
  
  int a,b;
  
  cin >> a >> b;
  
  if(a == 1){
  a = 14;
  }
  if(b == 1){
  b = 14;
  }
  
  if(a > b) {
    cout << "Alice" << endl;
  } else if(b > a){
  cout << "Bob" << endl;
  }else if(a == b){
  cout << "Draw" << endl;
  }
  
  else {
    cout << "Draw" << endl;
  }
}

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

#define ll long long

using namespace std;

ll INF = (ll) 1e20;
int iINF = (int) 1e20;
ll mod = (ll) 1e9 + 7;

mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
    ll n;
    cin >> n;
    map <string, int> mp;
    for(int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << '\n';
    cout << "WA x " << mp["WA"] << '\n';
    cout << "TLE x " << mp["TLE"] << '\n';
    cout << "RE x " << mp["RE"] << '\n';
}

Measured memory_bytes: 3632
import scala.annotation.tailrec
import scala.collection.mutable
import scala.io.StdIn._
object Main extends App {
  val memo = Array.fill(31){-1L}
  loop()
  @tailrec def loop(): Unit = {
    val n = readInt()
    if (n == 0) return
    println(((solve(n) + 9) / 10 + 364) / 365)
    loop()
  }
  def solve(n: Int): Long = {
    if (n < 0) {
      0
    } else if (n == 0) {
      1
    } else {
      if (memo(n) < 0) {
        memo(n) = solve(n - 1) + solve(n - 2) + solve(n - 3)
      }
      memo(n)
    }
  }
}



Measured memory_bytes: 43824
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch GCDOnBlackboard | diff GCDOnBlackboard.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address GCDOnBlackboard.cpp && ./a.out

/*
 
 3/28/2020
 
 17:38-
 
 */

const int MAX_N=1e6+1;
LL A[MAX_N];
int N;

vector<LL> divisors(LL N) {
  assert(N>=1);
  vector<LL> res;
  for(LL p=1; p*p<=N; ++p) if(N%p==0) {
    res.push_back(p);
    if(p!=N/p) res.push_back(N/p);
  }
  sort(res.begin(),res.end());
  return res;
}

LL f(vector<LL> ds) {
  LL res=1;
  FORR(d,ds) {
    int cnt=0;
    REP(i,N) {
      LL a=A[i];
      cnt+=a%d!=0;
    }
    if(cnt<=1) SMAX(res,d);
  }
  return res;
}

void solve() {
  vector<LL> divs1=divisors(A[0]),divs2=divisors(A[1]);
  LL res1=f(divs1),res2=f(divs2);
  cout<<max(res1,res2)<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  REP(i,N) cin>>A[i];
  solve();
  
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int q;
    cin >> q;
    int a, x, y;
    set<int> s;
    while(q--){
        cin >> a >> x;
        if(a==0){
            s.insert(x);
            cout << s.size() << "\n";
        }else if(a==1){
            cout << s.count(x) << "\n";
        }else if(a==2){
            s.erase(x);
        }else{
            cin >> y;
            set<int>:: iterator start, end;
            end=s.upper_bound(y);
            for(start=s.lower_bound(x); start!=end; start++){
                cout << *start << "\n";
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 12380
#include <stdio.h>
 
int isprime(int n) {
    int i;
    for(i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            return 0;
        }
    }
    return 1;
}
 
int main() {
    int n,i;
    int ans[2];
    int prime[10100][2];
    for (i = 0; i < 10100; i++) {
        prime[i][0] = i;
        prime[i][1] = isprime(i);
    }
    while(1) {
        ans[0] = 0;
        ans[1] = 0;    
        scanf("%d",&n);
        if(n == 0) {
            break;
        }
        for(i = n; i > 2; i--) {
            if(prime[i][1] == 1 && prime[i - 2][1] == 1) {
                ans[0] = prime[i - 2][0];
                ans[1] = prime[i][0];
                break;
            }
        }
        printf("%d %d\n",ans[0],ans[1]);
    }
    return 0;
}

Measured memory_bytes: 2628
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}

int N, M;
Vec< Vec< int > > edges;

void solve() {
	queue< int > que;
	que.push(0);
	
	vector< bool > vis(N, false);
	vis[0] = true;
	
	for_(rep,0,3) {
		queue< int > nxt_que;
		
		while (!que.empty()) {
			int v = que.front(); que.pop();
			
			if (rep == 2 && v == N - 1) {
				puts("POSSIBLE");
				return;
			}
			
			for (int u : edges[v]) {
				if (vis[u]) continue;
				vis[u] = true;
				nxt_que.push(u);
			}
		}
		
		swap(nxt_que, que);
	}
	
	puts("IMPOSSIBLE");
}

int main() {
	cin >> N >> M;
	edges.assign(N, vector< int >());
	
	for_(i,0,M) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	
	solve();
}

Measured memory_bytes: 12400
import std.stdio;
import std.string;
import std.algorithm;


void main() {
    foreach (input; stdin.byLine) {
        // 勝敗を判定
        string result = judge(input.chomp);

        // 結果を出力
        result.writeln;
    }
}

string judge(char[] banmen) {
    // 勝ち筋
    auto combs = [[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]];

    // それぞれの配置を取得
    auto areas = ["o":getArea(banmen, 'o'), "x":getArea(banmen, 'x')];

    // 各々の配置が勝ち筋に沿っていれば、その記号を返す
    foreach(key; areas.keys) {
        foreach(comb; combs) {
            if(canFind(areas[key], comb[0]) &&
               canFind(areas[key], comb[1]) &&
               canFind(areas[key], comb[2])) return key;
        }
    }

    // どちらも勝ち筋に沿っていない場合はドローの記号を返す
    return "d";
}

int[] getArea(char[] banmen, char side) {
    int[] area = [];
    foreach (i; 0..9) {
        if(banmen[i] == side) { area ~= i; }
    }
    return area;
}

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

int main(){
  ll k;
  cin >> k;
  ll n = k/50;
  ll m = k%50;
  vector<ll> ans(50, n+49);
  rep(i, 50){
    if(i < m) ans.at(i)++;
    else ans.at(i) -= m;
  }
  cout << 50 << endl;
  rep(i, 50){
    if(i != 0) cout << " ";
    cout << ans.at(i);
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define rep(n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for (int i=0;i<(n);i++)
#define rep3(i,a,b) for (int i=a;i<(b);i++)
#define out(ans) cout << ans << endl;
#define outs(ans) cout << ans;
using ll = long long;

int main(){

    //imput n, a(n), b(n)
    int a, p;
    cin >> a>>p;

    //main process
    int ans;
    ans=floor((a*3+p)/2);

    out(ans)
}





Measured memory_bytes: 256
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final long N = sc.nextInt();
		out.println((N-1)*N/2);
	}
}


Measured memory_bytes: 23124
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

char map[100][100]={{0}};
int check[100][100]={{0}};
int n,m,robots=0;
int dist[11][11]={0};
int pos[11][2]={0};
int queue[1000][3]={{0}}, st,ed;
int dp[1024][10]={0};
void clean_check(){
    int i,j;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++) check[i][j] = 0;
    }
}
bool input(){
    int i,j;
    scanf("%d%d",&m,&n);
    robots = 0;
    if(m==0 || n==0) return false;
    for(i=0;i<n;i++){
        scanf("%s",map[i]);
        for(j=0;j<m;j++){
            if(map[i][j] == '*'){
                map[i][j] = robots + '0';
                robots++;
                pos[robots][0] = i;
                pos[robots][1] = j;
            }
            else if(map[i][j] == 'o'){
                pos[0][0] = i;
                pos[0][1] = j;
            }
        }
    }
    return true;
}
bool bfs(){
    int i,j;
    for(i=0;i<=robots;i++){
        clean_check();
        queue[0][0] = pos[i][0], queue[0][1] = pos[i][1];
        check[pos[i][0]][pos[i][1]] = -1;
        queue[0][2] = 0;
        st=0,ed=1;
        while(st<ed){
            int x = queue[st][0], y = queue[st][1];
            int go[4][2] = {1,0,-1,0,0,1,0,-1};
            for(j=0;j<4;j++){
                if(x+go[j][0]>=0 && x+go[j][0]<n && y+go[j][1]>=0 && y+go[j][1]<m && map[x+go[j][0]][y+go[j][1]] != 'x' && !check[x+go[j][0]][y+go[j][1]]){
                    queue[ed][0] = x+go[j][0], queue[ed][1] = y+go[j][1];
                    queue[ed][2] = queue[st][2]+1;
                    check[queue[ed][0]][queue[ed][1]] = queue[ed][2];
                    ed++;
                }
            }
            st++;
        }
        for(j=0;j<=robots;j++){
            if(i==j) continue;
            dist[i][j] = check[pos[j][0]][pos[j][1]];
            if(dist[i][j] == 0){
                return false;
            }
        }
    }
    return true;
}
void do_dp(int idx){
    int i,j;
    for(i=0;i<robots;i++){
        if((1<<i) & idx){
            dp[idx][i] = 2147480000;
            for(j=0;j<robots;j++){
                if(i==j)continue;
                if((1<<j) & idx){
                    dp[idx][i] = min(dp[idx][i], dp[idx^(1<<i)][j] + dist[i+1][j+1]);
                }
            }
        }
    }
}
int main()
{
    while(input()){
        int i,j,ans=2147480000;
        if(robots == 0){
            printf("0\n");
            continue;
        }
        if(!bfs()){
            printf("-1\n");
            continue;
        }
        if(robots == 1){
            printf("%d\n",dist[0][1]);
            continue;
        }
        for(i=0;i<robots;i++){
            dp[1<<i][i] = dist[0][i+1];
        }
        for(i=3;i<(1<<robots);i = (i<<1)|1){
            j = i;
            do{
                do_dp(j);
                int temp = j + (j&-j);
                j = (( ((temp & -temp) / (j & -j)) >> 1 ) - 1) | temp;
            }while(j<(1<<robots));
        }
        for(i=0;i<robots;i++){
            ans = min(ans, dp[(1<<robots)-1][i]);
        }
        printf("%d\n", ans);
    }

    return 0;
}

Measured memory_bytes: 1084