akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
using namespace std;
const int DIGIT=9;

int main() {
  int n;
  char buf[82];
  int l, x[2], y, z;
  char buf_part[DIGIT+1];
  int a[2][9];
  int b[9];
  bool overflow_flg;

  cin >> n;
  while (n--) {
    overflow_flg = false;
    for (int i=0; i<2; i++) {
      fscanf(stdin, "%81s", buf);
      l = strlen(buf);
      if (l > 80) {
        overflow_flg = true;
        while (getchar() != '\n');
        continue;
      }
      x[i] = (l+DIGIT-1)/DIGIT;
      y = (l-1)%DIGIT+1;
      for (int j=0; j<9; j++) {
        a[i][j] = 0;
      }
      for (int j=0; j<x[i]; j++) {
        if (!j) {
          memcpy(buf_part, buf, y);
          buf_part[y] = '\0';
        } else {
          memcpy(buf_part, &buf[y+DIGIT*(j-1)], DIGIT);
          buf_part[DIGIT] = '\0';
        }
        a[i][x[i]-j-1] = atoi(buf_part);
      }
    }
    if (overflow_flg) {
      cout << "overflow" << endl;
      continue;
    }

    for (int i=0; i<9; i++) b[i] = 0;
    z = (x[0] > x[1]) ? x[0] : x[1];
    for (int i=0; i<z; i++) {
      b[i] = a[0][i] + a[1][i];
      if (b[i] >= 1000000000) {
        a[0][i+1]++;
        b[i] -= 1000000000;
      }
    }
    if (z<9 && a[0][z]) {
      b[z] = a[0][z]+a[1][z];
      ++z;
    }
    if (b[8] >= 100000000) {
      cout << "overflow" << endl;
    } else {
      cout << b[z-1];
      for (int i=z-2; i>=0; i--) {
        cout.fill('0');
        cout.width(DIGIT);
        cout << b[i];
      }
      cout << endl;
    }
  }
  return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    int N; cin >> N;
    VI h(N); REP(i,N) cin >> h[i];
    int mx = 0; REP(i,N) chmax(mx,h[i]);
    int ans = 0;
    REP(i,mx){
        int tmp = 0;
        REP(j,N){
            while(j<N && h[j]==0) j++;
            if(j==N) continue;
            while(j<N && h[j]!=0) h[j++]--;
            tmp++;
        }
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main() {
    int n;
    while(cin>>n){
        if(n<0)break;
        int sum=1150;
        if(n<=10)goto end;
        
        if(10<n && n<=20){
            sum+=(n-10)*125;
            goto end;
        }
        else sum+=125*10;
        
        if(20<n && n<=30){
            sum+=(n-20)*140;
            goto end;
        }
        else sum+=140*10;
        
        sum+=(n-30)*160;
        
        end:;
        cout<<4280-sum<<endl;
    }
    
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <set>
#include <sstream>
#include <vector>
using namespace std;

#define DEBUG_ENABLED 0
typedef long long int ll;

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

    ll A, V, B, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;

    bool caught = false;

    ll velocity_diff = (V - W);
    if (DEBUG_ENABLED)
        cout << velocity_diff << endl;
    if (velocity_diff > 0)
    {
        // oni velocity is greater than sheep
        ll diff = (B - A > 0) ? (B - A) : (A - B);

        if (DEBUG_ENABLED)
            cout << diff << endl;

        if (diff <= velocity_diff * T)
        {
            caught = true;
        }
    }

    if (caught)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>

using namespace std;

//2^3通り？

int main(){
    int A,B,C,D,S;
    string op1,op2,op3;
    cin>>S;
    D=S%10;
    S=S/10;
    C=S%10;
    S=S/10;
    B=S%10;
    S=S/10;
    A=S%10;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                int sum=A;
                if(i%2==0){
                    sum+=B;
                    op1='+';
                }else{
                    sum-=B;
                    op1='-';
                }
                if(j%2==0){
                    sum+=C;
                    op2='+';
                }else{
                    sum-=C;
                    op2='-';
                }
                if(k%2==0){
                    sum+=D;
                    op3='+';
                }else{
                    sum-=D;
                    op3='-';
                }
                if(sum==7){
                    cout<<A<<op1<<B<<op2<<C<<op3<<D<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class Program{
  public static void Main(){

    var input = Console.ReadLine().Split();
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    if(a%3==0 || b%3==0 || (a+b)%3==0){
      Console.WriteLine("Possible");
    }
    else{
      Console.WriteLine("Impossible");
    }
  }
}


Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

int main()
{
	int K;
	string S;
	cin >> K;
	cin >> S;
	
	if(S.length() <= K) cout << S << endl;
	else cout << S.substr(0,K) + "..." << endl;
	
	return 0;

}

Measured memory_bytes: 3632
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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")
    };
}


fn main () {
    input! {
        s : chars,
    }
    let n = s.len();
    let mut t = String::new();
    for i in 0..n {
        if i % 2 == 0 {
            t.push(s[i]);
        }
    }
    println!("{}", t);
}


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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    string S;
    cin >> S;

    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    } else if (S == "Cloudy") {
        cout << "Rainy" << endl;
    } else if (S == "Rainy") {
        cout << "Sunny" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import bisect
# ABC-143-D
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0

for i in range(0, N-2):
    for j in range(i+1, N-1):
        a_plus_b = L[i] + L[j]
        ans += (bisect.bisect_left(L, a_plus_b) - 1) - j
print(ans)

Measured memory_bytes: 3188
import java.util.Arrays;
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int K = scanner.nextInt();

        int[] p = new int[N];

        for (int i = 0 ; i < N ; i++) {
            p[i] = scanner.nextInt();
        }

        Arrays.sort(p);

        int min = 0;
        for (int i = 0 ; i < K ; i++) {
            min += p[i];
        }

        System.out.println(min);
    }
}


Measured memory_bytes: 38696
using System;

namespace AtcoderABC046A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if(a != b && b != c && c != a)
            {
                Console.WriteLine(3);
            }else if (a == b && b == c)
            {
                Console.WriteLine(1);
            }else
            {
                Console.WriteLine(2);
            }
            Console.ReadKey();
        }
    }
}


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

