akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import re

def embedded_numbers(str):
	re_digits = re.compile(r'(\d+)')
	pieces = re_digits.split(str)
	pieces[1] = map(int, pieces[1])
	return pieces[1]

def selectionSort(Arry):
	for i in range(len(Arry)):
		minj = i
		for j in range(i,len(Arry)):
			if embedded_numbers(Arry[j]) < embedded_numbers(Arry[minj]):
				minj = j
		Arry[i],Arry[minj] = Arry[minj], Arry[i]

	return Arry

def bubbleSort(Arry):
	for i in range(len(Arry)):
		for j in range(len(Arry) - 1, i, -1):
			if embedded_numbers(Arry[j-1]) > embedded_numbers(Arry[j]):
				Arry[j-1], Arry[j] = Arry[j], Arry[j - 1]
	
	return Arry

def judge_satble(origin, sortedCards):
	if sorted(origin, key=embedded_numbers) == sortedCards:
		print "Stable"
	else:
		print "Not stable"

def main():
	
	N = int(raw_input())
	Cards = raw_input().split()
	s_cards = list(Cards)
	b_cards = list(Cards)
	
	bubble_sortedCards = bubbleSort(b_cards)
	print " ".join(bubble_sortedCards)
	judge_satble(Cards, bubble_sortedCards)

	select_sortedCards = selectionSort(s_cards)
	print " ".join(select_sortedCards)
	judge_satble(Cards, select_sortedCards)


#def test():
	#if  1 > embedded_numbers("s8"):
		#print "ok"


	
if __name__ == '__main__':
	main()
	#test()

Measured memory_bytes: 6480
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int n; cin >> n;
    vector<int> v(n+1, 0);
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= i; ++j) {
            if (i % j == 0) ++v[i];
        }
    }

    int rtn = 0;
    for (int i = 1; i <= n; ++i)
        if (i % 2 != 0 && v[i] == 8) ++rtn;

    cout << rtn << endl;
}


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

vector<ll> dp(100005,0);
vector<ll> dp1(100005, 0);
vector<vector<int>> t;
ll mod;

ll dfs(int nd, int parent)
{
  ll black = 1;
  auto I = find(t[nd].begin(), t[nd].end(), parent);
  if (I != t[nd].end()) t[nd].erase(I);
  
  for(auto adj : t[nd])
  {
    ll ways = dfs(adj, nd);
    black = black*(ways + 1)%mod;
  }
  dp[nd] = black;
  return dp[nd];
}

void dfs1(int nd, int parent)
{

  if((int)t[nd].size())
  {
    int n= t[nd].size();
    vector<ll> L(n, 0) , R(n, 0);
    L[0] = 1;
    R[n-1] = 1;
    for(int i=1; i<n; i++)
      L[i] = L[i-1] * (dp[t[nd][i-1]]+1) %mod;
    for(int i=n-2; i>=0; i--) 
      R[i] = R[i+1] * (dp[t[nd][i+1]]+1) % mod;

    for(int i=0; i<n; i++)
    {
      int y = t[nd][i];
      dp1[y] = (dp1[nd] +1) * L[i]%mod*R[i]%mod;
      dfs1(y, nd);
    }
  }
}

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

   t = vector<vector<int>>(n);
   for(int i=0, x,y; i<n-1; i++)
   {
    cin >> x>>y;
    --x, --y;
    t[x].push_back(y);
    t[y].push_back(x);
   }

   dfs(0,-1);
   dfs1(0,-1);

   for(int i=0; i<n; i++)
   {
    cout<<dp[i]*(dp1[i]+1)%mod<<endl;
   }

  return 0;
}


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

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

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second

/*-------------------------------------------------*/

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

  if(s == "SSS")
    cout << 0 << endl;
  
  if(s == "SSR" ||
     s == "SRS" ||
     s == "RSS" ||
     s == "RSR")
    cout << 1 << endl;
  
  if(s == "SRR" ||
     s == "RRS")
    cout << 2 << endl;

  if(s == "RRR")
    cout << 3 << endl;

return 0;
}

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


