akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string weather[] = {"Sunny", "Cloudy", "Rainy"};
    
    string inp ;
    cin >> inp;
    rep(i, 3){
        if(inp == weather[i]){
            i ++;
            i %= 3;
            cout << weather[i] << endl;
            return 0;
        }
    }


    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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

using namespace std;

template<class T>
string Translate(T input) {
  static const char kLookUp[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  string res = "";
  while (input > 0) {
    T idx = (input - 1) % 26;
    res = kLookUp[idx] + res;
    input = (input - 1) / 26;
  }
  return res;
}

int main() {
   long long int n;
   cin>>n;
   
   cout<<Translate(n)<<endl;
   
 
}

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

int main()
{
	string weather;
	cin>>weather;
	vector <char> w(3);
	for(int i=0;i<3;i++)
	{
		w[i] = weather[i];
	}
	int days=0;
	for(int i=0;i<3;i++)
	{
	    if(w[i]=='R')
	    {
	        days++;
	        break;
	    }
	}
	for(int i=1;i<3;i++)
	{
		if(w[i]=='R' && w[i-1]=='R')
			days++;
	}
	cout<<days;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int N=200005;
#define ll long long
char a[N];ll cnt[N],ans=0;
int main (){
	scanf ("%s",a+1);
	int n=strlen(a+1);
	for (int i=1;i<=n;i++)
		if (a[i]=='A') cnt[i]=1;
		else cnt[i]=0;
	for (int i=1;i<n;i++)
		if (a[i]=='B'&&a[i+1]=='C')
			ans+=cnt[i-1],cnt[i+1]+=cnt[i-1];
		else if (a[i]=='A') cnt[i]+=cnt[i-1];
	printf ("%lld",ans);
	return 0;
} 


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string(string(s)); }
string to_string(bool b) { return to_string(int(b)); }
string to_string(char b) { return "'" + string(1, b) + "'"; }
template <typename A, typename B>
string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A>
string to_string(A v) {
	string res = "{";
	for (const auto& x : v) res += (res == "{" ? "" : ", ") + to_string(x);
	return res + "}";
}
void debug() { cerr << endl; }
template <typename Head, typename... Tail>
void debug(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug(T...);
}
#define db(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define db(...) 42
#endif
typedef long long ll;
typedef long double ld;
int main() {
	int k;
	scanf("%d", &k);
	for (int i = 0; i < k; ++i) printf("ACL");
}


Measured memory_bytes: 3728
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
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();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int N,M;
multiset<int> E[101010];
vector<pair<int,int>> V;

int dfs(int cur,int pre){
  int lef=-1;
  while(E[cur].size()){
    int x=*E[cur].begin();
    E[cur].erase(x);
	E[x].erase(cur);
	int y=dfs(x,cur);
	if(y!=-1){
      if(lef==-1) lef=y;
      else{
        V.push_back({cur,lef});
        V.push_back({cur,y});
        lef=-1;
      }
    }
  }
  if(lef!=-1){
    if(pre!=-1){
      V.push_back({cur,pre});
      V.push_back({cur,lef});
      return -1;
    }
  }
  return cur;
}

int main(){
  int x,y;
  cin>>N>>M;
  REP(i,M){
    cin>>x>>y;
    E[x].insert(y);
    E[y].insert(x);
  }
  if(M%2){
    co(-1);
    return 0;
  }
  dfs(1,-1);
  FORE(v,V) cout<<v.first<<" "<<v.second<<endl;
  return 0;
}

Measured memory_bytes: 22144
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s; cin >> s;
	for (auto& x : s) {
		x = 'x';
	}
	cout << s << endl;

	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<min(b,c);
    cout<<" ";
    if(b+c<a){
        cout<<0<<endl;
    }
    else{
        cout<<b+c-a<<endl;
    }
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n)) #親ノード
        self.size = [1]*n #グループの要素数
 
    def root(self, x): #root(x): xの根ノードを返す．
        while self.parent[x] != x:
            self.parent[x] = self.parent[self.parent[x]]
            x = self.parent[x]
        return x 
 
    def merge(self, x, y): #merge(x,y): xのいる組とyのいる組をまとめる
        x, y = self.root(x), self.root(y)
        if x == y: return False
        if self.size[x] < self.size[y]: x,y=y,x #xの要素数が大きいように
        self.size[x] += self.size[y] #xの要素数を更新
        self.parent[y] = x #yをxにつなぐ
        return True
 
    def issame(self, x, y): #same(x,y): xとyが同じ組ならTrue
        return self.root(x) == self.root(y)
        
    def getsize(self,x): #size(x): xのいるグループの要素数を返す
        return self.size[self.root(x)]

############################################################################
############################################################################
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

n,m = [int(i) for i in readline().split()]
d = [int(i) for i in readline().split()]