using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define REP(i,N) for(int i=0;i<N;i++)

int main()
{
    string s; cin>>s;
    int n = s.length();
    int no = 0;
    for(int i=0;i<n;i++){
        if(s[i]=='o'){
            no++;
        }
    }
    if(15-n + no >= 8){
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

var n int
var t, a float64

func main() {
	fmt.Scan(&n)
	fmt.Scan(&t, &a)
	hs := make([]int, n)
	for i := range hs {
		fmt.Scan(&hs[i])
	}
	min_tmp := 1e60
	cnt := 0
	ans := 0
	for i := range hs {
		cnt += 1
		tmp := math.Abs(a - (t - float64(hs[i])*0.006))
		if min_tmp > tmp {
			min_tmp = tmp
			ans = cnt
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.sort()
y.sort()
for Z in range(max(X, x[-1]), min(Y, y[0])+1):
    if X < Z <= Y and x[-1] < Z <= y[0]:
        print('No War')
        break
else:
    print('War')

Measured memory_bytes: 3064
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [tuple(map(int, input().split())) for _ in range(m)]

A.sort()
BC.sort(key=lambda x: x[1], reverse=True)

cnt = 0
for b, c in BC:
    for i in range(b):
        if c < A[cnt]:
            break
        A[cnt] = c
        cnt += 1
        if cnt >= n:
            break
    else:
        continue
    break

print(sum(A))

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

int brute(vector<int> v) {
  vector<int> tmp;
  for (int i = 0; i < v.size(); i++) {
    for (int j = 0; j < v.size(); j++) {
      if (i == j) continue;
      tmp.push_back(stoi(to_string(v[i]) + to_string(v[j])));
    }
  }
  sort(tmp.begin(), tmp.end());
  return tmp[2];
}

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto& e : v) {
    cin >> e;
  }
  sort(v.begin(), v.end());
  if (n <= 10) {
    cout << brute(v) << endl;
    return 0;
  }
  vector<int> s(v.begin(), v.begin() + 10);
  cout << brute(s) << endl;

  return 0;
}



Measured memory_bytes: 3240
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }

    #[allow(dead_code)]
    pub fn get2<T: FromStr, U: FromStr>() -> (T, U)
    where
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }

    #[allow(dead_code)]
    pub fn get3<S: FromStr, T: FromStr, U: FromStr>() -> (S, T, U)
    where
        <S as FromStr>::Err: Debug,
        <T as FromStr>::Err: Debug,
        <U as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    }
}

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

fn f(b: usize, n: usize) -> usize {
    if b <= 1 {
        return 0;
    }
    if n < b { n } else { n % b + f(b, n / b) }
}

fn main() {
    let n: usize = util::get();
    let s: usize = util::get();

    if n == s {
        println!("{}", n + 1);
        return;
    }

    if s > n {
        println!("-1");
        return;
    }

    for b in (2..).take_while(|b| b * b <= n) {
        if f(b, n) == s {
            println!("{}", b);
            return;
        }
    }

    for &p in (1..)
        .take_while(|b| b * b <= n)
        .collect::<Vec<_>>()
        .iter()
        .rev()
    {
        let b = (n - s) / p + 1;
        if f(b, n) == s {
            println!("{}", b);
            return;
        }
    }

    println!("-1");
}


Measured memory_bytes: 9464
#include <stdio.h>
int main(){
 int x,N;
 scanf("%d%d",&x,&N);
 if(N==0) {
   printf("%d",x);
   return 0;
 }
 int p[N];
 for(int i=0;i<N;i++){
  	scanf("%d",&p[i]);
 }
 for(int i=0;i<101;i++){
  for(int j=0;j<N;j++){
	if(x-i==p[j]){
     break;
    }
    if(j==N-1){
     printf("%d",x-i);
     return 0;
    }
  }
  for(int j=0;j<N;j++){
	if(x+i==p[j]){
     break;
    }    
   if(j==N-1){
     printf("%d",x+i);
     return 0;
    }
  }
 }
 return 0;
}


Measured memory_bytes: 1732
#include<cstdio>
#include<cstring>
#define LEN 100005


typedef struct pp{
	char name[100];
	int t;
} P;

P Q[LEN];
int head, tail ,n;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b){return a < b ? a : b;}

