akhauriyash/Code-Regression huggingface dataset:
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Scanner;
import java.util.Comparator;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long N = in.nextLong();

            List<Long> list = divisor(N);
            list.remove(Long.valueOf(1));

            long ret = 0;
            for (Long n : list) {
                if (N / (n - 1) == N % (n - 1)) {
                    ret += (n - 1);
                }
            }
            out.println(ret);
        }

        private List<Long> divisor(long n) {
            List<Long> ret = new ArrayList<>();
            for (long i = 1; i * i <= n; i++) {
                if (n % i == 0) {
                    ret.add(i);
                    if (i * i != n) {
                        ret.add(n / i);
                    }
                }
            }
            ret.sort(Comparator.naturalOrder());
            return ret;
        }

    }
}



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


#define debug(x) cerr<< #x << ": "<< x << endl;
#define print(x) cerr<< x << endl;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rall(x) (x).rbegin() , (x).rend()
#define REP(i,x,y) for(int i=x;i<y;i++)
#define REPIT(it,A) for(typeof(A.begin()) it = (A.begin()); it!=A.end();it++)
#define fst first
#define snd second
#define sqr(x) ((x)*(x))

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);
#define ones(x) __builtin_popcountll(x)
using namespace std;

typedef pair<int,int> ii ;
typedef long long ll ;
typedef vector<int> vi;
typedef vector<ii> vii;

