akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

@SuppressWarnings("unused")
public class Main {

  private static void solve() {
    int n = ni();
    int cnt = 0;

    for (int i = 0; i < n; i++) {
      int d1 = ni();
      int d2 = ni();

      if (d1 == d2) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt >= 3) {
        System.out.println("Yes");
        return;
      }
    }
    System.out.println("No");
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 36648
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>


int main(void){
	int a, b, m;
	int min_a = INT_MAX, min_b = INT_MAX, total_min = INT_MAX;
	int arr_a[100000] = {0,};
	int arr_b[100000] = {0,};
	scanf("%d %d %d", &a, &b, &m);

	for(int i = 0; i < a; i++){
		scanf("%d", &arr_a[i]);
		min_a = (min_a > arr_a[i]) ? arr_a[i] : min_a;
	}

	for(int i = 0; i < b; i++){
		scanf("%d", &arr_b[i]);
		min_b = (min_b > arr_b[i]) ? arr_b[i] : min_b;
	}

	total_min = min_a + min_b;

	for(int i = 0; i < m; i++){
		int temp_x, temp_y, temp_c, discounted;
		scanf("%d %d %d", &temp_x, &temp_y, &temp_c);

		discounted = arr_a[temp_x-1] + arr_b[temp_y-1] - temp_c;

		total_min = (total_min > discounted) ? discounted : total_min;
	}

	printf("%d", total_min);

	return 0;
	
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(V) V.begin(), V.end()
#define PB push_back
using namespace std;
typedef long long ll;

int main() {
    string s;
    cin >> s;
    int cnt =0;
    rep(i,3){
        if(s.at(i) == 'S' && i != 0){
            if(s.at(2) == 'R'){
                cnt++;
                break;
            }else{
                break;
            }
        }else if(s.at(i) == 'R'){
            if(s.substr(0,2)=="RS"){
                cnt++;
                break;
            }else cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3596
x = int(input())
if x >= 400 and x < 600:
  print("8")
elif x >= 600 and x < 800:
  print("7")
elif x >= 800 and x < 1000:
  print("6")
elif x >= 1000 and x < 1200:
  print("5")
elif x >= 1200 and x < 1400:
  print("4")
elif x >= 1400 and x < 1600:
  print("3")
elif x >= 1600 and x < 1800:
  print("2")
elif x >= 1800 and x < 2000:
  print("1")

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

int main() {

	vector<int> a(3); cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());	
	cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;
	return 0;
}

Measured memory_bytes: 3572
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Here your code !
    string str;
    cin >> str;
    
    bool n = false,w = false,s = false,e = false;
    
    for(int i = 0; i < str.length(); i++){
        if(str[i] == 'N') n = true;
        if(str[i] == 'W') w = true;
        if(str[i] == 'S') s = true;
        if(str[i] == 'E') e = true;
    }
    
    if(n&&s&&e&&w){
        cout << "Yes" << endl;
    }else if(n&&s&&!e&&!w){
        cout << "Yes" << endl;
    }else if(!n&&!s&&e&&w){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

min_ = 10000000000000
ans = None
for i, x in enumerate(h):
    tmp = t - x*0.006# その地点の平均気温
    if a > 0 and tmp > 0:
        sa = a - tmp
    elif a > 0 and tmp < 0:
        sa = a + abs(tmp)
    elif a < 0 and tmp > 0:
        sa = abs(a) + tmp
    else:
        sa = abs(a) - abs(tmp)
    sa = abs(sa)
    if sa < min_:
        min_ = sa
        ans = i + 1
print(ans)


Measured memory_bytes: 3064
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  vl sum(n);
  sum[0]=a[0];
  for(ll i=1;i<n;i++)sum[i]=sum[i-1]+a[i];
  ll count=1;
  for(ll i=n-2;i>=0;i--){
    if(2*sum[i]>=a[i+1])count++;
    else break;
  }
  cout<<count<<endl;
}
  

Measured memory_bytes: 1792
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end
def debug(k,v) puts "#{k}: #{v}" end
def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

#$stdin = File.open('input.txt')
n = gi #10**5
cs = gs
w_num = cs.each_char.count { |c| c=="W" }
r_num = n-w_num
ans = 0
for i in 0...r_num
  ans+=1 if cs[i]=="W"
end
puts ans


Measured memory_bytes: 14764
//2:01 start
//2:09 writing done
//
//


#include <stdio.h>
#include <string.h>

//#define DEBUG

#define N_DATA 101
int n_appear[N_DATA];

int max_appear[N_DATA];
int n_max_appear=0;


int main(void)
{
    FILE *fp;
#ifdef DEBUG
    fp=fopen("input.txt","r");
#else
    fp=stdin;
#endif

    memset(n_appear,0,sizeof(int)*N_DATA);
    while(feof(fp)==0){
        int n;
        fscanf(fp,"%d\n",&n);
        n_appear[n]++;
    }

    int i;
    int max_val=0,max_n;
    for(i=0;i<N_DATA;i++){
        if(n_appear[i]>max_val){
            max_val=n_appear[i];
            n_max_appear=1;
            max_appear[0]=i;
        }
        else if(n_appear[i]==max_val){
            max_appear[n_max_appear++]=i;
        }
    }

    for(i=0;i<n_max_appear;i++){
        printf("%d\n",max_appear[i]);
    }

    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
    
using namespace std;  
typedef long long ll;
#define LOOP(i,n) for(int i=0; i<n; i++)
#define LOG(x) cout << "log: " << x << endl;

int main(void){
    int n;
	cin >> n;
	vector<int> a(n);
	LOOP(i, n) cin >> a[i];
  
	sort(a.begin(), a.end());
	
	vector<int> dp(1000001, 0);
	int ans = 0;
	LOOP(i, n) {
        if(dp[a[i]] != 0){
          dp[a[i]] = 2;
          continue;
        }
		for(int j = a[i]; j < 1000001; j += a[i]){
			dp[j] = 1;
		}
	}
	LOOP(i, n) {
		if(dp[a[i]] == 1) ans++;
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 8008
#include <cstdio>

const int N = 1e5+10;

int n,p;
int pa[N+1];

// int find(int x){
//     while(x != pa[x])
//         x = pa[x];
//     return x;
// }
int find(int x){
    if(x==pa[x]) return x;
    return find(pa[x]);
}


int main(){
    while(scanf("%d%d",&n,&p) == 2){
        if(!n && !p) break;
        pa[1] = 1;
        for(int i=2; i<=n; i++)
            scanf("%d",&pa[i]);

        long long sum = 0;
        for(int i=1; i<=p; i++){
            char s[2];
            int x;
            scanf("%s%d",s,&x);
            if(s[0] == 'M')
                pa[x] = x;
            else
                sum += find(x);
        }
        printf("%lld\n",sum);
    }
}

Measured memory_bytes: 2936
N,M,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

x.append(X)
y.append(Y)
x = sorted(x)
y = sorted(y)
if max(x) < min(y): print("No War")
else: print("War")

Measured memory_bytes: 9172
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read![usize];
    let a = read![[i64]];

    let mut x = 0;
    let mut y = a.iter().sum::<i64>();

    // 1枚以上は取る。
    x += a[0];
    y -= a[0];

    let mut m = (x - y).abs();
    for i in 1..N - 1 {
        x += a[i];
        y -= a[i];

        m = min(m, (x - y).abs());
    }

    println!("{}", m)
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int ma = max(a, c);
	int mi = min(b, d);

	cout << max(mi - ma, 0) << endl;

	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
using namespace std;

int main(){
  int N,Sn[10],s=0;


while(1){
  std::cin >> N;
  if(N>=1&&N<=1000000000) break;}

  int N_x=N;

  int x=1,i=0;

  while(N_x/10>0){

    N_x=N_x/10;
    x++;
  }



  while(i<x){
    if(i==0)Sn[i]=N%10;
    else if(i!=0&&i<x-1) {
      int n=0,N_y=N;
      while(n<i){
         N_y=N_y/10;
         n++;
       }

      Sn[i]=N_y%10;

    }
    else Sn[i]=N/pow(10,i);


    //std::cout << Sn[i] << '\n';
    s=s+Sn[i];
    i++;
  }


  if(N%s==0) std::cout << "Yes" << '\n';
  else std::cout << "No" << '\n';


}


Measured memory_bytes: 256
import java.util.*;

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

		HashMap<String,Integer> map = new HashMap<String,Integer>();
		map.put("yotta",24);
		map.put("zetta",21);
		map.put("exa",18);
		map.put("peta",15);
		map.put("tera",12);
		map.put("giga",9);
		map.put("mega",6);
		map.put("kilo",3);
		map.put("hecto",2);
		map.put("deca",1);
		map.put("deci",-1);
		map.put("centi",-2);
		map.put("milli",-3);
		map.put("micro",-6);
		map.put("nano",-9);
		map.put("pico",-12);
		map.put("femto",-15);
		map.put("ato",-18);
		map.put("zepto",-21);
		map.put("yocto",-24);

		while(n-- > 0){
			String s = sc.next();
			String a = sc.next();
			String b = null;
			if(!sc.hasNextDouble()){
				b = sc.next();
			}
			else{
				b = a;
				a = null;
			}

			int idx = 0;
			for(;s.charAt(idx)=='0' || s.charAt(idx)=='.';idx++);
			String ns = "" + s.charAt(idx++);
			if(idx < s.length()){
				ns += ".";
				for(;idx<s.length();idx++){
					char ch = s.charAt(idx);
					ns += ch == '.' ? "" : ch;
				}
			}

			int before = 0;
			for(;before<s.length() && s.charAt(before)!='.';before++);
			if(before == s.length()) before--;
			int after = 0;
			for(;after<ns.length() && ns.charAt(after)!='.';after++);
			if(after == ns.length()) after--;

			System.out.println(ns + " * 10^" + ((a==null ? 0 : map.get(a)) + (ns.length() - after) - (s.length() - before)) + " " + b);
		}
	}
}

Measured memory_bytes: 12000
while True:
    n=input()
    if n==0:break
    S=range(1,7)
    s=1
    for i in range(n):
        c=raw_input()
        if c=="North":
            S=[S[1],S[5],S[2],S[3],S[0],S[4]]
        elif c=="South":
            S=[S[4],S[0],S[2],S[3],S[5],S[1]]
        elif c=="East":
            S=[S[3],S[1],S[0],S[5],S[4],S[2]]
        elif c=="West":
            S=[S[2],S[1],S[5],S[0],S[4],S[3]]
        elif c=="Right":
            S=[S[0],S[2],S[4],S[1],S[3],S[5]]
        elif c=="Left":
            S=[S[0],S[3],S[1],S[4],S[2],S[5]]
        s+=S[0]
    print s

Measured memory_bytes: 4400
from collections import defaultdict
N, K = map(int, input().split())
d = defaultdict(int)
for _ in range(N):
    a, b = map(int, input().split())
    d[a] += b
d = list(d.items())
d = sorted(d, key=lambda x: x[0])
cnt = 0
for v, count in d:
    cnt += count
    if cnt >= K:
        print(v)
        exit()


Measured memory_bytes: 14940
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
const int N = 1000000;


int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;

    bool check = false;

    for (int i = 0; i < s.length(); ++i) {
        if(s == t){
            check = true;
            break;
        }
        s = s.back() + s.substr(0,s.length() - 1);
    }
    if(check)print("Yes");
    else print("No");
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
count=0
judge=True

while judge==True:
    A=[int(i/2) if i%2==0 else i/2 for i in A]
    for j in A:
        if isinstance(j,int)==False:
            judge=False
            break
    count=count+1
print(count-1)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
using pii=std::pair<int,int>;
using namespace std;

const int maxn = 1e5 + 5, maxlogn = 20;

int n, l, q, x[maxn], a, b, r[maxlogn][maxn];

int check(int from, int to, int mid)
{
    for(int j = 0; j < maxlogn; j++)
        if(mid & (1ll << j))
            from = r[j][from];
    return from >= to;
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> x[i];
    cin >> l;
    for(int i = n - 1; i >= 0; i--)
    {
        int pos = upper_bound(x, x + n, x[i] + l) - x - 1;
        assert(i == n - 1 || pos > i);
        r[0][i] = pos;
    }
    for(int i = 1; i < maxlogn; i++)
        for(int j = n - 1; j >= 0; j--)
            r[i][j] = r[i - 1][r[i - 1][j]];
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        cin >> a >> b;
        a--; b--;
        if(a > b)
            swap(a, b);
        int ans = 0;
        for(int j = maxlogn - 1; j >= 0; j--)
            if(r[j][a] < b)
            {
                a = r[j][a];
                ans += (1ll << j);
            }
        a = r[0][a];
        assert(a >= b);
        cout << ans + 1 << "\n";
    }
    return 0;
}

Measured memory_bytes: 20060
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    ll a, b;
    cin >> a >> b;
    ll x, y;
    x = y = 0;
    for (int i = 0; i < b; i++){
        x *= 10;
        x += a;
    }
    for (int i = 0; i < a; i++){
        y *= 10;
        y += b;
    }
    string s1, s2;
    s1 = to_string(x);
    s2 = to_string(y);
    if (s1 < s2){
        cout << s1 << endl;
    }
    else{
        cout << s2 << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double eps=1e-2;
const int MAXN = 1e5+5;
int a[MAXN];
int main()
{
    int n, k; cin>>n>>k;
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    int ans=a[n-1];
    for(int i=0; i<n; i++) {
        if(i+k-1<n) ans=min(a[i+k-1]-a[i],ans);
        else break;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n,*w = [int(i) for i in read().split()]
#n,*t = map(int,read().split())

#n = int(input())
#s = input()
h,n = [int(i) for i in readline().split()]

 
def div(m,a,b,dp): #divide by (1+bx^a) up to x^m
    for i in range(m-a+1):
        dp[i+a] = min(dp[i+a], dp[i]+b)
    for i in range(max(m-a+1,0),m):
        dp[-1] = min(dp[-1],dp[i]+b)
        #dp[i+c] += dp[i]


INF = 10**9+7
dp =[INF]*(h+1)
dp[0] = 0

for _ in range(n):
    a,b = [int(i) for i in readline().split()]
    div(h,a,b,dp)
    #print(a,b,dp)
 


print(dp[-1])


Measured memory_bytes: 40304
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	string res="";
	for(int i=0;i<s.size();i+=2) res+=s[i];
	cout<<res<<endl;
}


Measured memory_bytes: 592
#Between Two Integers
def ABC_61_A():
    x,y = map(int, input().split())
    list1 = [1,3,5,7,8,10,12]
    list2 = [4,6,9,11]
    list3 = [2]
    
    if list1.count(x) == 1 and list1.count(y) == 1:
        print('Yes')
    elif list2.count(x) == 1 and list2.count(y) == 1:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':

    ABC_61_A()

Measured memory_bytes: 3064
import sys; readline = sys.stdin.readline
from collections import deque


X, Y = map(int, readline().split())

n = 2 * X - Y
m = 2 * Y - X
if n < 0 or m < 0 or n % 3 != 0 or m % 3 != 0:
    print(0)
    exit(0)

n = (2 * Y - X) // 3
m = (2 * X - Y) // 3

P = 10**9 + 7

t = n + m
s = min(n, m)

ans = 1
for i in range(t, t - s, -1):
    ans = ans * i
    ans %= P

d = 1
for i in range(s):
    d *= (i + 1)
    d %= P

def sp(x, n):
    if n == 0:
        return 1
    r = n % 2
    ret = sp(x, n//2) ** 2
    ret %= P
    if r == 1:
        ret *= x
        ret %= P
    return ret
dinv = sp(d, P - 2)

ans = ans * dinv
ans %= P

print(ans)

Measured memory_bytes: 39408
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
#define mkp make_pair
typedef long long ll;
using namespace std;

typedef pair<ll,ll> H;

string S,T;

struct RollingHash {
    ll base1;
    ll base2;
    ll mod1;
    ll mod2;
    vector<ll> hash1;
    vector<ll> hash2;
    vector<ll> pow1;
    vector<ll> pow2;

    RollingHash() : base1(1009), base2(1007), mod1(1000000007), mod2(1000000009) {}

    void init(const string &s) {
        int n = s.size();
        hash1.assign(n+1,0);
        hash2.assign(n+1,0);
        pow1.assign(n+1,1);
        pow2.assign(n+1,1);

        for(int i=0;i<n;i++) {
            hash1[i+1] = (hash1[i]+s[i]) * base1 % mod1;
            hash2[i+1] = (hash2[i]+s[i]) * base2 % mod2;
            pow1[i+1] = pow1[i] * base1 % mod1;
            pow2[i+1] = pow2[i] * base2 % mod2;
        }
    }

    H get(int l,int r) {
        ll t1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
        ll t2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
        return make_pair(t1, t2);
    }
};


bool ok[2000020];

int num[2000020];

int m;
vector<int> p;

int dfs(int now,int d){
    if(num[now]>0) return num[now];
    if(d>m){
        cout<<-1<<endl;
        exit(0);
    }
    if(ok[now]==false) return 0;

    p.push_back(now);
    int nex=(now+T.size())%m;
    int res=dfs(nex,d+1)+1;
    return num[now]=res;
}

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

  string A=S;
  while(A.size()<T.size()) A+=S;


  m=A.size();
  A+=A;
  RollingHash p;
  RollingHash q;
  p.init(A);
  q.init(T);

  H targ=q.get(0,T.size());

  for(int i=0;i<m;i++){
      H a=p.get(i,i+T.size());
      if(a==targ){
          ok[i]=true;
      }
  }

  int ans=0;

  for(int i=0;i<m;i++){
      ans=max(ans,dfs(i,1));
  }

  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 120236
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
using pii = pair<int, int>;

priority_queue <int> pq;
vector <pii> work; //(lastdate, money)
int n, m;
int money;
int32_t main()
{
	usecppio
	cin >> n >> m;
	work.resize(n);
	for (int i = 0; i<n; i++)
	{
		int a, b;
		cin >> a >> b;
		work[i] = {m-a+1,b};
	}
	sort(all(work));
	for (int date = m; date > 0; date--)
	{
		if (!work.empty())
		{
			while(work.back().first==date)
			{
				//printf("Push %d at %d\n",work.back().second,date);
				pq.push(work.back().second);
				work.pop_back();
			}
		}

		if (!pq.empty())
		{
			//printf("Do %d at %d\n",pq.top(),date);
			money += pq.top();
			pq.pop();
		}
	}
	cout << money;
}

Measured memory_bytes: 1660
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long int dp[100001];

int main(){
    long long int n,k;
    fill(dp,dp+100001,1000000000);
    dp[0] = 0;

    cin >> n >> k;
    vector<long long int>v(n);

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

    for(int i = 0;i < n;i++){
        
        for(int j = 1;j <= k;j++){
            dp[i+j] = min(abs(v[j+i]-v[i])+dp[i],dp[i+j]);
        }
    }

    cout << dp[n-1] << endl;

    return 0;
}

Measured memory_bytes: 1792
def main():
    from collections import defaultdict
    n, *a = map(int, open(0).read().split())
    d = defaultdict(lambda: {'R': 0, 'L': 0})

    for i, x in enumerate(a, 1):
        d[i + x]['R'] += 1
        d[i - x]['L'] += 1

    ans = 0
    for key, dic in d.items():
        l = dic['L']
        r = dic['R']
        ans += l * r

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 145308
n,x=map(int,input().split())
if not (2 <= x <= 2*n-2):
    print('No')
    exit(0)
print('Yes')
ans = []
if n == 2:
    ans = [1,2,3]
else:
    d=[i for i in range(1,2*n)]
    ans=[0]*(2*n-1)
    v=[]
    if x > 2:
        v = [x-1, x, x+1, x-2]
    else:
        v = [x+2, x, x-1, x+3]
    for w in v:
        d.remove(w)
    ans[n-2:n+2] = v
    for i in range(2*n-1):
        if ans[i] == 0:
            ans[i] = d.pop()
for v in ans:
    print(v)

Measured memory_bytes: 12568
#!/usr/bin/env python


def read():
    return map(int, raw_input().split())



def work((a, b)):
    def calc(h, w):
        minV = 1 << 30
        for hh in range(1, h + 1):
            area1 = hh * w
            area2 = (h - hh) / 2 * w
            area3 = (h - hh + 1) / 2 * w
            minV = min(minV, max(area1, area2, area3) - min(area1, area2, area3))
            area2 = (h - hh) * (w / 2)
            area3 = (h - hh) * ((w + 1) / 2)
            minV = min(minV, max(area1, area2, area3) - min(area1, area2, area3))
        return minV

    print min(calc(a, b), calc(b, a))


if __name__ == "__main__":
    work(read())


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    ll n,m; cin >> n >> m;
    if(n == 1) {
        if(m == 1) {
            cout << 1 << endl;
            return 0;
        }
        cout << m - 2 << endl;
        return 0;
    } else {
        if(m == 1) {
            cout << n-2 << endl;
            return 0;
        }
        ll ans = m*n - 4;
        if(n > 2) {
            ans -= 2*(n-2);
        }
        if(m > 2) {
            ans -= 2*(m-2);
        }
        cout << ans << endl;
    }

    return 0;
}


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

int main() {
	char count[100];
	scanf("%s", count);
	int flg = 0;
	
	for (int i = 0; i < 50; i++) {
		if (count[2 * i] == 'L')flg = 1;
	}
	for (int i = 0; i < 50; i++) {
		if (count[2 * i + 1] == 'R')flg = 1;
	}
	if (flg == 0)printf("Yes");
	else printf("No");


	return 0;
}

Measured memory_bytes: 128
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        mut a: usize,
        mut b: usize,
    }
    let mut ans = 0;
    for _ in 0..2 {
        if a >= b {
            ans += a;
            a -= 1;
        } else {
            ans += b;
            b -= 1;
        }
    }

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


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

				Scanner sc = new Scanner(System.in);

				int N = sc.nextInt();
				double T = sc.nextDouble();
				double A = sc.nextDouble();
				double[] H = new double[N];
				double sa = 99999999.9;
				int ans = 0;

				for(int i = 0; i < N; i++) {
					H[i] = sc.nextDouble();
				}

				for(int i = 0; i < N; i++) {
					double tmp = T - H[i]*0.006;
					double abs = Math.abs(A - tmp);
					if(abs<sa) {
						ans = i+1;
						sa = abs;
					}
				}

				System.out.println(ans);

	}

}

Measured memory_bytes: 28244
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,j=0,N,M,a,b;
  cin>>N>>M;
  vec v(N+1,0);
  rep(i,M*2){
    cin>>a;
    v[a]++;
  }
  rep1(i,N+1){
    if(v[i]%2){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

vector<ll> pw2(51,1);
vector<ll> pw10(19,1);

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}
ll myceil(ll x,ll y){
	if(x<=y) return 1;
	else if(x%y==0) return x/y;
	else return x/y+1;
}

//a,b x
int main(){
	ll x,y,l; cin>>x>>y>>l;
	if(x==0) cout<<y/l+1;
	else cout<<y/l-(x-1)/l;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next()+sc.next();
		int x = Integer.parseInt(s);
		for(int i=1; i<=500; i++){
			if(i*i==x){
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
		return;
	}
}

Measured memory_bytes: 22996
import sys
sys.setrecursionlimit(10**6)
n,m = map(int, input().split())

INF = 1001001001

to = [[] for _ in range(n)]
dist = [INF]*n
dist[0] = 0
ans = [-1]*n
ans[0] = [0]

for i in range(m):
    a,b = map(int, input().split())
    a -= 1; b -= 1
    to[a].append(b)
    to[b].append(a)

import queue

q = queue.Queue()
used = [0]*n
q.put(0)
used[0] = 1 # qに突っ込んだ時点でその頂点のusedを1にする

while not q.empty():
    v = q.get()
    for i in range(len(to[v])):
        u = to[v][i]
        if used[u]: continue
        if dist[v]+1 < dist[u]:
            dist[u] = dist[v]+1
            ans[u] = v
        q.put(u)
        used[u] = 1 # qに突っ込んだ時点でその頂点のusedを1にする

if -1 not in ans:
    print('Yes')
    for i in ans[1:]: print(i+1)
else:
    print('No')

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

int main() {
  int X, Y, Z;
  cin >> X >> Y >> Z;
  int cnt = 1;
  int len = Y + Z * 2;
  do {
    len += Y + Z;
    if (X < len) {
      break;
    }
    ++cnt;
  } while (X != len);
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

#define NMAX 100000

using namespace std;

typedef unsigned long long int ull;
static ull N, M;
static char S[NMAX], T[NMAX];

ull gcd(ull a, ull b) {
  ull t;
  while (b) {
    t = a % b;
    a = b;
    b = t;
  }
  return a;
}

bool is_good(const char *X, ull L) {
  if (L % N != 0 || L % M != 0) {
    return false;
  }

  for (ull i = 0; i < N; i++) {
    if (X[i * L/N] != S[i]) {
      return false;
    }
  }

  for (ull i = 0; i < M; i++) {
    if (X[i * L/M] != T[i]) {
      return false;
    }
  }

  return true;
}

int main(int ac, char **av) {
  scanf("%lld %lld", &N, &M);
  scanf("%s", S);
  scanf("%s", T);
  ull g = gcd(N, M);
  for (ull i = 0; i < min(N, M); i++) {
    if (((i * N) % M == 0 && (i * N) / M < N && S[(i * N) / M] != T[i]) || ((i * M) % N == 0 && (i * M) % N < M && S[i] != T[(i * M) / N])) {
      printf("-1\n");
      return 0;
    }
  }
  printf("%lld\n", N*M/g);
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int a = sc1.nextInt();
		int b = sc1.nextInt();
		double ans = (double)a/b;

		System.out.println(a/b + " " + a%b + " " + String.format("%.8f", ans));

		sc1.close();

	}

}


Measured memory_bytes: 26552
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	long long N, M, K;
	cin >> N >> M >> K;
	vector<long long> A(N, 0), a(N + 1, 0);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		a[i + 1] = a[i] + A[i];
	}
	vector<long long> B(M, 0), b(M + 1, 0);
	for (int i = 0; i < M; i++) {
		cin >> B[i];
		b[i + 1] = b[i] + B[i];
	}

	int ans = 0;
	int j = M;
	for (int i = 0; i <= N; i++) {
		if (a[i] > K) {
			break;
		}
		while (b[j] > K - a[i]) {
			j--;
		}
		ans = max(ans, i + j);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9596
#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    REP(i, n) {
        int a;
        cin >> a;
        l[i] = a;
    }

    sort(ALL(l), greater<int>());
    cout << accumulate(l.begin(), l.begin()+k, 0) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(final String[] args) throws Exception {

        final int[] ans = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4,
                1, 51 };
        final Scanner scan = new Scanner(System.in);
        final String index = scan.nextLine();
        System.out.println(ans[Integer.parseInt(index) - 1]);
        scan.close();
    }
}

Measured memory_bytes: 21972
H, W = map(int, input().split())

l = []
for i in range(H):
  l.append(list(input()))

for h in range(H):
  for w in range(W):
    if l[h][w] == "#":
      continue
    cnt = 0
    for x in range(-1, 2):
      for y in range(-1, 2):
        if h+x >= 0 and w+y >= 0 and h+x < H and w+y < W:
          if l[h+x][w+y] == "#":
            cnt = cnt + 1
    l[h][w] = str(cnt)

for i in l:
  print("".join(i))


Measured memory_bytes: 3188
n = input()
a = []
n = int(n)

for i in range(n):
    a.append(int(input()))

if n == 1:
    print(a[0])
else:
    s = sorted(a, reverse=True)[0]
    t = sorted(a, reverse=True)[1]

    for i in a:
        if i == s:
            print(t)
        else:
            print(s)

Measured memory_bytes: 14652
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
    static void Main()
    {
        var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int left = r[0] + r[1];
        int right = r[2] + r[3];

        if (left > right)
        {
            Console.WriteLine("Left");
        }
        else if(right> left)
        {
            Console.WriteLine("Right");
        }
        else
        {
            Console.WriteLine("Balanced");
        }
    }
}

Measured memory_bytes: 28136
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Swap(int[] ary, int i)
    {
        ary[i] = ary[i] ^ ary[i + 1];
        ary[i + 1] = ary[i] ^ ary[i + 1];
        ary[i] = ary[i] ^ ary[i + 1];
    }
    static int BubbleSort(int[] ary)
    {
        int swapnum = 0;
        bool swapped = true;
        while (swapped)
        {
            swapped = false;
            for (int i = 0; i < ary.Length - 1; i++)
            {
                if (ary[i] > ary[i + 1])
                {
                    swapnum++;
                    swapped = true;
                    Swap(ary, i);
                }             
            }
        }
        return swapnum;
    }
    public static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int res = BubbleSort(A);
        for (int i = 0; i < N - 1; i++) Console.Write("{0} ", A[i]);
        Console.WriteLine(A[N - 1]);
        Console.WriteLine(res);
    }
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