int main(){
	int elaps = 0, c;
	int i, q;
	P u;
	scanf("%d %d", &n, &q);


	for(i = 1; i <= n; i++){
		scanf("%s", Q[i].name);
		scanf("%d", &Q[i].t);
	}
	head = 1; tail = n + 1;


	while(head != tail){
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0) enqueue(u);
		else{
			printf("%s %d\n", u.name, elaps);
		}
	}

	return 0;
}

Measured memory_bytes: 12752
n=int(input())
L=[]
for i in range(n):
  s,p=map(str,input().split())
  p=int(p)
  L.append([i+1,s,p])
L.sort(key=lambda x:x[2],reverse=True)
L.sort(key=lambda x:x[1])
for l in L:
  print(l[0])

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, d;
ll a[maxn];

ll loc[maxn];//where we are after i moves
ll min_fail[maxn]; //mindist s.t. we can't reach goal after the ith move

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>d;
    for (int i=1; i<=n; i++) {
	cin>>a[i];
    }

    loc[0]=d;
    for (int i=1; i<=n; i++) {
	loc[i]=min(loc[i-1], abs(loc[i-1]-a[i]));
    }

    min_fail[n] = 1;
    for (int i=n-1; i>=0; i--) {
	if (a[i+1]/2 >= min_fail[i+1]) {
	    min_fail[i] = min_fail[i+1];
	} else {
	    min_fail[i] = min_fail[i+1] + a[i+1];
	}
    }

    int q; cin>>q;

    while (q--) {
	int i; cin>>i;

	// we can force a fail
	if (min_fail[i] <= loc[i-1]) {
	    cout<<"YES\n";
	} else {
	    cout<<"NO\n";
	}
    }


    // for (int i=0; i<=n; i++) {
    // 	cout<<loc[i]<<" ";
    // }
    // cout<<endl;

    // for (int i=0; i<=n; i++) {
    // 	cout<<min_fail[i]<<" ";
    // }
    // cout<<endl;

    return 0;
}


Measured memory_bytes: 18304
N = int(input())
n3 = N//3
n5 = N//5
n15 = N//15
sum3 = n3/2*(2*3+(n3-1)*3)
sum5 = n5/2*(2*5+(n5-1)*5)
sum15 = n15/2*(2*15+(n15-1)*15)
sumall = (1+N)*N/2
print(int(sumall-sum3-sum5+sum15))

Measured memory_bytes: 61688
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

	X, A := nextInt(), nextInt()

	if X < A {
		fmt.Println(0)
	} else {
		fmt.Println(10)
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long int lli;
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
int a,b,c;
cin>>a>>b>>c;
if(a==b && b==c){
    cout<<1;
    return 0;
}
if(a==b || b==c || a==c){
    cout<<2;
    return 0;
}
cout<<3;
	return 0;
}


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

using namespace std;

#define ll long long

int n, res, p;
int a;

ll binpow (int a, int b) {
	if (b == 0) {
		return 1;
	}
	if (b % 2 == 0) {
		ll r = (binpow(a, b / 2));
		return r * r;
	}
	else {
		return binpow(a, b - 1) * a;
	}
}

int main () {
    ios_base:
	cin >> n >> p;
	int e = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a;
        e += a % 2;
	}

	ll ans = binpow(2, n - 1);

	if (!e) {
		if (p == 0) {
			cout << ans * 2;
		}
		else {
			cout << 0;
		}
		return 0;
	}
	cout << ans;

	return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int D, N;
  cin >> D >> N;

  int ret;
  if(N < 100) {
    ret = pow(100, D) * N;
  }else{
    ret = pow(100, D) * (N + 1);
  }

  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
 
class Main {
      
    public static void main(String[] args) {
         
       Scanner cin=new Scanner(System.in);
       
       while(true) {
    	   String str1=cin.next();
    	   if(str1.equals("."))break;
    	   String str2=cin.next();
    	   
    	   String[] stra1=str1.split("\"",-1);
    	   String[] stra2=str2.split("\"",-1);
    	   
    	   int n=stra1.length,jd=0;
    	   
    	   if(n == stra2.length) {
    		   
    		   int s1m,s1lm,s2m,s2lm;
    		   if(str1.indexOf("\"")==0)s1m=1; else s1m=0;
    		   if(str2.indexOf("\"")==0)s2m=1; else s2m=0;
    		   if(str1.lastIndexOf("\"")==str1.length()-1)s1lm=1; else s1lm=0;
    		   if(str2.lastIndexOf("\"")==str2.length()-1)s2lm=1; else s2lm=0;
    		   
    		   if(s1m == s2m && s1lm == s2lm) {
    			   
    			   boolean MODE=false;
    			   /*if(s1m==0)MODE=false; else MODE=true;*/
    			   int same=0;
    			   for(int i=0;i<n;i++) {
    				   //System.out.println(MODE+" "+stra1[i]+" "+stra2[i]);
    				   if(!MODE && !stra1[i].equals(stra2[i])) {
    					   same=0;
    					   //System.out.println("MODE0 INCOLLECT");
    					   break;
    				   }
    				   else if(!MODE && stra1[i].equals(stra2[i]))same++;
    				   else if(MODE && stra1[i].equals(stra2[i]))same++;
    				   MODE = !MODE;
    			   }
    			   
    			   //System.out.println(same);
    			   if(same==n)jd=2;
    			   else if(n>=2 && same==n-1)jd=1;
    			   
    		   }
    		   //else System.out.println("MODE ERROR");
    	   }
    	   
    	   if(jd==2)System.out.println("IDENTICAL");
    	   else if(jd==1)System.out.println("CLOSE");
    	   else System.out.println("DIFFERENT");
       }
       
    }
     
 
}


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