int main(){
    char a[100],b[100],c[100];
    scanf("%s%s%s",a,b,c);
    int lb,la;
    lb=strlen(b);
    la=strlen(a);
    if(a[la-1]==b[0] && b[lb-1]==c[0])printf("YES\n");
    else printf("NO\n");
    return 0;

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
#include <unordered_map>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1e9+7;

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

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

  vector<ll> dp(n+1);
  dp[0]=1;
  for(int now=0;now<n;now++){
    for(int next=now+1;next<=min(n, now+2);next++){
      if(oks[next]){
        dp[next]+=dp[now];
        dp[next]%=mod;
      }
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	cout << (n >= 3200 ? s : "red");





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main(){int n,D1,D2;int res=0;cin >> n;rep(i,n){cin>>D1>>D2;if(D1==D2)res+=1;else res=0; if(res==3){cout<<"Yes"<<endl;return 0;}}cout<<"No"<<endl;return 0;}

Measured memory_bytes: 3564
N=int(input())
B=list(map(int,input().split()))
A=[1000000]*N
for i in range(N-1):
    if A[i]>B[i]:
        A[i]=B[i]
    if A[i+1]>B[i]:
        A[i+1]=B[i]
ans=0
for j in range(N):
    ans+=A[j]
print(ans)

Measured memory_bytes: 3064
//=template==================================================================//
// include
#include <vector>
#include <list>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

// namespace
using namespace std;

// define
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(i,n) FOR(i,0,n)
#define MIN_V(v) *min_element(v.begin(), v.end())
#define MAX_V(v) *max_element(v.begin(), v.end())

// typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef long long LL;

// conversion
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
inline int count(string s, char c) {int cnt,i; cnt=0; REP (i,s.size()) {if (s[i]==c) cnt++;} return cnt;}
template<class T> inline string toString(T x) {ostringstream sout; sout<<x; return sout.str();}
//===========================================================================//

//=function prototype========================================================//

//===========================================================================//

//=variables=================================================================//

//===========================================================================//
int main(void)
{
  // Scan begin.
  int n, i;
  string s;
  VI costs;

  cin >> n >> s;
  // Scan done.

  // Code begin.
  costs.push_back(count(s.substr(1,s.size()-1), 'E'));
  FOR (i, 1, n) {
    char before = s[i-1];
    char me = s[i];

    int change = 0;
    if (before == 'W') change++;
    if (me     == 'E') change--;

    int lastCost = costs.at(costs.size()-1);
    costs.push_back(lastCost + change);
  }

  cout << MIN_V(costs) << endl;
  // Code done.

  return 0;
}

//=functions=================================================================//

//===========================================================================//

Measured memory_bytes: 2776
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
#include<deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define erep(i, n) for (int i = 0; i <= (int)(n); i++)

int main() {
    int n; cin >> n;
    vector<int> a(n), b(n);
    rep (i, n) cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());

    int small, large;
    if (n % 2 == 1) {
        small = a[(n - 1) / 2];
        large = b[(n - 1) / 2];
    } else {
        small = a[n / 2] + a[(n / 2) - 1];
        large = b[n / 2] + b[(n / 2) - 1]; 
    }
    cout << large - small + 1 << endl;
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> h(n), dp(n);
  
  for (int i=0; i<n; i++)
    cin >> h.at(i);
  
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(1) - h.at(0));
  
  for (int i=1; i<=n-2; i++)
    dp.at(i+1) = min(dp.at(i-1) + abs(h.at(i+1) - h.at(i-1)), dp.at(i) + abs(h.at(i+1) - h.at(i)));
  
  cout << dp.at(n-1) << endl;
}
     

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007

int main(){
    int h,n;
    cin>>h>>n;
    vector<int> a(n);
    rep(i,n){
        cin>>a[i];
    }
    int sum=0;
    rep(i,n){
        sum += a[i];
    }
    if(sum>=h){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 640
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int p = sc.nextInt();
		String str = sc.next();
		sc.close();
		
		
		long ans = 0;
		if(p == 2 || p == 5) {
			for(int i = str.length() - 1; i >= 0; i--) {
				int charVal = str.charAt(i) - '0';
				if(charVal % p == 0) {
					ans += n - (n - 1 - i);
				}
			}
		}else {
			
			long cumlation = 0;
			long tenmod = 1;
			HashMap<Long, Long> cumMap = new HashMap<>();
			
			long thisDigitMod = (str.charAt(str.length() - 1) - '0') % p;
			cumlation += thisDigitMod;
			cumMap.compute(thisDigitMod, (k,v) -> (v== null)? 1 : v + 1);
			
			for(int i = 1; i < n; i++) {
				long thisDigitNum = str.charAt(str.length() - 1 - i) - '0';
				tenmod = (tenmod * 10) % p;
				cumlation = (cumlation + thisDigitNum * tenmod) % p;
				cumMap.compute(cumlation, (k,v) -> (v== null)? 1 : v + 1);
			}
			
			for (Map.Entry<Long, Long> mapEntry : cumMap.entrySet()) {
				long value = mapEntry.getValue();
				if(mapEntry.getKey() == 0) {
					ans += value;
				}
				ans += value*(value - 1) / 2;
			}
		}	
		
		System.out.println(ans);
	}
}


Measured memory_bytes: 33532
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

using namespace std;

typedef long long ll;

typedef pair<int,int> P1;
typedef pair<int,P1> P2;
const ll inf=100000000000000;
struct edge{
	int to,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 100002
int dp[MAX_N]={};
bool d[MAX_N]={};
int pa[MAX_N];
vector<edge> G[MAX_N];
P1 cost[MAX_N]={};
vector<int> child[MAX_N];
vector<int> ra[MAX_N];
priority_queue<P2,vector<P2>,greater<P2>> que;
ll t[100001]={};
ll k[100001]={};
int main() {
	int n;
	ll c,k;
	cin>>n>>c>>k;
	rep(i,n)cin>>t[i];
	sort(t,t+n);
	int r=0;
	ll e=0;
	ll cn=0;
	rep(i,n){
		if(t[i]>e||cn==0){
			r++;
			e=t[i]+k;
			cn=c-1;
		}else{
			cn--;
		}
	}
	cout<<r<<endl;
	return 0;

}





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

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0;i < N;i++){
    cin >> h.at(i);
  }
  int sa_min = 10000000000;
  sort(h.begin(),h.end());
  reverse(h.begin(),h.end());
  for(int i = 0;i < N - K + 1;i++){
    sa_min = min(sa_min,h.at(i) - h.at(i + K - 1));
  }
  cout << sa_min;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,A,B;
  cin >> N >> A >> B;
  string s;
  cin>>s;
  int a=0;
  int b=1;
  for(int i=0;i<N;i++){
    if(s[i]=='a'){
      if(a<A+B){
        cout << "Yes" << endl;
        a++;
      }
      else{
        cout << "No" << endl;
      }
    }
    else if(s[i]=='b'){
      if(a<A+B && B>=b){
        cout << "Yes" << endl;
        a++;
        b++;
      }
      else{
        cout << "No" << endl;
      }
    }
    else{
      cout << "No" << endl;
    }
  }
}


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

