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

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

		for (int i = 0; i < x + 1; i++) {
			for (int j = 0; j < x + 1; j++) {
				if ((2 * i + 4 * j) == y && i + j == x) {
					System.out.println("Yes");
					System.exit(0);
				}
			}
		}

		System.out.println("No");

		sc.close();
	}
}

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

const ll MMM = -1e18;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int n;
	cin >> n;
	int a[n];
	for (int i=0; i<n; i++) cin >> a[i];
	int m = n/2;
	if (n&1) {
		ll ans = MMM;
		vector<ll> suff(m+1), pref(m+1), best_suff(m+1);
		// both end case
		for (int i=0; i<m; i++) {
			pref[i+1] = pref[i] + a[2*i];
		}
		for (int i=m-1; i>=0; i--) {
			suff[i] = suff[i+1] + a[2*i+2];
		}
		// single 3-jump
		for (int i=0; i<=m; i++) {
			ans = max(ans, pref[i] + suff[i]);
		}
		
		// double 2-jump
		for (int i=m-1; i>=0; i--) {
//			best_suff[i] = max(best_suff[i+1] + a[i*2+1], suff[i+1] + a[i*2+1]);
			best_suff[i] = max(best_suff[i+1], suff[i+1]) + a[i*2+1];
		}
		
		bool dbg = false;
		if (dbg) {
			cout << "PREF "; for (ll x : pref) cout << x << ' '; cout << '\n';
			cout << "SUFF "; for (ll x : suff) cout << x << ' '; cout << '\n';
			cout << "BEST "; for (ll x : best_suff) cout << x << ' '; cout << '\n';
		}
		
		ll best_pref = 0;
		ans = max(ans, best_suff[0]);
		for (int i=0; i<m; i++) {
			best_pref = max(best_pref, pref[i]) + a[i*2+1];
			ans = max(ans, best_pref + best_suff[i+1]);
		}
//		ans = max(ans, max(best_pref, pref[
		
		// one end case
		// should have covered by double 2-jump
		
		// neither end case
		ll tmp = 0;
		for (int i=0, idx=1; i<m; i++, idx+=2) tmp += a[idx];
		ans = max(ans, tmp);
		cout << ans;
	}
	else {
		vector<ll> suff(m+1);
		for (int i=m-1; i>=0; i--) {
			suff[i] = suff[i+1] + a[2*i+1];
		}
		ll ans = suff[0];
		ll pref = 0;
		for (int i=0; i<m; i++) {
			pref += a[i*2];
			ans = max(ans, pref + suff[i+1]);
		}
		cout << ans;
	}
}