typedef long long ll;

ll gcd(ll a, ll b){
	  return (a%b==0)? b: gcd(b,a%b);
}
ll lcm(ll a, ll b){
	  return a/gcd(a,b)*b;
}

int main(){

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

	  int ans = a[0];
	  for(int i=0; i<n; i++) ans = lcm(ans,a[i]);
	  cout << ans << endl;
	  

}

Measured memory_bytes: 1164
#include<cstdio>
#include<algorithm>
#define N_ 301000
#define SZ 524288
using namespace std;
int W, H;
int n;
struct point {
	int x, y;
	bool operator <(const point &p)const {
		return x < p.x;
	}
}w[N_], st1[N_], st2[N_];

int X[N_], CX, INF = 2e9;
struct Tree {
	int Mx[SZ + SZ], K[SZ + SZ];
	void UDT(int nd) {
		Mx[nd] = max(Mx[nd * 2], Mx[nd * 2 + 1]);
	}
	void init(int nd, int b, int e) {
		K[nd] = 0;
		if (b == e) {
			Mx[nd] = -X[b];
			return;
		}
		int m = (b + e) >> 1;
		init(nd * 2, b, m);
		init(nd * 2 + 1, m + 1, e);
		UDT(nd);
	}
	void Add2(int nd, int x) {
		Mx[nd] += x;
		K[nd] += x;
	}
	void Spread(int nd) {
		Add2(nd * 2, K[nd]);
		Add2(nd * 2 + 1, K[nd]);
		K[nd] = 0;
	}
	void Add(int nd, int b, int e, int s, int l, int x) {
		if (s > l)return;
		if (b == s&&e == l) {
			Add2(nd, x);
			return;
		}
		Spread(nd);
		int m = (b + e) >> 1;
		if (s <= m)Add(nd * 2, b, m, s, min(m, l), x);
		if (l>m)Add(nd * 2 + 1, m + 1, e, max(m + 1, s), l, x);
		UDT(nd);
	}
	int Max(int nd, int b, int e, int s, int l) {
		if (s > l)return -INF;
		if (b == s && e == l) return Mx[nd];
		Spread(nd);
		int m = (b + e) >> 1, r = -INF;
		if (s <= m)r = max(r, Max(nd * 2, b, m, s, min(m, l)));
		if (l > m)r = max(r, Max(nd * 2 + 1, m + 1, e, max(m + 1, s), l));
		return r;
	}
}TT;

int top1, top2;
int GetX(int x) {
	return lower_bound(X + 1, X + CX + 1, x) - X;
}
void Put1(int x, int y) {
	while (top1 && st1[top1].y >= y) {
		if (top1>=2) {
			TT.Add(1, 1, CX, GetX(st1[top1 - 1].x), GetX(st1[top1].x) - 1, H/2-st1[top1].y);
		}
		top1--;
	}
	st1[++top1] = { x,y };
	if(top1>=2)TT.Add(1, 1, CX, GetX(st1[top1-1].x), GetX(st1[top1].x) - 1, st1[top1].y-H/2);
}
void Put2(int x, int y) {
	while (top2 && st2[top2].y <= y) {
		if (top2 >= 2) {
			TT.Add(1, 1, CX, GetX(st2[top2 - 1].x), GetX(st2[top2].x) - 1, st2[top2].y-H/2);
		}
		top2--;
	}
	st2[++top2] = { x,y };
	if (top2 >= 2)TT.Add(1, 1, CX, GetX(st2[top2 - 1].x), GetX(st2[top2].x) - 1, H/2-st2[top2].y);
}
int res;
void Do() {
	int i;
	sort(w + 1, w + n + 1);
	CX = 0;
	X[++CX] = 0, X[++CX] = W;
	for (i = 1; i <= n; i++)X[++CX] = w[i].x;
	sort(X + 1, X + CX + 1);
	CX = unique(X + 1, X + CX + 1) - X - 1;
	w[0] = { 0, H / 2 };
	w[n + 1] = { W, H / 2 };
	TT.init(1, 1, CX);
	top1 = top2 = 0;
	for (i = 1; i <= n + 1; i++) {
		if (w[i - 1].y >= H / 2) {
			Put1(w[i - 1].x, w[i - 1].y);
		}
		if (w[i - 1].y <= H / 2) {
			Put2(w[i - 1].x, w[i - 1].y);
		}
		Put1(w[i].x, H);
		Put2(w[i].x, 0);
		if (w[i].x) {
			res = max(res, TT.Max(1, 1, CX, 1, GetX(w[i].x) - 1) + w[i].x);
		}
	}
}
int main() {
	int i;
	scanf("%d%d%d", &W, &H, &n);
	for (i = 1; i <= n; i++) {
		scanf("%d%d", &w[i].x, &w[i].y);
	}
	W *= 2, H *= 2;
	for (i = 1; i <= n; i++)w[i].x *= 2, w[i].y *= 2;

	Do();
	swap(W, H);
	for (i = 1; i <= n; i++)swap(w[i].x, w[i].y);
	Do();
	printf("%d\n", res);
}