g = [[] for _ in range(n)]
a = map(int,read().split())

for i,(u,v) in enumerate(zip(a,a)):
    u -= 1; v -= 1
    g[u].append((v,i))
    g[v].append((u,i))

INF = 10**9
ans = [INF]*m #辺のコスト

UF = UnionFind(2*n+1) #二部グラフ構成のため

dd = [(c,i) for i,c in enumerate(d)]
dd.sort()

"""
コストが小さい順に、以下を行う
　コスト以下の点があれば、辺を結び、breakする
　なければアウト
"""
for c,idx in dd:
    for (v,j) in g[idx]:
        if d[v] <= c:
            UF.merge(v,idx+n)
            UF.merge(v+n,idx)
            ans[j] = c
            break
    else:
        print(-1)
        exit()

#UF に超頂点を加えて、二部グラフの塗分けをする
s = []
T = 2*n
for i in range(n):
    if UF.issame(T,i):
        s.append("W")
    elif UF.issame(T,i+n):
        s.append("B")
    else:
        s.append("W")
        UF.merge(T,i)
                
print("".join(s))
print(*ans,sep="\n")

    


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

int main()
{
	for (double a, b, c, d, e, f, x, y; cin >> a >> b >> c >> d >> e >> f; cout << fixed << setprecision(3) << x << ' '  << y << endl) {
		int tmp;
		x = ((c*e - b*f) ? (c*e - b*f) / (a*e - b*d) : 0.0000);
		if (x < 0) {
			x -= 0.0005;
		}
		else if (x>0) {
			x += 0.0005;
		}
		x = int(x * 1000) / 1000.0;
		y = ((a*f - c*d) ? (a*f - c*d) / (a*e - b*d) : 0.0000);
		if (y > 0) {
			y += 0.0005;
		}
		else if (y < 0) {
			y -= 0.0005;
		}
		y = int(y * 1000) / 1000.0;
	}
	return 0;
}

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

using namespace std;
const int maxn = 1e5+10;
int cnt[maxn];
typedef long long ll;
ll qsm(ll a,ll b,ll mod){ll ans= 1;while(b){if(b&1)ans = ans * a %mod;b/=2;a= a *  a %mod;}return ans;}
int main(){
    cnt[0] = 0; 
    int n;
    cin >> n;
    string a;
    cin >> a;
    long long  ans = 0;
    for(int i = 0;i<a.size();i++)if(a[i] == '1')ans++;
    long long temp1 = 0;
    long long temp2 = 0;
    for(int i = 1;i <=ans;i++){
        int temp = i;
        int k = 0;
        while(temp){
            if(temp %2)k++;
            temp/=2;
        }
        if(i % k == 0)cnt[i] = 1;
        else cnt[i] = 1+cnt[i%k];
        // cout << cnt[i] << endl;
    }

    for(int i = 0;i<a.size();i++){
        temp1  = (temp1*2) %(ans+1);
        if(ans >= 2 )temp2  = (temp2*2) %(ans-1);
        if(a[i] == '1')temp1++,temp2++;
        temp1%=(ans+1);
        if(ans >=2)temp2%=(ans-1);
    }

    for(int i = 0;i <n;i++){
        if(a[i] == '0'){
            // cout << (temp1 + qsm(2,n-i-1,ans+1)) % (ans+1) << endl;
            cout << cnt[(temp1 + qsm(2,n-i-1,ans+1)) % (ans+1)]+1 << endl;
        }
        else {
            if(ans == 1)cout << 0 << endl;
            else if(ans == 2)cout << 1 << endl;
            else cout << cnt[((temp2 - qsm(2,n-i-1,ans-1) + ans-1) %(ans-1))]+1 << endl;
        }
    }
    // system("pause");
}

Measured memory_bytes: 4140
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
 
public class Main {
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    List<Integer> xList = new ArrayList<>();
    for(int i = 0;i < N;i++){
      xList.add(scanner.nextInt());
    }
    int maxv = 0;
    for(int v : xList){
      if(v > maxv)maxv = v;
    }
    List<Integer> sumList = new ArrayList<>();
      for(int k = 0;k < maxv + 10;k++){
      int sum = 0;
      for(int x : xList){
        sum = sum + (int)Math.pow((x - k),2);
      }
        sumList.add(sum);
    }
    int miniSum = sumList.get(0);
    for(int sum : sumList){
     if(sum < miniSum)miniSum = sum;
    }
    System.out.println(miniSum);
  }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
signed main(){
  int N;
  cin>>N;
  int n=sqrt(N);
  cout<<n*n;
  }


Measured memory_bytes: 256
N = int(input())
A = [int(input()) for _ in range(N)]
ans = 0
for i in range(N):
    ans += A[i] // 2
    A[i] %= 2
    if i < N - 1:
        if A[i] * A[i + 1] > 0:
            ans += 1
            A[i] = 0
            A[i+1] -= 1
