akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ll_s long
#define mod 1000000007
#define forn(i,start,lim) for(ll i=start;i<lim;i++)
#define forn_d(i,start,lim) for(ll i=start;i>=lim;i--)
#define f first
#define s second
#define pb push_back
#define pf push_front
#define mp make_pair
#define debug1(a) cout<<"------\n"<<#a<<" = "<<a<<endl<<"------"<<endl
#define debug2(a,b) cout<<"--------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<endl<<"--------------"<<endl
#define debug3(a,b,c) cout<<"----------------------\n"<<#a<<" = "<<a<<" ; "<<#b<<" = "<<b<<" ; "<<#c<<" = "<<c<<endl<<"----------------------"<<endl
#define sz(a) (ll)(a.size())
#define debug4(a) cout<<"chu "<<a<<endl
#define endl "\n"

ll a[20][20],presum[1LL<<16LL+10],dp[1LL<<16LL+10];

void fn(ll i,vector <ll>& not_taken,ll old_score,ll mask,ll group){
  if(i==sz(not_taken)){
    dp[mask]=max(dp[mask],old_score+presum[group]);
    return ;
  }
  fn(i+1,not_taken,old_score,mask,group);
  fn(i+1,not_taken,old_score,mask^(1<<not_taken[i]),group^(1<<not_taken[i]));
}

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  ll n;
  cin>>n;
  forn(i,0,n){
    forn(j,0,n){
      cin>>a[i][j];
    }
  }
  for(ll mask=0;mask<(1<<n);mask++){
    for(ll i=0;i<n;i++){
      if(mask&(1<<i)){
        for(ll j=i+1;j<n;j++){
          if(mask&(1<<j))
            presum[mask]+=a[i][j];
        }
      }
    }
  }
  for(ll i=0;i<(1LL<<n)+5;i++)
    dp[i]=LONG_LONG_MIN;
  //for(ll mask=0;mask<(1<<n);mask++)
    //cout<<presum[mask]<<endl;
  dp[0]=0;
  for(ll mask=0;mask<(1<<n);mask++){
    vector <ll> not_taken;
    for(ll i=0;i<n;i++){
      if((mask&(1<<i))==0)
        not_taken.pb(i);
    }
    fn(0,not_taken,dp[mask],mask,0);
  }
  ll ans=dp[(1LL<<n)-1];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2816
package main

import "fmt"

func main(){
	var H, W int
	var a[100] string

	fmt.Scan(&H, &W)

	for i := 0 ; i < H ; i++ {
		fmt.Scan(&a[i])
	}

	/*for i := 0 ; i < H + 2; i++{
		for j := 0 ; j < W + 2; j++{
			fmt.Printf("#")
		}
		fmt.Println()
	}*/
	for i := 0 ; i < W + 2 ; i++{
		fmt.Printf("#")
	}
	fmt.Println()
	for i := 0 ; i < H ; i++ {
		fmt.Printf("#%s#\n", a[i])
	}
	for i := 0 ; i < W + 2 ; i++{
		fmt.Printf("#")
	}
	fmt.Println()
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    int N;  cin >> N;
    vector<int> div(101);
    for (int i = 2; i <= N; i++) {
        int temp = i;
        for (int j = 2; j <= sqrt(temp); j++) {
            while (temp % j == 0) {
                div[j]++, temp /= j;
            }
        }
        if (temp > 1) div[temp]++;
    }
    /*
    for (int i = 2; i <= N; i++) {
        cout << i << " " << div[i] << endl;
    }
    */
    map<int, ll> cnt;
    for (int i = 2; i <= N; i++) {
        if (div[i] >= 74) cnt[75]++;
        if (div[i] >= 24) cnt[25]++;
        if (div[i] >= 14) cnt[15]++;
        if (div[i] >= 4)  cnt[5]++;
        if (div[i] >= 2)  cnt[3]++;
        if (div[i] >= 0)  cnt[1]++;
    }
    ll ans = cnt[75] + cnt[25] * (cnt[3] - 1) + cnt[15] * (cnt[5] - 1) 
        + ((cnt[5] * (cnt[5] - 1)/2) * (cnt[3] - 2));
    cout << ans << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, m, p, wa, ac int
	var res string
	fmt.Scan(&n, &m)
	problems := make([]bool, n)
	was := make(map[int]int)
	for i := 0; i < m; i++ {
		fmt.Scan(&p, &res)
		if res == "AC" {
			problems[p-1] = true
		} else {
			if !problems[p-1] {
				was[p-1]++
			}
		}
	}
	for _, val := range problems {
		if val == true {
			ac++
		}
	}
	for key, val := range was {
		if problems[key] {
			wa += val
		}
	}
	fmt.Printf("%d %d", ac, wa)
}


