akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

void swap(int *x,int *y)
{
	int temp = *x;
	*x=*y;
	*y=temp;
}

int main()
{
	int count;
	scanf("%d",&count);

	for(int i=0;i<count;i++)
	{
		int a,b,c;
		scanf("%d %d %d",&a,&b,&c);
		if(a<b)
			swap(&a,&b);
		if(a<c)
			swap(&a,&c);

		if(a*a == b*b+c*c)
			printf("YES\n");
		else
			printf("NO\n");
	}

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  string s;
  cin >> s;
  ll ans=INF,k=s.size();
  rep(i,26){
    bool a=false,b=true;
    ll cnt=INF;
    rep(j,s.size()){
      if(abc[i]==s[j]){
        a=true;
      }
      else{
        b=false;
      }
    }
    if(a){
      cnt=0;
      string S=s;
      ll l=k;
      while(!b){
        string t="";
        b=true;
        l--;
        rep(j,l){
          if(abc[i]==S[j]||abc[i]==S[j+1]){
            t+=abc[i];
          }
          else{
            t+='0';
            b=false;
          }
        }
        S=t;
        cnt++;
      }
    }
    ans=min(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include "stdio.h"
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;



class Puzzle
{
public:
	string T;
	string P;

	void input()
	{
		cin >> T;
		cin >> P;

	}

	void play()
	{
		if (T.size() < P.size()) return;

		for (int si = 0; si <= (T.size() - P.size()); si++) {
			if (T.substr(si, P.size()) == P) {
				cout << si << "\n";
			}
		}
	}

};


int main()
{
	Puzzle puz;

	puz.input();
	puz.play();

    return 0;
}




Measured memory_bytes: 3972
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <iomanip>

using namespace std;

const int maxn = 22;
const int mo = 1e9 + 7;

int n, a[maxn][maxn], f[maxn][1<<maxn];

int countOne(int cur) {
	int res = 0;
	while (cur > 0) {
		if (cur&1)
			++res;

		cur >>= 1;
	}
	return res;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cin >> n;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j)
			cin >> a[i][j];

	int lim = (1<<n)-1;

	f[0][0] = 1;
	for (int i = 1; i <= n; ++i)
		for (int j = (1<<i)-1; j <= lim; ++j)
			if (countOne(j) == i) {
				for (int k = 0; k < n; ++k)
					if ((j & (1<<k)) && a[i-1][k]) {
						f[i][j] += f[i-1][j-(1<<k)];
						if (f[i][j] >= mo)
							f[i][j] -= mo;
					}
			}

	cout << f[n][lim] << endl;

	return 0;
}

Measured memory_bytes: 178432
X, N = map(int, input().split())

if N == 0:
     print(X)
else:
    given_list = [int(i) for i in input().split()]
    ans = 0

    for diff in range(X):
        X_plus = X + diff
        X_minus = X - diff
        # print(X_plus)
        # print
        if (X_minus in given_list) == False:
            ans = X_minus
            break
        elif (X_plus in given_list) == False:
            ans = X_plus
            break
    print(ans)

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using namespace std; 

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";} 
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}
template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;

    while(k > 0&& b <= a) {
        b*=2;
        k--;
    }

    while(k && c <= b) {
        c*=2;
        k--;
    }

    if(a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

/*atcoder*/



Measured memory_bytes: 3628
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
int prime(ll n, vector<int> a,ll m) {
	ll ans = 1;
	while (n % 2 == 0){
		a.push_back(2);n /= 2;
		if (a.size() == m){
			ans *= 2;
			a.clear();
		}
	}
	a.clear();
	for (ll i = 3; i * i <= n;i += 2){
		while (n % i == 0){
			n /= i;a.push_back(i);
			if (a.size() == m) {
				ans *= i;
				a.clear();
			}
		}
		a.clear();
	}
	return ans;
}
int main() {
	ll n, m, ans = 0,sum = 0,x,y;cin >> n >> m;
	vector<int> a;
	if (n == 1) {
		cout << m << endl;
		return 0;
	}
	cout << prime(m,a ,n) << endl;
}

Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
s=get_nsp
ans=1
(N-1).times do|i|
    if s[i]!=s[i+1]
      ans+=1 
    end
end
puts ans

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

int main(){
    long long int n;
    cin >> n;
    string ans = "";
    long long int base = 26;
    do{
        for(int i = 0; i < 26; i++){
            if((n+i)%26 == 0){
                ans = (char)('a'+26-i-1) + ans;
                n = n - (26-i);
                n /= 26;
            }
        }
    }while(n > 0);
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long LL;

int main()
{
	int N;
	cin >> N;
	if ((N / 10) == 9)
	{
		cout << "Yes" << endl;
	}
	else
	{
		if ((N % 10) == 9)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;

void buystock(int &a, ll &money, ll &cnt){
    cnt += money/a;
    money -= (money/a)*a;
}

void sellstock(int &a, ll &money, ll &cnt){
    money += a*cnt;
    cnt = 0;
}

int main() {
    int n;
    cin>>n;
    vector<int>a(n+1);
    rep(i,n) cin>>a[i];
    ll money = 1000;
    ll cnt = 0;
    rep(i,n){
        if(a[i]<a[i+1]) buystock(a[i],money,cnt);
        else if(a[i]>a[i+1]) sellstock(a[i],money,cnt);
    }
    cout<<money<<endl;

    return 0;
}

Measured memory_bytes: 3600
// Problem : D - ###
// Contest : AtCoder - AtCoder Beginner Contest 058
// URL : https://atcoder.jp/contests/abc058/tasks/arc071_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int n,m;cin>>n>>m;
vi x(n);cin>>x;
vi y(m);cin>>y;
vi post(n);
post[n-1]=0;
for(int i=n-2;i>=0;i--)
{
	post[i]=post[i+1]+x[i+1];
	post[i]%=md;
}
int ans=0;
int ycal=0;
for(int i=0;i<m;i++)
{
	ycal=(ycal+(i*y[i])%md+((-((m-(i+1))*y[i]))%md+md)%md+md)%md;
}
for(int i=0;i<n;i++)
{
	ans=(ans+(ycal*(((post[i]-(n-(i+1))*x[i])%md+md)%md)%md)%md)%md;
}
cout<<ans;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;
 
int parent[N];
 
int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 
 
ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}
 
int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}
 
void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}
 
ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}
 
int ask(int i, int j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    int v;
    cin >> v;
    return v;
}
 
void solve() {
    int n;
    cin >> n;
    vector<int> h(n);
    vector<int> dp(n, INT_MAX);
    for(int i=0;i<n;i++) cin >> h[i];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2;i<n;i++) {
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2]);
    }
    cout << dp[n-1] << endl;
    return;
} 
 