Measured memory_bytes: 16640
#include <iostream>

int main()
{
    int N;
    std::cin >> N;
    if (N == 1) {
        std::cout << "Hello World" << std::endl;
    } else {
        int A, B;
        std::cin >> A >> B;
        std::cout << A + B << std::endl;
    }
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    for (int a = 1; a < 10;a++){
        for (int b = 1; b < 10;b++){
            if(a*b==N){
                cout << "Yes"<< endl;
              return 0;
            }
        }
    }
    cout << "No" << endl;
}


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

int skl(int a){
  a%=10;
  return a!=0?10-a:0;
}

int main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  int ans = 0;
  int k = 0;
  k = min(k,-skl(a));
  k = min(k,-skl(b));
  k = min(k,-skl(c));
  k = min(k,-skl(d));
  k = min(k,-skl(e));

  a += skl(a);
  b += skl(b);
  c += skl(c);
  d += skl(d);
  e += skl(e);

  ans += (a+b+c+d+e);
  cerr << ans << endl;
  ans += k;
  cerr << k << endl;
  cout << ans << endl;
  return 0;
}


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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  if ((c-a-b) * (c-a-b) > 4*a*b && c-a-b>0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for(ll i=(ll)a;i<=(ll)b;i++)
#define per(i, a, b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define all(v) v.begin(), v.end()
#define N 1000010
#define MAX 1234567890

int main()
{
    fastio;
    
    ll d, m, v;
    cin >> d >> m >> v;
    if(m*v >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

    static long ANS_POSI;
    static long ANS_NEGA;
    static int N;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.nextLine());

        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            long elm = Long.parseLong(sc.next());
            a[i] = elm;
        }

        solve(a);

        System.out.println(Math.min(ANS_POSI, ANS_NEGA));
    }


    private static void solve(long[] a) {
        long posi = 0;
        long nega = 0;
        for (int i = 0; i < N; i++) {
            // 前回のループで変更があった場合は、1か-1になっている値に配列値を合算して合計値としている。
            posi += a[i];
            nega += a[i];
            if (i % 2 == 0) {
                if (posi >= 0) {
                    ANS_POSI += posi + 1;
                    posi = -1;
                }
                if (nega <= 0) {
                    ANS_NEGA -= nega - 1;
                    nega = 1;
                }
            } else {
                if (posi <= 0) {
                    ANS_POSI -= posi - 1;
                    posi = 1;
                }
                if (nega >= 0) {
                    ANS_NEGA += nega + 1;
                    nega = -1;
                }
            }
        }
    }
}


Measured memory_bytes: 47468
import math
from functools import reduce
k=int(input())
def gcd(*numbers):
    return reduce(math.gcd,numbers)
ans=0
for i in range(1,k+1):
    for j in range(1,k+1):
        for m in range(1,k+1):
            ans+=gcd(i,j,m)
print(ans)

Measured memory_bytes: 69640
#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 <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <limits>
#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
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
cin>>a>>b;
	cout << a - b + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int n, ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		int t = 0;
		for (int j = 1; j <= i; j++) if (i % j == 0)t++;
		if (t == 8 && i % 2 == 1) ans++;
	}
	printf("%d", ans);
	return 0;
}

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

ll A, B, C, D;

ll gcd(ll a, ll b) {
  ll A = max(a, b);
  ll B = min(a, b);
  if (A < 1 || B < 1) {
    return A;
  }
  return gcd(B, A % B);
}

ll lcm(ll a, ll b) {
  if (a < 1 || b < 1) {
    return 0;
  } else {
    return a / gcd(a, b) * b;
  }
}

void solve() {
  ll cd = lcm(C, D);
  ll ans_B = B - (B / C + B / D - B / cd);
  ll ans_A = (A - 1) - ((A - 1) / C + (A - 1) / D - (A - 1) / cd);
  cout << ans_B - ans_A << '\n';
}

int main() {
  cin >> A >> B >> C >> D;
  solve();
  return 0;
}

Measured memory_bytes: 256
import collections
N = int(input())
edges = [[] for _ in range(N)]
for i in range(N-1):
    a, b = map(int, input().split())
    edges[a-1].append([b-1,i])
    edges[b-1].append([a-1,i])
# for i in edges:
#     print(i)
q = collections.deque()
q.append([0,-1,-1])
colors = [0]*(N-1)
check = [0]*N
while len(q) != 0:
    v, color, num = q.popleft()
    check[v] = 1
    # print(v,color,num)
    if colors[num] == 0 and color != -1:
        colors[num] = color
    next_color = 0
    for w in edges[v]:
        if check[w[0]] != 0:
            continue
        next_color += 1
        if next_color == colors[num]:
            next_color += 1
        q.append([w[0],next_color,w[1]])
# print(colors)
print(len(set(colors)))
for i in colors:
    print(i)

Measured memory_bytes: 107416
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>

using namespace std;