Measured memory_bytes: 7936
#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N, M;
  cin >> N >> M;
  string s;
  cin >> s;
  vector<int> graph[N];
  int cnt[N][2];
  for (int i = 0; i < N; i++) cnt[i][0] = cnt[i][1] = 0;
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a != b) {
      graph[a].push_back(b);
      graph[b].push_back(a);
    }
    cnt[a][s[b] - 'A']++;
    cnt[b][s[a] - 'A']++;
  }
  bool alive[N];
  fill(alive, alive + N, true);
  function<void(int)> dfs = [&](int v) {
    if (!alive[v]) return;
    alive[v] = false;
    for (int u : graph[v]) {
      cnt[u][s[v] - 'A']--;
      if (cnt[u][0] == 0 || cnt[u][1] == 0) dfs(u);
    }
  };
  for (int i = 0; i < N; i++)
    if (cnt[i][0] == 0 || cnt[i][1] == 0) dfs(i);
  bool isok = false;
  for (int i = 0; i < N; i++) {
    isok |= alive[i];
  }
  cout << (isok ? "Yes" : "No") << '\n';
  return 0;
}


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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
bool taken[30];
char s[30];

int main() {
	cin>>s;
	int n = strlen(s);
	for(int i=0;i<n;i++){
		taken[s[i]-'a'] = 1;
	}
	for(int i=n;i>=0;i--){
		for(int j=0;j<26;j++){
			if(!taken[j] && j>s[i]-'a'){
				s[i] = j+'a';
				s[i+1] = 0;
				cout<<s<<endl;
				return 0;
			}
		}
		if(isalpha(s[i]))taken[s[i]-'a'] = 0;
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
A,B,K = map(int, input().split())
if A >= 1:
    if K - A >= 0:
        K = K - A
        A = 0
        if K - B >= 0:
            B = 0
        else:
            B = B - K
    else:
        A = A - K
else:
    if K - B >= 0:
        B = 0
    else:
        B = B - K
print("{} {}".format(A, B))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1ll<<60;
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; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int n;cin >> n;

    int cnt=0;
    while(n%1000!=0){
        cnt++;
        n++;
    }
    cout << cnt<< endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define gc getchar
#define int long long
const int N=1e5+5;
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
inline int read()
{
    int ret=0,f=0;char c=gc();
    while(!isdigit(c)){if(c=='-')f=1;c=gc();}
    while(isdigit(c)){ret=ret*10+c-48;c=gc();}
    if(f)return -ret;return ret;
}
struct node{
	int x,y;
}a[N];
struct Node{
	int x;
};
bool operator < (Node a,Node b)
{
	return a.x>b.x;
}
bool operator < (node a,node b)
{
	if(a.y==b.y)return a.x<b.x;
	return a.y>b.y;
}
int n,m,t,ans;
set<Node>s;
set<Node>::iterator it;
signed main()
{
	n=read();m=read();
	for(int i=1;i<=n;i++)
	{
		a[i].x=read();a[i].y=read();
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=m;i++)s.insert((Node){i});
	for(int i=1;i<=n;i++)
	{
//		cout<<i<<endl;
		it=s.lower_bound((Node){m-a[i].x+1});
		if(it==s.end())continue;
		ans+=a[i].y;
		s.erase(it);
	}
	cout<<ans;
}

Measured memory_bytes: 6528
h, w = map(int, input().split())
s = [input() for _ in range(h)]
u = [[0] * (w + 2) for _ in range(h + 2)]
d = [[0] * (w + 2) for _ in range(h + 2)]
l = [[0] * (w + 2) for _ in range(h + 2)]
r = [[0] * (w + 2) for _ in range(h + 2)]

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            u[i + 1][j + 1] = 0
        else:
            u[i + 1][j + 1] = u[i][j + 1] + 1

for i in range(h - 1, -1, -1):
    for j in range(w):
        if s[i][j] == "#":
            d[i + 1][j + 1] = 0
        else:
            d[i + 1][j + 1] = d[i + 2][j + 1] + 1

for i in range(h):
    for j in range(w):
        if s[i][j] == "#":
            l[i + 1][j + 1] = 0
        else:
            l[i + 1][j + 1] = l[i + 1][j] + 1

for i in range(h):
    for j in range(w - 1, -1, -1):
        if s[i][j] == "#":
            r[i + 1][j + 1] = 0
        else:
            r[i + 1][j + 1] = r[i + 1][j + 2] + 1

ans = 0
for i in range(1, h + 1):
    for j in range(1, w + 1):
        num = u[i][j] + d[i][j] + l[i][j] + r[i][j] - 3
        ans = max(ans, num)
print(ans)

Measured memory_bytes: 179460
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;






int main(){
    int n,k,q;cin >> n >> k >> q;
    vector<int> v(n+10,0);
    for (int i = 0; i < q; i++) {
        int a;cin >> a;
        v[0]++;
        v[a]--;
        v[a+1]++;
        v[n+1]--;
    }
    LL sum = 0;
    vector<bool> ans(n+10,false);
    for (int i = 0; i <= n; i++) {
        sum += v[i];
        if(sum<k) ans[i] = true;
    }
    for (int i = 1; i <= n; i++) {
        if(ans[i]) puts("Yes");
        else puts("No");
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N,x[110],y[110],i,j,k;
    string str;

    cin >> str;

    for(i = 0; i<str.length(); i++){
        for(j = i + 1; j < str.length(); j++){
            if(str[i] == str[j]){
                 cout << "no" << endl;
                 return 0;
            }
        }
    }
   
    cout << "yes" << endl;
       
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct Edge {
	int from, to;
};


struct Trie {
	Trie* ch[2] = {};


	void add(string& str, int pos) {
		if (str.length() == pos) return;
		if (ch[str[pos] - '0'] == NULL) ch[str[pos] - '0'] = new Trie;
		ch[str[pos] - '0']->add(str, pos + 1);

	}

	ll calc(ll height) {
		ll ret = 0;
		if (ch[0] == NULL && ch[1] == NULL) return 0;
		if (ch[0]) ret ^= ch[0]->calc(height - 1);
		if (ch[1]) ret ^= ch[1]->calc(height - 1);
		if (ch[0] == NULL || ch[1] == NULL) {
			ll bai = 1;
			while (height % 2 == 0) height /= 2, bai *= 2;
			ret ^= bai;
		}
		return ret;
	}

};


int main() {
	int n;
	ll l;
	cin >> n >> l;
	Trie tr;
	REP(i, n) {
		string str;
		cin >> str;
		tr.add(str, 0);
	}

	cout << (tr.calc(l) == 0 ? "Bob" : "Alice") << endl;

	return 0;
}

Measured memory_bytes: 6528
def isprime(num):
	for k in range(2, int(num**0.5)+1):
		if num % k == 0:
			return False
	return True

n = int(input())
pl = []

for i in range(2, 55555):
	if i % 5 == 1:
		if isprime(i):
			pl.append(i)

print(" ".join(list(map(str, pl[0:n]))))

Measured memory_bytes: 3060
n, m = map(int, input().split())
res1, res2 = 0, 0
l = [0] * (n + 1)

for _ in range(m):
    p, s = input().split()
    p = int(p)
    
    if l[p] == -1:
        continue

    if s == "AC":
        res1 += 1
        res2 += l[p]
        l[p] = -1
    else:
        l[p] += 1

print(res1, res2)

Measured memory_bytes: 3828
#include <iostream>
int main(int argc, char *argv[]) {
  int r, g, b;
  bool yes = false;
  std::cin >> r >> g >> b;
  if ((r * 100 + g * 10 + b) % 4 == 0)
    yes = true;
  std::cout << (yes ? "YES" : "NO") << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=int(n/i);j++)
		{
			if(i*j!=n)ans++;
//			for(int k=1;k<=n-i*j;k++)
//			{
//				if(i*j+k==n)ans++;
////				cout<<i<<' '<<j<<' '<<k ;
//			}
		}
	}
	cout<<ans;
	return 0; 
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
/////////////////////////////////
const ll INF = 1LL << 60;
ll dp[1000010];

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

int main(){
    rep(i, 100010) dp[i] = INF;
    int n;
    cin >> n;
    int h[n];
    rep(i, n) cin >> h[i];
    dp[0] = 0;
    for (int i = 1; i < n;i++){
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if(i>1){
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    cout << dp[n - 1] << endl;
    
}

Measured memory_bytes: 4692
N, L = map(int, input().split())
APsum=0
AJIList=[]
AbsList=[]

for i in range(N):
    APsum += i+L
    AJIList.append(i+L)
    AbsList.append(abs(i+L))
    
#print(AJIList)
#print(AbsList)

del AJIList[AbsList.index(min(AbsList))]

print(sum(AJIList))


Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#define P 1000000007

using namespace std;

typedef long long ll;

int n, A[777], B[777];

ll F[2][333][333], Fac[777], Rev[777], bra[777];

void add(ll &x, ll y) {
    x = (x + y) % P;
}

ll powmod(ll x, ll y = P - 2, ll p = P) {
    ll ans = 1;
    while(y) {
        if(y & 1) ans = ans * x % p;
        x = x * x % p;
        y >>= 1;
    }
    return ans;
}

int main() {
    scanf("%d", &n);
    for(int i = 1; i <= n * 2; i++) scanf("%d", &A[i]);
    for(int i = 0; i <= n * 2; i++) Fac[i] = !i ? 1 : Fac[i - 1] * i % P, Rev[i] = powmod(Fac[i]);
    for(int i = 0; i <= n; i++) bra[i] = Fac[i * 2] * Rev[i] % P * Rev[i] % P * powmod(i + 1) % P * Fac[i] % P;
    int a = 0, b = 1, cnt = 0;
    for(int i = 1; i <= n * 2; i += 2) {
        if(A[i] != -1 && A[i + 1] != -1) {
            B[A[i]] = (B[A[i + 1]] = 2);
        } else if(A[i] != -1) B[A[i]] = 1;
        else if(A[i + 1] != -1) B[A[i + 1]] = 1;
        else cnt++;
    }
    memset(F, 0, sizeof F);
    F[a][0][0] = 1;
    for(int i = 1; i <= n * 2; i++) if(B[i] != 2) {
        memset(F[b], 0, sizeof F[b]);
        for(int j = 0; j <= i && j <= n; j++)
            for(int k = 0; k <= i && k <= n; k++)
                if(F[a][j][k]) {
                    ll v = F[a][j][k];
                    if(B[i] == 0) {
                        if(k) add(F[b][j][k - 1], v);
                        add(F[b][j][k + 1], v);
                        add(F[b][j + 1][k], v);
                    } else {
                        if(j) add(F[b][j - 1][k], v * j);
                        add(F[b][j][k + 1], v);
                    }
                }
        swap(a, b);
    }
    ll ans = 0;
    //for(int i = 0; i <= n; i++) ans = (ans + bra[i] * F[a][i * 2][0]) % P;
    printf("%lld\n", (F[a][0][0] * Fac[cnt] % P + P) % P);
    return 0;
}

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

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

  vector<int> A(N), B(N - 1);
  for (int i = 0; i < N - 1; i++) {
    cin >> B.at(i);
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      A.at(i) = B.at(i);
    } else if (i == N - 1) {
      A.at(i) = B.at(i - 1);
    } else {
      if(B.at(i - 1) <= B.at(i)) {
        A.at(i) = B.at(i - 1);
      } else {
        A.at(i) = B.at(i);
      }
    }
  }

  for (int i = 0; i < N; i++) {
    ans += A.at(i);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main(){
 int n,m;
  cin >> n;
  vector<string> b(n);
  for(int i=0;i<n;i++) cin >> b[i];
  cin >> m;
  vector<string> a(m);
  for(int i=0;i<m;i++) cin >> a[i];   

  int res=0;
  for(int i=0;i<n;i++){
    int cnt=0;
   for(int j=0;j<n;j++){
     if(b[i]==b[j]) cnt++;
   }
   for(int j=0;j<m;j++){
     if(b[i]==a[j]) cnt--;
  }
    res=max(res,cnt);
  }
  cout << res << endl;
}


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

using namespace std;

int a,b,area,pathA,pathB,intrsctsqr,final;

int main() {
    cin>>a>>b;
    area=a*b;
    pathA=1*a;
    pathB=1*b;
    intrsctsqr=1;
    final=area-(pathA+pathB-intrsctsqr);
    cout<<final<<endl;
}

Measured memory_bytes: 3524
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n, k, h, i;
	int ans = 0;

	cin >> n >> k;

	for (i = 0; i < n; i++) {
		cin >> h;
		if (h >= k) {
			ans++;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
fun main(args:Array<String>){
    val (a,b,c)=readInts()
    if(a==b||b==c||c==a){
        if(a==b&&b==c){
            println("No")
        }else{
            println("Yes")
        }
    }else{
        println("No")
    }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

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

int main()
{

   string s;
   cin>>s;
int sum=0,a[4],i;
   for(i=0;i<4;i++)
   {
        a[i] = (s[i] - '0');
   }

int x=a[0]*10+a[1];
int y=a[2]*10+a[3];


if(x<13 && x>0)
{
if(y<13 && y>0)
    {
        cout<<"AMBIGUOUS";
    }
    else
        cout<<"MMYY";

}
if(y<13 && y>0)
{
    if(x==0 || x>12)

    cout<<"YYMM";
}
if((x==0 ||x>12 )&&(y==0 ||y>12))
{cout<<"NA";}
}

Measured memory_bytes: 256
# AOJ 0015 National Budget

class Bigint
  MAX_DIGIT = 80

  attr_reader :digit_num

  def initialize(s = "0")
    raise ArgumentError, "Non-numeric character exists" if /[^0-9]/ =~ s

    @digit = Array.new(MAX_DIGIT, 0)

    s = s.sub(/^0+/, "").reverse

    if s.empty?
      # 0 と等しい場合
      @digit_num = 1
    else
      # 0 より大きい場合
      @digit_num = s.length
      raise OverflowError, "Given integer is too big" if @digit_num > MAX_DIGIT

      s.each_char.with_index {|c, i| @digit[i] = c.to_i}
    end
  end

  def to_s
    @digit[0..(@digit_num - 1)].reverse.join("")
  end

  def to_i
    result = 0
    d = 1

    @digit[0..(@digit_num - 1)].each_with_index do |x, i|
      result += x * d
      d *= 10
    end

    result
  end

  def +(bi)
    raise TypeError unless bi.is_a?(Bigint)

    new_digit = @digit.dup
    new_digit_num = [@digit_num, bi.digit_num].max

    add = lambda {
      rec = lambda {|i, x|
        return if x.zero?

        raise OverflowError, "Sum is too big" unless i < MAX_DIGIT

        new_digit_num = i + 1 unless i < new_digit_num

        result = new_digit[i] + x
        new_digit[i] = result % 10

        # 桁上り
        rec[i + 1, 1] if result > 9
      }
    }.call

    bi.digit_num.times do |i|
      add[i, bi.digit[i]]
    end

    new2(new_digit_num, new_digit)
  end

  protected
  def digit
    @digit
  end

  def digit=(d)
    @digit = d
  end

  def digit_num=(n)
    @digit_num = n
  end

  private
  def new2(digit_num, digit)
    that = Bigint.new

    that.digit_num = digit_num
    that.digit = digit

    that
  end

  class OverflowError < Exception
  end
end

n = gets.to_i
n.times do
  begin
    x = gets.chomp
    y = gets.chomp
    puts(Bigint.new(x) + Bigint.new(y))
  rescue Bigint::OverflowError
    puts "overflow"
  end
end

Measured memory_bytes: 6264
N, M, Q = map( int, input().split())
NN = [ [0 for _ in range(N+1)] for _ in range(N+1)]
for _ in range(M):
    L, R = map( int, input().split())
    NN[L][R] += 1

for i in range(1,N+1):
    for j in range(1,N+1):
        NN[i][j] += NN[i][j-1]+NN[i-1][j]-NN[i-1][j-1]
for _ in range(Q):
    p, q = map( int, input().split())
    print(NN[q][q]-NN[q][p-1]-NN[p-1][q]+NN[p-1][p-1])

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int N; cin >> N;
	map<int, int> ans;
	for (int x = 1; x * x <= N; ++x) {
		for (int y = 1; y * y + x + x <= N; ++y) {
			for (int z = 1; x * x + y * y + z * z <= N; ++z) {
				ans[x*x + y*y + z*z + x*y + y*z + z*x]++;
			}
		}
	}
	for (int i = 1; i <= N; ++i) print(ans[i]);
}

Measured memory_bytes: 4468
#include <bits/stdc++.h>
#define ll long long
#define make_pair mp
#define MAX 1e9;
using namespace std;

int main(){
  ll N,Q;
  string S;
  cin>>N>>Q>>S;
  vector<ll> A(N,0);
  for(ll i=0;i<N;i++){
    if(S[i]=='A'&&S[i+1]=='C') A[i+1]++;
  }
  for(ll i=1;i<N;i++) A[i]+=A[i-1];
  for(ll i=0;i<Q;i++){
    ll l,r;
    cin>>l>>r;
    cout<<A[r-1]-A[l-1]<<endl;
  }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll K, res = 0; cin >> K;
  RNG(i, 1, K+1) {
    RNG(j, 1, K+1) {
      RNG(k, 1, K+1) {
        res += gcd(gcd(i,j), k);
      }
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 5e5 + 5;

int n, m;
int cache[N][5];
vector<int> g2[N];
int s, t;
int arrival[N], departure[N], vis[N], parent[N];
vector<pair<int, int> > g[N];

int dijkstra(int source, int destination)
{
	for(int i = 1; i < N; i++)
	{
		arrival[i] = 2e9;
		departure[i] = 2e9;
		vis[i] = 0;
	}
	arrival[source]=0;
	set<pair<int, int> > s;
	s.insert({0, source});
	while(!s.empty())
	{
		auto x = *(s.begin());
		s.erase(x);
		vis[x.second]=1;
		departure[x.second]=arrival[x.second];
		for(auto it:g[x.second])
		{
			if(arrival[it.first] > departure[x.second] + it.second)
			{
				s.erase({arrival[it.first], it.first});
				arrival[it.first]=departure[x.second] + it.second;
				s.insert({arrival[it.first], it.first});
				parent[it.first]=x.second;
			}
		}
	}
	if(!vis[destination])
		return 1e18;
	return arrival[destination];
}

int get(int u, int x)
{
	return n * x + u;
}

int32_t main()
{
	IOS;
	cin >> n >> m;
	for(int i = 1; i <= m; i++)
	{
		int u, v;
		cin >> u >> v;
		g2[u].push_back(v);
	}
	for(int i = 1; i <= n; i++)
	{
		for(int j = 0; j <= 2; j++)
		{
			for(auto &it:g2[i])
			{
				g[get(i, j)].push_back({get(it, (j + 1) % 3), (int)(j == 0)});
			}
		}
	}
	cin >> s >> t;
	int src = get(s, 0);
	int dest = get(t, 0);
	int ans = dijkstra(src, dest);
	if(ans == 1e18)
		ans = -1;
	cout << ans;
	return 0;
}

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

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

typedef long long ll;

int main(void){
	string str;

	while(getline(cin,str)){
		if (str.size()==1 && str[0]=='.') break;
		bool f=1;
		stack<int> st;
		REP(i,str.length()){
			switch(str[i]){
				case '(' :
					st.push(0);
					break;
				case '[' :
					st.push(1);
					break;
				case ')' :
					if (st.empty()){
						f=0;
						break;
					}
					if (st.top()==0)
						st.pop();
					else
						f=0;
					break;
				case ']' :
					if (st.empty()){
						f=0;
						break;
					}
					if (st.top()==1)
						st.pop();
					else
						f=0;
					break;
			}
		}
		if (!st.empty())
			f=0;

		if (f)
			cout << "yes" << endl;
		else 
			cout << "no" << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1172
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define inf (int)(1e18)

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

signed main(){
	int N, i, j, k;
	scanf("%lld", &N);
	int *a = (int *)malloc(sizeof(int) * N);
	for(i = 0; i < N; i++){
		scanf("%lld", &a[i]);
	}
	int *s = (int *)malloc(sizeof(int) * (N + 1));
	s[0] = 0;
	for(i = 1; i <= N; i++){
		s[i] = s[i - 1] + a[i - 1];
	}
	int **dp = (int **)malloc(sizeof(int *) * (N + 1));
	for(i = 0; i <= N; i++){
		dp[i] = (int *)malloc(sizeof(int) * (N + 1));
		for(j = 0; j <= N; j++){
			dp[i][j] = inf;
		}
	}
	for(i = 0; i < N; i++){
		dp[i][i + 1] = 0;
	}
	for(i = 2; i <= N; i++){
		for(j = 0; j + i <= N; j++){
			for(k = 1; k < i; k++){
				dp[j][j + i] = min(dp[j][j + i], dp[j][j + k] + dp[j + k][j + i] + s[j + i] - s[j]);
			}
//			printf("dp[%lld][%lld] = %lld\n", j, j + i, dp[j][j + i]);
		}
	}
	printf("%lld\n", dp[0][N]);
	return 0;
}

Measured memory_bytes: 1408
from sys import stdin

def ascii2num(ascii):
    return ord(ascii) - 96

def num2ascii(num):
    return chr(num + 96)

def slide(word,num):
    return ''.join([num2ascii((ascii2num(ascii) - num) % 26 + 1) if ascii != '.' else '.' for ascii in word])

def includekeyword(words):
    for word in words:
        if word in keywords:
            return True
    return False

keywords = ['the', 'this', 'that']

decode = []
for row in stdin:
    words = row.split()
    for num in range(1,27):
        tmp = [slide(word,num) for word in words]
        if includekeyword(tmp):
            decode = tmp
            print(' '.join(decode))
            break

Measured memory_bytes: 7372
/*-----lusar98-----*/
#include<bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define mod 1000000007
#define eps 1e-9
#define ff first
#define ss second
#define pb push_back
#define endl "\n"
using namespace std;
int main()
{
    //fast();
    ll n;
	cin>>n;
	ll arr[n];
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	ll dp[n+1][n+1];
	memset( dp ,0 , sizeof dp);
	for(ll i=n-1;i>=0;i--)
	{
		for(ll j=i;j<n;j++)
		{
			if(i == j)
				dp[i][j] = arr[i];
			else
				dp[i][j] = max( arr[i] - dp[i+1][j] , arr[j] - dp[i][j-1]);
		}
	}
	cout<< dp[0][n-1]<<endl;
}


Measured memory_bytes: 70656
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main() {
    int time[5], ceilTime[5], diff[5];
    for (int i = 0; i < 5; i++) {
        cin >> time[i];
        if (time[i] % 10 != 0) ceilTime[i] = (time[i] / 10 + 1) * 10;
        else ceilTime[i] = time[i];
        diff[i] = ceilTime[i] - time[i];
    }

    int rep = 0;
    for (int i = 0; i < 5; i++) rep += ceilTime[i];
    
    sort(diff, diff + 5);
    rep -= diff[4];

    cout << rep << endl;
}


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

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		boolean[] prime_number = new boolean[1000000];
		Arrays.fill(prime_number,true);
		prime_number[0] = false;
		prime_number[1] = false;
		for(int i=2;i<prime_number.length;i++){
			if(prime_number[i]){
				for(int j=i+i;j<prime_number.length;j+=i){
					prime_number[j] = false;
				}
			}
		}
		while(stdIn.hasNext()){
			int n = stdIn.nextInt();
			int count = 0;
			
			for(int i=2;i<=n;i++){
				if(prime_number[i]){
					count++;
				}
			}
			
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 22508
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using namespace boost::multiprecision;
int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
    int cnt[100000];
signed main(){
    int n,q;
    char s[100000];
    scanf("%d%d%s",&n,&q,s);
    rep(i,n-1){
        if(s[i]=='A'&&s[i+1]=='C')cnt[i+1]++;
        cnt[i+1]+=cnt[i];
    }
    rep(i,q){
        int l,r;
        cin>>l>>r;
        printf("%d\n",cnt[r-1]-cnt[l-1]);
    }
}


Measured memory_bytes: 1280
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii         pair<int,int>
#define psi         pair<string,int>
#define vi             vector<int>
#define vpii          vector<pii>
#define vvi         vector<vi>
#define sz(x)        (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n)     fixed<<setprecision(n)
#define ini(a, i)     memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

signed main() {
    tezz
 

    int n, x, t;
    cin >> n >> x >> t;
    int ans = (ceil(ceil((n*t)/(1.0*x))/(1.0*t))*t);
    cout << ans << endl;
 
    return 0;
}  

Measured memory_bytes: 3608
e=enumerate
n,a=open(0)
n=int(n)
d=[0]
for j,(a,i)in e(sorted((int(a),i)for i,a in e(a.split()))[::-1]):d=[d[0]+a*(~i-j+n)]+[max(d[k+1]+a*(n+k-i-j),t+a*abs(i-k))for k,t in e(d[:j])]+[d[j]+a*abs(i-j)]
print(max(d))

Measured memory_bytes: 9548
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long   ll;
typedef unsigned long long   ull;
typedef long double ld;
typedef pair<ll, ll>    pll;
typedef pair<ull, ull>    pull;
typedef pair<int, int>  pii;
typedef pair<ld, ld>  pld;
ll n, x, d;
ll mini(ll cnt){
    return cnt*(cnt-1)/2*d;
}
ll maxi(ll cnt){
    return (n-1+(n-1-cnt+1))*cnt/2*d;
}

vector<pair<ll, pll>> v;
void func(ll id1, ll id2){
    if(v[id1].ff != v[id2].ff)
        return;
    if(v[id1].ss.ss < v[id2].ss.ff)
        return;
    v[id2].ss = {min(v[id1].ss.ff, v[id2].ss.ff),
    max(v[id1].ss.ss ,v[id2].ss.ss)};
    v[id1].ss = {1, -1};
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    
    cin >> n >> x >> d;
    if(x == 0 && d == 0){
        cout << "1\n";
        return 0;
    }
    else if(d == 0){
        cout << (n+1) << "\n";
        return 0;
    }
    if(d < 0){
        x = x+(n-1)*d;
        d *= -1;
    }
    //x = 0;
    v.pb({{0}, {0, 0}});
    for(ll i = 1; i <= n; ++i){
        v.pb({abs((i*x)%d), {i*x+mini(i), i*x+maxi(i)}});
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for(int i = 0; i+1 < v.size(); ++i)
        func(i, i+1);
    for(auto u : v){
        if(u.ss.ff <= u.ss.ss)
            ans += (u.ss.ss-u.ss.ff)/d+1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 8560
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
// #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

struct ant {
  char d;
  int p;
};

int main() {
  int n, l;
  while(cin >> n >> l, n | l) {
    vector<ant> ants(n);
    REP(i, n){
      cin >> ants[i].d >> ants[i].p;
      ants[i].d = ants[i].d == 'L' ? -1 : 1;
    }

    int field[l + 1];
    for(int t = 1;; t++) {
      fill_n((int *)field, l + 1, -1);
      int last = -1;
      bool update = false;

      REP(i, n){
        if(ants[i].p <=0 || ants[i].p >= l) continue;
        ants[i].p += ants[i].d;
        if(ants[i].p <=0 || ants[i].p >= l) {
          // LOG("out : %d at %d --- %d\n", i + 1, t, ants[i].p);
          if(last == -1 || ants[last].p != 0) {
            last = i;
          }
          continue;
        }
        update = true;
        int p = ants[i].p;
        if (field[p] == -1) {
          field[p] = i;
        }else{
          ants[field[p]].d *= -1;
          ants[i].d *= -1;
        }
      }
      if(!update) {
        printf("%d %d\n", t, last + 1);
        break;
      }
    }
  }
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;

bool isWhite(char c){return c=='.';}
bool isBlack(char c){return c=='#';}
bool costly(char pre, char next){return isWhite(pre)&&isBlack(next);}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);

    int h,w; cin >> h >> w;
    vstr s(h);
    rep(i,h) cin >> s[i];
    int dp[101][101];
    dp[0][0] = (s[0][0]=='#')?1:0;
    rng(i,1,w){
        dp[0][i] = costly(s[0][i-1], s[0][i])?dp[0][i-1]+1:dp[0][i-1];
    }
    rng(i,1,h){
        dp[i][0] = costly(s[i-1][0], s[i][0])?dp[i-1][0]+1:dp[i-1][0];
    }
    rng(i,1,h){
        rng(j,1,w){
            int fromUp = costly(s[i-1][j],s[i][j])?dp[i-1][j]+1:dp[i-1][j];
            int fromLeft = costly(s[i][j-1],s[i][j])?dp[i][j-1]+1:dp[i][j-1];
            dp[i][j] = min(fromUp, fromLeft);
        }
    }
   
    cout << dp[h-1][w-1] << endl;
    return 0;
}

Measured memory_bytes: 384
from functools import lru_cache
from operator import mul
from functools import reduce


def cmb(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under


N = list(input())
N = list(map(int, N))
K = int(input())
n = len(N)


@lru_cache(None)
def rec(i, k, yn):
    if k == 0:
        return 1
    elif i == n:
        return 0
    if n - i < k:
        return 0

    if yn:
        # i桁目がNより小さいとき
        return cmb(n - i, k) * pow(9, k)
    else:
        if N[i] == 0:
            return rec(i + 1, k, False)
        else:
            a = rec(i + 1, k, True)
            b = rec(i + 1, k - 1, True) * (N[i] - 1)
            c = rec(i + 1, k - 1, False)
            return a + b + c


answer = rec(0, K, False)
print(answer)


Measured memory_bytes: 3700
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: String = read();
    println!("ABC{}", n);
}

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


Measured memory_bytes: 4352
/******************************************************************************

                            Online C Compiler.
                Code, Compile, Run and Debug C program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>
#include <iostream>
using namespace std;
int main()
{
    int x,y;
    cin >> x >> y;
    
    int output = 0;
    
    if (x % y == 0) {
        printf("-1\n");
    } else {
    
    
    printf("%d\n", x);
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int n,a[100000],b[100000],i;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
        b[a[i]-1]=i+1;
    }
    for(i=0;i<n-1;i++){
        cout<<b[i]<<" ";
    }
    cout<<b[n-1]<<endl;
}


Measured memory_bytes: 4348
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();

		boolean flag = false;
		for (int i = 0; i <= n; i++) {
			for (int j = 0; j <= m; j++) {
				int total = m * i + (n - i) * j - i * j;
				if (k == total) {
					flag = true;
					break;
				}
			}
		}

		out.println(flag ? "Yes" : "No");
		out.flush();
	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private 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;
	}

	private byte readByte() {
		if (hasNextByte()) return buffer[ptr++];
		return -1;
	}

	private boolean isPrintableChar(byte c) {
		return '!' <= c && c <= '~';
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		byte b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public int nextInt() {
		if (!hasNext()) throw new NoSuchElementException();
		int n = 0;
		boolean minus = false;
		byte 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();
		}
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}

	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		byte 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();
		}
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		return a;
	}
}

Measured memory_bytes: 21460
#[allow(unused_imports)]
use std::{cmp::Reverse, collections::*};

#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Chars, Usize1},
};

#[allow(unused_imports)]
use itertools::Itertools;

#[allow(unused_imports)]
use num::Integer;

#[fastout]
pub fn main() {
    input! {
        a: i32, b: i32,
    }

    println!("{}", ((b - 1) as f32 / (a - 1) as f32).ceil() as i32);
}


Measured memory_bytes: 2648
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    int cnt = 0;
    int c2 = 0;
    cin >> n;
    vector<int> v(n);
    for(int i=0;i<n;i++)cin >> v[i];
    sort(v.begin(),v.end());
    int max = v[n-1];
    vector<bool> b(max+1,true);
    for(int x:v){
        if(b[x]){
            if(v[c2] != v[c2+1])cnt++;
            for(int i=1;i<max/x+1;i++)b[i*x] = false;
        }
        c2++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4028
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n, f = 0, s = 0;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a.at(i));
        if (a.at(i) >= f) s = f, f = a.at(i);
        else if (a.at(i) > s) s = a.at(i);
    }
    for (int i = 0; i < n; ++i) printf("%d\n", a.at(i) == f ? s : f);
    return 0;
}


Measured memory_bytes: 2432
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	vector<int>a(100), b, c;
	int n;
	cin >> n;
	int sum;
	map<int, int>mp;
	iota(all(a), 1);
	b = c = a;
	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			for (int k = 1; k <= 100; k++) {
				sum = i * i + j * j + k * k + i * j + i * k + j * k;
				mp[sum]++;
			}
		}
	}
	for (int i = 1; i <= n; i++) {
		cout << mp[i] << endl;
	}
	//for (auto m : mp)cout << m.first << ":" << m.second << endl;
}


Measured memory_bytes: 5292