vector<vector<pair<int, ll>>> tree(100001);
vector<ll> cost(100001);

void dfs(int c, int p, ll v) {
	cost[c] = v;
	for (pair<int, int> tmp : tree[c]) {
		if (tmp.first != p) {
			dfs(tmp.first, c, v + tmp.second);
		}
	}
}

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

	int n;
	cin >> n;

	rep (i, 0, n - 1) {
		int a, b, c;
		cin >> a >> b >> c;

		tree[a].push_back(make_pair(b, c));
		tree[b].push_back(make_pair(a, c));
	}

	int q, k;
	cin >> q >> k;

	dfs(k, -1, 0);

	rep (i, 0, q) {
		int x, y;
		cin >> x >> y;

		cout << cost[x] + cost[y] << endl;
	}

	return 0;
}


Measured memory_bytes: 14336
using System;
class slime{
  public static void Main(){
    int n = int.Parse(Console.ReadLine());
    String str = Console.ReadLine();
    char com = str[0];
    int count = 1;
    n++;
    foreach(char c in str){
      if(com != c){
        count++;
        com = c;
      }
    }
    Console.WriteLine(count);
  }
}


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

int main() {
    int n;
    cin >> n;
    ll ans = 0;
    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
    }

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

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int i,j,s=0,t=0,a[4],b[4];
	for(j=0;j<2;j++)
	{
		for(i=0;i<4;i++)
		{
			if(j==0)
			{
				cin>>a[i];
				s=a[i]+s;
			}
			else
			{
				cin>>b[i];
				t=b[i]+t;
			}
		}
	}
	if(t<s)
	{
	 cout<<s<<endl;
	}
	else
	{
	cout<<t<<endl;
	}	
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a>0&&b>0){
        cout<<"Positive"<<endl;
    }
    else if(a<=0&&0<=b){
        cout<<"Zero"<<endl;
    }
    else{
        if((b-a+1)%2){
            cout<<"Negative"<<endl;
        }else{
            cout<<"Positive"<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    string s;
    std::cin >> a >> b >>s;
    for (int i = 0; i < a+b+1; i++) {
        if(i==a && s[i]!='-'){
            std::cout << "No" << std::endl;
            return 0;
        }
        if(i!=a && s[i]=='-'){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 4e6+10;
int n, a;
int sum;
bitset<N> b;
int main() {
	scanf("%d", &n);
	b[0] = 1;
	for(int i = 1; i <= n; i++) {
		scanf("%d", &a);
		b |= b<<a;
		sum += a;
	}
	for(int i = (sum+1)/2; i <= sum; i++) {
		if(b[i] == 1) {
			printf("%d\n", i);
			return 0;
		}
	}
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	map<string, int> m;

	int n;
	cin >> n;
	string s[n];

	REP(i, n){
		cin >> s[i];
		if (i != 0){
			if (s[i][0] != s[i - 1].back()){
				cout << "No" << endl;
				return 0;
			}
		}
		m[s[i]]++;
	}

	for (auto& x : m){
		if (x.second != 1){
			cout << "No" << endl;
			return 0;
		}

	}

	cout << "Yes" << endl;

}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String strIn =scan.nextLine();
		int intLoop = 0;
		int intSplit = 0;
		String strAns = "";
		String strTemp = "";
		ArrayList<String> list = new ArrayList<String>();
		while(!"-".equals(strIn)){
			intLoop = scan.nextInt();
			for(int i = 0; i < intLoop; i++){
				intSplit = scan.nextInt();
				strTemp = "";
				strAns ="";
				for(int j = 0; j < strIn.length(); j++){

					if(j < intSplit){
						strTemp += strIn.charAt(j);
						//System.out.println("strTemp : " + strTemp);
					}else{
						strAns += strIn.charAt(j);
						//System.out.println("strAns : " + strAns);
					}
				}
				strIn = strAns + strTemp;
			}
			//System.out.println(strIn);
			list.add(strIn);
			strIn =scan.next();
		}
		for(int i = 0; i < list.size(); i++){
			System.out.println(list.get(i));
		}
		scan.close();
	}
}

Measured memory_bytes: 39344