akhauriyash/Code-Regression huggingface dataset:
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	a := make([]int, n)
	v := make([]float64, n)

	sum := 0
	for i := 0; i < n; i++ {
		a[i] = nextInt()
		sum += a[i]
	}
	av := float64(sum) / float64(n)
	dmin := 999999.9
	didx := -1
	for i := 0; i < n; i++ {
		v[i] = float64(a[i]) - av
		if v[i] < 0 {
			v[i] = -v[i]
		}
		if dmin > v[i] {
			dmin = v[i]
			didx = i
		}
	}

	fmt.Println(didx)

}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // default=64*1024
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>

int main()
{
	int n;
	std::cin >> n;
	std::vector<std::pair<int, int> > XY;
	std::vector<int> N;
	for (int i = 0; i < n; i++)
	{
		int x, y;
		std::cin >> x >> y;
		XY.push_back(std::make_pair(x, y));
		N.push_back(i);
	}
	double distance = 0;
	double ans = 0;
	int count = 0;
	do
	{
		for (int i = 0; i < n - 1; i++)
		{
			distance += sqrt((XY.at(N.at(i)).first - XY.at(N.at(i + 1)).first) * (XY.at(N.at(i)).first - XY.at(N.at(i + 1)).first) + (XY.at(N.at(i)).second - XY.at(N.at(i + 1)).second) * (XY.at(N.at(i)).second - XY.at(N.at(i + 1)).second));
		}
		++count;
	} while (std::next_permutation(N.begin(), N.end()));
	ans = distance / count;
	std::cout << std::fixed << std:: setprecision(10) << ans << '\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main()
{
	int a , b;
	scanf("%d %d",&a ,&b);
	if((a + b) % 3 == 0 || b % 3 == 0 || a % 3 == 0) printf("Possible\n");
	else printf("Impossible\n");
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;
public class Main {
    
    static double ret = 0.0;
    public static void main(String args[]) {
        int c = 0;
        double[] p = null;
        try (Scanner scanner = new Scanner(System.in)) {
            c = scanner.nextInt();
            
            p = new double[c];
            for(int i = 0; i < c; i++) {
                p[i] = scanner.nextDouble();
            }
            
        }
        
       double[][] dp = new double[c + 1][c + 1];
       dp[0][0] = 1;
       for(int i = 1; i <= c ; i++) {
           for(int j = 0; j <= i; j++) {
               if(j > 0)
                dp[i][j] += dp[i-1][j-1]*p[i - 1];
            dp[i][j] += dp[i-1][j]*(1 -p[i - 1]);
           }
       }
       
       double ret = 0.0;
       for(int j = (c/2)+1; j <= c; j++) {
           ret += dp[c][j];
       }
       
       System.out.println(ret);
    }
}

Measured memory_bytes: 123280
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll dp[5010][5010];
ll sz[5010][5010];
int main(){
    int n;
    cin >> n;
    ll A,B;
    cin >> A >> B;
    vector<int>p(n+2);
    vector<int>q(n+2);
    rep(i,n)cin >> p[i+1];
    rep(i,n){
        q[p[i+1]] = i+1;
        sz[i+1][p[i+1]]++;
    }
    for(int j=n-1;j>=1;j--){
        for(int i=1;i<=n;i++){
            sz[i][j] += sz[i][j+1];
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            sz[i][j] += sz[i-1][j];
        }
    }
    // rep(i,n){
    //     rep(j,n){
    //         cerr << sz[i+1][j+1] << " " ;
    //     }
    //     cerr << endl;
    // }
    vector<ll> v(n+1);
    Fill(dp,1LL<<60);
    rep(i,n+3){
        dp[n][i] = 0;
    }
    rep(i,n+3){
        dp[i][n+1] = 0;
        dp[i][n+2] = 0;
    }
    for(int x=n-1;x>=0;x--){
        for(int y=1;y<=n;y++){
            if(q[x+1]<=y){
                dp[x][y] = dp[x+1][y];
            }else{
                ll cnt = sz[q[x+1]-1][x+1]-sz[y-1][x+1];
                // cerr << x << " " << q[x+1] << endl;
                // cerr << x << " " << y << " " <<  cnt << endl;
                // cerr << x+1 << " " << q[x+1]+1 << endl;
                dp[x][y] = min(dp[x+1][y]+B,dp[x+1][q[x+1]+1]+A*cnt);
            }
        }
    }
    // cerr << dp[9][10] << endl;
    // cerr << dp[8][10] << endl;
    // rep(i,n){
    //     rep(j,n){
    //         cerr << i << " " << j+1 << " " <<  dp[i][j+1] << endl;
    //     }

    // }
    cout << dp[0][1] << endl;
    return 0;
}

Measured memory_bytes: 392320
#数字はnumberに格納
number=input()
length=len(number)


#調整のための数字
sizemin=1000000007

#まずはからのDPリストを用意
dp=[[0 for i in range(13)] for j in range(length)]

#1桁目の情報を入力
if number[-1]=="?":
    for i in range(10):
        dp[0][i]=1
else:
    dp[0][int(number[-1])]=1

#１０〜９０の、13modリストを作る
modlist=[(i*10)%13 for i in range(10)]


        
#二桁目からの情報を更新していく。
for n in range(length-1):
    #n桁目の情報があれば、次のようにn+1行目を更新。

    #n+1のくらいの数をchecknumとする
    checknum=number[-1*(n+1)-1]
#     print(checknum)

    #n+1の位が整数であれば
    if checknum!="?":
        
        #n[m]の値をn+1[m+(その整数)]にすればいい
        for m in range(13):
            dp[n+1][(m+modlist[int(checknum)])%13]=dp[n][m]
#         print(dp)
        
        
        
        
        
    #n+1のくらいが？の時
    else:
    #？が０〜９までの可能性を全て試す  
    
        for checknum in range(10):
            for m in range(13):
                dp[n+1][(m+modlist[int(checknum)])%13]=(dp[n+1][(m+modlist[int(checknum)])%13]+dp[n][m])%sizemin
#             print(dp)

    #modlistを更新
    modlist=[(j*10)%13 for j in modlist]


print(dp[-1][5])

Measured memory_bytes: 66652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 1e7+5;

vector<ll> spf(MAX);

// void make_spf(){
//     for(int i = 0;i < MAX; i++)spf[i] = i;
//     for (int i = 2; i*i < MAX; i++)
//     {
//         if(spf[i] == i){
//             for (int j = i*i; j < MAX; j += i)
//             {
//                 if(spf[j] == j)spf[j] = i;
//             }
//         }
//     }
// }

ll f(ll k){
    map<int, ll> mp;
    while(k > 1){
        mp[spf[k]]++;
        k /= spf[k];
    }
    ll ret = 1;
    for(auto c :mp){
        ret *= c.second + 1;
    }
    return ret;
}



int main() {
    ll n;cin >> n;
    for(int i = 0;i < MAX; i++)spf[i] = i;
    for (int i = 2; i*i < MAX; i++)
    {
        if(spf[i] == i){
            for (int j = i*i; j < MAX; j += i)
            {
                if(spf[j] == j)spf[j] = i;
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
    {
        ans += i*f(i);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
int MOD = 1000000007;

int main() {
  int N; cin >> N;
  
  ll ans = 0;
  ll ten = 1;
  for (int i = 0; i < N; i++) {
    ten = (ten * 10) % MOD;
  }
  ll nine = 1;
  for (int i = 0; i < N; i++) {
    nine = (nine * 9) % MOD;
  }
  ll eight = 1;
  for (int i = 0; i < N; i++) {
    eight = (eight * 8) % MOD;
  }
  ans = (ten - 2*nine + eight + 2 * MOD) % MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0; i < n; i++) {
        cin >> s[i];
    }
    sort(all(s));
    string ans = "";
    for(auto &e : s) {
        ans = ans + e;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include <vector>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <array>
#include <cmath>
#include <set>
#include <numeric>

using namespace std;


template <typename T>
using TABLE = vector<vector<T>>;

long long PRIME = 1e9 + 7;
long long PRIME2 = 998244353;


int main(){
    long long H, W;
    cin >> H >> W;

    if(H % 3 == 0 || W % 3 == 0){
        cout << 0;
        return 0;
    }

    long long one, two, three;
    long long sum = H * W;
    long long min_dif = sum, diff;

    for(long long i = 1; i < H ; ++i){
        one = W * i;
        two = max((H - i) * (W / 2), W * ((H - i) / 2));
        three = sum - one - two;

        diff = max({one, two, three}) - min({one, two, three});
        min_dif = min(diff, min_dif);
    }
    for(long long i = 1; i < W; ++i){
        one = H * i;
        two = max((W - i) * (H / 2), H * ((W - i) / 2));
        three = sum - one - two;

        diff = max({one, two, three}) - min({one, two, three});
        min_dif = min(diff, min_dif);
    }

    cout << min_dif;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#undef int
#define INF 1000000009
#define INFL 1000000000000000018ll
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define mk make_pair
typedef pair<int, int> PA;
typedef pair<pair<int, int> , pair<int, int> > PPA;
typedef priority_queue<int> PQ;
typedef priority_queue<PA, vector<PA>, greater<PA> >PQG;

int N, M;
int a[100100], b[100100];
vector<int> G[10100], RG[10100], GG[10110];
int C[10100], color = 1;
int num[10100];
int revnum = 1;
bool used[10100];
int island;
bool visited[10100];
int tobari[2][100100];

void visit(int v)
{
    visited[v] = true;
    for(int i = 0; i < (int)GG[v].size(); i++){
        if(!visited[GG[v][i]]){
            visit(GG[v][i]);
        }
    }
    return;
}

void paint(int v, int c)
{
    C[v] = c;
    for(int i = 0; i < (int)RG[v].size(); i++){
        if(C[RG[v][i]] == 0){
            paint(RG[v][i], c);
        }
    }
    return;
}

void revpar(int v)
{
    used[v] = true;
    //printf("revpar v:%d\n", v);
    for(int i = 0; i < (int)G[v].size(); i++){
        if(!used[G[v][i]])revpar(G[v][i]);
    }
    num[v] = revnum;
    revnum++;
    return;
}

signed main()
{
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int s, t;
        cin >> s >> t;
        a[i] = s;
        b[i] = t;
        G[s].pb(t);
        RG[t].pb(s);
        GG[s].pb(t);
        GG[t].pb(s);
    }
    //printf("%d\n", __LINE__);
    /*for(int i = 0; i < N; i++){
        if(!visited[i]){
            island++;
            visit(i);
        }
    }*/
    //printf("%d\n", __LINE__);
    for(int i = 0; i < N; i++){
        if(!used[i]){
            revpar(i);
        }
    }
    //printf("%d\n", __LINE__);
    priority_queue<pair<int, int> > que;
    for(int i = 0; i < N; i++){
        que.push(mk(num[i], i));
    }
    //printf("%d\n", __LINE__);
    while(!que.empty()){
        pair<int, int> p = que.top();
        que.pop();
        if(C[p.second] == 0){
            paint(p.second, color);
            color++;
        }
    }
    //printf("%d\n", __LINE__);
    int ans = 0;
    for(int i = 0; i < M; i++){
        if(C[a[i]] != C[b[i]]){
            tobari[0][C[a[i]]]++;
            tobari[1][C[b[i]]]++;
            //printf("e:%d\n", i);
        }
    }
    //printf("colors:%d\n", color);
    int l = 0, r = 0;
    for(int i = 1; i < color; i++){
        if(tobari[0][i] == 0){
            l++;
            //printf("a:%d\n", i);
        }
        if(tobari[1][i] == 0){
            r++;
            //printf("b:%d\n", i);
        }
    }
    //printf("%d\n", __LINE__);
    if(color == 2){
        cout << 0 << endl;
    }
    else cout << max(l, r) << endl;
    //printf("%d\n", __LINE__);

    return 0;
}
/*

10 18
0 1
1 2
2 0
0 2
2 1
1 0
3 4
4 2
3 6
1 6
5 3
5 4
7 6
7 5
7 9
9 8
8 7
6 7


*/



Measured memory_bytes: 8108
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define P pair<int, int>
#define V vector<int>
//#define S set<int>
#define itn int
bool dbg = false;
int A, B, K;


void solve() {
    int tmp = 0;
    tmp = K - A;
    A -= K;
    if (A >= 0) {
        cout << A << " " << B << endl;
    } else {
        cout << 0 << " " << max(0ll, B - tmp) << endl;
    }
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> A >> B >> K;
    solve();
    return 0;
}


Measured memory_bytes: 256
N,M = map(int, input().split())

H=list(map(int,input().split()))

graph=[[0] for _ in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    graph[A-1].append(H[B-1])
    graph[B-1].append(H[A-1])

ans=0

for i in range(N):
    if H[i]>max(graph[i]):
        ans+=1
        
print(ans)














    

                
            





    









        

    









    

        




    















    



    





    






        






    
















        


























            
    


    


    
    














    


    














Measured memory_bytes: 26100
#include <stdio.h>
int main (void){
  int n,l,r,i,count;
  scanf("%d",&n);
  count = 0;
  for (i = 0; i < n; i++){
    scanf("%d %d",&l,&r);
    count += r - l + 1;
  }
  printf("%d\n",count);
  return (0);
}
  


Measured memory_bytes: 128
def ans(n, x):
	if n < 0:
		return 0
	if x < 1:
		return 0
	if x < 2 ** (n + 1) - 1:
		return ans(n - 1, x - 1)
	if x == 2 ** (n + 1) - 1:
		return 2 ** n
	return 2 ** n + ans(n - 1, x - 2 ** (n + 1) + 1)
N, X = map(int, input().split())
print(ans(N, X))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  vector<long> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
    data.at(i)--;
  }
  int count = 0;
  for(int i = 0; i < N; i++){
    if(data.at(data.at(i)) == i)count++;
  }
  cout << count / 2 << endl;
  return 0;
}

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

using namespace std;
#define ll long long

ll INF = 1e9 + 7;
const int N = 1e6 + 5;

ll getVal( vector<int> &num, vector<int>&cost, int n, int pos, int k)
{
    ll cst = 0;
    vector<bool> isVisited(n, false);
    vector<ll> psum;
    
    int tmp = num[pos]; 
    while(!isVisited[tmp])
    {
        isVisited[tmp] = true;
        cst += cost[tmp];
        tmp = num[tmp];
        psum.push_back(cst);
    }

    int tp = k/(psum.size());
    ll p = tp;
    ll maxVal = psum[0];
    if(psum[psum.size() - 1] > 0){
        if( k < psum.size())
        {
            int sz = min(k,(int)(psum.size()));
            for(int i=1;i<sz;i++)
            {
                maxVal = max(maxVal, psum[i]);
            }
        }
        else
        {
            k -= (p*psum.size());
            for(int i = 0; i< psum.size(); i++)
            {
                if(i < k)
                {
                    ll val = psum[i] + p * psum[psum.size()-1];
                    maxVal = max(maxVal, val);
                }
                else
                {
                    ll val = psum[i] + (p - 1) * psum[psum.size() -1];
                    maxVal = max(maxVal, val);
                }
            }
        }
    }
    else
    {
        int sz = min(k,(int)(psum.size()));
        for(int i=1;i<sz;i++)
        {
            maxVal = max(maxVal, psum[i]);
        }
    }

    return maxVal;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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

    vector<int>arr(n), cost(n);

    for(int i=0;i<n;i++) { cin>>arr[i]; arr[i]--;}
    for(int i=0;i<n;i++) cin>>cost[i];

    ll ans = -1e19;
    for(int i=0;i<n;i++)
    {
        ll tmp = getVal(arr,cost,n,i, k);
        //cout<<tmp<<endl;
        ans = max(tmp,ans);
    }

    cout<<ans<<endl;
}


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

#define fr first
#define sc second
#define OK puts("OK");
#define pb push_back
#define mk make_pair

using namespace std;

typedef long long ll;

const int inf = (int)1e9 + 7;
const int N = (int)2e5 + 7;

ll n,s,d,mn = 1e18;

ll check (ll x) {
        ll sum = 0;
        ll nn = n;

        while (nn > 0) {
                sum += (nn % x);
                nn /= x;

        }
        return sum;
}

int main () {
        scanf("%lld%lld", &n,&s);

        if (n == s) {
                cout << n + 1;
                return 0;
        }
        for (ll i = 2; i * 1ll * i <= n + 1; i ++) {
                if (check(i) == s){
                        printf("%lld", i);
                        return 0;
                }
        }
        if (n < s) {
                puts("-1");
                return 0;
        }

        d = n - s;

        for (ll i = 1; i * 1ll * i <= d + 1; i ++) {
                if (d % i == 0) {
                        ll o = (d / i) + 1;
                        if (o > i && check(o) == s) {
                                mn = min(mn,o);
                        }
                }
        }
        if (mn == 1e18)
                cout << "-1" << endl;
        else
                cout << mn << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
signed main(){
  int N; cin>>N;
  string A,B; cin>>A>>B;
  int ans=2*N;
  rep(i,0,N){
    if(A.substr(i,N-i)==B.substr(0,N-i)){
      ans-=N-i;
      break;
    }
  }
  cout<<ans<<endl;
  }


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

using ll = long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define aint(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(aint((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義
#define int 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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(aint(v)),v.end());

#define MAX 1000002
#define MOD 1000000007
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

bool knight(pint p){
  int x=p.first,y=p.second;
  if((x+y)%3!=0)return false;
  if(x*2<y)return false;
  if(x>2*y)return false;
  return true;
}


signed main(void){
  COMinit();
  pint t;cin>>t.first>>t.second;
  if(!knight(t)){
    cout << 0 << endl;
    return 0;
  }

  int x=t.first,y=t.second;
  int h=0,w=0;
  if(x==y){
    w=x/3;
    h=y/3;
  }else if(x>=y){
    while(x-(w*3)!=2*(y-(h*3))){
      w++;h++;
    }
    w+=y-(w*3);
  }else{
    while((y-h*3)!=2*(x-(w*3))){
      w++;h++;
    }
    h+=x-(h*3);
  }

  printf("%lld\n",COM(h+w,w)%MOD);

}


Measured memory_bytes: 23680
while True:
    s=input()
    if s=="0":
        break
    
    a,b=s[1::].count("A"),s[1::].count("B") #最後の一回以外
    if a<b:  #最後
        x,y=0,1
    else:
        x,y=1,0
    print(a+x,b+y)


Measured memory_bytes: 5556
#include<bits/stdc++.h>
using namespace std;
int n,W;
long long dp[100005];
int main(){
	scanf("%d%d",&n,&W);
	for(int i=0;i<n;i++){
		int w,v;
		scanf("%d%d",&w,&v);
		for(int j=W;j>=w;j--)dp[j]=max(dp[j],dp[j-w]+v);
	}
	printf("%lld\n",*max_element(dp,dp+W+1));
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    long long N, M, a[100001], i, dp[100001], count=1, broken;

    cin >> N >> M;

    dp[0] = 1;
    for(i=1; i<=M; i++){
        cin >> a[i];
    }

    broken = a[1];

    for(i=1; i<=N; i++){
        if(i == a[count]){
            dp[i] = 0;
            if(count<M) count++;
        }

        else if(i==1){
            dp[1] = dp[0];
        }

        else{
            dp[i] = dp[i-2] + dp[i-1];
        }

        dp[i] %= div1;
    }

    cout << dp[N] << endl;

    return 0;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int l[] = new int[n];
		for(int i = 0; i < n; i++){
			l[i] = sc.nextInt();
		}

		Arrays.sort(l);
		int result = 0;

		for(int i = 0; i < n; i++){
			for(int j = i + 1; j < n; j++){
				for(int k = j + 1; k < n; k++){
					if(l[k] >= l[i] + l[j]){
						break;
					}
					if(l[j] < l[i] + l[k] && l[k] < l[i] + l[j]){
						result++;
					}
				}
			}
		}

		System.out.println(result);
	}

}


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

using namespace std;

long long n,a,b;

int main() {
 ios_base::sync_with_stdio(0); cin.tie(0);
 cin>>n>>a>>b;
 long long zero =0;
 cout<<max(zero,(n-((a==b)?1:2))*(b-a) +1)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int x, y, s; 
	int a, b;
	int max;

	while(scanf("%d %d %d", &x, &y, &s) == 3){
		if(x == 0 && y == 0 && s == 0){
			break;
		}
	for(a = 1; a < s; a++){
		for(b = 1; b < s; b++){
			if((int)(a * x / 100.0 + a) + (int)(b * x / 100.0 + b) == s){
				if((int)(a * y / 100.0 + a) + (int)(b * y / 100.0 + b) > max){
					max = (int)(a * y / 100.0 + a) + (int)(b * y / 100.0 + b);
				}

			}
		}
	}
	printf("%d\n", max);
	max = 0;
	}
    return 0;
}


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

using namespace std;

string S;

int main() {
	cin >> S;
	int size = S.size();
	int ans = 0;
	for (int i = 0; i < size / 2; i++) {
		if (S[i] != S[size - i - 1]) {
			ans++;
		}
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 128
def trans(c):
    return ord(c)-ord('a')

S=[input() for _ in range(3)]
now=0
while True:
    if len(S[now])==0:
        break
    tmp=trans(S[now][0])
    S[now]=S[now][1:]
    now=tmp

print(chr(ord('A')+now))


Measured memory_bytes: 2940
#include <cstdio>

int main(){
    int x;
    scanf("%d",&x);
    int a = x;
    int b = 0;
    while(a != 0){
        b = b + a % 10;
        a = (a - a % 10) / 10;
    }
    if(x % b == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rp(i,n) for(int i=0;i<n;i++)
#define rep(i,m,n) for(int i=m;i<=n;i++)
#define lrp(i,n) for(long long i=0;i<n;i++)
#define lrep(i,m,n) for(long long i=m;i<=n;i++)
#define ll long long
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define vi vector<int>
#define vl vector<long long>
#define pb push_back
#define abs(a,b) (a-b>0?a-b:b-a)


int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==1){
        cout << "YES" << endl;
        goto Exit;
    }
    rep(i,2,1000000){
        if((i*a)%b==c){
            cout << "YES" << endl;
            goto Exit;
        }
    }
    cout << "NO" << endl;
    
Exit:
    ;
}








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

long long gcd(long long a, long long b){
    if (b == 0){
        return a;
    }
    return gcd(b, a % b);
}

long long lcm(long long a, long long b){
    return a/gcd(a, b) * b;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> Ts(N);
    for (auto & t : Ts) cin >> t;
    long long res = 1LL;
    for (auto t : Ts){
        res = lcm(res, t);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() 
{
	int R;
	while(cin>>R)
	{
		if(R<1200)
		{
			cout<<"ABC"<<endl;
		}
		if(R>=1200&&R<2800)
		{
			cout<<"ARC"<<endl;
		}
		if(R>=2800)
		{
			cout<<"AGC"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
hs = list(map(int, input().split()))

def doit(sub_hs):
    if len(sub_hs) == 0:
        return 0
    for i in range(len(sub_hs)):
        if sub_hs[i] == 0:
            a = 0
            if len(sub_hs[0:i]) > 0:
                min_h = min(sub_hs[0:i])
                a += min_h + doit([h - min_h for h in sub_hs[0:i]])
            if len(sub_hs) >= i:
                a += doit(sub_hs[i+1:])
            return a
    min_h = min(sub_hs)
    a = min_h + doit([h - min_h for h in sub_hs])
    return a
print(doit(hs))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define ordered_set tree < ll ,  null_type ,  less<ll> ,  rb_tree_tag ,  tree_order_statistics_node_update >
//added two more functions to set
//(1)*(set.find_by_order(k))[kth element in the sorted set] 
//(2)set.order_of_key(k)[count of elements strictly less than k]
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)//remember i is an iterator
#define present(c,x) ((c).find(x) != (c).end())//for sets,maps,multimaps
#define cpresent(c,x) (find(all(c),x) != (c).end())//for vectors
#define tc(t) int (t); cin>>(t);while((t)--)
#define ff first
#define ss second
#define mp make_pair
#define ld long double
#define ull unsigned long long int
#define mod 1000000007
	ll dp[3005][3005];
int main()
{
    ios_base::sync_with_stdio(false);//this works only
    cin.tie(NULL);// when first all inputs are from user
    cout.tie(NULL);//you will see all outputs afterwards
    string s,t;
    cin>>s>>t;
    int n=s.length(),m=t.length();
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<=max(n,m);i++)
	{
		if(i<=m) dp[n][i]=0;
		if(i<=n) dp[i][m]=0;
	}   
	for (int i = n-1; i>=0; --i)
	{
		for (int j = m-1; j>=0; --j)
		{
			if(s[i]==t[j])
			{
				dp[i][j]=1+dp[i+1][j+1];
			}
			else
			{
				dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
			}
		}
	}
	int m1=dp[0][0];
/*	cout<<dp[0][0]<<endl;
*/	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(m1==0) break;
			if((dp[i][j]>dp[i+1][j])&&(dp[i][j]>dp[i][j+1]))
			{
				cout<<s[i];
				i++;m1--;
				continue;
			}
			if(dp[i][j]>dp[i+1][j])
			{
				continue;
			}
			if(dp[i][j]>dp[i][j+1])
			{
				i++;j--;
			}
		}
		//cout<<"\n";
	}
	cout<<endl;
    return 0;
}

Measured memory_bytes: 70784
//............Created by:- Arth Raj...........................//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vii vector<pair<int,int>>
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rlp(i,a,b) for(int i=b;i>=a;i--)
#define ld long double
#define tl tuple<ll,ll,ll>
#define all(x) (x).begin(),(x).end()
#define bs(x,b) binary_search(all(x),b)
#define vip vector<pair<int,pair<int,int>>>
#define pip pair<int,pair<int,int>>
#define INF 1e18
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll abm(ll a, ll b, ll m) {ll ans = 1; a = a % m; while (b > 0) {if (b & 1)ans = (ans * a) % m; a = (a * a) % m; b = b / 2;} return ans % m;}
ll ncr(ll n, ll r, ll m) {if (r == 0)return 1; ll fac[n + 5]; fac[0] = 1; lp(i, 1, n + 1) {fac[i] = fac[i - 1] * i % m;} return (((fac[n] * abm(fac[r], m - 2, m)) % m) * (abm(fac[n - r], m - 2, m))) % m;}
int main()
{
	int n;
	cin >> n;
	int arr[n + 1];
	for (int i = 1; i <= n; i++)
		cin >> arr[i];
	int dp[n + 1];
	dp[0] = dp[1] = 0;
	for (int i = 2; i <= n; i++)
	{
		if (i == 2)
		{
			dp[i] = dp[i - 1] + abs(arr[i] - arr[i - 1]);
		}
		else
		{
			dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
		}
	}
	cout << dp[n] << endl;
	return 0;
}

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

using namespace std;
#define int long long
const int MOD = 1000000007;

int A, B, N;
int f(int X) {
	return (A * X / B) - A * (X / B);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> A >> B >> N;
	if (B == 1) {
		cout << 0 << endl;
		return 0;
	}
	//cerr << f(9) << " " << f(18) << endl;
	int res = f(N);
	int X = (N / (B - 1)) * (B - 1);
	for (int i = 0; i < A + 1; i++) {
		int t = (i + 1) * (B - 1);
		if (t <= N) {
			res = max(res, f(t));
		}
		t = X - i * (B - 1);
		if (t >= 0) {
			res = max(res, f(t));
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String input = sc.nextLine();
		char[] arr = input.toCharArray();
		for(int i = 0;i<input.length();i++) {
			if(i%2==0&&arr[i]!='R'&&arr[i]!='U'&&arr[i]!='D') {
				System.out.println("No");
				return;
			}else if(i%2!=0&&arr[i]!='L'&&arr[i]!='U'&&arr[i]!='D') {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");

	}

}


Measured memory_bytes: 22740
import sys
N,Y=map(int,input().split())

for i in range(N+1):
  for j in range(N+1-i):
    k=N-i-j
    if 10000*i+5000*j+1000*k==Y:
      print(i,j,k)
      sys.exit(0)
else:
  print(-1,-1,-1)

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll ;

const ll inf = 1e9 + 17;
const int maxn = 1e5 + 10;
const int maxq = 5e2 + 10;
const int alf = 26;
const ll dlm = 1e9 + 7;
const int del = 998244353 ;
const int eps = 1e-7 ;


int dp1[maxn],dp2[maxn],dp3[maxn];
int a[maxn];
int b[maxn];
int c[maxn];

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    for(int i=1;i<=n;i++){
        dp1[i] = max(dp2[i-1],dp3[i-1]) + a[i];
        dp2[i] = max(dp1[i-1],dp3[i-1]) + b[i];
        dp3[i] = max(dp1[i-1],dp2[i-1]) + c[i];
    }
    int ans = max(dp1[n],max(dp2[n],dp3[n]) );
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2560
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<double,P> PP;
struct edge { int to; int cost; };
int x[100006], y[100006], z[100006];
int par[100006], rnk[100006];
void init(int n) {
	rep(i, n) {
		par[i] = i; rnk[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return x = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x== y)return;
	if (rnk[x]<rnk[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}
}
signed main() {
	int n, m; cin >> n >> m;
	rep(i, m)cin >> x[i] >> y[i] >> z[i];
	init(n);
	rep(i, m)unite(x[i] - 1, y[i] - 1);
	set<int>S;
	rep(i, n)S.insert(find(i));
	cout << S.size() << endl;
}

Measured memory_bytes: 8832
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	string s;
	cin >> s;

	deque<char> d;
	for(int i = 0; i < s.size(); i++) {
		d.push_front(s[i]);
	}

	int f = 0;
	int q;
	cin >> q;

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

		if(t == 1) {
			f ^= 1;
		}
		else {
			int p;
			char c;
			cin >> p >> c;

			if(p == 1) {
				if(f) {
					d.push_front(c);
				}
				else {
					d.push_back(c);
				}
			}
			else {
				if(f) {
					d.push_back(c);
				}
				else {
					d.push_front(c);
				}
			}
		}
	}

	if(f) {
		while(!d.empty()) {
			cout << d.front();
			d.pop_front();
		}
	}
	else { 
		while(!d.empty()) {
			cout << d.back();
			d.pop_back();
		}
	}
}

Measured memory_bytes: 976
t, x, y = 0, 0, 0
N = int(input())
r = "Yes"
for i in range(0, N):
  t2, x2, y2 = map(int, input().split())
  d = abs(x2-x)+abs(y2-y)
  if not(t2-t>=d and d%2==(t2-t)%2):
    r = "No"
    break
print(r)
    

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	int n;
	int x;
	int i;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>x;
		if(x%2==0)
		{
			if(x%3==0||x%5==0)
				continue;
			else 
			{
				cout<<"DENIED"<<endl;
				return 0;
			}
				
		}
		else 
			continue;
	}
	cout<<"APPROVED"<<endl;
	return 0;
}

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

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 100+5;
const int MAXV= 1000+5;

int n,W;
int w[N];
int v[N];

ll dp[N*MAXV];

int main() {
    cin >> n >> W;
    loop(i,n){
        cin >> w[i] >> v[i];
    }



    loop(i,N*MAXV) dp[i] = -1;
    dp[0] = 0;

    for(int i = 0; i < n; i++){
        for(int j = N*MAXV-1; j >= 0; j--){
            if(dp[j] != -1 && j+v[i] < N*MAXV && (dp[j+v[i]] == -1 || dp[j+v[i]] > dp[j] + w[i])){
                dp[j+v[i]] = dp[j] + w[i];
            }
        }


    }

    int res = 0;
    for(int j = 0; j < N*MAXV; j++){
        if(dp[j] != -1 && dp[j] <= W){
            res = j;
        }
    }

    cout << res << endl;



    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, count, sum = 0;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < n; i++) {
    if(sum < vec.at(i)) {
      sum = vec.at(i);
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define en puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check(int n) {
    for(int i=2;i*i<=n;++i) {
        if(n%i==0)
        return false;
    }
    return true;
}


// bool cmp(pair<int,int>p,pair<int,int>q) {
//     // return p.first>q.first;//descending by first
//     // return p.first<q.first;//ascending by first
//     // return p.second>q.second;//descending by second
//     return p.second<q.second;//ascending by second
// }

bool cmp(int p,int q) {
    return p>q;//descending
    // return p<q;//ascending
}


int main() {

    int t;
    // cin>>t;
    t=1;
    while(t-->0) {
        clue();
    }

    return 0;
}
int clue() {

    string s;
    cin>>s;
    int cnt;
    if(s=="SUN") {
        cnt=7;
    }
    elif(s=="MON") {
        cnt=6;
    }
    elif(s=="TUE") {
        cnt=5;
    }
    elif(s=="WED") {
        cnt=4;
    }
    elif(s=="THU") {
        cnt=3;
    }
    elif(s=="FRI") {
        cnt=2;
    }
    elif(s=="SAT") {
        cnt=1;
    }

    cout<<cnt<<endl;

    
    // ()?cout<<"1"<<endl:cout<<"0"<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
import java.util.*;
import java.io.*;

public class Main {
    private static IO io = new IO();
    public static void main(String[] args) {
        
        int fib[] = new int[45];
        fib[0] = 1;
        fib[1] = 1;
        int n = io.nextInt();
        for (int i = 2; i <= n; i++) fib[i] = fib[i-1] + fib[i-2];
        System.out.println(fib[n]);
        
    }

    static class IO extends PrintWriter {
        private final InputStream in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        IO() {
            this(System.in);
        }

        IO(InputStream source) {
            super(System.out);
            this.in = source;
        }

        boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }
        int readByte() {
            if (hasNextByte()) return buffer[ptr++];
            else return -1;
        }
        boolean isPrintableChar(int c) {return 33<=c &&c <=126;}
        void skipUnprintable() {while(hasNextByte() && !isPrintableChar(buffer[ptr]))ptr++;}
        boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }

        int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public void close() {
            super.close();
            try {
                in.close();
            } catch (IOException ignored) {
            }
        }
    }
}

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

public class Main {
	public static void main(String[] args) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String[] v = br.readLine().split(" ");
			int a = Integer.parseInt(v[0]);
			int b = Integer.parseInt(v[1]);
			int c = Integer.parseInt(v[2]);

			if (a < b && b < c) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 24340
#include<stdio.h>
int main()
{
    int n;

    while(scanf("%d",&n)==1)
    {
     int  a,b,c,d;
    int count=0;
    for(a=0;a<=9;a++)
    {
        for(b=0;b<=9;b++)
        {
            for(c=0;c<=9;c++)
            {
                for(d=0;d<=9;d++)
                {
                    if(a+b+c+d==n)
                        {
                            count++;
                        }
                }
            }
        }
    }
    printf("%d\n",count);
    }

    return 0;
}



Measured memory_bytes: 2064
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
int mod = 998244353;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int N; cin >> N;
    vector<int>A(N);
    vector<int>count(100000);
    rep(i, N) {
        cin >> A[i];
        count[A[i]]++;
    }
    vector<int>ans(99999);
    REP(i, 99999) {
        ans[i] = count[i - 1] + count[i] + count[i + 1];
    }
    sort(ans.begin(), ans.end());
    cout << ans[99998] << endl;
}

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

int main(){
    int n,q;
    cin >> n >> q;
    vector<vi> graph(n,vi());
    for(int i=0;i<n-1;i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    vi counter(n);
    for(int i=0;i<q;i++){
        int p,q;
        cin >> p >> q;
        p--;
        counter[p]+=q;
    }
    vector<bool> found(n,false);
    queue<int> que;
    que.push(0);
    found[0]=true;
    while(!que.empty()){
        int v=que.front();
        que.pop();
        for(auto x:graph[v]){
            if(found[x]) continue;
            found[x]=true;
            counter[x]+=counter[v];
            que.push(x);
        }
    }
    for(int i=0;i<n;i++){
        cout << counter[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 16584
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n;
    cin>>n;

    string s;
    cin>>s;

    int ans = 1;

    for(int i=1;i<n;i++){
        if(s[i] != s[i - 1]) ans++;
    }

    cout<<ans;
} 

Measured memory_bytes: 512
#include<iostream>
#include<climits>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<list>
#include<string>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF INT_MAX/3

char MAP[50][50];
int B_area = 0;
int W_area = 0;
int W, H;
int temp = 0;
//0:black,1:white
int color = -1;
int color_f = 1;
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };


void dfs(int x, int y) 
{
	if (x < 0 || W <= x || y < 0 || H <= y)return;
	if (MAP[y][x]=='D')return;
	else if (MAP[y][x] == '.')
	{
		temp++;
		MAP[y][x] = 'D';
		for (int r = 0; r < 4; r++)
		{
			int nx = x + dx[r];
			int ny = y + dy[r];
			dfs(nx, ny);
		}
	}
	else if (MAP[y][x] == 'W')
	{
		if(color==-1)color = 1;
		else if (color == 0)color_f = -1;
	}
	else if (MAP[y][x] == 'B')
	{
		if (color == -1)color = 0;
		else if (color == 1)color_f = -1;
	}
	
	if (color_f == -1)
	{
		W_area = 0;
		B_area = 0;
	}
	else if (color == 0)
	{
		B_area = temp;
		W_area = 0;
	}
	else if (color == 1)
	{
		W_area = temp;
		B_area = 0;
	}
}

int main()
{
	while (1)
	{
		B_area = 0;
		W_area = 0;
		cin >> W >> H;
		if (W == 0)break;
		int ansB=0, ansW=0;
		REP(i, H)REP(j, W)cin >> MAP[i][j];
		REP(i, H)REP(j, W)
		{
			if (MAP[i][j] == '.')
			{
				color = -1;
				color_f = 1;
				temp = 0;
				W_area = 0;
				B_area = 0;
				dfs(j, i);
				ansB += B_area;
				ansW += W_area;
			}
		}
		cout << ansB << " " << ansW << endl;
	}
	return 0;
}

Measured memory_bytes: 3132