Measured memory_bytes: 6296
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
using namespace std;
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;
}
vector<int> vec;
int main() {
    int N, A, B, ans = 0;
    //vector<vector<int>> data(3, vector<int>(4));
    cin >> N >> A >> B;
    rep(i, 1, N+1) {
        string s = to_string(i);
        int len = 0;
        rep(i, 0, s.length()) {
            len += s[i] - 48;
        }
        if (len >= A && len <= B) {
            ans += i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long int lli;
int mod = 1e9 + 7;

lli modPow(lli x, lli n){
  if(n == 0)return 1LL;
  lli res = modPow((x*x)%mod, n/2);
  if(n&1)res = (res*x)%mod;
  return res;
}

int main(){
  lli n, m;
  std::cin >> m >> n;

  std::cout << modPow(m, n) << std::endl;
  return 0;
}

Measured memory_bytes: 3108
#!/bin/ruby

str = gets.chomp.to_s

flag = true
remove_cnt = 0
cnt = 0
data = {"0"=> 0, "1" => 0}
(str.length).times do |i|
  if str[i] == "0"
    data["0"] += 1
  elsif str[i] == "1"
    data["1"] += 1
  end
end
tmp_ans = data["0"] - data["1"]
tmp_ans = -tmp_ans if tmp_ans < 0
puts str.length - tmp_ans


Measured memory_bytes: 1916
#include<cstdio>
using namespace std;

int main(){
	int cnt=0;
	int sum=0,avg=0;
	int s,t;
	while(scanf("%d,%d",&s,&t)!=EOF){
		sum += s*t;
		avg += t;
		cnt++;
	}
	printf("%d\n%d\n",sum,(int)((double)avg/cnt+0.5));
	return 0;
}

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


int main(){
  int n;
cin>>n;
  set<vector<int> > s;  
  for(int i=0;i<n;i++){
    int a,b,c;
    vector<int> v;
    cin>>a>>b>>c;
    v.push_back(a);
    v.push_back(b);
    v.push_back(c);
    sort(v.begin(),v.end());
    s.insert(v);
  }
cout<<n-s.size()<<endl;

  return 0;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> d(N);
    for (int i = 0; i < N; i++) {
        cin >> d.at(i);
    }
    sort(d.begin(), d.end());
    int A = 1;
    for (int i = 0; i < N - 1; i++) {
        if (d.at(i) != d.at(i + 1)) {
            A += 1;
        }
    }
    cout << A << endl;
    
}


Measured memory_bytes: 256
#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;
  cin >> n;
  ll ans = 0;
  for (int a = 1; a <= n; ++a) {
    ans += (n-1)/a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll inf=99999999999999999;
int main()
{	
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)cin>>a[i];
	ll pre[n+1];memset(pre, 0, sizeof pre);
	for(int i=1;i<=n;i++)pre[i]=a[i-1]+pre[i-1];
	ll dp[n][n];
	for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	{
		if(i==j)dp[i][j]=0;
		dp[i][j]=inf;
	}
	
	for(int l=n-1;l>=0;l--)
	{
		for(int r=l;r<n;r++)
		{
			if(l==r){dp[l][r]=0;continue;}
			for(int k=l;k<=r;k++)
			dp[l][r]=min(dp[l][r], dp[l][k]+dp[k+1][r]+pre[r+1]-pre[l]);
			
		}
	}
	cout<<dp[0][n-1];

}


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

int main()
{
    int n,m;
    cin>>n>>m;
    vector<char> x(n);
    for(int i=0;i<n;i++){
        cin>>x.at(i);

    }
    
    if(x.at(m-1)=='A'){
        x.at(m-1)='a';
    }
    if(x.at(m-1)=='B'){
        x.at(m-1)='b';
    }
    if(x.at(m-1)=='C'){
        x.at(m-1)='c';
    }
    for(int i=0;i<n;i++){
        cout<<x.at(i);
    }
    cout<<endl;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A = [None]*N
    B = [None]*N

    for i in range(N):
        a,b = map(int, input().split())
        A[i]=a
        B[i]=b
    A.sort()
    B.sort()

    if N%2==0:
        x=A[N//2-1]+A[N//2]
        y=B[N//2-1]+B[N//2]
        print(y-x+1)
    else:
        x=A[N//2]
        y=B[N//2]
        print(y-x+1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 25384
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

struct Data {
    int two, five, under;
};

int main() {
    int n; cin >> n;
    vector<string> avec(n);
    for(int i = 0; i < n; ++i) cin >> avec[i];

    vector<Data> Adata(n);
    // 各avecについてData変換
    for(int i = 0; i < n; ++i) {
        string ch = avec[i];
        int chlen = ch.length();
        bool flg = false;
        int cnt = 0;
        string no;
        for(int j = 0; j < chlen; ++j) {
            if(ch[j] == '.') {
                flg = true;
                continue;
            }
            if(flg) cnt++;
            no.push_back(ch[j]);
        }
        // 後ろから0が何個あるか
        int nolen = no.length();
        int zero = 0;
        for(int j = nolen-1; j >= 0; --j) {
            if(no[j] == '0') zero++;
            else break;
        }
        cnt -= zero;    // cnt調節
        no = no.substr(0, nolen-zero);
        ll num = stoll(no);
        // 小数点を左にずらすことができた
        int tch = 0, fch = 0;
        // 素因数2, 5の数をそれぞれ見つける
        while(1) {
            if(num%2 == 0) {
                tch++;
                num /= 2;
            }else break;
        }
        while(1) {
            if(num%5 == 0) {
                fch++;
                num /= 5;
            }else break;
        }

        Adata[i].two = tch; Adata[i].five = fch; Adata[i].under = cnt;
        Adata[i].two -= Adata[i].under;
        Adata[i].five -= Adata[i].under;
        Adata[i].under = min(Adata[i].two, Adata[i].five);
    }

    vector< vector<ll> > tfmap(20, vector<ll>(20, 0));
    for(int i = 0; i < n; ++i) {
        int tch = Adata[i].two+9;
        int fch = Adata[i].five+9;
        tfmap[min(19, tch)][min(19, fch)]++;
    }

    ll ans = 0;
    for(int i = 0; i < n; ++i) {
        int trest = max(0, 0-Adata[i].two+9);
        int frest = max(0, 0-Adata[i].five+9);
        int rmt = min(19, Adata[i].two+9);
        int rmf = min(19, Adata[i].five+9);
        tfmap[rmt][rmf]--;

        for(int j = trest; j < 20; ++j) {
            for(int k = frest; k < 20; ++k) {
                ans += tfmap[j][k];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 11968
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}


int main(){
  
  string s;
  cin>>s;
  int l = s.size();
  string res = "NO";
  REP(i,8){
    string temp = s.substr(0,i) + s.substr(l-(7-i), 7-i);
    if(temp == "keyence"){
      res = "YES";
      break;
    }
  }
  cout<<res<<endl;
  return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S;
  cin>>S;
  int cnt=0;
  int ans=0;
  for(int i=0;i<3;i++)
  {
    if(S[i]=='R')
      cnt++;
    else
    {
      if(cnt>ans)
		ans=cnt;
      cnt=0;
    }
  }
  if(cnt>ans)
    ans=cnt;
  cout<<ans<<endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
int N;
int ans[100010];
std::string s;
bool solve(int a,int b) {
	ans[0] = a;
	ans[1] = b;
	for (int i = 1; i < N; i++) {
		if (s[i] == 'o') {
			if (ans[i] == 1)ans[i + 1] = ans[i - 1];
			else ans[i + 1] = -ans[i - 1];
		}
		else {
			if (ans[i] == -1)ans[i + 1] = ans[i - 1];
			else ans[i + 1] = -ans[i - 1];
		}
	}
	if (ans[0] != ans[N])return false;
	if (s[0] == 'o') {
		if (ans[0] == 1)return ans[1] == ans[N - 1];
		if (ans[0] == -1)return ans[1] != ans[N - 1];
	}
	if (s[0] == 'x') {
		if (ans[0] == 1)return ans[1] != ans[N - 1];
		if (ans[0] == -1)return ans[1] == ans[N - 1];
	}
}

void out() {
	for (int i = 0; i < N; i++) {
		std::cout << (ans[i] == 1 ? 'S' : 'W');
	}
	std::cout << std::endl;
}
int main() {
	std::cin >> N >> s;
	if (solve(1, 1)) {
		out();
		return 0;
	}
	if (solve(-1, 1)) {
		out();
		return 0;
	}
	if (solve(1, -1)) {
		out();
		return 0;
	}
	if (solve(-1, -1)) {
		out();
		return 0;
	}
	std::cout << -1 << std::endl;
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
//#include <unordered_map>
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for(ll i = (a-1); i >= (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod=1000000007;
//ll mod=67280421310721;
//ll mod=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll re=1;
	while(b)
	{
		if(b%2==1)
		{
			re=(re*a);
			re%=mod;
		}
		a=(a*a);
		a%=mod;
		b>>=1;
	}
	return re;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1,gtest=1;
//	cin>>test;
	while(test--)
	{
		ll a,b,n;
		cin>>a>>b>>n;
		ll ans=((a*n)/b)-(a*(n/b));
		n-=n%b;
		n--;
		ans=max(ans,((a*n)/b)-(a*(n/b)));
		cout<<ans;
	}
	return 0;
}


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


using namespace std;
typedef long long ll;

int main() {
  int n;
  scanf("%d", &n);
  ll y;
  scanf("%lld", &y);

  ll x[3] = {10000, 5000, 1000};

  for (int i=0; i<n+1; i++) {
    for (int j=0; j<n+1; j++) {
      int k = n-i-j;
      if (k < 0) continue;
      if (i*x[0] + j*x[1] + k*x[2] == y) {
        printf("%d %d %d\n", i, j, k);
        return 0;
      }
    }
  }

  printf("-1 -1 -1\n");
  return 0;
}


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

void printvec(vector<int> vec) {
  for (int i = 0; i < vec.size(); i++) {
    if (i) cout << " ";
    cout << vec.at(i);
  }
  cout << endl;
}

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

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  bool flag = true;
  int c = 0;
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      if (a.at(j) < a.at(j - 1)) {
        swap(a.at(j), a.at(j - 1));
        c++;
      }
    }
  }
  printvec(a);
  cout << c << endl;
}


Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <string>
#include <queue>

typedef long long ll;
using namespace std;
const int mod = 1000000007;

const int MAX = 200001;
vector< vector<int> > M(MAX);
vector<int> counter(MAX, 0);
vector<int> visited(MAX, 0);


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

    int a, b;
    for (int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        M[a].push_back(b);
        M[b].push_back(a);
    }

    for (int i = 0; i < Q; i++) {
        cin >> a >> b;
        counter[a] += b;
    }

    queue<int> q;
    q.push(1);
    visited[1] = 1;
    int u;
    while (!q.empty()) {
        u = q.front(); q.pop();
        for (int v = 0; v < M[u].size(); v++) {
            int cur_node = M[u][v];
            if (visited[cur_node]) continue;
            visited[cur_node] = 1;
            counter[cur_node] += counter[u];
            q.push(cur_node);
        }
    }

    for (int i = 1; i <= N; i++) {
        cout << counter[i] << ' ';
    } cout << '\n';

}


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

using namespace std;

typedef long long ll;

#define pb push_back




int main() {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    int m, d;
    cin >> m >> d;
    int ans = 0;
    for (int a = 1; a <= m; a++) {
        for (int b = 10; b <= d; b++) {
            if (b % 10 < 2)
                continue;
            if (b / 10 % 10 < 2)
                continue;
            if ((b % 10) * (b / 10 % 10) == a)
                ans++;
        }
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll a[n];
	bool pos=false;
	for(ll i=0;i<n;i++) {
		cin>>a[i];
		if(a[i]==0){
			pos=true;
		}
	}
	if(pos){
		cout<<0;
		return 0;
	}
	ll ans=1;
	bool flag=true;
	for(ll i=0;i<n;i++){
		//cout<<ans<<" "<<inf/ans<<"\n";
		if(a[i] > inf/ans){
			cout<<-1;
			flag=false;
			break;
		}
		ans *=a[i];
	}
	if(flag)cout<<ans;
	
	return 0;
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

const ll INF = 1001001001001001LL;

ll D, G; 
ll p[20], c[20];
ll dp[20][150010];

void print() {
   rep (i, D+1) {
      for (int j = 0; j <= G; j++) {
         if (dp[i][j] == INF) {
            printf("%2c ", 'I');
         } else {
            printf("%2d ", dp[i][j]);
         }
      }
      puts("");
   }
}

int main() {
   // 初期化:
   cin >> D >> G;
   G /= 100;

   // 入力
   rep (i, D) {
      cin >> p[i] >> c[i];
      c[i] /= 100;
   }

   // DPテーブル初期化
   fill(dp[0], dp[20], INF);
   dp[0][0] = 0;

   // DP
   rep (i, D) {
      for (int j = 0; j <= p[i]; j++) {
         ll bonus = (j == p[i] ? c[i] : 0);
         ll score = (i+1)*j + bonus;

         for (int k = 0; k <= G; k++) {
            int nk = min(G, k + score);
            dp[i+1][nk] = min(dp[i+1][nk], dp[i][k] + j);
         }
      }
   }

   cout << dp[D][G] << endl;

   return 0;
}


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

using namespace std;

int
main(void){
	int n, k; cin >> n >> k;
	vector<int> h(n);
	for(int i = 0; i < n; i++) cin >> h[i];
	vector<int> dp(n, INT_MAX);
	dp[0] = 0;
	for(int i = 0; i < n; i++){
		for(int j = 1; j <= k; j++){
			if(i + j < n){
				dp[i + j] = min(dp[i + j], dp[i] + (int)fabs(h[i + j] - h[i]));
			}
		}
	}
	
	cout << dp[n - 1];
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N; cin >> N;
    cout << (N-1)*N/2 << endl;

}


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

int hantei(int x){
	for(int i=1;i<=1000;i++){
    	if(x==i*i){
          	//cout<<i<<endl;
        	return 1;
        }
    }
  return 0;
}


int main() {

  int a,b,c,d;
  string s,t;
  cin>>s>>t;
  
  a = stoi(s+t);
  if(hantei(a))
  cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
a, b, c, d = map(int, list(input()))
for i in range(8):
    ans = a
    tb = b
    tc = c
    td = d
    op = format(i, "b").zfill(3)
    if op[0] == "1":
        tb = -tb
    if op[1] == "1":
        tc = -tc
    if op[2] == "1":
        td = -td
    ans += tb + tc + td
    if ans == 7:
        break
op = op.replace("0", "+").replace("1", "-") + "_"
s = ""
for n, o in zip([a, b, c, d], op):
    s += str(n) + o
print(s[:-1] + "=7")


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

int main() {
  ll T1, T2, A1, A2, B1, B2;
  cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
  if (A1 == B1 || T1 * A1 + T2 * A2 == T1 * B1 + T2 * B2) {
    cout << "infinity" << endl;
    return 0;
  }

  if (T1 * A1 + T2 * A2 <= T1 * B1 + T2 * B2) {
    swap(A1, B1);
    swap(A2, B2);
  }

  if (B1 > A1) {
    ll m = T1 * (B1 - A1);
    cout << (m / (T1 * (A1 - B1) + T2 * (A2 - B2))) * 2 +
                (m % (T1 * (A1 - B1) + T2 * (A2 - B2)) != 0)
         << endl;
  } else {
    cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    import math
    import collections
    def input():
        return sys.stdin.readline()[:-1]
    N,M=map(int,input().split())
    sc=[list(map(int,input().split())) for _ in range(M)]
    answer=[0]*N
    check=[]
    if [1,0] in sc and N!=1:
        print(-1)
        sys.exit()
    for i in range(M):
        if sc[i][0] in check:
            if answer[sc[i][0]-1]!=sc[i][1]:
                print(-1)
                sys.exit()
        answer[sc[i][0]-1]=sc[i][1]
        check.append(sc[i][0])
    if answer[0]==0 and N!=1:
        answer[0]=1   
    x=0
    for j in range(N):
        x+=answer[j]*(10**(N-j-1))
    print(x)
if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// PfsMap : 素因数分解し、マップを作成
func PfsMap(n int, pfs map[int]int) map[int]int {
	for n%2 == 0 {
		pfs[2] = pfs[2] + 1
		n = n / 2
	}

	for i := 3; i*i <= n; i = i + 2 {
		for n%i == 0 {
			pfs[i] = pfs[i] + 1
			n = n / i
		}
	}

	if n > 2 {
		pfs[n] = pfs[n] + 1
	}

	return pfs
}

const mod = 1000000007

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	pfs := make(map[int]int)

	for i := 1; i <= N; i++ {
		pfs = PfsMap(i, pfs)
	}

	ans := 1
	for _, v := range pfs {
		ans *= v + 1
		ans %= mod
	}
	out(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  string S;
  cin >> S;
  if (S.length() % 2 != 0) {
    cout << "No" << endl;
    return 0;
  }
  REP(i, 0, S.length()) {
    if (i % 2 == 0 && S[i] != 'h') {
      cout << "No" << endl;
      return 0;
    }
    if (i % 2 == 1 && S[i] != 'i') {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>


using namespace std;



int main() {
    double x1, y1, x2, y2;
    double ans;
    cin >> x1 >> y1 >> x2 >> y2;
    cout<< fixed << sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)* (y1 - y2)) << endl;
}


Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define all(v) (v).begin(), (v).end()
#define MP make_pair

using namespace std;


int v[1010];
int w[1010];

int dp[1010][1010];

void solve(int n, int weight){
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= weight; j++){
			if(j < w[i]){
				dp[i][j] = dp[i-1][j];
			}else{
				dp[i][j] = max(dp[i-1][j - w[i]]+v[i], dp[i-1][j]);
			}
		}
	}
	int bestval = dp[n][weight];
	int bestwei = weight;
	for(int i = weight; i >= 0; i--){
		if(dp[n][i] == bestval){
			bestwei = i;
		}else{
			break;
		}
	}

	cout << bestval << endl;
	cout << bestwei << endl;
}

int main(){
	int W;
	int casecnt = 1;
	while(cin >> W, W){
		memset(dp, 0, sizeof(dp));
		int n;
		cin >> n;
		
		rep(i, n){
			scanf("%d,%d", &v[i+1], &w[i+1]);
		}
		cout << "Case " << casecnt++ << ':' << endl;
		solve(n, W);
	}


	return 0;
}

Measured memory_bytes: 5244
fun main(args: Array<String>) {
    val c = readLine()!!
    val vo = listOf("a","i","u","e","o")
    
    var ans = false
    vo.forEach {
        if (c == it) {
            ans = true
        }
    }
    if (ans) {
        print("vowel")
    } else {
        print("consonant")
    }
}

Measured memory_bytes: 32164
n = int(input())

t_vote = 1
a_vote = 1

for _ in range(n):
    t,a = map(int,input().split())
    if t_vote*a > a_vote*t:
        t_vote = (t_vote + t-1)//t*t
        a_vote = t_vote//t*a
    else:
        a_vote = (a_vote + a-1)//a*a
        t_vote = a_vote//a*t
print(t_vote+a_vote)

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

using namespace std;

long long a[400001];
                                       
int main () {
	int  n, k, c;
	cin >> n;
	int ans = 0;
	for (int i = 1;i <= n;i ++) {
		cin >> a[i];
		if (a[i] % 2) ans ++;
	}
	if (ans % 2) cout << "NO";
	else cout << "YES";
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000000000000

int main(void)
{
    int n;
    cin >> n;
    string tmp;
    vector<string> a(n);
    rep(i,n){
        cin >> a[i];
        sort(a[i].begin(), a[i].end());
    }
    int count[n][26] = {0};
    for( int i = 0; i < n; i++){
        for( int j = 0; j < a[i].length(); j++){
            for ( int k = 0; k < 26; k++){
                if( a[i][j] == 'a' + k) count[i][k]++;
            }
        }
    }
    int min[26];
    rep(k,26) min[k] = 1000;
    rep(k,26){
        rep(i,n){
            if( min[k] > count[i][k]){
                min[k] = count[i][k];
            }
        }
    }

    rep(k,26){
        rep(i,min[k]){
            printf("%c", 'a' + k);
        }
    }

    return 0;
}

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

void solve(int r,int n){
  double tmp[60] = {};
  double *height = tmp + 30;
  for(int i = 0;i < n;++i){
    int xl,xr;
    double h;
    cin >> xl >> xr >> h;
    for(int i = xl;i <xr;++i){
      height[i] = max(height[i],h);
    }
  }
  double res = 100.0;
  for(int i = 0;i < r;++i){
    res = min(res, height[i] - sqrt(r*r - i*i) + r);
  }
  for(int i = 0;i > -r;--i){
    res = min(res, height[i-1] - sqrt(r*r - i*i) + r);
  }
  cout << setprecision(15) << res << endl;
}

int main(void){
  int r,n;
  while(cin >> r >> n,
	!(r == 0 && n == 0)){
    solve(r,n);
  }
  return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll i, j, k, l, n, res=0;
  cin>>n;
  ll a[n];
  for(i=0; i<n; i++){
    cin>>a[i];
    res=res^a[i];
  }
  for(i=0; i<n; i++){
    printf("%lld ", res^a[i]);
  }
  return 0;
}

Measured memory_bytes: 5332
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <vector>

namespace n91 {

  using i8 = std::int_fast8_t;
  using i32 = std::int_fast32_t;
  using i64 = std::int_fast64_t;
  using u8 = std::uint_fast8_t;
  using u32 = std::uint_fast32_t;
  using u64 = std::uint_fast64_t;
  using isize = std::ptrdiff_t;
  using usize = std::size_t;

  constexpr usize operator"" _z(unsigned long long x) noexcept {
    return static_cast<usize>(x);
  }

  class rep {
    const usize f, l;

  public:
    class itr {
      friend rep;
      usize i;
      constexpr itr(const usize x) noexcept : i(x) {}

    public:
      void operator++() noexcept { ++i; }
      constexpr usize operator*() const noexcept { return i; }
      constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
    };
    constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
    constexpr itr begin() const noexcept { return itr(f); }
    constexpr itr end() const noexcept { return itr(l); }
  };
  class revrep {
    const usize f, l;

  public:
    class itr {
      friend revrep;
      usize i;
      constexpr itr(usize x) noexcept : i(x) {}

    public:
      void operator++() noexcept { --i; }
      constexpr usize operator*() const noexcept { return i; }
      constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
    };
    constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
    constexpr itr begin() const noexcept { return itr(l); }
    constexpr itr end() const noexcept { return itr(f); }
  };
  template <class T> using vec_alias = std::vector<T>;
  template <class T> auto md_vec(const usize n, const T& value) {
    return std::vector<T>(n, value);
  }
  template <class... Args> auto md_vec(const usize n, Args... args) {
    return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
  }
  template <class T> constexpr T difference(const T& a, const T& b) {
    return a < b ? b - a : a - b;
  }
  template <class T> T scan() {
    T ret;
    std::cin >> ret;
    return ret;
  }

} // namespace n91

#include <algorithm>
#include <iostream>
#include <utility>

namespace n91 {

  void main_() {
    const usize m = scan<usize>();
    const usize d = scan<usize>();
    usize ans = 0_z;
    for (const auto i : rep(1_z, m + 1_z)) {
      for (const auto k : rep(1_z, d + 1_z)) {
        const usize d1 = k % 10_z;
        const usize d10 = k / 10_z;
        if (d1 >= 2_z && d10 >= 2_z && d1 * d10 == i) {
          ++ans;
        }
      }
    }
    std::cout << ans << std::endl;
  }

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define REP(i, n) for (int i = 0; i < n; ++i)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
typedef vector<ll> vec;
typedef vector<P> pvec;
typedef vector<vector<ll>> vvec;
typedef vector<vector<P>> pvvec;
typedef priority_queue<ll> PQI;
typedef priority_queue<P> PQP;
const vector<int> dx = {0, -1, 0, 1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
const int MOD = (1000000007);
// const int MOD = (998244353);
// const int INF = (1 << 30);
const int INF = (1LL << 60);
const double EPS = (1 >> 30);
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;}



signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);
    //---------------------------------------------
    
    int n;
    cin>>n;
    cout<<n/2+n%2<<endl;
    
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
As = list(mapint())
Bs = list(mapint())
Cs = list(mapint())
ans = 0

before = -2
for a in As:
    a -= 1
    ans += Bs[a]
    if a==before+1:
        ans += Cs[before]
    before = a
print(ans)

Measured memory_bytes: 80016
#include <stdio.h>

int main(){
  char f[4],s[4];
  scanf("%s",f);
  scanf("%s",s);
  if(f[0]==s[2] && f[1]==s[1] && f[2]==s[0]){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}

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

void solve() {
  int n;
  cin >> n;
  int ans = (n+1)*n;
  ans /=2;
  cout << ans;
}


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


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
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;

//ここから

ll n,k;
vector<ll>a;

void solve(){
  cin>>n>>k;
  a.resize(n);
  k*=2;
  rep(i,n){
    cin>>a[i];
  }
  sort(all(a));
  ll l=-1e18-1,r=1e18;
  while(abs(r-l)>1){
    ll mid=(l+r)/2;
    ll sum=0;
    rep(i,n){
      if(a[i]*a[i]<=mid)--sum;
      if(a[i]>0){
        //4通り場合分けして考える
        ll pos;
        if(mid>=0)pos=upper_bound(all(a),mid/a[i])-a.begin();
        else pos=upper_bound(all(a),(mid-(a[i]-1))/a[i])-a.begin();
        sum+=pos;
      }
      else if(a[i]<0){
        ll pos;
        if(mid>=0)pos=a.end()-lower_bound(all(a),mid/a[i]);
        else pos=a.end()-lower_bound(all(a),(mid+a[i]+1)/a[i]);
        sum+=pos;
      }
      else {
        if(mid>=0)sum+=n;
      }
    }
    if(sum>=k)r=mid;
    else l=mid;
  }
  cout<<r<<"\n";
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

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

int main() {
	std::vector< std::vector<int> > mat;
	std::vector<int> vec;

	int m, n;
	std::cin >> n >> m;
	
	mat.resize(n);
	for (std::vector< std::vector<int> >::iterator it = mat.begin(); it != mat.end(); ++it) {
		it->resize(m);
	}
	for (std::vector< std::vector<int> >::iterator i = mat.begin(); i != mat.end(); ++i) {
		for (std::vector<int>::iterator j = i->begin(); j != i->end(); ++j) {
			std::cin >> *j;
		}
	}

	vec.resize(m);

	for (std::vector<int>::iterator i = vec.begin(); i != vec.end(); ++i) {
		std::cin >> *i;
	}
	
	std::vector<int> ans;

	for (std::vector< std::vector<int> >::iterator i = mat.begin(); i != mat.end(); ++i) {
		int temp = 0;
		std::vector<int>::iterator v = vec.begin();
		for (std::vector<int>::iterator j = i->begin(); j != i->end(); ++j) {
			temp += (*v) * (*j);
			++v;
		}
		ans.push_back(temp);
	}

	for (std::vector<int>::iterator i = ans.begin(); i != ans.end(); ++i) {
		std::cout << *i << std::endl;
	}
	
	std::cin >> n;

	return 0;

}

Measured memory_bytes: 3160
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <ios>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <utility>
#include <vector>
#define itn int
#define retrun return
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
using namespace std;
typedef long long llong;
typedef pair<int, int> pii;
llong gcd(llong a, llong b) {
	if (a < b) std::swap(a, b);
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
llong lcm(llong a, llong b) {
	llong g = gcd(a, b);
	return a * b / g;
}
//ここまで共通
int H, W;
char S[110][110];
int memo[110][110];
int main() {
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> S[i][j];
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int tmp;
			if (S[i][j] == '#') tmp = 1;
			else tmp = 0;

			if (i == 0 && j == 0) {
				memo[i][j] = tmp;
			}
			else if (i == 0) {
				memo[i][j] = memo[i][j - 1];
				if (S[i][j] == '#' && S[i][j - 1] == '.') {
					memo[i][j]++;
				}
			}
			else if (j == 0) {
				memo[i][j] = memo[i - 1][j];
				if (S[i][j] == '#' && S[i - 1][j] == '.') {
					memo[i][j]++;
				}
			}
			else {
				int tmp1 = memo[i][j - 1];
				if (S[i][j] == '#' && S[i][j - 1] == '.') {
					tmp1++;
				}
				int tmp2 = memo[i - 1][j];
				if (S[i][j] == '#' && S[i - 1][j] == '.') {
					tmp2++;
				}
				memo[i][j] = min(tmp1, tmp2);
			}
		}
	}

	cout << memo[H - 1][W - 1];
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <complex>
#include<vector>
#include<map>

struct City {
    int y, p, i;
    long long number;
};

int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    City *cities = new City[m];
    std::map<int, std::vector<int>> mv;
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d", &cities[i].p, &cities[i].y);
        cities[i].i = i;
        mv[cities[i].p].push_back(i);
    }

    for (auto& vp : mv)
    {
        std::sort(vp.second.begin(), vp.second.end(),
        [&cities](const int a, const int b){ return cities[a].y < cities[b].y; }
        );
        for (int i = 0; i < vp.second.size(); i++)
        {
            cities[vp.second[i]].number = i + 1;
        }
    }
    for (int i = 0; i < m; i++)
    {
        printf("%012lld\n", cities[i].number + (long long)cities[i].p * 1000000);
    }
    
    delete[] cities;
    return 0;
}

Measured memory_bytes: 14720
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

void mco(int);

int p[100];
int m[100][100];

int main(){
  int n,i,r,c;

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d%d",&r,&c);
    p[i] = r;
    if(i == n-1)
      p[i+1] = c;
  }
  
  mco(n);

  printf("%d\n",m[1][n]);

  return 0;
}

void mco(int n){
  int i,j,k,l=1,q;
  for(i = 1; i <= n; i++)
    m[i][i] = 0;
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;
      m[i][j] = INFINITY;
      for(k = i; k < j; k++){
	q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
	if(q < m[i][j]) m[i][j] = q;
      }
    }
  }
}



Measured memory_bytes: 2112
#define _USE_MATH_DEFIMES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007;
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

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


struct edge{
    int to, cost;
    edge(int To, int Cost): to(To), cost(Cost){};
};


long long prim(std::vector<std::vector<edge>>& G){
    int V(G.size());
    long long res(0);
    //std::pair<int, int> first: 距離　second: 頂点
    std::priority_queue<std::pair<int, int>,
                        std::vector<std::pair<int, int>>,
                        std::greater<std::pair<int, int>>> que;
    std::vector<int> d(V, INF);
    d[0] = 0;
    que.push({0, 0});

    while(!que.empty()){
        std::pair<int, int> p = que.top(); que.pop();
        int v(p.second);
        if(d[v] < p.first) continue;
        d[v] = 0;
        res += p.first;
        for(edge &e : G[v]){
            if(d[e.to] > e.cost){
                d[e.to] = e.cost;
                que.push({d[e.to], e.to});
            }
        }
    }
    return res;
}

int main(){
    int N; std::cin >> N;
    std::vector<std::vector<edge>> G(N);
    //x,y,id と y,x,id
    std::vector<std::pair<std::pair<int, int>, int>> px(N), py(N);
    for(int i(0); i < N; ++i){
        px[i].second = py[i].second = i;
        std::cin >> px[i].first.first >> px[i].first.second;
        py[i].first.first = px[i].first.second;
        py[i].first.second = px[i].first.first;
    }
    std::sort(std::begin(px), std::end(px));
    std::sort(std::begin(py), std::end(py));
    for(int i(0), i_len(N-1); i < i_len; ++i){
        G[px[i].second].emplace_back(px[i+1].second, 
                                     std::abs(px[i].first.first - px[i+1].first.first));
        G[px[i+1].second].emplace_back(px[i].second, 
                                     std::abs(px[i].first.first - px[i+1].first.first));
        G[py[i].second].emplace_back(py[i+1].second, 
                                     std::abs(py[i].first.first - py[i+1].first.first));
        G[py[i+1].second].emplace_back(py[i].second, 
                                     std::abs(py[i].first.first - py[i+1].first.first));
    }
    std::cout << prim(G) << std::endl;
    return 0;
}


Measured memory_bytes: 11768
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);


void solve(int T){
    string s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    map<string,int>mp;
    mp[s]=a;
    mp[t]=b;
    string u;
    cin>>u;
    mp[u]--;
    cout<<mp[s]<<" "<<mp[t]<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}





Measured memory_bytes: 3656
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,ssse3")
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<ll>;
using pi = pair<ll, ll>;
const int maxn = 34000, mod = 1e9 + 7;
int main() {
	cin.tie(0)->sync_with_stdio(0);
	string s;
	cin >> s;
	for(int i = 0; i + 1 < s.size(); i++) {
		if(s[i] == s[i+1]) cout << i+1 << " " << i+2, exit(0);
	}
	for(int i = 0; i + 2 < s.size(); i++) {
		if(s[i] == s[i+1] || s[i+1] == s[i+2] || s[i] == s[i+2]) cout << i+1 << " " << i+3, exit(0);
	}
	cout << "-1 -1\n";
}


Measured memory_bytes: 512
#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))
//-------------------------------------------------------

int hoge(int a) {
	if(a<3200) return a/400;
	else return 100;
}

int N;
int A[1010];
int O;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) {
		cin>>x;
		if(x<3200) A[hoge(x)]++;
		else O++;
	}
	
	int count=0;
	FOR(i,8) if(A[i]>0) count++;
	
	cout<<max(1,count)<<" "<<(count+O)<<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);
	solve(); return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
from heapq import heapify, heappush, heappop

def dijkstra(path, N, a):
    visited = [False] * N
    que = [(0, a)]
    heapify(que)  # 始点aから各頂点への(距離, 頂点ID)
    dist = [-1] * N  # 始点aから各頂点への距離
    dist[a] = 0  # 始点aからaへの距離は0
    while que:
        d, v = heappop(que)  # 始点から最短距離の頂点を(確定ノード)を取り出す
        visited[v] = True  # 確定フラグを立てる
        # 接続先ノードの情報を更新する
        for d, to in path[v]:
            cost = dist[v] + d
            if dist[to] < 0 or cost < dist[to]:
                dist[to] = cost
                if not visited[to]:
                    heappush(que, (cost, to))

    return dist

def main():
    N = int(input())
    path = [[] for _ in range(N)]
    for _ in range(N-1):
        u, v, w = map(int, readline().rstrip().split())
        path[u-1].append((w, v-1))
        path[v-1].append((w, u-1))
    
    G = dijkstra(path, N, 0)
    for i in range(N):
        if G[i] % 2 == 0:
            print(0)
        else:
            print(1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 42948
using System;
using System.Collections;
using System.Linq;
class Mainclass
{
  static void Main ()
{
  var word = Console.ReadLine();
  int[] array = new int[3];
  for(int i = 0; i < 3; i++ ){
    array[i] = int.Parse(word[i].ToString());
  }
  int count = 0;
  foreach ( int i in array )
  {
    if (i == 1){
      count++;
    }
  }
  Console.WriteLine(count);
}
}

Measured memory_bytes: 11092
# -*- encoding: utf-8 -*-
n = int(input().rstrip())
array = sorted(list(map(int, input().split(' '))))
count = [0] * 100002

for a in array:
    count[a - 1] += 1
    count[a    ] += 1
    count[a + 1] += 1

print(max(count))

Measured memory_bytes: 14008