int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}

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

					using namespace std;
					typedef long long ll;
					int a, b, c, d, i = 1;
					int main()
					{
						cin >> a >> b >> c >> d;
						while(a > 0 && c > 0)	
						{
							if(i & 1)
								c -= b;
							else a -= d;
							i++;	
						}
						if(a <= 0)
							cout << "No";
						else cout << "Yes";	
					}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     9e18
#define ld                      long double
#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            for(ll i=0;i<size;i++) cout<<w[i]<<" ";
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a, ll m=MOD) { return powm(a, m-2, m);}

int main()
{
	fastIO
	ll n;
	cin>>n;
	vll a(n);
	input(a,n);
	ll ans=inf;
	rep(i,1,100,1)
	{
		ll temp=0;
		rep(j,0,n-1,1)
		{
			temp+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,temp);
	}
	cout<<ans;
	return 0;
}


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() {
  string s;
  cin >> s;
  if (s == "Sunny")
    s = "Cloudy";
  else if (s == "Rainy")
    s = "Sunny";
  else if (s == "Cloudy")
    s = "Rainy";
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
V = list(map(int,input().split()))
answer = 0
for i in range(min(N,K)+1):
    for j in range(min(N,K)+1-i):
        tempV = V[0:i]+V[N-j:] + [0]
        tempV.sort()
        for k in range(K-i-j):
            if tempV[0] < 0:
                tempV.pop(0)
        if sum(tempV) > answer:
            answer = sum(tempV)
            
print(answer)

Measured memory_bytes: 3064
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    n=int(input())
    c=0
    ans=0
    for i in range(n+1):
        if(i%3!=0) and (i%5 !=0):
            ans+=i
    print(ans)
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 9224
PROGRAM B
  IMPLICIT NONE
  INTEGER :: n,i,j,k
  INTEGER :: count=0
  INTEGER,allocatable :: l(:)
  READ *, n
  allocate(l(n))
  READ *, l

  DO i=1,n
  DO j=1,n
  DO k=1,n
    IF(l(i)/=l(j) .and. l(j)/=l(k) .and. l(k)/=l(i)) THEN
      IF(l(i) < (l(j)+l(k)) ) THEN
        IF(l(j) < (l(k)+l(i)) ) THEN
          IF(l(k) < (l(i)+l(j)) ) THEN
            count=count+1
          END IF
        END IF
      END IF
    END IF
  END DO
  END DO
  END DO
  deallocate(l)
  PRINT *, count/6
END PROGRAM B


Measured memory_bytes: 2768
import java.util.Scanner

object Main {
  def main(args:Array[String]):Unit = {
    val sc:Scanner = new Scanner(System.in)

    val n:Integer = sc.nextLine().toInt
    val k:Integer = sc.nextLine().toInt
    val x:Integer = sc.nextLine().toInt
    val y:Integer = sc.nextLine().toInt

    if (n > k) {
      println(x * k + y * (n - k))
    } else {
      println(x * n)
    }
  }
}

Measured memory_bytes: 27332
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

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

int main()
{
    vector<int> w(10), k(10);
    REP(10) cin >> w[i];
    REP(10) cin >> k[i];
    sort(all(w), greater<int>() );
    sort(all(k), greater<int>() );
    cout << w[0] + w[1] + w[2] << " " << k[0] + k[1] + k[2] << endl;

    return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> t(n);
  vector<ll> a(n);
  for(ll i=0;i<n;i++) {
    cin >> t[i] >> a[i];
  }
  ll f1=1,f2=1;
  for(ll i=0;i<n;i++) {
    if(f1%t[i]) {
      f1=(f1+t[i]-1)/t[i]*t[i];
    }
    if(f2%a[i]) {
      f2=(f2+a[i]-1)/a[i]*a[i];
    }
    if(f1/t[i]==f2/a[i]) {
      continue;
    }
    if(f1/t[i]>f2/a[i]) {
      f2=f1/t[i]*a[i];
    }
    else {
      f1=f2/a[i]*t[i];
    }
  }
  cout << f1 + f2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int n,m,g,d,l[10],f;
string p[30];
int c(){
  int i,j;
  for(i=0;i<n;i++)l[i]=i+1;
  for(i=0;i<d;i++)
    for(j=0;j<n-1;j++)
      if(p[i][j]=='1')swap(l[j],l[j+1]);
  return l[g-1]==m;
}

main(){
  int i,j;
  while(cin>>n,n){
    cin>>m>>g>>d;
    for(i=0;i<d;i++)cin>>p[i];
    f=c()*2;
    for(i=0;!f && i<d;i++){
      for(j=0;!f && j<n-1;j++){
	if((p[i][j]=='1')|(p[i][j-1]=='1')|(p[i][j+1]=='1'))continue;
	p[i][j]='1';
	f=c();
	p[i][j]='0';
      }
    }
    if(f==2)puts("0");
    else if(f==0)puts("1");
    else cout<<i<<" "<<j<<endl;
  }
}

Measured memory_bytes: 0
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int N=0,K=0,X=0,Y=0;
  
  cin >> N >> K >> X >> Y;
  cout << (N>K?X*K+(N-K)*Y:N*X) << endl;

  return 0;
}

Measured memory_bytes: 256
a, b = map(int, input().split())


def factorization_in_prime_number(x):
    prime_factor = []
    if x % 2 == 0:
        prime_factor.append(2)
    while x % 2 == 0:
        x //= 2
    m = int(x**.5) + 1
    for i in range(3, m, 2):
        if x % i == 0:
            prime_factor.append(i)
        while x % i == 0:
            x //= i
    if x != 1:
        prime_factor.append(x)
    # x=1 の時はからのリストを返す
    return prime_factor


a_factor = factorization_in_prime_number(a)
b_factor = factorization_in_prime_number(b)
ans = len(set(a_factor) & set(b_factor)) + 1
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
  int i,j;
  int n;
  int minj;
  int stable=1;
  
  scanf("%d",&n);
  
  if(n < 1 || 36 < n)
    exit(0);
  
  char c1[n][3];
  char c2[n][3];
  char tmp[3];
  
  for(i=0; i<n; i++){
    scanf("%s",c1[i]);
    for(j=0; j<4; j++){
      c2[i][j] = c1[i][j];
    }
  }
  
  /*BubbleSort*/
  
  for(i = 0; i < n; i++){
    for(j = n-1; j > i; j--){
      if(c1[j][1] < c1[j-1][1]){
	strcpy(tmp, c1[j]);
	strcpy(c1[j],c1[j-1]);
	strcpy(c1[j-1],tmp);
      }
    }
  }
  
  for(i = 0; i<n-1; i++){
    printf("%c%c ",c1[i][0],c1[i][1]);
  }
  printf("%c%c\n",c1[i][0],c1[i][1]);
  printf("Stable\n");
  
  /*SelectionSort*/
  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(c2[j][1] < c2[minj][1]){
	minj = j;
      }
    }
    strcpy(tmp, c2[i]);
    strcpy(c2[i],c2[minj]);
    strcpy(c2[minj],tmp);
  }
  
  for(i = 0; i<n-1; i++){
    printf("%c%c ",c2[i][0],c2[i][1]);
  }
  printf("%c%c\n",c2[i][0],c2[i][1]);

  for(i=0; i<n; i++){
    if(strcmp(c1[i],c2[i]) != 0){
      stable = 0;
    }
  }

  if(stable == 1){
    printf("Stable\n");
  }
  else printf("Not stable\n");
  
  return 0;
}
	



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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, t, x, y, pt, px, py;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t >> x >> y;
        int dt = t - pt;
        int d = abs(x - px) + abs(y - py);
        if (d > dt) {
            cout << "No" << endl;
            exit(0);
        }
        if ((dt & 1) ^ (d & 1)) {
            cout << "No" << endl;
            exit(0);
        }

        pt = t;
        px = x;
        py = y;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