int main(){
  int n;
  vector<int> a(4801,0);
  cin >> n;
  int tmp;
  for(int i = 0; i < n;i++){
    cin >> tmp;
    a[tmp]++;
  }
  
  int ans = 0;
  int ans2 = 0;
  for(int i = 1; i <= 399; i++){ if(a[i]){ ans++; break;}}
  for(int i = 400; i <= 799; i++){ if(a[i]){ ans++; break;}}
  for(int i = 800; i <= 1199; i++){ if(a[i]){ ans++; break;}}
  for(int i = 1200; i <= 1599; i++){ if(a[i]){ ans++; break;}}
  for(int i = 1600; i <= 1999; i++){ if(a[i]){ ans++; break;}}
  for(int i = 2000; i <= 2399; i++){ if(a[i]){ ans++; break;}}
  for(int i = 2400; i <= 2799; i++){ if(a[i]){ ans++; break;}}
  for(int i = 2800; i <= 3199; i++){ if(a[i]){ ans++; break;}}
  for(int i = 3200; i <= 4800; i++){  ans2+= a[i];}
  if(ans == 0){
    cout << 1 << " " <<ans2 << endl;
  }else{
    cout << ans << " " << ans + ans2 << endl;
  }
  return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using Graph = vector<vector<int>>;
using ll = long long;
 
 
int main() {
    ll N;
    cin>>N;
    vector<char> alph(26);
    alph[0]='a';
    alph[1]='b';
    alph[2]='c';
    alph[3]='d';
    alph[4]='e';
    alph[5]='f';
    alph[6]='g';
    alph[7]='h';
    alph[8]='i';
    alph[9]='j';
    alph[10]='k';
    alph[11]='l';
    alph[12]='m';
    alph[13]='n';
    alph[14]='o';
    alph[15]='p';
    alph[16]='q';
    alph[17]='r';
    alph[18]='s';
    alph[19]='t';
    alph[20]='u';
    alph[21]='v';
    alph[22]='w';
    alph[23]='x';
    alph[24]='y';
    alph[25]='z';
    vector<char> ans(1,'a');
    while(N>26){
        if(N%26==0){
            ans.push_back(alph[25]);
            N=N/26-1;
            continue;
        }
        else{
            ans.push_back(alph[N%26-1]);
        }
        N=N/26;
    }
    if(N<=26){
        ans.push_back(alph[N-1]);
    }
    reverse(ans.begin(),ans.end());
    rep(i,ans.size()-1){
        cout<<ans[i];
    }
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string str;
  cin >> str;
  set<char> vals;
  for(char c : str)
    vals.insert(c);
  const char* DIR = "EWNS";
  for(int i=0;i<4;++i)
    if(vals.count(DIR[i]) && !vals.count(DIR[i^1])) {
      cout << "No\n";
      return 0;
    }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
#define ll long long

using namespace std;
//        tmp = stoi(S.substr(i,3));
int main(){
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
    ll A,B;
    ll res;

    cin >> A >> B;

    res = (A-1)*(B-1);

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
/*
    -ensure correct output format
    -ensure printing required output
    -reread the problem statement
  */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll>pll;
typedef pair<ll,pair<ll,ll>>plll;
#define fastread() (ios_base:: sync_with_stdio(false),cin.tie(NULL));
#define vll(v) v.begin(),v.end()
#define all(x) x.rbegin(),x.rend()
#define min3(a, b, c)   min(a, min(b, c))
#define max3(a, b, c)   max(a, max(b, c))
#define F first
#define S second
#define in  freopen("input.txt", "r", stdin)
#define out  freopen("output.txt", "w", stdout)
#define minheap int,vector<int>,greater<int>
#define pb push_back
#define eb emplace_back
#define ischar(x)  (('a' <= x && x <= 'z') || ('A' <= x && x <= 'Z'))
#define isvowel(ch) ((ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')||(ch=='A'|| ch=='E' || ch=='I'|| ch=='O'|| ch=='U'))
#define bug cout<<"BUG"<<endl;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const double PI  =3.141592653589793238463;
bool compare(const pair<ll,ll> &a, const pair<ll,ll> &b)
{
    return (a.first > b.first);
}
ll lcm(ll a,ll b)
{
    if(a==0 || b==0)return 0;

    return a/__gcd(a,b)*b;
}

void input(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)cin>>ara[i];
}
void print(ll ara[],ll n)
{
    for(ll i=0; i<n; i++)
        cout<<ara[i]<<" ";
    cout<<endl;
}


ll ara[Max+10];
long long bigmod(long long b,long long p,ll mod)
{

    if(p==0)return 1ll;

    ll x=bigmod(b,p/2,mod);

    x=(x*x)%mod;

    if(p&1)x=(x*b)%mod;

    return x;
}


ll mp[Max];

vector<ll>v;
int main()
{



    fastread();

    ll i,j,n,m,p,a,sum=0,k,t,b,c,d,cnt=0,q,l,r,ans=0;

    bool flag=false;

    string str;

    ll x;
    cin>>n>>x>>m;


    ara[1]=x;



    sum=x;

    mp[x]=1;

    v.eb(x);

    for(i=2; i<=n; i++)
    {
        ara[i]=bigmod(ara[i-1],2,m);





        if(mp[ara[i]])
        {
            ll need=n-i+1;

            j=i;

            for(i=0; i<v.size(); i++)
            {
                if(ara[j]==v[i])
                {
                    break;
                }
            }

            cnt=0;

            j=i;

            for(  ; i<v.size() && need--; i++)
            {
                sum+=v[i];

                ans+=v[i];

                cnt++;
            }

            if(need)
            {
                a=need/cnt;

                sum+=(ans*a);

                a=need%cnt;

                need=a;

                i=j;

                for(  ; i<v.size() && need--; i++)
                {
                    sum+=v[i];


                }


            }
            break;
        }

        mp[ara[i]]=1;

        v.eb(ara[i]);

        sum+=ara[i];
    }

    cout<<sum<<endl;


}



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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

vector<vector<int> > board;

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

	bool flag = false;
	for (int i = 0; i < N+1; i++) {
		for (int j = 0; j < M+1; j++) {
			int count = i*M + j*N - 2*i*j;
			if (count == K) {
				flag = true;
			}
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int n;cin>>n;
    int a=n%10;
    if(a==3){
        cout<<"bon"<<endl;
    }else if(a==0 || a==1 || a==6 || a==8){
        cout<<"pon"<<endl;
    }else{
        cout<<"hon"<<endl;
    }
}


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

int main() {
  int64_t N,A,B;
  cin >> N >> A >> B;
  if(N%(A+B) > A){
    cout << (N/(A+B))*A + A << endl;
  }
  else{
    cout << (N/(A+B))*A + N%(A+B) << endl;
  }
  
}

  
  

  
  // int型の2次元配列(3×4要素の)の宣言
  //vector<vector<int>> data(3, vector<int>(4));

  // 入力 (2重ループを用いる)
  //for (int i = 0; i < 3; i++) {
    //for (int j = 0; j < 4; j++) {
      //cin >> data.at(i).at(j);
    //}
  //}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
using namespace std;


int main() {
	const long long int kuni = 10000000000;
	long long int n, m, p[300000], y[300000],so[300000],cou=2;
	map<long long int, long long int>mp;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> y[i];
		
		so[i] = p[i] * kuni + y[i];
		y[i] = so[i];
	}
	sort(so, so + m);
	mp[so[0]] = 1;
	for (int i = 1; i < m; i++) {
		if (so[i] / kuni == so[i - 1] / kuni) {
			mp[so[i]] = cou;
			cou++;
		}
		else {
			mp[so[i]] = 1;
			cou=2;
		}
		
	}

	for (int i = 0; i < m; i++) {
		cout << setw(6) << setfill('0') << y[i] / kuni;
		cout << setw(6) << setfill('0') << mp[y[i]]<<endl;
	}
}


Measured memory_bytes: 14720
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;
use std::char;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        s: Chars,
    }

    let mut alphabet: Vec<usize> = vec![0;30];
    for i in 0..s.len() {
        alphabet[s[i] as usize - 'a' as usize] += 1;
    }
    debug!('a' as usize);
    debug!(alphabet);
    for i in 0..26 {
        if alphabet[i]==0 {
            println!("{}", char::from_u32(i as u32 + 'a' as u32).unwrap());
            return;
        }
    }
    println!("None");
}