const int MAXN = 330;
ll a[MAXN][MAXN], d[MAXN][MAXN];
int n;
const ll INF = 1e16;
int main(){
   fastio;
   cin >> n;

	REP(i,0,n) REP(j,0,n) {cin >> a[i][j]; d[i][j] = a[i][j];}
	
	REP(k,0,n){
		REP(i,0,n){
			REP(j,0,n){
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	REP(i,0,n) REP(j,0,n) if(d[i][j] != a[i][j]) {cout<<-1<<endl; return 0;}
	
	REP(k,0,n){
		REP(i,0,n){
			REP(j,i + 1,n){
				if(k == i || k == j) continue;
				if(d[i][j] == d[i][k] + d[k][j]){
					d[i][j] = INF;
				}
			}
		}
	}

	ll ans = 0;
	REP(i,0,n) REP(j,i+1,n) if(d[i][j] != INF) ans += d[i][j];
	cout<<ans<<endl;

   return 0;
}



Measured memory_bytes: 1792
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int length = s.length() - 2;

		System.out.println(s.substring(0, 1) + length + s.substring(s.length() - 1));
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   int A,B,C,X,Y;
   cin>>A>>B>>C>>X>>Y;
   ll MIN = 1<<30;
   for(int i=0;i<=max(X,Y);i++){
      ll money = 0;
      money += 2*i*C;
      money += max((X-i),0)*A+max((Y-i),0)*B;
      MIN = min(money,MIN);
   }
   cout<<MIN<<endl;
   return 0; 
}


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

int main(){
  char N[200001];
  scanf("%s",N);
  int S=0;
  
  int k=0;
  
  int L=strlen(N);
  
  while(k<L){
    S=S+N[k]-'0';
    k++;
  }
  
  if(S%9==0) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1784
#include<stdio.h>
int main(){
int n;
scanf("%d",&n);
int l[100];
int max=0,sum=0;
for(int j=0;j<n;j++){
	scanf("%d",&l[j]);
if (max<l[j])max=l[j];
sum+=l[j];
}
if(2*max<sum) printf("Yes");
else printf("No");
return 0;
}

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

int t[21][21];
int n, m, x, y, l, sum, nx, ny;
char d;

void pick(int x, int y) {
  if(t[x][y] == 1) sum++;
  t[x][y] = 0;
}

void move() {
  if(d == 'W') {
    for(int i = 0; i < l; ++i) {
      nx = nx - 1;
      pick(nx, ny);
    }
  }
  else if(d == 'E') {
    for(int i = 0; i < l; ++i) {
      nx = nx + 1;
      pick(nx, ny);
    }
  }
  else if(d == 'N') {
    for(int i = 0; i < l; ++i) {
      ny = ny + 1;
      pick(nx, ny);
    }
  }
  else if(d == 'S') {
    for(int i = 0; i < l; ++i) {
      ny = ny - 1;
      pick(nx, ny);
    }
  }
}

int main() {
  while(cin >> n && n) {
    memset(t, 0, sizeof(t));
    nx = 10; ny = 10; sum = 0;

    for(int i = 0; i < n; ++i) {
      cin >> x >> y;
      t[x][y] = 1;
    }
    cin >> m;

    for(int i = 0; i < m; ++i) {
      cin >> d >> l;
      move();
    }
    cout << (sum == n ? "Yes" : "No") << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
#include<stdio.h>
 
#define MAXLEN 10000
  
   
int main( void ) 
{
    int n,q;
    int S[MAXLEN+1],T[MAXLEN+1];
    int i,j;
    int cnt;    
     
    scanf( "%d", &n ); 
    for( i=0; i<n; i++ ) {
        scanf( "%d", &S[i] ); 
    }
 
    for( i=0; i<n; i++ ) {
        for( j=i+1; j<n; j++ ) {
            if( S[i] == S[j] ) {
                S[j]=-1;
            }
        }
    }
    scanf( "%d", &q); 
    for( i=0; i<q; i++ ) {
        scanf( "%d", &T[i] ); 
    }
    
     
    cnt=0;
    for( i=0; i<n; i++ ) {
        if( -1==S[i] ) { continue; }
        for( j=0; j<q; j++ ) {
            if( S[i] == T[j] ) {
                cnt++;
                break;
            }
        }
    }
     
    if( cnt ) {
        printf( "%d\n", cnt );
    } else {
        printf( "0\n" );
    }
 
    return 0;
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

    vector<pair<int, int>> m(n);
    for (int i = 0; i < n; ++i) {
        int a; cin >> a;
        m[i] =  make_pair(a, i+1);
    }

    sort(m.begin(), m.end());

    for (int i = 0; i < n; ++i) {
        cout << m[i].second << " ";
    }

    cout << endl;
}

Measured memory_bytes: 1664
N = int(input())
K = int(input())
X = [int(k) for k in input().split()]
X = [-1] + X
# print(X)
result = 0

for i in range(len(X)):
    if (i != 0):
        # print(
        #     "i = "+str(i)+", X[i] = "+str(X[i])
        # )
        A = X[i]
        B = abs(K - X[i])
        # print(
        #     "A = "+str(A)+", B = "+str(B)
        # )
        if (A > B):
            result += B*2
        else:
            result += A*2

print(result)


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>x;
	cout<<x*x<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
  string s; cin >> s;
  if(s[0] == s[1] and s[1] == s[2] || s[1] == s[2] and s[2] == s[3]) cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    tenka12018beginner_b()
}

fun tenka12018beginner_b() {
    var (a, b, k) = readLine()!!.split(' ').map { it.toLong() }

    var turnOfA = true
    while (k-- > 0) {
        if (turnOfA) {
            b += a / 2
            a /= 2
        } else {
            a += b / 2
            b /= 2
        }
        turnOfA = !turnOfA
    }

    val answer = "$a $b"

    println(answer)
}


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

string s,f[2];

bool parse(int id, int l, int r){
  int k = 0;
  for(int i=r-1;i>=l;i--){
    if(f[id][i] == '(')k++;
    if(f[id][i] == ')')k--;

    if(k==0){
      char op = f[id][i];
      if(op == '*')return parse(id,l,i) & parse(id,i+1,r);
      if(op == '+')return parse(id,l,i) | parse(id,i+1,r);
      if(op == '>')return !parse(id,l,i-1) | parse(id,i+1,r);
    }
  }

  if(f[id][l] == '(' && f[id][r-1] == ')')return parse(id,l+1,r-1);
  if(f[id][l] == '-')return !parse(id,l+1,r);
  return f[id][l] == 'T';
}

int main(){
  while(cin >> s, s!="#"){
    string t[2];
    for(int i=0;i<s.size();i++){
      if(s[i] == '='){
	t[0] = s.substr(0,i);
	t[1] = s.substr(i+1);
	break;
      }
    }

    bool flag = true;
    for(int i=0;i<(1<<11);i++){
      //replace
      for(int j=0;j<2;j++){
	f[j] = t[j];
	for(int k=0;k<f[j].size();k++){
	  if(islower(f[j][k])){
	    int bit = f[j][k] - 'a';
	    if((i>>bit) & 1)f[j][k] = 'T';
	    else f[j][k] = 'F';
	  }
	}
      }
      flag &= ( parse(0,0,f[0].size()) == parse(1,0,f[1].size()) );
      if(!flag)break;
    }

    if(flag)cout << "YES\n";
    else cout << "NO\n";
  }
}

Measured memory_bytes: 1300
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAX_LENGTH = 1024;

char A[MAX_LENGTH + 1];
char B[MAX_LENGTH + 1];

int tu[MAX_LENGTH][MAX_LENGTH];

void lcs(int, int);

int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> A >> B;
		int lA = strlen(A), lB = strlen(B);
		lcs(lA, lB);
		cout << tu[lA][lB] << endl;
	}

}

void lcs(int lA, int lB)
{
	for (int i = 0; i < lA; ++i)
		tu[0][i] = 0;
	for (int i = 0; i < lB; ++i)
		tu[i][0] = 0;

	for (int i = 1; i <= lA; i++)
	{
		for (int j = 1; j <= lB; j++)
		{
			if (A[i-1] == B[j-1])
				tu[i][j] = tu[i - 1][j - 1] + 1;
			else
				tu[i][j] = max(tu[i][j - 1], tu[i - 1][j]);
		}
	}
}

Measured memory_bytes: 7080
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = 998244353
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    H = Scanner.int()
    ans = 0
    tmp = 1
    while H > 1:
        H //= 2
        ans += tmp
        tmp *= 2
    ans += tmp
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<class T>using numr=std::numeric_limits<T>;
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; }
const int INF = 1e9;
const ll LLINF = 1e16;
const int MOD = 1000000007;
const int MOD2 = 998244353;

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
    { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
os << "{";
    for (auto it = v.begin(); it != v.end(); it++)
        {os << (it != v.begin() ? "," : "") << *it;}
    return os << "}";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    for(int i = 0;i<100000;i+=1000){
        if(i-n>=0){
            cout << i -n << endl;
            return 0;
        } 
    }
}

Measured memory_bytes: 3648
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)
const ll INF = 1LL << 60;
const ll ZERO = 0;

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

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