using namespace std;

string s;

int main()
{
    cin >> s;
    for (int i = 0; i + 2 < s.size(); i++)
    {
        if (s[i] == s[i + 2])
        {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }
    for (int i = 0; i < s.size(); i++)
    {
        if (i + 1 == s.size())
        {
            cout << -1 << " " << -1 << endl;
            return 0;
        }
        if (s[i] == s[i + 1])
        {
            cout << i + 1 << " " << i + 2;
            return 0;
        }
    }
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
	int cnt,n,m,dat[110000];
	while(1){
	cin>>n>>m;
	if(n==0 && m==0){
		break;
	}
	for(int i=0;i<n;i++){
		cin>>dat[i];
	}
	int ans=0;
	int cnt=0;
	for(int i=0;i<m;i++){
		ans+=dat[i];
	}
	cnt=ans;
	for(int i=m;i<n;i++){
		cnt+=dat[i]-dat[i-m];
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1556
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 2001
#define INF   1000000000
#define p     1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
vector<P> v;

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

ll prime_factorize(ll n) {

  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll ex = 0;
    while (n % i == 0) { ++ex; n /= i; }
    v.push_back( P(i, ex) );
  }
  if (n != 1) v.push_back( P(n, 1) );

  return 0;
}


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

    ll A, B;
    cin >> A >> B;

    ll gcd_AB = gcd(A, B);
    prime_factorize(gcd_AB);
    cout << v.size() + 1 << endl;
    
    return 0;
}
    




Measured memory_bytes: 888
n = int(input())
c = []
s = []
f = []
for i in range(n-1):
    x,y,z =map(int,input().split())
    c.append(x)
    s.append(y)
    f.append(z)
for i in range(n):
    t = 0
    for j in range(i,n-1):
        if t <s[j]:
            t = s[j]
        elif t%f[j] == 0:
            pass
        else:
            t += f[j] - t%f[j]
        t += c[j]
    print(t)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long act = 0;
		long bct = 0;
		long ans = 0;
      	int i = 0;
		while(i<str.Length){
			if(str.Substring(i,1)=="A"){
				act++;
			} else if(str.Substring(i,1)=="B"){
				if(i<str.Length-1 && str.Substring(i+1,1)=="C"){
					ans += act;
					i += 1;
				} else {
					act = 0;
				}
			} else if(str.Substring(i,1)=="C"){
				act = 0;
			}
          i++;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17332
N, M, Q = map(int, input().split())
LR = []
for _ in range(M):
    l, r = map(int, input().split())
    LR.append((l, r))
pq = []
for _ in range(Q):
    p, q = map(int, input().split())
    pq.append((p, q))

table = [[0] * (N + 1) for _ in range(N + 1)]
for l, r in LR:
    table[l][r] += 1
for i in range(1, N + 1):
    for j in range(1, N + 1):
        table[i][j] += table[i - 1][j]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        table[i][j] += table[i][j - 1]

for p, q in pq:
    print(table[q][q] - table[p - 1][q] -
          table[q][p - 1] + table[p - 1][p - 1])


Measured memory_bytes: 44328
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n;cin>>n;
  vl d(n);
  rep(i,n)cin>>d[i];
  set<ll>S;
  rep(i,n)S.insert(d[i]);
  cout<<S.size()<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s[0]=='a' && s[1] =='b' && s[2] == 'c'){
    cout<<"Yes"<<'\n';
  }
  else if(s[0] == 'a' && s[1] == 'c' && s[2] == 'b'){
    cout<<"Yes"<<'\n';
  }
  else if(s[0] == 'b' && s[1] == 'a' && s[2] == 'c'){
    cout<<"Yes"<<'\n';
  }
  else if(s[0] == 'b' && s[1] == 'c' && s[2] == 'a'){
    cout<<"Yes"<<'\n';
  }
  else if(s[0] == 'c' && s[1] == 'a' && s[2] == 'b'){
    cout<<"Yes"<<'\n';
  }
  else if(s[0] == 'c' && s[1] == 'b' && s[2] == 'a'){
    cout<<"Yes"<<'\n';
  }
  else {
    cout<<"No"<<'\n';
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1000000000000000000
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define f first
#define s second
#define pb push_back
#define mp make_pair

ll n, a[202020], x, ans=0;


int main(){
cin >> n >> x;
for(int i =1; i<=n ;i++){
    cin >> a[i];
}
for(int i =1;i<=n-1; i++ )
{
    if(a[i]+a[i+1]<=x)continue;
    if(a[i]<x)ans+=a[i+1]+a[i]-x,a[i+1]=x-a[i];
    else ans+=a[i+1]+a[i]-x, a[i+1]=0, a[i]=x;

}
cout << ans << endl;


return 0;}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

void solve()
{
	int N, K;
	cin >> N >> K;
	int size = N / 2;
	for(int i = 0; i < K; ++i)
	{
		int x, y;
		cin >> x >> y;
		if(x > size)
		{
			x = N - x;
			++x;
		}
		if(y > size)
		{
			y = N - y;
			++y;
		}
		if(x > y)
		{
			y %= 3;
			if(y == 0)
			{
				cout << 3 << endl;
			}
			else if(y == 1)
			{
				cout << 1 << endl;
			}
			else if(y == 2)
			{
				cout << 2 << endl;
			}
		}
		else if(x <= y)
		{
			x %= 3;
			if(x == 0)
			{
				cout << 3 << endl;
			}
			else if(x == 1)
			{
				cout << 1 << endl;
			}
			else if(x == 2)
			{
				cout << 2 << endl;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
N = list(input())

if N[len(N) - 1] == "2" or N[len(N) - 1] == "4" or N[len(N) - 1] == "5" or N[len(N) - 1] == "7" or N[len(N) - 1] == "9":
    print("hon")
elif N[len(N) - 1] == "0" or N[len(N) - 1] == "1" or N[len(N) - 1] == "6" or N[len(N) - 1] == "8":
    print("pon")
elif N[len(N) - 1] == "3":
    print("bon")

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

int main() {
  int n,count=0;
  cin >> n;
  vector<int> d(n+1);
  for(int i=0;i<n;i++){
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  for(int i=0;i<n;i++){
    if(d.at(i)!=d.at(i+1)){
      count++;
    }
  }
  cout << count << endl;
}


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

int main (void)
{
  string s;
  cin >> s;
  string c = s;
  reverse(c.begin(), c.end());
  int cnt = 0;
  for(int i = 0; i < s.size(); i++)
  {
    if(s[i] != c[i])
      cnt++;
  }
  cout << cnt / 2<< endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
H, W = MAP()
S = [input() for _ in range(H)]

w = [[-1]*W for _ in range(H)]
h = [[-1]*W for _ in range(H)]

for i in range(H):
	cnt = 0
	for j in range(W):
		if S[i][j] == ".":
			cnt += 1
			w[i][j] = cnt
		else:
			cnt = 0
	for j in range(W-2, -1, -1):
		if S[i][j] == ".":
			w[i][j] = max(w[i][j], w[i][j+1])


for i in range(W):
	cnt = 0
	for j in range(H):
		if S[j][i] == ".":
			cnt += 1
			h[j][i] = cnt
		else:
			cnt = 0

	for j in range(H-2, -1, -1):
		if S[j][i] == ".":
			h[j][i] = max(h[j][i], h[j+1][i])


ans = 0
for i in range(H):
	for j in range(W):
		if h[i][j] != -1 and w[i][j] != -1:
			ans = max(ans, h[i][j]+w[i][j]-1)
print(ans)



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

const long long MOD = 1000000007;

int main(){
  int x,a;
  cin >> x>>a;
  if(x<a)cout<<0<<endl;
  else cout<<10<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	list := make([]int, 5)
	for i := 0; i < 5; i++ {
		fmt.Scan(&list[i])
	}

	min := 10
	minI := 0
	result := 0
	for i := 0; i < 5; i++ {
		if list[i]%10 < min && list[i]%10 != 0 {
			min = list[i] % 10
			minI = i
		}
	}
	for i := 0; i < 5; i++ {
		if i != minI {
			if list[i]%10 != 0 {
				result += list[i] + (10 - list[i]%10)
			} else {
				result += list[i]
			}
		}
	}
	result += list[minI]

	fmt.Println(result)
}


Measured memory_bytes: 512
#include <stdio.h>

int main(void){
    int i,j;
    char a[21],b[21];
    scanf("%s",a);
    while(a[i]!=0)
        i++;
    i--;
    for(j=0;j<=i;j++){
        b[j]=a[i-j];
    }
    b[j]=0;
    j=0;
    while(b[j]!=0){
        printf("%c",b[j]);
        j++;
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include<string>
using namespace std;

int main()
{
    string s;
    cin>>s;
    int i=0;
    int count=0;
    int lower=0;
while(i<s.length())
{
    if(islower(s[i]))
      {
         lower++;
      }
    i++;
}

for(int i=2;i<s.length()-1;i++)
{   if(s[i]=='C')
      count++;

}

int x=s.length()-1;


     if(count==1 &&s[0]=='A' &&lower==s.length()-2)
        cout<<"AC";
    else
        cout<<"WA";

      return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MAX 1000000001

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    ll a,b,c,d;
	    cin >> a >> b >> c >> d;
	    cout << max(max(a*c,b*d),max(a*d,b*c)) << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
#define vi vector<int>
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}
const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};
const int nax=1e5+10;

void solve(){
    int n,k;cin>>n>>k;
    vector<int> v(n);fr(i,0,n-1)cin>>v[i];
    vector<bool> dp(k+1);
    fr(i,0,k){
        fr(j,0,n-1){
            if(i>=v[j] && !dp[i-v[j]])dp[i]=true;
        }
    }
    puts(dp[k]==true?"First":"Second");
    return;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,D;
  cin>>N>>D;
  
  int max=D*2+1;
  
  if(N%max!=0){
cout<<N/max+1<<endl;
  }
  
  else{
    cout<<N/max<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,m,ns=1,ans=0;
  cin >> n >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    ns = max(ns,a);
    n = min(n,b);
  }
  ans = n-ns+1;
  if(ans<0)ans=0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define eraser(v,i) (v).erase(v.begin()+(i))
#define pbpair(a,b) push_back(make_pair(a,b))
#define Little 1
const long long INF = 1LL<<60;
#define pairint pair<int,int>
signed main(){
  int x=0,y=0,z=0,w=0,n=0,m=0,o=0;
  std::cin >> x>>y;
  std::vector<int> v(x);
  rep(i,x){
    std::cin >> v[i];
  }
  sort(all(v));
  rep(i,y){
    z+=v[i];
  }
  std::cout << z << '\n';
}


Measured memory_bytes: 3604
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    int n;cin >> n;
    int t,a;cin >> t >> a;
    vector<int> h(n);
    rep(i,n){
        cin >> h[i];
    }
    double temp;
    double min=1000000;
    int min_index=0;
    int i=0;
    for(int x:h){
        temp=t-x*0.006;
        if(fabs(a-temp)<min){
            min=fabs(a-temp);
            min_index=i;
        }
        i++;
    }
    out(min_index+1);
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int calc(int x, int y){ return 2 * x * y + x + y; }
int main(){
    int n;
    cin >> n;
    int ans = n;
    for(int i = 0; i < n; i++){
        int k;
        cin >> k;
        for(int x = 1, mod = 3; calc(x, x) <= k; x++, mod += 2){
            if(k % mod == x){
                ans--;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#include<stdio.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)+1
#define MOD 1000000007
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pwi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<pair<ll,ll > > > wGraph;
typedef vector<vector<ll> > graph;
//typedef vector<vector<ll> > matrix;

int main(){
 
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(2);

    
    int k,n;
    cin>>n>>k;
    vi v(n);
    for(int i = 0; i<n;++i){
        cin>>v[i];
    }

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

    int sum = 0;
    for(int i = 0;i<n && k-->0;++i) sum+=v[i];
    cout<<sum<<endl;

    return 0;   
}


Measured memory_bytes: 3660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define pb push_back
#define pf push_fron
#define INF 1e9
#define PI acos(-1)
typedef long long ll;

string str;

int main() {
	cin >> str;
	int n = str.size();
	int ans = ((n % 2 == 0) ? n / 2 : n/2+1);
	int left = n / 2, right = ((n % 2 == 0) ? left + 1 : left + 2);
	left--; right--;

	while (left >= 0 && right < n) {
		if (str[left] == str[left + 1] && str[right] == str[right - 1]) {
			ans++;
			left--; right++;
		}
		else break;
	}

	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, m; cin >> n >> m;
  VV<> s(m, V<>(n));
  for (int i = 0; i < m; ++i) {
    int k; cin >> k;
    while (k--) {
      int x; cin >> x, --x;
      s[i][x] = 1;
    }
  }
  V<> p(m); for (auto&& e : p) cin >> e;
  int res = 0;
  for (int bit = 0; bit < 1 << n; ++bit) {
    bool ok = true;
    for (int i = 0; i < m; ++i) {
      int c = 0;
      for (int j = 0; j < n; ++j) if (bit >> j & 1) {
        c += s[i][j];
      }
      if ((c & 1) != (p[i] & 1)){
        ok = false;
        break;
      }
    }
    res += ok;
  }
  cout << res << '\n';
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
c=set()
for i in range(a,a+k):
    if i <a or i>b:
        continue
    c.add(i)
for j in range(b-k+1,b+1):
    if j <a or j>b:
        continue
    c.add(j)
c=sorted(list(c))
print("\n".join(map(str,c)))

Measured memory_bytes: 3060
function Main(input) {
  var nums = input.split('\n');
  var strings = nums[1].split(' ');
  
  var ans = [];
  
  for (var i = 0; i < nums[0]; i++) {
    ans.push(strings[0][i]);
    ans.push(strings[1][i]);
  }
  
  console.log(ans.join(''));
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main(){
  int n,k;
  int h[100005];
  int dp[100005];

  cin>>n>>k;
  for(int i=1;i<=n;i++){
    cin>>h[i];
  }
  
  memset(dp,0,sizeof(dp));

  for(int i=2;i<=n;i++){
    int mini=1<<30;
    for(int j=1;j<=min(i-1,k);j++){
      mini=min(mini,dp[i-j]+abs(h[i]-h[i-j]));
    }
    dp[i]=mini;
  }
    
  cout<<dp[n]<<"\n";

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
typedef long long ll;
const int INF = 1e+9+7;

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int L,R;
    L=0;
    R=0;
    rep(i,N){
        if(S[i]=='E'){
            R++;
        }else{
            L++;
        }
    }

    int l_i,r_i;
    l_i=0;
    r_i=0;
    int tmp_l,tmp_r;
    tmp_l=0;
    tmp_r=0;
    int ans=INF;
    rep(i,N){
        tmp_l=l_i;
        tmp_r=r_i;
        if(S[i]=='E'){
            r_i++;
        }else{
            l_i++;
        }
        ans = min(ans,tmp_l+R-r_i);
    }
    cout << ans << endl;

}


Measured memory_bytes: 900
n, k = map(int,input().split())
ps = [tuple(map(int,input().split())) for i in range(n)]

sx = sorted(ps,key = lambda x: x[0]) # x座標でソート
nx = list(enumerate(sx)) # 頂点番号を付加
ans = 5e18

for f, (x1,y1) in nx[:n-k+1]: # 左辺の頂点
    for e, (x2,y2) in nx[f+k-1:]: # 右辺の頂点
        dx = x2 - x1 # 横
        sy = sorted(y for x,y in sx[f:e+1]) # 含まれる頂点をy座標でソート
        for y3,y4 in zip(sy,sy[k-1:]): # y3=下辺の頂点，y4=上辺の頂点
            if y3 <= y1 and y4 >= y2: # 左右辺の頂点を含むこと
                ans = min(ans, dx * (y4 - y3))

print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{
    static boolean is7(int[] ABCD, String op){
        int cul;
        cul = ABCD[0];
        for(int i=0; i<op.length(); i++) {
            if (op.charAt(i) == '+'){
                cul += ABCD[i+1]; }
                else{
                cul -= ABCD[i+1];
            }
        }
            if(cul == 7) return true;

        return false;
    }

    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine().trim();
        int[] ABCD = new int[str.length()];
        for(int i=0; i<str.length(); i++){
            ABCD[i] = Integer.parseInt(""+str.charAt(i));
        }
        String[] ops = {"---", "--+","-+-", "-++",
                "+--", "+-+","++-", "+++",};
        for(int i=0; i<8; i++){
            if(is7(ABCD, ops[i])){
                System.out.println(ABCD[0] +""+ ops[i].charAt(0) + ABCD[1] + ops[i].charAt(1)
                        + ABCD[2] + ops[i].charAt(2) + ABCD[3] + "=7");
                break;
            }
        }

    }
}

Measured memory_bytes: 23252
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int digit(long long n)
{
  int digit=1;
  while((n/=10) != 0) digit++;

  return digit;
}


int main()
{
  long long N;
  cin >> N;
  int min=11;
  int dig;
  long long B;

  for(long long i=1;i<=sqrt(N);i++)
  {
    if((N%i)==0)
      {
        B=N/i;

        dig=digit(max(i,B));
      
        if(dig<min) min=dig;
      }

  }
  cout << min;

}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))
dp = [float('Inf')] * n
dp[0] = 0
for i in range(n - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]))
    if i + 2 < n:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]))
print(dp[n - 1])

Measured memory_bytes: 13800
n, r, t = map(int, input().split())
speed = [int(input()) for _ in range(n)]
point = [0] * n
bottle = [0] * r
for i in range(n):
  point[i] = (point[i] + speed[i]) % r
  bottle[point[i]] += 1
for _ in range(t - 1):
  nums = [0] * r
  for i in range(n):
    bottle[point[i]] -= 1
    point[i] = (point[i] + speed[i]) % r
    nums[point[i]] += 1
  for i in range(r):
    if bottle[i] < nums[i]:
      bottle[i] = nums[i]
    bottle[i] += nums[i]
print(sum(bottle))


Measured memory_bytes: 5624
n,y = map(int,input().split())
total = 0
for i in range(n+1):
	for j in range(n+1-i):
		k = n - i - j
		total = i*10000 + j*5000 + k*1000
		if total == y:
			print(i,j,k)
			break
		total = 0
	else:
		continue
	break
else:
	print("-1 -1 -1")

Measured memory_bytes: 3060
import math


def gcdf(a, b):
    if a > b:
        a, b = b, a
    if b%a==0:
        return a
    return gcdf(a, b % a)


def f(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append(i)

    if temp != 1:
        arr.append(temp)

    if arr == []:
        arr.append(n)

    return arr


def main():
    # return
    # N = int(input())
    # N,= [int(a) for a in input().split()]
    A, B = [int(a) for a in input().split()]

    gcd = gcdf(A, B)

    if gcd == 1:
        print(1)
    else:
        print(len(f(gcd)) + 1)


if __name__ == "__main__":
    main()


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

int main(){
    long n,m,ans; cin>>n>>m;
    if(n==1 and m==1) ans=1;
    else if (n==1 or m==1) ans=max(n,m)-2;
    else ans=(n-2)*(m-2);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
    ll L,R;
    cin >>L>>R;
    ll max=pow(10,9)*2;
    if((R-L)>2018){
        cout <<0<<endl;
        return 0;
    }else{
        for(int i=L;i<R;i++){
            for(int j=i+1;j<=R;j++){
                ll tmp=((i%2019) * (j%2019))%2019;
                if(max>tmp){
                    max=tmp;
                }
            }
        }
    }
    
    

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




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 1e5+5, maxn1=202;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll modneg(ll a,ll m)
{
    a = a % m;
    if(a<0)
        a=a+m;
    return a;
}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };
ll csb(ll n){ ll count = 0;while (n){ count += n & 1; n >>= 1; } return count;}

int main()
{

ll t,i,j,k,n,m,a,b,x,y,u,temp;
cin>>t>>a>>b;
rep(i,a,b+1)
    if(i%t==0)
    {
        cout<<"OK\n";
        exit(0);
    }
{
    cout<<"NG\n";
}
return 0;
}

Measured memory_bytes: 3612
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	const int M = 256;
	int N;
	while(cin >> N, N) {
		vi I(N+1);
		FOR(i, 1, N) {
			cin >> I[i];
		}

		vi R(N+1), O(N+1);
		double minH = INF;
		int aS, aA, aC;
		REP(S, 16) {
			REP(A, 16) {
				REP(C, 16) {
					R[0] = S;
					vi num(256);
					FOR(i, 1, N) {
						R[i] = (A*R[i-1] + C) % M;
						O[i] = (I[i]+R[i]) % M;
						num[O[i]]++;
					}
					double H = 0.0;
					REP(i, 256) {
						if(num[i]>0) {
							H -= (double)num[i]/N*log(num[i]*1.0/N);
						}
					}
					if(H+EPS < minH) {
						minH = H;
						aS = S, aA = A, aC = C;
					}
				}
			}
		}
		cout << aS << " " << aA << " " << aC << endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>

using namespace std;

int main(){

	int N;

	cin >> N;

	string val = to_string(N);

	if(val[0] == val[2]){
		cout << "Yes";
	}else{
		cout  << "No";
	}


	return 0;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int prev = 0;
		int min = sc.nextInt();
		int max = min;
		ArrayList<Integer> list = new ArrayList<>();
		for (int i = 1; i < n; i++) {
			int x = sc.nextInt();
			if (max < x) {
				max = x;
			}
			if (min > x) {
				list.add(max - min);
				min = x;
				max = x;
			}
		}
		list.add(max - min);
		Collections.sort(list);
		Collections.reverse(list);
		int first = list.get(0);
		if (first == 0) {
			System.out.println(0);
			return;
		}
		int cnt = 1;
		for (int i = 1; i < list.size(); i++) {
			if(first == list.get(i)) {
				cnt++;
			} else {
				break;
			}
		}
		System.out.println(cnt);
	}
}


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

using namespace std;

typedef long long ll;

const int nax = 3000;

ll deck[nax];
ll dp[nax][nax];
int indegree[nax][nax];
int n;


void dfs(int a, int b){
  if((n-b+a)%2){
    if(a>0){
      dp[a-1][b] = min(dp[a][b]-deck[a-1],dp[a-1][b]);
      indegree[a-1][b]--;
    }
    if(b<n-1){
      dp[a][b+1] = min(dp[a][b]-deck[b+1],dp[a][b+1]);
      indegree[a][b+1]--;
    }
  }
  else{
    if(a>0){
      dp[a-1][b] = max(dp[a][b]+deck[a-1],dp[a-1][b]);
      indegree[a-1][b]--;
    }
    if(b<n-1){
      dp[a][b+1] = max(dp[a][b]+deck[b+1],dp[a][b+1]);
      indegree[a][b+1]--;
    }
  }
  if(a>0&&indegree[a-1][b]==0){
    dfs(a-1,b);
  }
  if(b<n-1&&indegree[a][b+1]==0){
    dfs(a,b+1);
  }
}

int main(){
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> deck[i];
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      indegree[i][j]=2;
    }
  }
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(i==j)
        dp[i][j]=(n%2==1?1:-1)*deck[i];
      else if((n-1-j+i)%2)
        dp[i][j]=1e14;
      else
        dp[i][j]=-1e14;
    }
  }

  for(int i = 0; i < n; i++){
    dfs(i,i);
  }

  cout << dp[0][n-1] << endl;
  return 0;
}


Measured memory_bytes: 105984
n = int(input())
nlist = [input() for i in range(n)]
if len(nlist) != len(set(nlist)):
    print('No')
    exit()
for i, j in enumerate(nlist):
    if i + 1 < len(nlist):
        if nlist[i][-1] != nlist[i + 1][0]:
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
print(" ".join(map(str, a)))
for i in range(1, n):
    v = a[i]
    j = i - 1
    while j >= 0 and a[j] > v:
        a[j + 1] = a[j]
        j -= 1
    a[j + 1] = v
    print(" ".join(map(str, a)))
    


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct point{
	int a;
	int b;
}p[30];
bool cmp(const point &q,const point &w){
	return q.b<w.b;
}
int main()
{
	int n,i,sum;
	while(cin>>n&&n){
		for(i=0;i<n;i++)
			scanf("%d%d",&p[i].a,&p[i].b);
		sort(p,p+n,cmp);
		sum=0;int t=1;
		for(i=0;i<n;i++){
			sum+=p[i].a;
			if(sum>p[i].b) {t=0; break;}
		}
		if(t){ printf("Yes\n");}
		else  printf("No\n");
	}

}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#define pi 3.14159265358979323846264338327950

int main() {
	int s; std::cin >> s;
	std::vector<int> Check;
	bool flag = false;
	int count = 0;
	while (flag == false) {
		Check.push_back(s);
		++count;
		if (s % 2 == 0)
			s = s / 2;
		else
			s = s * 3 + 1;
		for (int i = 0; i < Check.size(); ++i)
			if (s == Check[i]) {
				flag = true;
				break;
			}
	}
	std::cout << count + 1 << std::endl;

	return 0;
}

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

int main(){
    int a, b, c, x, ans = 0;
    cin >> a >> b >> c >> x;

    for(int i=0; i<=a; i++)
        for(int j=0; j<=b; j++)
            for(int k=0; k<=c; k++)
                if(x==(500*i + 100*j + 50*k))
                    ans++;

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 2010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const ll mod = 1e9 + 7;

int main (){
    ios_base::sync_with_stdio(false);
    
    int w, h, xmax = 0, xmin = 0 , ymax = 0, ymin = 0, x =0 , y =0, a, n;
    cin >> w >> h >> n;

    for (int i=0; i<n; i++){
        cin >> x >> y >> a;
        if (a == 1){
            xmin = max(x, xmin);
        }
        else if (a == 2){
            xmax = max(w -x, xmax);
        }
        else if (a == 3){
            ymin = max(y, ymin);
        }
        else {
            ymax = max(h - y, ymax);
        }
    }

    if (xmax + xmin >= w || ymin + ymax >= h){
        cout << "0" << endl;
    }
    else {
        cout << ((w - xmax - xmin) * (h - ymin - ymax)) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
	    int Ball = sc.nextInt();
	    int Penki = sc.nextInt();
	    int answer = Penki;

	    for (int i = 0; i < Ball - 1; i++) {
	    	answer = answer * (Penki - 1);
	    }
	    System.out.println(answer);

	}

}

Measured memory_bytes: 21844
N,C = map(int,input().split())
STC = [[] for _ in range(C)]
for i in range(N):
    s,t,c = map(int,input().split())
    STC[c-1].append((s,t))

lenA = 200001
A = [[0]*lenA for _ in range(C)]
for i in range(C):
    for (s,t) in STC[i]:
        A[i][s*2-1:t*2] = [1]*(t*2-s*2+1)

Ans = [0]*lenA
for i in range(C):
    for j in range(lenA):
        if A[i][j] > 0:
            Ans[j] += 1

print(max(Ans))


Measured memory_bytes: 65324