Measured memory_bytes: 2500
N,M=map(int,input().split())
K=10**9+7
"""la=[]
for i in range(M):
    la.append(int(input()))"""
ldp=[0 for i in range(N)]
for i in range(M):
    a=int(input())
    ldp[a-1]=-1
if ldp[0]!=-1:
    ldp[0]=1
    #if ldp[1]!=-1:
    #    ldp[1]=1
#if N>=1:


if N>=2:
    if ldp[1]!=-1:
        ldp[1]+=1
        if ldp[0]!=-1:
            ldp[1]+=1
    for i in range(2,N):
        if ldp[i]!=-1:
            if ldp[i-1]!=-1:
                ldp[i]=(ldp[i]+ldp[i-1])%K
            if ldp[i-2]!=-1:
                ldp[i]=(ldp[i]+ldp[i-2])%K
#print(ldp)
print(ldp[N-1])


Measured memory_bytes: 7048
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}

int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int count=0;
  string s;
  bool flag=true;
  cin>>s;
  rep(i,s.size()){
    rep(j,s.size()){
      if(s[i]==s[j]) count++;
    }
    if(count%2!=0){
      flag=false;
      break;
    }
    if(!flag) break;
  }
  if(flag){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}
///////////////////////////

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	string S;
	cin >> S;

	ll sum = 0;
	for (int i = 0; i < S.length(); ++i) {
		int x = int(S[i]) - 48;
		sum += x;
	}

	if (sum % 9 == 0) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}


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

