akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
class Program
    {
    	static void Main(string[] args)
    	{
            string[] s0 = Console.ReadLine().Split(' ');
            int h = int.Parse(s0[0]);
            int w = int.Parse(s0[1]);
            int k = int.Parse(s0[2]);
            int[,] map = new int[h, w];
            Queue<int[]> queue = new Queue<int[]>();
            
            for (int i=0; i<h; i++)
            {
                string s = Console.ReadLine();
                for (int j=0; j<w; j++)
                {
                    switch (s[j])
                    {
                        case '.':
                        map[i, j] = -1;
                        break;

                        case '#':
                        map[i, j] = -2;
                        break;

                        case 'S':
                        map[i, j] = 0;
                        queue.Enqueue(new int[] {i, j});
                        break;
                    }
                }
            }

            int dist = 999;

            while (queue.Count > 0)
            {
                int[] pos = queue.Dequeue();
                int posX = pos[0];
                int posY = pos[1];
                if (map[posX, posY] > k) break;
                int newDist = Math.Min(Math.Min(Math.Min(posX, posY), h-1-posX), w-1-posY);
                if (newDist < dist) dist = newDist;
                if (dist == 0) break;

                if (map[posX + 1, posY] == -1)
                {
                    map[posX + 1, posY] = map[posX, posY] + 1;
                    queue.Enqueue(new int[] {posX + 1, posY});
                }
                if (map[posX - 1, posY] == -1)
                {
                    map[posX - 1, posY] = map[posX, posY] + 1;
                    queue.Enqueue(new int[] {posX - 1, posY});
                }
                if (map[posX, posY + 1] == -1)
                {
                    map[posX, posY + 1] = map[posX, posY] + 1;
                    queue.Enqueue(new int[] {posX, posY + 1});
                }
                if (map[posX, posY - 1] == -1)
                {
                    map[posX + 1, posY] = map[posX, posY] + 1;
                    queue.Enqueue(new int[] {posX, posY - 1});
                }
            }
            if (dist == 0) Console.WriteLine(1);
            else Console.WriteLine((dist - 1) / k + 2);

            
            
        }
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 22852
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0643?year=2018

#include <bits/stdc++.h>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;

    int a[25][25];
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }

    auto ans = (int) 1e9;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int temp = 0;
            for (int k = 0; k < h; ++k) {
                for (int l = 0; l < w; ++l) {
                    temp += a[k][l] * min(abs(i - k), abs(j - l));
                }
            }
            ans = min(temp, ans);
        }
    }

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

/*
 * 全検索
 * 幹線道路を(i,j)で指定。
 * 交差点(k,l)の住人についての和は
 * min(|i-k|,|j-l|)*a[k][l]
 *
 */


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const long long INF = 1LL << 60;
const ll MOD = 1000000007;
using pint = pair<ll, ll>;

int main() {
  ll N, M;
  ll a, b;
  cin >> a >> b;
  N = min(a, b);
  M = max(a, b);
  if (N == 1 && M == 1) {
    cout << 1 << endl;
  }
  else if(N-2>=0 && M-2>=0){
    cout << (N-2) * (M - 2) << endl;
  }
  else if(N-2>=0 || M-2>=0){
    cout << max(N-2, M-2) << endl;
  }
  else{
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 3536
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

ll a[200010];
int main(){
	ll n;
	scanf("%lld",&n);
	rep(i,0,n)scanf("%lld",a+i);
	sortdown(a,n);
	ll ans=0;
	for(ll i=0;i<n;){
		ll cnt=0,t=i;
		while(a[t]==a[i])cnt++,t++;
		if(cnt>=a[i])ans+=cnt-a[i];
		else ans+=cnt;
		i=t;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 1660
import java.util.*;

class Main{

  public static void main(String args[]){

    Scanner s=new Scanner(System.in);
    int A=s.nextInt();
    int B=s.nextInt();
    int C=s.nextInt();
    int K=s.nextInt();
    int ans=0;
    int i=0;
    for(;i<A&&i<K;i++) ans++;
    for(;i<A+B&&i<K;i++) ;
    for(;i<A+B+C&&i<K;i++) ans--;
    System.out.println(ans);
  }  
}

Measured memory_bytes: 35768
/*
　　　　 ∧＿∧　にっぽんちゃちゃちゃ
　／＼（　・∀・）／ヽ
（ ●　と　　　つ　● ）　にっぽんちゃちゃちゃ
　＼/⊂、 ノ　　＼ノ
　　　　　し'
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define MOD 1000000007
#define INF 9223372036854775807


signed main()
{
  string xyz ="";
int x=0,y=0,z=0,w=0,i=0,j=0,n=0;
std::vector<int> v;
while (std::cin >> x>>y) {
  z=x+y;
  i=1;
  for(;;){
    if(z/10==0){
      std::cout << i << '\n';
      break;
    }
    z/=10;
    i++;
  }
  /* code */
}
}



Measured memory_bytes: 3004
package main

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

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

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	a, b := nextInt(), nextInt()

	// a_f := big.NewFloat(float64(a))
	// b_f := big.NewFloat(float64(b))
	// f := new(big.Float).SetPrec(1024).Quo(a_f, b_f)

	fmt.Fprintf(out, "%d %d %.5f\n", a/b, a%b, float64(a)/float64(b))
}

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}