int N;
ll dp[100010][3];
ll a[100010][3];

void rec(int i, int pre)
{
  if (dp[i][pre] > 0)
  {
    return;
  }
  if (i == 0)
    return;

  ll res = 0;
  rep(j, 3)
  {
    rep(k, 3)
    {
      if (j == k)
        continue;
      rec(i - 1, k);
      chmax(dp[i][k], dp[i - 1][j] + a[i][k]);
    }
  }
  return;
}

int main()
{
  cin >> N;
  rep(i, N)
  {
    rep(j, 3)
    {
      cin >> a[i + 1][j];
    };
  }
  rep(i, N + 1)
  {
    rep(j, 3)
    {
      dp[i][j] = 0;
    };
  }

  rec(N, 0);
  ll res = 0;
  rep(i, 3) chmax(res, dp[N][i]);
  cout << res << endl;
}

Measured memory_bytes: 12800
#include<stdio.h>

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


Measured memory_bytes: 128
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int maxn = 100005;
int N, a[maxn], b[maxn], c[maxn];
long long dp[maxn][4];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>N;
    
    for(int i = 1; i <= N; i++)cin>>a[i]>>b[i]>>c[i];
    
    
    dp[1][1] = a[1];
    dp[1][2] = b[1];
    dp[1][3] = c[1];
    
    for(int i = 2; i<= N; i++){
        for(int j = 1; j<=3; j++){
            for (int k = 1; k<=3; k++) {
                if(j!=k){
                    int v;
                    switch (j) {
                        case 1:
                            v = a[i];
                            break;
                        case 2:
                            v = b[i];
                            break;
                        case 3:
                            v = c[i];
                            break;
                        default:
                            break;
                    }
                    dp[i][j] = max(dp[i][j], dp[i-1][k] + v);
                }
            }
        }
    }
        
    
    cout<<max(max(dp[N][1], dp[N][2]), dp[N][3])<<endl;
    
    
    return 0;
}


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 2e5;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	map <string, int> p;
	string s;
	for (int i = 0; i < n; i++) {
		cin >> s;
		p[s]++;
	}
	cout << sz(p) << "\n";
 	return 0;
}