int main() {
	// your code goes here
	int h,w,i,j;
	cin>>h>>w;
	char A[h][w];
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
			cin>>A[i][j];
	}
	long long dp[h][w];
	dp[0][0]=1;
	for(i=0;i<h;i++)
	{
		for(j=0;j<w;j++)
		{
			if(i==0 && j==0)
				continue;
			if(i>0 && j>0)
			{
				if(A[i][j]=='.')
					dp[i][j]=(dp[i][j-1]+dp[i-1][j])%1000000007;
				else
					dp[i][j]=0;
			}
			else if(i>0)
			{
				if(A[i][j]=='.')
					dp[i][j]=dp[i-1][j];
				else
					dp[i][j]=0;
			}
			else 
			{
				if(A[i][j]=='.')
					dp[i][j]=dp[i][j-1];
				else
					dp[i][j]=0;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
	return 0;
}

Measured memory_bytes: 9088
use std::cmp::min;

// 基本型の受け取り
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// println の省略
fn print<T: std::fmt::Display>(x: T) -> () {
    println!("{}", x);
}

fn main() {
    let s: String = read();
    let cs: Vec<char> = s.chars().collect();

    let mut diff1 = 0;
    let mut diff2 = 0;
    let mut i = 0;

    for c in cs {
        if i % 2 == 0 {
            if c == '0' {
                diff1 += 1;
                i += 1;
            } else {
                diff2 += 1;
                i += 1;
            }
        } else {
            if c == '1' {
                diff1 += 1;
                i += 1;
            } else {
                diff2 += 1;
                i += 1;
            }
        }
    }

    let ans = min(diff1, diff2);
    print(ans);
}


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

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N -1], dneg[2 * N -1];

bool X[N][N];

void initialize() {
    for (int i = 0; i < N; i++) {
        row[i] = FREE, col[i] = FREE;
    }
    for (int i = 0; i < N; i++) {
        dpos[i] = FREE;
        dneg[i] = FREE;
    }
}

void printBoard() {
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (X[i][j]) {
                if(row[i] != j) return;
            }
        }
    }
    for(int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << ((row[i] == j) ? "Q" : "." );
        }
        cout << endl;
    }
}

void recursive(int i) {
    if (i == N) {
        printBoard();
        return;
    }
    
    for (int j = 0; j < N; j++) {
        if (NOT_FREE == col[j] || NOT_FREE == dpos[i + j] || NOT_FREE == dneg[i - j + N - 1]) continue;
        row[i] = j;
        col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
        recursive(i + 1);
        row[i] = col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
    }
}

int main() {
    initialize();
    
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) X[i][j] = false;
    }
    
    int k;
    cin >> k;
    for(int i = 0; i < k; i++) {
        int r, c;
        cin >> r >> c;
        X[r][c] = true;
    }
    
    recursive(0);
    
    return 0;
}



Measured memory_bytes: 3124
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        String inputs = s.nextLine();
        String[] strings = inputs.split(" ");

        if (strings.length < 2) {
            System.out.println("0");
        }

        //合計の月
        int M = Integer.valueOf(strings[0]);

        //1ヶ月当たりの均等日付
        int D = Integer.valueOf(strings[1]);


        int counter = 0;
        for (int m = 1; m <= M; m++) {
            for (int i = 22; i <= D; i++) {
                if (i % 10 < 2) continue;
                int d10 = i / 10;
                int d1  = i % 10;
                if (d10 * d1 == m) counter++;
            }
        }

        System.out.println(counter);


    }
}


Measured memory_bytes: 24020
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
using namespace std;

ll sum[4][105];
int cnt[4];
ll n,w;
pll v[105];
ll we;
ll ans;

int cmp(pll x,pll y){
	if(x.first==y.first)return x.second>y.second;
	return x.first<y.first;
}

int main(){
	scanf("%d%d",&n,&w);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&v[i].first,&v[i].second);
		cnt[v[i].first-v[1].first]++;
	}
	sort(v+1,v+n+1,cmp);
	ll k=0,val=v[1].first,l=0;
	for(int i=1;i<=n;i++){
		if(v[i].first!=val)k+=v[i].first-val,val=v[i].first,l=1;else l++;
		sum[k][l]=sum[k][l-1]+v[i].second;
	}
	val=v[1].first;
	for(ll i=0;i<=cnt[0];i++){
		for(ll j=0;j<=cnt[1];j++){
			for(ll p=0;p<=cnt[2];p++){
				for(ll q=0;q<=cnt[3];q++){
					we=val*i+(val+1)*j+(val+2)*p+(val+3)*q;
					if(we>w)continue;
					ans=max(ans,sum[0][i]+sum[1][j]+sum[2][p]+sum[3][q]);
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  int d[1001] = {0};
  for (int i = 1; i <= 1000; i++) {
    d[i] = d[i - 1] + i;
  }
  int diff = b - a;
  for (int i = 0; i <= 1000; i++) {
    if (d[i + 1] - d[i] == diff) {
      cout << d[i] - a << endl;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 3160
chars = ["_",".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"]

gets.to_i.times do
    cmd = gets.chomp.chars.map(&:to_i)
    
    msg = ""
    ptr = 0
    rol = 0
    cmd.each do |c|
        if c == 0
            msg << chars[ptr][rol%chars[ptr].size] if ptr != 0
        elsif c == ptr
            rol = (rol+1)%chars[ptr].size
        else
            rol = 0
        end
        ptr = c
    end
    puts msg
end


Measured memory_bytes: 7084
S = int(input())
P = list(map(int,input().split()))
c = 0
for i in range(S-2):
    p_list = [P[i],P[i+1],P[i+2]]
    p_list.sort()
    if p_list[1] == P[i+1]:
        c += 1
print(c)


Measured memory_bytes: 2940