const int N=5010,Mo=1000000007;
int tt;
int head[N],to[N*2],nxt[N*2],sz[N],g[N],c[N],f[N][N];
inline int gi() {
    int x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
inline void dfs(int x,int fa) {
    sz[x]=f[x][1]=1;
    for(int i=head[x];i;i=nxt[i]) {
	int y=to[i];
	if(y!=fa) {
	    dfs(y,x);
	    memset(g,0,sizeof(g));
	    for(int a=1;a<=sz[x];a++)
		for(int b=1;b<=sz[y];b++) {
		    g[a]=(g[a]-1LL*f[x][a]*f[y][b]%Mo*c[b])%Mo;
		    g[a+b]=(g[a+b]+1LL*f[x][a]*f[y][b])%Mo;
		}
	    memcpy(f[x],g,sizeof(g)),sz[x]+=sz[y];
	}
    }
}
int main() {
    int n,ans=0;
    cin>>n,c[0]=1;
    for(int i=2;i<=n;i+=2) c[i]=1LL*c[i-2]*(i-1)%Mo;
    for(int i=1;i<n;i++) {
	int x=gi(),y=gi();
	to[++tt]=y,nxt[tt]=head[x],head[x]=tt;
	to[++tt]=x,nxt[tt]=head[y],head[y]=tt;
    }
    dfs(1,0);
    for(int i=1;i<=n;i++) ans=(ans+1LL*f[1][i]*c[i])%Mo;
    cout<<(ans+Mo)%Mo;
    return 0;
}

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

int f(int n) {
  return n%2==0? n/2 : 3*n+1;
}

int main(void) {
  int s;
  cin >> s;

  vector<int> v;
  int i = 0;

  while (1) {
    if ( i == 0 ) {
      v.push_back(s);
      i++;
      continue;
    } else {
      v.push_back( f(v.at(i-1)) );
    }
    
    int j;
    bool flg = false;

    for ( j = 0; j < v.size()-1; j++ ) {
      flg = v.at(i) == v.at(j);
      if (flg) break;
    }
    if ( flg ) {
      cout << i+1 << endl;
      break;
    } else {
      i++;
    }
  }

  return 0;
}

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

int main() {
	// your code goes here
	int n, k;
	cin >> n >> k;
	int h[n];
	int dp[n];
	for(int i=0; i<n; i++) {
		cin >> h[i];
		dp[i] = INT_MAX;
	}
	dp[0] = 0;
	for(int i=1; i<n; i++) {
		for(int j=1; j<=k; j++) {
			if(i-j >= 0) {
				dp[i] = min(dp[i-j]+abs(h[i]-h[i-j]), dp[i]);
			} else {
				break;
			}
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(void)
{
	int n,b,f,r,v,A[4][3][10],i;

	cin >> n;

	for(b=0;b<4;b++){
		for(f=0;f<3;f++){
			for(r=0;r<10;r++){
				A[b][f][r]=0;
			}
		}
	}

	for(i=1;i<=n;i++){
		cin >> b >> f >> r >> v;
		A[b-=1][f-=1][r-=1]+=v;
	}

	for(b=0;b<4;b++){
		for(f=0;f<3;f++){
			for(r=0;r<10;r++){
				cout << " " << A[b][f][r];
			}
			cout << endl;
		}
		if(b==3)break;
		cout << "####################" << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*4
#define N 2005
#define ll long long
#define mod 1000000007
ll f[nn],rf[nn];int n;
ll qpow(ll x,ll y)
{
	ll res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}
ll a[nn],b[nn];
ll dp[N+N][N+N];
ll bas=N-2;
ll C(ll x,ll y)
{
	return f[y]*rf[x]%mod*rf[y-x]%mod;
}
int main()
{
	f[0]=1;for(int i=1;i<nn;i++) f[i]=f[i-1]*i%mod;
	rf[nn-1]=qpow(f[nn-1],mod-2);
	for(int i=nn-2;i>=0;i--) rf[i]=rf[i+1]*(i+1)%mod; 
	cin>>n;ll ans=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&a[i],&b[i]);
		ans=ans-C(a[i]+a[i],b[i]+b[i]+a[i]+a[i]),ans%=mod;
		dp[-a[i]+bas][-b[i]+bas]++;
	}
	for(int i=1;i<N+N;i++)
	{
		for(int j=1;j<N+N;j++)
		{
			dp[i][j]=dp[i][j]+dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=mod;
		}
	}
	
	for(int i=1;i<=n;i++)
	{
		ans+=dp[a[i]+bas][b[i]+bas];
		ans%=mod;
	}
	
	ans+=mod;ans%=mod;ans=ans*qpow(2,mod-2)%mod;
	printf("%lld\n",ans);
	return 0; 
}

Measured memory_bytes: 134016
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;



int main(){
        _

        ll n; cin >> n;
        cout<<n*(n-1)/2<<endl;




return 0;
}



Measured memory_bytes: 3652
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unordered_map>
#include <vector>

int main() {
  long long H, W;
  scanf("%lld", &H);
  scanf("%lld", &W);
  long long ans = 1e15;
  for (int i = 0; i < 2; i++) {

    //横に2回切る
    if (H % 3 == 0) {
      ans = std::min((long long)0, ans);
    } else {
      ans = std::min(W, ans);
    }
    // 横に切った残りを縦に切る
    if (W % 2 == 0) {
      if (H % 3 == 0) {
        ans = std::min((long long)0, ans);
      } else {
        ans = std::min(W/2, ans);
      }
    } else {
      for (int i=0; i<=H; i++){
        long long area1 = i*(W/2);
        long long area2 = i*(W-W/2);
        long long area3 = (H-i)*W;
        long long diff = std::max(area1, std::max(area2, area3)) - std::min(area1, std::min(area2, area3));
        ans = std::min(ans, diff);
      }
    }
    std::swap(H, W);
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
/*
SelectionSort(A)
1 for i = 1 to length[A]
2     do mini = i
3     do for j = i to length[A]
4         do if A[j] < A[mini]
5             then mini = j
6        swap A[i] and A[mini]

*/
int main()
{
//	cut here before submit 
//	freopen ("testcase.selection_sort", "r", stdin );
	int n;
	scanf ("%d", &n );

	vector<int> A(n, 0 );
	rep (i, n ) scanf (" %d", &A[i] );

	int res = 0;
	rep (i, n ){
		int min_i = i;
		for (int j = i; j < n; j++ )
			if (A[j] < A[min_i] ) min_i = j;

		if (min_i != i ){
			swap (A[i], A[min_i] );
			res++;
		} // end if
	} // end rep

	rep (i, n ){
		cout << A[i] << (i != n - 1 ? ' ' : '\n' );
	} // end rep
	cout << res << endl;
		
	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int n,A[200];

int solve(int i,int m) {
  if(m == 0) return 1;
  if(i >= n) return 0;
  int res = solve(i+1,m) || solve(i+1,m-A[i]);
  return res;

}

int main () {
  int q,M,i;

  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d",&A[i]);
    }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&M);
    if(solve(0,M)) printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

  
  



Measured memory_bytes: 2052
import java.util.Scanner;

public class Main{

  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    boolean hitN = false;
    boolean hitE = false;
    boolean hitW = false;
    boolean hitS = false;
    for(int i = 0; i < S.length(); i++){
      // System.out.println(S.charAt(i));
      switch(S.charAt(i)) {
        case 'N':
          hitN = true;
          break;
        case 'W':
          hitW = true;
          break;
        case 'E':
          hitE = true;
          break;
        case 'S':
          hitS = true;
          break;
      }
    }

    System.out.println((hitN == hitS && hitW == hitE) ? "Yes" : "No");
  }
}


Measured memory_bytes: 21716
import copy
S = input()
T = input()

point = [ [0 for t in range(len(T) + 1)] for _ in range(len(S) + 1)]
path = [ [0 for t in range(len(T) + 1)] for _ in range(len(S) + 1)] #vert 3, right2, slash 1

# dp[point] S seq
for s_index in range(len(S)):
    for t_index in range(len(T)):
        if S[s_index] == T[t_index]:
            point[s_index + 1][t_index + 1] = point[s_index][t_index] + 1
            path[s_index + 1][t_index + 1] = 1
        elif point[s_index + 1][t_index] > point[s_index][t_index + 1] :
            point[s_index + 1][t_index + 1] = point[s_index + 1][t_index]
            path[s_index + 1][t_index + 1] = 3
        else:
            point[s_index + 1][t_index + 1] = point[s_index][t_index + 1]
            path[s_index + 1][t_index + 1] = 2



last_s = len(S) 
last_t = len(T)

ret = ''
while(last_s != 0 and last_t != 0):
    if path[last_s][last_t] == 1:
        ret += S[last_s-1]
        last_s -= 1
        last_t -= 1
    elif path[last_s][last_t] == 2:
        last_s -= 1
    else:
        last_t -= 1

print(ret[::-1])



Measured memory_bytes: 191752
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecd> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 200000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const ll INFL = 1e18;
const int MOD = 1000000007;

int dx4[4]={1,0,-1,0};
int dy4[4]={0,1,0,-1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

//********************************template END****************************************//

double gaiseki(comp a, comp b)
{
	return (conj(a)*b).imag();
}

void solve(void){

	vector <comp> ps;
	double x, y;
	char c;
	while(cin >> x >> c >> y)
	{
		comp p(x, y);
		ps.pb(p);
	}

	double ans = 0;

	rep((int)ps.size()-2, i)
	{
		ans += gaiseki(ps[i+1]-ps[0], ps[i+2]-ps[0]) / 2;
	}

	cout << abs(ans) << endl;
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3240
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> v;
  int index = 0;
  char pre = s[0];
  int now = 0;
  if(s[0]=='0')
    v.push_back(0);
  rep(i,int(s.size())){
    if(s[i]==pre){
      now++;
      if(i==s.size()-1){
        v.push_back(now);
      }
    }else{
      v.push_back(now);
      pre = s[i];
      now = 1;
      if(i==s.size()-1){
        v.push_back(now);
      }
    }
  }
  if(s.back()=='0')
    v.push_back(0);
  ll ans = 0;
  vector<ll> sum(v.size() + 1, 0);
  rep(i, v.size()) sum[i + 1] = sum[i] + v[i];
  for (int i = 0; i < sum.size(); i+=2){
    int j = i + 2 * k + 1;
    if(j >= sum.size())
      j = sum.size() - 1;
    chmax(ans, ll(sum[j] - sum[i]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4824
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
double pi=acos(-1);
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
// #define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< ll, ll >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace boost::multiprecision;
using namespace std;
void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int N=1000005;
ll fact[N],invfact[N];
ll power(ll x,ll y){
  if(y<=0) return 1LL;
  ll z=power(x,y/2);
  if(y%2) return (((z*z)%mod)*x)%mod;
  return (z*z)%mod;
}

void pre(){
  fact[0]=invfact[0]=invfact[1]=fact[1]=1;
  rep(i,2,N) fact[i]=(i*fact[i-1])%mod;
  rep(i,2,N) invfact[i]=(invfact[i-1]*power(i,mod-2))%mod;
}
ll nCr(ll n,ll k){ return (((fact[n]*invfact[n-k])%mod)*invfact[k])%mod; }



const int N1=1e6+1;
vector<int> isprime(N1,1),prime;
void seive(){
  rep(i,2,sqrt(N1)+1){
      if(isprime[i]){
        for(int j=i*i;j<N1;j+=i) isprime[j]=0;
        prime.pb(i);
      }
  }
  rep(i,sqrt(N1)+1,N1) if(isprime[i]) prime.pb(i);
}



struct dsu {
    vector<int> par, rank;
    dsu(int n): par(n+1), rank(n+1) {
        for (int i = 0; i <= n; i++) {
            par[i] = i;
            rank[i]= 1;
        }
    }
    int root(int a) {
        if (a == par[a]) return a;
        return par[a] = root(par[a]);
    }
    void merge(int a, int b) {
        a = root(a);
        b = root(b);
        if (a == b) return;
        if (rank[a] > rank[b]) swap(a, b);
        par[b] = a;
    }
    set<int> parent(int n){
        set<int> s;
        for(int i=1;i<=n;i++){
            s.insert(root(i));
        }
        return s;
    }
};

void solve(){
  string s;
  cin>>s;
  if((s[0]==s[1] && s[1]==s[2]) ||(s[1]==s[2] && s[2]==s[3])) cout<<"Yes";
  else cout<<"No";
}

int main(){
    optimizeIO();
    int r=1;
    {solve();}
}


Measured memory_bytes: 6988
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string s[200005];
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>s[i];
	sort(s,s+n);
	int k=0;
	string a="";
	for(int i=0;i<n;i++){
		if(s[i]==a);
		else {
			a=s[i];
			k++;
		}
	}
	cout<<k;
	
}

Measured memory_bytes: 9884
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;	
  string ans;
	cin >> n >> ans;
  	for(int i=0; i<ans.size(); i++){
		ans[i] = 'A' + ((int)(ans[i] - 'A') + n) %26;
    }
  	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
  int K, A, B;
  cin >> K >> A >> B;
  for(int i = A; i <= B; i++){
    if(i%K == 0 ){
      cout << "OK" <<endl;
      return 0;
    }
  }
      cout << "NG" <<endl;
  	return 0;
    
}


Measured memory_bytes: 3568
def func(x):
    c = 0
    n = x
    while True:
        if n < 100:
            break

        if n % 100 == 0:
            c += 1
            n = n // 100
        else:
            break
    return c


def main():
    d, n = map(int, input().split())

    i = 1
    count = 0
    if d == 0:
        while True:
            if i % 100 != 0:
                count += 1
            if count == n:
                break
            i += 1
    else:
        while True:
            if i % 100 == 0 and func(i) == d:
                count += 1
            if count == n:
                break
            i += 1
    print(i)


if __name__ == '__main__':
    main()


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

int main(){
  string s;
  cin>>s;
  
  int x=(s.at(0)=='+')+(s.at(1)=='+')+(s.at(2)=='+')+(s.at(3)=='+');
  
  cout<<2*x-4<<endl;
  
    
}
  













Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    char s1[11],s2[11],s3[11];
    scanf("%s%s%s",s1,s2,s3);
    printf("%c%c%c",s1[0]-'a'+'A',s2[0]-'a'+'A',s3[0]-'a'+'A');
    return 0;
}

Measured memory_bytes: 128
import math 
N, H  = map(int, input().split())
As = []
Bs = []
for i in range(N):
    a,b  = map(int, input().split())
    As.append(a)
    Bs.append(b)

cnt = 0
Bs = [0] + sorted(Bs)
b = Bs.pop()
a = max(As)
while H > 0 and b > a:
    # print(a,b)
    H -= b #投げつけるパターン
    cnt += 1
    b = Bs.pop()
cnt += max(0,int(math.ceil(H / a)))

print(cnt)

Measured memory_bytes: 12572
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <memory>
#include <functional>
using namespace std;
int main(){
	int a,b;
	while(cin>>a>>b){
		int ans=1;
		int cnt=a+b;
		while(cnt>=10){
			cnt/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <sstream>  // istringstream
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

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

    long long max;
    long long dis = K - (A+B); // AとBだけでは賄えない枚数

    if(K <= A){
        max = 1*K;
    }
    else if(K <= A+B){
        max = 1*A + 0*(K-A);
    }
    else{
        max = 1*A + 0*B - 1*(K-A-B);
    }

    cout << max << endl;
    return 0;
}

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        string W, str; _i64 ans = 0; cin >> W;
        while(cin >> str && str != "END_OF_TEXT") {
            _foreach(e, str) { if(isalpha(e)) { e = tolower(e); } }
            if(str == W) { ans++; }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3184
import java.util.*;
import java.awt.*;

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

    int n = sc.nextInt();
    long[] A = new long[n];
    long[] B = new long[n];

    for (int i = 0; i < n; i++) {
      A[i] = sc.nextLong();
    }

    for (int i = 0; i < n; i++) {
      B[i] = sc.nextLong();
    }

    long big_b = 0;
    long big_a = 0;

    for (int i = 0; i < n; i++) {
      if (A[i] > B[i]) {
        big_a += A[i] - B[i];
      } else {
        big_b += (B[i] - A[i]) / 2;
      }
    }

    if (big_a > big_b) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}


Measured memory_bytes: 43548
#define LOCAL
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char c) {return to_string((string) &c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll k; cin >> k;
    string s;cin >> s;
    string ans;
    if(k >= s.size()){
        ans = s;
    }
    else{
        ans = s.substr(0,k);
        ans += "...";
    }

    cout << ans << endl;
}

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

int main() {
    map<char, int> mp;
    string w;
    cin >> w;

    for(char c : w) {
        if(mp.count(c)) {
            mp.at(c)++;
        }
        else {
            mp[c] = 1;
        }
    }
    for(auto m : mp) {
        if(m.second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc150_a.cpp
 * time   : Sat May  2 18:53:38 2020
 * quest  : A - 500 Yen Coins
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int k, x;
  cin >> k >> x;
  cout << ((k * 500) >= x ? "Yes\n" : "No\n");
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from collections import deque
import math


def inputIntList():
  return [int(s) for s in input().split()]


def inputInt():
  return int(input())


def main():
  H, W = inputIntList()
  S = [[s for s in input()] for _ in range(H)]

  ans = 0
  for si in range(H):
    for sj in range(W):
      if S[si][sj] == '#':
        continue

      dist = [[-1 for _ in range(W)] for _ in range(H)]
      q = deque()

      start = (si, sj)
      if dist[si][sj] == -1:
        dist[si][sj] = 0
        q.append(start)

      while q:
        qi, qj = q.popleft()
        for di, dj in (-1, 0), (0, -1), (1, 0), (0, 1):
          ni = qi + di
          nj = qj + dj
          if ni < 0 or ni >= H:
            continue
          if nj < 0 or nj >= W:
            continue
          if S[ni][nj] == '#':
            continue
          if dist[ni][nj] == -1:
            dist[ni][nj] = dist[qi][qj]+1
            q.append((ni, nj))
            ans = max(ans, dist[ni][nj])
  return ans


if __name__ == "__main__":
  print(main())


Measured memory_bytes: 3316