Measured memory_bytes: 1220
#include <bits/stdc++.h>
using namespace std;
bool iskai(string s);
int main() {
	int n;
	string s;

	cin >> s;
	n=s.length();
	if (!iskai(s)){
		cout << "No" << endl;
	}else if(!iskai(s.substr(0,(n-1)/2))){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

bool iskai(string s){
	int n;

	n=s.length();
	for(int i=0;i<n/2;i++){
		if (s[i]!=s[n-i-1]){
			return false;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	sort(A.rbegin(), A.rend());
	
	int ansA = 0, ansB = 0;
	REP(i, N) {
		if (IsEven(i)) {
			ansA += A[i];
		} else {
			ansB += A[i];
		}
	}
	cout << ansA - ansB << endl;
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

string date[7] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

int main(){

    int year = 2004,month,day;

    while(cin >> month >> day){
    
        if(month == 0){
            return 0;
        }

        if(month == 1 || month==2){
            year--;
            month += 12;
        }
    
        int tmp = (year + year/4 - year/100 + year/400 + (13*month+8)/5 + day)%7;
    
        cout << date[tmp] << endl;
    }
    
    return 0;

}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 300, 10min

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

ll x;

signed main()
{
    cin >> x;
    ll ans = (x / 11) * 2;
    if(x % 11 == 0) { }
    else if(x % 11 <= 6) { ans += 1; }
    else { ans += 2; }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=9999999999;


int main(){
    ll n;
    cin>>n;
    vector<vector<P> > G(n);
    for(ll i=0;i<n-1;i++){
        ll u,v,w;
        cin>>u>>v>>w;
        u--; v--;
        G[u].push_back(P(v,w));
        G[v].push_back(P(u,w));
    }
    vector<bool> ans(n,false);
    vector<bool> done(n,false);
    done[0]=true;
    queue<ll> q;
    q.push(0);
    while(!q.empty()){
        ll now=q.front(); q.pop();
        for(P pp:G[now]){
            ll to=pp.first;
            ll w=pp.second;
            if(!done[to]){
                //cout<<now<<" "<<to<<endl;
                if(w%2==0){
                    ans[to]=ans[now];
                }else{
                    ans[to]=!ans[now];
                }
                done[to]=true;
                q.push(to);
            }
        }
    }
    for(ll i=0;i<n;i++) cout<<ans[i]<<endl;

}

Measured memory_bytes: 10656
#include <iostream>

using namespace std;

const int MAX = 101010;
int X[MAX];

int main()
{
  long long N, A, B;
  cin >> N >> A >> B;

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

  long long ans = 0;
  for (int i = 1; i < N; i++) {
    ans += min(A * (X[i+1] - X[i]), B);
  }

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


Measured memory_bytes: 640
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

int n;

void solve() {
  ll a, b, c, d;
  cin >> n >> a >> b >> c >> d;
  n--;
  bool can = false;
  for(int inc = 0; inc <= n; inc++) {
    ll smallest = a + c * inc - d * (n - inc);
    ll largest = a + d * inc - c * (n - inc);
    can |= smallest <= b && b <= largest;
  }
  if(can) cout << "YES\n";
  else cout << "NO\n";
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  /*
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << ": ";
    solve();
  }
  */
  solve();
}


Measured memory_bytes: 256
package main

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

func SelectionSort(buf []int) int {
	count := 0

	for i := 0; i < len(buf)-1; i++ {
		min := buf[i]
		index := i

		for j := i + 1; j < len(buf); j++ {
			if min > buf[j] {
				min = buf[j]
				index = j
			}
		}
		if i != index {
			buf[i], buf[index] = buf[index], buf[i]
			count++
		}
	}
	return count
}

func main() {

	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	buf := make([]int, n)

	sc.Scan()
	line := sc.Text()
	words := strings.Split(line, " ")
	for i, word := range words {
		buf[i], _ = strconv.Atoi(word)
	}

	count := SelectionSort(buf)

	for i, val := range buf {
		if i == len(buf)-1 {
			fmt.Printf("%d\n", val)
		} else {
			fmt.Printf("%d ", val)
		}
	}
	fmt.Println(count)
}



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

import sys
import os
import math
from collections import defaultdict

for s in sys.stdin:
    n = int(s)
    if n == 0:
        break

    d = defaultdict(int)
    keys = []
    for i in range(n):
        e, p, q = map(int, input().split())
        d[e] += p * q
        if e not in keys:
            keys.append(e)

    # remove dup
    is_exist = False

    for key in keys:
        v = d[key]
        if v >= 1000000:
            print(key)
            is_exist = True

    if not is_exist:
        print('NA')

Measured memory_bytes: 8104
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
   string s;
   cin>>s;
   int acount=0;
   int bcount=0;
   int ccount=0;
   rep(i,3){
       if(s.at(i)=='a'){
           acount++;
       }
   }
    rep(i,3){
       if(s.at(i)=='b'){
           bcount++;
       }
   }
    rep(i,3){
       if(s.at(i)=='c'){
           ccount++;
       }
   }
   if(acount==bcount&&bcount==ccount&&ccount==1){
       cout<<"Yes"<<endl;
   }
   else
   {
       cout<<"No"<<endl;
   }
   
}



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

typedef long long ll;
using namespace std;

ll get_len(ll x) {
  ll l = 0;
  while (x != 0) {
    x /= 10;
    l++;
  }
  return l;
}

int main() {
  ll n; cin >> n;
  ll sq = sqrt(n);

  ll ans = 9999999;
  for (int i = 1; i <= sq; i++) {
    if (n % i == 0) {
      ll j = n / i;
      ll res = max(get_len(i), get_len(n / i));
      ans = min(res, ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
h=list(map(int,input().split()))
c=[1]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]<=h[b-1]:
    c[a-1]=0
  if h[a-1]>=h[b-1]:
    c[b-1]=0
print(sum(c))

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

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

    int n; cin >> n;
    string s;
    int ac = 0, wa = 0, tle = 0, re = 0;

    for (int i=0; i<n; i++) {
        cin >> s;
        if (s == "AC") ac++;
        else if (s == "WA") wa++;
        else if (s == "TLE") tle++;
        else re++;
    }

    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";

       

    return 0;
}


Measured memory_bytes: 3656
maxNum, brokenCount = map(int,input().split(" "))

brokenIndexSet = set([int(input()) for i in range(brokenCount)])

ans = [0] * (maxNum + 1)
ans[0] = 1

for i in range(1,maxNum+1):
  if i in brokenIndexSet:
    ans[i] = 0
  else:
    ans[i] = (ans[i-1] + ans[i-2]) % 1000000007

print(ans[maxNum])

Measured memory_bytes: 13192
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String input = sc.nextLine();
            int i = 0;
            String output = "";
            while (i < input.length()) {
                if (input.charAt(i) == '@') {
                    int r = Integer.parseInt(String.valueOf(input.charAt(i + 1)));
                    for (int n = 1; n < r; n++) {
                        output += input.charAt(i + 2);
                    }
                    i++;
                } else {
                    output += input.charAt(i);
                }
                i++;
            }
            System.out.println(output);
        }
    }
}

Measured memory_bytes: 17324
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e10
using namespace std;
typedef pair<ll, ll> P;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main(void) {
	int n;
	cin >> n;
	cout << n * (n + 1) / 2 << endl;
	return 0;
}

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

int main(){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if((A+B)>(C+D)){
    cout << "Left" << endl;
  }
  else if((A+B)==(C+D)){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
h, w = map(int, input().split())
A = []
for i in range(h):
    s = input()
    if s != "." * w:
        A.append(s)

h = len(A)
white_col_index = []
for j in range(w):
    s = "".join([A[i][j] for i in range(h)])
    if s == "." * h:
        white_col_index.append(j)

output_col_index = sorted(list(set(range(w)) - set(white_col_index)))
for i in range(h):
    print("".join(A[i][j] for j in output_col_index))

Measured memory_bytes: 3064
from collections import Counter
import sys
h=w=index=0
n=int(input())
a=list(map(int,input().split()))
l=Counter(a)
l2=sorted(l.items(),reverse=True)
for i in range(len(l2)):
  if l2[i][1]>=2:
    if l2[i][1]>=4:
      print(l2[i][0]**2)
      sys.exit()
    w=l2[i][0]
    index=i
    break
for i in range(index+1,len(l2)):
  if l2[i][1]>=2:
    h=l2[i][0]
    break
print(h*w)


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

int main() {
   int N;char S;
   cin>>N;
   for(int i=0;i<N;i++){
       cin>>S;
       if(S=='Y'){
            cout<<"Four"<<endl;
            break;
      }else if(i==N-1){
           cout<<"Three"<<endl;
     }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int 
#define pb push_back
#define vv vector<ll>
#define MAX 105000
#define fr(i,x) for(int i=0;i<x;i++)
int dx[4] = {-1,0,0,1};
int dy[4] = {0,-1,1,0};

bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    
    if(a.first == b.first) return a.second<b.second;
    return (a.first < b.first); 
}
ll ar[MAX];
void divisor(){
    for (int i = 1; i <= MAX; i++)
    {
        for (int j = i; j <= MAX;j+=i)
        {
            ar[j]++;
            
        }
        
        
    }
    
}
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    
    ll h,n,x,min,c = 0;
    cin >>h >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> x;
        c += x;
    }
    if(c >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
        
}

Measured memory_bytes: 3644
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    ll a,b,n;
    cin>>a>>b;
    ll ans=0;
    while(a<=b)
    {
        a*=2;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  char C;
  cin >> C;
  cout << char(C+1) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin >> a >> b >> c;
  bool ans;
  for(int i=0;i<b;i++){
    if((b*i+c)%a==0){
       ans=true;
       break;
    }else{
       ans=false;
    }
  }
  if(ans){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
def main():
    import sys

    def I():
        return int(sys.stdin.readline().rstrip())

    def S():
        return sys.stdin.readline().rstrip()

    N = I()
    G = [[] for i in range(N + 1)]

    for i in range(N - 1):
        a, b, c = map(int, S().split())
        G[a].append((b, c))
        G[b].append((a, c))

    Q, K = map(int, S().split())

    from collections import deque

    distance = [-1] * (N + 1)  # arrive[i] = 頂点Kからの最短距離
    distance[K] = 0

    q = deque([K])
    while q:
        a = q.pop()
        for b, c in G[a]:
            if distance[b] != -1:
                continue
            distance[b] = distance[a] + c
            q.appendleft(b)

    for i in range(Q):
        x, y = map(int, S().split())
        print(distance[x] + distance[y])

if __name__ == '__main__':
    main()

Measured memory_bytes: 72752
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll MOD = 1000000007;  // 1e9 + 7

// Digit DP.

// In each digit, x and y is in one of the three.
// - x=0, y=0
// - x=0, y=1 (In this case, most significant bit must appear in the left bits)
// - x=1, y=1

// (digit)
// (L <= x is already satisfied by the left bits)
// (y <= R is already satisfied by the left bits)
// (most significant bit already appeared)
ll dp[61][2][2][2];

int main(int argc, char** argv) {
  ll L, R;
  cin >> L >> R;

  dp[0][0][0][0] = 1; // dp[i] represents the result of top-i digits. i-0 is initialized.
  for (ll i = 0; i < 60; ++i) {
    ll lb = (L >> (59-i)) & 1;
    ll rb = (R >> (59-i)) & 1;
    rep(j, 2) rep(k, 2) rep(s, 2) { // previous state
      ll pre = dp[i][j][k][s];
      rep(x, 2) rep(y, 2) {
        if (x && !y) { continue; } // x 1, y 0

        // Calculate the next state.
        if (!s && x != y) { continue; }
        int ns = s || (x && y); // x = 1, y = 1, bit appeared
        // j: L <= x
        if (!j && !x && lb) { continue; } // x = 0, lb = 1, invalid
        int nj = j || (x && !lb); // x = 1, lb = 0, L <= x is satisfied
        // k: y <= R
        if (!k && y && !rb) { continue; } // y = 1, rb = 0, invalid
        int nk = k || (!y && rb); // y = 0, rb = 1, y <= R is satisfied

        dp[i+1][nj][nk][ns] += pre;
        dp[i+1][nj][nk][ns] %= MOD;
      }
    }
  }
  ll ans = 0;
  rep(j, 2) rep(k, 2) rep(s, 2) {
    ans += dp[60][j][k][s];
    ans %= MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int H, W;
	cin >> H >> W;
	vector<string> a(H);
	int memo[26] = {0};
	REP(i, H) {
		cin >> a[i];
		REP(j, W) {
			memo[a[i][j] - 'a']++;
		}
	}
	priority_queue<int> pq;
	REP(i, 26) {
		pq.emplace(memo[i]);
	}
	REP(i, H / 2) {
		REP(j, W / 2) {
			int num = pq.top();
			pq.pop();
			if (num < 4) {
				cout << "No" << endl;
				return 0;
			}
			pq.emplace(num - 4);
		}
	}
	if (H % 2) {
		REP(j, W / 2) {
			int num = pq.top();
			pq.pop();
			if (num < 2) {
				cout << "No" << endl;
				return 0;
			}
			pq.emplace(num - 2);
		}
	}
	if (W % 2) {
		REP(i, H / 2) {
			int num = pq.top();
			pq.pop();
			if (num < 2) {
				cout << "No" << endl;
				return 0;
			}
			pq.emplace(num - 2);
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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


int main() {
  int n;
  double ans, A;
  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> A;
    ans += 1.0 / A;
  }
  cout << setprecision(16) << (1.0 / ans) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int
map<lli, lli> dp[200005][2];
// dp[i][j][k] := iまでにk回休んでjが1なら直前休んだ
void set_v(lli i, lli j, lli k, lli v)
{
  // cout << i << " " << j << " " << k << " <- " << v << endl;

  if (dp[i][j].find(k) != dp[i][j].end())
    chmax(dp[i][j][k], v);
  else
  {
    dp[i][j][k] = v;
  }
}
void solve(long long N, std::vector<long long> A)
{
  dp[0][0][0] = 0;
  dp[0][1][0] = 0;

  rep(i, N) rep(j, 2)
  {
    for (auto s : dp[i][j])
    {
      if (s.first > (i + 8) / 2 || s.first < (i - 8) / 2)
      {
        continue;
      }
      if (j)
      {
        set_v(i + 1, 1, s.first + 1, s.second);
        set_v(i + 1, 0, s.first, s.second + A[i]);
      }
      else
      {
        set_v(i + 1, 1, s.first + 1, s.second);
      }
    }
  }
  cout << max(dp[N][1][N - N / 2], dp[N][0][N - N / 2]) << endl;
}

signed main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 142416
#include <iostream>
#include <algorithm>

using namespace std;

long long gcd(long a,long b){
  if(a<b)swap(a,b);
  while(b>0){
    long long r=a%b;
    a=b;
    b=r;
  }
  return a;
}

int main(){
  long long n,x;
  cin>>n>>x;
  cout<<(n-gcd(n,x))*3<<endl;
  return 0;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int a, b; cin >> a >> b;
    string s; cin >> s;

    bool ans = true;

    for (int i = 0; i < s.size(); ++i) {
        if (i == a) {
            if (s[i] != '-') {
                ans = false;
                break;
            }
        } else {
            int k = s[i] - '0';
            if (!(0 <= k && k <= 9)) {
                ans = false;
                break;
            }
        }
    }

    if (ans) {
        puts("Yes");
    } else {
        puts("No");
    }
}

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

int ans;
int a[300000];
int b[300000];

int main() {
	
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
	}
	sort(a, a + n);
	int key1 = a[n / 2 - 1];
	int key2 = a[n / 2];
	for (int i = 0; i < n; i++) {
		if (b[i] < key2) {
			cout << key2 << endl;
		}
		else cout << key1 << endl;
	}
	return 0;
}

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

int main() {
  long long N,c;
  c=0;
  cin >> N;
  vector<long long> A(N);
  for (long long i=0;i<N;i++) {
    cin >> A.at(i);
    if (i>0) {
      if (A.at(i)<=A.at(i-1)) {
        c+=A.at(i-1)-A.at(i);
        A.at(i)=A.at(i-1);
      }
    }
  }
  cout << c << endl;
}

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

int main()
{
    char s[10];
    cin >> s;
    bool flag = true;
    if (s[2] != s[3] || s[4] != s[5])
    {
        flag = false;
    }
    if (flag == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int A, B, C, D ;
  cin >> A >> B >> C >> D;

  if ( A + B > C + D ) {
    cout << "Left" << endl;
 }
  if ( A + B == C + D ) {
    cout << "Balanced" << endl;
 }
  if ( A + B < C + D ) {
    cout << "Right" << endl;
 }   
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int count=0,flag=0,cnt=0;
  if(s[0]=='A'){
    flag++;
  }
  for(int i=0;i<s.size();i++){
    
    if(int(s[i]<=90)){
       count++;
      
    }
   
  }
  
  for(int x=2;x<s.size()-1;x++){
    if(s[x]=='C'){
      cnt++;
    }
  }
  if(count==2&&flag==1&&cnt==1){
    cout<<"AC";
  }
  else{
    cout<<"WA";
  }
  return 0;
}

Measured memory_bytes: 256
IDENTIFICATION DIVISION.
      PROGRAM-ID. 108A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 K PIC 9(3).
      01 SHO PIC 9(3).
      01 AMA PIC 9(1).
      01 ANS PIC 9(4).
      01 ANSS PIC ZZZ9.
      
      PROCEDURE DIVISION.
      ACCEPT K.
      DIVIDE K BY 2 GIVING SHO REMAINDER AMA.
      COMPUTE ANS = SHO * ( SHO + AMA ).
      MOVE ANS TO ANSS.
      DISPLAY ANSS.
      STOP RUN.

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

int calcSumOfDigits(int n){
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  
  int lowest = N;
  
  for (int i = 1; i <= N / 2; i++) {
    int sumOfDigitsOfTwo = calcSumOfDigits(i) + calcSumOfDigits(N - i);
    
    if (sumOfDigitsOfTwo < lowest) lowest = sumOfDigitsOfTwo;    
  }
  
  cout << lowest << endl;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int a = s.nextInt();
		int b = s.nextInt();


		double d=((double)(a+b)/2);
		int i=(a+b)/2;

		if(d==i){
			System.out.println(i);
		}else{
			System.out.println(i+1);
		}

	}
}


Measured memory_bytes: 23764
function main(input) {
    const reverse = (s) => {
        return s.split('').reverse().join('');
    };

    const WORDS = ['dream', 'dreamer', 'erase', 'eraser'].map(reverse);
    const S = reverse(input.split('\n')[0]);

    var index = 0;

    while(true) {
        var w = WORDS.find((w) => S.startsWith(w, index));
        if (!w) break;
        index += w.length;
    }

    if (S.length === index) {
        console.log('YES');
    } else {
        console.log('NO');
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 36252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_171
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long n = ReadLong();
            long sum = 0;
            long div = 26;
            int cnt = 1;
            while (n - div > 0)
            {
                n -= div;
                div *= 26;
                cnt++;
            }

            n--;
            int[] vals = new int[cnt];
            div = 26;
            for(int i = 0; i < cnt; i++)
            {
                vals[i] = (int)(n % div);
                n /= div;
            }

            for(int i = cnt-1; i >= 0; i--)
            {
                Write((char)(vals[i] + 'a'));
            }
            WriteLine();
        }

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


Measured memory_bytes: 27464
#include<algorithm>
#include<iostream>
#include<complex>
#include<vector>
using namespace std;
#define x second
#define y first
#define M st.size()
typedef complex<double> point;
pair<int,int> a[100000];
vector<int> st;
bool ccw(point a,point b,point c){
  b-=a,c-=a;
  c*=conj(b);
  if(c.imag()<=0)return true;  
  return false;
}

void check(int i){
  while(M>=2){
    int s=st[M-2];
    int e=st[M-1];
    point S=point(a[s].x,a[s].y);
    point E=point(a[e].x,a[e].y);
    point N=point(a[i].x,a[i].y);
    if(ccw(S,E,N))break;
    st.pop_back();
  }
  st.push_back(i);
}

int main(){
  int n;
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i].x>>a[i].y;
  sort(a,a+n);
  for(int i=0;i<n;i++)check(i);
  for(int i=n-2;i>=0;i--)check(i);
  cout<<M-1<<endl;
  for(int i=M-1;i>0;i--)cout<<a[st[i]].x<<' '<<a[st[i]].y<<endl;
  return 0;
}

Measured memory_bytes: 2456
#include <stdio.h>
int main(void){
	int A, B, C, D;

	scanf("%d %d %d %d", &A, &B, &C, &D);

	if(A*B > C*D)
		printf("%d\n", A*B);
	else
		printf("%d\n", C*D);

	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <bitset>
using namespace std;

typedef long long ll;
const ll INF = 1000000000000000000;
const ll MOD = 1000000000 + 7;

vector<int> v;

bool comp(int a, int b) {
  return a > b;
}

int enum_divisors(int n) {
  for (int i = 1; i*i <= n; i++) {
    if (n % i == 0) {
      v.push_back(i);
      if (n/i != i) v.push_back(n/i);
    }
  }
  
  sort(v.begin(), v.end(), comp);
  return 0;
}

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

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

  int amari = M % N;
  int base = M / N;
  
  if (amari == 0) {
    cout << base << endl;
    return 0;
  }
  
  enum_divisors(M);
  int ans = 0;
  for (int i = 0; i < v.size(); i++) {
    if (M / v[i] >= N) {
      cout << v[i] << endl;
      return 0;
    }
  }
  
  return 0;
}








Measured memory_bytes: 3204
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define be begin()
#define en end()
#define le length()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (__typeof(n) i = 0; i < n; i++)
#define repo(i, n) for (__typeof(n) i = 1; i <= n; i++)
#define eps 1e-6
#define pi 3.141592653589793
#define c(a) cout << a << "\n";
#define a(a)         \
    for (auto i : a) \
        cout << i << " ";
typedef vector<int> vii;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main()
{

ll a,b,c;
cin>>a>>b>>c;
if(a==b+c || b==a+c || c==a+b) c("Yes")
else c("No")
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
mod=1000000007
sum=0
tmp=0
o=0
while(o<n):
    tmp = (a[o]%mod + tmp%mod)%mod
    o += 1

for i in range(n):
    tmp=(tmp%mod-a[i]%mod)%mod
    sum=((a[i]%mod)*tmp)%mod+sum%mod



print(sum%mod)


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<pll,ll> m;
  
  reps(i,n){
    if(i%10==0) continue;
    string tmp=to_string(i);
    ll head=tmp[0]-'0', tail=i%10;
    m[pii(head,tail)]++;
  }
  ll ans=0;
  reps(i,9){
    reps(j,9){
      if(i==j) ans+=m[pii(i,j)]*m[pii(i,j)];
      else ans+=m[pii(i,j)]*m[pii(j,i)];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef pair<double,double> point;
const ll MAX = 2010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin >> n >> a >> b;
    if (n == 1){
        if (a == b) PRINT(1);
        else PRINT(0);
    }
    else if (a > b) PRINT(0);
    else{
        PRINT((b-a)*(n-2)+1);
    }
}


Measured memory_bytes: 256
from itertools import accumulate

N, Q = map(int, input().split())
S = input()
ac = [0] * N
for i in range(N-1):
    if S[i:i+2] == 'AC':
        ac[i] = 1

ac = [0] + ac
acc = list(accumulate(ac))
for i in range(Q):
    l, r = map(int, input().split())
    print(acc[r-1] - acc[l-1])


Measured memory_bytes: 9188
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD 1000000007
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M;
int X[200], Y[200];
int out[200];
i64 dp[1 << 15];

int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < M; ++i) {
		scanf("%d%d", X + i, Y + i);
		--X[i]; --Y[i];
		out[X[i]] |= 1 << Y[i];
	}
	dp[0] = 1;
	for (int m = 1; m < (1 << N); ++m) {
		dp[m] = 0;
		for (int t = m; t > 0; t = (t - 1) & m) {
			// choose <t> for nodes with largest grundy number among <m>
			if ((t & 3) == 3) continue;
			int rem = m ^ t;
			i64 pat = dp[rem];

			for (int i = 0; i < N; ++i) {
				if (!(m & (1 << i))) {
					pat = pat * ((1 << __builtin_popcount(out[i] & t)) - 1) % MOD;
				}
				if (t & (1 << i)) {
					pat = pat * (1 << __builtin_popcount(out[i] & ~m)) % MOD;
				}
			}
			ADD(dp[m], pat);
		}
	}
	printf("%lld\n", dp[(1 << N) - 1]);
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const long long mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main()
{
    ll n,q; cin >> n >> q;
    ll a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    for(int i = 0; i < q; i++){
        ll x; cin >> x;
        ll ans = 0;
        ll sum = 0;
        ll r = 0;
        for(ll l = 0; l < n; l++){
            while(r < n && sum + a[r] <= x){
                sum += a[r];
                r++;
            }
            ans += r - l;
            if(l == r) r++;
            else sum -= a[l];
        }
        cout << ans << endl;
    }
}


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

//   String nyuA=sc.nextLine();
  // String nyuB=sc.nextLine();
 
     String[] S=sc.nextLine().split(" ");

//int n=Integer.parseInt(nyu);

int N=Integer.parseInt(S[0]);
int M=Integer.parseInt(S[1]);

String[][] A=new String[N][N];
String[][] B=new String[M][M];

for(int i=0;i<N;i++){
A[i]=sc.nextLine().split("");
}
for(int i=0;i<M;i++){
B[i]=sc.nextLine().split("");
}
int count=0;

int flag=0;
for(int i=0;i<(N-M)+1;i++){
re:

for(int j=0;j<(N-M)+1;j++){

for(int k=0;k<M;k++){
for(int l=0;l<M;l++){
if(!A[i+k][j+l].equals(B[k][l]) ){
//System.out.println(i+"-"+j+"-"+k+"-"+l);
continue re;
}else{
//System.out.println(i+"-"+j+"-"+k+"-"+l+"-"+A[i+k][j+l]+"--"+B[k][l]);

}

}}
flag=1;
//System.out.println("sor");
}}

//long H=Long.parseLong(t[0]);
//long W=Long.parseLong(t[1]);
//long C=Long.parseLong(t[2]);


if(flag==0)
System.out.println("No");
else
System.out.println("Yes");


	}
}

Measured memory_bytes: 23252
#include<iostream>
#include<string>
#include<set>
using namespace std;
int ele[3]={3,5,7};
int temp_ans;
int cur_value;
int n;
bool judge(int val)
{
    if(val>n) return false;
    set<char> S;
    string str=to_string(val);
    for(auto ele:str)
    {
        S.insert(ele);
    }
    if(S.size()==3) return true;
    else return false;
}
void DFS(int len,int cur_len)
{
    if(cur_len==len)
    {
        if(judge(cur_value))
        {
            //cout<<cur_value<<endl;
            temp_ans++;
        }
        return;
    }
    for(int i=0;i<3;i++)
    {
        cur_value=cur_value*10+ele[i];
        DFS(len,cur_len+1);
        cur_value=(cur_value-ele[i])/10;
    }
}
int main()
{
    ios::sync_with_stdio(false);
    string str;
    while(cin>>str)
    {
        int len=str.length();
        if(len<=2)
        {
            cout<<0<<endl;
            continue;
        }
        int ans=0;
        n=stoi(str);
        for(int i=3;i<=len;i++)
        {
            temp_ans=0;
            cur_value=0;
            DFS(i,0);
            ans+=temp_ans;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	final int MAX_M = 2000;
	int[] a;
	boolean[] sums;

	void run() {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();

		a = new int[n];
		sums = new boolean[MAX_M + 1];
		for (int i = 0; i < n; i++)
			a[i] = scan.nextInt();
		dfs(0, 0);
		int q = scan.nextInt();
		for (int i = 0; i < q; i++) {
			int m = scan.nextInt();
			System.out.println(sums[m] ? "yes" : "no");
		}
	}
	void dfs(int deep, int sum) {
		if (sum > MAX_M) return;
		if (deep == a.length) {
			sums[sum] = true;
			return;
		}
		dfs(deep + 1, sum);
		dfs(deep + 1, sum + a[deep]);
	}
	public static void main(String[] args) {
		new Main().run();
	}
}



Measured memory_bytes: 26776
package main

import "fmt"

func main() {
	var S, T string
	fmt.Scan(&S, &T)
	var A, B int
	fmt.Scan(&A, &B)
	var U string
	fmt.Scan(&U)
	if S == U {
		A--
	} else {
		B--
	}
	fmt.Println(A, B)
}


Measured memory_bytes: 512
import           Control.Monad
import           Data.List
import           Debug.Trace

main :: IO ()
main = do
    [n, h] <- getInts
    ab <- replicateM n $ do
        [a, b] <- getInts
        return (a, b)
    let as = map fst ab
        bs = map snd ab
    print $ solve h as bs

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: Int -> [Int] -> [Int] -> Int
solve h as = go 0 0 . sortBy (flip compare) . filter (> maxA)
  where
    maxA = maximum as
    go n x [] = (h - x + maxA - 1) `div` maxA + n
    go n x (y:ys)
        | y + x >= h = n + 1
        | otherwise = go (n+1) (x + y) ys



Measured memory_bytes: 78204
import java.util.Scanner;

public class Main {
    static int[] dp;

    private static int fibonacci(int x) {
        if(dp[x] == 0) dp[x] = fibonacci(x - 1) + fibonacci(x - 2);
        return dp[x];
    }

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

        int n = sc.nextInt();
        dp = new int[n + 1];
        dp[0] = 1;
        dp[1] = 1;
        System.out.println(fibonacci(n));

        sc.close();
    }
}



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

int main(){
  int N;
  cin >> N;
  vector<int> nums(N);
  
  for(int i=0; i<N; i++){
    cin >> nums.at(i);
  }
  sort(nums.begin(), nums.end());
  reverse(nums.begin(), nums.end());
  
  int delta = 0;
  for(int i=0; i<N; i++){
    if(i % 2 == 0) delta += nums.at(i);
    else delta -= nums.at(i);
  }
  
  cout << delta << endl;
}

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

int main(){
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) a--;
    else b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3636