print(ans)

Measured memory_bytes: 80780
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    k--;
    for(int i=0;i<n;i++){
	  	if(i==k){
		  s[i]=tolower(s[i]);	
		}
	}
	cout<<s<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
  int n;
  cin>>n;
  int a[n];
  for(int i(0);i<n;i++){
    cin>>a[i];
  }
  int b(1);
  int cnt(0);
  for(int i(0);i<n;i++){
    b=a[b-1];
    cnt++;
    if(b==2)break;
  }
  if(cnt==n)cout<<-1<<endl;
  else cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 640
from math import log10

n = int(input())
m = int(log10(n)) + 1

ans = 0

def dfs(i, s):
    if i == m:
        if not '0' in str(int(s)) and '3' in s and '5' in s and '7' in s and int(s) <= n:
            return 1
        return 0
    return dfs(i+1, s + '0') + dfs(i+1, s + '3') + dfs(i+1, s + '5') + dfs(i+1, s + '7')

print(dfs(0, ''))

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

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

using namespace std;
using lint=long long;

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

	if(k<=a){
		cout<<a-k<<' '<<b<<'\n';
	}
	else{
		cout<<"0 "<<max(a+b-k,0LL)<<'\n';
	}

	return 0;
}


Measured memory_bytes: 256
// ProblemURL : https://atcoder.jp/contests/abc090/tasks/abc090_b
// ---------------------------------------------
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	isPalindrome := func(i int) bool {
		return i/10000 == i%10 && i/1000%10 == i/10%10
	}
	ans := 0
	for i := a; i <= b; i++ {
		if isPalindrome(i) {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll a[310][310];
ll d[310][310];
int main(){
    cin>>N;
    ll ans=0;
    for(ll i=0;i<N;i++){
        for(ll j=0;j<N;j++){
            cin>>a[i][j];
            d[i][j]=a[i][j];
            if(j>i)ans+=a[i][j];
        }
    }
    for(ll k=0;k<N;k++){
        for(ll i=0;i<N;i++){
            for(ll j=0;j<N;j++){
                if(d[i][j]>d[i][k]+d[k][j]){
                    cout<<-1<<endl;
                    return 0;
                }else if(i!=k && k!=j && d[i][j]==d[i][k]+d[k][j]){
                    if(a[i][j]==d[i][j]){
                        ans-=a[i][j];
                        a[i][j]=-1;
                        a[j][i]=-1;
                    }
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
//cout << setprecision(20) << 

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        a[i] -= i;
    }
    sort(a.begin(), a.end());
    const ll bCand[3] = {a[n / 2], a[n / 2 + 1], a[n / 2 - 1]};

    ll res[3] = {0, 0, 0};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            res[j] += abs(a[i] - bCand[j]);
        }
    }
    cout << min(min(res[0], res[1]), res[2]) << endl;
}

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

int main(){

  int q, a, b;
  string str, tmp, command, p;

  cin>>str;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>command>>a>>b;
    if(command=="print"){
      cout<<str.substr(a, b-a+1)<<endl;
    }else if(command=="reverse"){
      tmp=str.substr(a, b-a+1);
      reverse(tmp.begin(), tmp.end());
      str=str.replace(a, b-a+1, tmp);
    }else if(command=="replace"){
      cin>>p;
      str=str.replace(a, b-a+1, p);
    }
  }

  return 0;
}

Measured memory_bytes: 3228
#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
    int n,num;
    char mark;
    bool cards[4][14];
    
    for(int s=0;s<4;s++){
        for(int r=1;r<=13;r++){
            cards[s][r]=0;
        }    
    }
    scanf("%d",&n);
    for(int k=0;k<n;k++){
            scanf("%s %d",&mark,&num);
            if(mark=='S') cards[0][num]=1;
            if(mark=='H') cards[1][num]=1;
            if(mark=='C') cards[2][num]=1;
            if(mark=='D') cards[3][num]=1;
    }
    for(int s=0;s<4;s++){
        for(int r=1;r<=13;r++){
            if(cards[s][r]) continue;
            if(s==0) mark='S';
            if(s==1) mark='H';
            if(s==2) mark='C';
            if(s==3) mark='D';
            cout <<mark<<" "<<r<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int H,W;
string A[100];
bool IH[100], IW[100];

int main() {
  cin >> H >> W;
  rep(i,H) cin >> A[i];

  rep(i,H) rep(j,W) if(A[i][j] == '#') {
    IH[i] = true;
    IW[j] = true;
  }

  rep(i,H) rep(j,W) {
    if(IH[i] && IW[j]) cout << A[i][j];
    if(IH[i] && j == W - 1) cout << '\n';
  }
}


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


bool s,w,e,n;
string st;
int main()
{
	cin>>st;
	for(int i=0; i<st.size(); ++i)
	{
		if(st[i]=='S')
			s=1;
		if(st[i]=='N')
			n=1;
		if(st[i]=='W')
			w=1;
		if(st[i]=='E')
			e=1;
	}
	if(s+n==1 || e+w==1)
		cout<<"No";
	else
		cout<<"Yes";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[3001][3001];

ll dop(ll a[],int i,int n,bool b)
{
	if(dp[i][n]!=0)return dp[i][n];
	if(i==n)
	{
		if(b)return a[i-1];
		else return (-1)*a[i-1];
	}
	if(b)
	{
		dp[i][n]=max(a[i-1]+dop(a,i+1,n,!b),a[n-1]+dop(a,i,n-1,!b));
		
	}
	else
		dp[i][n]=min(dop(a,i+1,n,!b)-a[i-1],dop(a,i,n-1,!b)-a[n-1]);
	
	return dp[i][n];
}
int main()
{
	ll n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		memset(dp[i+1],0,(n)*(sizeof(int)));
	}
	ll ans=dop(a,1,n,true);
	cout<<ans<<endl;
	
}

Measured memory_bytes: 70528
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

int n, q, l, r, DP[MAXN];
char s[MAXN];

int main() {
    scanf("%d%d", &n, &q);
    scanf(" %s", s);

    DP[n - 2] = (s[n - 2] == 'A' && s[n - 1] == 'C');

    for (int i = n - 3; i >= 0; i--) {
        DP[i] = max(DP[i + 1], DP[i + 2] + (s[i] == 'A' && s[i + 1] == 'C'));
    }
    
    while (q--) {
        scanf("%d%d", &l, &r);
        printf("%d\n", DP[l - 1] - DP[r - 1]);
    }

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define MAX 10000000
using namespace std;
int criba[MAX+1];
int divs(int n)
{
	int tmp = 0, ans = 1,prev = 1;
	while(n^1)
	{
		if(tmp&&prev!=criba[n])
			ans *= tmp+1,tmp = 0;
		prev = criba[n];
		n /= criba[n];
		tmp++;
	}
	if(tmp)
		ans *= tmp+1;
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	criba[1] = 1;
	for(int i=2;i<=n;++i)
	{
		if(!criba[i])
		{
			int j = i;
			while(j<=n)
			{
				criba[j] = i;
				j += i;
			}
		}
	}	
	long long ans = 0;
	for(int i=1;i<=n;++i)
		ans += i*1LL*divs(i);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 42724
from sys import stdin

n,q=map(int,input().split())
s=input()
l = [stdin.readline().rstrip().split() for _ in range(q)]

t=[0]*(n+1)
for i in range(n):
    t[i+1]=t[i]+(1 if s[i:i+2]=="AC" else 0)
for j,k in l:
    print(t[int(k)-1]-t[int(j)-1])

Measured memory_bytes: 37104
#include <cstdio>
#include <iostream>
using namespace std;
int main (void)
{
    int a,b;
    cin>>a>>b;
    if(a>=13)cout<<b<<endl;
    else if(a>=6&&a<=12)cout<<b/2<<endl;
    else if(a<6) cout<<"0"<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a.insert(0,0)
a.insert(n+1,0)
total=0
for i in range(1,n+2):
    total+=abs(a[i]-a[i-1])
for i in range(1,n+1):
    ans=total-(abs(a[i]-a[i-1])+abs(a[i+1]-a[i]))+abs(a[i+1]-a[i-1])
    print(ans)

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

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
typedef pair<int,int> PI; 
typedef pair<LL,LL> PLL;
typedef unsigned long long ULL;
typedef pair<double,double> PD;

#define FOR(x, b, e) for(int x = b; x<= (e); x++)
#define FORD(x, b, e) for(int x = b; x>= (e); x--)
#define REP(x, n) for(int x = 0; x<(n); ++x)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())

#define PB push_back
#define IN insert
#define ST first
#define ND second
#define INF 2000000011
#define MOD 1000000007

#define MAXS 20123

LL dp[MAXS];

struct S{
	int w,v,s;
	void read(){
		cin>>w>>s>>v;
	}	
};

bool comp_(S s1,S s2){
	return s1.w+s1.s<s2.s+s2.w;
}

int n;

int main(){	//TODO: ogarnac exchanging arguments
	
	ios::sync_with_stdio(0); cin.tie(0);
	cin>>n;
	
	vector<S> zb(n);
	
	REP(I,n)
		zb[I].read();
	
	sort(ALL(zb),comp_);
	
	for(auto block : zb){
		FORD(k,block.s,0)
			dp[k+block.w]=max(dp[k+block.w],dp[k]+block.v);
	}
	
	LL odp=0;
	REP(i,MAXS)
		odp=max(odp,dp[i]);
	
	cout<<odp;
	
	
	return 0;
}




Measured memory_bytes: 384
import java.io.PrintWriter;
import java.util.Scanner;

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

        int n = Integer.parseInt(sc.next());
        int ans = 1;
        for(int i = 1; i < n; i++){
            if(i * i <= n) ans = i * i;
            else break;
        }
        out.println(ans);
        out.flush();
        sc.close();
    }
}

Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>

using namespace std;


int main(void){

	int n;
	int a, b, c;
	int mn;
	cin >> n;

	if (n == 2){
		cin >> a >> b;
		mn = min(a, b);
	}
	else{
		cin >> a >> b >> c;
		mn = min(a, min(b, c));
	}

	for (int i = 1; i <= mn; i++){
		if (n == 2){
			if (a%i == 0 && b%i == 0) cout << i << endl;
		}
		else if (a%i == 0 && b%i == 0 && c%i == 0) cout << i << endl;
	}
	return 0;
}

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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


signed main(){

	int H, W, N;
	cin >> H >> W >> N;
	map<P,int> m;
	rep(i, N){
		int a, b;
		cin >> a >> b;
		for (int x = -1; x <= 1; x++)
			for (int y = -1; y <= 1; y++){
				m[P(a + x, b + y)]++;
			}
	}
	int ans[10];
	rep(i, 10) ans[i] = 0;
	for (auto i = m.begin(); i != m.end(); i++){
		P p = i->first;
		if (p.first >= 2 && p.first <= H-1 && p.second >= 2 && p.second <= W-1){
			ans[i->second]++;
		}
	}

	int sum = 0;
	for (int i = 1; i < 10; i++) sum += ans[i];
	cout << (H - 2)*(W - 2) - sum << endl;
	for (int i = 1; i < 10; i++)
		cout << ans[i] << endl;

	return 0;
}

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


int main()
{
  int n;
  cin >> n;
  n %= 10;
  if(n == 3) cout << "bon" << endl;
  else if(n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
  
  
  return 0;
}

Measured memory_bytes: 3636
def search(num, moji):
    num2str = str(num)
    for i, n in enumerate(moji):
        if n == num2str:
            return moji[i+1:], True
    return "", False


a = int(input())
b = input()
buf = b[:]
result = 0
for i in range(10):
    buf, flag = search(i, b[:])
    if flag:
        for j in range(10):
            buf2, flag2 = search(j, buf)
            if flag2:
                for k in range(10):
                    _, flag3 = search(k, buf2)
                    if flag3:
                        result += 1
print(result)


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(ll i=(ll)(n); i<=(ll)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

#define POW5(x) (x*x*x*x*x)

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x; cin>>x;
    FOR(a,-200,200)FOR(b,-200,200){
        if (POW5(a)-POW5(b)==x){
            cout<<a<<" "<<b<<"\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3652
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
const long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
   int a,b,c;
   cin>>a>>b>>c;
   if(b-a==c-b){
       cout<<"YES"<<endl;
   }
   else{
       cout<<"NO"<<endl;
   }

}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
typedef long long ll;
typedef vector<ll> vi;
 
vi solve(ll a,ll b,ll c) {
  double D=b*b-4*a*c;
  if (D < 0) return vi();
  ll rD=sqrt(D+0.1);
  if (rD*rD!=D) return vi();
  ll p=2*a, r=2*a;
  ll q=b+rD;
  ll s=b-rD;
  ll gpq = __gcd(p,abs(q)), grs = __gcd(r,abs(s));
  p/=gpq;
  q/=gpq;
  r/=grs;
  s/=grs;
 
  if (p<r || (p==r&&q<s)){
    swap(p,r);
    swap(q,s);
  }
  return vi{p,q,r,s};
}
 
int main() {
  ll a,b,c;
  while (cin >> a >> b >> c && a) {
    vi v=solve(a,b,c);
    if (v.size()){
      for(int i=0;i<4;i++)cout<<v[i]<<(i==3?'\n':' ');
    }
    else cout << "Impossible" << endl;
  }
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string s;
string a="keyence";

int main(void){
    cin >> s;
    int n=s.size();
    bool flag=false;
    for(int i=0;i<n;i++){
        int cnt=0;
        bool fo=false;
        for(int j=0;j<i;j++){
            if(cnt<a.size() && s[j]==a[j])cnt++;
            else{
                fo=true;
            }
        }
        if(fo)continue;
        for(int j=i;j<n;j++){
            int cnt2=cnt;
            bool ci=false;
            for(int k=j;k<n;k++){
                if(cnt2<a.size() && s[k]==a[cnt2])cnt2++;
                else{
                    ci=true;
                }
            }
            if(!ci && cnt2==a.size()){
                flag=true;
            }
        }
    }
    printf("%s\n",flag?"YES":"NO");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

signed main(){

  int n; cin >> n;
  map<string, int> mp;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    mp[s]++;
  }
  cout << mp.size() << endl;

  return 0;
}

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

const ll MAXN = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;

ll N, tmp=0;
vector<ll> t, v;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll T;
        cin >> T;
        t.push_back(T);
        tmp += T;
    }
    for(int i=0;i<N;i++) {
        ll V;
        cin >> V;
        v.push_back(V);
    }
    ll nowt = 0;
    vector<double> vmax(2*tmp+1, 1000.0);
    vmax[0] = vmax[2*tmp] = 0.0;
    for(int i=0;i<N;i++) {
        if(i==0) vmax[nowt] = 0.0;
        else vmax[nowt] = v[i-1];
        for(int j=0;j<t[i];j++) {
            ll t1 = nowt + 2*j;
            ll t2 = nowt + 2*j + 1;
            vmax[t1] = min(vmax[t1], (double)v[i]);
            vmax[t2] = min(vmax[t2], (double)v[i]);
        }
        nowt += 2*t[i];
    }
    for(int i=0;i<2*tmp;i++) {
        vmax[i+1] = min(vmax[i+1], vmax[i]+0.5);
    }
    for(int i=2*tmp-1;i>=0;i--) {
        vmax[i] = min(vmax[i], vmax[i+1]+0.5);
    }
    double ans = 0.0;
    for(int i=0;i<2*tmp;i++) {
        ans += (vmax[i]+vmax[i+1]) / 4.0;
    }
    cout << fixed << setprecision(8) << ans << endl;
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int a,b,c,d;
  cin>>a>>b>>c>>d;

  int ct=0;
  bool A=false;
  bool B=false;

  rep(i,101){
    if(i==a) A=true;
    if(i==c) B=true;
    if(i==b) A=false;
    if(i==d) B=false;

    if(A and B) ++ct;
  }

  cout<< ct<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct UnionFind
{
private:
    vector<int> par;
    int n;

public:
    UnionFind(int size)
    {
        n = size;
        par.assign(n, -1);
    }
    int root(int node)
    {
        if (par[node] < 0)
            return node;
        return par[node] = root(par[node]);
    }
    bool unite(int a, int b)
    {
        a = root(a);
        b = root(b);
        if(a == b)
            return false;
        if(par[a] > par[b])
            swap(a, b);
        par[a] += par[b];
        par[b] = a;
        return true;
    }
    bool same(int a, int b)
    {
        return root(a) == root(b);
    }
};
int main(){
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    int x, y, z;
    for(int i = 0; i < m; i++){
        cin >> x >> y >> z;
        x--;
        y--;
        uf.unite(x, y);
    }
    set<int> s;
    for(int i = 0; i < n; i++){
        s.insert(uf.root(i));
    }
    cout << s.size() << "\n";
}


Measured memory_bytes: 8272
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N,M;
  cin >> N >> M;
  vector<string> S(N);
  rep(i,N)  cin >> S.at(i);

  mf_graph<int> graph(N*M+2);
  int s = N*M;
  int t = N*M+1;

  rep(i,N){
    rep(j,M){
      if(S.at(i).at(j) == '#')  continue;
      int v = i*M+j;
      if((i+j)%2 == 0)  graph.add_edge(s, v, 1);
      else  graph.add_edge(v, t, 1);
    }
  }

  rep(i,N){
    rep(j,M){
      if((i+j)%2 == 1 || S.at(i).at(j) == '#')  continue;
      int v0 = i*M+j;
      if(i-1 >= 0 && S.at(i-1).at(j) != '#'){
        int v1 = (i-1)*M+j;
        graph.add_edge(v0, v1, 1);
      }
      if(i+1 < N && S.at(i+1).at(j) != '#'){
        int v1 = (i+1)*M+j;
        graph.add_edge(v0, v1, 1);
      }
      if(j-1 >= 0 && S.at(i).at(j-1) != '#'){
        int v1 = i*M+(j-1);
        graph.add_edge(v0, v1, 1);
      }
      if(j+1 < M && S.at(i).at(j+1) != '#'){
        int v1 = i*M+(j+1);
        graph.add_edge(v0, v1, 1);
      }
    }
  }

  cout << graph.flow(s, t) << endl;

  auto edges = graph.edges();
  for(auto e : edges){
    if(e.from == s || e.to == t || e.flow == 0) continue;
    int i0 = e.from/M;
    int j0 = e.from%M;
    int i1 = e.to/M;
    int j1 = e.to%M;

    if(i0 == i1+1){
      S.at(i0).at(j0) = '^';
      S.at(i1).at(j1) = 'v';
    }
    else if(i0 == i1-1){
      S.at(i0).at(j0) = 'v';
      S.at(i1).at(j1) = '^';
    }
    else if(j0 == j1+1){
      S.at(i0).at(j0) = '<';
      S.at(i1).at(j1) = '>';
    }
    else if(j0 == j1-1){
      S.at(i0).at(j0) = '>';
      S.at(i1).at(j1) = '<';
    }
  }
  rep(i,N)  cout << S.at(i) << endl;

  return 0;
}

Measured memory_bytes: 5532
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string S;
    cin >> S;
    int N = S.size();
    int ans = 0;

    for(int i=0;i<(1<<(N-1));i++){
      int num = S[0] - '0';
      for(int j=0;j<N-1;j++){
        if((1<<j) & i){
          ans += num;
          num = S[j+1] - '0';
        }
        else{
          num *= 10;
          num += S[j+1] - '0';
        }
      }
      ans += num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
 
ans = [-1] * n
 
for s, c in sc:
    t = s - 1
    if ans[t] == -1:
        ans[t] = c
    elif ans[t] != c:
        print(-1)
        exit()
 
if n == 1:
    if ans[0] == -1:
        ans[0] = '0'
    else:
        ans[0] = str(ans[0])
elif ans[0] == 0:
    print(-1)
    exit()
else:
    ans[0] = str(max(1, ans[0]))
for i in range(1, n):
    ans[i] = str(max(0, ans[i]))
 
print(''.join(ans))

Measured memory_bytes: 3064
#include<cstdio>
int vis[200005];

void preWork(int n){
    vis[1] = 1;
    for(int i = 2; i <= n; i++){
        if(!vis[i]){
            for(int j = 2*i; j <= n; j+=i) vis[j] = 1;
        }
    }
}

int main(){
    preWork(200000);
    int x;
    scanf("%d",&x);
    while(vis[x]) x++;
    printf("%d\n",x);
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define MODD 1000000007LL
#define MAX_SIZE 400001
#define MAX_N 100001
using namespace std;
typedef long long ll;
typedef long double ld;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return a % MODD; }

ll comp(ll& a, ll& b){
    return a>b;
}

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}

string _reverse(string s){
    ll n=s.length();
    for(ll i=0, j=n-1; i<j; i++, j--){
        char t=s[i];
        s[i]=s[j];
        s[j]=t;
    }
    return s;
}

void swap(char &a, char &b){
    char t=a;
    a=b;b=t;
}

int main(){





    // #ifndef ONLINE_JUDGE 

    // // For getting input from input.txt file 
    // freopen("input.txt", "r", stdin); 

    // // Printing the Output to output.txt file 
    // freopen("output.txt", "w", stdout); 
    // #endif 

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,a,b;
    cin>>n>>a>>b;
    ll ans=0;
    ll diff=b-a;

    // if(n%2==1){
    //     cout<<"n odd"<<endl;
    // }
    // else{
    //     cout<<"n even"<<endl;
    // }

    if(b%2==a%2){
        ans=diff/2LL;
    }
    else{
        // ans=min(b-1LL, n-a);
        ans=min(a-1, n-b)+diff/2;
        ans+=1LL;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int n,m,k,ans;
char s[9][9];
int main(){
	n=read(),m=read(),k=read();
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			cin>>s[i][j];
		}
	}
	for(int r=0;r<(1<<n);r++){
		for(int c=0;c<(1<<m);c++){
			int cnt=0;
			for(int i=0;i<n;i++){
				for(int j=0;j<m;j++){
					if(((r>>i)&1)==0&&((c>>j)&1)==0&&s[i][j]=='#') ++cnt;
				}
			}
			if(cnt==k) ++ans;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3740
import sys
input=sys.stdin.readline

n,m=map(int,input().split())
S=[]
now=0
for i in range(m):
    a=int(input())
    if i==0 and a==1:
        now=a
        continue
    elif i==0:
        S.append(a-now)
        now=a
        continue
    elif i!=0 and a-now==1:
        print(0)
        sys.exit()
    S.append(a-now-1)
    now=a

if m==0:
    S.append(n-now+1)
else:
    S.append(n-now)

mod=10**9+7
N=10**5+10
g1=[1,1]
g2=[1,1]
inverse=[0,1]

for i in range(2,N+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1])%mod)

def cmb(n,r):
    if (r<0 or r>n):
        return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod


ans=1

for s in S:
    cnt=0
    for i in range((s-1)//2+1):
        cnt+=cmb(s-i-1,i)
        cnt%=mod
    ans=ans*cnt%mod

print(ans%mod)

Measured memory_bytes: 60892
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int n; cin >> n;
    vector<pair<int, int>> ab(n);
    rep(i, n) {
        cin >> ab[i].second >> ab[i].first;
    }
    sort(ALL(ab));
    int time = 0;
    int flg = 0;
    rep(i, n) {
        time += ab[i].second;
        if(ab[i].first < time) flg = 1;
    }
    if(flg) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn=1e6+10;
const int mo=2019;
int n,p[maxn],num[maxn];
char s[maxn];
long long ans;
int po(int a,int b)
{
	if (b==1) return a%mo;
	int c=po(a,b/2);
	if (b&1) return c*c%mo*a%mo;else return c*c%mo;
}
int main()
{
	scanf("%s",s+1); n=strlen(s+1); int sum=0; num[0]++;
	for (int i=1;i<=n;i++)
	{
		sum=(sum+(s[i]-'0')*po(10,n-i+1)%mo)%mo;
		ans+=num[sum]; num[sum]++;
	}
	printf("%lld\n",ans);
return 0;	
}

Measured memory_bytes: 4004
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		Integer[] A = new Integer[N];
		HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
		for(int i=0;i<N;i++) {
			A[i] = sc.nextInt();
			if (map.containsKey(A[i])) map.put(A[i],map.get(A[i])+sc.nextInt());
			else map.put(A[i], sc.nextInt());
		}
		Arrays.sort(A);
		long ret = 0;
		int sum = 0;
		int count = 0;
		while(sum<M) {
			int a = A[count];
			int b = map.get(a);
			if(sum + b >= M) {
				ret+= (long)(M-sum)*a;
				break;
			}
			else {
				ret += (long)a*b;
				sum += b;
				count++;
				map.put(a,0);
			}
		}

		System.out.println(ret);
	}
}


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

main(){
  string s;
  cin>>s;
  int flag = 0;
  
  for(int i= 0;i<2;i++){
    if((s[i]==s[i+1]) && (s[i] == s[i+2]))flag=1;
  }
  
  if(flag == 1)cout<< "Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 7;
const int INF = 1 << 29;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while (A > 0 & C > 0) {
    C -= B;
    A -= D;
  }
  if (C <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3656
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	num1 := 0.0
	for i := 1; i <= n; i++ {
		var ai float64
		fmt.Scan(&ai)
		num1 += 1.0 / ai
	}
	fmt.Println(1.0 / num1)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

/**
 * sheep => 0, wolf => 1
 */

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

  function<int(int, int, int)> retA = [](int a, int self, char c){
    if(self == 0 && c == 'o' || self == 1 && c == 'x')
      return a;
    else
      return 1-a;
  };

  REP(i, 2)REP(j, 2){
    vector<int> c(n);
    c[0] = i; c[1] = j;

    FOR(i, 1, n-1) c[i+1] = retA(c[i-1], c[i], s[i]);

    if(retA(c[n-2], c[n-1], s[n-1]) == c[0] && retA(c[1], c[0], s[0]) == c[n-1]){
      for(const auto& a: c){
        cout << (a? 'W': 'S');
      }
      cout << endl;
      
      return 0;
    }
  }

  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 1016
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  string s; readV(s);
  string t; readV(t);

  auto n = s.length;
  foreach (_; 0..n) {
    if (s == t) {
      writeln("Yes");
      return;
    }
    s = s[$-1] ~ s[0..$-1];
  }

  writeln("No");
}


Measured memory_bytes: 256
package main
 
import(
  "fmt"
  "bufio"
  "os"
  "strings"
  "strconv"
  "log"
)
 

func main(){
    a := 0
    b := 0
    fmt.Scan(&a)
    fmt.Scan(&b)
    fmt.Println(a*b,a*2+b*2)
}


var sc = bufio.NewScanner(os.Stdin)

func Rr() []string {
  sc.Scan()
  slice := strings.Split(sc.Text(), " ")
  return slice
}



//入力関係ライブラリ(Atcoder:yamanobori_oldさんのもの)
func make_liner(maxByte int) *bufio.Scanner {
  liner := bufio.NewScanner(os.Stdin)
  liner.Buffer(make([]uint8, 0, 8192), maxByte)
  return liner
}
func word_spliter() *bufio.Scanner {
  words := make_liner(8192) 
  words.Split(bufio.ScanWords)
  return words
}

func eGetLine(r *bufio.Scanner) string {
  if r.Scan() {
    return r.Text()
  }
  err := r.Err()
  if err != nil {
    log.Fatal(err)
  }
  // EOF
  return ""
}

func eGetInt(r *bufio.Scanner) int {
  line := eGetLine(r)
  return eAtoi(line)
}

func eAtoi(s string) int {
  n, err := strconv.Atoi(s)
  if err != nil {
    log.Fatal(err)
  }
  return n
}


Measured memory_bytes: 1088