Measured memory_bytes: 19200
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    long[] a = new long[n];
    long sum = 0;
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextLong();
      sum += a[i];
    }
    Arrays.sort(a);
    ArrayList<Long> c = new ArrayList<Long>();
    HashMap<Long, Integer> map = new HashMap<Long, Integer>();
    for(int i = 0; i < m; i++) {
      int b = sc.nextInt();
      long cc = sc.nextLong();
   //   if(!(c.contains(cc))) c.add(cc);
      c.add(cc);
      if(map.containsKey(cc)) {
        map.put(cc, map.get(cc) + b);
      } else {
        map.put(cc, b);
      }
    }
    Collections.sort(c);
    long[] d = new long[n];
    int p = 0;
    long r = 0;
    for(int i = c.size() - 1; i >= 0; i--) {
      if(p >= n) break;
      long s = c.get(i);
      if(r == s) continue; 
      int t = map.get(s);
      r = s;
      for(int j = 0; j < t; j++) {
        if(p >= n) break;
        d[p] = s;
        p++;
      }
    }
    for(int i = 0; i < n; i++) {
      if(d[i] > a[i]) {
        sum += (d[i] - a[i]);
      } else {
        break;
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 99368
use std::io::*;
use std::str::FromStr;
use std::cmp;
use std::collections::HashMap;
use std::collections::HashSet;
use std::char;
use std::cmp::min;
use num_traits::abs;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

fn read_tuple2<T: FromStr, S: FromStr>() -> (T, S) {
    let a = read();
    let b = read();
    (a, b)
}

fn count_two(n: u64) -> u64 {
    fn go(count: u64, num: u64) -> u64 {
        if num % 2 == 0 {
            go(count + 1, num / 2)
        } else {
            count
        }
    }
    go(0, n)
}

fn main() {
    let (n, m): (u64, u64) = read_tuple2();
    if n == 1 && m == 1 {
        println!("1");
        return;
    }
    let omote = if n == 1 || m == 1 { 2 } else { n * 2 + m * 2 - 4 };
    let all = n * m;
    println!("{}", all - omote);
}



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

int main(){
    int N, X, T;
    cin >> N >> X >> T;
    int M = 0;
    while(N > 0){
        N = N - X;
        M = M + T;
    }
    cout << M << endl;
    return 0;
}

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

class Program
{
    static Dictionary<int, List<int>> G;
    static int[] dp = new int[100100];
    static void Main(string[] args)
    {
        int[] NM = ReadLineParseIntArray();
        int N = NM[0];
        int M = NM[1];
        G = new Dictionary<int, List<int>>();
        for(int i = 0; i < M; i++)
        {
            int[] xy = ReadLineParseIntArray();
            xy[0]--;
            xy[1]--;
            if (!G.ContainsKey(xy[0]))
            {
                List<int> list = new List<int>();
                list.Add(xy[1]);
                G.Add(xy[0], list);
            }
            else
                G[xy[0]].Add(xy[1]);
        }
        for (int v = 0; v < N; v++) dp[v] = -1;
        int res = 0;
        for (int v = 0; v < N; v++) res = Max(res, record(v));
        WriteLine(res);
    }
    static int record(int v)
    {
        if (dp[v] != -1) return dp[v];
        int res = 0;
        if (G.ContainsKey(v))
        {
            foreach (var nv in G[v])
            {
                res = Max(res, record(nv) + 1);
            }
        }
        return dp[v] = res;
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

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

using namespace std;

struct in {
    int t, f;
    string c;
};

int main() {
    string s; cin >> s;
    int q; cin >> q;
    deque<char> S;
    for (auto x:s) S.push_back(x);

    int sum_t = 0;
    for(int i = 0; i < q; i++) {
        int t, f;
        char c;
        cin >> t;
        if (t == 2) {
            cin >> f >> c;
        }
 
        if (t == 1) sum_t++;
        else if ((sum_t % 2) == 0) {
            if (f == 1) S.push_front(c);
            else S.push_back(c);
        } else {
            if (f == 1) S.push_back(c);
            else S.push_front(c);
        }
    }

    if ((sum_t % 2) == 1) reverse(S.begin(), S.end());
    for (auto& x:S) cout << x;
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 896
#include<stdio.h>
int main()
{
	int num[100];
	int unum[100];
	int i,j,a=0,n;
	
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
	}
	
	for(i=n-1;i>=0;i--)
	{
		printf("%d",num[i]);
		if(i!=0)
		{
			printf(" ");
		}
	}
	printf("\n");
	return 0;
}

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

long long n, dist[200003], a[200003];
long long k;
vector<long long>cycle;

int main(){
	memset(dist,-1,sizeof dist);
	cin >> n >> k;
	for (int i=1;i<=n;i++) cin >> a[i];
	long long now=1, d=0;
	while (dist[now]==-1){
		if (k==d){
			cout << now << "\n";
			return 0;
		}
		dist[now]=d++;
		now=a[now];
	}
//	cout << now << " " << dist[now] << "\n";
	k-=dist[now];
	long long tail=now;
	do{
		cycle.push_back(now);
		now=a[now];
	} while(now!=tail);
	long long m=cycle.size();
//	cout << k << "\n";
//	for (long long i : cycle) cout << i << " ";
//	cout << "\n";
	cout << cycle[k%m] << "\n";
}

Measured memory_bytes: 8416
using System;

namespace p3 {
	class prg {
		static void Main() {
			int a, b;

			{	string[] str = Console.ReadLine().Split(' ');
				a = int.Parse(str[0]);
				b = int.Parse(str[1]);	
			}

			Console.WriteLine((a * b) + " " + (a * 2 + b * 2));
		}
	}
}

Measured memory_bytes: 9196
A, B, C, D = (x for x in input())

OP = ('+', '-')

def solve():
  for op1 in OP:
    for op2 in OP:
      for op3 in OP:
        formula = A + op1 + B + op2 + C + op3 + D
        if eval(formula) == 7:
          return formula + '=7'

print(solve())          
        
        

Measured memory_bytes: 38384
def B():
    n = int(input())
    cnt = 0
    for _ in range(n):
        d_1,d_2 = list(map(int, input().split()))
        if d_1 == d_2:
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            print("Yes")
            return
    print("No")
B()

Measured memory_bytes: 9168
<?php
  $n = trim(fgets(STDIN));
  $a = explode(" ", trim(fgets(STDIN)));
  $b = [];
  if($n%2 == 0){
      $g = $n-1;
      $k = 0;
      while($g > 0){
          $b[] = $a[$g];
          $g -= 2;
      }
      while($k < $n){
          $b[] = $a[$k];
          $k += 2;
      }
  }else{
      $k = $n-1;
      $g = 1;
      while($k >= 0){
          $b[] = $a[$k];
          $k -= 2;
      }
      while($g < $n){
          $b[] = $a[$g];
          $g += 2;
      }
  }
//   print_r($b);
  
  echo implode(" ",$b);

Measured memory_bytes: 33264
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int res = -(int)Math.pow(10, 9);
        res = Math.max(a + b, Math.max(a - b, Math.max(a * b, res)));
        System.out.println(res);
        sc.close();
    }
}

Measured memory_bytes: 35692
import sys

# import re
# import math
# import collections
# import decimal
# import bisect
# import itertools
# import fractions
# import functools
# import copy
# import heapq
# import decimal
# import statistics
# import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 10
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    mat = [[0 for _ in range(10)] for _ in range(10)]

    for i in range(1, n + 1):
        s = str(i)
        ss = int(s[0])
        st = int(s[-1])
        mat[ss][st] += 1

    ans=0
    for i in range(1,10):
        for j in range(1,10):
            ans += mat[i][j]*mat[j][i]

    print(ans)




if __name__ == '__main__':
    main()


Measured memory_bytes: 41068
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int a;
string s;

signed main()
{
	cin >> a;
	cin >> s;
  
  REP(i, 100000) cerr << "test" << endl;

	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    bool used[4];
    rep(i, 4)used[i]=false;
    rep(i, s.size()){
        if(s[i]=='N')used[0]=true;
        else if(s[i]=='W')used[1]=true;
        else if(s[i]=='S')used[2]=true;
        else used[3]=true;
    }
    if((used[0]==used[2])&&(used[1]==used[3]))cout << "Yes";
    else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int b[100],a[100];

int main(){
  int i,N,j,k,maxj;
  cin >> N;
  for (i=0;i<N;++i) {
    cin >> b[i];
    if (b[i]>i+1) {
      cout << -1 << endl;
      return 0;
    }
  }
  for (i=0;i<N;++i) {
    maxj=0;
    for (j=0;j<N-i;j++) {
      if (b[j] == j+1) {
        maxj=j+1;
      }
    }
    a[N-1-i] = maxj;
    for (k=maxj;k<N-i;++k) {
      b[k-1] = b[k];
    }
  }
  for (i=0;i<N;++i) {
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

typedef vector< vector<int> > Array;
int H, W, C;
int ans = -1;

void solve(Array prev, int turn=0) {
    int orig = prev[0][0];

    if(turn == 5) {
        int temp = 0;
        bool used[10][10] = {};
        used[0][0] = true;

        queue<pii> q;
        q.push(pii(0, 0));
        while(!q.empty()) {
            temp++;
            pii temp = q.front(); q.pop();
            int x = temp.first, y = temp.second;

            rep(k,0,4) {
                int nx = x + dx[k], ny = y + dy[k];
                if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                if(used[nx][ny]) continue;
                if(prev[nx][ny] != orig) continue;
                used[nx][ny] = true;
                q.push(pii(nx, ny));
            }
        }
        chmax(ans, temp);
        return;
    }

    
    repq(i,1,6) {
        if(turn == 4 && i != C) continue;
        Array board = prev;
        bool used[10][10] = {};
        used[0][0] = true;

        queue<pii> q;
        q.push(pii(0, 0));
        while(!q.empty()) {
            pii temp = q.front(); q.pop();
            int x = temp.first, y = temp.second;
            board[x][y] = i;

            rep(k,0,4) {
                int nx = x + dx[k], ny = y + dy[k];
                if(nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                if(board[nx][ny] != orig) continue;
                if(used[nx][ny]) continue;
                used[nx][ny] = true;
                q.push(pii(nx, ny));
            }
        }

        solve(board, turn+1);
    }
}

signed main() {
    while(cin >> H >> W >> C, H || W || C) {
        ans = -1;
        Array board(H, vector<int>(W, 0));
        rep(i,0,H) rep(j,0,W) cin >> board[i][j];
        solve(board, 0);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3172
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto q = readln.chomp.to!size_t;

  foreach (_; q.iota) {
    auto x = readln.chomp, xl = x.length;
    auto y = readln.chomp, yl = y.length;

    auto memo = new int[][](xl + 1, yl + 1);
    foreach (i; 1..xl+1)
      foreach (j; 1..yl+1)
        if (x[i-1] == y[j-1])
          memo[i][j] = memo[i-1][j-1] + 1;
        else
          memo[i][j] = max(memo[i-1][j], memo[i][j-1]);

    writeln(memo[xl][yl]);
  }
}

Measured memory_bytes: 23732
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000

struct team{
  int id;
  int ac;
  int penalty;
  int wa[10];

  bool operator<(const team& r) const{
    if(ac == r.ac){
      if(penalty == r.penalty){
	return id < r.id;
      } else {
	return penalty < r.penalty;
      }
    } else {
      return ac > r.ac;
    }
  }
};

team teams[50];


int main(){
  int t,p,r;

  while(cin>>t>>p>>r, t|p|r){
    // initialize
    rep(i,t){
      teams[i].id=i+1;
      teams[i].ac=0;
      teams[i].penalty=0;
      rep(j,p){
	teams[i].wa[j]=0;
      }
    }

    // read records
    rep(i,r){
      int tid, pid, time;
      char m[10];
      scanf("%d %d %d %s", &tid, &pid, &time, m);
      tid--; pid--;
      if(m[0]=='C'){
	teams[tid].ac++;
	teams[tid].penalty += time + teams[tid].wa[pid]*1200;
      } else {
	teams[tid].wa[pid]++;
      }
    }

    sort(teams, teams+t);

    rep(i,t){
      printf("%d %d %d\n", teams[i].id, teams[i].ac, teams[i].penalty);
    }
  }
  return 0;
}

Measured memory_bytes: 1260
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr>
std::istream& operator>> (std::istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, std::enable_if_t<!std::is_same< Container, std::string >::value, std::nullptr_t> = nullptr >
std::ostream& operator<< (std::ostream& os, Container const& v) {
 os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector< int > a(n); std::cin >> a;
  std::set< int > set(a.begin(), a.end());
  // debug(set);
  int k = set.size();
  if (k % 2 == 0) k--;
  int ans = k;
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 5376
a,b,c,d,e,f=map(int,input().split())
i=0
answ=0
anss=0
cnt=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    k=0
    while c*k<=(a*i+b*j)*e:
      l=0
      if (a*i+b*j+c*k+d*l)!=0:
        if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
          if (a*i+b*j)*100+c*k+d*l<=f:
            cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
            answ=(a*i+b*j)*100
            anss=c*k+d*l
      l=((a*i+b*j)*e-c*k)//d
      if l>0:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if (a*i+b*j)*100+c*k+d*l<=f:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
      l=(f-(a*i+b*j)*100-c*k)//d
      if l>0:
        if (a*i+b*j+c*k+d*l)!=0:
          if cnt<100*(c*k+d*l)/(a*i+b*j+c*k+d*l):
            if c*k+d*l<=(a*i+b*j)*e:
              cnt=100*(c*k+d*l)/(a*i+b*j+c*k+d*l)
              answ=(a*i+b*j)*100
              anss=c*k+d*l
      k=k+1
    j=j+1
  i=i+1
temp=0
i=0
while 100*a*i<=f:
  j=0
  while 100*a*i+100*b*j<=f:
    temp=max(temp,100*a*i+100*b*j)
    j=j+1
  i=i+1
if 100*a+c>f:
  print(100*a,0)
elif temp//100*e<c:
  print(temp,0)
else:
  print(answ+anss,anss)

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int>A(N);
	int sum = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		sum += A[i];
	}
	sort(A.begin(), A.end(), greater<int>());
	if (A[M - 1]* M * 4 >= sum) cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int>ans(N);
  for(int i=0 ; i<K ; i++){
    int d;
    cin >> d;
    for (int j=0; j<d ; j++){
      int Z;
      cin >> Z;
      ans.at(Z-1)++;
    }
  }
  cout << count(ans.begin(),ans.end(),0) << endl;
}

Measured memory_bytes: 3592
N,Y = map(int,input().split(" "))


for i in range(N,-1,-1):
	for j in range(N-i,-1,-1):
			num = (10000*i+5000*j+1000*(N-i-j))
			if num == Y:
				print(str(i) + " " + str(j) + " " + str(N-i-j))
				exit(0)

print("-1 -1 -1")

Measured memory_bytes: 3188
/* template.cpp [[[ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)s)
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)s)
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int INF = 1e9 + 10;
const ll INF_LL = 1e18 + 10;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
/* ]]] */

int n, m;
int a[100];

int main(){
  cin >> n >> m;
  rep(i, n) cin >> a[i];
  rep(i, 1, m + 1) rep(j, 0, n - 1){
    if (a[j] % i > a[j + 1] % i) swap(a[j], a[j + 1]);
  }
  rep(i, n) cout << a[i] << endl;
}

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

int main()
{
	int N;
	cin >> N;
	string S;
	cin >> S;
	int ans = 0;
	rep(i,N-1)
	{
		if (S[i] != S[i+1]) ans++;
	}
	cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		List<Integer> dupList = new ArrayList<>();


		for (int i=1; i<N; i++) {
			int dupNum=0;
			List<String> fHalfList = new ArrayList<String>(new HashSet<>(Arrays.asList(S.substring(0,i).split(""))));
			List<String> sHalfList = new ArrayList<String>(new HashSet<>(Arrays.asList(S.substring(i,N).split(""))));

			for (int j=0; j<fHalfList.size(); j++) {
				if (sHalfList.contains(fHalfList.get(j))) {
					dupNum++;
				}
			}
			dupList.add(dupNum);
		}

		Optional<Integer> max = dupList.stream().max((a, b) -> a.compareTo(b));

		System.out.println(max.orElse(0));
	}
}



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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int n, m;
    cin >> n >> m;
    cout << 100 * (n - m) * pow(2, m) + 1900 * m * pow(2, m) << endl; 
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define s second
#define f first
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;

typedef double ld;
typedef long long ll;
typedef pair<int,int> pii;

const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;

int main(){ _

	int N;
	cin >> N;

	map<int,int> M;

	vector<int> V(N);
	for(auto &x : V) cin >> x, M[x]++;
	
	int cnt = 0;
	for(auto x : M){
		if(x.s == 1) continue;
		cnt += !(x.s & 1);
	}

	cnt &= 1;
	
	cout << M.size() - cnt << endl;

	return 0;
}


Measured memory_bytes: 8180
#include<stdio.h>

int main(void){
  char s[1];
  scanf("%s",s);

  if(s[0]>='a' && s[0]<='z')
    printf("a\n");
  else if(s[0]>='A' && s[0]<='Z')
    printf("A\n");

  return 0;
}


Measured memory_bytes: 1632
n = int(input())
xy = set(tuple(map(int, input().split())) for _ in range(n))

costs = []
for a in xy:
    besides_a = xy - {a}
    for b in besides_a:
        p = b[0] - a[0]
        q = b[1] - a[1]
        arrow_num = 0
        for c in xy:
            if (c[0] + p, c[1] + q) in xy:
                arrow_num += 1
        cost = n - arrow_num
        costs.append(cost)

if n == 1:
    print(1)
else:
    print(min(costs))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, n) for (int i = (a); i < (n); i++)
#define repb(i, n) for (int i = (n - 1); i >= 0; i--)
#define repb2(i, a, n) for (int i = (n - 1); i >= (a); i--)
#define all(x) x.begin(), x.end()
#define print(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
inline void fastio() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
const int INF = 2e9 + 7;

typedef struct {
    uint32_t i;
    uint32_t p;
    uint32_t y;
} info_t;

int main() {
    int32_t n, m;
    cin >> n >> m;

    vector<info_t> v(m);
    for (auto i = 0; i < m; ++i) {
        cin >> v[i].p >> v[i].y;
        v[i].i = i;
    }

    sort(v.begin(), v.end(), [](info_t x1, info_t x2) { return x1.y < x2.y; });

    vector<uint64_t> number(m);
    vector<uint32_t> count(n, 0);
    for (auto &x : v) {
        ++count[x.p];
        number[x.i] = count[x.p] + 1e6 * x.p;
    }

    for (auto &x : number) {
        cout << setw(12) << std::setfill('0') << x << '\n';
    }
}

Measured memory_bytes: 3968
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
k=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n=ii()
print(k[n-1])









Measured memory_bytes: 64620